1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +00:00

xterm apparently supports ESC[90m through ESC[97m to set bright

foreground colours, and ESC[100m through ESC[107m to set bright
background colours. Hence, so do we. Bright-foreground is
distinguishable from bold, and bright-background distinguishable
from blink, when it leaves terminal.c; the front end may then choose
to display them in the same way if it's configured to do so. This
change makes the xterm backend for Turbo Vision (!!!) work properly.
Untested on Mac.

[originally from svn r2734]
This commit is contained in:
Simon Tatham 2003-01-27 23:03:31 +00:00
parent 6aa4211f6e
commit c370336a92
7 changed files with 75 additions and 61 deletions

View File

@ -1,4 +1,4 @@
\versionid $Id: config.but,v 1.51 2003/01/23 11:37:54 jacob Exp $
\versionid $Id: config.but,v 1.52 2003/01/27 23:03:30 simon Exp $
\C{config} Configuring PuTTY
@ -1282,9 +1282,10 @@ colour to go in place of the old one.
PuTTY allows you to set the cursor colour, the default foreground
and background, and the precise shades of all the ANSI configurable
colours (black, red, green, yellow, blue, magenta, cyan, and white).
In addition, if you have selected \q{Bolded text is a different
colour}, you can also modify the precise shades used for the bold
versions of these colours.
You can also modify the precise shades used for the bold versions of
these colours; these are used to display bold text if you have
selected \q{Bolded text is a different colour}, and can also be used
if the server asks specifically to use them.
\H{config-connection} The Connection panel

View File

@ -1,4 +1,4 @@
/* $Id: macterm.c,v 1.57 2003/01/27 00:39:01 ben Exp $ */
/* $Id: macterm.c,v 1.58 2003/01/27 23:03:30 simon Exp $ */
/*
* Copyright (c) 1999 Simon Tatham
* Copyright (c) 1999, 2002 Ben Harris
@ -1090,8 +1090,10 @@ static pascal void do_text_for_device(short depth, short devflags,
if (HAVE_COLOR_QD()) {
if (depth > 2) {
fgcolour = ((a->attr & ATTR_FGMASK) >> ATTR_FGSHIFT) * 2;
fgcolour = ((a->attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
fgcolour = (fgcolour & 0xF) * 2 + (fgcolour & 0x10 ? 1 : 0);
bgcolour = ((a->attr & ATTR_BGMASK) >> ATTR_BGSHIFT) * 2;
bgcolour = (bgcolour & 0xF) * 2 + (bgcolour & 0x10 ? 1 : 0);
} else {
/*
* NB: bold reverse in 2bpp breaks with the usual PuTTY model and
@ -1106,7 +1108,7 @@ static pascal void do_text_for_device(short depth, short devflags,
bgcolour = tmp;
}
if (bright && depth > 2)
fgcolour++;
fgcolour |= 1;
if ((a->attr & TATTR_ACTCURS) && depth > 1) {
fgcolour = CURSOR_FG;
bgcolour = CURSOR_BG;

26
putty.h
View File

@ -80,27 +80,27 @@ typedef struct terminal_tag Terminal;
*/
#define UCSWIDE 0xDFFF
#define ATTR_NARROW 0x20000000UL
#define ATTR_WIDE 0x10000000UL
#define ATTR_BOLD 0x01000000UL
#define ATTR_UNDER 0x02000000UL
#define ATTR_REVERSE 0x04000000UL
#define ATTR_BLINK 0x08000000UL
#define ATTR_FGMASK 0x000F0000UL
#define ATTR_BGMASK 0x00F00000UL
#define ATTR_COLOURS 0x00FF0000UL
#define ATTR_NARROW 0x80000000UL
#define ATTR_WIDE 0x40000000UL
#define ATTR_BOLD 0x04000000UL
#define ATTR_UNDER 0x08000000UL
#define ATTR_REVERSE 0x10000000UL
#define ATTR_BLINK 0x20000000UL
#define ATTR_FGMASK 0x001F0000UL
#define ATTR_BGMASK 0x03E00000UL
#define ATTR_COLOURS 0x03FF0000UL
#define ATTR_FGSHIFT 16
#define ATTR_BGSHIFT 20
#define ATTR_BGSHIFT 21
#define ATTR_DEFAULT 0x00980000UL
#define ATTR_DEFAULT 0x01280000UL
#define ATTR_DEFFG 0x00080000UL
#define ATTR_DEFBG 0x00900000UL
#define ATTR_DEFBG 0x01200000UL
#define ERASE_CHAR (ATTR_DEFAULT | ATTR_ASCII | ' ')
#define ATTR_MASK 0xFFFFFF00UL
#define CHAR_MASK 0x000000FFUL
#define ATTR_CUR_AND (~(ATTR_BOLD|ATTR_REVERSE|ATTR_BLINK|ATTR_COLOURS))
#define ATTR_CUR_XOR 0x00BA0000UL
#define ATTR_CUR_XOR 0x016A0000UL
struct sesslist {
int nsessions;

View File

@ -474,8 +474,9 @@ void term_size(Terminal *term, int newrows, int newcols, int newsavelines)
} else {
line = smalloc(TSIZE * (newcols + 2));
line[0] = newcols;
for (j = 0; j <= newcols; j++)
for (j = 0; j < newcols; j++)
line[j + 1] = ERASE_CHAR;
line[newcols] = LATTR_NORM;
}
addpos234(term->screen, line, 0);
}
@ -504,8 +505,9 @@ void term_size(Terminal *term, int newrows, int newcols, int newsavelines)
for (i = 0; i < newrows; i++) {
line = smalloc(TSIZE * (newcols + 2));
line[0] = newcols;
for (j = 0; j <= newcols; j++)
for (j = 0; j < newcols; j++)
line[j + 1] = term->erase_char;
line[newcols + 1] = LATTR_NORM;
addpos234(newalt, line, i);
}
if (term->alt_screen) {
@ -742,7 +744,7 @@ static void scroll(Terminal *term, int topline, int botline, int lines, int sb)
line = resizeline(line, term->cols);
for (i = 0; i < term->cols; i++)
line[i + 1] = term->erase_char;
line[term->cols + 1] = 0;
line[term->cols + 1] = LATTR_NORM;
addpos234(term->screen, line, botline);
/*
@ -972,10 +974,12 @@ static void erase_lots(Terminal *term,
ldata = lineptr(start.y);
while (poslt(start, end)) {
if (start.x == term->cols && !erase_lattr)
ldata[start.x] &= ~(LATTR_WRAPPED | LATTR_WRAPPED2);
else
if (start.x == term->cols) {
if (erase_lattr)
ldata[start.x] &= ~(LATTR_WRAPPED | LATTR_WRAPPED2);
} else {
ldata[start.x] = term->erase_char;
}
if (incpos(start) && start.y < term->rows)
ldata = lineptr(start.y);
}
@ -2281,6 +2285,20 @@ void term_out(Terminal *term)
term->curr_attr |=
(term->esc_args[i] - 30)<<ATTR_FGSHIFT;
break;
case 90:
case 91:
case 92:
case 93:
case 94:
case 95:
case 96:
case 97:
/* xterm-style bright foreground */
term->curr_attr &= ~ATTR_FGMASK;
term->curr_attr |=
((term->esc_args[i] - 90 + 16)
<< ATTR_FGSHIFT);
break;
case 39: /* default-foreground */
term->curr_attr &= ~ATTR_FGMASK;
term->curr_attr |= ATTR_DEFFG;
@ -2298,6 +2316,20 @@ void term_out(Terminal *term)
term->curr_attr |=
(term->esc_args[i] - 40)<<ATTR_BGSHIFT;
break;
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
case 106:
case 107:
/* xterm-style bright background */
term->curr_attr &= ~ATTR_BGMASK;
term->curr_attr |=
((term->esc_args[i] - 100 + 16)
<< ATTR_BGSHIFT);
break;
case 49: /* default-background */
term->curr_attr &= ~ATTR_BGMASK;
term->curr_attr |= ATTR_DEFBG;

View File

@ -1542,17 +1542,19 @@ void do_text_internal(Context ctx, int x, int y, char *text, int len,
int nfg, nbg, t, fontid, shadow, rlen, widefactor;
nfg = 2 * ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
nbg = 2 * ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
nfg = ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
nfg = 2 * (nfg & 0xF) + (nfg & 0x10 ? 1 : 0);
nbg = ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
nbg = 2 * (nbg & 0xF) + (nbg & 0x10 ? 1 : 0);
if (attr & ATTR_REVERSE) {
t = nfg;
nfg = nbg;
nbg = t;
}
if (inst->cfg.bold_colour && (attr & ATTR_BOLD))
nfg++;
nfg |= 1;
if (inst->cfg.bold_colour && (attr & ATTR_BLINK))
nbg++;
nbg |= 1;
if (attr & TATTR_ACTCURS) {
nfg = NCOLOURS-2;
nbg = NCOLOURS-1;

View File

@ -657,11 +657,6 @@ static const char *const colours[] = {
"ANSI Cyan", "ANSI Cyan Bold",
"ANSI White", "ANSI White Bold"
};
static const int permcolour[] = {
TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
};
static void fmtfont(char *buf)
{
@ -1308,9 +1303,8 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
SendDlgItemMessage(hwnd, IDC_COLOURLIST,
LB_DELETESTRING, i, 0);
for (i = 0; i < 22; i++)
if (cfg.bold_colour || permcolour[i])
SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
(LPARAM) colours[i]);
SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
(LPARAM) colours[i]);
}
SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
@ -3399,25 +3393,6 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
int n, i;
cfg.bold_colour =
IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
FALSE, 0);
n =
SendDlgItemMessage(hwnd, IDC_COLOURLIST,
LB_GETCOUNT, 0, 0);
if (n != 12 + 10 * cfg.bold_colour) {
for (i = n; i-- > 0;)
SendDlgItemMessage(hwnd, IDC_COLOURLIST,
LB_DELETESTRING, i, 0);
for (i = 0; i < 22; i++)
if (cfg.bold_colour || permcolour[i])
SendDlgItemMessage(hwnd, IDC_COLOURLIST,
LB_ADDSTRING, 0,
(LPARAM) colours[i]);
}
SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
TRUE, 0);
InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
TRUE);
}
break;
case IDC_PALETTE:

View File

@ -2798,8 +2798,10 @@ void do_text(Context ctx, int x, int y, char *text, int len,
if ((attr & CSET_MASK) == ATTR_OEMCP)
nfont |= FONT_OEM;
nfg = 2 * ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
nbg = 2 * ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
nfg = ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
nfg = 2 * (nfg & 0xF) + (nfg & 0x10 ? 1 : 0);
nbg = ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
nbg = 2 * (nbg & 0xF) + (nbg & 0x10 ? 1 : 0);
if (bold_mode == BOLD_FONT && (attr & ATTR_BOLD))
nfont |= FONT_BOLD;
if (und_mode == UND_FONT && (attr & ATTR_UNDER))
@ -2821,9 +2823,9 @@ void do_text(Context ctx, int x, int y, char *text, int len,
nbg = t;
}
if (bold_mode == BOLD_COLOURS && (attr & ATTR_BOLD))
nfg++;
nfg |= 1;
if (bold_mode == BOLD_COLOURS && (attr & ATTR_BLINK))
nbg++;
nbg |= 1;
fg = colours[nfg];
bg = colours[nbg];
SelectObject(hdc, fonts[nfont]);