diff options
| -rw-r--r-- | TODO | 7 | ||||
| -rw-r--r-- | doc/editing_keys.txt | 13 | ||||
| -rw-r--r-- | src/edbox.c | 80 |
3 files changed, 83 insertions, 17 deletions
@@ -12,6 +12,13 @@ FujiChat features, we're almost at parity! Other stuff: +- Allow typing a character in the last edit box position. +- Make Start+A search backwards (from screen 7), since [server] + is the least interesting screen (we don't want it constantly + coming up first). +- Atari key should insert a ^B. Then the actual ^B keystroke can + do something else. +- ^B and ^F for back/forward one word in the editbox. - Server /ping command is iffy (see do_server_pong() in irc.c). - Bug: *no idea* how this happened. I typed /quit, then reconnected, and got "USER: not enough parameters" from the server. Can't diff --git a/doc/editing_keys.txt b/doc/editing_keys.txt index dfa6fd0..59b87bc 100644 --- a/doc/editing_keys.txt +++ b/doc/editing_keys.txt @@ -8,23 +8,24 @@ Shift-Clear or Ctrl-Clear: clear buffer and hide input box (show status) Left/Right arrows - move cursor Backspace - delete the character to the left of the cursor Ctrl-Del - delete the character under the cursor +Atari key - insert a ^B (meaning, toggle bold) +^U - delete to start of buffer +^K - kill (delete) to end of buffer. +^F or ctrl-shift-Up - move right by one word. +^B or ctrl-shift-Down - move left by one word. Future plans: -Shift + Ctrl + Up/Down arrows - history (if we can spare the RAM) -Up/Down arrows - move up/down by one line (40 chars) +History (if we can spare the RAM), maybe Start+Up/Down? Up arrow *in an empty inputbox* - bring up last entered command. Can coexist with regular use of Up for movement. ^Y, Shift-Insert - paste (^K, ^U, ^W fill a paste buffer; need RAM) Ctrl-Insert - toggle insert/typeover (does anyone care about this?) -Atari key - insert a ^B (meaning, toggle bold) -^U should be "delete to start of buffer", not delete whole line. -^K - kill (delete) to end of buffer. -Ctrl + Shift + Left/Right - move back/forward one word (space-separated). Tab - tab completion. For [server], complete channels. For [private], complete nicks that have PM'ed us or that we have PM'ed. For channels, complete channel nicks (we'll never have enough RAM to have full lists; search back through screen memory is how it'll work) +Shift-Return: Maybe... send buffer but do not clear it. The glyphs for these will appear as inverse letters, but will actually be the appropriate low ASCII characters: diff --git a/src/edbox.c b/src/edbox.c index 4847713..6dfaaca 100644 --- a/src/edbox.c +++ b/src/edbox.c @@ -25,7 +25,7 @@ static void show_cursor(void) { void edbox_clear(void) { memset(edit_box, 0, EDBOX_SIZE); edbox_pos = edbox_len = 0; - show_cursor(); + show_cursor(); // not needed? seems it is.. } void edbox_show(void) { @@ -49,6 +49,11 @@ void edbox_hide(void) { scr_refresh(); } +/* note: c will never be an EOL. + idea: when the edbox is completely full (240 chars), go + ahead and pretend the user pressed Return (call edbox_callback, + etc). not sure if this is more or less annoying than just + refusing to accept more input until Return is pressed. */ void edbox_putc(char c) { if(!c) return; /* no inserting nulls */ @@ -60,7 +65,7 @@ void edbox_putc(char c) { edbox_show(); } -static void special_keystroke(char c) { +static void fake_keystroke(char c) { keyclick(); OS.ch = 0xff; edbox_putc(c); @@ -72,24 +77,49 @@ static void del_char(void) { edbox_len--; } +static void del_to_end(void) { + while(edbox_len > edbox_pos) + del_char(); +} + static void backspace(void) { if(!edbox_pos) return; edbox_pos--; del_char(); } -static void del_word(void) { +static void word_left(char del) { if(!edbox_pos) return; edbox_pos--; while(edbox_pos && edit_box[edbox_pos] == ' ') { - del_char(); + if(del) del_char(); edbox_pos--; } while(edbox_pos && edit_box[edbox_pos] != ' ') { - del_char(); + if(del) del_char(); edbox_pos--; } - if(!edbox_pos) edit_box[edbox_pos] = ' '; + // XXX: what's this good for? + if(del && !edbox_pos) edit_box[edbox_pos] = /* ' ' */ 0; +} + +static void del_word(void) { + word_left(1); +} + +static void back_word(void) { + word_left(0); +} + +static void forward_word(void) { + while(edbox_pos < edbox_len && edit_box[edbox_pos] == ' ') + edbox_pos++; + while(edbox_pos < edbox_len && edit_box[edbox_pos] != ' ') + edbox_pos++; +} + +static void del_to_start(void) { + while(edbox_pos) backspace(); } static void normal_keystroke(void) { @@ -99,7 +129,7 @@ static void normal_keystroke(void) { switch(c) { case CH_EOL: - hide_cursor(); + // hide_cursor(); // already done by the caller if(edbox_callback) (*edbox_callback)(); /* fall thru */ @@ -107,12 +137,23 @@ static void normal_keystroke(void) { edbox_hide(); /* fall thru */ case CH_DELLINE: - case 0x15: /* ^U */ edbox_clear(); break; + case 0x15: /* ^U */ + del_to_start(); + break; + case 0x0b: /* ^K */ + del_to_end(); + break; case CH_DEL: backspace(); break; + case 0x02: /* ^B */ + back_word(); + break; + case 0x06: /* ^F */ + forward_word(); + break; case 0x17: /* ^W */ del_word(); break; @@ -122,6 +163,15 @@ static void normal_keystroke(void) { case CH_CURS_RIGHT: if(edbox_pos < edbox_len) edbox_pos++; break; + case CH_CURS_UP: + if(edbox_pos > 39) edbox_pos -= 40; + break; + case CH_CURS_DOWN: + if(edbox_pos < edbox_len - 40) + edbox_pos += 40; + else + edbox_pos = edbox_len; + break; case CH_DELCHR: del_char(); break; @@ -162,16 +212,24 @@ void edbox_keystroke(void) { c = 0x7e; /* ascii: ~ */ break; case 0x3c: /* caps */ + case 0x7c: /* shift-caps */ + case 0xbc: /* ctrl-caps */ OS.shflok ^= 0x40; keyclick(); OS.ch = 0xff; return; break; - case 0x7c: /* shift-caps */ - case 0xbc: /* ctrl-caps */ case 0x27: /* atari key */ case 0x67: /* ...w/shift */ case 0xa7: /* ...w/ctrl */ + c = 0x02; /* ^B = IRC bold formatting char */ + break; + case 0xce: /* ctrl-shift-up, same as... */ + OS.ch = 0x95; /* ^B = back 1 word */ + break; + case 0xcf: /* ctrl-shift-down, same as... */ + OS.ch = 0xb8; /* ^F = forward 1 word */ + break; case 0x9a: /* ctrl-3 (crash if cgetc() reads it!) */ OS.ch = 0xff; /* ignore it! */ return; @@ -183,7 +241,7 @@ void edbox_keystroke(void) { hide_cursor(); if(c) { - special_keystroke(c); + fake_keystroke(c); } else { normal_keystroke(); } |
