diff --git a/Makefile.am b/Makefile.am index 8f19e880..2551bce3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -58,7 +58,7 @@ if IS_SUNCC CFLAGS += -erroff=E_EMPTY_DECLARATION endif -# Set _LINUX_SOURCE_COMPAT for AIX for mallocing 0 bytes +# Set _LINUX_SOURCE_COMPAT for AIX for malloc(0). if IS_AIX DEFS += -D_LINUX_SOURCE_COMPAT=1 endif diff --git a/TODO b/TODO index 4a284220..e0e3de6d 100644 --- a/TODO +++ b/TODO @@ -75,6 +75,7 @@ * searching in copy mode should unwrap lines, so if you seach for "foobar" then it should be found even if it is now "foo\nbar" (if the WRAP flag is set on the line) + * {} to go to next/previous blank line in copy mode - layout stuff * way to tag a layout as a number/name diff --git a/configure.ac b/configure.ac index 10d761bc..55eaf24a 100644 --- a/configure.ac +++ b/configure.ac @@ -180,10 +180,17 @@ if test "x$found_curses" = xno; then fi # Look for utempter. -AC_CHECK_HEADER(utempter.h, have_utempter=yes, have_utempter=no) -if test "x$have_utempter" = xyes; then - AC_DEFINE(HAVE_UTEMPTER) - LIBS="$LIBS -lutempter" +AC_CHECK_HEADER(utempter.h, found_utempter=yes, found_utempter=no) +if test "x$found_utempter" = xyes; then + AC_SEARCH_LIBS( + utempter_add_record, + utempter, + found_utempter=yes, + found_utempter=no + ) + if test "x$found_utempter" = xyes; then + AC_DEFINE(HAVE_UTEMPTER) + fi fi PKG_CHECK_MODULES( diff --git a/key-string.c b/key-string.c index c56681f1..119035a0 100644 --- a/key-string.c +++ b/key-string.c @@ -93,6 +93,9 @@ const struct { KEYC_MOUSE_STRING(MOUSEDRAG1, MouseDrag1), KEYC_MOUSE_STRING(MOUSEDRAG2, MouseDrag2), KEYC_MOUSE_STRING(MOUSEDRAG3, MouseDrag3), + KEYC_MOUSE_STRING(MOUSEDRAGEND1, MouseDragEnd1), + KEYC_MOUSE_STRING(MOUSEDRAGEND2, MouseDragEnd2), + KEYC_MOUSE_STRING(MOUSEDRAGEND3, MouseDragEnd3), KEYC_MOUSE_STRING(WHEELUP, WheelUp), KEYC_MOUSE_STRING(WHEELDOWN, WheelDown), }; diff --git a/mode-key.c b/mode-key.c index a9b15bb9..aed161bb 100644 --- a/mode-key.c +++ b/mode-key.c @@ -347,7 +347,7 @@ const struct mode_key_entry mode_key_vi_copy[] = { { KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP }, { KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN }, { KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION }, - { KEYC_MOUSEUP1_PANE, 0, MODEKEYCOPY_COPYSELECTION }, + { KEYC_MOUSEDRAGEND1_PANE, 0, MODEKEYCOPY_COPYSELECTION }, { 0, -1, 0 } }; @@ -496,7 +496,7 @@ const struct mode_key_entry mode_key_emacs_copy[] = { { KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP }, { KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN }, { KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION }, - { KEYC_MOUSEUP1_PANE, 0, MODEKEYCOPY_COPYSELECTION }, + { KEYC_MOUSEDRAGEND1_PANE, 0, MODEKEYCOPY_COPYSELECTION }, { 0, -1, 0 } }; diff --git a/server-client.c b/server-client.c index 3f11477e..21cccc85 100644 --- a/server-client.c +++ b/server-client.c @@ -384,33 +384,33 @@ server_client_check_mouse(struct client *c) c->tty.mouse_drag_release = NULL; /* - * End a mouse drag by passing a MouseUp key corresponding to - * the button that started the drag. + * End a mouse drag by passing a MouseDragEnd key corresponding + * to the button that started the drag. */ switch (c->tty.mouse_drag_flag) { case 1: if (where == PANE) - key = KEYC_MOUSEUP1_PANE; + key = KEYC_MOUSEDRAGEND1_PANE; if (where == STATUS) - key = KEYC_MOUSEUP1_STATUS; + key = KEYC_MOUSEDRAGEND1_STATUS; if (where == BORDER) - key = KEYC_MOUSEUP1_BORDER; + key = KEYC_MOUSEDRAGEND1_BORDER; break; case 2: if (where == PANE) - key = KEYC_MOUSEUP2_PANE; + key = KEYC_MOUSEDRAGEND2_PANE; if (where == STATUS) - key = KEYC_MOUSEUP2_STATUS; + key = KEYC_MOUSEDRAGEND2_STATUS; if (where == BORDER) - key = KEYC_MOUSEUP2_BORDER; + key = KEYC_MOUSEDRAGEND2_BORDER; break; case 3: if (where == PANE) - key = KEYC_MOUSEUP3_PANE; + key = KEYC_MOUSEDRAGEND3_PANE; if (where == STATUS) - key = KEYC_MOUSEUP3_STATUS; + key = KEYC_MOUSEDRAGEND3_STATUS; if (where == BORDER) - key = KEYC_MOUSEUP3_BORDER; + key = KEYC_MOUSEDRAGEND3_BORDER; break; default: key = KEYC_MOUSE; diff --git a/tmux.1 b/tmux.1 index 35bfddf8..776b6faf 100644 --- a/tmux.1 +++ b/tmux.1 @@ -3298,10 +3298,10 @@ for a pane border or for the status line). The following mouse events are available: .Bl -column "MouseDown1" "MouseDrag1" "WheelDown" -offset indent -.It Li "MouseDown1" Ta "MouseUp1" Ta "MouseDrag1" -.It Li "MouseDown2" Ta "MouseUp2" Ta "MouseDrag2" -.It Li "MouseDown3" Ta "MouseUp3" Ta "MouseDrag3" -.It Li "WheelUp" Ta "WheelDown" Ta "" +.It Li "MouseDown1" Ta "MouseUp1" Ta "MouseDrag1" Ta "MouseDragEnd1" +.It Li "MouseDown2" Ta "MouseUp2" Ta "MouseDrag2" Ta "MouseDragEnd2" +.It Li "MouseDown3" Ta "MouseUp3" Ta "MouseDrag3" Ta "MouseDragEnd3" +.It Li "WheelUp" Ta "WheelDown" Ta "" Ta "" .El .Pp Each should be suffixed with a location, for example diff --git a/tmux.h b/tmux.h index 059558bd..1ab784b7 100644 --- a/tmux.h +++ b/tmux.h @@ -139,6 +139,9 @@ enum { KEYC_MOUSE_KEY(MOUSEDRAG1), KEYC_MOUSE_KEY(MOUSEDRAG2), KEYC_MOUSE_KEY(MOUSEDRAG3), + KEYC_MOUSE_KEY(MOUSEDRAGEND1), + KEYC_MOUSE_KEY(MOUSEDRAGEND2), + KEYC_MOUSE_KEY(MOUSEDRAGEND3), KEYC_MOUSE_KEY(WHEELUP), KEYC_MOUSE_KEY(WHEELDOWN), diff --git a/window-copy.c b/window-copy.c index 6294cd84..3862a688 100644 --- a/window-copy.c +++ b/window-copy.c @@ -27,6 +27,7 @@ struct screen *window_copy_init(struct window_pane *); void window_copy_free(struct window_pane *); +void window_copy_pagedown(struct window_pane *); void window_copy_resize(struct window_pane *, u_int, u_int); void window_copy_key(struct window_pane *, struct client *, struct session *, key_code, struct mouse_event *); @@ -281,15 +282,80 @@ window_copy_pageup(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; struct screen *s = &data->screen; - u_int n; + u_int n, ox, oy; + + oy = screen_hsize(data->backing) + data->cy - data->oy; + ox = window_copy_find_length(wp, oy); + + if (s->sel.lineflag == LINE_SEL_LEFT_RIGHT && oy == data->sely) + window_copy_other_end(wp); + + if (data->cx != ox) { + data->lastcx = data->cx; + data->lastsx = ox; + } + data->cx = data->lastcx; n = 1; if (screen_size_y(s) > 2) n = screen_size_y(s) - 2; + if (data->oy + n > screen_hsize(data->backing)) data->oy = screen_hsize(data->backing); else data->oy += n; + + if (!data->screen.sel.flag || !data->rectflag) { + u_int py = screen_hsize(data->backing) + data->cy - data->oy; + u_int px = window_copy_find_length(wp, py); + if ((data->cx >= data->lastsx && data->cx != px) || data->cx > px) + window_copy_cursor_end_of_line(wp); + } + + window_copy_update_selection(wp, 1); + window_copy_redraw_screen(wp); +} + +void +window_copy_pagedown(struct window_pane *wp) +{ + struct window_copy_mode_data *data = wp->modedata; + struct screen *s = &data->screen; + u_int n, ox, oy; + + oy = screen_hsize(data->backing) + data->cy - data->oy; + ox = window_copy_find_length(wp, oy); + + if (s->sel.lineflag == LINE_SEL_RIGHT_LEFT && oy == data->sely) + window_copy_other_end(wp); + + if (data->cx != ox) { + data->lastcx = data->cx; + data->lastsx = ox; + } + data->cx = data->lastcx; + + n = 1; + if (screen_size_y(s) > 2) + n = screen_size_y(s) - 2; + + if (data->oy < n) + data->oy = 0; + else + data->oy -= n; + + if (!data->screen.sel.flag || !data->rectflag) { + u_int py = screen_hsize(data->backing) + data->cy - data->oy; + u_int px = window_copy_find_length(wp, py); + if ((data->cx >= data->lastsx && data->cx != px) || data->cx > px) + window_copy_cursor_end_of_line(wp); + } + + if (data->scroll_exit && data->oy == 0) { + window_pane_reset_mode(wp); + return; + } + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); } @@ -436,21 +502,8 @@ __window_copy_key(struct window_pane *wp, struct client *c, struct session *sess window_copy_pageup(wp); break; case MODEKEYCOPY_NEXTPAGE: - n = 1; - if (screen_size_y(s) > 2) - n = screen_size_y(s) - 2; - for (; np != 0; np--) { - if (data->oy < n) - data->oy = 0; - else - data->oy -= n; - } - if (data->scroll_exit && data->oy == 0) { - window_pane_reset_mode(wp); - return; - } - window_copy_update_selection(wp, 1); - window_copy_redraw_screen(wp); + for (; np != 0; np--) + window_copy_pagedown(wp); break; case MODEKEYCOPY_HALFPAGEUP: n = screen_size_y(s) / 2;