repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: dd72d46c194eb70fa4792bb81a905626ad9d9b55:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit dd72d46c194eb70fa4792bb81a905626ad9d9b55
Author: Marc Lehmann 
Date:   Tue Nov 23 22:58:09 2010 +0000

    *** empty log message ***

diff --git a/Changes b/Changes
index 279888504b23e1ad478850d9462f86e66ef48e1f..
index ..14db8fa78561f104bca10b16c8d0dc044949245d 100644
--- a/Changes
+++ b/Changes
@@ -19,11 +19,20 @@ DUMB: support tex fonts
 TODO: perl-shell-window? perl-unix-socket?
 TODO: command line editing when icanon?

-        - avoid spurious redraws of the bg image when bg is transparent or
-          when using 'root' mode (Emanuele Giaquinta).
-        - make OSC 20 simpler and more correct (Emanuele Giaquinta).
+TODO: decrqm
+http://ue.tst.eu/71d7dbd1fcfeaa7d2a4b96eb957d570c.txt
+	- the "schmorp=north korea dickey=south korea" release.
         - fix regression in urxvtd that prevented options from being correctly
           set (reported by Michal Vaner).
+        - INCOMPATIBLE CHANGE: make OSC 20 simpler and more correct
+          (Emanuele Giaquinta).
+	- implement xterm's horribly broken 1005 mouse reporting code,
+          and an alternative 1015 code that works in non-utf-8 locales
+          and has fewer limitations.
+	- fix a possible bug where mouse mouse notifications didn't work after
+          startup for the upper left corner.
+        - avoid spurious redraws of the bg image when bg is transparent or
+          when using 'root' mode (Emanuele Giaquinta).
         - fix build on XFree86.

 9.09 Sat Nov 13 01:39:07 CET 2010
diff --git a/doc/rxvt.7.pod b/doc/rxvt.7.pod
index c23cc30901134e1c3bbe39b4e86600e4b754f70a..
index ..85ae1a1e92a975fb81a220fb172018354117866d 100644
--- a/doc/rxvt.7.pod
+++ b/doc/rxvt.7.pod
@@ -1222,7 +1222,7 @@ selectable at C time.

 =item B<< C >>

-The literal character c.
+The literal character c (potentially a multi-byte character).

 =item B<< C >>

@@ -1919,6 +1919,20 @@ X

 =end table

+=item B<< C >> (X11 XTerm)
+
+Try to avoid this mode, it doesn't work sensibly in non-UTF-8 locales. Use
+mode C<1015> instead.
+
+Unlike XTerm, coordinates larger than 2015) will work fine.
+
+=begin table
+
+	B<< C >>	Enable mouse coordinates in locale-specific encoding.
+	B<< C >>	Enable mouse coordinates as binary octets.
+
+=end table
+
 =item B<< C >> (B)

 =begin table
@@ -1937,6 +1951,45 @@ X

 =end table

