summaryrefslogtreecommitdiff
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
parentb0226726f8ea6b55ddd2e5a539da9d1798d23345 (diff)
feature: move cursor to position on click+alt. Closes 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 @@
6#include "termio.h" 6#include "termio.h"
7#include "termiolink.h" 7#include "termiolink.h"
8#include "termpty.h" 8#include "termpty.h"
9#include "termptyops.h"
9#include "termcmd.h" 10#include "termcmd.h"
10#include "termptydbl.h" 11#include "termptydbl.h"
11#include "utf8.h" 12#include "utf8.h"
@@ -3998,6 +3999,12 @@ _handle_mouse_down_single_click(Termio *sd,
3998 sd->pty->selection.end.y = cy; 3999 sd->pty->selection.end.y = cy;
3999 _selection_dbl_fix(sd); 4000 _selection_dbl_fix(sd);
4000 } 4001 }
4002 else if (!shift && alt && !sd->pty->selection.is_active
4003 && (sd->pty->mouse_mode == MOUSE_OFF))
4004 {
4005 /* move cursor to position */
4006 termpty_move_cursor(sd->pty, cx, cy);
4007 }
4001 else if (!shift && !sd->pty->selection.is_active) 4008 else if (!shift && !sd->pty->selection.is_active)
4002 { 4009 {
4003 /* New selection */ 4010 /* 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)
472 ty->cursor_state.cy = ty->cursor_save[ty->altbuf].cy; 472 ty->cursor_state.cy = ty->cursor_save[ty->altbuf].cy;
473 } 473 }
474} 474}
475
476
477void
478termpty_move_cursor(Termpty *ty, int cx, int cy)
479{
480 int vect;
481
482 /* right/left */
483 vect = cx - ty->cursor_state.cx;
484 /* left */
485 for (; vect < 0; vect++)
486 termpty_write(ty, "\033[D", strlen("\033[D"));
487 /* right */
488 for (; vect > 0; vect--)
489 termpty_write(ty, "\033[C", strlen("\033[C"));
490
491 /* up/down */
492 vect = cy - ty->cursor_state.cy;
493 /* up */
494 for (; vect < 0; vect++)
495 termpty_write(ty, "\033[A", strlen("\033[A"));
496 /* down*/
497 for (; vect > 0; vect--)
498 termpty_write(ty, "\033[B", strlen("\033[B"));
499
500}
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);
28void termpty_clear_tabs_on_screen(Termpty *ty); 28void termpty_clear_tabs_on_screen(Termpty *ty);
29void termpty_clear_backlog(Termpty *ty); 29void termpty_clear_backlog(Termpty *ty);
30 30
31void termpty_move_cursor(Termpty *ty, int cx, int cy);
32
31#define _term_txt_write(ty, txt) termpty_write(ty, txt, sizeof(txt) - 1) 33#define _term_txt_write(ty, txt) termpty_write(ty, txt, sizeof(txt) - 1)
32 34
33#define TAB_WIDTH 8u 35#define TAB_WIDTH 8u