mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 19:39:04 +00:00
Allow use of alt keys. move-window command.
This commit is contained in:
parent
eb5638f3e7
commit
7836298f29
5
CHANGES
5
CHANGES
@ -1,5 +1,8 @@
|
||||
25 June 2008
|
||||
|
||||
* move-window command.
|
||||
* Support binding alt keys (prefixed with M-). Change default to use
|
||||
C- for ctrl keys (^ is still accepted as an alternative).
|
||||
* Slim down default key bindings: support lowercase only.
|
||||
* Handle escaped keys properly (parse eg \033b into a single key code) and
|
||||
use this to change copy mode next/previous work to M-f and M-b to match
|
||||
@ -567,4 +570,4 @@
|
||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||
customisation.
|
||||
|
||||
$Id: CHANGES,v 1.142 2008-06-25 19:18:20 nicm Exp $
|
||||
$Id: CHANGES,v 1.143 2008-06-25 20:33:20 nicm Exp $
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: GNUmakefile,v 1.33 2008-06-23 22:24:16 nicm Exp $
|
||||
# $Id: GNUmakefile,v 1.34 2008-06-25 20:33:20 nicm Exp $
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
@ -28,7 +28,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
|
||||
cmd-kill-server.c cmd-set-window-option.c cmd-show-options.c \
|
||||
cmd-show-window-options.c cmd-command-prompt.c cmd-set-buffer.c \
|
||||
cmd-show-buffer.c cmd-list-buffers.c cmd-delete-buffer.c \
|
||||
cmd-list-commands.c \
|
||||
cmd-list-commands.c cmd-move-window.c \
|
||||
window-scroll.c window-more.c window-copy.c options.c paste.c \
|
||||
tty.c tty-keys.c tty-write.c screen-write.c screen-redraw.c
|
||||
|
||||
|
4
Makefile
4
Makefile
@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.66 2008-06-23 22:24:16 nicm Exp $
|
||||
# $Id: Makefile,v 1.67 2008-06-25 20:33:20 nicm Exp $
|
||||
|
||||
.SUFFIXES: .c .o .y .h
|
||||
.PHONY: clean update-index.html upload-index.html
|
||||
@ -32,7 +32,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
|
||||
cmd-kill-server.c cmd-set-window-option.c cmd-show-options.c \
|
||||
cmd-show-window-options.c cmd-command-prompt.c cmd-set-buffer.c \
|
||||
cmd-show-buffer.c cmd-list-buffers.c cmd-delete-buffer.c \
|
||||
cmd-list-commands.c \
|
||||
cmd-list-commands.c cmd-move-window.c \
|
||||
window-scroll.c window-more.c window-copy.c options.c paste.c \
|
||||
tty.c tty-keys.c tty-write.c screen-write.c screen-redraw.c
|
||||
|
||||
|
2
TODO
2
TODO
@ -49,7 +49,7 @@
|
||||
|
||||
-- For 0.4 --------------------------------------------------------------------
|
||||
|
||||
- document list-commands. document switch-client
|
||||
- document list-commands. document switch-client. document move-window
|
||||
- document buffer stuff
|
||||
- document next/prev word
|
||||
- commands:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-link-window.c,v 1.23 2008-06-18 22:21:51 nicm Exp $ */
|
||||
/* $Id: cmd-link-window.c,v 1.24 2008-06-25 20:33:20 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -46,29 +46,29 @@ void
|
||||
cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
{
|
||||
struct cmd_srcdst_data *data = self->data;
|
||||
struct session *s;
|
||||
struct session *dst;
|
||||
struct winlink *wl_src, *wl_dst;
|
||||
int idx;
|
||||
|
||||
if ((wl_src = cmd_find_window(ctx, data->src, NULL)) == NULL)
|
||||
return;
|
||||
|
||||
if (arg_parse_window(data->dst, &s, &idx) != 0) {
|
||||
if (arg_parse_window(data->dst, &dst, &idx) != 0) {
|
||||
ctx->error(ctx, "bad window: %s", data->dst);
|
||||
return;
|
||||
}
|
||||
if (s == NULL)
|
||||
s = ctx->cursession;
|
||||
if (s == NULL)
|
||||
s = cmd_current_session(ctx);
|
||||
if (s == NULL) {
|
||||
if (dst == NULL)
|
||||
dst = ctx->cursession;
|
||||
if (dst == NULL)
|
||||
dst = cmd_current_session(ctx);
|
||||
if (dst == NULL) {
|
||||
ctx->error(ctx, "session not found: %s", data->dst);
|
||||
return;
|
||||
}
|
||||
|
||||
wl_dst = NULL;
|
||||
if (idx != -1)
|
||||
wl_dst = winlink_find_by_index(&s->windows, idx);
|
||||
wl_dst = winlink_find_by_index(&dst->windows, idx);
|
||||
if (wl_dst != NULL) {
|
||||
if (wl_dst->window == wl_src->window)
|
||||
goto out;
|
||||
@ -78,35 +78,30 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
* Can't use session_detach as it will destroy session
|
||||
* if this makes it empty.
|
||||
*/
|
||||
session_alert_cancel(s, wl_dst);
|
||||
winlink_remove(&s->windows, wl_dst);
|
||||
session_alert_cancel(dst, wl_dst);
|
||||
winlink_remove(&dst->windows, wl_dst);
|
||||
|
||||
/* Force select/redraw if current. */
|
||||
if (wl_dst == s->curw) {
|
||||
if (wl_dst == dst->curw) {
|
||||
data->flags &= ~CMD_DFLAG;
|
||||
s->curw = NULL;
|
||||
dst->curw = NULL;
|
||||
}
|
||||
if (wl_dst == s->lastw)
|
||||
s->lastw = NULL;
|
||||
|
||||
/*
|
||||
* Can't error out after this or there could be an
|
||||
* empty session!
|
||||
*/
|
||||
if (wl_dst == dst->lastw)
|
||||
dst->lastw = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
wl_dst = session_attach(s, wl_src->window, idx);
|
||||
wl_dst = session_attach(dst, wl_src->window, idx);
|
||||
if (wl_dst == NULL) {
|
||||
ctx->error(ctx, "index in use: %d", idx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data->flags & CMD_DFLAG)
|
||||
server_status_session(s);
|
||||
server_status_session(dst);
|
||||
else {
|
||||
session_select(s, wl_dst->idx);
|
||||
server_redraw_session(s);
|
||||
session_select(dst, wl_dst->idx);
|
||||
server_redraw_session(dst);
|
||||
}
|
||||
recalculate_sizes();
|
||||
|
||||
|
3
cmd.c
3
cmd.c
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd.c,v 1.56 2008-06-23 22:24:16 nicm Exp $ */
|
||||
/* $Id: cmd.c,v 1.57 2008-06-25 20:33:20 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -45,6 +45,7 @@ const struct cmd_entry *cmd_table[] = {
|
||||
&cmd_list_keys_entry,
|
||||
&cmd_list_sessions_entry,
|
||||
&cmd_list_windows_entry,
|
||||
&cmd_move_window_entry,
|
||||
&cmd_new_session_entry,
|
||||
&cmd_new_window_entry,
|
||||
&cmd_next_window_entry,
|
||||
|
86
key-string.c
86
key-string.c
@ -1,4 +1,4 @@
|
||||
/* $Id: key-string.c,v 1.5 2008-06-04 20:01:36 nicm Exp $ */
|
||||
/* $Id: key-string.c,v 1.6 2008-06-25 20:33:20 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -173,39 +173,7 @@ struct {
|
||||
{ "SUNDO", KEYC_SUNDO },
|
||||
{ "SUSPEND", KEYC_SUSPEND },
|
||||
{ "UNDO", KEYC_UNDO },
|
||||
{ "UP", KEYC_UP },
|
||||
{ "^ ", 0 },
|
||||
{ "^A", 1 },
|
||||
{ "^B", 2 },
|
||||
{ "^C", 3 },
|
||||
{ "^D", 4 },
|
||||
{ "^E", 5 },
|
||||
{ "^F", 6 },
|
||||
{ "^G", 7 },
|
||||
{ "^H", 8 },
|
||||
{ "^I", 9 },
|
||||
{ "^J", 10 },
|
||||
{ "^K", 11 },
|
||||
{ "^L", 12 },
|
||||
{ "^M", 13 },
|
||||
{ "^N", 14 },
|
||||
{ "^O", 15 },
|
||||
{ "^P", 16 },
|
||||
{ "^Q", 17 },
|
||||
{ "^R", 18 },
|
||||
{ "^S", 19 },
|
||||
{ "^T", 20 },
|
||||
{ "^U", 21 },
|
||||
{ "^V", 22 },
|
||||
{ "^W", 23 },
|
||||
{ "^X", 24 },
|
||||
{ "^Y", 25 },
|
||||
{ "^Z", 26 },
|
||||
{ "^[", 27 },
|
||||
{ "^\\", 28 },
|
||||
{ "^]", 29 },
|
||||
{ "^^", 30 },
|
||||
{ "^_", 31 }
|
||||
{ "UP", KEYC_UP }
|
||||
};
|
||||
#define NKEYSTRINGS (sizeof key_string_table / sizeof key_string_table[0])
|
||||
|
||||
@ -213,12 +181,39 @@ int
|
||||
key_string_lookup_string(const char *string)
|
||||
{
|
||||
u_int i;
|
||||
int key;
|
||||
|
||||
if (string[0] == '\0')
|
||||
return (KEYC_NONE);
|
||||
if (string[1] == '\0')
|
||||
return (string[0]);
|
||||
|
||||
if (string[0] == 'C' && string[1] == '-') {
|
||||
if (string[2] == '\0' || string[3] != '\0')
|
||||
return (KEYC_NONE);
|
||||
if (string[2] >= 64 && string[2] <= 95)
|
||||
return (string[2] - 64);
|
||||
if (string[2] >= 97 && string[2] <= 122)
|
||||
return (string[2] - 96);
|
||||
return (KEYC_NONE);
|
||||
}
|
||||
|
||||
if (string[0] == '^') {
|
||||
if (string[1] == '\0' || string[2] != '\0')
|
||||
return (KEYC_NONE);
|
||||
if (string[1] >= 64 && string[1] <= 95)
|
||||
return (string[1] - 64);
|
||||
if (string[1] >= 97 && string[1] <= 122)
|
||||
return (string[1] - 96);
|
||||
return (KEYC_NONE);
|
||||
}
|
||||
|
||||
if (string[0] == 'M' && string[1] == '-') {
|
||||
if ((key = key_string_lookup_string(string + 2)) == KEYC_NONE)
|
||||
return (KEYC_NONE);
|
||||
return (KEYC_ADDESCAPE(key));
|
||||
}
|
||||
|
||||
for (i = 0; i < NKEYSTRINGS; i++) {
|
||||
if (strcasecmp(string, key_string_table[i].string) == 0)
|
||||
return (key_string_table[i].key);
|
||||
@ -229,15 +224,34 @@ key_string_lookup_string(const char *string)
|
||||
const char *
|
||||
key_string_lookup_key(int key)
|
||||
{
|
||||
static char tmp[2];
|
||||
static char tmp[24], tmp2[24];
|
||||
const char *s;
|
||||
u_int i;
|
||||
|
||||
if (key > 31 && key < 256) {
|
||||
if (key == 127)
|
||||
return (NULL);
|
||||
|
||||
if (KEYC_ISESCAPE(key)) {
|
||||
if ((s = key_string_lookup_key(KEYC_REMOVEESCAPE(key))) == NULL)
|
||||
return (NULL);
|
||||
xsnprintf(tmp2, sizeof tmp2, "M-%s", s);
|
||||
return (tmp2);
|
||||
}
|
||||
|
||||
if (key >= 32 && key <= 255) {
|
||||
tmp[0] = key;
|
||||
tmp[1] = '\0';
|
||||
return (tmp);
|
||||
}
|
||||
|
||||
if (key >= 0 && key <= 32) {
|
||||
if (key == 0 || key > 26)
|
||||
xsnprintf(tmp, sizeof tmp, "C-%c", 64 + key);
|
||||
else
|
||||
xsnprintf(tmp, sizeof tmp, "C-%c", 96 + key);
|
||||
return (tmp);
|
||||
}
|
||||
|
||||
for (i = 0; i < NKEYSTRINGS; i++) {
|
||||
if (key == key_string_table[i].key)
|
||||
return (key_string_table[i].string);
|
||||
|
37
tmux.1
37
tmux.1
@ -1,4 +1,4 @@
|
||||
.\" $Id: tmux.1,v 1.42 2008-06-19 22:14:12 nicm Exp $
|
||||
.\" $Id: tmux.1,v 1.43 2008-06-25 20:33:20 nicm Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
.\"
|
||||
@ -112,30 +112,30 @@ $
|
||||
.Ed
|
||||
.Pp
|
||||
Within an active session, a new window may be created by typing
|
||||
.Ql ^B
|
||||
(ctrl-B, known as the prefix key)
|
||||
.Ql C-b
|
||||
(ctrl-b, known as the prefix key)
|
||||
followed by the
|
||||
.Ql c
|
||||
key.
|
||||
.Pp
|
||||
Windows may be navigated with:
|
||||
.Ql ^B 0
|
||||
.Ql C-b 0
|
||||
(to select window 0),
|
||||
.Ql ^B 1
|
||||
.Ql C-b 1
|
||||
(to select window 1), and so on;
|
||||
.Ql ^B n
|
||||
.Ql C-b n
|
||||
to select the next window; and
|
||||
.Ql ^B p
|
||||
.Ql C-b p
|
||||
to select the previous window.
|
||||
.Pp
|
||||
A session may be detached using
|
||||
.Ql ^B d
|
||||
.Ql C-b d
|
||||
and reattached with:
|
||||
.Pp
|
||||
.Dl $ tmux attach-session
|
||||
.Pp
|
||||
Typing
|
||||
.Ql ^B \&?
|
||||
.Ql C-b \&?
|
||||
lists the current key bindings in the current window; up and down may be used
|
||||
to navigate the list or
|
||||
.Ql Q
|
||||
@ -144,8 +144,8 @@ to exit from it.
|
||||
.Nm
|
||||
may be controlled from an attached client by using a key combination of a
|
||||
prefix key,
|
||||
.Ql ^B
|
||||
(ctrl-B) by default, followed by a command key.
|
||||
.Ql C-b
|
||||
(ctrl-b) by default, followed by a command key.
|
||||
.Pp
|
||||
Some of the default key bindings include:
|
||||
.Pp
|
||||
@ -227,9 +227,9 @@ This permits a section of a window or its history to be copied to the
|
||||
for later insertion into another window.
|
||||
The navigation keys move the cursor around the window, scrolling as necessary.
|
||||
In addition,
|
||||
.Ql ^A
|
||||
.Ql C-a
|
||||
and
|
||||
.Ql ^E
|
||||
.Ql C-e
|
||||
(or the
|
||||
.Xr vi 1
|
||||
style
|
||||
@ -238,7 +238,7 @@ and
|
||||
.Ql $
|
||||
keys) move to the start and end of the line; the space key begins a selection;
|
||||
and the enter key or
|
||||
.Ql ^W
|
||||
.Ql C-w
|
||||
copies the selection to the paste buffer and exits copy mode.
|
||||
.Pp
|
||||
This mode is entered with the
|
||||
@ -333,6 +333,13 @@ Bind key
|
||||
.Ar key
|
||||
to
|
||||
.Ar command .
|
||||
Keys may be specified prefixed with
|
||||
.Ql C-
|
||||
or
|
||||
.Ql ^
|
||||
for ctrl keys, or
|
||||
.Ql M-
|
||||
for alt (meta) keys.
|
||||
.It Xo Ic command-prompt
|
||||
.Op Fl t Ar target-client
|
||||
.Xc
|
||||
@ -525,7 +532,7 @@ Send a key or keys to a window.
|
||||
Each argument
|
||||
.Ar key
|
||||
is the name of the key (such as
|
||||
.Ql ^A
|
||||
.Ql C-a
|
||||
or
|
||||
.Ql npage
|
||||
) to send; if the string is not recognised as a key, it is sent as a series of
|
||||
|
3
tmux.h
3
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.168 2008-06-25 07:30:08 nicm Exp $ */
|
||||
/* $Id: tmux.h,v 1.169 2008-06-25 20:33:20 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -958,6 +958,7 @@ extern const struct cmd_entry cmd_list_commands_entry;
|
||||
extern const struct cmd_entry cmd_list_keys_entry;
|
||||
extern const struct cmd_entry cmd_list_sessions_entry;
|
||||
extern const struct cmd_entry cmd_list_windows_entry;
|
||||
extern const struct cmd_entry cmd_move_window_entry;
|
||||
extern const struct cmd_entry cmd_new_session_entry;
|
||||
extern const struct cmd_entry cmd_new_window_entry;
|
||||
extern const struct cmd_entry cmd_next_window_entry;
|
||||
|
Loading…
Reference in New Issue
Block a user