Changeset 428834d
- Timestamp:
- Jan 9, 2008, 2:17:57 PM (17 years ago)
- Branches:
- master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 369479d
- Parents:
- c10fef0
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
keymap.c
r47519e1b r428834d 5 5 6 6 /* returns 0 on success */ 7 int owl_keymap_init(owl_keymap *km, char *name, char *desc, void (*default_fn)( int), void (*prealways_fn)(int), void (*postalways_fn)(int))7 int owl_keymap_init(owl_keymap *km, char *name, char *desc, void (*default_fn)(owl_input), void (*prealways_fn)(owl_input), void (*postalways_fn)(owl_input)) 8 8 { 9 9 if (!name || !desc) return(-1); … … 151 151 } 152 152 153 owl_keymap *owl_keyhandler_create_and_add_keymap(owl_keyhandler *kh, char *name, char *desc, void (*default_fn)( int), void (*prealways_fn)(int), void (*postalways_fn)(int))153 owl_keymap *owl_keyhandler_create_and_add_keymap(owl_keyhandler *kh, char *name, char *desc, void (*default_fn)(owl_input), void (*prealways_fn)(owl_input), void (*postalways_fn)(owl_input)) 154 154 { 155 155 owl_keymap *km; … … 202 202 /* processes a keypress. returns 0 if the keypress was handled, 203 203 * 1 if not handled, -1 on error, and -2 if j==ERR. */ 204 int owl_keyhandler_process(owl_keyhandler *kh, gunicharj)204 int owl_keyhandler_process(owl_keyhandler *kh, owl_input j) 205 205 { 206 206 owl_keymap *km; … … 214 214 215 215 /* temporarily disallow C-`/C-SPACE until we fix associated bugs */ 216 if (j ==ERR || j==0) {216 if (j.ch == ERR || j.ch == 0) { 217 217 return(-1); 218 218 } … … 224 224 225 225 /* deal with ESC prefixing */ 226 if (!kh->in_esc && j ==27) {226 if (!kh->in_esc && j.ch == 27) { 227 227 kh->in_esc = 1; 228 228 return(0); 229 229 } 230 230 if (kh->in_esc) { 231 j = OWL_META(j);231 j.ch = OWL_META(j.ch); 232 232 kh->in_esc = 0; 233 233 } 234 234 235 kh->kpstack[++(kh->kpstackpos)] = j ;235 kh->kpstack[++(kh->kpstackpos)] = j.ch; 236 236 if (kh->kpstackpos >= OWL_KEYMAP_MAXSTACK) { 237 237 owl_keyhandler_reset(kh); … … 260 260 } else if (match == 2) { /* exact match */ 261 261 /* owl_function_debugmsg("processkey: found exact match in %s", km->name); */ 262 owl_keybinding_execute(kb, j );262 owl_keybinding_execute(kb, j.ch); 263 263 owl_keyhandler_reset(kh); 264 264 if (km->postalways_fn) { -
keypress.c
r948b942 r428834d 148 148 } 149 149 if (!*kb) { 150 if (j &OWL_META(0)) {150 if (j & OWL_META(0)) { 151 151 strcat(kb, "M-"); 152 152 j &= ~OWL_META(0); … … 163 163 strcat(kb, kb2); 164 164 } 165 165 166 } 166 167 if (!*kb) { -
keys.c
r8938188 r428834d 294 294 /****************************************************************/ 295 295 296 void owl_keys_recwin_prealways( int j) {296 void owl_keys_recwin_prealways(owl_input j) { 297 297 /* Clear the message line on subsequent key presses */ 298 298 owl_function_makemsg(""); 299 299 } 300 300 301 void owl_keys_editwin_default( int j) {301 void owl_keys_editwin_default(owl_input j) { 302 302 owl_editwin *e; 303 if (NULL != (e=owl_global_get_typwin(&g))) { 304 owl_editwin_process_char(e, j); 303 if (NULL != (e=owl_global_get_typwin(&g)) 304 && j.ch < 0x100) { 305 owl_editwin_process_char(e, j.uch); 305 306 } 306 307 } 307 308 308 void owl_keys_editwin_postalways( int j) {309 void owl_keys_editwin_postalways(owl_input j) { 309 310 owl_editwin *e; 310 if (NULL != (e=owl_global_get_typwin(&g))) { 311 owl_editwin_post_process_char(e, j); 311 if (NULL != (e=owl_global_get_typwin(&g)) 312 && j.ch < 0x100) { 313 owl_editwin_post_process_char(e, j.uch); 312 314 } 313 315 owl_global_set_needrefresh(&g); 314 316 } 315 317 316 void owl_keys_popless_postalways( int j) {318 void owl_keys_popless_postalways(owl_input j) { 317 319 owl_viewwin *v = owl_global_get_viewwin(&g); 318 320 owl_popwin *pw = owl_global_get_popwin(&g); … … 323 325 } 324 326 325 void owl_keys_default_invalid( int j) {326 if (j ==ERR) return;327 if (j ==410) return;327 void owl_keys_default_invalid(owl_input j) { 328 if (j.ch==ERR) return; 329 if (j.ch==410) return; 328 330 owl_keyhandler_invalidkey(owl_global_get_keyhandler(&g)); 329 331 } -
owl.c
rc10fef0 r428834d 71 71 owl_popwin *pw; 72 72 int ret, initialsubs, debug, argcsave, followlast; 73 gunicharj;73 owl_input j; 74 74 int newmsgs, nexttimediff; 75 75 struct sigaction sigact; … … 546 546 * little bit, but otherwise do not. This lets input be grabbed 547 547 * as quickly as possbile */ 548 j=wgetch(typwin); 549 if (j == ERR 550 #ifdef KEY_RESIZE 551 || j == KEY_RESIZE 552 #endif 553 ) { 548 j.ch = wgetch(typwin); 549 if (j.ch == ERR) { 554 550 usleep(10000); 555 551 } else { 556 /* Pull in a full utf-8 character. */ 557 if (j & 0x80) { 558 char utf8buf[7]; 552 j.uch = '\0'; 553 if (j.ch >= KEY_MIN && j.ch <= KEY_MAX) { 554 /* This is a curses control character. */ 555 } 556 else if (j.ch > 0x7f && j.ch < 0xfe) { 557 /* Pull in a full utf-8 character. */ 559 558 int bytes, i; 560 memset(utf8buf,'\0',7); 561 utf8buf[0] = j; 562 563 if ((j & 0xc0) && (~j & 0x20)) bytes = 2; 564 else if ((j & 0xe0) && (~j & 0x10)) bytes = 3; 565 else if ((j & 0xf0) && (~j & 0x08)) bytes = 4; 566 else if ((j & 0xf8) && (~j & 0x04)) bytes = 5; 567 else if ((j & 0xfc) && (~j & 0x02)) bytes = 6; 559 char *utf8buf[7]; 560 memset(utf8buf, '\0', 7); 561 562 utf8buf[0] = j.ch; 563 564 if ((j.ch & 0xc0) && (~j.ch & 0x20)) bytes = 2; 565 else if ((j.ch & 0xe0) && (~j.ch & 0x10)) bytes = 3; 566 else if ((j.ch & 0xf0) && (~j.ch & 0x08)) bytes = 4; 567 else if ((j.ch & 0xf8) && (~j.ch & 0x04)) bytes = 5; 568 else if ((j.ch & 0xfc) && (~j.ch & 0x02)) bytes = 6; 568 569 else bytes = 1; 569 570 … … 572 573 } 573 574 if (g_utf8_validate(utf8buf, -1, NULL)) { 574 j = g_utf8_get_char(utf8buf);575 j.uch = g_utf8_get_char(utf8buf); 575 576 } 576 577 else { 577 j = ERR;578 j.ch = ERR; 578 579 } 579 580 } 581 else if (j.ch <= 0x7f) { 582 j.uch = j.ch; 583 } 584 580 585 owl_global_update_lastinputtime(&g); 581 586 /* find and activate the current keymap. -
owl.h
r9866c3a r428834d 272 272 } owl_variable; 273 273 274 typedef struct _owl_input { 275 int ch; 276 char utf8buf[8]; 277 gunichar uch; 278 } owl_input; 279 274 280 typedef struct _owl_fmtext { 275 281 int textlen; … … 511 517 owl_list bindings; /* key bindings */ 512 518 struct _owl_keymap *submap; /* submap */ 513 void (*default_fn)( int j); /* default action (takes a keypress) */514 void (*prealways_fn)( intj); /* always called before a keypress is received */515 void (*postalways_fn)( intj); /* always called after keypress is processed */519 void (*default_fn)(owl_input j); /* default action (takes a keypress) */ 520 void (*prealways_fn)(owl_input j); /* always called before a keypress is received */ 521 void (*postalways_fn)(owl_input j); /* always called after keypress is processed */ 516 522 } owl_keymap; 517 523
Note: See TracChangeset
for help on using the changeset viewer.