1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00: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:
Jacob Nevins 2005-03-22 23:20:23 +00:00
parent 5b695d81ad
commit faf59c78be
9 changed files with 36 additions and 6 deletions

View File

@ -1282,6 +1282,11 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
'r', 100, HELPCTX(translation_codepage),
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);
s = ctrl_getset(b, "Window/Translation", "linedraw", str);
sfree(str);

View File

@ -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
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}
\cfg{winhelp-topic}{translation.cyrillic}

View File

@ -525,6 +525,7 @@ struct config_tag {
/* translations */
int vtmode;
char line_codepage[128];
int cjk_ambig_wide;
int utf8_override;
int xlat_capslockcyr;
/* X11 forwarding */
@ -869,6 +870,8 @@ void get_unitab(int codepage, wchar_t * unitab, int ftype);
*/
int wcwidth(wchar_t ucs);
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

View File

@ -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, "LineCodePage", cfg->line_codepage);
write_setting_i(sesskey, "CJKAmbigWide", cfg->cjk_ambig_wide);
write_setting_i(sesskey, "UTF8Override", cfg->utf8_override);
write_setting_s(sesskey, "Printer", cfg->printer);
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,
sizeof(cfg->line_codepage));
gppi(sesskey, "CJKAmbigWide", 0, &cfg->cjk_ambig_wide);
gppi(sesskey, "UTF8Override", 1, &cfg->utf8_override);
gpps(sesskey, "Printer", "", cfg->printer, sizeof(cfg->printer));
gppi (sesskey, "CapsLockCyr", 0, &cfg->xlat_capslockcyr);

View File

@ -2845,7 +2845,9 @@ static void term_out(Terminal *term)
if (DIRECT_CHAR(c))
width = 1;
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) {
cline->lattr |= LATTR_WRAPPED;

2
testdata/utf8.txt vendored
View File

@ -19,3 +19,5 @@ Arabic and bidirectional text:
عن جرير رضي الله عنه قال قال رسول الله صلى الله عليه
وسلم: بني الاسلام على خمس شهادة ان لا اله الا الله واقام
Mixed LTR and RTL text: جرير رضي back to LTR.
East Asian Ambiguous characters: ¼½¾¼½¾¼½¾¼½¾¼½¾¼½¾¼½¾¼½¾¼½¾¼½¾

View File

@ -146,7 +146,6 @@ int wcswidth(const wchar_t *pwcs, size_t n)
return width;
}
#if 0 /* RDB: we don't need the cjk version */
/*
* The following function is the same as wcwidth(), except that
* 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
* 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
* characters */
@ -233,4 +232,3 @@ int wcswidth_cjk(const wchar_t *pwcs, size_t n)
return width;
}
#endif

View File

@ -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
* platform (at least unless someone fixes it!).
*/
s = ctrl_getset(b, "Window/Translation", "input",
"Enable character set translation on input data");
s = ctrl_getset(b, "Window/Translation", "tweaks", NULL);
ctrl_checkbox(s, "Caps Lock acts as Cyrillic switch", 's',
HELPCTX(translation_cyrillic),
dlg_stdcheckbox_handler,

View File

@ -112,6 +112,7 @@
#define WINHELP_CTX_colours_logpal "colours.logpal"
#define WINHELP_CTX_colours_config "colours.config"
#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_linedraw "translation.linedraw"
#define WINHELP_CTX_ssh_tunnels_x11 "ssh.tunnels.x11"