aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2017-06-29 23:45:05 +0200
committerBoris Faure <billiob@gmail.com>2017-06-29 23:45:05 +0200
commitde3890dad36dcaa1869b13dc7590f4e3c0e81df3 (patch)
treedfcd997bcc7071a242fd571c56d7814b20709533
parenttermpty: correctly handle DECFRA wrt SGR 0 (diff)
downloadterminology-de3890dad36dcaa1869b13dc7590f4e3c0e81df3.tar.gz
feature: move cursor to position on click+alt. Closes https://phab.enlightenment.org/T5537
-rw-r--r--src/bin/termio.c7
-rw-r--r--src/bin/termptyops.c26
-rw-r--r--src/bin/termptyops.h2
3 files changed, 35 insertions, 0 deletions
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