Mouse in copy mode.

This commit is contained in:
Nicholas Marriott 2009-01-28 22:00:22 +00:00
parent 4428987e95
commit 2057e666a2
4 changed files with 35 additions and 7 deletions

View File

@ -1,5 +1,7 @@
28 January 2009 28 January 2009
* Support mouse in copy mode to move cursor. Can't do anything else at the
moment until other mouse modes are handled.
* Better support for at least the most common variant of mouse input: parse it * Better support for at least the most common variant of mouse input: parse it
and adjust for different panes. Also support mouse in window/session choice and adjust for different panes. Also support mouse in window/session choice
mode. mode.
@ -1035,7 +1037,7 @@
(including mutt, emacs). No status bar yet and no key remapping or other (including mutt, emacs). No status bar yet and no key remapping or other
customisation. customisation.
$Id: CHANGES,v 1.239 2009-01-28 19:52:21 nicm Exp $ $Id: CHANGES,v 1.240 2009-01-28 22:00:22 nicm Exp $
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms

2
TODO
View File

@ -76,6 +76,7 @@
utf8 should work differently; could store as multiple cells, 1 of width >0 utf8 should work differently; could store as multiple cells, 1 of width >0
and n of width 0, then translate cursor indexes on-the-fly would need to and n of width 0, then translate cursor indexes on-the-fly would need to
adjust all cursor movement and also handle different width lines properly. adjust all cursor movement and also handle different width lines properly.
- support other mouse modes (highlight etc) and use it in copy mode
(hopefully) for 0.7, in no particular order: (hopefully) for 0.7, in no particular order:
- swap-pane-up, swap-pane-down (maybe move-pane-*) - swap-pane-up, swap-pane-down (maybe move-pane-*)
@ -89,5 +90,4 @@
- document find-window - document find-window
- document split-window -p and -l - document split-window -p and -l
- attach should have a flag to create session if it doesn't exist - attach should have a flag to create session if it doesn't exist
- support mouse in copy mode
- fix page up/down in choice mode AGAIN - fix page up/down in choice mode AGAIN

View File

@ -1,4 +1,4 @@
/* $Id: window-choose.c,v 1.8 2009-01-28 19:52:21 nicm Exp $ */ /* $Id: window-choose.c,v 1.9 2009-01-28 22:00:22 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@ -257,7 +257,7 @@ window_choose_mouse(struct window_pane *wp,
struct window_choose_mode_item *item; struct window_choose_mode_item *item;
u_int idx; u_int idx;
if ((b & 3) == 0) if ((b & 3) == 3)
return; return;
if (x >= screen_size_x(s)) if (x >= screen_size_x(s))
return; return;

View File

@ -1,4 +1,4 @@
/* $Id: window-copy.c,v 1.48 2009-01-28 19:52:21 nicm Exp $ */ /* $Id: window-copy.c,v 1.49 2009-01-28 22:00:22 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -26,6 +26,8 @@ struct screen *window_copy_init(struct window_pane *);
void window_copy_free(struct window_pane *); void window_copy_free(struct window_pane *);
void window_copy_resize(struct window_pane *, u_int, u_int); void window_copy_resize(struct window_pane *, u_int, u_int);
void window_copy_key(struct window_pane *, struct client *, int); void window_copy_key(struct window_pane *, struct client *, int);
void window_copy_mouse(
struct window_pane *, struct client *, u_char, u_char, u_char);
void window_copy_redraw_lines(struct window_pane *, u_int, u_int); void window_copy_redraw_lines(struct window_pane *, u_int, u_int);
void window_copy_redraw_screen(struct window_pane *); void window_copy_redraw_screen(struct window_pane *);
@ -64,7 +66,7 @@ const struct window_mode window_copy_mode = {
window_copy_free, window_copy_free,
window_copy_resize, window_copy_resize,
window_copy_key, window_copy_key,
NULL, window_copy_mouse,
NULL, NULL,
}; };
@ -97,6 +99,8 @@ window_copy_init(struct window_pane *wp)
s = &data->screen; s = &data->screen;
screen_init(s, screen_size_x(&wp->base), screen_size_y(&wp->base), 0); screen_init(s, screen_size_x(&wp->base), screen_size_y(&wp->base), 0);
s->mode |= MODE_MOUSE;
s->cx = data->cx; s->cx = data->cx;
s->cy = data->cy; s->cy = data->cy;
@ -212,6 +216,28 @@ window_copy_key(struct window_pane *wp, struct client *c, int key)
} }
} }
void
window_copy_mouse(struct window_pane *wp,
unused struct client *c, u_char b, u_char x, u_char y)
{
struct window_copy_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
if ((b & 3) == 3)
return;
if (x >= screen_size_x(s))
return;
if (y >= screen_size_y(s))
return;
data->cx = x;
data->cy = y;
if (window_copy_update_selection(wp))
window_copy_redraw_screen(wp);
window_copy_update_cursor(wp);
}
void void
window_copy_write_line(struct window_pane *wp, struct screen_write_ctx *ctx, u_int py) window_copy_write_line(struct window_pane *wp, struct screen_write_ctx *ctx, u_int py)
{ {