degesch: little libedit details
This commit is contained in:
parent
1d7903ae03
commit
85baf5ecec
24
degesch.c
24
degesch.c
|
@ -5589,10 +5589,10 @@ on_editline_complete (EditLine *editline, int key)
|
||||||
unsigned char result = CC_REFRESH_BEEP;
|
unsigned char result = CC_REFRESH_BEEP;
|
||||||
|
|
||||||
// First prepare what Readline would have normally done for us...
|
// First prepare what Readline would have normally done for us...
|
||||||
const LineInfo *info = el_line (editline);
|
const LineInfo *info_mb = el_line (editline);
|
||||||
int len = info->lastchar - info->buffer;
|
int len = info_mb->lastchar - info_mb->buffer;
|
||||||
int point = info->cursor - info->buffer;
|
int point = info_mb->cursor - info_mb->buffer;
|
||||||
char *copy = xstrndup (info->buffer, len);
|
char *copy = xstrndup (info_mb->buffer, len);
|
||||||
|
|
||||||
// XXX: possibly incorrect wrt. shift state encodings
|
// XXX: possibly incorrect wrt. shift state encodings
|
||||||
int el_start = point, el_end = point;
|
int el_start = point, el_end = point;
|
||||||
|
@ -5652,17 +5652,15 @@ on_editline_return (EditLine *editline, int key)
|
||||||
history_w (self->current->history, &ev, H_ENTER, line);
|
history_w (self->current->history, &ev, H_ENTER, line);
|
||||||
print_debug ("history: %d %ls", ev.num, ev.str);
|
print_debug ("history: %d %ls", ev.num, ev.str);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert it to multibyte to reflect the Readline interface
|
|
||||||
size_t needed = wcstombs (NULL, line, 0) + 1;
|
|
||||||
char converted[needed];
|
|
||||||
if (!needed || wcstombs (converted, line, needed) == (size_t) -1)
|
|
||||||
print_error ("encoding conversion failed");
|
|
||||||
else
|
|
||||||
process_input (g_ctx, converted);
|
|
||||||
|
|
||||||
free (line);
|
free (line);
|
||||||
|
|
||||||
|
// process_input() expects a multibyte string
|
||||||
|
const LineInfo *info_mb = el_line (editline);
|
||||||
|
char copy[info_mb->lastchar - info_mb->buffer + 1];
|
||||||
|
memcpy (copy, info_mb->buffer, sizeof copy - 1);
|
||||||
|
copy[sizeof copy - 1] = '\0';
|
||||||
|
process_input (g_ctx, copy);
|
||||||
|
|
||||||
el_cursor (editline, len - point);
|
el_cursor (editline, len - point);
|
||||||
el_wdeletestr (editline, len);
|
el_wdeletestr (editline, len);
|
||||||
return CC_REFRESH;
|
return CC_REFRESH;
|
||||||
|
|
Loading…
Reference in New Issue