xaizek / vifm-pdcurses (License: mostly public domain) (since 2019-03-20)
PDCurses 3.4 with vifm-specific patches applied (a couple were upstreamed)
Commit 1c1201af763df6023bfe52b7a60d23d1688472bd

Improve wide (CJK) characters handling on Windows
This change addresses issues with Windows Terminal of various versions
and partially ConEmu.

ConEmu works fine on Windows 10 unless colors >=16 are used. On Windows
7, it works better than before (was quite horrible), but there are still
issues.
Author: xaizek
Author date (UTC): 2024-12-19 23:15
Committer name: xaizek
Committer date (UTC): 2024-12-19 23:15
Parent(s): 895986be99522d9c5314718234134042d7fa766b
Signing key: 99DC5E4DB05F6BE2
Tree: 4015775a9c18a558b127da80be6855652b0bc354
File Lines added Lines deleted
wincon/pdcdisp.c 19 3
File wincon/pdcdisp.c changed (mode: 100644) (index 14418396..e3902c1e)
... ... void _new_packet(attr_t attr, int lineno, int x, int len, const chtype *srcp)
176 176 #else #else
177 177 char buffer[512]; char buffer[512];
178 178 #endif #endif
179 // Current offset in the output buffer, can be smaller than the offset
180 // in the input buffer (j).
181 int buf_len = 0;
179 182 for (j = 0; j < len; j++) for (j = 0; j < len; j++)
180 183 { {
181 184 chtype ch = srcp[j]; chtype ch = srcp[j];
 
... ... void _new_packet(attr_t attr, int lineno, int x, int len, const chtype *srcp)
191 194 if (blink && blinked_off) if (blink && blinked_off)
192 195 ch = ' '; ch = ' ';
193 196
194 buffer[j] = ch & A_CHARTEXT;
197 buffer[buf_len] = ch & A_CHARTEXT;
198
199 // In case of CJK characters input buffer is padded to account for
200 // their width being larger than one. This allows most of the code
201 // in the library which knows nothing of CJK to remain unchanged and
202 // naturaly take real width of such characters into account without
203 // handling them in any special way. However, need to jump over the
204 // padding when drawing things to avoid having it in the output.
205 int char_width = compat_wcwidth(buffer[buf_len]);
206 if (char_width < 0)
207 char_width = 1;
208 j += char_width - 1;
209
210 ++buf_len;
195 211 } }
196 212
197 213 PDC_gotoyx(lineno, x); PDC_gotoyx(lineno, x);
198 214 _set_ansi_color(fore, back, attr); _set_ansi_color(fore, back, attr);
199 215 #ifdef PDC_WIDE #ifdef PDC_WIDE
200 WriteConsoleW(pdc_con_out, buffer, len, NULL, NULL);
216 WriteConsoleW(pdc_con_out, buffer, buf_len, NULL, NULL);
201 217 #else #else
202 WriteConsoleA(pdc_con_out, buffer, len, NULL, NULL);
218 WriteConsoleA(pdc_con_out, buffer, buf_len, NULL, NULL);
203 219 #endif #endif
204 220 } }
205 221 else else
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm-pdcurses

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm-pdcurses

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master