mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-27 02:02:26 +00:00
Attribute masking implemented. The variable attr_mask stored the current
set of "interesting" attributes, and do_paint only takes those ones into account when deciding when to break style runs. Makes redraw quite a bit faster on displays which don't do ANSI colour. [originally from svn r102]
This commit is contained in:
parent
61504ef68c
commit
c7c358fa3f
39
macterm.c
39
macterm.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macterm.c,v 1.1.2.21 1999/03/14 15:51:34 ben Exp $ */
|
/* $Id: macterm.c,v 1.1.2.22 1999/03/14 17:43:35 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Ben Harris
|
* Copyright (c) 1999 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -77,6 +77,7 @@ static void mac_initpalette(struct mac_session *);
|
|||||||
static void mac_adjustsize(struct mac_session *, int, int);
|
static void mac_adjustsize(struct mac_session *, int, int);
|
||||||
static pascal void mac_scrolltracker(ControlHandle, short);
|
static pascal void mac_scrolltracker(ControlHandle, short);
|
||||||
static pascal void do_text_for_device(short, short, GDHandle, long);
|
static pascal void do_text_for_device(short, short, GDHandle, long);
|
||||||
|
static pascal void mac_set_attr_mask(short, short, GDHandle, long);
|
||||||
static int mac_keytrans(struct mac_session *, EventRecord *, unsigned char *);
|
static int mac_keytrans(struct mac_session *, EventRecord *, unsigned char *);
|
||||||
static void text_click(struct mac_session *, EventRecord *);
|
static void text_click(struct mac_session *, EventRecord *);
|
||||||
|
|
||||||
@ -138,6 +139,7 @@ void mac_newsession(void) {
|
|||||||
term_size(cfg.height, cfg.width, cfg.savelines);
|
term_size(cfg.height, cfg.width, cfg.savelines);
|
||||||
mac_initfont(s);
|
mac_initfont(s);
|
||||||
mac_initpalette(s);
|
mac_initpalette(s);
|
||||||
|
attr_mask = ATTR_MASK;
|
||||||
/* Set to FALSE to not get palette updates in the background. */
|
/* Set to FALSE to not get palette updates in the background. */
|
||||||
SetPalette(s->window, s->palette, TRUE);
|
SetPalette(s->window, s->palette, TRUE);
|
||||||
ActivatePalette(s->window);
|
ActivatePalette(s->window);
|
||||||
@ -560,6 +562,7 @@ void mac_updateterm(WindowPtr window) {
|
|||||||
|
|
||||||
s = (struct mac_session *)GetWRefCon(window);
|
s = (struct mac_session *)GetWRefCon(window);
|
||||||
BeginUpdate(window);
|
BeginUpdate(window);
|
||||||
|
get_ctx();
|
||||||
term_paint(s,
|
term_paint(s,
|
||||||
(*window->visRgn)->rgnBBox.left,
|
(*window->visRgn)->rgnBBox.left,
|
||||||
(*window->visRgn)->rgnBBox.top,
|
(*window->visRgn)->rgnBBox.top,
|
||||||
@ -577,6 +580,7 @@ void mac_updateterm(WindowPtr window) {
|
|||||||
DrawGrowIcon(window);
|
DrawGrowIcon(window);
|
||||||
clip.left = SHRT_MIN;
|
clip.left = SHRT_MIN;
|
||||||
ClipRect(&clip);
|
ClipRect(&clip);
|
||||||
|
free_ctx(NULL);
|
||||||
EndUpdate(window);
|
EndUpdate(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,10 +645,7 @@ static pascal void do_text_for_device(short depth, short devflags,
|
|||||||
|
|
||||||
bright = (a->attr & ATTR_BOLD) && cfg.bold_colour;
|
bright = (a->attr & ATTR_BOLD) && cfg.bold_colour;
|
||||||
|
|
||||||
if (a->attr & ATTR_REVERSE)
|
TextMode(a->attr & ATTR_REVERSE ? notSrcCopy : srcCopy);
|
||||||
TextMode(notSrcCopy);
|
|
||||||
else
|
|
||||||
TextMode(srcCopy);
|
|
||||||
|
|
||||||
switch (depth) {
|
switch (depth) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -652,7 +653,7 @@ static pascal void do_text_for_device(short depth, short devflags,
|
|||||||
ForeColor(whiteColor);
|
ForeColor(whiteColor);
|
||||||
BackColor(blackColor);
|
BackColor(blackColor);
|
||||||
if (a->attr & ATTR_ACTCURS)
|
if (a->attr & ATTR_ACTCURS)
|
||||||
TextMode((a->attr & ATTR_REVERSE) ? srcCopy : notSrcCopy);
|
TextMode(a->attr & ATTR_REVERSE ? srcCopy : notSrcCopy);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (a->attr & ATTR_ACTCURS) {
|
if (a->attr & ATTR_ACTCURS) {
|
||||||
@ -666,7 +667,7 @@ static pascal void do_text_for_device(short depth, short devflags,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (a->attr & ATTR_ACTCURS) {
|
if (a->attr & ATTR_ACTCURS) {
|
||||||
fgcolour = (bright ? CURSOR_FG_BOLD : CURSOR_FG);
|
fgcolour = bright ? CURSOR_FG_BOLD : CURSOR_FG;
|
||||||
bgcolour = CURSOR_BG;
|
bgcolour = CURSOR_BG;
|
||||||
TextMode(srcCopy);
|
TextMode(srcCopy);
|
||||||
} else {
|
} else {
|
||||||
@ -702,10 +703,32 @@ static pascal void do_text_for_device(short depth, short devflags,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Call from the terminal emulator to get its graphics context.
|
* Call from the terminal emulator to get its graphics context.
|
||||||
|
* Should probably be called start_redraw or something.
|
||||||
*/
|
*/
|
||||||
struct mac_session *get_ctx(void) {
|
struct mac_session *get_ctx(void) {
|
||||||
|
struct mac_session *s = onlysession;
|
||||||
|
|
||||||
return onlysession;
|
attr_mask = ATTR_INVALID;
|
||||||
|
DeviceLoop(s->window->visRgn, mac_set_attr_mask, (long)s, 0);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
static pascal void mac_set_attr_mask(short depth, short devflags,
|
||||||
|
GDHandle device, long cookie) {
|
||||||
|
|
||||||
|
switch (depth) {
|
||||||
|
default:
|
||||||
|
attr_mask |= ATTR_FGMASK | ATTR_BGMASK;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
case 2:
|
||||||
|
attr_mask |= ATTR_BOLD;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
case 1:
|
||||||
|
attr_mask |= ATTR_UNDER | ATTR_REVERSE | ATTR_ACTCURS |
|
||||||
|
ATTR_PASCURS | ATTR_ASCII | ATTR_GBCHR | ATTR_LINEDRW |
|
||||||
|
(cfg.bold_colour ? 0 : ATTR_BOLD);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
2
putty.h
2
putty.h
@ -70,6 +70,8 @@ typedef HDC Context;
|
|||||||
#define GLOBAL extern
|
#define GLOBAL extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
GLOBAL unsigned long attr_mask;
|
||||||
|
|
||||||
GLOBAL int rows, cols, savelines;
|
GLOBAL int rows, cols, savelines;
|
||||||
|
|
||||||
GLOBAL int font_width, font_height;
|
GLOBAL int font_width, font_height;
|
||||||
|
@ -1242,7 +1242,7 @@ static void do_paint (Context ctx, int may_optimise){
|
|||||||
unsigned long t = wanttext[idx];
|
unsigned long t = wanttext[idx];
|
||||||
int needs_update = (j < cols && t != disptext[idx]);
|
int needs_update = (j < cols && t != disptext[idx]);
|
||||||
int keep_going = (start != -1 && needs_update &&
|
int keep_going = (start != -1 && needs_update &&
|
||||||
(t & ATTR_MASK) == attr &&
|
(t & attr_mask) == attr &&
|
||||||
j-start < sizeof(ch));
|
j-start < sizeof(ch));
|
||||||
if (start != -1 && !keep_going) {
|
if (start != -1 && !keep_going) {
|
||||||
do_text (ctx, start, i, ch, j-start, attr);
|
do_text (ctx, start, i, ch, j-start, attr);
|
||||||
@ -1251,7 +1251,7 @@ static void do_paint (Context ctx, int may_optimise){
|
|||||||
if (needs_update) {
|
if (needs_update) {
|
||||||
if (start == -1) {
|
if (start == -1) {
|
||||||
start = j;
|
start = j;
|
||||||
attr = t & ATTR_MASK;
|
attr = t & attr_mask;
|
||||||
}
|
}
|
||||||
ch[j-start] = (char) (t & CHAR_MASK);
|
ch[j-start] = (char) (t & CHAR_MASK);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user