-u to start with screen scrolled up.

This commit is contained in:
Nicholas Marriott 2009-01-27 23:35:44 +00:00
parent 7b18a9a6eb
commit 2af52440ba
8 changed files with 67 additions and 22 deletions

View File

@ -1,5 +1,7 @@
27 January 2009
* -u flag to scroll-mode and copy-mode to start scrolled one page
up. scroll-mode -u is bound to prefix,page-up (ppage) by default.
* Allow status, mode and message attributes to be changed by three new options:
status-attr, mode-attr, message-attr. A comma-separataed list is accepted
containing: bright, dim, underscore, blink, reverse, hidden, italics, for
@ -1025,7 +1027,7 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.237 2009-01-27 20:22:33 nicm Exp $
$Id: CHANGES,v 1.238 2009-01-27 23:35:44 nicm Exp $
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

2
TODO
View File

@ -82,7 +82,7 @@
- move-pane (to window) (maybe break-pane?)
- command: copy-buffer -s src-session -t dst-session -a src-index -b dst-index
(copy from other session)
- flag to scroll-mode/copy-mode to automatically scroll up a page
- document -u flag to scroll-mode/copy-mode
- key to switch to copy mode from scroll mode
- document suspend-client
- document command sequences

View File

@ -1,4 +1,4 @@
/* $Id: cmd-copy-mode.c,v 1.14 2009-01-19 18:23:40 nicm Exp $ */
/* $Id: cmd-copy-mode.c,v 1.15 2009-01-27 23:35:44 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -29,7 +29,7 @@ int cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_copy_mode_entry = {
"copy-mode", NULL,
CMD_TARGET_WINDOW_USAGE,
0,
CMD_UFLAG,
cmd_target_init,
cmd_target_parse,
cmd_copy_mode_exec,
@ -49,6 +49,9 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
window_pane_set_mode(wl->window->active, &window_copy_mode);
if (data->flags & CMD_UFLAG)
window_copy_pageup(wl->window->active);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $Id: cmd-scroll-mode.c,v 1.15 2009-01-19 18:23:40 nicm Exp $ */
/* $Id: cmd-scroll-mode.c,v 1.16 2009-01-27 23:35:44 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -24,13 +24,14 @@
* Enter scroll mode.
*/
void cmd_scroll_mode_init(struct cmd *, int);
int cmd_scroll_mode_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_scroll_mode_entry = {
"scroll-mode", NULL,
CMD_TARGET_WINDOW_USAGE,
0,
cmd_target_init,
CMD_UFLAG,
cmd_scroll_mode_init,
cmd_target_parse,
cmd_scroll_mode_exec,
cmd_target_send,
@ -39,6 +40,21 @@ const struct cmd_entry cmd_scroll_mode_entry = {
cmd_target_print
};
void
cmd_scroll_mode_init(struct cmd *self, int key)
{
struct cmd_target_data *data;
cmd_target_init(self, key);
data = self->data;
switch (key) {
case KEYC_PPAGE:
data->flags |= CMD_UFLAG;
break;
}
}
int
cmd_scroll_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
{
@ -49,6 +65,8 @@ cmd_scroll_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
window_pane_set_mode(wl->window->active, &window_scroll_mode);
if (data->flags & CMD_UFLAG)
window_scroll_pageup(wl->window->active);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $Id: key-bindings.c,v 1.57 2009-01-18 18:31:45 nicm Exp $ */
/* $Id: key-bindings.c,v 1.58 2009-01-27 23:35:44 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -111,6 +111,7 @@ key_bindings_init(void)
{ 'w', &cmd_choose_window_entry },
{ 'x', &cmd_kill_pane_entry, },
{ '\032', &cmd_suspend_client_entry },
{ KEYC_PPAGE, &cmd_scroll_mode_entry },
{ KEYC_ADDESC('n'), &cmd_next_window_entry },
{ KEYC_ADDESC('p'), &cmd_previous_window_entry },
{ KEYC_UP, &cmd_up_pane_entry },

4
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.253 2009-01-27 21:39:15 nicm Exp $ */
/* $Id: tmux.h,v 1.254 2009-01-27 23:35:44 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -1458,9 +1458,11 @@ extern const struct window_mode window_clock_mode;
/* window-copy.c */
extern const struct window_mode window_copy_mode;
void window_copy_pageup(struct window_pane *);
/* window-scroll.c */
extern const struct window_mode window_scroll_mode;
void window_scroll_pageup(struct window_pane *);
/* window-more.c */
extern const struct window_mode window_more_mode;

View File

@ -1,4 +1,4 @@
/* $Id: window-copy.c,v 1.46 2009-01-27 20:22:33 nicm Exp $ */
/* $Id: window-copy.c,v 1.47 2009-01-27 23:35:44 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -117,6 +117,20 @@ window_copy_free(struct window_pane *wp)
xfree(data);
}
void
window_copy_pageup(struct window_pane *wp)
{
struct window_copy_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
if (data->oy + screen_size_y(s) > screen_hsize(&wp->base))
data->oy = screen_hsize(&wp->base);
else
data->oy += screen_size_y(s);
window_copy_update_selection(wp);
window_copy_redraw_screen(wp);
}
void
window_copy_resize(struct window_pane *wp, u_int sx, u_int sy)
{
@ -156,12 +170,7 @@ window_copy_key(struct window_pane *wp, struct client *c, int key)
window_copy_cursor_down(wp);
return;
case MODEKEY_PPAGE:
if (data->oy + screen_size_y(s) > screen_hsize(&wp->base))
data->oy = screen_hsize(&wp->base);
else
data->oy += screen_size_y(s);
window_copy_update_selection(wp);
window_copy_redraw_screen(wp);
window_copy_pageup(wp);
break;
case MODEKEY_NPAGE:
if (data->oy < screen_size_y(s))

View File

@ -1,4 +1,4 @@
/* $Id: window-scroll.c,v 1.29 2009-01-27 20:22:33 nicm Exp $ */
/* $Id: window-scroll.c,v 1.30 2009-01-27 23:35:44 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -86,6 +86,20 @@ window_scroll_free(struct window_pane *wp)
xfree(data);
}
void
window_scroll_pageup(struct window_pane *wp)
{
struct window_scroll_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
if (data->oy + screen_size_y(s) > screen_hsize(&wp->base))
data->oy = screen_hsize(&wp->base);
else
data->oy += screen_size_y(s);
window_scroll_redraw_screen(wp);
}
void
window_scroll_resize(struct window_pane *wp, u_int sx, u_int sy)
{
@ -126,11 +140,7 @@ window_scroll_key(struct window_pane *wp, unused struct client *c, int key)
window_scroll_scroll_down(wp);
break;
case MODEKEY_PPAGE:
if (data->oy + screen_size_y(s) > screen_hsize(&wp->base))
data->oy = screen_hsize(&wp->base);
else
data->oy += screen_size_y(s);
window_scroll_redraw_screen(wp);
window_scroll_pageup(wp);
break;
case MODEKEY_NPAGE:
if (data->oy < screen_size_y(s))