Refactor Focus and Paste mode strings

master
C. McEnroe 2021-02-15 18:59:17 -05:00
parent 3b9e778dac
commit 66c67542ff
1 changed files with 8 additions and 10 deletions

18
ui.c
View File

@ -222,16 +222,14 @@ enum {
// XXX: Assuming terminals will be fine with these even if they're unsupported, // XXX: Assuming terminals will be fine with these even if they're unsupported,
// since they're "private" modes. // since they're "private" modes.
static const char *EnterFocusMode = "\33[?1004h"; static const char *FocusMode[2] = { "\33[?1004l", "\33[?1004h" };
static const char *ExitFocusMode = "\33[?1004l"; static const char *PasteMode[2] = { "\33[?2004l", "\33[?2004h" };
static const char *EnterPasteMode = "\33[?2004h";
static const char *ExitPasteMode = "\33[?2004l";
struct Time uiTime = { .format = "%X" }; struct Time uiTime = { .format = "%X" };
static void errExit(void) { static void errExit(void) {
putp(ExitFocusMode); putp(FocusMode[false]);
putp(ExitPasteMode); putp(PasteMode[false]);
reset_shell_mode(); reset_shell_mode();
} }
@ -447,8 +445,8 @@ static void unmark(struct Window *window) {
void uiShow(void) { void uiShow(void) {
if (!hidden) return; if (!hidden) return;
prevTitle[0] = '\0'; prevTitle[0] = '\0';
putp(EnterFocusMode); putp(FocusMode[true]);
putp(EnterPasteMode); putp(PasteMode[true]);
fflush(stdout); fflush(stdout);
hidden = false; hidden = false;
unmark(windows.ptrs[windows.show]); unmark(windows.ptrs[windows.show]);
@ -458,8 +456,8 @@ void uiHide(void) {
if (hidden) return; if (hidden) return;
mark(windows.ptrs[windows.show]); mark(windows.ptrs[windows.show]);
hidden = true; hidden = true;
putp(ExitFocusMode); putp(FocusMode[false]);
putp(ExitPasteMode); putp(PasteMode[false]);
endwin(); endwin();
} }