From 749c54ddb68a2ebbd1e707b3286cd01470a10a9b Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 9 Aug 2023 10:52:17 +1000 Subject: [PATCH] ncurses: catch and ignore focus-in/out focus-in/out comes in as unknown key at awkward times causing problems for C-l and the refresh causes a focus-out. So catch and ignore for now. Also log any unrecognised keys so I can try to handle them. Signed-off-by: NeilBrown --- DOC/TODO.md | 4 ++++ display-ncurses.c | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/DOC/TODO.md b/DOC/TODO.md index 143a5899..a3e1a6a0 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -11,6 +11,7 @@ the file. - [ ] find a better wat to handle "case when EOF is at the end" of a non-empty line. +- [ ] input uses 0 for Efallthrough! - [X] call, not caLl in server.py - [X] lib-server received unexpected notification Close - [ ] should pane ->cx,cy be a struct xy?? @@ -158,6 +159,8 @@ Core features - [ ] teach input to allow a repeat command to be registered so that e.g. search/replace and do a bit of work, then ask to be called again. input can cancel this on suitable input. +- [ ] should input leave mode unchanged for key that isn't handled at + all - [ ] marks can be used after they go invalid too easily. How to fix?? - [ ] catching doc:replace in a pane doesn't catch doc:insert-file. I need a simple way to intercept any change. @@ -355,6 +358,7 @@ Module features ### ncurses +- [ ] What to do with Focus-in/out keys? - [ ] add full list of colour names (to lib-colourmap) - [ ] allow a pane to require 'true-colour' and discover number of colours available Colour map gets changed when it becomes the focus. diff --git a/display-ncurses.c b/display-ncurses.c index 64d64084..8e7436f4 100644 --- a/display-ncurses.c +++ b/display-ncurses.c @@ -1527,6 +1527,8 @@ static struct namelist { { 00436, ":S:F10"}, { 00437, ":S:F11"}, { 00440, ":S:F12"}, + { 01114, ":Focus-in"}, + { 01115, ":Focus-out"}, {0, NULL} }, char_names[] = { {'\e', ":ESC"}, @@ -1557,8 +1559,11 @@ static void send_key(int keytype, wint_t c, int alt, struct pane *p safe) if (keytype == KEY_CODE_YES) { n = find_name(key_names, c); - if (!n) + if (!n) { + LOG("Unknown ncurses key 0o%o", c); sprintf(buf, "%sNcurs-%o", a, c); + } else if (strstarts(n, ":Focus-")) + /* Ignore focus changes for now */; else strcat(strcpy(buf, a), n); } else { -- 2.39.5