billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=de3890dad36dcaa1869b13dc7590f4e3c0e81df3

commit de3890dad36dcaa1869b13dc7590f4e3c0e81df3
Author: Boris Faure <bill...@gmail.com>
Date:   Thu Jun 29 23:45:05 2017 +0200

    feature: move cursor to position on click+alt. Closes T5537
---
 src/bin/termio.c     |  7 +++++++
 src/bin/termptyops.c | 26 ++++++++++++++++++++++++++
 src/bin/termptyops.h |  2 ++
 3 files changed, 35 insertions(+)

diff --git a/src/bin/termio.c b/src/bin/termio.c
index 6d709f2..9b03008 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -6,6 +6,7 @@
 #include "termio.h"
 #include "termiolink.h"
 #include "termpty.h"
+#include "termptyops.h"
 #include "termcmd.h"
 #include "termptydbl.h"
 #include "utf8.h"
@@ -3998,6 +3999,12 @@ _handle_mouse_down_single_click(Termio *sd,
         sd->pty->selection.end.y = cy;
         _selection_dbl_fix(sd);
      }
+   else if (!shift && alt && !sd->pty->selection.is_active
+            && (sd->pty->mouse_mode == MOUSE_OFF))
+     {
+        /* move cursor to position */
+        termpty_move_cursor(sd->pty, cx, cy);
+     }
    else if (!shift && !sd->pty->selection.is_active)
      {
         /* New selection */
diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c
index e300db4..7635d0e 100644
--- a/src/bin/termptyops.c
+++ b/src/bin/termptyops.c
@@ -472,3 +472,29 @@ termpty_cursor_copy(Termpty *ty, Eina_Bool save)
         ty->cursor_state.cy = ty->cursor_save[ty->altbuf].cy;
      }
 }
+
+
+void
+termpty_move_cursor(Termpty *ty, int cx, int cy)
+{
+   int vect;
+
+   /* right/left */
+   vect = cx - ty->cursor_state.cx;
+   /* left */
+   for (; vect < 0; vect++)
+     termpty_write(ty, "\033[D", strlen("\033[D"));
+   /* right */
+   for (; vect > 0; vect--)
+     termpty_write(ty, "\033[C", strlen("\033[C"));
+
+   /* up/down */
+   vect = cy - ty->cursor_state.cy;
+   /* up */
+   for (; vect < 0; vect++)
+     termpty_write(ty, "\033[A", strlen("\033[A"));
+   /* down*/
+   for (; vect > 0; vect--)
+     termpty_write(ty, "\033[B", strlen("\033[B"));
+
+}
diff --git a/src/bin/termptyops.h b/src/bin/termptyops.h
index 7046d5b..ee27860 100644
--- a/src/bin/termptyops.h
+++ b/src/bin/termptyops.h
@@ -28,6 +28,8 @@ void termpty_cursor_copy(Termpty *ty, Eina_Bool save);
 void termpty_clear_tabs_on_screen(Termpty *ty);
 void termpty_clear_backlog(Termpty *ty);
 
+void termpty_move_cursor(Termpty *ty, int cx, int cy);
+
 #define _term_txt_write(ty, txt) termpty_write(ty, txt, sizeof(txt) - 1)
 
 #define TAB_WIDTH 8u

-- 


Reply via email to