]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Attribute masking implemented. The variable attr_mask stored the current
authorBen Harris <bjh21@bjh21.me.uk>
Sun, 14 Mar 1999 17:43:35 +0000 (17:43 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Sun, 14 Mar 1999 17:43:35 +0000 (17:43 +0000)
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]

macterm.c
putty.h
terminal.c

index 247039f7442bcfd33dfa22ecf94940512d3d0adc..859aba45f17f15fc7beb783402d8c81a3d631e65 100644 (file)
--- a/macterm.c
+++ b/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
  * All rights reserved.
@@ -77,6 +77,7 @@ static void mac_initpalette(struct mac_session *);
 static void mac_adjustsize(struct mac_session *, int, int);
 static pascal void mac_scrolltracker(ControlHandle, short);
 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 void text_click(struct mac_session *, EventRecord *);
 
@@ -138,6 +139,7 @@ void mac_newsession(void) {
     term_size(cfg.height, cfg.width, cfg.savelines);
     mac_initfont(s);
     mac_initpalette(s);
+    attr_mask = ATTR_MASK;
     /* Set to FALSE to not get palette updates in the background. */
     SetPalette(s->window, s->palette, TRUE); 
     ActivatePalette(s->window);
@@ -560,6 +562,7 @@ void mac_updateterm(WindowPtr window) {
 
     s = (struct mac_session *)GetWRefCon(window);
     BeginUpdate(window);
+    get_ctx();
     term_paint(s,
               (*window->visRgn)->rgnBBox.left,
               (*window->visRgn)->rgnBBox.top,
@@ -577,6 +580,7 @@ void mac_updateterm(WindowPtr window) {
     DrawGrowIcon(window);
     clip.left = SHRT_MIN;
     ClipRect(&clip);
+    free_ctx(NULL);
     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;
 
-    if (a->attr & ATTR_REVERSE)
-       TextMode(notSrcCopy);
-    else
-       TextMode(srcCopy);
+    TextMode(a->attr & ATTR_REVERSE ? notSrcCopy : srcCopy);
 
     switch (depth) {
       case 1:
@@ -652,7 +653,7 @@ static pascal void do_text_for_device(short depth, short devflags,
        ForeColor(whiteColor);
        BackColor(blackColor);
        if (a->attr & ATTR_ACTCURS)
-           TextMode((a->attr & ATTR_REVERSE) ? srcCopy : notSrcCopy);
+           TextMode(a->attr & ATTR_REVERSE ? srcCopy : notSrcCopy);
        break;
       case 2:
        if (a->attr & ATTR_ACTCURS) {
@@ -666,7 +667,7 @@ static pascal void do_text_for_device(short depth, short devflags,
        break;
       default:
        if (a->attr & ATTR_ACTCURS) {
-           fgcolour = (bright ? CURSOR_FG_BOLD : CURSOR_FG);
+           fgcolour = bright ? CURSOR_FG_BOLD : CURSOR_FG;
            bgcolour = CURSOR_BG;
            TextMode(srcCopy);
        } 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.
+ * Should probably be called start_redraw or something.
  */
 struct mac_session *get_ctx(void) {
+    struct mac_session *s = 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) {
 
-    return onlysession;
+    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;
+    }
 }
 
 /*
diff --git a/putty.h b/putty.h
index bd5eada9e792db9e188a1d700c1dcba578d84ca4..0616c573210408ef6d5f9f37050844a8767dc367 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -70,6 +70,8 @@ typedef HDC Context;
 #define GLOBAL extern
 #endif
 
+GLOBAL unsigned long attr_mask;
+
 GLOBAL int rows, cols, savelines;
 
 GLOBAL int font_width, font_height;
index e4b1e667b313b813bab4152cb03ad444c334fe36..cc13ddf633e8ae24c65528b68a05108774e5e5e4 100644 (file)
@@ -1242,7 +1242,7 @@ static void do_paint (Context ctx, int may_optimise){
            unsigned long t = wanttext[idx];
            int needs_update = (j < cols && t != disptext[idx]);
            int keep_going = (start != -1 && needs_update &&
-                             (t & ATTR_MASK) == attr &&
+                             (t & attr_mask) == attr &&
                              j-start < sizeof(ch));
            if (start != -1 && !keep_going) {
                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 (start == -1) {
                    start = j;
-                   attr = t & ATTR_MASK;
+                   attr = t & attr_mask;
                }
                ch[j-start] = (char) (t & CHAR_MASK);
            }