1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

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
This commit is contained in:
Timo Sirainen 2000-07-11 09:44:38 +00:00 committed by cras
parent 02495002e4
commit 767aadfb7f
3 changed files with 20 additions and 15 deletions

View File

@ -48,7 +48,7 @@ typedef struct {
static ENTRY_REDIRECT_REC *redir; static ENTRY_REDIRECT_REC *redir;
static char *savebuffer; char *cutbuffer;
static int readtag, sigint_count = 0; static int readtag, sigint_count = 0;
static time_t idle_time; static time_t idle_time;
@ -199,15 +199,25 @@ void handle_key(int key)
case CTRL('u'): case CTRL('u'):
/* Ctrl-U, clear line */ /* Ctrl-U, clear line */
g_free_not_null(savebuffer); g_free_not_null(cutbuffer);
savebuffer = g_strdup(gui_entry_get_text()); cutbuffer = g_strdup(gui_entry_get_text());
gui_entry_set_text(""); gui_entry_set_text("");
break; 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'): case CTRL('y'):
/* Ctrl-Y, write last ^U'd line */ /* Ctrl-Y, write last ^U'd line */
if (savebuffer != NULL) if (cutbuffer != NULL)
gui_entry_insert_text(savebuffer); gui_entry_insert_text(cutbuffer);
break; break;
case 9: case 9:
key_pressed("Tab", NULL); key_pressed("Tab", NULL);
@ -232,13 +242,6 @@ void handle_key(int key)
} }
break; 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: case 0:
/* Ctrl-space - ignore */ /* Ctrl-space - ignore */
break; break;
@ -434,7 +437,7 @@ void gui_readline_init(void)
char *key, data[MAX_INT_STRLEN]; char *key, data[MAX_INT_STRLEN];
int n; int n;
savebuffer = NULL; cutbuffer = NULL;
redir = NULL; redir = NULL;
idle_time = time(NULL); idle_time = time(NULL);
readtag = g_input_add(0, G_INPUT_READ, (GInputFunction) readline, 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) void gui_readline_deinit(void)
{ {
g_free_not_null(savebuffer); g_free_not_null(cutbuffer);
g_source_remove(readtag); g_source_remove(readtag);
key_unbind("completion", (SIGNAL_FUNC) sig_completion); key_unbind("completion", (SIGNAL_FUNC) sig_completion);

View File

@ -1,6 +1,8 @@
#ifndef __GUI_READLINE_H #ifndef __GUI_READLINE_H
#define __GUI_READLINE_H #define __GUI_READLINE_H
extern char *cutbuffer;
void readline(void); void readline(void);
time_t get_idle_time(void); time_t get_idle_time(void);

View File

@ -43,7 +43,7 @@ static char *expando_inputline(void *server, void *item, int *free_ret)
/* FIXME: value of cutbuffer */ /* FIXME: value of cutbuffer */
static char *expando_cutbuffer(void *server, void *item, int *free_ret) static char *expando_cutbuffer(void *server, void *item, int *free_ret)
{ {
return NULL; return cutbuffer;
} }
void gui_special_vars_init(void) void gui_special_vars_init(void)