feature: move cursor to position on click+alt. Closes T5537

devs/iscaro/meson
Boris Faure 6 years ago
parent b0226726f8
commit de3890dad3
  1. 7
      src/bin/termio.c
  2. 26
      src/bin/termptyops.c
  3. 2
      src/bin/termptyops.h

@ -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 */

@ -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"));
}

@ -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

Loading…
Cancel
Save