diff options
| author | B. Watson <urchlay@slackware.uk> | 2026-02-18 13:08:23 -0500 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2026-02-18 13:08:23 -0500 |
| commit | 48feffd829f30d393b39ae1cbdc7bf3eddca7652 (patch) | |
| tree | 0db282f0c9b9a0fd9825426a51742fc37afbe128 /src | |
| parent | f1bf0a483e917b67cf9db6483072db261f7688c3 (diff) | |
| download | fujinet-chat-48feffd829f30d393b39ae1cbdc7bf3eddca7652.tar.gz | |
WIP, still not working.
Diffstat (limited to 'src')
| -rw-r--r-- | src/edbox.c | 43 | ||||
| -rw-r--r-- | src/edbox.h | 23 | ||||
| -rw-r--r-- | src/irc.c | 2 |
3 files changed, 66 insertions, 2 deletions
diff --git a/src/edbox.c b/src/edbox.c index b1b06a7..b64ef11 100644 --- a/src/edbox.c +++ b/src/edbox.c @@ -37,6 +37,7 @@ void edbox_show(void) { scr_waitvcount(116); *dlist_bottom_lms = addr; + show_cursor(); } void edbox_hide(void) { @@ -52,6 +53,44 @@ void edbox_putc(char c) { edbox_show(); } +void edbox_append(char *s) { + while(*s) + edit_box[edbox_pos++] = *s++; +} + +void edbox_preset(char *s) { + edbox_pos = 0; + edbox_append(s); +} + +static char readline_done, readline_len; +static char *readline_dest; +static void readline_callback(void) { + strncpy(readline_dest, edit_box, readline_len); + readline_done = 1; +} + +void edbox_readline(char *dest, char len) { + void (*old_callback)(void); + + edbox_clear(); + if(*dest) + edbox_preset(dest); + edbox_show(); + + old_callback = edbox_callback; + edbox_callback = readline_callback; + readline_dest = dest; + readline_len = len; + + readline_done = 0; + + while(!readline_done) + edbox_keystroke(); + + edbox_callback = old_callback; +} + static void special_keystroke(char c) { OS.ch = 0xff; edbox_putc(c); @@ -74,6 +113,7 @@ static void normal_keystroke(void) { switch(c) { case CH_EOL: edbox_putc(c); + hide_cursor(); if(edbox_callback) (*edbox_callback)(); /* fall thru */ @@ -99,6 +139,9 @@ static void normal_keystroke(void) { void edbox_keystroke(void) { char c; + while(OS.ch == 0xff) + ; + hide_cursor(); edbox_show(); diff --git a/src/edbox.h b/src/edbox.h index ad70cc6..a410cec 100644 --- a/src/edbox.h +++ b/src/edbox.h @@ -4,11 +4,32 @@ #define EDBOX_SIZE 160 +/* clear the contents of the edit box (whether it's visible or not) */ void edbox_clear(void); + +/* make the edit box visible */ void edbox_show(void); + +/* make the edit box go away (current screen's status lines display instead) */ void edbox_hide(void); + +/* put one character into the edit box. */ void edbox_putc(char c); + +/* wait for a keystroke, insert its character into the edit box. if Return + is pressed, edbox_callback gets called (if it's set!) */ void edbox_keystroke(void); -/* called when the user presses Enter */ +/* append a string to the edit box. */ +void edbox_append(char *s); + +/* explicitly set the edit box's contents. wipes out whatever was there + before. */ +void edbox_preset(char *s); + +/* read a complete line into the edit box; doesn't return until the user + pressed Return. copies it to dest, up to len characters. */ +void edbox_readline(char *dest, char len); + +/* called when the user presses Return */ extern void (*edbox_callback)(void); @@ -355,7 +355,7 @@ void irc_loop(void) { while(1) { if(!irc_read()) return; - if(kbhit()) + if(OS.ch != 0xff) if(joined) keystroke(); else join_channel(); |
