Introduce alternative cursor shapes: underline, vertical line
[u/mdw/putty] / window.c
index a9456c8..0a7419c 100644 (file)
--- a/window.c
+++ b/window.c
@@ -1663,7 +1663,7 @@ void do_text (Context ctx, int x, int y, char *text, int len,
     x *= fnt_width;
     y *= font_height;
 
-    if (attr & ATTR_ACTCURS) {
+    if ((attr & ATTR_ACTCURS) && cfg.cursor_type == 0) {
        attr &= (bold_mode == BOLD_COLOURS ? 0x300200 : 0x300300);
        attr ^= ATTR_CUR_XOR;
     }
@@ -1824,7 +1824,7 @@ void do_text (Context ctx, int x, int y, char *text, int len,
         oldpen = SelectObject (hdc, oldpen);
         DeleteObject (oldpen);
     }
-    if (attr & ATTR_PASCURS) {
+    if ((attr & ATTR_PASCURS) && cfg.cursor.type == 0) {
        POINT pts[5];
         HPEN oldpen;
        pts[0].x = pts[1].x = pts[4].x = x;
@@ -1836,6 +1836,27 @@ void do_text (Context ctx, int x, int y, char *text, int len,
         oldpen = SelectObject (hdc, oldpen);
         DeleteObject (oldpen);
     }
+    if ((attr & (ATTR_ACTCURS | ATTR_PASCURS)) && cfg.cursor_type != 0) {
+        HPEN oldpen;
+       int pentype;
+       if (attr & ATTR_PASCURS)
+           pentype = PS_DOTTED;
+       else
+           pentype = PS_SOLID;
+       oldpen = SelectObject (hdc, CreatePen(pentype, 0, colours[23]));
+       if (cfg.cursor_type == 1) {
+           MoveToEx (hdc, x, y+descent, NULL);
+           LineTo (hdc, x+fnt_width-1, y+descent);
+       } else {
+           int xadjust = 0;
+           if (attr & ATTR_RIGHTCURS)
+               xadjust = fnt_width-1;
+           MoveToEx (hdc, x+xadjust, y, NULL);
+           LineTo (hdc, x+xadjust, y+font_height-1);
+       }
+        oldpen = SelectObject (hdc, oldpen);
+        DeleteObject (oldpen);
+    }
 }
 
 static int check_compose(int first, int second) {