Introduce alternative cursor shapes: underline, vertical line
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 17 Jan 2001 16:57:33 +0000 (16:57 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 17 Jan 2001 16:57:33 +0000 (16:57 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@870 cda61777-01e9-0310-a592-d414129be87e

putty.h
settings.c
terminal.c
windlg.c
window.c

diff --git a/putty.h b/putty.h
index 263c045..4f9bfa4 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -24,6 +24,7 @@
 #define ATTR_PASCURS 0x40000000UL      /* passive cursor (box) */
 #define ATTR_INVALID 0x20000000UL
 #define ATTR_WRAPPED 0x10000000UL
+#define ATTR_RIGHTCURS 0x10000000UL    /* doubles as cursor-on-RHS indicator */
 
 #define LATTR_NORM   0x00000000UL
 #define LATTR_WIDE   0x01000000UL
@@ -179,6 +180,7 @@ typedef struct {
     int dec_om;
     int wrap_mode;
     int lfhascr;
+    int cursor_type;                  /* 0=block 1=underline 2=vertical */
     int blink_cur;
     int beep;
     int scrollbar;
index 5b2b521..235430c 100644 (file)
@@ -93,6 +93,7 @@ void save_settings (char *section, int do_host, Config *cfg) {
     write_setting_i (sesskey, "ComposeKey", cfg->compose_key);
     write_setting_i (sesskey, "LdiscTerm", cfg->ldisc_term);
     write_setting_i (sesskey, "AlwaysOnTop", cfg->alwaysontop);
+    write_setting_i (sesskey, "CurType", cfg->cursor_type);
     write_setting_i (sesskey, "BlinkCur", cfg->blink_cur);
     write_setting_i (sesskey, "Beep", cfg->beep);
     write_setting_i (sesskey, "ScrollbackLines", cfg->savelines);
@@ -226,6 +227,7 @@ void load_settings (char *section, int do_host, Config *cfg) {
     gppi (sesskey, "ComposeKey", 0, &cfg->compose_key);
     gppi (sesskey, "LdiscTerm", 0, &cfg->ldisc_term);
     gppi (sesskey, "AlwaysOnTop", 0, &cfg->alwaysontop);
+    gppi (sesskey, "CurType", 0, &cfg->cursor_type);
     gppi (sesskey, "BlinkCur", 0, &cfg->blink_cur);
     gppi (sesskey, "Beep", 1, &cfg->beep);
     gppi (sesskey, "ScrollbackLines", 200, &cfg->savelines);
index 143693d..4d7a87d 100644 (file)
@@ -1771,6 +1771,8 @@ static void do_paint (Context ctx, int may_optimise){
         }
         else
             cursor = ATTR_PASCURS;
+       if (wrapnext)
+           cursor |= ATTR_RIGHTCURS;
     }
     else           cursor = 0;
     rv = (rvideo ? ATTR_REVERSE : 0);
@@ -1781,11 +1783,10 @@ static void do_paint (Context ctx, int may_optimise){
        int lattr = (disptop[idx+cols] & LATTR_MODE);
        for (j=0; j<=cols; j++,idx++) {
            unsigned long *d = disptop+idx;
-           wanttext[idx] = lattr | ((*d ^ rv
+           wanttext[idx] = lattr | (((*d &~ ATTR_WRAPPED) ^ rv
                              ^ (selstart <= d && d < selend ?
                                 ATTR_REVERSE : 0)) |
                             (i==our_curs_y && j==curs_x ? cursor : 0));
-
            if (blink_is_real) {
                if (has_focus && tblinker && (wanttext[idx]&ATTR_BLINK) )
                {
index 36cbf5c..7f2c8a1 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -274,6 +274,10 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_BOX_APPEARANCE1, IDC_BOXT_APPEARANCE1,
     IDC_BOX_APPEARANCE2, IDC_BOXT_APPEARANCE2,
     IDC_BOX_APPEARANCE3, IDC_BOXT_APPEARANCE3,
+    IDC_CURSTATIC,
+    IDC_CURBLOCK,
+    IDC_CURUNDER,
+    IDC_CURVERT,
     IDC_BLINKCUR,
     IDC_FONTSTATIC,
     IDC_CHOOSEFONT,
@@ -472,6 +476,9 @@ static void init_dlg_ctrls(HWND hwnd) {
 
     SetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle);
     CheckDlgButton (hwnd, IDC_WINNAME, cfg.win_name_always);
+    CheckRadioButton (hwnd, IDC_CURBLOCK, IDC_CURVERT,
+                     cfg.cursor_type==0 ? IDC_CURBLOCK :
+                     cfg.cursor_type==1 ? IDC_CURUNDER : IDC_CURVERT);
     CheckDlgButton (hwnd, IDC_BLINKCUR, cfg.blink_cur);
     CheckDlgButton (hwnd, IDC_SCROLLBAR, cfg.scrollbar);
     CheckDlgButton (hwnd, IDC_LOCKSIZE, cfg.locksize);
@@ -828,7 +835,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
             treeview_insert(&tvfaff, 0, "Window");
        }
 
-        /* The Appearance panel. Accelerators used: [acgo] rmkhti */
+        /* The Appearance panel. Accelerators used: [acgo] rmkhtibluv */
        {
            struct ctlpos cp;
            ctlposinit(&cp, hwnd, 80, 3, 13);
@@ -836,6 +843,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                      IDC_TITLE_APPEARANCE);
             beginbox(&cp, "Adjust the use of the cursor",
                      IDC_BOX_APPEARANCE1, IDC_BOXT_APPEARANCE1);
+           radioline(&cp, "Cursor appearance:", IDC_CURSTATIC, 3,
+                     "B&lock", IDC_CURBLOCK,
+                     "&Underline", IDC_CURUNDER,
+                     "&Vertical line", IDC_CURVERT,
+                     NULL);
            checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
             endbox(&cp);
             beginbox(&cp, "Set the font used in the terminal window",
@@ -1417,6 +1429,21 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                HIWORD(wParam) == BN_DOUBLECLICKED)
                cfg.win_name_always = IsDlgButtonChecked (hwnd, IDC_WINNAME);
            break;
+         case IDC_CURBLOCK:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED)
+               cfg.cursor_type = 0;
+           break;
+         case IDC_CURUNDER:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED)
+               cfg.cursor_type = 1;
+           break;
+         case IDC_CURVERT:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED)
+               cfg.cursor_type = 2;
+           break;
           case IDC_BLINKCUR:
             if (HIWORD(wParam) == BN_CLICKED ||
                 HIWORD(wParam) == BN_DOUBLECLICKED)
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) {