repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: 2562068c19a5bc8da707b72bdb28fed02b8c1e78:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit 2562068c19a5bc8da707b72bdb28fed02b8c1e78
Author: Emanuele Giaquinta 
Date:   Tue Mar 26 14:16:46 2013 +0000

    Add support for the set cursor style (DECSCUSR) control function.

diff --git a/Changes b/Changes
index 1b527037656a3263e98b5a4bbf42dbc011a88929..
index ..c1c3e3258df10d3b5f22d526026fda8139134191 100644
--- a/Changes
+++ b/Changes
@@ -30,6 +30,8 @@ TODO: provide something like % for easy access for parse_keysym
 TODO: description into --help output?
 TODO: rxvt -help => (see rxvt-XXX(1))?

+	- add support for the set cursor style (DECSCUSR) control
+	  function.
 	- honour cursorColor also when the cursor style is underline.

 9.18 Sun Mar 24 15:33:35 CET 2013
diff --git a/doc/rxvt.7.pod b/doc/rxvt.7.pod
index 9c90331d0d437b738fec4434ce9a0f06053403fe..
index ..11cbde1582741337a84896cb21059c7f2d13ef9d 100644
--- a/doc/rxvt.7.pod
+++ b/doc/rxvt.7.pod
@@ -1282,7 +1282,7 @@ Switch to Alternate Character Set
 Shift In (Ctrl-O), invokes the G0 character set (the default).
 Switch to Standard Character Set

-=item B<< C >>
+=item B<< C >>

 Space Character

@@ -1632,6 +1632,20 @@ Device Status Report (DSR)

 =end table

+=item B<< C >>
+
+Set Cursor Style (DESCUSR)
+
+=begin table
+
+	B<< C >>	Blink Block
+	B<< C >>	Blink Block
+	B<< C >>	Steady Block
+	B<< C >>	Blink Underline
+	B<< C >>	Steady Underline
+
+=end table
+
 =item B<< C >>

 Set Scrolling Region [top;bottom]
diff --git a/src/command.C b/src/command.C
index 82ad10adaf2c84dff0faccbb29045e90bf3273de..
index ..a4029f421c1c0adc30058868b9a2167175f154eb 100644
--- a/src/command.C
+++ b/src/command.C
@@ -2801,7 +2801,7 @@ static const unsigned char csi_defaults[] =
 void ecb_hot
 rxvt_term::process_csi_seq ()
 {
-  unicode_t ch, priv, i;
+  unicode_t ch, priv, prev_ch, i;
   unsigned int nargs, p;
   int n, ndef;
   int arg[ESC_ARGS] = { };
@@ -2817,6 +2817,7 @@ rxvt_term::process_csi_seq ()
       ch = cmd_getc ();
     }

+  prev_ch = 0;
   /* read any numerical arguments */
   for (n = -1; ch < CSI_ICH; )
     {
@@ -2836,6 +2837,7 @@ rxvt_term::process_csi_seq ()
       else if (IS_CONTROL (ch))
         process_nonprinting (ch);

+      prev_ch = ch;
       ch = cmd_getc ();
     }

@@ -3079,6 +3081,11 @@ rxvt_term::process_csi_seq ()
           priv_modes |= PrivMode_LFNL;
         break;

+      case CSI_71:		// DESCUSR: set cursor style
+        if (prev_ch == ' ')
+          set_cursor_style (arg[0]);
+        break;
+
         /*
          * PRIVATE USE beyond this point.  All CSI_7? sequences here
          */
@@ -3993,6 +4000,22 @@ rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg)
         }
     }
 }
+
+void
+rxvt_term::set_cursor_style (int style)
+{
+  if (!IN_RANGE_INC (style, 0, 4))
+    return;
+
+  set_option (Opt_cursorUnderline, style >= 3);
+
+#ifdef CURSOR_BLINK
+  set_option (Opt_cursorBlink, !style || (style & 1));
+  cursor_blink_reset ();
+#endif
+
+  want_refresh = 1;
+}
 /*}}} */

 /* ------------------------------------------------------------------------- */
diff --git a/src/rxvt.h b/src/rxvt.h
index 8a6c895abd09b9aac1cd43c14bbee303f15577a1..
index ..82791d88af531d4d5d10dbb4a5c5f1a2e7cf9c63 100644
--- a/src/rxvt.h
+++ b/src/rxvt.h
@@ -1402,6 +1402,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen
   int privcases (int mode, unsigned long bit);
   void process_terminal_mode (int mode, int priv, unsigned int nargs, const int *arg);
   void process_sgr_mode (unsigned int nargs, const int *arg);
+  void set_cursor_style (int style);
   // init.C
   void init (stringvec *argv, stringvec *envv);
   void init (int argc, const char *const *argv, const char *const *envv);

-----END OF PAGE-----