+=item B<< C >> (B)
+
+Changes all mouse reporting codes to use decimal parameters instead of
+octets or characters.
+
+This mode should be enabled I actually enabling mouse reporting,
+for semi-obvious reasons.
+
+The sequences received for various modes are as follows:
+
+   ESC [ M o o o    !1005, !1015 (three octets)
+   ESC [ M c c c    1005, !1015 (three characters)
+   ESC [ Pm M       1015 (three or more numeric paramaters)
+
+The three parameters are C, C and C. Code is the numeric code
+as for the other modes (but encoded as a decimal number), C and C
+are the coordinates (1|1 is the upper left corner, just as with cursor
+positioning).
+
+Example: Shift-Button-1 press at top row, column 80.
+
+   ESC [ 5 ; 80 ; 1 M
+
+One can use this feature by simply enabling it and then looking for
+parameters to the C reply - if there are any, this mode is
+active, otherwise one of the old reporting styles is used.
+
+Other (to be implemented) reply sequences will use a similar encoding.
+
+In the future, more parameters might get added (pixel coordinates for
+example - anybody out there who needs this?).
+
+=begin table
+
+	B<< C >>	Enable new mouse coordinate reporting.
+	B<< C >>	Use old-style C encoding.
+
+=end table
+
 =item B<< C >> (B)

 =begin table
diff --git a/src/command.C b/src/command.C
index c4644ad1fb20ce534e528b2fb5921022408ff810..
index ..8e328b1e04e1002ff0aacda9dce7364c139a5436 100644
--- a/src/command.C
+++ b/src/command.C
@@ -1254,12 +1254,14 @@ rxvt_term::mouse_report (XButtonEvent &ev)
   int x, y;
   int code = 32;

-  x = Pixel2Col (ev.x);
-  y = Pixel2Row (ev.y);
+  x = Pixel2Col (ev.x) + 1;
+  y = Pixel2Row (ev.y) + 1;
+
   if (ev.type == MotionNotify)
     {
       if (x == mouse_row && y == mouse_col)
         return;
+
       mouse_row = x;
       mouse_col = y;
       code += 32;
@@ -1272,7 +1274,7 @@ rxvt_term::mouse_report (XButtonEvent &ev)
       button_number = MEvent.button - Button1;
       /* add 0x3D for wheel events, like xterm does */
       if (button_number >= 3)
-        button_number += (64 - 3);
+        button_number += 64 - 3;
     }

   if (priv_modes & PrivMode_MouseX10)
@@ -1314,14 +1316,27 @@ rxvt_term::mouse_report (XButtonEvent &ev)
     fputc ('2', stderr);
   fprintf (stderr, "]: <%d>, %d/%d\n",
           button_number,
-          x + 1,
-          y + 1);
+          x,
+          y);
 #endif

-  tt_printf ("\033[M%c%c%c",
-            (code + button_number + key_state),
-            (32 + x + 1),
-            (32 + y + 1));
+#if ENABLE_FRILLS
+  if (priv_modes & PrivMode_ExtMouseRight)
+    tt_printf ("\033[%d;%d;%dM",
+              code + button_number + key_state,
+              x,
+              y);
+  else if (priv_modes & PrivMode_ExtModeMouse)
+    tt_printf ("\033[M%c%lc%lc",
+              code + button_number + key_state,
+              wint_t (32 + x),
+              wint_t (32 + y));
+  else
+#endif
+    tt_printf ("\033[M%c%c%c",
+              code + button_number + key_state,
+              32 + x,
+              32 + y);
 }

 /*{{{ process an X event */
@@ -3656,13 +3671,19 @@ rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs,
                   { 1000, PrivMode_MouseX11 },
                   { 1002, PrivMode_MouseBtnEvent },
                   { 1003, PrivMode_MouseAnyEvent },
+#if ENABLE_FRILLS
+                  { 1005, PrivMode_ExtModeMouse },
+#endif
                   { 1010, PrivMode_TtyOutputInh }, // rxvt extension
                   { 1011, PrivMode_Keypress }, // rxvt extension
+#if ENABLE_FRILLS
+                  { 1015, PrivMode_ExtMouseRight }, // urxvt extension of 1005
+#endif
                  // 1035 enable modifiers for alt, numlock NYI
                  // 1036 send ESC for meta keys NYI
                  // 1037 send DEL for keypad delete NYI
                   { 1047, PrivMode_Screen },
-                 // 1048 save and restore cursor
+                 // 1048 save and restore cursor, implemented in code
                   { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */
                  // 1051, 1052, 1060, 1061 keyboard emulation NYI
                   { 2004, PrivMode_BracketPaste },
diff --git a/src/rxvt.h b/src/rxvt.h
index 18fd2c6dd71e357bdd53b605329971ba6dd764d7..
index ..712703088f5eda5fe8fa1b6e9deba57a461f4f48 100644
--- a/src/rxvt.h
+++ b/src/rxvt.h
@@ -557,6 +557,8 @@ enum {
 #define PrivMode_MouseBtnEvent  (1UL<<20)
 #define PrivMode_MouseAnyEvent  (1UL<<21)
 #define PrivMode_BracketPaste   (1UL<<22)
+#define PrivMode_ExtModeMouse   (1UL<<23) // xterm pseudo-utf-8 hack
+#define PrivMode_ExtMouseRight  (1UL<<24) // xterm pseudo-utf-8, but works in non-utf-8-locales

 #define PrivMode_mouse_report   (PrivMode_MouseX10|PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent)

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