billiob pushed a commit to branch master. http://git.enlightenment.org/apps/terminology.git/commit/?id=fe47376460948da424a13e09e27c73d4894c7bfb
commit fe47376460948da424a13e09e27c73d4894c7bfb Author: Boris Faure <bill...@gmail.com> Date: Tue Nov 2 23:28:37 2021 +0100 termptyesc: add focus reporting --- src/bin/termio.c | 2 ++ src/bin/termpty.c | 11 +++++++++++ src/bin/termpty.h | 3 +++ src/bin/termptyesc.c | 14 +++++++++++--- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/bin/termio.c b/src/bin/termio.c index 9211112..9602b59 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c @@ -2548,6 +2548,7 @@ termio_focus_in(Evas_Object *termio) else edje_object_signal_emit(sd->cursor.obj, "focus,in", "terminology"); if (!sd->win) return; + termpty_focus_report(sd->pty, EINA_TRUE); } void @@ -2562,6 +2563,7 @@ termio_focus_out(Evas_Object *termio) sd->pty->selection.last_click = 0; if (!sd->ctxpopup) termio_remove_links(sd); + termpty_focus_report(sd->pty, EINA_FALSE); term_unfocus(sd->term); } diff --git a/src/bin/termpty.c b/src/bin/termpty.c index 7ae4705..90cb84f 100644 --- a/src/bin/termpty.c +++ b/src/bin/termpty.c @@ -1733,6 +1733,17 @@ hl_bitmap_clear_bit(Termpty *ty, uint16_t id) *pos &= ~bit; } +void +termpty_focus_report(Termpty *ty, Eina_Bool focus) +{ + if (!ty || !ty->focus_reporting) + return; + if (focus) + TERMPTY_WRITE_STR("\033[I"); + else + TERMPTY_WRITE_STR("\033[O"); +} + Term_Link * term_link_new(Termpty *ty) { diff --git a/src/bin/termpty.h b/src/bin/termpty.h index 31ba5e8..64b4a30 100644 --- a/src/bin/termpty.h +++ b/src/bin/termpty.h @@ -203,6 +203,7 @@ struct _Termpty unsigned int mouse_ext : 2; unsigned int bracketed_paste : 1; unsigned int decoding_error : 1; + unsigned int focus_reporting : 1; struct { Term_Link *links; uint8_t *bitmap; @@ -315,6 +316,8 @@ void term_link_free(Termpty *ty, Term_Link *link); int termpty_color_class_get(Termpty *ty, const char *key, int *r, int *g, int *b, int *a); +void +termpty_focus_report(Termpty *ty, Eina_Bool focus); extern int _termpty_log_dom; diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index a15dc73..530bdef 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -467,9 +467,17 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b, else ty->mouse_mode = MOUSE_OFF; DBG("set mouse (press+release+all motion) %i", mode); break; - case 1004: // I don't know what focus reporting is? - WRN("TODO: enable focus reporting %i", mode); - ty->decoding_error = EINA_TRUE; + case 1004: + DBG("%s focus reporting", mode ? "enable" : "disable"); + if (mode) + { + ty->focus_reporting = EINA_TRUE; + termpty_focus_report(ty, termio_is_focused(ty->obj)); + } + else + { + ty->focus_reporting = EINA_FALSE; + } break; case 1005: if (mode) ty->mouse_ext = MOUSE_EXT_UTF8; --