From: simon Date: Mon, 9 Apr 2001 11:59:35 +0000 (+0000) Subject: Default handling of VT100 line drawing characters in cut and paste is X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/d3a22f7952add0b13fac029efb18faae537795bd Default handling of VT100 line drawing characters in cut and paste is now to translate them into poor man's characters (+--+ and |). We also have an option to disable this (and map line drawing characters to the corresponding ASCII code as before). Thanks to Robert de Bath. git-svn-id: svn://svn.tartarus.org/sgt/putty@1029 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/putty.h b/putty.h index 549349c4..755704c9 100644 --- a/putty.h +++ b/putty.h @@ -52,6 +52,7 @@ #define ERASE_CHAR (ATTR_DEFAULT | ' ') #define ATTR_MASK 0xFFFFFF00UL #define CHAR_MASK 0x000000FFUL +#define CSET_MASK 0x00F00000UL /* mask for character set */ typedef HDC Context; #define SEL_NL { 13, 10 } @@ -232,6 +233,7 @@ typedef struct { unsigned char colours[22][3]; /* Selection options */ int mouse_is_xterm; + int rawcnp; short wordness[256]; /* translations */ VT_Mode vtmode; diff --git a/settings.c b/settings.c index a5050501..ff23ad06 100644 --- a/settings.c +++ b/settings.c @@ -124,6 +124,7 @@ void save_settings (char *section, int do_host, Config *cfg) { cfg->colours[i][1], cfg->colours[i][2]); write_setting_s (sesskey, buf, buf2); } + write_setting_i (sesskey, "RawCNP", cfg->rawcnp); write_setting_i (sesskey, "MouseIsXterm", cfg->mouse_is_xterm); for (i=0; i<256; i+=32) { char buf[20], buf2[256]; @@ -296,6 +297,7 @@ void load_settings (char *section, int do_host, Config *cfg) { cfg->colours[i][2] = c2; } } + gppi (sesskey, "RawCNP", 0, &cfg->rawcnp); gppi (sesskey, "MouseIsXterm", 0, &cfg->mouse_is_xterm); for (i=0; i<256; i+=32) { static char *defaults[] = { diff --git a/terminal.c b/terminal.c index 0f4504ac..f205c31f 100644 --- a/terminal.c +++ b/terminal.c @@ -1948,34 +1948,34 @@ static void clipme(unsigned long *top, unsigned long *bottom, char *workbuf) { } while (top < nlpos && top < bottom) { -#if 0 - /* VT Specials -> ISO8859-1 */ - static const char poorman2[] = + int ch = (*top & CHAR_MASK); + int set = (*top & CSET_MASK); + + /* VT Specials -> ISO8859-1 for Cut&Paste */ + static const unsigned char poorman2[] = "* # HTFFCRLF\xB0 \xB1 NLVT+ + + + + - - - - - + + + + | <=>=PI!=\xA3 \xB7 "; -#endif - int ch = (*top & CHAR_MASK); + if (set && !cfg.rawcnp) { + if (set == ATTR_LINEDRW && ch >= 0x60 && ch < 0x7F) { + int x; + if ((x = poorman2[2*(ch-0x60)+1]) == ' ') + x = 0; + ch = (x<<8) + poorman2[2*(ch-0x60)]; + } + } -#if 0 - if ((*top & ATTR_LINEDRW) && ch >= 0x60 && ch < 0x7F) { - int x; - *wbptr++ = poorman2[2*(ch-0x60)]; - if ( (x = poorman2[2*(ch-0x60)+1]) != ' ') - *wbptr++ = x; - } else -#endif -#if 0 - if ((*top & ATTR_GBCHR) && ch == '#') - *wbptr++ = (unsigned char) 0xA3; - else -#endif - if ( wblen == buflen ) - { - workbuf = srealloc(workbuf, buflen += 100); - wbptr = workbuf + wblen; + while(ch != 0) { + if (cfg.rawcnp || !!(ch&0xE0)) { + if ( wblen == buflen ) + { + workbuf = srealloc(workbuf, buflen += 100); + wbptr = workbuf + wblen; + } + wblen++; + *wbptr++ = (unsigned char) ch; + } + ch>>=8; } - wblen++; - *wbptr++ = (unsigned char) ch; top++; } if (nl) { diff --git a/windlg.c b/windlg.c index 80b1adf5..391938a8 100644 --- a/windlg.c +++ b/windlg.c @@ -385,6 +385,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_TITLE_SELECTION, IDC_BOX_SELECTION1, IDC_BOX_SELECTION2, + IDC_BOX_SELECTION3, IDC_MBSTATIC, IDC_MBWINDOWS, IDC_MBXTERM, @@ -393,6 +394,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_CCSET, IDC_CCSTATIC2, IDC_CCEDIT, + IDC_RAWCNP, selectionpanelend, colourspanelstart, @@ -591,6 +593,7 @@ static void init_dlg_ctrls(HWND hwnd) { CheckRadioButton (hwnd, IDC_MBWINDOWS, IDC_MBXTERM, cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS); + CheckDlgButton (hwnd, IDC_RAWCNP, cfg.rawcnp); { static int tabs[4] = {25, 61, 96, 128}; SendDlgItemMessage (hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4, @@ -906,20 +909,25 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { } if (panel == selectionpanelstart) { - /* The Selection panel. Accelerators used: [acgo] wx hst */ + /* The Selection panel. Accelerators used: [acgo] d wx hst */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling copy and paste", IDC_TITLE_SELECTION); - beginbox(&cp, "Control which mouse button does which thing", + beginbox(&cp, "Translation of pasted characters", IDC_BOX_SELECTION1); + checkbox(&cp, "&Don't translate line drawing chars into +, - and |", + IDC_RAWCNP); + endbox(&cp); + beginbox(&cp, "Control which mouse button does which thing", + IDC_BOX_SELECTION2); radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC, "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS, "&xterm (Right extends, Middle pastes)", IDC_MBXTERM, NULL); endbox(&cp); beginbox(&cp, "Control the select-one-word-at-a-time mode", - IDC_BOX_SELECTION2); + IDC_BOX_SELECTION3); charclass(&cp, "C&haracter classes:", IDC_CCSTATIC, IDC_CCLIST, "&Set", IDC_CCSET, IDC_CCEDIT, "&to class", IDC_CCSTATIC2); @@ -1842,6 +1850,8 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, SetDlgItemText (hwnd, IDC_PKEDIT, cfg.keyfile); } break; + case IDC_RAWCNP: + cfg.rawcnp = IsDlgButtonChecked (hwnd, IDC_RAWCNP); case IDC_MBWINDOWS: case IDC_MBXTERM: cfg.mouse_is_xterm = IsDlgButtonChecked (hwnd, IDC_MBXTERM);