aboutsummaryrefslogtreecommitdiff
path: root/unicode-mode.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-07-28 16:09:16 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-07-29 07:26:31 +0000
commit8967dd9cfe51276d63ef8ff64e8fc76f80a6fa3d (patch)
tree5df2e32f399132105886600ab1854b392e83ff38 /unicode-mode.c
parentselection: rework how we update a selection (diff)
input: add new Unicode input mode
This mode is activated through the new key-bindings.unicode-input and search-bindings.unicode-input key bindings. When active, the user can “build” a Unicode codepoint by typing its hexadecimal value. Note that there’s no visual feedback in this mode. This is intentional. This mode is intended to be a fallback for users that don’t use an IME. Closes #1116
Diffstat (limited to 'unicode-mode.c')
-rw-r--r--unicode-mode.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/unicode-mode.c b/unicode-mode.c
new file mode 100644
index 00000000..0da86add
--- /dev/null
+++ b/unicode-mode.c
@@ -0,0 +1,38 @@
+#include "unicode-mode.h"
+
+#include "render.h"
+
+void
+unicode_mode_activate(struct seat *seat)
+{
+ if (seat->unicode_mode.active)
+ return;
+
+ seat->unicode_mode.active = true;
+ seat->unicode_mode.character = u'\0';
+ seat->unicode_mode.count = 0;
+ unicode_mode_updated(seat);
+}
+
+void
+unicode_mode_deactivate(struct seat *seat)
+{
+ if (!seat->unicode_mode.active)
+ return;
+
+ seat->unicode_mode.active = false;
+ unicode_mode_updated(seat);
+}
+
+void
+unicode_mode_updated(struct seat *seat)
+{
+ struct terminal *term = seat->kbd_focus;
+ if (term == NULL)
+ return;
+
+ if (term->is_searching)
+ render_refresh_search(term);
+ else
+ render_refresh(term);
+}