diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2011-09-27 21:35:13 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2011-09-27 21:35:13 +0200 |
commit | d0f41efeb7753caa1d7408ca71167ceaed320da5 (patch) | |
tree | 2623f90f2e2bf0acde231efa9ffae4e602215a91 /src/gui | |
parent | a8c22c11fcdafc6ca936e478d732327d63df46f8 (diff) | |
download | weechat-d0f41efeb7753caa1d7408ca71167ceaed320da5.zip |
core: fix paste detection (problem with end of lines)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-key.c | 8 | ||||
-rw-r--r-- | src/gui/gui-key.c | 12 |
2 files changed, 16 insertions, 4 deletions
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; } |