diff options
author | Timo Sirainen <cras@irssi.org> | 2000-07-11 09:44:38 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-07-11 09:44:38 +0000 |
commit | 767aadfb7f53c4664bc3da560e44649aaf118a91 (patch) | |
tree | 50d334eb5f5f32b8a66d0bef2e737e35fa3252b9 | |
parent | 02495002e42e2eeb97563b059e32945326ca1a70 (diff) | |
download | irssi-767aadfb7f53c4664bc3da560e44649aaf118a91.zip |
Ctrl-K also puts the deleted text to cutbuffer which can be recovered
with Ctrl-Y. /eval $U prints the cutbuffer.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@461 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r-- | src/fe-text/gui-readline.c | 31 | ||||
-rw-r--r-- | src/fe-text/gui-readline.h | 2 | ||||
-rw-r--r-- | src/fe-text/gui-special-vars.c | 2 |
3 files changed, 20 insertions, 15 deletions
diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index 4a20d097..224caac9 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -48,7 +48,7 @@ typedef struct { static ENTRY_REDIRECT_REC *redir; -static char *savebuffer; +char *cutbuffer; static int readtag, sigint_count = 0; static time_t idle_time; @@ -199,15 +199,25 @@ void handle_key(int key) case CTRL('u'): /* Ctrl-U, clear line */ - g_free_not_null(savebuffer); - savebuffer = g_strdup(gui_entry_get_text()); + g_free_not_null(cutbuffer); + cutbuffer = g_strdup(gui_entry_get_text()); gui_entry_set_text(""); break; + case CTRL('k'): + /* C-K - erase the rest of the line */ + c = gui_entry_get_pos(); + g_free_not_null(cutbuffer); + cutbuffer = g_strdup(gui_entry_get_text()+c); + + gui_entry_set_pos(strlen(gui_entry_get_text())); + gui_entry_erase(strlen(gui_entry_get_text()) - c); + break; + case CTRL('y'): /* Ctrl-Y, write last ^U'd line */ - if (savebuffer != NULL) - gui_entry_insert_text(savebuffer); + if (cutbuffer != NULL) + gui_entry_insert_text(cutbuffer); break; case 9: key_pressed("Tab", NULL); @@ -232,13 +242,6 @@ void handle_key(int key) } break; - case CTRL('k'): - /* C-K - erase the rest of the line */ - c = gui_entry_get_pos(); - gui_entry_set_pos(strlen(gui_entry_get_text())); - gui_entry_erase(strlen(gui_entry_get_text()) - c); - break; - case 0: /* Ctrl-space - ignore */ break; @@ -434,7 +437,7 @@ void gui_readline_init(void) char *key, data[MAX_INT_STRLEN]; int n; - savebuffer = NULL; + cutbuffer = NULL; redir = NULL; idle_time = time(NULL); readtag = g_input_add(0, G_INPUT_READ, (GInputFunction) readline, NULL); @@ -476,7 +479,7 @@ void gui_readline_init(void) void gui_readline_deinit(void) { - g_free_not_null(savebuffer); + g_free_not_null(cutbuffer); g_source_remove(readtag); key_unbind("completion", (SIGNAL_FUNC) sig_completion); diff --git a/src/fe-text/gui-readline.h b/src/fe-text/gui-readline.h index d6be0d59..6464921f 100644 --- a/src/fe-text/gui-readline.h +++ b/src/fe-text/gui-readline.h @@ -1,6 +1,8 @@ #ifndef __GUI_READLINE_H #define __GUI_READLINE_H +extern char *cutbuffer; + void readline(void); time_t get_idle_time(void); diff --git a/src/fe-text/gui-special-vars.c b/src/fe-text/gui-special-vars.c index ac648ff1..f0a66727 100644 --- a/src/fe-text/gui-special-vars.c +++ b/src/fe-text/gui-special-vars.c @@ -43,7 +43,7 @@ static char *expando_inputline(void *server, void *item, int *free_ret) /* FIXME: value of cutbuffer */ static char *expando_cutbuffer(void *server, void *item, int *free_ret) { - return NULL; + return cutbuffer; } void gui_special_vars_init(void) |