mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Three more patches from RDB: one to make Atomica work right, one to
fiddle with the widths of characters in DBCS screen fonts, and (the big one) one to enable a mode in which resizing the window locks the terminal size and lets the font change, instead of vice versa. That should shut up a few feature requests! [originally from svn r1269]
This commit is contained in:
parent
abee2a59ab
commit
3d3ef9b8a4
9
putty.h
9
putty.h
@ -66,6 +66,7 @@
|
||||
#define UCSERR (ATTR_LINEDRW|'a') /* UCS Format error character. */
|
||||
#define UCSWIDE 0x303F
|
||||
|
||||
#define ATTR_NARROW 0x20000000UL
|
||||
#define ATTR_WIDE 0x10000000UL
|
||||
#define ATTR_BOLD 0x01000000UL
|
||||
#define ATTR_UNDER 0x02000000UL
|
||||
@ -92,8 +93,6 @@ typedef HDC Context;
|
||||
|
||||
GLOBAL int rows, cols, savelines;
|
||||
|
||||
GLOBAL int font_width, font_height;
|
||||
|
||||
#define INBUF_SIZE 2048
|
||||
GLOBAL unsigned char inbuf[INBUF_SIZE];
|
||||
GLOBAL int inbuf_head;
|
||||
@ -113,6 +112,7 @@ GLOBAL int repeat_off, cr_lf_return;
|
||||
|
||||
GLOBAL int seen_key_event;
|
||||
GLOBAL int seen_disp_event;
|
||||
GLOBAL int alt_pressed;
|
||||
|
||||
GLOBAL int session_closed;
|
||||
|
||||
@ -313,6 +313,7 @@ typedef struct {
|
||||
char bell_wavefile[FILENAME_MAX];
|
||||
int scrollbar;
|
||||
int locksize;
|
||||
int lockfont;
|
||||
int bce;
|
||||
int blinktext;
|
||||
int win_name_always;
|
||||
@ -326,6 +327,7 @@ typedef struct {
|
||||
int logxfovr;
|
||||
int hide_mouseptr;
|
||||
int sunken_edge;
|
||||
int window_border;
|
||||
char answerback[256];
|
||||
/* Colour options */
|
||||
int try_palette;
|
||||
@ -386,9 +388,10 @@ struct RSAKey; /* be a little careful of scope */
|
||||
/*
|
||||
* Exports from window.c.
|
||||
*/
|
||||
void request_resize(int, int, int);
|
||||
void request_resize(int, int);
|
||||
void do_text(Context, int, int, char *, int, unsigned long, int);
|
||||
void do_cursor(Context, int, int, char *, int, unsigned long, int);
|
||||
int CharWidth(Context ctx, int uc);
|
||||
void set_title(char *);
|
||||
void set_icon(char *);
|
||||
void set_sbar(int, int, int);
|
||||
|
@ -201,6 +201,7 @@ void save_settings(char *section, int do_host, Config * cfg)
|
||||
write_setting_i(sesskey, "FullScreenOnAltEnter", cfg->fullscreenonaltenter);
|
||||
write_setting_i(sesskey, "HideMousePtr", cfg->hide_mouseptr);
|
||||
write_setting_i(sesskey, "SunkenEdge", cfg->sunken_edge);
|
||||
write_setting_i(sesskey, "WindowBorder", cfg->window_border);
|
||||
write_setting_i(sesskey, "CurType", cfg->cursor_type);
|
||||
write_setting_i(sesskey, "BlinkCur", cfg->blink_cur);
|
||||
write_setting_i(sesskey, "Beep", cfg->beep);
|
||||
@ -251,6 +252,7 @@ void save_settings(char *section, int do_host, Config * cfg)
|
||||
write_setting_i(sesskey, "ScrollOnKey", cfg->scroll_on_key);
|
||||
write_setting_i(sesskey, "ScrollOnDisp", cfg->scroll_on_disp);
|
||||
write_setting_i(sesskey, "LockSize", cfg->locksize);
|
||||
write_setting_i(sesskey, "LockFont", cfg->lockfont);
|
||||
write_setting_i(sesskey, "BCE", cfg->bce);
|
||||
write_setting_i(sesskey, "BlinkText", cfg->blinktext);
|
||||
write_setting_i(sesskey, "X11Forward", cfg->x11_forward);
|
||||
@ -378,6 +380,7 @@ void load_settings(char *section, int do_host, Config * cfg)
|
||||
gppi(sesskey, "FullScreenOnAltEnter", 0, &cfg->fullscreenonaltenter);
|
||||
gppi(sesskey, "HideMousePtr", 0, &cfg->hide_mouseptr);
|
||||
gppi(sesskey, "SunkenEdge", 0, &cfg->sunken_edge);
|
||||
gppi(sesskey, "WindowBorder", 1, &cfg->window_border);
|
||||
gppi(sesskey, "CurType", 0, &cfg->cursor_type);
|
||||
gppi(sesskey, "BlinkCur", 0, &cfg->blink_cur);
|
||||
/* pedantic compiler tells me I can't use &cfg->beep as an int * :-) */
|
||||
@ -397,7 +400,7 @@ void load_settings(char *section, int do_host, Config * cfg)
|
||||
gpps(sesskey, "WinTitle", "", cfg->wintitle, sizeof(cfg->wintitle));
|
||||
gppi(sesskey, "TermWidth", 80, &cfg->width);
|
||||
gppi(sesskey, "TermHeight", 24, &cfg->height);
|
||||
gpps(sesskey, "Font", "Courier", cfg->font, sizeof(cfg->font));
|
||||
gpps(sesskey, "Font", "Courier New", cfg->font, sizeof(cfg->font));
|
||||
gppi(sesskey, "FontIsBold", 0, &cfg->fontisbold);
|
||||
gppi(sesskey, "FontCharSet", ANSI_CHARSET, &cfg->fontcharset);
|
||||
gppi(sesskey, "FontHeight", 10, &cfg->fontheight);
|
||||
@ -413,7 +416,7 @@ void load_settings(char *section, int do_host, Config * cfg)
|
||||
newh--;
|
||||
cfg->fontheight = newh;
|
||||
}
|
||||
gppi(sesskey, "FontVTMode", VT_OEMANSI, (int *) &cfg->vtmode);
|
||||
gppi(sesskey, "FontVTMode", VT_UNICODE, (int *) &cfg->vtmode);
|
||||
gppi(sesskey, "TryPalette", 0, &cfg->try_palette);
|
||||
gppi(sesskey, "BoldAsColour", 1, &cfg->bold_colour);
|
||||
for (i = 0; i < 22; i++) {
|
||||
@ -472,6 +475,7 @@ void load_settings(char *section, int do_host, Config * cfg)
|
||||
gppi(sesskey, "ScrollOnKey", 0, &cfg->scroll_on_key);
|
||||
gppi(sesskey, "ScrollOnDisp", 1, &cfg->scroll_on_disp);
|
||||
gppi(sesskey, "LockSize", 0, &cfg->locksize);
|
||||
gppi(sesskey, "LockFont", cfg->locksize, &cfg->lockfont);
|
||||
gppi(sesskey, "BCE", 0, &cfg->bce);
|
||||
gppi(sesskey, "BlinkText", 0, &cfg->blinktext);
|
||||
gppi(sesskey, "X11Forward", 0, &cfg->x11_forward);
|
||||
|
73
terminal.c
73
terminal.c
@ -497,6 +497,7 @@ void term_size(int newrows, int newcols, int newsavelines)
|
||||
|
||||
update_sbar();
|
||||
term_update();
|
||||
back->size();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -851,7 +852,7 @@ static void toggle_mode(int mode, int query, int state)
|
||||
break;
|
||||
case 3: /* 80/132 columns */
|
||||
deselect();
|
||||
request_resize(state ? 132 : 80, rows, 1);
|
||||
request_resize(state ? 132 : 80, rows);
|
||||
reset_132 = state;
|
||||
break;
|
||||
case 5: /* reverse video */
|
||||
@ -1339,12 +1340,18 @@ void term_out(void)
|
||||
width = wcwidth((wchar_t) c);
|
||||
switch (width) {
|
||||
case 2:
|
||||
if (curs.x + 1 != cols) {
|
||||
*cpos++ = c | ATTR_WIDE | curr_attr;
|
||||
*cpos++ = UCSWIDE | curr_attr;
|
||||
curs.x++;
|
||||
break;
|
||||
*cpos++ = c | curr_attr;
|
||||
if (++curs.x == cols) {
|
||||
*cpos |= LATTR_WRAPPED;
|
||||
if (curs.y == marg_b)
|
||||
scroll(marg_t, marg_b, 1, TRUE);
|
||||
else if (curs.y < rows - 1)
|
||||
curs.y++;
|
||||
curs.x = 0;
|
||||
fix_cpos;
|
||||
}
|
||||
*cpos++ = UCSWIDE | curr_attr;
|
||||
break;
|
||||
case 1:
|
||||
*cpos++ = c | curr_attr;
|
||||
break;
|
||||
@ -1461,7 +1468,7 @@ void term_out(void)
|
||||
compatibility(VT100);
|
||||
power_on();
|
||||
if (reset_132) {
|
||||
request_resize(80, rows, 1);
|
||||
request_resize(80, rows);
|
||||
reset_132 = 0;
|
||||
}
|
||||
fix_cpos;
|
||||
@ -1906,7 +1913,7 @@ void term_out(void)
|
||||
compatibility(VT340TEXT);
|
||||
if (esc_nargs <= 1
|
||||
&& (esc_args[0] < 1 || esc_args[0] >= 24)) {
|
||||
request_resize(cols, def(esc_args[0], 24), 0);
|
||||
request_resize(cols, def(esc_args[0], 24));
|
||||
deselect();
|
||||
}
|
||||
break;
|
||||
@ -1932,9 +1939,7 @@ void term_out(void)
|
||||
*/
|
||||
compatibility(VT420);
|
||||
if (esc_nargs == 1 && esc_args[0] > 0) {
|
||||
request_resize(cols,
|
||||
def(esc_args[0], cfg.height),
|
||||
0);
|
||||
request_resize(cols, def(esc_args[0], cfg.height));
|
||||
deselect();
|
||||
}
|
||||
break;
|
||||
@ -1945,8 +1950,7 @@ void term_out(void)
|
||||
*/
|
||||
compatibility(VT340TEXT);
|
||||
if (esc_nargs <= 1) {
|
||||
request_resize(def(esc_args[0], cfg.width),
|
||||
rows, 0);
|
||||
request_resize(def(esc_args[0], cfg.width), rows);
|
||||
deselect();
|
||||
}
|
||||
break;
|
||||
@ -2074,9 +2078,9 @@ void term_out(void)
|
||||
*/
|
||||
if (!has_compat(VT420) && has_compat(VT100)) {
|
||||
if (reset_132)
|
||||
request_resize(132, 24, 1);
|
||||
request_resize(132, 24);
|
||||
else
|
||||
request_resize(80, 24, 1);
|
||||
request_resize(80, 24);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -2531,9 +2535,10 @@ static void do_paint(Context ctx, int may_optimise)
|
||||
if (dispcurs && (curstype != cursor ||
|
||||
dispcurs !=
|
||||
disptext + our_curs_y * (cols + 1) + curs.x)) {
|
||||
if (dispcurs > disptext && (dispcurs[-1] & ATTR_WIDE))
|
||||
if (dispcurs > disptext &&
|
||||
(*dispcurs & (CHAR_MASK | CSET_MASK)) == UCSWIDE)
|
||||
dispcurs[-1] |= ATTR_INVALID;
|
||||
if ((*dispcurs & ATTR_WIDE))
|
||||
if ( (dispcurs[1] & (CHAR_MASK | CSET_MASK)) == UCSWIDE)
|
||||
dispcurs[1] |= ATTR_INVALID;
|
||||
*dispcurs |= ATTR_INVALID;
|
||||
curstype = 0;
|
||||
@ -2580,6 +2585,8 @@ static void do_paint(Context ctx, int may_optimise)
|
||||
}
|
||||
tattr |= (tchar & CSET_MASK);
|
||||
tchar &= CHAR_MASK;
|
||||
if ((d[1] & (CHAR_MASK | CSET_MASK)) == UCSWIDE)
|
||||
tattr |= ATTR_WIDE;
|
||||
|
||||
/* Video reversing things */
|
||||
tattr = (tattr ^ rv
|
||||
@ -2596,6 +2603,17 @@ static void do_paint(Context ctx, int may_optimise)
|
||||
tattr &= ~ATTR_BLINK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the font we'll _probably_ be using to see if
|
||||
* the character is wide when we don't want it to be.
|
||||
*/
|
||||
if ((tchar | tattr) != (disptext[idx]& ~ATTR_NARROW)) {
|
||||
if ((tattr & ATTR_WIDE) == 0 &&
|
||||
CharWidth(ctx, (tchar | tattr) & 0xFFFF) == 2)
|
||||
tattr |= ATTR_NARROW;
|
||||
} else if (disptext[idx]&ATTR_NARROW)
|
||||
tattr |= ATTR_NARROW;
|
||||
|
||||
/* Cursor here ? Save the 'background' */
|
||||
if (i == our_curs_y && j == curs.x) {
|
||||
cursor_background = tattr | tchar;
|
||||
@ -2716,14 +2734,14 @@ void term_invalidate(void)
|
||||
/*
|
||||
* Paint the window in response to a WM_PAINT message.
|
||||
*/
|
||||
void term_paint(Context ctx, int l, int t, int r, int b)
|
||||
void term_paint(Context ctx, int left, int top, int right, int bottom)
|
||||
{
|
||||
int i, j, left, top, right, bottom;
|
||||
int i, j;
|
||||
if (left < 0) left = 0;
|
||||
if (top < 0) top = 0;
|
||||
if (right >= cols) right = cols-1;
|
||||
if (bottom >= rows) bottom = rows-1;
|
||||
|
||||
left = l / font_width;
|
||||
right = (r - 1) / font_width;
|
||||
top = t / font_height;
|
||||
bottom = (b - 1) / font_height;
|
||||
for (i = top; i <= bottom && i < rows; i++) {
|
||||
if ((disptext[i * (cols + 1) + cols] & LATTR_MODE) == LATTR_NORM)
|
||||
for (j = left; j <= right && j < cols; j++)
|
||||
@ -2736,8 +2754,9 @@ void term_paint(Context ctx, int l, int t, int r, int b)
|
||||
/* This should happen soon enough, also for some reason it sometimes
|
||||
* fails to actually do anything when re-sizing ... painting the wrong
|
||||
* window perhaps ?
|
||||
do_paint (ctx, FALSE);
|
||||
*/
|
||||
if (alt_pressed)
|
||||
do_paint (ctx, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2987,6 +3006,12 @@ static int wordtype(int uc)
|
||||
break;
|
||||
}
|
||||
|
||||
/* For DBCS font's I can't do anything usefull. Even this will sometimes
|
||||
* fail as there's such a thing as a double width space. :-(
|
||||
*/
|
||||
if (dbcs_screenfont && font_codepage == line_codepage)
|
||||
return (uc != ' ');
|
||||
|
||||
if (uc < 0x80)
|
||||
return wordness[uc];
|
||||
|
||||
|
@ -393,6 +393,13 @@ void init_ucs_tables(void)
|
||||
link_font(unitab_xterm, unitab_oemcp, ATTR_OEMCP);
|
||||
}
|
||||
|
||||
if (dbcs_screenfont && font_codepage != line_codepage) {
|
||||
/* F***ing Microsoft fonts, Japanese and Korean codepage fonts
|
||||
* have a currency symbol at 0x5C but their unicode value is
|
||||
* still given as U+005C not the correct U+00A5. */
|
||||
unitab_line['\\'] = ATTR_OEMCP + '\\';
|
||||
}
|
||||
|
||||
/* Last chance, if !unicode then try poorman links. */
|
||||
if (cfg.vtmode != VT_UNICODE) {
|
||||
static char poorman_scoacs[] =
|
||||
@ -537,7 +544,7 @@ int check_compose(int first, int second)
|
||||
0x43, 0x2f, 0x00a2}, {
|
||||
0x43, 0x7c, 0x00a2}, {
|
||||
0x4c, 0x2d, 0x00a3}, {
|
||||
0x4c, 0x3d, 0x00a3}, {
|
||||
0x4c, 0x3d, 0x20a4}, {
|
||||
0x58, 0x4f, 0x00a4}, {
|
||||
0x58, 0x30, 0x00a4}, {
|
||||
0x59, 0x2d, 0x00a5}, {
|
||||
|
27
windlg.c
27
windlg.c
@ -355,6 +355,7 @@ enum { IDCX_ABOUT =
|
||||
IDC_COLSSTATIC,
|
||||
IDC_COLSEDIT,
|
||||
IDC_LOCKSIZE,
|
||||
IDC_LOCKFONT,
|
||||
IDC_SCROLLBAR,
|
||||
IDC_CLOSEWARN,
|
||||
IDC_SAVESTATIC,
|
||||
@ -387,6 +388,8 @@ enum { IDCX_ABOUT =
|
||||
IDC_WINNAME,
|
||||
IDC_HIDEMOUSE,
|
||||
IDC_SUNKENEDGE,
|
||||
IDC_WINBSTATIC,
|
||||
IDC_WINBEDIT,
|
||||
appearancepanelend,
|
||||
|
||||
connectionpanelstart,
|
||||
@ -662,12 +665,14 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
|
||||
CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
|
||||
CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
|
||||
CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
|
||||
SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
|
||||
CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
|
||||
cfg.cursor_type == 0 ? IDC_CURBLOCK :
|
||||
cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
|
||||
CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
|
||||
CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
|
||||
CheckDlgButton(hwnd, IDC_LOCKSIZE, cfg.locksize);
|
||||
CheckDlgButton(hwnd, IDC_LOCKFONT, cfg.lockfont);
|
||||
CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
|
||||
cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
|
||||
cfg.close_on_exit ==
|
||||
@ -1037,7 +1042,8 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
|
||||
multiedit(&cp,
|
||||
"&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
|
||||
"Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
|
||||
checkbox(&cp, "Lock window size against resi&zing", IDC_LOCKSIZE);
|
||||
checkbox(&cp, "Lock terminal size against resi&zing", IDC_LOCKSIZE);
|
||||
checkbox(&cp, "Lock font size against resi&zing", IDC_LOCKFONT);
|
||||
endbox(&cp);
|
||||
beginbox(&cp, "Control the scrollback in the window",
|
||||
IDC_BOX_WINDOW2);
|
||||
@ -1062,8 +1068,8 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
|
||||
/* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
|
||||
struct ctlpos cp;
|
||||
ctlposinit(&cp, hwnd, 80, 3, 13);
|
||||
bartitle(&cp, "Options controlling PuTTY's appearance",
|
||||
IDC_TITLE_APPEARANCE);
|
||||
/* bartitle(&cp, "Options controlling PuTTY's appearance",
|
||||
IDC_TITLE_APPEARANCE); */
|
||||
beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
|
||||
radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
|
||||
"B&lock", IDC_CURBLOCK,
|
||||
@ -1089,6 +1095,8 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
|
||||
beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
|
||||
checkbox(&cp, "&Sunken-edge border (slightly thicker)",
|
||||
IDC_SUNKENEDGE);
|
||||
staticedit(&cp, "Gap between text and window edge",
|
||||
IDC_WINBSTATIC, IDC_WINBEDIT, 20);
|
||||
endbox(&cp);
|
||||
}
|
||||
|
||||
@ -2058,6 +2066,13 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
|
||||
cfg.sunken_edge =
|
||||
IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
|
||||
break;
|
||||
case IDC_WINBEDIT:
|
||||
if (HIWORD(wParam) == EN_CHANGE)
|
||||
MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
|
||||
&cfg.window_border);
|
||||
if (cfg.window_border > 32)
|
||||
cfg.window_border = 32;
|
||||
break;
|
||||
case IDC_CURBLOCK:
|
||||
if (HIWORD(wParam) == BN_CLICKED ||
|
||||
HIWORD(wParam) == BN_DOUBLECLICKED)
|
||||
@ -2091,6 +2106,12 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
|
||||
cfg.locksize =
|
||||
IsDlgButtonChecked(hwnd, IDC_LOCKSIZE);
|
||||
break;
|
||||
case IDC_LOCKFONT:
|
||||
if (HIWORD(wParam) == BN_CLICKED ||
|
||||
HIWORD(wParam) == BN_DOUBLECLICKED)
|
||||
cfg.lockfont =
|
||||
IsDlgButtonChecked(hwnd, IDC_LOCKFONT);
|
||||
break;
|
||||
case IDC_WINEDIT:
|
||||
if (HIWORD(wParam) == EN_CHANGE)
|
||||
GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
|
||||
|
Loading…
Reference in New Issue
Block a user