aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2023-09-20 11:45:06 +0000
committerDaniel Eklöf <daniel@ekloef.se>2023-09-25 14:50:44 +0000
commit4eef001d5855b9b5afb59bbd3b92b3a2828fcca0 (patch)
treeb82c167fdd088f7c7a5d7595f2e77de8e16bf128
parentdcs: xtgettcap: ignore queries with invalid hex encodings (diff)
csi: implement DECSET/DECRST/DECRQM 2027 - grapheme cluster processing
This implements private mode 2027 - grapheme cluster processing, as defined in the "Terminal Unicode Core"[1] specification. Internally, we just flip the already existing option "grapheme shaping". Since it's now runtime changeable, we need a copy of it in the terminal struct, rather than referencing the conf object. [1]: https://github.com/contour-terminal/terminal-unicode-core/blob/13fc5a8993a033ff10c1f3433d08cb618cde4ac2/spec/terminal-unicode-core.tex#L50-L53
-rw-r--r--CHANGELOG.md2
-rw-r--r--csi.c7
-rw-r--r--doc/foot-ctlseqs.7.scd3
-rw-r--r--doc/foot.ini.5.scd2
-rw-r--r--terminal.c3
-rw-r--r--terminal.h3
-rw-r--r--vt.c2
7 files changed, 21 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 645e6e30..a064d1ee 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -58,6 +58,8 @@
* New key binding: `select-quote`. This key binding selects text
between quote characters, and falls back to selecting the entire
row ([#1364][1364]).
+* Support for DECSET/DECRST/DECRQM 2027 (_Grapheme cluster
+ processing_).
[1077]: https://codeberg.org/dnkl/foot/issues/1077
[1364]: https://codeberg.org/dnkl/foot/issues/1364
diff --git a/csi.c b/csi.c
index 959c913d..2abf08f8 100644
--- a/csi.c
+++ b/csi.c
@@ -491,6 +491,10 @@ decset_decrst(struct terminal *term, unsigned param, bool enable)
term_disable_app_sync_updates(term);
break;
+ case 2027:
+ term->grapheme_shaping = enable;
+ break;
+
case 8452:
term->sixel.cursor_right_of_graphics = enable;
break;
@@ -572,6 +576,7 @@ decrqm(const struct terminal *term, unsigned param)
case 1070: return decrpm(term->sixel.use_private_palette);
case 2004: return decrpm(term->bracketed_paste);
case 2026: return decrpm(term->render.app_sync_updates.enabled);
+ case 2027: return decrpm(term->grapheme_shaping);
case 8452: return decrpm(term->sixel.cursor_right_of_graphics);
case 737769: return decrpm(term_ime_is_enabled(term));
}
@@ -614,6 +619,7 @@ xtsave(struct terminal *term, unsigned param)
case 1070: term->xtsave.sixel_private_palette = term->sixel.use_private_palette; break;
case 2004: term->xtsave.bracketed_paste = term->bracketed_paste; break;
case 2026: term->xtsave.app_sync_updates = term->render.app_sync_updates.enabled; break;
+ case 2027: term->xtsave.grapheme_shaping = term->grapheme_shaping; break;
case 8452: term->xtsave.sixel_cursor_right_of_graphics = term->sixel.cursor_right_of_graphics; break;
case 737769: term->xtsave.ime = term_ime_is_enabled(term); break;
}
@@ -655,6 +661,7 @@ xtrestore(struct terminal *term, unsigned param)
case 1070: enable = term->xtsave.sixel_private_palette; break;
case 2004: enable = term->xtsave.bracketed_paste; break;
case 2026: enable = term->xtsave.app_sync_updates; break;
+ case 2027: enable = term->xtsave.grapheme_shaping; break;
case 8452: enable = term->xtsave.sixel_cursor_right_of_graphics; break;
case 737769: enable = term->xtsave.ime; break;
diff --git a/doc/foot-ctlseqs.7.scd b/doc/foot-ctlseqs.7.scd
index 3fa03158..d26bb39d 100644
--- a/doc/foot-ctlseqs.7.scd
+++ b/doc/foot-ctlseqs.7.scd
@@ -328,6 +328,9 @@ that corresponds to one of the following modes:
| 2026
: terminal-wg
: Application synchronized updates mode
+| 2027
+: contour
+: Grapheme cluster processing
| 8452
: xterm
: Position cursor to the right of sixels, instead of on the next line
diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd
index d9470626..24c42a5e 100644
--- a/doc/foot.ini.5.scd
+++ b/doc/foot.ini.5.scd
@@ -1307,6 +1307,8 @@ any of these options.
- foot must have been compiled with utf8proc support
- fcft must have been compiled with HarfBuzz support
+ This option can also be set runtime with DECSET/DECRST 2027.
+
See also: *grapheme-width-method*.
Default: _yes_
diff --git a/terminal.c b/terminal.c
index f19da873..1b082100 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1253,6 +1253,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
},
.foot_exe = xstrdup(foot_exe),
.cwd = xstrdup(cwd),
+ .grapheme_shaping = conf->tweak.grapheme_shaping,
#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
.ime_enabled = true,
#endif
@@ -1903,6 +1904,8 @@ term_reset(struct terminal *term, bool hard)
tll_remove(term->alt.sixel_images, it);
}
+ term->grapheme_shaping = term->conf->tweak.grapheme_shaping;
+
#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
term_ime_enable(term);
#endif
diff --git a/terminal.h b/terminal.h
index 624efd5c..da873ae6 100644
--- a/terminal.h
+++ b/terminal.h
@@ -469,6 +469,7 @@ struct terminal {
bool alt_screen:1;
bool ime:1;
bool app_sync_updates:1;
+ bool grapheme_shaping:1;
bool sixel_display_mode:1;
bool sixel_private_palette:1;
@@ -718,6 +719,8 @@ struct terminal {
char *foot_exe;
char *cwd;
+
+ bool grapheme_shaping;
};
struct config;
diff --git a/vt.c b/vt.c
index f6e8b79b..0f7bfe63 100644
--- a/vt.c
+++ b/vt.c
@@ -657,7 +657,7 @@ static void
action_utf8_print(struct terminal *term, char32_t wc)
{
int width = c32width(wc);
- const bool grapheme_clustering = term->conf->tweak.grapheme_shaping;
+ const bool grapheme_clustering = term->grapheme_shaping;
#if !defined(FOOT_GRAPHEME_CLUSTERING)
xassert(!grapheme_clustering);