diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-07-30 23:58:32 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-07-31 00:33:43 +0300 |
commit | 2ec568579823c991b919fa3a2c8583a8db21cb81 (patch) | |
tree | 5ee30e3cde1df8b284aec73380c34b79afdbc8ab /src/interface-gtk/gtk-label.c | |
parent | 86fbf212de71a83e7bb4d83a4b33e54bed52dff9 (diff) | |
download | sciteco-2ec568579823c991b919fa3a2c8583a8db21cb81.tar.gz |
implemented ^T command: allows typing by code and getting characters from stdin or the user
* n:^T always prints bytes (cf. :^A)
* ^T without arguments returns a codepoint or byte from stdin.
In interactive mode, this currentply places a cursor in the message line and waits for a keypress.
Diffstat (limited to 'src/interface-gtk/gtk-label.c')
-rw-r--r-- | src/interface-gtk/gtk-label.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/interface-gtk/gtk-label.c b/src/interface-gtk/gtk-label.c index ef370a2..9fc9e76 100644 --- a/src/interface-gtk/gtk-label.c +++ b/src/interface-gtk/gtk-label.c @@ -275,3 +275,27 @@ teco_gtk_label_get_text(TecoGtkLabel *self) { return &self->string; } + +/** + * Signal that a keypress is expected (after executing ^T) + * by printing the first character in reverse. + * + * @fixme This mimics the current Curses implementation. + * Perhaps better show an icon? + */ +void +teco_gtk_label_highlight_getch(TecoGtkLabel *self) +{ + const gchar *plaintext = gtk_label_get_text(GTK_LABEL(self)); + g_assert(plaintext != NULL); + if (!*plaintext || !strcmp(plaintext, "\u258C")) { + gtk_label_set_text(GTK_LABEL(self), "\u258C"); + } else { + PangoAttrList *attribs = gtk_label_get_attributes(GTK_LABEL(self)); + teco_gtk_label_add_highlight_attribs(attribs, + &self->fg, self->fg_alpha, + &self->bg, self->bg_alpha, + 0, 1); + gtk_label_set_attributes(GTK_LABEL(self), attribs); + } +} |