Handle bracketed paste, including newlines
parent
3cb7cc97f6
commit
60b189200e
19
ui.c
19
ui.c
|
@ -704,8 +704,15 @@ static void inputAdd(struct Style *style, const char *str) {
|
||||||
break; case R: waddch(input, 'R');
|
break; case R: waddch(input, 'R');
|
||||||
break; case I: waddch(input, 'I');
|
break; case I: waddch(input, 'I');
|
||||||
break; case U: waddch(input, 'U');
|
break; case U: waddch(input, 'U');
|
||||||
|
break; case '\n': waddch(input, 'N');
|
||||||
}
|
}
|
||||||
if (str - code > 1) waddnstr(input, &code[1], str - &code[1]);
|
if (str - code > 1) waddnstr(input, &code[1], str - &code[1]);
|
||||||
|
if (str[0] == '\n') {
|
||||||
|
str++;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
size_t nl = strcspn(str, "\n");
|
||||||
|
if (nl < len) len = nl;
|
||||||
wattr_set(
|
wattr_set(
|
||||||
input,
|
input,
|
||||||
style->attr | colorAttr(Colors[style->fg]),
|
style->attr | colorAttr(Colors[style->fg]),
|
||||||
|
@ -853,8 +860,6 @@ static void keyCode(int code) {
|
||||||
break; case KEY_RESIZE: resize();
|
break; case KEY_RESIZE: resize();
|
||||||
break; case KeyFocusIn: unmark(window);
|
break; case KeyFocusIn: unmark(window);
|
||||||
break; case KeyFocusOut: mark(window);
|
break; case KeyFocusOut: mark(window);
|
||||||
break; case KeyPasteOn:; // TODO
|
|
||||||
break; case KeyPasteOff:; // TODO
|
|
||||||
|
|
||||||
break; case KeyMetaSlash: windowShow(windows.swap);
|
break; case KeyMetaSlash: windowShow(windows.swap);
|
||||||
|
|
||||||
|
@ -939,9 +944,15 @@ void uiRead(void) {
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
wint_t ch;
|
wint_t ch;
|
||||||
static bool style;
|
static bool paste, style;
|
||||||
while (ERR != (ret = wget_wch(input, &ch))) {
|
while (ERR != (ret = wget_wch(input, &ch))) {
|
||||||
if (ret == KEY_CODE_YES) {
|
if (ret == KEY_CODE_YES && ch == KeyPasteOn) {
|
||||||
|
paste = true;
|
||||||
|
} else if (ret == KEY_CODE_YES && ch == KeyPasteOff) {
|
||||||
|
paste = false;
|
||||||
|
} else if (paste) {
|
||||||
|
edit(windows.ptrs[windows.show]->id, EditInsert, ch);
|
||||||
|
} else if (ret == KEY_CODE_YES) {
|
||||||
keyCode(ch);
|
keyCode(ch);
|
||||||
} else if (ch == (L'Z' ^ L'@')) {
|
} else if (ch == (L'Z' ^ L'@')) {
|
||||||
style = true;
|
style = true;
|
||||||
|
|
Loading…
Reference in New Issue