aboutsummaryrefslogtreecommitdiff
path: root/linenoise.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2019-06-10 14:57:08 +1000
committerSteve Bennett <steveb@workware.net.au>2019-06-10 14:58:16 +1000
commita5a84b197a864399617b439215864f3cc7b1d6a8 (patch)
tree1e2a402d90ee5817d7ef93540e272985bff1a861 /linenoise.c
parent7155afa31fdc385eab0d69e8d55ccd54ba4d2805 (diff)
downloadjimtcl-a5a84b197a864399617b439215864f3cc7b1d6a8.zip
jimtcl-a5a84b197a864399617b439215864f3cc7b1d6a8.tar.gz
jimtcl-a5a84b197a864399617b439215864f3cc7b1d6a8.tar.bz2
linenoise: Update to rev d1a245f4a75747a1c4a1c08
win32 insert/delete fix to avoid assertion failure Accept linefeed as enter Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'linenoise.c')
-rw-r--r--linenoise.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/linenoise.c b/linenoise.c
index 35cef7b..1c01853 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -1578,13 +1578,14 @@ static int remove_char(struct current *current, int pos)
int rc = 1;
/* Now we try to optimise in the simple but very common case that:
- * - we are remove the char at EOL
+ * - outputChars() can be used directly (not win32)
+ * - we are removing the char at EOL
* - the buffer is not empty
* - there are columns available to the left
* - the char being deleted is not a wide or utf-8 character
* - no hints are being shown
*/
- if (current->pos == pos + 1 && current->pos == sb_chars(current->buf) && pos > 0) {
+ if (current->output && current->pos == pos + 1 && current->pos == sb_chars(current->buf) && pos > 0) {
#ifdef USE_UTF8
/* Could implement utf8_prev_len() but simplest just to not optimise this case */
char last = sb_str(current->buf)[offset];
@@ -1639,11 +1640,12 @@ static int insert_char(struct current *current, int pos, int ch)
buf[n] = 0;
/* Now we try to optimise in the simple but very common case that:
+ * - outputChars() can be used directly (not win32)
* - we are inserting at EOL
* - there are enough columns available
* - no hints are being shown
*/
- if (pos == current->pos && pos == sb_chars(current->buf)) {
+ if (current->output && pos == current->pos && pos == sb_chars(current->buf)) {
int width = char_display_width(ch);
if (current->colsright > width) {
/* Yes, can optimise */
@@ -1881,7 +1883,8 @@ static int linenoiseEdit(struct current *current) {
switch(c) {
case SPECIAL_NONE:
break;
- case '\r': /* enter */
+ case '\r': /* enter/CR */
+ case '\n': /* LF */
history_len--;
free(history[history_len]);
current->pos = sb_chars(current->buf);