| ︙ | | | ︙ | |
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
static int kbd_codepage;
static void *ldisc;
static Backend *back;
static void *backhandle;
static int session_closed;
Config cfg; /* exported to windlg.c */
extern struct sesslist sesslist; /* imported from windlg.c */
#define FONT_NORMAL 0
|
>
|
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
static int kbd_codepage;
static void *ldisc;
static Backend *back;
static void *backhandle;
static struct unicode_data ucsdata;
static int session_closed;
Config cfg; /* exported to windlg.c */
extern struct sesslist sesslist; /* imported from windlg.c */
#define FONT_NORMAL 0
|
| ︙ | | | ︙ | |
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
|
wndclass.lpszClassName = appname;
RegisterClass(&wndclass);
}
hwnd = NULL;
term = term_init(&cfg, NULL);
logctx = log_init(NULL, &cfg);
term_provide_logctx(term, logctx);
cfgtopalette();
/*
* Guess some defaults for the window size. This all gets
|
>
>
|
|
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
wndclass.lpszClassName = appname;
RegisterClass(&wndclass);
}
hwnd = NULL;
memset(&ucsdata, 0, sizeof(ucsdata));
term = term_init(&cfg, &ucsdata, NULL);
logctx = log_init(NULL, &cfg);
term_provide_logctx(term, logctx);
cfgtopalette();
/*
* Guess some defaults for the window size. This all gets
|
| ︙ | | | ︙ | |
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
|
{
CHARSETINFO info;
DWORD cset = tm.tmCharSet;
memset(&info, 0xFF, sizeof(info));
/* !!! Yes the next line is right */
if (cset == OEM_CHARSET)
font_codepage = GetOEMCP();
else
if (TranslateCharsetInfo
((DWORD *) cset, &info, TCI_SRCCHARSET)) font_codepage =
info.ciACP;
else
font_codepage = -1;
GetCPInfo(font_codepage, &cpinfo);
dbcs_screenfont = (cpinfo.MaxCharSize > 1);
}
f(FONT_UNDERLINE, cfg.fontcharset, fw_dontcare, TRUE);
/*
* Some fonts, e.g. 9-pt Courier, draw their underlines
* outside their character cell. We successfully prevent
|
|
|
<
|
|
|
|
|
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
|
{
CHARSETINFO info;
DWORD cset = tm.tmCharSet;
memset(&info, 0xFF, sizeof(info));
/* !!! Yes the next line is right */
if (cset == OEM_CHARSET)
ucsdata.font_codepage = GetOEMCP();
else
if (TranslateCharsetInfo ((DWORD *) cset, &info, TCI_SRCCHARSET))
ucsdata.font_codepage = info.ciACP;
else
ucsdata.font_codepage = -1;
GetCPInfo(ucsdata.font_codepage, &cpinfo);
ucsdata.dbcs_screenfont = (cpinfo.MaxCharSize > 1);
}
f(FONT_UNDERLINE, cfg.fontcharset, fw_dontcare, TRUE);
/*
* Some fonts, e.g. 9-pt Courier, draw their underlines
* outside their character cell. We successfully prevent
|
| ︙ | | | ︙ | |
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
|
fontsize[FONT_BOLD] != fontsize[FONT_NORMAL]) {
bold_mode = BOLD_SHADOW;
DeleteObject(fonts[FONT_BOLD]);
fonts[FONT_BOLD] = 0;
}
fontflag[0] = fontflag[1] = fontflag[2] = 1;
init_ucs(&cfg);
}
static void another_font(int fontno)
{
int basefont;
int fw_dontcare, fw_bold;
int c, u, w, x;
|
|
|
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
|
fontsize[FONT_BOLD] != fontsize[FONT_NORMAL]) {
bold_mode = BOLD_SHADOW;
DeleteObject(fonts[FONT_BOLD]);
fonts[FONT_BOLD] = 0;
}
fontflag[0] = fontflag[1] = fontflag[2] = 1;
init_ucs(&cfg, &ucsdata);
}
static void another_font(int fontno)
{
int basefont;
int fw_dontcare, fw_bold;
int c, u, w, x;
|
| ︙ | | | ︙ | |
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
|
case 0xBD:
text_adjust = 2 * font_height / 5;
break;
}
if (lattr == LATTR_TOP || lattr == LATTR_BOT)
text_adjust *= 2;
attr &= ~CSET_MASK;
text[0] = (char) (unitab_xterm['q'] & CHAR_MASK);
attr |= (unitab_xterm['q'] & CSET_MASK);
if (attr & ATTR_UNDER) {
attr &= ~ATTR_UNDER;
force_manual_underline = 1;
}
}
}
|
|
|
|
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
|
case 0xBD:
text_adjust = 2 * font_height / 5;
break;
}
if (lattr == LATTR_TOP || lattr == LATTR_BOT)
text_adjust *= 2;
attr &= ~CSET_MASK;
text[0] = (char) (ucsdata.unitab_xterm['q'] & CHAR_MASK);
attr |= (ucsdata.unitab_xterm['q'] & CSET_MASK);
if (attr & ATTR_UNDER) {
attr &= ~ATTR_UNDER;
force_manual_underline = 1;
}
}
}
|
| ︙ | | | ︙ | |
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
|
line_box.bottom = y + font_height;
/* Only want the left half of double width lines */
if (line_box.right > font_width*term->cols+offset_width)
line_box.right = font_width*term->cols+offset_width;
/* We're using a private area for direct to font. (512 chars.) */
if (dbcs_screenfont && (attr & CSET_MASK) == ATTR_ACP) {
/* Ho Hum, dbcs fonts are a PITA! */
/* To display on W9x I have to convert to UCS */
static wchar_t *uni_buf = 0;
static int uni_len = 0;
int nlen, mptr;
if (len > uni_len) {
sfree(uni_buf);
uni_buf = smalloc((uni_len = len) * sizeof(wchar_t));
}
for(nlen = mptr = 0; mptr<len; mptr++) {
uni_buf[nlen] = 0xFFFD;
if (IsDBCSLeadByteEx(font_codepage, (BYTE) text[mptr])) {
IpDx[nlen] += char_width;
MultiByteToWideChar(font_codepage, MB_USEGLYPHCHARS,
text+mptr, 2, uni_buf+nlen, 1);
mptr++;
}
else
{
MultiByteToWideChar(font_codepage, MB_USEGLYPHCHARS,
text+mptr, 1, uni_buf+nlen, 1);
}
nlen++;
}
if (nlen <= 0)
return; /* Eeek! */
|
|
|
|
|
|
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
|
line_box.bottom = y + font_height;
/* Only want the left half of double width lines */
if (line_box.right > font_width*term->cols+offset_width)
line_box.right = font_width*term->cols+offset_width;
/* We're using a private area for direct to font. (512 chars.) */
if (ucsdata.dbcs_screenfont && (attr & CSET_MASK) == ATTR_ACP) {
/* Ho Hum, dbcs fonts are a PITA! */
/* To display on W9x I have to convert to UCS */
static wchar_t *uni_buf = 0;
static int uni_len = 0;
int nlen, mptr;
if (len > uni_len) {
sfree(uni_buf);
uni_buf = smalloc((uni_len = len) * sizeof(wchar_t));
}
for(nlen = mptr = 0; mptr<len; mptr++) {
uni_buf[nlen] = 0xFFFD;
if (IsDBCSLeadByteEx(ucsdata.font_codepage, (BYTE) text[mptr])) {
IpDx[nlen] += char_width;
MultiByteToWideChar(ucsdata.font_codepage, MB_USEGLYPHCHARS,
text+mptr, 2, uni_buf+nlen, 1);
mptr++;
}
else
{
MultiByteToWideChar(ucsdata.font_codepage, MB_USEGLYPHCHARS,
text+mptr, 1, uni_buf+nlen, 1);
}
nlen++;
}
if (nlen <= 0)
return; /* Eeek! */
|
| ︙ | | | ︙ | |
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
|
/* If the font max is the same as the font ave width then this
* function is a no-op.
*/
if (!font_dualwidth) return 1;
switch (uc & CSET_MASK) {
case ATTR_ASCII:
uc = unitab_line[uc & 0xFF];
break;
case ATTR_LINEDRW:
uc = unitab_xterm[uc & 0xFF];
break;
case ATTR_SCOACS:
uc = unitab_scoacs[uc & 0xFF];
break;
}
if (DIRECT_FONT(uc)) {
if (dbcs_screenfont) return 1;
/* Speedup, I know of no font where ascii is the wrong width */
if ((uc&CHAR_MASK) >= ' ' && (uc&CHAR_MASK)<= '~')
return 1;
if ( (uc & CSET_MASK) == ATTR_ACP ) {
SelectObject(hdc, fonts[FONT_NORMAL]);
|
|
|
|
|
|
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
|
/* If the font max is the same as the font ave width then this
* function is a no-op.
*/
if (!font_dualwidth) return 1;
switch (uc & CSET_MASK) {
case ATTR_ASCII:
uc = ucsdata.unitab_line[uc & 0xFF];
break;
case ATTR_LINEDRW:
uc = ucsdata.unitab_xterm[uc & 0xFF];
break;
case ATTR_SCOACS:
uc = ucsdata.unitab_scoacs[uc & 0xFF];
break;
}
if (DIRECT_FONT(uc)) {
if (ucsdata.dbcs_screenfont) return 1;
/* Speedup, I know of no font where ascii is the wrong width */
if ((uc&CHAR_MASK) >= ' ' && (uc&CHAR_MASK)<= '~')
return 1;
if ( (uc & CSET_MASK) == ATTR_ACP ) {
SelectObject(hdc, fonts[FONT_NORMAL]);
|
| ︙ | | | ︙ | |
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
|
keystate[VK_CAPITAL] = 0;
}
r = ToAsciiEx(wParam, scan, keystate, keys, 0, kbd_layout);
#ifdef SHOW_TOASCII_RESULT
if (r == 1 && !key_down) {
if (alt_sum) {
if (in_utf(term) || dbcs_screenfont)
debug((", (U+%04x)", alt_sum));
else
debug((", LCH(%d)", alt_sum));
} else {
debug((", ACH(%d)", keys[0]));
}
} else if (r > 0) {
|
|
|
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
|
keystate[VK_CAPITAL] = 0;
}
r = ToAsciiEx(wParam, scan, keystate, keys, 0, kbd_layout);
#ifdef SHOW_TOASCII_RESULT
if (r == 1 && !key_down) {
if (alt_sum) {
if (in_utf(term) || ucsdata.dbcs_screenfont)
debug((", (U+%04x)", alt_sum));
else
debug((", LCH(%d)", alt_sum));
} else {
debug((", ACH(%d)", keys[0]));
}
} else if (r > 0) {
|
| ︙ | | | ︙ | |
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
|
continue;
}
compose_state = 0;
if (!key_down) {
if (alt_sum) {
if (in_utf(term) || dbcs_screenfont) {
keybuf = alt_sum;
term_seen_key_event(term);
luni_send(ldisc, &keybuf, 1, 1);
} else {
ch = (char) alt_sum;
/*
* We need not bother about stdin
|
|
|
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
|
continue;
}
compose_state = 0;
if (!key_down) {
if (alt_sum) {
if (in_utf(term) || ucsdata.dbcs_screenfont) {
keybuf = alt_sum;
term_seen_key_event(term);
luni_send(ldisc, &keybuf, 1, 1);
} else {
ch = (char) alt_sum;
/*
* We need not bother about stdin
|
| ︙ | | | ︙ | |
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
|
return p - output;
}
/* If we're definitly not building up an ALT-54321 then clear it */
if (!left_alt)
keys[0] = 0;
/* If we will be using alt_sum fix the 256s */
else if (keys[0] && (in_utf(term) || dbcs_screenfont))
keys[0] = 10;
}
/*
* ALT alone may or may not want to bring up the System menu.
* If it's not meant to, we return 0 on presses or releases of
* ALT, to show that we've swallowed the keystroke. Otherwise
|
|
|
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
|
return p - output;
}
/* If we're definitly not building up an ALT-54321 then clear it */
if (!left_alt)
keys[0] = 0;
/* If we will be using alt_sum fix the 256s */
else if (keys[0] && (in_utf(term) || ucsdata.dbcs_screenfont))
keys[0] = 10;
}
/*
* ALT alone may or may not want to bring up the System menu.
* If it's not meant to, we return 0 on presses or releases of
* ALT, to show that we've swallowed the keystroke. Otherwise
|
| ︙ | | | ︙ | |