RE: nano hangs when pasting five characters
"Doug Smythies" <[email protected]>
| Newsgroups | gmane.editors.nano.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Benno,
Further to my email earlier today:
> As mentioned yesterday, notice how sometimes the 5 character paste is not split and sometimes is.
The issue is not keystroke based, but time based.
After the first one, 5 character pastes work fine if I paste repeatedly and rapidly.
5 character pastes are always split if I paste repeatedly but very slowly.
With that in mind I did this to the code, just as a test, not as a potential solution:
diff --git a/src/winio.c b/src/winio.c
index 2fff0d9e..310c0d46 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -292,23 +292,21 @@ void read_keys_from(WINDOW *frame)
/* If there aren't any more characters, stop reading. */
if (input == ERR)
break;
-
/* When the keystroke buffer is full, extend it. */
if (waiting_codes == capacity)
reserve_space_for(2 * capacity);
key_buffer[waiting_codes++] = input;
+ napms(2); /* rate limit the input */
}
/* Restore blocking-input mode. */
nodelay(frame, FALSE);
-#ifdef DEBUG
fprintf(stderr, "\nSequence of hex codes:");
for (size_t i = 0; i < waiting_codes; i++)
fprintf(stderr, " %3x", key_buffer[i]);
fprintf(stderr, "\n");
-#endif
}
/* Return the number of key codes waiting in the keystroke buffer. */
And it worked fine, although I only tested 5 character pastes.
Note that " napms(1)" wasn't enough.
I also thought this might work, it but didn't:
diff --git a/src/winio.c b/src/winio.c
index 2fff0d9e..e13bceef 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -290,9 +290,12 @@ void read_keys_from(WINDOW *frame)
input = wgetch(frame);
/* If there aren't any more characters, stop reading. */
- if (input == ERR)
- break;
-
+ if (input == ERR) {
+ napms(20); /* check for sender slower than here */
+ input = wgetch(frame); /* check again */
+ if (input == ERR)
+ break;
+ }
/* When the keystroke buffer is full, extend it. */
if (waiting_codes == capacity)
reserve_space_for(2 * capacity);
@@ -303,12 +306,10 @@ void read_keys_from(WINDOW *frame)
/* Restore blocking-input mode. */
nodelay(frame, FALSE);
-#ifdef DEBUG
fprintf(stderr, "\nSequence of hex codes:");
for (size_t i = 0; i < waiting_codes; i++)
fprintf(stderr, " %3x", key_buffer[i]);
fprintf(stderr, "\n");
-#endif
}
/* Return the number of key codes waiting in the keystroke buffer. */
... Doug