Add ^A && ^E to copy mode. Also use STDIN instead of STDOUT in a couple of places.

This commit is contained in:
Nicholas Marriott 2007-11-26 20:36:30 +00:00
parent d61a63c04e
commit 818df923de
5 changed files with 78 additions and 9 deletions

View File

@ -1,3 +1,7 @@
26 November 2007
* Add ^A and ^E to copy mode to move to start-of-line/end-of-line.
24 November 2007
* Support for alt charset mode (VT100 graphics characters).
@ -267,4 +271,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.84 2007-11-24 23:29:49 nicm Exp $
$Id: CHANGES,v 1.85 2007-11-26 20:36:30 nicm Exp $

View File

@ -1,4 +1,4 @@
/* $Id: client.c,v 1.21 2007-11-12 15:12:08 nicm Exp $ */
/* $Id: client.c,v 1.22 2007-11-26 20:36:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -102,7 +102,7 @@ retry:
cctx->srv_in = buffer_create(BUFSIZ);
cctx->srv_out = buffer_create(BUFSIZ);
if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
if (isatty(STDIN_FILENO)) {
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1) {
log_warn("ioctl(TIOCGWINSZ)");
return (-1);

View File

@ -1,4 +1,4 @@
/* $Id: local.c,v 1.22 2007-11-25 10:59:44 nicm Exp $ */
/* $Id: local.c,v 1.23 2007-11-26 20:36:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -243,7 +243,7 @@ local_init(struct buffer **in, struct buffer **out)
NULL
};
if ((tty = ttyname(STDOUT_FILENO)) == NULL)
if ((tty = ttyname(STDIN_FILENO)) == NULL)
fatal("ttyname failed");
if ((local_fd = open(tty, O_RDWR)) == -1)
fatal("open failed");

9
tmux.1
View File

@ -1,4 +1,4 @@
.\" $Id: tmux.1,v 1.19 2007-11-24 18:05:39 nicm Exp $
.\" $Id: tmux.1,v 1.20 2007-11-26 20:36:30 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@ -176,7 +176,12 @@ This is permits a section of a window or its history to be copied to the
.Em paste buffer
for later insertion into another window.
The navigation keys move the cursor around the window, scrolling as necessary.
The space key begins a selection; the enter key or
In addition,
.Ql ^A
and
.Ql ^E
move to the start and end of the line; the space key begins a selection; and the
enter key or
.Ql ^W
copies the selection to the paste buffer and exits copy mode.
.Pp

View File

@ -1,4 +1,4 @@
/* $Id: window-copy.c,v 1.6 2007-11-23 17:52:54 nicm Exp $ */
/* $Id: window-copy.c,v 1.7 2007-11-26 20:36:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -34,6 +34,8 @@ void window_copy_copy_line(
struct window *, char **, size_t *, size_t *, u_int, u_int, u_int);
u_int window_copy_find_length(struct window *, u_int);
void window_copy_move_cursor(struct window *);
void window_copy_cursor_bol(struct window *);
void window_copy_cursor_eol(struct window *);
void window_copy_cursor_left(struct window *);
void window_copy_cursor_right(struct window *);
void window_copy_cursor_up(struct window *);
@ -186,12 +188,21 @@ window_copy_key(struct window *w, int key)
data->sely = data->size + data->cy - data->oy;
oy = -1; /* XXX */
break;
case '\033':
data->selflag = 0;
oy = -1; /* XXX */
break;
case '\027': /* C-w */
case '\r': /* enter */
if (data->selflag)
window_copy_copy_selection(w);
goto done;
/* XXX start/end of line, next word, prev word, cancel sel */
case '\001': /* C-a */
window_copy_cursor_bol(w);
return;
case '\005': /* C-e */
window_copy_cursor_eol(w);
return;
}
if (data->oy != oy) {
server_redraw_window_all(w);
@ -337,6 +348,55 @@ window_copy_move_cursor(struct window *w)
}
}
void
window_copy_cursor_bol(struct window *w)
{
struct window_copy_mode_data *data = w->modedata;
if (data->ox != 0)
window_copy_scroll_right(w, data->ox);
data->cx = 0;
window_copy_move_cursor(w);
}
void
window_copy_cursor_eol(struct window *w)
{
struct window_copy_mode_data *data = w->modedata;
struct screen *s = &w->screen;
u_int xx;
xx = window_copy_find_length(w, data->size + data->cy - data->oy);
/* On screen. */
if (xx > data->ox && xx < data->ox + screen_last_x(s))
data->cx = xx - data->ox;
/* Off right of screen. */
if (xx > data->ox + screen_last_x(s)) {
/* Move cursor to last and scroll screen. */
window_copy_scroll_left(w,
xx - data->ox - screen_last_x(s));
data->cx = screen_last_x(s);
}
/* Off left of screen. */
if (xx <= data->ox) {
if (xx < screen_last_x(s)) {
/* Short enough to fit on screen. */
window_copy_scroll_right(w, data->ox);
data->cx = xx;
} else {
/* Too long to fit on screen. */
window_copy_scroll_right(
w, data->ox - (xx - screen_last_x(s)));
data->cx = screen_last_x(s);
}
}
window_copy_move_cursor(w);
}
void
window_copy_cursor_left(struct window *w)
{