summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-09-25 02:27:59 -0300
committerdequis <dx@dxzone.com.ar>2015-09-27 16:08:07 -0300
commit7d062a313add81584608f2b0abf086f2b73e8098 (patch)
tree1d9a72b6a47139164e9543a78e14b474fbe8d630 /src
parent83f9772e213b6b1e181338738c2997150162c871 (diff)
downloadirssi-7d062a313add81584608f2b0abf086f2b73e8098.zip
Create paste_bracketed_middle() function to handle small pastes
"Small" as in ending in the same sig_input() call where they started
Diffstat (limited to 'src')
-rw-r--r--src/fe-text/gui-readline.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c
index 9b635139..5d859ede 100644
--- a/src/fe-text/gui-readline.c
+++ b/src/fe-text/gui-readline.c
@@ -678,6 +678,24 @@ static void paste_bracketed_end(int i, gboolean rest)
paste_bracketed_mode = FALSE;
}
+static void paste_bracketed_middle()
+{
+ int i;
+ int len = paste_buffer->len - G_N_ELEMENTS(bp_end);
+ unichar *ptr = (unichar *) paste_buffer->data;
+
+ if (len <= 0) {
+ return;
+ }
+
+ for (i = 0; i <= len; i++, ptr++) {
+ if (ptr[0] == bp_end[0] && memcmp(ptr, bp_end, sizeof(bp_end)) == 0) {
+ paste_bracketed_end(i, i != len);
+ break;
+ }
+ }
+}
+
static void sig_input(void)
{
if (!active_entry) {
@@ -701,20 +719,8 @@ static void sig_input(void)
/* use the bracketed paste mode to detect when the user pastes
* some text into the entry */
if (paste_bracketed_mode) {
- int i;
- int len = paste_buffer->len - G_N_ELEMENTS(bp_end);
- unichar *ptr = (unichar *) paste_buffer->data;
-
- if (len <= 0) {
- return;
- }
+ paste_bracketed_middle();
- for (i = 0; i <= len; i++, ptr++) {
- if (ptr[0] == bp_end[0] && memcmp(ptr, bp_end, sizeof(bp_end)) == 0) {
- paste_bracketed_end(i, i != len);
- break;
- }
- }
} else if (paste_detect_time > 0 && paste_buffer->len >= 3) {
if (paste_timeout_id != -1)
g_source_remove(paste_timeout_id);
@@ -729,6 +735,9 @@ static void sig_input(void)
if (paste_bracketed_mode) {
/* just enabled by the signal, remove what was processed so far */
g_array_remove_range(paste_buffer, 0, i + 1);
+
+ /* handle single-line / small pastes here */
+ paste_bracketed_middle();
return;
}
}