diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-key.c | 8 | ||||
-rw-r--r-- | src/gui/gui-key.c | 12 |
3 files changed, 18 insertions, 5 deletions
@@ -1,12 +1,13 @@ WeeChat ChangeLog ================= Sébastien Helleu <flashcode@flashtux.org> -v0.3.6-dev, 2011-09-24 +v0.3.6-dev, 2011-09-27 Version 0.3.6 (under dev!) -------------------------- +* core: fix paste detection (problem with end of lines) * core: add new option weechat.look.color_basic_force_bold, off by default: bold is used only if terminal has less than 16 colors (patch #7621) * core: add default key "meta2-[E" (F5) for linux console diff --git a/src/gui/curses/gui-curses-key.c b/src/gui/curses/gui-curses-key.c index a07727d9d..a303b4f77 100644 --- a/src/gui/curses/gui-curses-key.c +++ b/src/gui/curses/gui-curses-key.c @@ -509,7 +509,13 @@ gui_key_read_cb (void *data, int fd) for (i = 0; i < ret; i++) { - gui_key_buffer_add (buffer[i]); + /* add all chars (ignore a '\n' after a '\r') */ + if ((i == 0) + || (buffer[i] != '\n') + || (buffer[i - 1] != '\r')) + { + gui_key_buffer_add (buffer[i]); + } } text_added_to_buffer = 1; diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index f9920f9d7..0d3c0b64e 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -1386,10 +1386,13 @@ gui_key_buffer_add (unsigned char key) if (gui_key_buffer) { gui_key_buffer[gui_key_buffer_size - 1] = key; - if ((key == 13) + if (((key == '\r') || (key == '\n')) && (gui_key_buffer_size > 1) - && (gui_key_buffer[gui_key_buffer_size - 2] != 13)) + && (gui_key_buffer[gui_key_buffer_size - 2] != '\r') + && (gui_key_buffer[gui_key_buffer_size - 2] != '\n')) + { gui_key_paste_lines++; + } } else { @@ -1409,8 +1412,11 @@ int gui_key_get_paste_lines () { if ((gui_key_buffer_size > 0) - && (gui_key_buffer[gui_key_buffer_size - 1] != 13)) + && (gui_key_buffer[gui_key_buffer_size - 1] != '\r') + && (gui_key_buffer[gui_key_buffer_size - 1] != '\n')) + { return gui_key_paste_lines + 1; + } return gui_key_paste_lines; } |