mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 06:38:37 -05:00
Add an option to use wcwidth_cjk() instead of wcwidth(), as several people
have asked for it. [originally from svn r5542]
This commit is contained in:
parent
5b695d81ad
commit
faf59c78be
5
config.c
5
config.c
@ -1282,6 +1282,11 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
|
|||||||
'r', 100, HELPCTX(translation_codepage),
|
'r', 100, HELPCTX(translation_codepage),
|
||||||
codepage_handler, P(NULL), P(NULL));
|
codepage_handler, P(NULL), P(NULL));
|
||||||
|
|
||||||
|
s = ctrl_getset(b, "Window/Translation", "tweaks", NULL);
|
||||||
|
ctrl_checkbox(s, "Treat CJK ambiguous characters as wide", 'w',
|
||||||
|
HELPCTX(translation_cjk_ambig_wide),
|
||||||
|
dlg_stdcheckbox_handler, I(offsetof(Config,cjk_ambig_wide)));
|
||||||
|
|
||||||
str = dupprintf("Adjust how %s handles line drawing characters", appname);
|
str = dupprintf("Adjust how %s handles line drawing characters", appname);
|
||||||
s = ctrl_getset(b, "Window/Translation", "linedraw", str);
|
s = ctrl_getset(b, "Window/Translation", "linedraw", str);
|
||||||
sfree(str);
|
sfree(str);
|
||||||
|
@ -1213,6 +1213,24 @@ its name manually (\c{CP866} for example) in the list box. If the
|
|||||||
underlying version of Windows has the appropriate translation table
|
underlying version of Windows has the appropriate translation table
|
||||||
installed, PuTTY will use it.
|
installed, PuTTY will use it.
|
||||||
|
|
||||||
|
\S{config-cjk-ambig-wide} \q{Treat CJK ambiguous characters as wide}
|
||||||
|
|
||||||
|
\cfg{winhelp-topic}{translation.cjkambigwide}
|
||||||
|
|
||||||
|
There are \I{East Asian Ambiguous characters}some Unicode characters
|
||||||
|
whose width is not well-defined. In most contexts, such characters
|
||||||
|
should be treated as single-width for the purposes of wrapping and so
|
||||||
|
on; however, in some CJK contexts, they are better treated as
|
||||||
|
double-width for historical reasons, and some server-side applications
|
||||||
|
may expect them to be displayed as such. Setting this option will
|
||||||
|
cause PuTTY to take the double-width interpretation.
|
||||||
|
|
||||||
|
If you use legacy CJK applications, and you find your lines are
|
||||||
|
wrapping in the wrong places, or you are having other display
|
||||||
|
problems, you might want to play with this setting.
|
||||||
|
|
||||||
|
This option only has any effect in UTF-8 mode (see \k{config-charset}).
|
||||||
|
|
||||||
\S{config-cyr} \q{Caps Lock acts as Cyrillic switch}
|
\S{config-cyr} \q{Caps Lock acts as Cyrillic switch}
|
||||||
|
|
||||||
\cfg{winhelp-topic}{translation.cyrillic}
|
\cfg{winhelp-topic}{translation.cyrillic}
|
||||||
|
3
putty.h
3
putty.h
@ -525,6 +525,7 @@ struct config_tag {
|
|||||||
/* translations */
|
/* translations */
|
||||||
int vtmode;
|
int vtmode;
|
||||||
char line_codepage[128];
|
char line_codepage[128];
|
||||||
|
int cjk_ambig_wide;
|
||||||
int utf8_override;
|
int utf8_override;
|
||||||
int xlat_capslockcyr;
|
int xlat_capslockcyr;
|
||||||
/* X11 forwarding */
|
/* X11 forwarding */
|
||||||
@ -869,6 +870,8 @@ void get_unitab(int codepage, wchar_t * unitab, int ftype);
|
|||||||
*/
|
*/
|
||||||
int wcwidth(wchar_t ucs);
|
int wcwidth(wchar_t ucs);
|
||||||
int wcswidth(const wchar_t *pwcs, size_t n);
|
int wcswidth(const wchar_t *pwcs, size_t n);
|
||||||
|
int wcwidth_cjk(wchar_t ucs);
|
||||||
|
int wcswidth_cjk(const wchar_t *pwcs, size_t n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exports from mscrypto.c
|
* Exports from mscrypto.c
|
||||||
|
@ -339,6 +339,7 @@ void save_open_settings(void *sesskey, int do_host, Config *cfg)
|
|||||||
write_setting_s(sesskey, buf, buf2);
|
write_setting_s(sesskey, buf, buf2);
|
||||||
}
|
}
|
||||||
write_setting_s(sesskey, "LineCodePage", cfg->line_codepage);
|
write_setting_s(sesskey, "LineCodePage", cfg->line_codepage);
|
||||||
|
write_setting_i(sesskey, "CJKAmbigWide", cfg->cjk_ambig_wide);
|
||||||
write_setting_i(sesskey, "UTF8Override", cfg->utf8_override);
|
write_setting_i(sesskey, "UTF8Override", cfg->utf8_override);
|
||||||
write_setting_s(sesskey, "Printer", cfg->printer);
|
write_setting_s(sesskey, "Printer", cfg->printer);
|
||||||
write_setting_i(sesskey, "CapsLockCyr", cfg->xlat_capslockcyr);
|
write_setting_i(sesskey, "CapsLockCyr", cfg->xlat_capslockcyr);
|
||||||
@ -666,6 +667,7 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg)
|
|||||||
*/
|
*/
|
||||||
gpps(sesskey, "LineCodePage", "", cfg->line_codepage,
|
gpps(sesskey, "LineCodePage", "", cfg->line_codepage,
|
||||||
sizeof(cfg->line_codepage));
|
sizeof(cfg->line_codepage));
|
||||||
|
gppi(sesskey, "CJKAmbigWide", 0, &cfg->cjk_ambig_wide);
|
||||||
gppi(sesskey, "UTF8Override", 1, &cfg->utf8_override);
|
gppi(sesskey, "UTF8Override", 1, &cfg->utf8_override);
|
||||||
gpps(sesskey, "Printer", "", cfg->printer, sizeof(cfg->printer));
|
gpps(sesskey, "Printer", "", cfg->printer, sizeof(cfg->printer));
|
||||||
gppi (sesskey, "CapsLockCyr", 0, &cfg->xlat_capslockcyr);
|
gppi (sesskey, "CapsLockCyr", 0, &cfg->xlat_capslockcyr);
|
||||||
|
@ -2845,7 +2845,9 @@ static void term_out(Terminal *term)
|
|||||||
if (DIRECT_CHAR(c))
|
if (DIRECT_CHAR(c))
|
||||||
width = 1;
|
width = 1;
|
||||||
if (!width)
|
if (!width)
|
||||||
width = wcwidth((wchar_t) c);
|
width = (term->cfg.cjk_ambig_wide ?
|
||||||
|
wcwidth_cjk((wchar_t) c) :
|
||||||
|
wcwidth((wchar_t) c));
|
||||||
|
|
||||||
if (term->wrapnext && term->wrap && width > 0) {
|
if (term->wrapnext && term->wrap && width > 0) {
|
||||||
cline->lattr |= LATTR_WRAPPED;
|
cline->lattr |= LATTR_WRAPPED;
|
||||||
|
2
testdata/utf8.txt
vendored
2
testdata/utf8.txt
vendored
@ -19,3 +19,5 @@ Arabic and bidirectional text:
|
|||||||
عن [44mجرير[m [41mرضي[m الله عنه قال قال رسول الله صلى الله عليه
|
عن [44mجرير[m [41mرضي[m الله عنه قال قال رسول الله صلى الله عليه
|
||||||
وسلم: بني الاسلام على خمس شهادة ان لا اله الا الله واقام
|
وسلم: بني الاسلام على خمس شهادة ان لا اله الا الله واقام
|
||||||
Mixed LTR and RTL text: [44mجرير[m [41mرضي[m back to LTR.
|
Mixed LTR and RTL text: [44mجرير[m [41mرضي[m back to LTR.
|
||||||
|
|
||||||
|
East Asian Ambiguous characters: ¼½¾¼½¾¼½¾¼½¾¼½¾¼½¾¼½¾¼½¾¼½¾¼½¾
|
||||||
|
@ -146,7 +146,6 @@ int wcswidth(const wchar_t *pwcs, size_t n)
|
|||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* RDB: we don't need the cjk version */
|
|
||||||
/*
|
/*
|
||||||
* The following function is the same as wcwidth(), except that
|
* The following function is the same as wcwidth(), except that
|
||||||
* spacing characters in the East Asian Ambiguous (A) category as
|
* spacing characters in the East Asian Ambiguous (A) category as
|
||||||
@ -155,7 +154,7 @@ int wcswidth(const wchar_t *pwcs, size_t n)
|
|||||||
* encodings who want to migrate to UCS. It is not otherwise
|
* encodings who want to migrate to UCS. It is not otherwise
|
||||||
* recommended for general use.
|
* recommended for general use.
|
||||||
*/
|
*/
|
||||||
static int wcwidth_cjk(wchar_t ucs)
|
int wcwidth_cjk(wchar_t ucs)
|
||||||
{
|
{
|
||||||
/* sorted list of non-overlapping intervals of East Asian Ambiguous
|
/* sorted list of non-overlapping intervals of East Asian Ambiguous
|
||||||
* characters */
|
* characters */
|
||||||
@ -233,4 +232,3 @@ int wcswidth_cjk(const wchar_t *pwcs, size_t n)
|
|||||||
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
@ -177,8 +177,7 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
|||||||
* the least we can do is ensure it never makes it to any other
|
* the least we can do is ensure it never makes it to any other
|
||||||
* platform (at least unless someone fixes it!).
|
* platform (at least unless someone fixes it!).
|
||||||
*/
|
*/
|
||||||
s = ctrl_getset(b, "Window/Translation", "input",
|
s = ctrl_getset(b, "Window/Translation", "tweaks", NULL);
|
||||||
"Enable character set translation on input data");
|
|
||||||
ctrl_checkbox(s, "Caps Lock acts as Cyrillic switch", 's',
|
ctrl_checkbox(s, "Caps Lock acts as Cyrillic switch", 's',
|
||||||
HELPCTX(translation_cyrillic),
|
HELPCTX(translation_cyrillic),
|
||||||
dlg_stdcheckbox_handler,
|
dlg_stdcheckbox_handler,
|
||||||
|
@ -112,6 +112,7 @@
|
|||||||
#define WINHELP_CTX_colours_logpal "colours.logpal"
|
#define WINHELP_CTX_colours_logpal "colours.logpal"
|
||||||
#define WINHELP_CTX_colours_config "colours.config"
|
#define WINHELP_CTX_colours_config "colours.config"
|
||||||
#define WINHELP_CTX_translation_codepage "translation.codepage"
|
#define WINHELP_CTX_translation_codepage "translation.codepage"
|
||||||
|
#define WINHELP_CTX_translation_cjk_ambig_wide "translation.cjkambigwide"
|
||||||
#define WINHELP_CTX_translation_cyrillic "translation.cyrillic"
|
#define WINHELP_CTX_translation_cyrillic "translation.cyrillic"
|
||||||
#define WINHELP_CTX_translation_linedraw "translation.linedraw"
|
#define WINHELP_CTX_translation_linedraw "translation.linedraw"
|
||||||
#define WINHELP_CTX_ssh_tunnels_x11 "ssh.tunnels.x11"
|
#define WINHELP_CTX_ssh_tunnels_x11 "ssh.tunnels.x11"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user