Index: src/fe-text/gui-readline.c =================================================================== --- src/fe-text/gui-readline.c (revision 4605) +++ src/fe-text/gui-readline.c (working copy) @@ -317,13 +317,44 @@ g_string_free(str, TRUE); } +static void paste_flush_signal() { + unsigned int i; + unichar *arr; + char out[10]; + char *text = gui_entry_get_text(active_entry); + GString *str = g_string_new(text); + + g_free(text); + + arr = (unichar *) paste_buffer->data; + + for (i = 0; i < paste_buffer->len; i++) { + if (active_entry->utf8) { + out[utf16_char_to_utf8(arr[i], out)] = '\0'; + g_string_append(str, out); + } else if (term_type == TERM_TYPE_BIG5) { + if (arr[i] > 0xff) + g_string_append_c(str, (arr[i] >> 8) & 0xff); + g_string_append_c(str, arr[i] & 0xff); + } else { + g_string_append_c(str, arr[i]); + } + } + signal_emit("gui paste flush", 1, str->str); + + g_string_free(str, TRUE); +} + static void paste_flush(int send) { gui_entry_set_text(active_entry, paste_entry); gui_entry_set_pos(active_entry, paste_entry_pos); - if (send) + if (send == TRUE) paste_send(); + else if (send) + paste_flush_signal(); + g_array_set_size(paste_buffer, 0); gui_entry_set_prompt(active_entry, @@ -376,6 +407,8 @@ gui_entry_set_prompt(active_entry, str); gui_entry_set_text(active_entry, ""); g_free(str); + + signal_emit("gui paste detected", 1, paste_line_count); } return TRUE; } @@ -411,8 +444,9 @@ } /* continuing quick hits */ - if ((key == 11 || key == 3) && paste_prompt) { - paste_flush(key == 11); + if ((key == 11 || key == 3 || key == 15 || key == 16) && paste_prompt) { + /* 15 (^O) and 16 (^P) can be used by a script */ + paste_flush(key == 11 ? TRUE : key == 3 ? FALSE : key); return TRUE; } Index: docs/signals.txt =================================================================== --- docs/signals.txt (revision 4605) +++ docs/signals.txt (working copy) @@ -319,6 +319,8 @@ gui-readline.c: "gui key pressed", int key + "gui paste detected", int lines + "gui paste flush", int key, char *paste_buffer gui-printtext.c: "beep"