Introduction
Introduction Statistics Contact Development Disclaimer Help
st-nowide-20241013-0.8.2.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
st-nowide-20241013-0.8.2.diff (3230B)
---
1 From 6fb87a9dbdbdc344fec14d026adf2c84853794b3 Mon Sep 17 00:00:00 2001
2 From: 8dcc <[email protected]>
3 Date: Sun, 13 Oct 2024 14:45:12 +0200
4 Subject: [PATCH] Allow user to not render wide characters
5
6 This patch adds a new terminal mode, NOWIDE. If it's enabled, wide chara…
7 will be replaced with a faint question mark. This mode can be enabled or
8 disabled by default with the `renderwide' variable in <config.def.h>, an…
9 toggled with a keybind (Ctrl+Shift+W by default).
10
11 This mode is specially useful if your font doesn't support wide characte…
12 since rendering them usually makes the terminal really, really slow, spe…
13 when scrolling.
14
15 This patch is intended for ST 0.8.2, but it should be easy to port it to…
16 versions.
17 ---
18 config.def.h | 7 +++++++
19 st.c | 17 ++++++++++++++++-
20 st.h | 2 ++
21 3 files changed, 25 insertions(+), 1 deletion(-)
22
23 diff --git a/config.def.h b/config.def.h
24 index 0e01717..bc3f06f 100644
25 --- a/config.def.h
26 +++ b/config.def.h
27 @@ -56,6 +56,12 @@ static unsigned int blinktimeout = 800;
28 */
29 static unsigned int cursorthickness = 2;
30
31 +/*
32 + * should we render wide characters by default? Can be toggled with the
33 + * `togglewide' shortcut below.
34 + */
35 +int renderwide = 1;
36 +
37 /*
38 * bell volume. It must be a value between -100 and 100. Use 0 for disa…
39 * it
40 @@ -178,6 +184,7 @@ static Shortcut shortcuts[] = {
41 { TERMMOD, XK_Y, selpaste, {.i = …
42 { ShiftMask, XK_Insert, selpaste, {.i = …
43 { TERMMOD, XK_Num_Lock, numlock, {.i = …
44 + { TERMMOD, XK_W, togglewide, {.i = …
45 };
46
47 /*
48 diff --git a/st.c b/st.c
49 index b8e6077..c583b5c 100644
50 --- a/st.c
51 +++ b/st.c
52 @@ -52,6 +52,7 @@ enum term_mode {
53 MODE_PRINT = 1 << 5,
54 MODE_UTF8 = 1 << 6,
55 MODE_SIXEL = 1 << 7,
56 + MODE_NOWIDE = 1 << 8,
57 };
58
59 enum cursor_movement {
60 @@ -1029,6 +1030,8 @@ treset(void)
61 term.top = 0;
62 term.bot = term.row - 1;
63 term.mode = MODE_WRAP|MODE_UTF8;
64 + if (!renderwide)
65 + term.mode |= MODE_NOWIDE;
66 memset(term.trantbl, CS_USA, sizeof(term.trantbl));
67 term.charset = 0;
68
69 @@ -1980,6 +1983,12 @@ tprinter(char *s, size_t len)
70 }
71 }
72
73 +void
74 +togglewide(const Arg *arg)
75 +{
76 + term.mode ^= MODE_NOWIDE;
77 +}
78 +
79 void
80 toggleprinter(const Arg *arg)
81 {
82 @@ -2427,7 +2436,13 @@ check_control_code:
83 tsetchar(u, &term.c.attr, term.c.x, term.c.y);
84
85 if (width == 2) {
86 - gp->mode |= ATTR_WIDE;
87 + if (IS_SET(MODE_NOWIDE)) {
88 + gp[0].u = '?';
89 + gp[0].mode |= ATTR_FAINT;
90 + } else {
91 + gp[0].mode |= ATTR_WIDE;
92 + }
93 +
94 if (term.c.x+1 < term.col) {
95 gp[1].u = '\0';
96 gp[1].mode = ATTR_WDUMMY;
97 diff --git a/st.h b/st.h
98 index 38c61c4..0691246 100644
99 --- a/st.h
100 +++ b/st.h
101 @@ -83,6 +83,7 @@ void draw(void);
102 void printscreen(const Arg *);
103 void printsel(const Arg *);
104 void sendbreak(const Arg *);
105 +void togglewide(const Arg *);
106 void toggleprinter(const Arg *);
107
108 int tattrset(int);
109 @@ -116,6 +117,7 @@ extern char *stty_args;
110 extern char *vtiden;
111 extern char *worddelimiters;
112 extern int allowaltscreen;
113 +extern int renderwide;
114 extern char *termname;
115 extern unsigned int tabspaces;
116 extern unsigned int defaultfg;
117 --
118 2.46.2
119
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.