Merge branch 'obsd-master'

Conflicts:
	format.c
	osdep-openbsd.c
This commit is contained in:
Thomas Adam
2016-10-12 09:45:49 +01:00
98 changed files with 2110 additions and 2229 deletions

View File

@@ -34,6 +34,7 @@ struct args_entry {
RB_ENTRY(args_entry) entry; RB_ENTRY(args_entry) entry;
}; };
static void args_set(struct args *, u_char, const char *);
static struct args_entry *args_find(struct args *, u_char); static struct args_entry *args_find(struct args *, u_char);
static int args_cmp(struct args_entry *, struct args_entry *); static int args_cmp(struct args_entry *, struct args_entry *);
@@ -46,30 +47,6 @@ args_cmp(struct args_entry *a1, struct args_entry *a2)
return (a1->flag - a2->flag); return (a1->flag - a2->flag);
} }
/* Create an arguments set with no flags. */
struct args *
args_create(int argc, ...)
{
struct args *args;
va_list ap;
int i;
args = xcalloc(1, sizeof *args);
args->argc = argc;
if (argc == 0)
args->argv = NULL;
else
args->argv = xcalloc(argc, sizeof *args->argv);
va_start(ap, argc);
for (i = 0; i < argc; i++)
args->argv[i] = xstrdup(va_arg(ap, char *));
va_end(ap);
return (args);
}
/* Find a flag in the arguments tree. */ /* Find a flag in the arguments tree. */
static struct args_entry * static struct args_entry *
args_find(struct args *args, u_char ch) args_find(struct args *args, u_char ch)
@@ -205,7 +182,7 @@ args_has(struct args *args, u_char ch)
} }
/* Set argument value in the arguments tree. */ /* Set argument value in the arguments tree. */
void static void
args_set(struct args *args, u_char ch, const char *value) args_set(struct args *args, u_char ch, const char *value)
{ {
struct args_entry *entry; struct args_entry *entry;

18
cfg.c
View File

@@ -27,15 +27,15 @@
#include "tmux.h" #include "tmux.h"
char *cfg_file; char *cfg_file;
struct cmd_q *cfg_cmd_q; static struct cmd_q *cfg_cmd_q;
int cfg_finished; int cfg_finished;
int cfg_references; int cfg_references;
char **cfg_causes; static char **cfg_causes;
u_int cfg_ncauses; static u_int cfg_ncauses;
struct client *cfg_client; struct client *cfg_client;
void cfg_default_done(struct cmd_q *); static void cfg_default_done(struct cmd_q *);
void void
set_cfg_file(const char *path) set_cfg_file(const char *path)
@@ -125,7 +125,7 @@ load_cfg(const char *path, struct cmd_q *cmdq, int quiet)
return (found); return (found);
} }
void static void
cfg_default_done(__unused struct cmd_q *cmdq) cfg_default_done(__unused struct cmd_q *cmdq)
{ {
if (--cfg_references != 0) if (--cfg_references != 0)

View File

@@ -30,7 +30,7 @@
* Attach existing session to the current terminal. * Attach existing session to the current terminal.
*/ */
enum cmd_retval cmd_attach_session_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_attach_session_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_attach_session_entry = { const struct cmd_entry cmd_attach_session_entry = {
.name = "attach-session", .name = "attach-session",
@@ -154,7 +154,7 @@ cmd_attach_session(struct cmd_q *cmdq, int dflag, int rflag, const char *cflag,
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
enum cmd_retval static enum cmd_retval
cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq) cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -27,24 +27,24 @@
* Bind a key to a command, this recurses through cmd_*. * Bind a key to a command, this recurses through cmd_*.
*/ */
enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmd_q *);
enum cmd_retval cmd_bind_key_mode_table(struct cmd *, struct cmd_q *, static enum cmd_retval cmd_bind_key_mode_table(struct cmd *, struct cmd_q *,
key_code); key_code);
const struct cmd_entry cmd_bind_key_entry = { const struct cmd_entry cmd_bind_key_entry = {
.name = "bind-key", .name = "bind-key",
.alias = "bind", .alias = "bind",
.args = { "cnrR:t:T:", 1, -1 }, .args = { "cnrt:T:", 1, -1 },
.usage = "[-cnr] [-t mode-table] [-R repeat-count] [-T key-table] key " .usage = "[-cnr] [-t mode-table] [-T key-table] key "
"command [arguments]", "command [arguments]",
.flags = 0, .flags = 0,
.exec = cmd_bind_key_exec .exec = cmd_bind_key_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq) cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -93,16 +93,14 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
enum cmd_retval static enum cmd_retval
cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key) cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key)
{ {
struct args *args = self->args; struct args *args = self->args;
const char *tablename, *arg; const char *tablename;
const struct mode_key_table *mtab; const struct mode_key_table *mtab;
struct mode_key_binding *mbind, mtmp; struct mode_key_binding *mbind, mtmp;
enum mode_key_cmd cmd; enum mode_key_cmd cmd;
char *cause;
u_int repeat;
tablename = args_get(args, 't'); tablename = args_get(args, 't');
if ((mtab = mode_key_findtable(tablename)) == NULL) { if ((mtab = mode_key_findtable(tablename)) == NULL) {
@@ -116,44 +114,9 @@ cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
switch (cmd) { if (args->argc != 2) {
case MODEKEYCOPY_APPENDSELECTION: cmdq_error(cmdq, "no argument allowed");
case MODEKEYCOPY_COPYSELECTION: return (CMD_RETURN_ERROR);
case MODEKEYCOPY_STARTNAMEDBUFFER:
if (args->argc == 2)
arg = NULL;
else {
arg = args->argv[2];
if (strcmp(arg, "-x") != 0) {
cmdq_error(cmdq, "unknown argument");
return (CMD_RETURN_ERROR);
}
}
break;
case MODEKEYCOPY_COPYPIPE:
if (args->argc != 3) {
cmdq_error(cmdq, "no argument given");
return (CMD_RETURN_ERROR);
}
arg = args->argv[2];
break;
default:
if (args->argc != 2) {
cmdq_error(cmdq, "no argument allowed");
return (CMD_RETURN_ERROR);
}
arg = NULL;
break;
}
repeat = 1;
if (args_has(args, 'R')) {
repeat = args_strtonum(args, 'R', 1, SHRT_MAX, &cause);
if (cause != NULL) {
cmdq_error(cmdq, "repeat count %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
} }
mtmp.key = key; mtmp.key = key;
@@ -164,8 +127,6 @@ cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key)
mbind->mode = mtmp.mode; mbind->mode = mtmp.mode;
RB_INSERT(mode_key_tree, mtab->tree, mbind); RB_INSERT(mode_key_tree, mtab->tree, mbind);
} }
mbind->repeat = repeat;
mbind->cmd = cmd; mbind->cmd = cmd;
mbind->arg = arg != NULL ? xstrdup(arg) : NULL;
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -28,7 +28,7 @@
#define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}" #define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_break_pane_entry = { const struct cmd_entry cmd_break_pane_entry = {
.name = "break-pane", .name = "break-pane",
@@ -44,7 +44,7 @@ const struct cmd_entry cmd_break_pane_entry = {
.exec = cmd_break_pane_exec .exec = cmd_break_pane_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -27,13 +27,14 @@
* Write the entire contents of a pane to a buffer or stdout. * Write the entire contents of a pane to a buffer or stdout.
*/ */
enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmd_q *);
char *cmd_capture_pane_append(char *, size_t *, char *, size_t); static char *cmd_capture_pane_append(char *, size_t *, char *,
char *cmd_capture_pane_pending(struct args *, struct window_pane *, size_t);
size_t *); static char *cmd_capture_pane_pending(struct args *,
char *cmd_capture_pane_history(struct args *, struct cmd_q *, struct window_pane *, size_t *);
struct window_pane *, size_t *); static char *cmd_capture_pane_history(struct args *, struct cmd_q *,
struct window_pane *, size_t *);
const struct cmd_entry cmd_capture_pane_entry = { const struct cmd_entry cmd_capture_pane_entry = {
.name = "capture-pane", .name = "capture-pane",
@@ -49,7 +50,7 @@ const struct cmd_entry cmd_capture_pane_entry = {
.exec = cmd_capture_pane_exec .exec = cmd_capture_pane_exec
}; };
char * static char *
cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen) cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen)
{ {
buf = xrealloc(buf, *len + linelen + 1); buf = xrealloc(buf, *len + linelen + 1);
@@ -58,7 +59,7 @@ cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen)
return (buf); return (buf);
} }
char * static char *
cmd_capture_pane_pending(struct args *args, struct window_pane *wp, cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
size_t *len) size_t *len)
{ {
@@ -90,7 +91,7 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
return (buf); return (buf);
} }
char * static char *
cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq, cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
struct window_pane *wp, size_t *len) struct window_pane *wp, size_t *len)
{ {
@@ -175,7 +176,7 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
return (buf); return (buf);
} }
enum cmd_retval static enum cmd_retval
cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -30,7 +30,7 @@
#define CHOOSE_BUFFER_TEMPLATE \ #define CHOOSE_BUFFER_TEMPLATE \
"#{buffer_name}: #{buffer_size} bytes: #{buffer_sample}" "#{buffer_name}: #{buffer_size} bytes: #{buffer_sample}"
enum cmd_retval cmd_choose_buffer_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_choose_buffer_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_choose_buffer_entry = { const struct cmd_entry cmd_choose_buffer_entry = {
.name = "choose-buffer", .name = "choose-buffer",
@@ -45,7 +45,7 @@ const struct cmd_entry cmd_choose_buffer_entry = {
.exec = cmd_choose_buffer_exec .exec = cmd_choose_buffer_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq) cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -33,9 +33,9 @@
"#{?client_utf8, (utf8),}#{?client_readonly, (ro),} " \ "#{?client_utf8, (utf8),}#{?client_readonly, (ro),} " \
"(last used #{t:client_activity})" "(last used #{t:client_activity})"
enum cmd_retval cmd_choose_client_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_choose_client_exec(struct cmd *, struct cmd_q *);
void cmd_choose_client_callback(struct window_choose_data *); static void cmd_choose_client_callback(struct window_choose_data *);
const struct cmd_entry cmd_choose_client_entry = { const struct cmd_entry cmd_choose_client_entry = {
.name = "choose-client", .name = "choose-client",
@@ -54,7 +54,7 @@ struct cmd_choose_client_data {
struct client *client; struct client *client;
}; };
enum cmd_retval static enum cmd_retval
cmd_choose_client_exec(struct cmd *self, struct cmd_q *cmdq) cmd_choose_client_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -110,7 +110,7 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
void static void
cmd_choose_client_callback(struct window_choose_data *cdata) cmd_choose_client_callback(struct window_choose_data *cdata)
{ {
struct client *c; struct client *c;

View File

@@ -41,7 +41,7 @@
"#{window_index}: #{window_name}#{window_flags} " \ "#{window_index}: #{window_name}#{window_flags} " \
"\"#{pane_title}\"" "\"#{pane_title}\""
enum cmd_retval cmd_choose_tree_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_choose_tree_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_choose_tree_entry = { const struct cmd_entry cmd_choose_tree_entry = {
.name = "choose-tree", .name = "choose-tree",
@@ -83,7 +83,7 @@ const struct cmd_entry cmd_choose_window_entry = {
.exec = cmd_choose_tree_exec .exec = cmd_choose_tree_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_choose_tree_exec(struct cmd *self, struct cmd_q *cmdq) cmd_choose_tree_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -24,7 +24,7 @@
* Clear pane history. * Clear pane history.
*/ */
enum cmd_retval cmd_clear_history_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_clear_history_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_clear_history_entry = { const struct cmd_entry cmd_clear_history_entry = {
.name = "clear-history", .name = "clear-history",
@@ -39,7 +39,7 @@ const struct cmd_entry cmd_clear_history_entry = {
.exec = cmd_clear_history_exec .exec = cmd_clear_history_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_clear_history_exec(__unused struct cmd *self, struct cmd_q *cmdq) cmd_clear_history_exec(__unused struct cmd *self, struct cmd_q *cmdq)
{ {
struct window_pane *wp = cmdq->state.tflag.wp; struct window_pane *wp = cmdq->state.tflag.wp;

View File

@@ -29,17 +29,17 @@
* Prompt for command in client. * Prompt for command in client.
*/ */
enum cmd_retval cmd_command_prompt_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_command_prompt_exec(struct cmd *, struct cmd_q *);
int cmd_command_prompt_callback(void *, const char *); static int cmd_command_prompt_callback(void *, const char *);
void cmd_command_prompt_free(void *); static void cmd_command_prompt_free(void *);
const struct cmd_entry cmd_command_prompt_entry = { const struct cmd_entry cmd_command_prompt_entry = {
.name = "command-prompt", .name = "command-prompt",
.alias = NULL, .alias = NULL,
.args = { "I:p:t:", 0, 1 }, .args = { "1I:p:t:", 0, 1 },
.usage = "[-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " " .usage = "[-1] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " "
"[template]", "[template]",
.tflag = CMD_CLIENT, .tflag = CMD_CLIENT,
@@ -58,7 +58,7 @@ struct cmd_command_prompt_cdata {
int idx; int idx;
}; };
enum cmd_retval static enum cmd_retval
cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq) cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -67,6 +67,7 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq)
struct client *c = cmdq->state.c; struct client *c = cmdq->state.c;
char *prompt, *ptr, *input = NULL; char *prompt, *ptr, *input = NULL;
size_t n; size_t n;
int flags;
if (c->prompt_string != NULL) if (c->prompt_string != NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
@@ -108,14 +109,17 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq)
input = strsep(&cdata->next_input, ","); input = strsep(&cdata->next_input, ",");
} }
flags = 0;
if (args_has(args, '1'))
flags |= PROMPT_SINGLE;
status_prompt_set(c, prompt, input, cmd_command_prompt_callback, status_prompt_set(c, prompt, input, cmd_command_prompt_callback,
cmd_command_prompt_free, cdata, 0); cmd_command_prompt_free, cdata, flags);
free(prompt); free(prompt);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
int static int
cmd_command_prompt_callback(void *data, const char *s) cmd_command_prompt_callback(void *data, const char *s)
{ {
struct cmd_command_prompt_cdata *cdata = data; struct cmd_command_prompt_cdata *cdata = data;
@@ -162,7 +166,7 @@ cmd_command_prompt_callback(void *data, const char *s)
return (0); return (0);
} }
void static void
cmd_command_prompt_free(void *data) cmd_command_prompt_free(void *data)
{ {
struct cmd_command_prompt_cdata *cdata = data; struct cmd_command_prompt_cdata *cdata = data;

View File

@@ -28,10 +28,10 @@
* Asks for confirmation before executing a command. * Asks for confirmation before executing a command.
*/ */
enum cmd_retval cmd_confirm_before_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_confirm_before_exec(struct cmd *, struct cmd_q *);
int cmd_confirm_before_callback(void *, const char *); static int cmd_confirm_before_callback(void *, const char *);
void cmd_confirm_before_free(void *); static void cmd_confirm_before_free(void *);
const struct cmd_entry cmd_confirm_before_entry = { const struct cmd_entry cmd_confirm_before_entry = {
.name = "confirm-before", .name = "confirm-before",
@@ -51,7 +51,7 @@ struct cmd_confirm_before_data {
struct client *client; struct client *client;
}; };
enum cmd_retval static enum cmd_retval
cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq) cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -83,7 +83,7 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
int static int
cmd_confirm_before_callback(void *data, const char *s) cmd_confirm_before_callback(void *data, const char *s)
{ {
struct cmd_confirm_before_data *cdata = data; struct cmd_confirm_before_data *cdata = data;
@@ -113,7 +113,7 @@ cmd_confirm_before_callback(void *data, const char *s)
return (0); return (0);
} }
void static void
cmd_confirm_before_free(void *data) cmd_confirm_before_free(void *data)
{ {
struct cmd_confirm_before_data *cdata = data; struct cmd_confirm_before_data *cdata = data;

View File

@@ -24,7 +24,7 @@
* Enter copy or clock mode. * Enter copy or clock mode.
*/ */
enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_copy_mode_entry = { const struct cmd_entry cmd_copy_mode_entry = {
.name = "copy-mode", .name = "copy-mode",
@@ -52,7 +52,7 @@ const struct cmd_entry cmd_clock_mode_entry = {
.exec = cmd_copy_mode_exec .exec = cmd_copy_mode_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq) cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -26,7 +26,7 @@
* Detach a client. * Detach a client.
*/ */
enum cmd_retval cmd_detach_client_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_detach_client_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_detach_client_entry = { const struct cmd_entry cmd_detach_client_entry = {
.name = "detach-client", .name = "detach-client",
@@ -55,7 +55,7 @@ const struct cmd_entry cmd_suspend_client_entry = {
.exec = cmd_detach_client_exec .exec = cmd_detach_client_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq) cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -32,7 +32,7 @@
"#{window_name}, current pane #{pane_index} " \ "#{window_name}, current pane #{pane_index} " \
"- (%H:%M %d-%b-%y)" "- (%H:%M %d-%b-%y)"
enum cmd_retval cmd_display_message_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_display_message_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_display_message_entry = { const struct cmd_entry cmd_display_message_entry = {
.name = "display-message", .name = "display-message",
@@ -49,7 +49,7 @@ const struct cmd_entry cmd_display_message_entry = {
.exec = cmd_display_message_exec .exec = cmd_display_message_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_display_message_exec(struct cmd *self, struct cmd_q *cmdq) cmd_display_message_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -33,9 +33,9 @@
"[#{window_width}x#{window_height}] " \ "[#{window_width}x#{window_height}] " \
"(#{window_panes} panes) #{window_find_matches}" "(#{window_panes} panes) #{window_find_matches}"
enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmd_q *);
void cmd_find_window_callback(struct window_choose_data *); static void cmd_find_window_callback(struct window_choose_data *);
/* Flags for determining matching behavior. */ /* Flags for determining matching behavior. */
#define CMD_FIND_WINDOW_BY_TITLE 0x1 #define CMD_FIND_WINDOW_BY_TITLE 0x1
@@ -68,11 +68,11 @@ struct cmd_find_window_data {
}; };
TAILQ_HEAD(cmd_find_window_list, cmd_find_window_data); TAILQ_HEAD(cmd_find_window_list, cmd_find_window_data);
u_int cmd_find_window_match_flags(struct args *); static u_int cmd_find_window_match_flags(struct args *);
void cmd_find_window_match(struct cmd_find_window_list *, int, static void cmd_find_window_match(struct cmd_find_window_list *, int,
struct winlink *, const char *, const char *); struct winlink *, const char *, const char *);
u_int static u_int
cmd_find_window_match_flags(struct args *args) cmd_find_window_match_flags(struct args *args)
{ {
u_int match_flags = 0; u_int match_flags = 0;
@@ -92,7 +92,7 @@ cmd_find_window_match_flags(struct args *args)
return (match_flags); return (match_flags);
} }
void static void
cmd_find_window_match(struct cmd_find_window_list *find_list, cmd_find_window_match(struct cmd_find_window_list *find_list,
int match_flags, struct winlink *wl, const char *str, int match_flags, struct winlink *wl, const char *str,
const char *searchstr) const char *searchstr)
@@ -138,7 +138,7 @@ cmd_find_window_match(struct cmd_find_window_list *find_list,
free(find_data); free(find_data);
} }
enum cmd_retval static enum cmd_retval
cmd_find_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_find_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -216,7 +216,7 @@ out:
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
void static void
cmd_find_window_callback(struct window_choose_data *cdata) cmd_find_window_callback(struct window_choose_data *cdata)
{ {
struct session *s; struct session *s;

View File

@@ -26,33 +26,35 @@
#include "tmux.h" #include "tmux.h"
struct session *cmd_find_try_TMUX(struct client *, struct window *); static struct session *cmd_find_try_TMUX(struct client *, struct window *);
int cmd_find_client_better(struct client *, struct client *); static int cmd_find_client_better(struct client *, struct client *);
struct client *cmd_find_best_client(struct client **, u_int); static struct client *cmd_find_best_client(struct client **, u_int);
int cmd_find_session_better(struct session *, struct session *, static int cmd_find_session_better(struct session *, struct session *,
int); int);
struct session *cmd_find_best_session(struct session **, u_int, int); static struct session *cmd_find_best_session(struct session **, u_int, int);
int cmd_find_best_session_with_window(struct cmd_find_state *); static int cmd_find_best_session_with_window(struct cmd_find_state *);
int cmd_find_best_winlink_with_window(struct cmd_find_state *); static int cmd_find_best_winlink_with_window(struct cmd_find_state *);
int cmd_find_current_session_with_client(struct cmd_find_state *); static int cmd_find_current_session_with_client(struct cmd_find_state *);
int cmd_find_current_session(struct cmd_find_state *); static int cmd_find_current_session(struct cmd_find_state *);
struct client *cmd_find_current_client(struct cmd_q *); static struct client *cmd_find_current_client(struct cmd_q *);
const char *cmd_find_map_table(const char *[][2], const char *); static const char *cmd_find_map_table(const char *[][2], const char *);
int cmd_find_get_session(struct cmd_find_state *, const char *); static int cmd_find_get_session(struct cmd_find_state *, const char *);
int cmd_find_get_window(struct cmd_find_state *, const char *); static int cmd_find_get_window(struct cmd_find_state *, const char *);
int cmd_find_get_window_with_session(struct cmd_find_state *, const char *); static int cmd_find_get_window_with_session(struct cmd_find_state *,
int cmd_find_get_window_with_pane(struct cmd_find_state *); const char *);
int cmd_find_get_pane(struct cmd_find_state *, const char *); static int cmd_find_get_pane(struct cmd_find_state *, const char *);
int cmd_find_get_pane_with_session(struct cmd_find_state *, const char *); static int cmd_find_get_pane_with_session(struct cmd_find_state *,
int cmd_find_get_pane_with_window(struct cmd_find_state *, const char *); const char *);
static int cmd_find_get_pane_with_window(struct cmd_find_state *,
const char *);
const char *cmd_find_session_table[][2] = { static const char *cmd_find_session_table[][2] = {
{ NULL, NULL } { NULL, NULL }
}; };
const char *cmd_find_window_table[][2] = { static const char *cmd_find_window_table[][2] = {
{ "{start}", "^" }, { "{start}", "^" },
{ "{last}", "!" }, { "{last}", "!" },
{ "{end}", "$" }, { "{end}", "$" },
@@ -60,7 +62,7 @@ const char *cmd_find_window_table[][2] = {
{ "{previous}", "-" }, { "{previous}", "-" },
{ NULL, NULL } { NULL, NULL }
}; };
const char *cmd_find_pane_table[][2] = { static const char *cmd_find_pane_table[][2] = {
{ "{last}", "!" }, { "{last}", "!" },
{ "{next}", "+" }, { "{next}", "+" },
{ "{previous}", "-" }, { "{previous}", "-" },
@@ -80,7 +82,7 @@ const char *cmd_find_pane_table[][2] = {
}; };
/* Get session from TMUX if present. */ /* Get session from TMUX if present. */
struct session * static struct session *
cmd_find_try_TMUX(struct client *c, struct window *w) cmd_find_try_TMUX(struct client *c, struct window *w)
{ {
struct environ_entry *envent; struct environ_entry *envent;
@@ -107,7 +109,7 @@ cmd_find_try_TMUX(struct client *c, struct window *w)
} }
/* Is this client better? */ /* Is this client better? */
int static int
cmd_find_client_better(struct client *c, struct client *than) cmd_find_client_better(struct client *c, struct client *than)
{ {
if (than == NULL) if (than == NULL)
@@ -116,7 +118,7 @@ cmd_find_client_better(struct client *c, struct client *than)
} }
/* Find best client from a list, or all if list is NULL. */ /* Find best client from a list, or all if list is NULL. */
struct client * static struct client *
cmd_find_best_client(struct client **clist, u_int csize) cmd_find_best_client(struct client **clist, u_int csize)
{ {
struct client *c_loop, *c; struct client *c_loop, *c;
@@ -142,7 +144,7 @@ cmd_find_best_client(struct client **clist, u_int csize)
} }
/* Is this session better? */ /* Is this session better? */
int static int
cmd_find_session_better(struct session *s, struct session *than, int flags) cmd_find_session_better(struct session *s, struct session *than, int flags)
{ {
int attached; int attached;
@@ -160,7 +162,7 @@ cmd_find_session_better(struct session *s, struct session *than, int flags)
} }
/* Find best session from a list, or all if list is NULL. */ /* Find best session from a list, or all if list is NULL. */
struct session * static struct session *
cmd_find_best_session(struct session **slist, u_int ssize, int flags) cmd_find_best_session(struct session **slist, u_int ssize, int flags)
{ {
struct session *s_loop, *s; struct session *s_loop, *s;
@@ -182,7 +184,7 @@ cmd_find_best_session(struct session **slist, u_int ssize, int flags)
} }
/* Find best session and winlink for window. */ /* Find best session and winlink for window. */
int static int
cmd_find_best_session_with_window(struct cmd_find_state *fs) cmd_find_best_session_with_window(struct cmd_find_state *fs)
{ {
struct session **slist = NULL; struct session **slist = NULL;
@@ -219,7 +221,7 @@ fail:
* Find the best winlink for a window (the current if it contains the pane, * Find the best winlink for a window (the current if it contains the pane,
* otherwise the first). * otherwise the first).
*/ */
int static int
cmd_find_best_winlink_with_window(struct cmd_find_state *fs) cmd_find_best_winlink_with_window(struct cmd_find_state *fs)
{ {
struct winlink *wl, *wl_loop; struct winlink *wl, *wl_loop;
@@ -243,7 +245,7 @@ cmd_find_best_winlink_with_window(struct cmd_find_state *fs)
} }
/* Find current session when we have an unattached client. */ /* Find current session when we have an unattached client. */
int static int
cmd_find_current_session_with_client(struct cmd_find_state *fs) cmd_find_current_session_with_client(struct cmd_find_state *fs)
{ {
struct window_pane *wp; struct window_pane *wp;
@@ -307,7 +309,7 @@ unknown_pane:
* Work out the best current state. If this function succeeds, the state is * Work out the best current state. If this function succeeds, the state is
* guaranteed to be completely filled in. * guaranteed to be completely filled in.
*/ */
int static int
cmd_find_current_session(struct cmd_find_state *fs) cmd_find_current_session(struct cmd_find_state *fs)
{ {
/* If we know the current client, use it. */ /* If we know the current client, use it. */
@@ -337,7 +339,7 @@ cmd_find_current_session(struct cmd_find_state *fs)
} }
/* Work out the best current client. */ /* Work out the best current client. */
struct client * static struct client *
cmd_find_current_client(struct cmd_q *cmdq) cmd_find_current_client(struct cmd_q *cmdq)
{ {
struct cmd_find_state current; struct cmd_find_state current;
@@ -383,7 +385,7 @@ cmd_find_current_client(struct cmd_q *cmdq)
} }
/* Maps string in table. */ /* Maps string in table. */
const char * static const char *
cmd_find_map_table(const char *table[][2], const char *s) cmd_find_map_table(const char *table[][2], const char *s)
{ {
u_int i; u_int i;
@@ -396,7 +398,7 @@ cmd_find_map_table(const char *table[][2], const char *s)
} }
/* Find session from string. Fills in s. */ /* Find session from string. Fills in s. */
int static int
cmd_find_get_session(struct cmd_find_state *fs, const char *session) cmd_find_get_session(struct cmd_find_state *fs, const char *session)
{ {
struct session *s, *s_loop; struct session *s, *s_loop;
@@ -460,7 +462,7 @@ cmd_find_get_session(struct cmd_find_state *fs, const char *session)
} }
/* Find window from string. Fills in s, wl, w. */ /* Find window from string. Fills in s, wl, w. */
int static int
cmd_find_get_window(struct cmd_find_state *fs, const char *window) cmd_find_get_window(struct cmd_find_state *fs, const char *window)
{ {
log_debug("%s: %s", __func__, window); log_debug("%s: %s", __func__, window);
@@ -496,7 +498,7 @@ cmd_find_get_window(struct cmd_find_state *fs, const char *window)
* Find window from string, assuming it is in given session. Needs s, fills in * Find window from string, assuming it is in given session. Needs s, fills in
* wl and w. * wl and w.
*/ */
int static int
cmd_find_get_window_with_session(struct cmd_find_state *fs, const char *window) cmd_find_get_window_with_session(struct cmd_find_state *fs, const char *window)
{ {
struct winlink *wl; struct winlink *wl;
@@ -646,18 +648,8 @@ cmd_find_get_window_with_session(struct cmd_find_state *fs, const char *window)
return (-1); return (-1);
} }
/* Find window from given pane. Needs wp, fills in s and wl and w. */
int
cmd_find_get_window_with_pane(struct cmd_find_state *fs)
{
log_debug("%s", __func__);
fs->w = fs->wp->window;
return (cmd_find_best_session_with_window(fs));
}
/* Find pane from string. Fills in s, wl, w, wp. */ /* Find pane from string. Fills in s, wl, w, wp. */
int static int
cmd_find_get_pane(struct cmd_find_state *fs, const char *pane) cmd_find_get_pane(struct cmd_find_state *fs, const char *pane)
{ {
log_debug("%s: %s", __func__, pane); log_debug("%s: %s", __func__, pane);
@@ -694,7 +686,7 @@ cmd_find_get_pane(struct cmd_find_state *fs, const char *pane)
* Find pane from string, assuming it is in given session. Needs s, fills in wl * Find pane from string, assuming it is in given session. Needs s, fills in wl
* and w and wp. * and w and wp.
*/ */
int static int
cmd_find_get_pane_with_session(struct cmd_find_state *fs, const char *pane) cmd_find_get_pane_with_session(struct cmd_find_state *fs, const char *pane)
{ {
log_debug("%s: %s", __func__, pane); log_debug("%s: %s", __func__, pane);
@@ -721,7 +713,7 @@ cmd_find_get_pane_with_session(struct cmd_find_state *fs, const char *pane)
* Find pane from string, assuming it is in the given window. Needs w, fills in * Find pane from string, assuming it is in the given window. Needs w, fills in
* wp. * wp.
*/ */
int static int
cmd_find_get_pane_with_window(struct cmd_find_state *fs, const char *pane) cmd_find_get_pane_with_window(struct cmd_find_state *fs, const char *pane)
{ {
const char *errstr; const char *errstr;

View File

@@ -29,11 +29,11 @@
* Executes a tmux command if a shell command returns true or false. * Executes a tmux command if a shell command returns true or false.
*/ */
enum cmd_retval cmd_if_shell_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_if_shell_exec(struct cmd *, struct cmd_q *);
void cmd_if_shell_callback(struct job *); static void cmd_if_shell_callback(struct job *);
void cmd_if_shell_done(struct cmd_q *); static void cmd_if_shell_done(struct cmd_q *);
void cmd_if_shell_free(void *); static void cmd_if_shell_free(void *);
const struct cmd_entry cmd_if_shell_entry = { const struct cmd_entry cmd_if_shell_entry = {
.name = "if-shell", .name = "if-shell",
@@ -63,7 +63,7 @@ struct cmd_if_shell_data {
int references; int references;
}; };
enum cmd_retval static enum cmd_retval
cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq) cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -137,7 +137,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_WAIT); return (CMD_RETURN_WAIT);
} }
void static void
cmd_if_shell_callback(struct job *job) cmd_if_shell_callback(struct job *job)
{ {
struct cmd_if_shell_data *cdata = job->data; struct cmd_if_shell_data *cdata = job->data;
@@ -174,7 +174,7 @@ cmd_if_shell_callback(struct job *job)
cmd_list_free(cmdlist); cmd_list_free(cmdlist);
} }
void static void
cmd_if_shell_done(struct cmd_q *cmdq1) cmd_if_shell_done(struct cmd_q *cmdq1)
{ {
struct cmd_if_shell_data *cdata = cmdq1->data; struct cmd_if_shell_data *cdata = cmdq1->data;
@@ -197,7 +197,7 @@ cmd_if_shell_done(struct cmd_q *cmdq1)
free(cdata); free(cdata);
} }
void static void
cmd_if_shell_free(void *data) cmd_if_shell_free(void *data)
{ {
struct cmd_if_shell_data *cdata = data; struct cmd_if_shell_data *cdata = data;

View File

@@ -28,9 +28,7 @@
* Join or move a pane into another (like split/swap/kill). * Join or move a pane into another (like split/swap/kill).
*/ */
enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmd_q *);
enum cmd_retval join_pane(struct cmd *, struct cmd_q *, int);
const struct cmd_entry cmd_join_pane_entry = { const struct cmd_entry cmd_join_pane_entry = {
.name = "join-pane", .name = "join-pane",
@@ -60,14 +58,8 @@ const struct cmd_entry cmd_move_pane_entry = {
.exec = cmd_join_pane_exec .exec = cmd_join_pane_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_join_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_join_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{
return (join_pane(self, cmdq, self->entry == &cmd_join_pane_entry));
}
enum cmd_retval
join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
{ {
struct args *args = self->args; struct args *args = self->args;
struct session *dst_s; struct session *dst_s;
@@ -78,6 +70,12 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
int size, percentage, dst_idx; int size, percentage, dst_idx;
enum layout_type type; enum layout_type type;
struct layout_cell *lc; struct layout_cell *lc;
int not_same_window;
if (self->entry == &cmd_join_pane_entry)
not_same_window = 1;
else
not_same_window = 0;
dst_s = cmdq->state.tflag.s; dst_s = cmdq->state.tflag.s;
dst_wl = cmdq->state.tflag.wl; dst_wl = cmdq->state.tflag.wl;

View File

@@ -26,7 +26,7 @@
* Kill pane. * Kill pane.
*/ */
enum cmd_retval cmd_kill_pane_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_kill_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_kill_pane_entry = { const struct cmd_entry cmd_kill_pane_entry = {
.name = "kill-pane", .name = "kill-pane",
@@ -41,7 +41,7 @@ const struct cmd_entry cmd_kill_pane_entry = {
.exec = cmd_kill_pane_exec .exec = cmd_kill_pane_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_kill_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_kill_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct winlink *wl = cmdq->state.tflag.wl; struct winlink *wl = cmdq->state.tflag.wl;

View File

@@ -27,7 +27,7 @@
* Kill the server and do nothing else. * Kill the server and do nothing else.
*/ */
enum cmd_retval cmd_kill_server_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_kill_server_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_kill_server_entry = { const struct cmd_entry cmd_kill_server_entry = {
.name = "kill-server", .name = "kill-server",
@@ -51,7 +51,7 @@ const struct cmd_entry cmd_start_server_entry = {
.exec = cmd_kill_server_exec .exec = cmd_kill_server_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_kill_server_exec(struct cmd *self, __unused struct cmd_q *cmdq) cmd_kill_server_exec(struct cmd *self, __unused struct cmd_q *cmdq)
{ {
if (self->entry == &cmd_kill_server_entry) if (self->entry == &cmd_kill_server_entry)

View File

@@ -27,7 +27,7 @@
* Note this deliberately has no alias to make it hard to hit by accident. * Note this deliberately has no alias to make it hard to hit by accident.
*/ */
enum cmd_retval cmd_kill_session_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_kill_session_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_kill_session_entry = { const struct cmd_entry cmd_kill_session_entry = {
.name = "kill-session", .name = "kill-session",
@@ -42,7 +42,7 @@ const struct cmd_entry cmd_kill_session_entry = {
.exec = cmd_kill_session_exec .exec = cmd_kill_session_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_kill_session_exec(struct cmd *self, struct cmd_q *cmdq) cmd_kill_session_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -24,7 +24,7 @@
* Destroy window. * Destroy window.
*/ */
enum cmd_retval cmd_kill_window_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_kill_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_kill_window_entry = { const struct cmd_entry cmd_kill_window_entry = {
.name = "kill-window", .name = "kill-window",
@@ -52,7 +52,7 @@ const struct cmd_entry cmd_unlink_window_entry = {
.exec = cmd_kill_window_exec .exec = cmd_kill_window_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_kill_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_kill_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -30,7 +30,7 @@
#define LIST_BUFFERS_TEMPLATE \ #define LIST_BUFFERS_TEMPLATE \
"#{buffer_name}: #{buffer_size} bytes: \"#{buffer_sample}\"" "#{buffer_name}: #{buffer_size} bytes: \"#{buffer_sample}\""
enum cmd_retval cmd_list_buffers_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_list_buffers_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_list_buffers_entry = { const struct cmd_entry cmd_list_buffers_entry = {
.name = "list-buffers", .name = "list-buffers",
@@ -43,7 +43,7 @@ const struct cmd_entry cmd_list_buffers_entry = {
.exec = cmd_list_buffers_exec .exec = cmd_list_buffers_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_list_buffers_exec(struct cmd *self, struct cmd_q *cmdq) cmd_list_buffers_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -33,7 +33,7 @@
"[#{client_width}x#{client_height} #{client_termname}]" \ "[#{client_width}x#{client_height} #{client_termname}]" \
"#{?client_utf8, (utf8),} #{?client_readonly, (ro),}" "#{?client_utf8, (utf8),} #{?client_readonly, (ro),}"
enum cmd_retval cmd_list_clients_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_list_clients_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_list_clients_entry = { const struct cmd_entry cmd_list_clients_entry = {
.name = "list-clients", .name = "list-clients",
@@ -48,7 +48,7 @@ const struct cmd_entry cmd_list_clients_entry = {
.exec = cmd_list_clients_exec .exec = cmd_list_clients_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_list_clients_exec(struct cmd *self, struct cmd_q *cmdq) cmd_list_clients_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -138,8 +138,7 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
const char *tablename, *key, *cmdstr, *mode; const char *tablename, *key, *cmdstr, *mode;
const struct mode_key_table *mtab; const struct mode_key_table *mtab;
struct mode_key_binding *mbind; struct mode_key_binding *mbind;
char repeat[16]; int width, keywidth, any_mode;
int width, keywidth, repeatwidth, any_mode;
tablename = args_get(args, 't'); tablename = args_get(args, 't');
if ((mtab = mode_key_findtable(tablename)) == NULL) { if ((mtab = mode_key_findtable(tablename)) == NULL) {
@@ -147,7 +146,7 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
keywidth = repeatwidth = 0; keywidth = 0;
any_mode = 0; any_mode = 0;
RB_FOREACH(mbind, mode_key_tree, mtab->tree) { RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
key = key_string_lookup_key(mbind->key); key = key_string_lookup_key(mbind->key);
@@ -158,13 +157,6 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
width = strlen(key); width = strlen(key);
if (width > keywidth) if (width > keywidth)
keywidth = width; keywidth = width;
if (mbind->repeat != 1) {
snprintf(repeat, sizeof repeat, "%u", mbind->repeat);
width = strlen(repeat);
if (width > repeatwidth)
repeatwidth = width;
}
} }
RB_FOREACH(mbind, mode_key_tree, mtab->tree) { RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
@@ -173,20 +165,12 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
mode = ""; mode = "";
if (mbind->mode != 0) if (mbind->mode != 0)
mode = "c"; mode = "c";
snprintf(repeat, sizeof repeat, "%u", mbind->repeat);
cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd); cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd);
if (cmdstr != NULL) { if (cmdstr != NULL) {
cmdq_print(cmdq, cmdq_print(cmdq, "bind-key -%st %s%s %*s %s",
"bind-key -%st %s%s%s%*s %*s %s%s%s%s",
mode, any_mode && *mode == '\0' ? " " : "", mode, any_mode && *mode == '\0' ? " " : "",
mtab->name, mtab->name,
mbind->repeat != 1 ? " -R " : (int)keywidth, key, cmdstr);
(repeatwidth == 0 ? "" : " "),
repeatwidth, mbind->repeat != 1 ? repeat : "",
(int)keywidth, key, cmdstr,
mbind->arg != NULL ? " \"" : "",
mbind->arg != NULL ? mbind->arg : "",
mbind->arg != NULL ? "\"": "");
} }
} }

View File

@@ -26,13 +26,13 @@
* List panes on given window. * List panes on given window.
*/ */
enum cmd_retval cmd_list_panes_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_list_panes_exec(struct cmd *, struct cmd_q *);
void cmd_list_panes_server(struct cmd *, struct cmd_q *); static void cmd_list_panes_server(struct cmd *, struct cmd_q *);
void cmd_list_panes_session(struct cmd *, struct session *, struct cmd_q *, static void cmd_list_panes_session(struct cmd *, struct session *,
int); struct cmd_q *, int);
void cmd_list_panes_window(struct cmd *, struct session *, struct winlink *, static void cmd_list_panes_window(struct cmd *, struct session *,
struct cmd_q *, int); struct winlink *, struct cmd_q *, int);
const struct cmd_entry cmd_list_panes_entry = { const struct cmd_entry cmd_list_panes_entry = {
.name = "list-panes", .name = "list-panes",
@@ -47,7 +47,7 @@ const struct cmd_entry cmd_list_panes_entry = {
.exec = cmd_list_panes_exec .exec = cmd_list_panes_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_list_panes_exec(struct cmd *self, struct cmd_q *cmdq) cmd_list_panes_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -64,7 +64,7 @@ cmd_list_panes_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
void static void
cmd_list_panes_server(struct cmd *self, struct cmd_q *cmdq) cmd_list_panes_server(struct cmd *self, struct cmd_q *cmdq)
{ {
struct session *s; struct session *s;
@@ -73,7 +73,7 @@ cmd_list_panes_server(struct cmd *self, struct cmd_q *cmdq)
cmd_list_panes_session(self, s, cmdq, 2); cmd_list_panes_session(self, s, cmdq, 2);
} }
void static void
cmd_list_panes_session(struct cmd *self, struct session *s, struct cmd_q *cmdq, cmd_list_panes_session(struct cmd *self, struct session *s, struct cmd_q *cmdq,
int type) int type)
{ {
@@ -83,7 +83,7 @@ cmd_list_panes_session(struct cmd *self, struct session *s, struct cmd_q *cmdq,
cmd_list_panes_window(self, s, wl, cmdq, type); cmd_list_panes_window(self, s, wl, cmdq, type);
} }
void static void
cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl, cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
struct cmd_q *cmdq, int type) struct cmd_q *cmdq, int type)
{ {

View File

@@ -36,7 +36,7 @@
"#{session_group}#{?session_grouped,),}" \ "#{session_group}#{?session_grouped,),}" \
"#{?session_attached, (attached),}" "#{?session_attached, (attached),}"
enum cmd_retval cmd_list_sessions_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_list_sessions_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_list_sessions_entry = { const struct cmd_entry cmd_list_sessions_entry = {
.name = "list-sessions", .name = "list-sessions",
@@ -49,7 +49,7 @@ const struct cmd_entry cmd_list_sessions_entry = {
.exec = cmd_list_sessions_exec .exec = cmd_list_sessions_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_list_sessions_exec(struct cmd *self, struct cmd_q *cmdq) cmd_list_sessions_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -39,11 +39,11 @@
"(#{window_panes} panes) " \ "(#{window_panes} panes) " \
"[#{window_width}x#{window_height}] " "[#{window_width}x#{window_height}] "
enum cmd_retval cmd_list_windows_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_list_windows_exec(struct cmd *, struct cmd_q *);
void cmd_list_windows_server(struct cmd *, struct cmd_q *); static void cmd_list_windows_server(struct cmd *, struct cmd_q *);
void cmd_list_windows_session(struct cmd *, struct session *, static void cmd_list_windows_session(struct cmd *, struct session *,
struct cmd_q *, int); struct cmd_q *, int);
const struct cmd_entry cmd_list_windows_entry = { const struct cmd_entry cmd_list_windows_entry = {
.name = "list-windows", .name = "list-windows",
@@ -58,7 +58,7 @@ const struct cmd_entry cmd_list_windows_entry = {
.exec = cmd_list_windows_exec .exec = cmd_list_windows_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_list_windows_exec(struct cmd *self, struct cmd_q *cmdq) cmd_list_windows_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -71,7 +71,7 @@ cmd_list_windows_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
void static void
cmd_list_windows_server(struct cmd *self, struct cmd_q *cmdq) cmd_list_windows_server(struct cmd *self, struct cmd_q *cmdq)
{ {
struct session *s; struct session *s;
@@ -80,7 +80,7 @@ cmd_list_windows_server(struct cmd *self, struct cmd_q *cmdq)
cmd_list_windows_session(self, s, cmdq, 1); cmd_list_windows_session(self, s, cmdq, 1);
} }
void static void
cmd_list_windows_session(struct cmd *self, struct session *s, cmd_list_windows_session(struct cmd *self, struct session *s,
struct cmd_q *cmdq, int type) struct cmd_q *cmdq, int type)
{ {

View File

@@ -31,8 +31,9 @@
* Loads a paste buffer from a file. * Loads a paste buffer from a file.
*/ */
enum cmd_retval cmd_load_buffer_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_load_buffer_exec(struct cmd *, struct cmd_q *);
void cmd_load_buffer_callback(struct client *, int, void *);
static void cmd_load_buffer_callback(struct client *, int, void *);
const struct cmd_entry cmd_load_buffer_entry = { const struct cmd_entry cmd_load_buffer_entry = {
.name = "load-buffer", .name = "load-buffer",
@@ -45,7 +46,7 @@ const struct cmd_entry cmd_load_buffer_entry = {
.exec = cmd_load_buffer_exec .exec = cmd_load_buffer_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq) cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -132,7 +133,7 @@ error:
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
void static void
cmd_load_buffer_callback(struct client *c, int closed, void *data) cmd_load_buffer_callback(struct client *c, int closed, void *data)
{ {
const char *bufname = data; const char *bufname = data;

View File

@@ -24,7 +24,7 @@
* Lock commands. * Lock commands.
*/ */
enum cmd_retval cmd_lock_server_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_lock_server_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_lock_server_entry = { const struct cmd_entry cmd_lock_server_entry = {
.name = "lock-server", .name = "lock-server",
@@ -63,7 +63,7 @@ const struct cmd_entry cmd_lock_client_entry = {
.exec = cmd_lock_server_exec .exec = cmd_lock_server_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_lock_server_exec(struct cmd *self, __unused struct cmd_q *cmdq) cmd_lock_server_exec(struct cmd *self, __unused struct cmd_q *cmdq)
{ {
if (self->entry == &cmd_lock_server_entry) if (self->entry == &cmd_lock_server_entry)

View File

@@ -26,7 +26,7 @@
* Move a window. * Move a window.
*/ */
enum cmd_retval cmd_move_window_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_move_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_move_window_entry = { const struct cmd_entry cmd_move_window_entry = {
.name = "move-window", .name = "move-window",
@@ -56,7 +56,7 @@ const struct cmd_entry cmd_link_window_entry = {
.exec = cmd_move_window_exec .exec = cmd_move_window_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -33,7 +33,7 @@
#define NEW_SESSION_TEMPLATE "#{session_name}:" #define NEW_SESSION_TEMPLATE "#{session_name}:"
enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_new_session_entry = { const struct cmd_entry cmd_new_session_entry = {
.name = "new-session", .name = "new-session",
@@ -63,7 +63,7 @@ const struct cmd_entry cmd_has_session_entry = {
.exec = cmd_new_session_exec .exec = cmd_new_session_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -32,7 +32,7 @@
#define NEW_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}" #define NEW_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
enum cmd_retval cmd_new_window_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_new_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_new_window_entry = { const struct cmd_entry cmd_new_window_entry = {
.name = "new-window", .name = "new-window",
@@ -48,7 +48,7 @@ const struct cmd_entry cmd_new_window_entry = {
.exec = cmd_new_window_exec .exec = cmd_new_window_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -27,10 +27,7 @@
* Paste paste buffer if present. * Paste paste buffer if present.
*/ */
enum cmd_retval cmd_paste_buffer_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_paste_buffer_exec(struct cmd *, struct cmd_q *);
void cmd_paste_buffer_filter(struct window_pane *,
const char *, size_t, const char *, int);
const struct cmd_entry cmd_paste_buffer_entry = { const struct cmd_entry cmd_paste_buffer_entry = {
.name = "paste-buffer", .name = "paste-buffer",
@@ -46,7 +43,7 @@ const struct cmd_entry cmd_paste_buffer_entry = {
.exec = cmd_paste_buffer_exec .exec = cmd_paste_buffer_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq) cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -32,9 +32,9 @@
* Open pipe to redirect pane output. If already open, close first. * Open pipe to redirect pane output. If already open, close first.
*/ */
enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmd_q *);
void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *); static void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
const struct cmd_entry cmd_pipe_pane_entry = { const struct cmd_entry cmd_pipe_pane_entry = {
.name = "pipe-pane", .name = "pipe-pane",
@@ -49,7 +49,7 @@ const struct cmd_entry cmd_pipe_pane_entry = {
.exec = cmd_pipe_pane_exec .exec = cmd_pipe_pane_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -141,7 +141,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
} }
} }
void static void
cmd_pipe_pane_error_callback(__unused struct bufferevent *bufev, cmd_pipe_pane_error_callback(__unused struct bufferevent *bufev,
__unused short what, void *data) __unused short what, void *data)
{ {

View File

@@ -26,6 +26,7 @@
#include "tmux.h" #include "tmux.h"
static enum cmd_retval cmdq_continue_one(struct cmd_q *); static enum cmd_retval cmdq_continue_one(struct cmd_q *);
static void cmdq_flush(struct cmd_q *);
/* Create new command queue. */ /* Create new command queue. */
struct cmd_q * struct cmd_q *
@@ -319,7 +320,7 @@ out:
} }
/* Flush command queue. */ /* Flush command queue. */
void static void
cmdq_flush(struct cmd_q *cmdq) cmdq_flush(struct cmd_q *cmdq)
{ {
struct cmd_q_item *item, *item1; struct cmd_q_item *item, *item1;

View File

@@ -24,7 +24,7 @@
* Refresh client. * Refresh client.
*/ */
enum cmd_retval cmd_refresh_client_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_refresh_client_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_refresh_client_entry = { const struct cmd_entry cmd_refresh_client_entry = {
.name = "refresh-client", .name = "refresh-client",
@@ -39,7 +39,7 @@ const struct cmd_entry cmd_refresh_client_entry = {
.exec = cmd_refresh_client_exec .exec = cmd_refresh_client_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_refresh_client_exec(struct cmd *self, struct cmd_q *cmdq) cmd_refresh_client_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -26,7 +26,7 @@
* Change session name. * Change session name.
*/ */
enum cmd_retval cmd_rename_session_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_rename_session_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_rename_session_entry = { const struct cmd_entry cmd_rename_session_entry = {
.name = "rename-session", .name = "rename-session",
@@ -41,7 +41,7 @@ const struct cmd_entry cmd_rename_session_entry = {
.exec = cmd_rename_session_exec .exec = cmd_rename_session_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_rename_session_exec(struct cmd *self, struct cmd_q *cmdq) cmd_rename_session_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -26,7 +26,7 @@
* Rename a window. * Rename a window.
*/ */
enum cmd_retval cmd_rename_window_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_rename_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_rename_window_entry = { const struct cmd_entry cmd_rename_window_entry = {
.name = "rename-window", .name = "rename-window",
@@ -41,7 +41,7 @@ const struct cmd_entry cmd_rename_window_entry = {
.exec = cmd_rename_window_exec .exec = cmd_rename_window_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_rename_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_rename_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -26,9 +26,10 @@
* Increase or decrease pane size. * Increase or decrease pane size.
*/ */
enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_q *);
void cmd_resize_pane_mouse_update(struct client *, struct mouse_event *); static void cmd_resize_pane_mouse_update(struct client *,
struct mouse_event *);
const struct cmd_entry cmd_resize_pane_entry = { const struct cmd_entry cmd_resize_pane_entry = {
.name = "resize-pane", .name = "resize-pane",
@@ -44,7 +45,7 @@ const struct cmd_entry cmd_resize_pane_entry = {
.exec = cmd_resize_pane_exec .exec = cmd_resize_pane_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -123,7 +124,7 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
void static void
cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m) cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m)
{ {
struct winlink *wl; struct winlink *wl;
@@ -154,12 +155,14 @@ cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m)
continue; continue;
if (wp->xoff + wp->sx == m->lx && if (wp->xoff + wp->sx == m->lx &&
wp->yoff <= 1 + ly && wp->yoff + wp->sy >= ly) { wp->yoff <= 1 + ly &&
wp->yoff + wp->sy >= ly) {
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, m->x - m->lx, 0); layout_resize_pane(wp, LAYOUT_LEFTRIGHT, m->x - m->lx, 0);
found = 1; found = 1;
} }
if (wp->yoff + wp->sy == ly && if (wp->yoff + wp->sy == ly &&
wp->xoff <= 1 + m->lx && wp->xoff + wp->sx >= m->lx) { wp->xoff <= 1 + m->lx &&
wp->xoff + wp->sx >= m->lx) {
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, y - ly, 0); layout_resize_pane(wp, LAYOUT_TOPBOTTOM, y - ly, 0);
found = 1; found = 1;
} }

View File

@@ -28,7 +28,7 @@
* Respawn a pane (restart the command). Kill existing if -k given. * Respawn a pane (restart the command). Kill existing if -k given.
*/ */
enum cmd_retval cmd_respawn_pane_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_respawn_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_respawn_pane_entry = { const struct cmd_entry cmd_respawn_pane_entry = {
.name = "respawn-pane", .name = "respawn-pane",
@@ -43,7 +43,7 @@ const struct cmd_entry cmd_respawn_pane_entry = {
.exec = cmd_respawn_pane_exec .exec = cmd_respawn_pane_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -27,7 +27,7 @@
* Respawn a window (restart the command). Kill existing if -k given. * Respawn a window (restart the command). Kill existing if -k given.
*/ */
enum cmd_retval cmd_respawn_window_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_respawn_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_respawn_window_entry = { const struct cmd_entry cmd_respawn_window_entry = {
.name = "respawn-window", .name = "respawn-window",
@@ -42,7 +42,7 @@ const struct cmd_entry cmd_respawn_window_entry = {
.exec = cmd_respawn_window_exec .exec = cmd_respawn_window_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_respawn_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_respawn_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -24,7 +24,7 @@
* Rotate the panes in a window. * Rotate the panes in a window.
*/ */
enum cmd_retval cmd_rotate_window_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_rotate_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_rotate_window_entry = { const struct cmd_entry cmd_rotate_window_entry = {
.name = "rotate-window", .name = "rotate-window",
@@ -39,7 +39,7 @@ const struct cmd_entry cmd_rotate_window_entry = {
.exec = cmd_rotate_window_exec .exec = cmd_rotate_window_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_rotate_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_rotate_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct winlink *wl = cmdq->state.tflag.wl; struct winlink *wl = cmdq->state.tflag.wl;

View File

@@ -29,11 +29,11 @@
* Runs a command without a window. * Runs a command without a window.
*/ */
enum cmd_retval cmd_run_shell_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_run_shell_exec(struct cmd *, struct cmd_q *);
void cmd_run_shell_callback(struct job *); static void cmd_run_shell_callback(struct job *);
void cmd_run_shell_free(void *); static void cmd_run_shell_free(void *);
void cmd_run_shell_print(struct job *, const char *); static void cmd_run_shell_print(struct job *, const char *);
const struct cmd_entry cmd_run_shell_entry = { const struct cmd_entry cmd_run_shell_entry = {
.name = "run-shell", .name = "run-shell",
@@ -55,7 +55,7 @@ struct cmd_run_shell_data {
int wp_id; int wp_id;
}; };
void static void
cmd_run_shell_print(struct job *job, const char *msg) cmd_run_shell_print(struct job *job, const char *msg)
{ {
struct cmd_run_shell_data *cdata = job->data; struct cmd_run_shell_data *cdata = job->data;
@@ -74,7 +74,7 @@ cmd_run_shell_print(struct job *job, const char *msg)
window_copy_add(wp, "%s", msg); window_copy_add(wp, "%s", msg);
} }
enum cmd_retval static enum cmd_retval
cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq) cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -113,7 +113,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_WAIT); return (CMD_RETURN_WAIT);
} }
void static void
cmd_run_shell_callback(struct job *job) cmd_run_shell_callback(struct job *job)
{ {
struct cmd_run_shell_data *cdata = job->data; struct cmd_run_shell_data *cdata = job->data;
@@ -161,7 +161,7 @@ cmd_run_shell_callback(struct job *job)
free(msg); free(msg);
} }
void static void
cmd_run_shell_free(void *data) cmd_run_shell_free(void *data)
{ {
struct cmd_run_shell_data *cdata = data; struct cmd_run_shell_data *cdata = data;

View File

@@ -31,7 +31,7 @@
* Saves a paste buffer to a file. * Saves a paste buffer to a file.
*/ */
enum cmd_retval cmd_save_buffer_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_save_buffer_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_save_buffer_entry = { const struct cmd_entry cmd_save_buffer_entry = {
.name = "save-buffer", .name = "save-buffer",
@@ -55,7 +55,7 @@ const struct cmd_entry cmd_show_buffer_entry = {
.exec = cmd_save_buffer_exec .exec = cmd_save_buffer_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq) cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -26,7 +26,7 @@
* Switch window to selected layout. * Switch window to selected layout.
*/ */
enum cmd_retval cmd_select_layout_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_select_layout_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_select_layout_entry = { const struct cmd_entry cmd_select_layout_entry = {
.name = "select-layout", .name = "select-layout",
@@ -67,7 +67,7 @@ const struct cmd_entry cmd_previous_layout_entry = {
.exec = cmd_select_layout_exec .exec = cmd_select_layout_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq) cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -24,7 +24,7 @@
* Select pane. * Select pane.
*/ */
enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_select_pane_entry = { const struct cmd_entry cmd_select_pane_entry = {
.name = "select-pane", .name = "select-pane",
@@ -52,7 +52,7 @@ const struct cmd_entry cmd_last_pane_entry = {
.exec = cmd_select_pane_exec .exec = cmd_select_pane_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -26,7 +26,7 @@
* Select window by index. * Select window by index.
*/ */
enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_select_window_entry = { const struct cmd_entry cmd_select_window_entry = {
.name = "select-window", .name = "select-window",
@@ -80,7 +80,7 @@ const struct cmd_entry cmd_last_window_entry = {
.exec = cmd_select_window_exec .exec = cmd_select_window_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_select_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_select_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct winlink *wl = cmdq->state.tflag.wl; struct winlink *wl = cmdq->state.tflag.wl;

View File

@@ -27,14 +27,14 @@
* Send keys to client. * Send keys to client.
*/ */
enum cmd_retval cmd_send_keys_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_send_keys_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_send_keys_entry = { const struct cmd_entry cmd_send_keys_entry = {
.name = "send-keys", .name = "send-keys",
.alias = "send", .alias = "send",
.args = { "lRMt:", 0, -1 }, .args = { "lXRMN:t:", 0, -1 },
.usage = "[-lRM] " CMD_TARGET_PANE_USAGE " key ...", .usage = "[-lXRM] [-N repeat-count] " CMD_TARGET_PANE_USAGE " key ...",
.tflag = CMD_PANE, .tflag = CMD_PANE,
@@ -55,16 +55,48 @@ const struct cmd_entry cmd_send_prefix_entry = {
.exec = cmd_send_keys_exec .exec = cmd_send_keys_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_send_keys_exec(struct cmd *self, struct cmd_q *cmdq) cmd_send_keys_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
struct client *c = cmdq->state.c;
struct window_pane *wp = cmdq->state.tflag.wp; struct window_pane *wp = cmdq->state.tflag.wp;
struct session *s = cmdq->state.tflag.s; struct session *s = cmdq->state.tflag.s;
struct mouse_event *m = &cmdq->item->mouse; struct mouse_event *m = &cmdq->item->mouse;
const u_char *keystr; const u_char *keystr;
int i, literal; int i, literal;
key_code key; key_code key;
u_int np;
char *cause = NULL;
if (args_has(args, 'N')) {
if (wp->mode == NULL || wp->mode->command == NULL) {
cmdq_error(cmdq, "not in a mode");
return (CMD_RETURN_ERROR);
}
np = args_strtonum(args, 'N', 1, UINT_MAX, &cause);
if (cause != NULL) {
cmdq_error(cmdq, "prefix %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
wp->modeprefix = np;
}
if (args_has(args, 'X')) {
if (wp->mode == NULL || wp->mode->command == NULL) {
cmdq_error(cmdq, "not in a mode");
return (CMD_RETURN_ERROR);
}
if (!m->valid)
wp->mode->command(wp, c, s, args, NULL);
else
wp->mode->command(wp, c, s, args, m);
return (CMD_RETURN_NORMAL);
}
if (args_has(args, 'N')) /* only with -X */
return (CMD_RETURN_NORMAL);
if (args_has(args, 'M')) { if (args_has(args, 'M')) {
wp = cmd_mouse_pane(m, &s, NULL); wp = cmd_mouse_pane(m, &s, NULL);

View File

@@ -27,7 +27,7 @@
* Add, set, append to or delete a paste buffer. * Add, set, append to or delete a paste buffer.
*/ */
enum cmd_retval cmd_set_buffer_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_set_buffer_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_set_buffer_entry = { const struct cmd_entry cmd_set_buffer_entry = {
.name = "set-buffer", .name = "set-buffer",
@@ -51,7 +51,7 @@ const struct cmd_entry cmd_delete_buffer_entry = {
.exec = cmd_set_buffer_exec .exec = cmd_set_buffer_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq) cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -27,7 +27,7 @@
* Set an environment variable. * Set an environment variable.
*/ */
enum cmd_retval cmd_set_environment_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_set_environment_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_set_environment_entry = { const struct cmd_entry cmd_set_environment_entry = {
.name = "set-environment", .name = "set-environment",
@@ -42,7 +42,7 @@ const struct cmd_entry cmd_set_environment_entry = {
.exec = cmd_set_environment_exec .exec = cmd_set_environment_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq) cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -27,7 +27,7 @@
* Set or show global or session hooks. * Set or show global or session hooks.
*/ */
enum cmd_retval cmd_set_hook_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_set_hook_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_set_hook_entry = { const struct cmd_entry cmd_set_hook_entry = {
.name = "set-hook", .name = "set-hook",
@@ -55,7 +55,7 @@ const struct cmd_entry cmd_show_hooks_entry = {
.exec = cmd_set_hook_exec .exec = cmd_set_hook_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_set_hook_exec(struct cmd *self, struct cmd_q *cmdq) cmd_set_hook_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -27,40 +27,40 @@
* Set an option. * Set an option.
*/ */
enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmd_q *);
enum cmd_retval cmd_set_option_user(struct cmd *, struct cmd_q *, static enum cmd_retval cmd_set_option_user(struct cmd *, struct cmd_q *,
const char *, const char *); const char *, const char *);
int cmd_set_option_unset(struct cmd *, struct cmd_q *, static int cmd_set_option_unset(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *, const struct options_table_entry *, struct options *,
const char *); const char *);
int cmd_set_option_set(struct cmd *, struct cmd_q *, static int cmd_set_option_set(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *, const struct options_table_entry *, struct options *,
const char *); const char *);
struct options_entry *cmd_set_option_string(struct cmd *, struct cmd_q *, static struct options_entry *cmd_set_option_string(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *, const struct options_table_entry *, struct options *,
const char *); const char *);
struct options_entry *cmd_set_option_number(struct cmd *, struct cmd_q *, static struct options_entry *cmd_set_option_number(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *, const struct options_table_entry *, struct options *,
const char *); const char *);
struct options_entry *cmd_set_option_key(struct cmd *, struct cmd_q *, static struct options_entry *cmd_set_option_key(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *, const struct options_table_entry *, struct options *,
const char *); const char *);
struct options_entry *cmd_set_option_colour(struct cmd *, struct cmd_q *, static struct options_entry *cmd_set_option_colour(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *, const struct options_table_entry *, struct options *,
const char *); const char *);
struct options_entry *cmd_set_option_attributes(struct cmd *, struct cmd_q *, static struct options_entry *cmd_set_option_attributes(struct cmd *,
struct cmd_q *, const struct options_table_entry *,
struct options *, const char *);
static struct options_entry *cmd_set_option_flag(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *, const struct options_table_entry *, struct options *,
const char *); const char *);
struct options_entry *cmd_set_option_flag(struct cmd *, struct cmd_q *, static struct options_entry *cmd_set_option_choice(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *, const struct options_table_entry *, struct options *,
const char *); const char *);
struct options_entry *cmd_set_option_choice(struct cmd *, struct cmd_q *, static struct options_entry *cmd_set_option_style(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *,
const char *);
struct options_entry *cmd_set_option_style(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *, const struct options_table_entry *, struct options *,
const char *); const char *);
@@ -90,7 +90,7 @@ const struct cmd_entry cmd_set_window_option_entry = {
.exec = cmd_set_option_exec .exec = cmd_set_option_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq) cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -223,7 +223,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
} }
/* Set user option. */ /* Set user option. */
enum cmd_retval static enum cmd_retval
cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr, cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr,
const char *valstr) const char *valstr)
{ {
@@ -301,7 +301,7 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr,
} }
/* Unset an option. */ /* Unset an option. */
int static int
cmd_set_option_unset(struct cmd *self, struct cmd_q *cmdq, cmd_set_option_unset(struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo, const struct options_table_entry *oe, struct options *oo,
const char *value) const char *value)
@@ -331,7 +331,7 @@ cmd_set_option_unset(struct cmd *self, struct cmd_q *cmdq,
} }
/* Set an option. */ /* Set an option. */
int static int
cmd_set_option_set(struct cmd *self, struct cmd_q *cmdq, cmd_set_option_set(struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo, const struct options_table_entry *oe, struct options *oo,
const char *value) const char *value)
@@ -386,7 +386,7 @@ cmd_set_option_set(struct cmd *self, struct cmd_q *cmdq,
} }
/* Set a string option. */ /* Set a string option. */
struct options_entry * static struct options_entry *
cmd_set_option_string(struct cmd *self, __unused struct cmd_q *cmdq, cmd_set_option_string(struct cmd *self, __unused struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo, const struct options_table_entry *oe, struct options *oo,
const char *value) const char *value)
@@ -408,7 +408,7 @@ cmd_set_option_string(struct cmd *self, __unused struct cmd_q *cmdq,
} }
/* Set a number option. */ /* Set a number option. */
struct options_entry * static struct options_entry *
cmd_set_option_number(__unused struct cmd *self, struct cmd_q *cmdq, cmd_set_option_number(__unused struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo, const struct options_table_entry *oe, struct options *oo,
const char *value) const char *value)
@@ -426,7 +426,7 @@ cmd_set_option_number(__unused struct cmd *self, struct cmd_q *cmdq,
} }
/* Set a key option. */ /* Set a key option. */
struct options_entry * static struct options_entry *
cmd_set_option_key(__unused struct cmd *self, struct cmd_q *cmdq, cmd_set_option_key(__unused struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo, const struct options_table_entry *oe, struct options *oo,
const char *value) const char *value)
@@ -443,7 +443,7 @@ cmd_set_option_key(__unused struct cmd *self, struct cmd_q *cmdq,
} }
/* Set a colour option. */ /* Set a colour option. */
struct options_entry * static struct options_entry *
cmd_set_option_colour(__unused struct cmd *self, struct cmd_q *cmdq, cmd_set_option_colour(__unused struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo, const struct options_table_entry *oe, struct options *oo,
const char *value) const char *value)
@@ -459,7 +459,7 @@ cmd_set_option_colour(__unused struct cmd *self, struct cmd_q *cmdq,
} }
/* Set an attributes option. */ /* Set an attributes option. */
struct options_entry * static struct options_entry *
cmd_set_option_attributes(__unused struct cmd *self, struct cmd_q *cmdq, cmd_set_option_attributes(__unused struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo, const struct options_table_entry *oe, struct options *oo,
const char *value) const char *value)
@@ -475,7 +475,7 @@ cmd_set_option_attributes(__unused struct cmd *self, struct cmd_q *cmdq,
} }
/* Set a flag option. */ /* Set a flag option. */
struct options_entry * static struct options_entry *
cmd_set_option_flag(__unused struct cmd *self, struct cmd_q *cmdq, cmd_set_option_flag(__unused struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo, const struct options_table_entry *oe, struct options *oo,
const char *value) const char *value)
@@ -503,7 +503,7 @@ cmd_set_option_flag(__unused struct cmd *self, struct cmd_q *cmdq,
} }
/* Set a choice option. */ /* Set a choice option. */
struct options_entry * static struct options_entry *
cmd_set_option_choice(__unused struct cmd *self, struct cmd_q *cmdq, cmd_set_option_choice(__unused struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo, const struct options_table_entry *oe, struct options *oo,
const char *value) const char *value)
@@ -538,7 +538,7 @@ cmd_set_option_choice(__unused struct cmd *self, struct cmd_q *cmdq,
} }
/* Set a style option. */ /* Set a style option. */
struct options_entry * static struct options_entry *
cmd_set_option_style(struct cmd *self, struct cmd_q *cmdq, cmd_set_option_style(struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo, const struct options_table_entry *oe, struct options *oo,
const char *value) const char *value)

View File

@@ -27,11 +27,11 @@
* Show environment. * Show environment.
*/ */
enum cmd_retval cmd_show_environment_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_show_environment_exec(struct cmd *, struct cmd_q *);
char *cmd_show_environment_escape(struct environ_entry *); static char *cmd_show_environment_escape(struct environ_entry *);
void cmd_show_environment_print(struct cmd *, struct cmd_q *, static void cmd_show_environment_print(struct cmd *, struct cmd_q *,
struct environ_entry *); struct environ_entry *);
const struct cmd_entry cmd_show_environment_entry = { const struct cmd_entry cmd_show_environment_entry = {
.name = "show-environment", .name = "show-environment",
@@ -46,7 +46,7 @@ const struct cmd_entry cmd_show_environment_entry = {
.exec = cmd_show_environment_exec .exec = cmd_show_environment_exec
}; };
char * static char *
cmd_show_environment_escape(struct environ_entry *envent) cmd_show_environment_escape(struct environ_entry *envent)
{ {
const char *value = envent->value; const char *value = envent->value;
@@ -64,7 +64,7 @@ cmd_show_environment_escape(struct environ_entry *envent)
return (ret); return (ret);
} }
void static void
cmd_show_environment_print(struct cmd *self, struct cmd_q *cmdq, cmd_show_environment_print(struct cmd *self, struct cmd_q *cmdq,
struct environ_entry *envent) struct environ_entry *envent)
{ {
@@ -87,7 +87,7 @@ cmd_show_environment_print(struct cmd *self, struct cmd_q *cmdq,
cmdq_print(cmdq, "unset %s;", envent->name); cmdq_print(cmdq, "unset %s;", envent->name);
} }
enum cmd_retval static enum cmd_retval
cmd_show_environment_exec(struct cmd *self, struct cmd_q *cmdq) cmd_show_environment_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -28,7 +28,7 @@
* Show client message log. * Show client message log.
*/ */
enum cmd_retval cmd_show_messages_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_show_messages_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_show_messages_entry = { const struct cmd_entry cmd_show_messages_entry = {
.name = "show-messages", .name = "show-messages",
@@ -54,10 +54,10 @@ const struct cmd_entry cmd_server_info_entry = {
.exec = cmd_show_messages_exec .exec = cmd_show_messages_exec
}; };
int cmd_show_messages_terminals(struct cmd_q *, int); static int cmd_show_messages_terminals(struct cmd_q *, int);
int cmd_show_messages_jobs(struct cmd_q *, int); static int cmd_show_messages_jobs(struct cmd_q *, int);
int static int
cmd_show_messages_terminals(struct cmd_q *cmdq, int blank) cmd_show_messages_terminals(struct cmd_q *cmdq, int blank)
{ {
struct tty_term *term; struct tty_term *term;
@@ -78,7 +78,7 @@ cmd_show_messages_terminals(struct cmd_q *cmdq, int blank)
return (n != 0); return (n != 0);
} }
int static int
cmd_show_messages_jobs(struct cmd_q *cmdq, int blank) cmd_show_messages_jobs(struct cmd_q *cmdq, int blank)
{ {
struct job *job; struct job *job;
@@ -97,7 +97,7 @@ cmd_show_messages_jobs(struct cmd_q *cmdq, int blank)
return (n != 0); return (n != 0);
} }
enum cmd_retval static enum cmd_retval
cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq) cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -27,12 +27,12 @@
* Show options. * Show options.
*/ */
enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmd_q *);
enum cmd_retval cmd_show_options_one(struct cmd *, struct cmd_q *, static enum cmd_retval cmd_show_options_one(struct cmd *, struct cmd_q *,
struct options *, int); struct options *, int);
enum cmd_retval cmd_show_options_all(struct cmd *, struct cmd_q *, static enum cmd_retval cmd_show_options_all(struct cmd *, struct cmd_q *,
struct options *, enum options_table_scope); struct options *, enum options_table_scope);
const struct cmd_entry cmd_show_options_entry = { const struct cmd_entry cmd_show_options_entry = {
.name = "show-options", .name = "show-options",
@@ -60,7 +60,7 @@ const struct cmd_entry cmd_show_window_options_entry = {
.exec = cmd_show_options_exec .exec = cmd_show_options_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq) cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -110,7 +110,7 @@ cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
return (cmd_show_options_one(self, cmdq, oo, quiet)); return (cmd_show_options_one(self, cmdq, oo, quiet));
} }
enum cmd_retval static enum cmd_retval
cmd_show_options_one(struct cmd *self, struct cmd_q *cmdq, cmd_show_options_one(struct cmd *self, struct cmd_q *cmdq,
struct options *oo, int quiet) struct options *oo, int quiet)
{ {
@@ -160,7 +160,7 @@ retry:
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
enum cmd_retval static enum cmd_retval
cmd_show_options_all(struct cmd *self, struct cmd_q *cmdq, struct options *oo, cmd_show_options_all(struct cmd *self, struct cmd_q *cmdq, struct options *oo,
enum options_table_scope scope) enum options_table_scope scope)
{ {

View File

@@ -26,9 +26,9 @@
* Sources a configuration file. * Sources a configuration file.
*/ */
enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmd_q *);
void cmd_source_file_done(struct cmd_q *); static void cmd_source_file_done(struct cmd_q *);
const struct cmd_entry cmd_source_file_entry = { const struct cmd_entry cmd_source_file_entry = {
.name = "source-file", .name = "source-file",
@@ -41,7 +41,7 @@ const struct cmd_entry cmd_source_file_entry = {
.exec = cmd_source_file_exec .exec = cmd_source_file_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_source_file_exec(struct cmd *self, struct cmd_q *cmdq) cmd_source_file_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -76,7 +76,7 @@ cmd_source_file_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_WAIT); return (CMD_RETURN_WAIT);
} }
void static void
cmd_source_file_done(struct cmd_q *cmdq1) cmd_source_file_done(struct cmd_q *cmdq1)
{ {
struct cmd_q *cmdq = cmdq1->data; struct cmd_q *cmdq = cmdq1->data;

View File

@@ -32,7 +32,7 @@
#define SPLIT_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}" #define SPLIT_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_split_window_entry = { const struct cmd_entry cmd_split_window_entry = {
.name = "split-window", .name = "split-window",
@@ -48,7 +48,7 @@ const struct cmd_entry cmd_split_window_entry = {
.exec = cmd_split_window_exec .exec = cmd_split_window_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -31,14 +31,14 @@
* Parse a command from a string. * Parse a command from a string.
*/ */
int cmd_string_getc(const char *, size_t *); static int cmd_string_getc(const char *, size_t *);
void cmd_string_ungetc(size_t *); static void cmd_string_ungetc(size_t *);
void cmd_string_copy(char **, char *, size_t *); static void cmd_string_copy(char **, char *, size_t *);
char *cmd_string_string(const char *, size_t *, char, int); static char *cmd_string_string(const char *, size_t *, char, int);
char *cmd_string_variable(const char *, size_t *); static char *cmd_string_variable(const char *, size_t *);
char *cmd_string_expand_tilde(const char *, size_t *); static char *cmd_string_expand_tilde(const char *, size_t *);
int static int
cmd_string_getc(const char *s, size_t *p) cmd_string_getc(const char *s, size_t *p)
{ {
const u_char *ucs = s; const u_char *ucs = s;
@@ -48,7 +48,7 @@ cmd_string_getc(const char *s, size_t *p)
return (ucs[(*p)++]); return (ucs[(*p)++]);
} }
void static void
cmd_string_ungetc(size_t *p) cmd_string_ungetc(size_t *p)
{ {
(*p)--; (*p)--;
@@ -173,7 +173,7 @@ out:
return (rval); return (rval);
} }
void static void
cmd_string_copy(char **dst, char *src, size_t *len) cmd_string_copy(char **dst, char *src, size_t *len)
{ {
size_t srclen; size_t srclen;
@@ -187,7 +187,7 @@ cmd_string_copy(char **dst, char *src, size_t *len)
free(src); free(src);
} }
char * static char *
cmd_string_string(const char *s, size_t *p, char endch, int esc) cmd_string_string(const char *s, size_t *p, char endch, int esc)
{ {
int ch; int ch;
@@ -245,7 +245,7 @@ error:
return (NULL); return (NULL);
} }
char * static char *
cmd_string_variable(const char *s, size_t *p) cmd_string_variable(const char *s, size_t *p)
{ {
int ch, fch; int ch, fch;
@@ -314,7 +314,7 @@ error:
return (NULL); return (NULL);
} }
char * static char *
cmd_string_expand_tilde(const char *s, size_t *p) cmd_string_expand_tilde(const char *s, size_t *p)
{ {
struct passwd *pw; struct passwd *pw;
@@ -337,7 +337,10 @@ cmd_string_expand_tilde(const char *s, size_t *p)
cp = user = xmalloc(strlen(s)); cp = user = xmalloc(strlen(s));
for (;;) { for (;;) {
last = cmd_string_getc(s, p); last = cmd_string_getc(s, p);
if (last == EOF || last == '/' || last == ' '|| last == '\t') if (last == EOF ||
last == '/' ||
last == ' '||
last == '\t')
break; break;
*cp++ = last; *cp++ = last;
} }

View File

@@ -26,7 +26,7 @@
* Swap two panes. * Swap two panes.
*/ */
enum cmd_retval cmd_swap_pane_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_swap_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_swap_pane_entry = { const struct cmd_entry cmd_swap_pane_entry = {
.name = "swap-pane", .name = "swap-pane",
@@ -42,7 +42,7 @@ const struct cmd_entry cmd_swap_pane_entry = {
.exec = cmd_swap_pane_exec .exec = cmd_swap_pane_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct window *src_w, *dst_w; struct window *src_w, *dst_w;

View File

@@ -26,7 +26,7 @@
* Swap one window with another. * Swap one window with another.
*/ */
enum cmd_retval cmd_swap_window_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_swap_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_swap_window_entry = { const struct cmd_entry cmd_swap_window_entry = {
.name = "swap-window", .name = "swap-window",
@@ -42,7 +42,7 @@ const struct cmd_entry cmd_swap_window_entry = {
.exec = cmd_swap_window_exec .exec = cmd_swap_window_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_swap_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_swap_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct session *src, *dst; struct session *src, *dst;

View File

@@ -27,7 +27,7 @@
* Switch client to a different session. * Switch client to a different session.
*/ */
enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_switch_client_entry = { const struct cmd_entry cmd_switch_client_entry = {
.name = "switch-client", .name = "switch-client",
@@ -44,7 +44,7 @@ const struct cmd_entry cmd_switch_client_entry = {
.exec = cmd_switch_client_exec .exec = cmd_switch_client_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -26,9 +26,9 @@
* Unbind key from command. * Unbind key from command.
*/ */
enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmd_q *);
enum cmd_retval cmd_unbind_key_mode_table(struct cmd *, struct cmd_q *, static enum cmd_retval cmd_unbind_key_mode_table(struct cmd *, struct cmd_q *,
key_code); key_code);
const struct cmd_entry cmd_unbind_key_entry = { const struct cmd_entry cmd_unbind_key_entry = {
.name = "unbind-key", .name = "unbind-key",
@@ -41,7 +41,7 @@ const struct cmd_entry cmd_unbind_key_entry = {
.exec = cmd_unbind_key_exec .exec = cmd_unbind_key_exec
}; };
enum cmd_retval static enum cmd_retval
cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq) cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -98,7 +98,7 @@ cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
enum cmd_retval static enum cmd_retval
cmd_unbind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key) cmd_unbind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key)
{ {
struct args *args = self->args; struct args *args = self->args;

View File

@@ -28,7 +28,7 @@
* Block or wake a client on a named wait channel. * Block or wake a client on a named wait channel.
*/ */
enum cmd_retval cmd_wait_for_exec(struct cmd *, struct cmd_q *); static enum cmd_retval cmd_wait_for_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_wait_for_entry = { const struct cmd_entry cmd_wait_for_entry = {
.name = "wait-for", .name = "wait-for",
@@ -52,31 +52,30 @@ struct wait_channel {
RB_ENTRY(wait_channel) entry; RB_ENTRY(wait_channel) entry;
}; };
RB_HEAD(wait_channels, wait_channel); RB_HEAD(wait_channels, wait_channel);
struct wait_channels wait_channels = RB_INITIALIZER(wait_channels); static struct wait_channels wait_channels = RB_INITIALIZER(wait_channels);
int wait_channel_cmp(struct wait_channel *, struct wait_channel *); static int wait_channel_cmp(struct wait_channel *, struct wait_channel *);
RB_PROTOTYPE(wait_channels, wait_channel, entry, wait_channel_cmp); RB_GENERATE_STATIC(wait_channels, wait_channel, entry, wait_channel_cmp);
RB_GENERATE(wait_channels, wait_channel, entry, wait_channel_cmp);
int static int
wait_channel_cmp(struct wait_channel *wc1, struct wait_channel *wc2) wait_channel_cmp(struct wait_channel *wc1, struct wait_channel *wc2)
{ {
return (strcmp(wc1->name, wc2->name)); return (strcmp(wc1->name, wc2->name));
} }
enum cmd_retval cmd_wait_for_signal(struct cmd_q *, const char *, static enum cmd_retval cmd_wait_for_signal(struct cmd_q *, const char *,
struct wait_channel *); struct wait_channel *);
enum cmd_retval cmd_wait_for_wait(struct cmd_q *, const char *, static enum cmd_retval cmd_wait_for_wait(struct cmd_q *, const char *,
struct wait_channel *); struct wait_channel *);
enum cmd_retval cmd_wait_for_lock(struct cmd_q *, const char *, static enum cmd_retval cmd_wait_for_lock(struct cmd_q *, const char *,
struct wait_channel *); struct wait_channel *);
enum cmd_retval cmd_wait_for_unlock(struct cmd_q *, const char *, static enum cmd_retval cmd_wait_for_unlock(struct cmd_q *, const char *,
struct wait_channel *); struct wait_channel *);
struct wait_channel *cmd_wait_for_add(const char *); static struct wait_channel *cmd_wait_for_add(const char *);
void cmd_wait_for_remove(struct wait_channel *wc); static void cmd_wait_for_remove(struct wait_channel *wc);
struct wait_channel * static struct wait_channel *
cmd_wait_for_add(const char *name) cmd_wait_for_add(const char *name)
{ {
struct wait_channel *wc; struct wait_channel *wc;
@@ -97,7 +96,7 @@ cmd_wait_for_add(const char *name)
return (wc); return (wc);
} }
void static void
cmd_wait_for_remove(struct wait_channel *wc) cmd_wait_for_remove(struct wait_channel *wc)
{ {
if (wc->locked) if (wc->locked)
@@ -113,7 +112,7 @@ cmd_wait_for_remove(struct wait_channel *wc)
free(wc); free(wc);
} }
enum cmd_retval static enum cmd_retval
cmd_wait_for_exec(struct cmd *self, struct cmd_q *cmdq) cmd_wait_for_exec(struct cmd *self, struct cmd_q *cmdq)
{ {
struct args *args = self->args; struct args *args = self->args;
@@ -132,7 +131,7 @@ cmd_wait_for_exec(struct cmd *self, struct cmd_q *cmdq)
return (cmd_wait_for_wait(cmdq, name, wc)); return (cmd_wait_for_wait(cmdq, name, wc));
} }
enum cmd_retval static enum cmd_retval
cmd_wait_for_signal(__unused struct cmd_q *cmdq, const char *name, cmd_wait_for_signal(__unused struct cmd_q *cmdq, const char *name,
struct wait_channel *wc) struct wait_channel *wc)
{ {
@@ -158,7 +157,7 @@ cmd_wait_for_signal(__unused struct cmd_q *cmdq, const char *name,
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
enum cmd_retval static enum cmd_retval
cmd_wait_for_wait(struct cmd_q *cmdq, const char *name, cmd_wait_for_wait(struct cmd_q *cmdq, const char *name,
struct wait_channel *wc) struct wait_channel *wc)
{ {
@@ -185,7 +184,7 @@ cmd_wait_for_wait(struct cmd_q *cmdq, const char *name,
return (CMD_RETURN_WAIT); return (CMD_RETURN_WAIT);
} }
enum cmd_retval static enum cmd_retval
cmd_wait_for_lock(struct cmd_q *cmdq, const char *name, cmd_wait_for_lock(struct cmd_q *cmdq, const char *name,
struct wait_channel *wc) struct wait_channel *wc)
{ {
@@ -207,7 +206,7 @@ cmd_wait_for_lock(struct cmd_q *cmdq, const char *name,
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
enum cmd_retval static enum cmd_retval
cmd_wait_for_unlock(struct cmd_q *cmdq, const char *name, cmd_wait_for_unlock(struct cmd_q *cmdq, const char *name,
struct wait_channel *wc) struct wait_channel *wc)
{ {

View File

@@ -28,11 +28,10 @@
*/ */
RB_HEAD(environ, environ_entry); RB_HEAD(environ, environ_entry);
int environ_cmp(struct environ_entry *, struct environ_entry *); static int environ_cmp(struct environ_entry *, struct environ_entry *);
RB_PROTOTYPE(environ, environ_entry, entry, environ_cmp); RB_GENERATE_STATIC(environ, environ_entry, entry, environ_cmp);
RB_GENERATE(environ, environ_entry, entry, environ_cmp);
int static int
environ_cmp(struct environ_entry *envent1, struct environ_entry *envent2) environ_cmp(struct environ_entry *envent1, struct environ_entry *envent2)
{ {
return (strcmp(envent1->name, envent2->name)); return (strcmp(envent1->name, envent2->name));

120
format.c
View File

@@ -40,35 +40,41 @@
struct format_entry; struct format_entry;
typedef void (*format_cb)(struct format_tree *, struct format_entry *); typedef void (*format_cb)(struct format_tree *, struct format_entry *);
void format_job_callback(struct job *); static void format_job_callback(struct job *);
char *format_job_get(struct format_tree *, const char *); static char *format_job_get(struct format_tree *, const char *);
void format_job_timer(int, short, void *); static void format_job_timer(int, short, void *);
void format_cb_host(struct format_tree *, struct format_entry *); static void format_cb_host(struct format_tree *, struct format_entry *);
void format_cb_host_short(struct format_tree *, struct format_entry *); static void format_cb_host_short(struct format_tree *,
void format_cb_pid(struct format_tree *, struct format_entry *); struct format_entry *);
void format_cb_session_alerts(struct format_tree *, struct format_entry *); static void format_cb_pid(struct format_tree *, struct format_entry *);
void format_cb_window_layout(struct format_tree *, struct format_entry *); static void format_cb_session_alerts(struct format_tree *,
void format_cb_window_visible_layout(struct format_tree *, struct format_entry *);
struct format_entry *); static void format_cb_window_layout(struct format_tree *,
void format_cb_start_command(struct format_tree *, struct format_entry *); struct format_entry *);
void format_cb_current_command(struct format_tree *, struct format_entry *); static void format_cb_window_visible_layout(struct format_tree *,
void format_cb_current_path(struct format_tree *, struct format_entry *); struct format_entry *);
void format_cb_history_bytes(struct format_tree *, struct format_entry *); static void format_cb_start_command(struct format_tree *,
void format_cb_pane_tabs(struct format_tree *, struct format_entry *); struct format_entry *);
static void format_cb_current_command(struct format_tree *,
struct format_entry *);
static void format_cb_history_bytes(struct format_tree *,
struct format_entry *);
static void format_cb_pane_tabs(struct format_tree *,
struct format_entry *);
char *format_find(struct format_tree *, const char *, int); static char *format_find(struct format_tree *, const char *, int);
void format_add_cb(struct format_tree *, const char *, format_cb); static void format_add_cb(struct format_tree *, const char *, format_cb);
void format_add_tv(struct format_tree *, const char *, struct timeval *); static void format_add_tv(struct format_tree *, const char *,
int format_replace(struct format_tree *, const char *, size_t, char **, struct timeval *);
size_t *, size_t *); static int format_replace(struct format_tree *, const char *, size_t,
char *format_time_string(time_t); char **, size_t *, size_t *);
void format_defaults_pane_tabs(struct format_tree *, struct window_pane *); static void format_defaults_session(struct format_tree *,
void format_defaults_session(struct format_tree *, struct session *); struct session *);
void format_defaults_client(struct format_tree *, struct client *); static void format_defaults_client(struct format_tree *, struct client *);
void format_defaults_winlink(struct format_tree *, struct session *, static void format_defaults_winlink(struct format_tree *, struct session *,
struct winlink *); struct winlink *);
/* Entry in format job tree. */ /* Entry in format job tree. */
struct format_job { struct format_job {
@@ -84,14 +90,13 @@ struct format_job {
}; };
/* Format job tree. */ /* Format job tree. */
struct event format_job_event; static struct event format_job_event;
int format_job_cmp(struct format_job *, struct format_job *); static int format_job_cmp(struct format_job *, struct format_job *);
RB_HEAD(format_job_tree, format_job) format_jobs = RB_INITIALIZER(); static RB_HEAD(format_job_tree, format_job) format_jobs = RB_INITIALIZER();
RB_PROTOTYPE(format_job_tree, format_job, entry, format_job_cmp); RB_GENERATE_STATIC(format_job_tree, format_job, entry, format_job_cmp);
RB_GENERATE(format_job_tree, format_job, entry, format_job_cmp);
/* Format job tree comparison function. */ /* Format job tree comparison function. */
int static int
format_job_cmp(struct format_job *fj1, struct format_job *fj2) format_job_cmp(struct format_job *fj1, struct format_job *fj2)
{ {
return (strcmp(fj1->cmd, fj2->cmd)); return (strcmp(fj1->cmd, fj2->cmd));
@@ -122,19 +127,18 @@ struct format_tree {
RB_HEAD(format_entry_tree, format_entry) tree; RB_HEAD(format_entry_tree, format_entry) tree;
}; };
int format_entry_cmp(struct format_entry *, struct format_entry *); static int format_entry_cmp(struct format_entry *, struct format_entry *);
RB_PROTOTYPE(format_entry_tree, format_entry, entry, format_entry_cmp); RB_GENERATE_STATIC(format_entry_tree, format_entry, entry, format_entry_cmp);
RB_GENERATE(format_entry_tree, format_entry, entry, format_entry_cmp);
/* Format entry tree comparison function. */ /* Format entry tree comparison function. */
int static int
format_entry_cmp(struct format_entry *fe1, struct format_entry *fe2) format_entry_cmp(struct format_entry *fe1, struct format_entry *fe2)
{ {
return (strcmp(fe1->key, fe2->key)); return (strcmp(fe1->key, fe2->key));
} }
/* Single-character uppercase aliases. */ /* Single-character uppercase aliases. */
const char *format_upper[] = { static const char *format_upper[] = {
NULL, /* A */ NULL, /* A */
NULL, /* B */ NULL, /* B */
NULL, /* C */ NULL, /* C */
@@ -164,7 +168,7 @@ const char *format_upper[] = {
}; };
/* Single-character lowercase aliases. */ /* Single-character lowercase aliases. */
const char *format_lower[] = { static const char *format_lower[] = {
NULL, /* a */ NULL, /* a */
NULL, /* b */ NULL, /* b */
NULL, /* c */ NULL, /* c */
@@ -194,7 +198,7 @@ const char *format_lower[] = {
}; };
/* Format job callback. */ /* Format job callback. */
void static void
format_job_callback(struct job *job) format_job_callback(struct job *job)
{ {
struct format_job *fj = job->data; struct format_job *fj = job->data;
@@ -226,7 +230,7 @@ format_job_callback(struct job *job)
} }
/* Find a job. */ /* Find a job. */
char * static char *
format_job_get(struct format_tree *ft, const char *cmd) format_job_get(struct format_tree *ft, const char *cmd)
{ {
struct format_job fj0, *fj; struct format_job fj0, *fj;
@@ -260,7 +264,7 @@ format_job_get(struct format_tree *ft, const char *cmd)
} }
/* Remove old jobs. */ /* Remove old jobs. */
void static void
format_job_timer(__unused int fd, __unused short events, __unused void *arg) format_job_timer(__unused int fd, __unused short events, __unused void *arg)
{ {
struct format_job *fj, *fj1; struct format_job *fj, *fj1;
@@ -289,7 +293,7 @@ format_job_timer(__unused int fd, __unused short events, __unused void *arg)
} }
/* Callback for host. */ /* Callback for host. */
void static void
format_cb_host(__unused struct format_tree *ft, struct format_entry *fe) format_cb_host(__unused struct format_tree *ft, struct format_entry *fe)
{ {
char host[HOST_NAME_MAX + 1]; char host[HOST_NAME_MAX + 1];
@@ -301,7 +305,7 @@ format_cb_host(__unused struct format_tree *ft, struct format_entry *fe)
} }
/* Callback for host_short. */ /* Callback for host_short. */
void static void
format_cb_host_short(__unused struct format_tree *ft, struct format_entry *fe) format_cb_host_short(__unused struct format_tree *ft, struct format_entry *fe)
{ {
char host[HOST_NAME_MAX + 1], *cp; char host[HOST_NAME_MAX + 1], *cp;
@@ -316,14 +320,14 @@ format_cb_host_short(__unused struct format_tree *ft, struct format_entry *fe)
} }
/* Callback for pid. */ /* Callback for pid. */
void static void
format_cb_pid(__unused struct format_tree *ft, struct format_entry *fe) format_cb_pid(__unused struct format_tree *ft, struct format_entry *fe)
{ {
xasprintf(&fe->value, "%ld", (long)getpid()); xasprintf(&fe->value, "%ld", (long)getpid());
} }
/* Callback for session_alerts. */ /* Callback for session_alerts. */
void static void
format_cb_session_alerts(struct format_tree *ft, struct format_entry *fe) format_cb_session_alerts(struct format_tree *ft, struct format_entry *fe)
{ {
struct session *s = ft->s; struct session *s = ft->s;
@@ -353,7 +357,7 @@ format_cb_session_alerts(struct format_tree *ft, struct format_entry *fe)
} }
/* Callback for window_layout. */ /* Callback for window_layout. */
void static void
format_cb_window_layout(struct format_tree *ft, struct format_entry *fe) format_cb_window_layout(struct format_tree *ft, struct format_entry *fe)
{ {
struct window *w = ft->w; struct window *w = ft->w;
@@ -368,7 +372,7 @@ format_cb_window_layout(struct format_tree *ft, struct format_entry *fe)
} }
/* Callback for window_visible_layout. */ /* Callback for window_visible_layout. */
void static void
format_cb_window_visible_layout(struct format_tree *ft, struct format_entry *fe) format_cb_window_visible_layout(struct format_tree *ft, struct format_entry *fe)
{ {
struct window *w = ft->w; struct window *w = ft->w;
@@ -380,7 +384,7 @@ format_cb_window_visible_layout(struct format_tree *ft, struct format_entry *fe)
} }
/* Callback for pane_start_command. */ /* Callback for pane_start_command. */
void static void
format_cb_start_command(struct format_tree *ft, struct format_entry *fe) format_cb_start_command(struct format_tree *ft, struct format_entry *fe)
{ {
struct window_pane *wp = ft->wp; struct window_pane *wp = ft->wp;
@@ -392,7 +396,7 @@ format_cb_start_command(struct format_tree *ft, struct format_entry *fe)
} }
/* Callback for pane_current_command. */ /* Callback for pane_current_command. */
void static void
format_cb_current_command(struct format_tree *ft, struct format_entry *fe) format_cb_current_command(struct format_tree *ft, struct format_entry *fe)
{ {
struct window_pane *wp = ft->wp; struct window_pane *wp = ft->wp;
@@ -430,7 +434,7 @@ format_cb_current_path(struct format_tree *ft, struct format_entry *fe)
} }
/* Callback for history_bytes. */ /* Callback for history_bytes. */
void static void
format_cb_history_bytes(struct format_tree *ft, struct format_entry *fe) format_cb_history_bytes(struct format_tree *ft, struct format_entry *fe)
{ {
struct window_pane *wp = ft->wp; struct window_pane *wp = ft->wp;
@@ -455,7 +459,7 @@ format_cb_history_bytes(struct format_tree *ft, struct format_entry *fe)
} }
/* Callback for pane_tabs. */ /* Callback for pane_tabs. */
void static void
format_cb_pane_tabs(struct format_tree *ft, struct format_entry *fe) format_cb_pane_tabs(struct format_tree *ft, struct format_entry *fe)
{ {
struct window_pane *wp = ft->wp; struct window_pane *wp = ft->wp;
@@ -556,7 +560,7 @@ format_add(struct format_tree *ft, const char *key, const char *fmt, ...)
} }
/* Add a key and time. */ /* Add a key and time. */
void static void
format_add_tv(struct format_tree *ft, const char *key, struct timeval *tv) format_add_tv(struct format_tree *ft, const char *key, struct timeval *tv)
{ {
struct format_entry *fe; struct format_entry *fe;
@@ -580,7 +584,7 @@ format_add_tv(struct format_tree *ft, const char *key, struct timeval *tv)
} }
/* Add a key and function. */ /* Add a key and function. */
void static void
format_add_cb(struct format_tree *ft, const char *key, format_cb cb) format_add_cb(struct format_tree *ft, const char *key, format_cb cb)
{ {
struct format_entry *fe; struct format_entry *fe;
@@ -604,7 +608,7 @@ format_add_cb(struct format_tree *ft, const char *key, format_cb cb)
} }
/* Find a format entry. */ /* Find a format entry. */
char * static char *
format_find(struct format_tree *ft, const char *key, int modifiers) format_find(struct format_tree *ft, const char *key, int modifiers)
{ {
struct format_entry *fe, fe_find; struct format_entry *fe, fe_find;
@@ -699,7 +703,7 @@ found:
* Replace a key/value pair in buffer. #{blah} is expanded directly, * Replace a key/value pair in buffer. #{blah} is expanded directly,
* #{?blah,a,b} is replace with a if blah exists and is nonzero else b. * #{?blah,a,b} is replace with a if blah exists and is nonzero else b.
*/ */
int static int
format_replace(struct format_tree *ft, const char *key, size_t keylen, format_replace(struct format_tree *ft, const char *key, size_t keylen,
char **buf, size_t *len, size_t *off) char **buf, size_t *len, size_t *off)
{ {
@@ -1019,7 +1023,7 @@ format_defaults(struct format_tree *ft, struct client *c, struct session *s,
} }
/* Set default format keys for a session. */ /* Set default format keys for a session. */
void static void
format_defaults_session(struct format_tree *ft, struct session *s) format_defaults_session(struct format_tree *ft, struct session *s)
{ {
struct session_group *sg; struct session_group *sg;
@@ -1048,7 +1052,7 @@ format_defaults_session(struct format_tree *ft, struct session *s)
} }
/* Set default format keys for a client. */ /* Set default format keys for a client. */
void static void
format_defaults_client(struct format_tree *ft, struct client *c) format_defaults_client(struct format_tree *ft, struct client *c)
{ {
struct session *s; struct session *s;
@@ -1115,7 +1119,7 @@ format_defaults_window(struct format_tree *ft, struct window *w)
} }
/* Set default format keys for a winlink. */ /* Set default format keys for a winlink. */
void static void
format_defaults_winlink(struct format_tree *ft, struct session *s, format_defaults_winlink(struct format_tree *ft, struct session *s,
struct winlink *wl) struct winlink *wl)
{ {

40
grid.c
View File

@@ -43,16 +43,20 @@ const struct grid_cell_entry grid_default_entry = {
0, { .data = { 0, 8, 8, ' ' } } 0, { .data = { 0, 8, 8, ' ' } }
}; };
void grid_reflow_copy(struct grid_line *, u_int, struct grid_line *l, static void grid_expand_line(struct grid *, u_int, u_int);
u_int, u_int);
void grid_reflow_join(struct grid *, u_int *, struct grid_line *, u_int); static void grid_reflow_copy(struct grid_line *, u_int, struct grid_line *,
void grid_reflow_split(struct grid *, u_int *, struct grid_line *, u_int, u_int, u_int);
u_int); static void grid_reflow_join(struct grid *, u_int *, struct grid_line *,
void grid_reflow_move(struct grid *, u_int *, struct grid_line *); u_int);
size_t grid_string_cells_fg(const struct grid_cell *, int *); static void grid_reflow_split(struct grid *, u_int *, struct grid_line *,
size_t grid_string_cells_bg(const struct grid_cell *, int *); u_int, u_int);
void grid_string_cells_code(const struct grid_cell *, static void grid_reflow_move(struct grid *, u_int *, struct grid_line *);
const struct grid_cell *, char *, size_t, int);
static size_t grid_string_cells_fg(const struct grid_cell *, int *);
static size_t grid_string_cells_bg(const struct grid_cell *, int *);
static void grid_string_cells_code(const struct grid_cell *,
const struct grid_cell *, char *, size_t, int);
/* Copy default into a cell. */ /* Copy default into a cell. */
static void static void
@@ -242,7 +246,7 @@ grid_scroll_history_region(struct grid *gd, u_int upper, u_int lower)
} }
/* Expand line to fit to cell. */ /* Expand line to fit to cell. */
void static void
grid_expand_line(struct grid *gd, u_int py, u_int sx) grid_expand_line(struct grid *gd, u_int py, u_int sx)
{ {
struct grid_line *gl; struct grid_line *gl;
@@ -473,7 +477,7 @@ grid_move_cells(struct grid *gd, u_int dx, u_int px, u_int py, u_int nx)
} }
/* Get ANSI foreground sequence. */ /* Get ANSI foreground sequence. */
size_t static size_t
grid_string_cells_fg(const struct grid_cell *gc, int *values) grid_string_cells_fg(const struct grid_cell *gc, int *values)
{ {
size_t n; size_t n;
@@ -522,7 +526,7 @@ grid_string_cells_fg(const struct grid_cell *gc, int *values)
} }
/* Get ANSI background sequence. */ /* Get ANSI background sequence. */
size_t static size_t
grid_string_cells_bg(const struct grid_cell *gc, int *values) grid_string_cells_bg(const struct grid_cell *gc, int *values)
{ {
size_t n; size_t n;
@@ -575,7 +579,7 @@ grid_string_cells_bg(const struct grid_cell *gc, int *values)
* given a current state. The output buffer must be able to hold at least 57 * given a current state. The output buffer must be able to hold at least 57
* bytes. * bytes.
*/ */
void static void
grid_string_cells_code(const struct grid_cell *lastgc, grid_string_cells_code(const struct grid_cell *lastgc,
const struct grid_cell *gc, char *buf, size_t len, int escape_c0) const struct grid_cell *gc, char *buf, size_t len, int escape_c0)
{ {
@@ -773,7 +777,7 @@ grid_duplicate_lines(struct grid *dst, u_int dy, struct grid *src, u_int sy,
} }
/* Copy a section of a line. */ /* Copy a section of a line. */
void static void
grid_reflow_copy(struct grid_line *dst_gl, u_int to, struct grid_line *src_gl, grid_reflow_copy(struct grid_line *dst_gl, u_int to, struct grid_line *src_gl,
u_int from, u_int to_copy) u_int from, u_int to_copy)
{ {
@@ -798,7 +802,7 @@ grid_reflow_copy(struct grid_line *dst_gl, u_int to, struct grid_line *src_gl,
} }
/* Join line data. */ /* Join line data. */
void static void
grid_reflow_join(struct grid *dst, u_int *py, struct grid_line *src_gl, grid_reflow_join(struct grid *dst, u_int *py, struct grid_line *src_gl,
u_int new_x) u_int new_x)
{ {
@@ -833,7 +837,7 @@ grid_reflow_join(struct grid *dst, u_int *py, struct grid_line *src_gl,
} }
/* Split line data. */ /* Split line data. */
void static void
grid_reflow_split(struct grid *dst, u_int *py, struct grid_line *src_gl, grid_reflow_split(struct grid *dst, u_int *py, struct grid_line *src_gl,
u_int new_x, u_int offset) u_int new_x, u_int offset)
{ {
@@ -873,7 +877,7 @@ grid_reflow_split(struct grid *dst, u_int *py, struct grid_line *src_gl,
} }
/* Move line data. */ /* Move line data. */
void static void
grid_reflow_move(struct grid *dst, u_int *py, struct grid_line *src_gl) grid_reflow_move(struct grid *dst, u_int *py, struct grid_line *src_gl)
{ {
struct grid_line *dst_gl; struct grid_line *dst_gl;

View File

@@ -29,8 +29,7 @@ struct hooks {
}; };
static int hooks_cmp(struct hook *, struct hook *); static int hooks_cmp(struct hook *, struct hook *);
RB_PROTOTYPE(hooks_tree, hook, entry, hooks_cmp); RB_GENERATE_STATIC(hooks_tree, hook, entry, hooks_cmp);
RB_GENERATE(hooks_tree, hook, entry, hooks_cmp);
static struct hook *hooks_find1(struct hooks *, const char *); static struct hook *hooks_find1(struct hooks *, const char *);
static void hooks_free1(struct hooks *, struct hook *); static void hooks_free1(struct hooks *, struct hook *);

8
job.c
View File

@@ -32,8 +32,8 @@
* output. * output.
*/ */
void job_callback(struct bufferevent *, short, void *); static void job_callback(struct bufferevent *, short, void *);
void job_write_callback(struct bufferevent *, void *); static void job_write_callback(struct bufferevent *, void *);
/* All jobs list. */ /* All jobs list. */
struct joblist all_jobs = LIST_HEAD_INITIALIZER(all_jobs); struct joblist all_jobs = LIST_HEAD_INITIALIZER(all_jobs);
@@ -148,7 +148,7 @@ job_free(struct job *job)
} }
/* Called when output buffer falls below low watermark (default is 0). */ /* Called when output buffer falls below low watermark (default is 0). */
void static void
job_write_callback(__unused struct bufferevent *bufev, void *data) job_write_callback(__unused struct bufferevent *bufev, void *data)
{ {
struct job *job = data; struct job *job = data;
@@ -164,7 +164,7 @@ job_write_callback(__unused struct bufferevent *bufev, void *data)
} }
/* Job buffer error callback. */ /* Job buffer error callback. */
void static void
job_callback(__unused struct bufferevent *bufev, __unused short events, job_callback(__unused struct bufferevent *bufev, __unused short events,
void *data) void *data)
{ {

View File

@@ -232,6 +232,146 @@ key_bindings_init(void)
"bind -n MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= \"#{pane_in_mode}\" \"copy-mode -M\" \"send-keys -M\"' 'copy-mode -M'", "bind -n MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= \"#{pane_in_mode}\" \"copy-mode -M\" \"send-keys -M\"' 'copy-mode -M'",
"bind -n MouseDown3Pane if-shell -Ft= '#{mouse_any_flag}' 'select-pane -t=; send-keys -M' 'select-pane -mt='", "bind -n MouseDown3Pane if-shell -Ft= '#{mouse_any_flag}' 'select-pane -t=; send-keys -M' 'select-pane -mt='",
"bind -n WheelUpPane if-shell -Ft= '#{mouse_any_flag}' 'send-keys -M' 'if -Ft= \"#{pane_in_mode}\" \"send-keys -M\" \"copy-mode -et=\"'", "bind -n WheelUpPane if-shell -Ft= '#{mouse_any_flag}' 'send-keys -M' 'if -Ft= \"#{pane_in_mode}\" \"send-keys -M\" \"copy-mode -et=\"'",
"bind -Tcopy-mode C-Space send -X begin-selection",
"bind -Tcopy-mode C-a send -X start-of-line",
"bind -Tcopy-mode C-c send -X cancel",
"bind -Tcopy-mode C-e send -X end-of-line",
"bind -Tcopy-mode C-f send -X cursor-right",
"bind -Tcopy-mode C-g send -X clear-selection",
"bind -Tcopy-mode C-k send -X copy-end-of-line",
"bind -Tcopy-mode C-n send -X cursor-down",
"bind -Tcopy-mode C-p send -X cursor-up",
"bind -Tcopy-mode C-r command-prompt -p'search up' \"send -X search-backward '%%'\"",
"bind -Tcopy-mode C-s command-prompt -p'search down' \"send -X search-forward '%%'\"",
"bind -Tcopy-mode C-v send -X page-down",
"bind -Tcopy-mode C-w send -X copy-selection-and-cancel",
"bind -Tcopy-mode Escape send -X cancel",
"bind -Tcopy-mode Space send -X page-down",
"bind -Tcopy-mode , send -X jump-reverse",
"bind -Tcopy-mode \\; send -X jump-again",
"bind -Tcopy-mode F command-prompt -1p'jump backward' \"send -X jump-backward '%%'\"",
"bind -Tcopy-mode N send -X search-reverse",
"bind -Tcopy-mode R send -X rectangle-toggle",
"bind -Tcopy-mode T command-prompt -1p'jump to backward' \"send -X jump-to-backward '%%'\"",
"bind -Tcopy-mode f command-prompt -1p'jump forward' \"send -X jump-forward '%%'\"",
"bind -Tcopy-mode g command-prompt -p'goto line' \"send -X goto-line '%%'\"",
"bind -Tcopy-mode n send -X search-again",
"bind -Tcopy-mode q send -X cancel",
"bind -Tcopy-mode t command-prompt -1p'jump to forward' \"send -X jump-to-forward '%%'\"",
"bind -Tcopy-mode MouseDrag1Pane send -X begin-selection",
"bind -Tcopy-mode MouseDragEnd1Pane send -X copy-selection-and-cancel",
"bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up",
"bind -Tcopy-mode WheelDownPane send -N5 -X scroll-down",
"bind -Tcopy-mode DoubleClick1Pane send -X select-word",
"bind -Tcopy-mode TripleClick1Pane send -X select-line",
"bind -Tcopy-mode NPage send -X page-down",
"bind -Tcopy-mode PPage send -X page-up",
"bind -Tcopy-mode Up send -X cursor-up",
"bind -Tcopy-mode Down send -X cursor-down",
"bind -Tcopy-mode Left send -X cursor-left",
"bind -Tcopy-mode Right send -X cursor-right",
"bind -Tcopy-mode M-1 command-prompt -p'repeat' -I1 \"send -N '%%'\"",
"bind -Tcopy-mode M-2 command-prompt -p'repeat' -I2 \"send -N '%%'\"",
"bind -Tcopy-mode M-3 command-prompt -p'repeat' -I3 \"send -N '%%'\"",
"bind -Tcopy-mode M-4 command-prompt -p'repeat' -I4 \"send -N '%%'\"",
"bind -Tcopy-mode M-5 command-prompt -p'repeat' -I5 \"send -N '%%'\"",
"bind -Tcopy-mode M-6 command-prompt -p'repeat' -I6 \"send -N '%%'\"",
"bind -Tcopy-mode M-7 command-prompt -p'repeat' -I7 \"send -N '%%'\"",
"bind -Tcopy-mode M-8 command-prompt -p'repeat' -I8 \"send -N '%%'\"",
"bind -Tcopy-mode M-9 command-prompt -p'repeat' -I9 \"send -N '%%'\"",
"bind -Tcopy-mode M-< send -X history-top",
"bind -Tcopy-mode M-> send -X history-bottom",
"bind -Tcopy-mode M-R send -X top-line",
"bind -Tcopy-mode M-b send -X previous-word",
"bind -Tcopy-mode M-f send -X next-word-end",
"bind -Tcopy-mode M-m send -X back-to-indentation",
"bind -Tcopy-mode M-r send -X middle-line",
"bind -Tcopy-mode M-v send -X page-up",
"bind -Tcopy-mode M-w send -X copy-selection-and-cancel",
"bind -Tcopy-mode M-{ send -X previous-paragraph",
"bind -Tcopy-mode M-} send -X next-paragraph",
"bind -Tcopy-mode M-Up send -X halfpage-up",
"bind -Tcopy-mode M-Down send -X halfpage-down",
"bind -Tcopy-mode C-Up send -X scroll-up",
"bind -Tcopy-mode C-Down send -X scroll-down",
"bind -Tcopy-mode-vi C-b send -X page-up",
"bind -Tcopy-mode-vi C-c send -X cancel",
"bind -Tcopy-mode-vi C-d send -X halfpage-down",
"bind -Tcopy-mode-vi C-e send -X scroll-down",
"bind -Tcopy-mode-vi C-f send -X page-down",
"bind -Tcopy-mode-vi C-h send -X cursor-left",
"bind -Tcopy-mode-vi C-j send -X copy-selection-and-cancel",
"bind -Tcopy-mode-vi Enter send -X copy-selection-and-cancel",
"bind -Tcopy-mode-vi C-u send -X halfpage-up",
"bind -Tcopy-mode-vi C-v send -X rectangle-toggle",
"bind -Tcopy-mode-vi C-y send -X scroll-up",
"bind -Tcopy-mode-vi Escape send -X clear-selection",
"bind -Tcopy-mode-vi Space send -X begin-selection",
"bind -Tcopy-mode-vi '$' send -X end-of-line",
"bind -Tcopy-mode-vi , send -X jump-reverse",
"bind -Tcopy-mode-vi / command-prompt -p'search down' \"send -X search-forward '%%'\"",
"bind -Tcopy-mode-vi 0 send -X start-of-line",
"bind -Tcopy-mode-vi 1 command-prompt -p'repeat' -I1 \"send -N '%%'\"",
"bind -Tcopy-mode-vi 2 command-prompt -p'repeat' -I2 \"send -N '%%'\"",
"bind -Tcopy-mode-vi 3 command-prompt -p'repeat' -I3 \"send -N '%%'\"",
"bind -Tcopy-mode-vi 4 command-prompt -p'repeat' -I4 \"send -N '%%'\"",
"bind -Tcopy-mode-vi 5 command-prompt -p'repeat' -I5 \"send -N '%%'\"",
"bind -Tcopy-mode-vi 6 command-prompt -p'repeat' -I6 \"send -N '%%'\"",
"bind -Tcopy-mode-vi 7 command-prompt -p'repeat' -I7 \"send -N '%%'\"",
"bind -Tcopy-mode-vi 8 command-prompt -p'repeat' -I8 \"send -N '%%'\"",
"bind -Tcopy-mode-vi 9 command-prompt -p'repeat' -I9 \"send -N '%%'\"",
"bind -Tcopy-mode-vi : command-prompt -p'goto line' \"send -X goto-line '%%'\"",
"bind -Tcopy-mode-vi \\; send -X jump-again"
"bind -Tcopy-mode-vi ? command-prompt -p'search up' \"send -X search-backward '%%'\"",
"bind -Tcopy-mode-vi A send -X append-selection-and-cancel",
"bind -Tcopy-mode-vi B send -X previous-space",
"bind -Tcopy-mode-vi D send -X copy-end-of-line",
"bind -Tcopy-mode-vi E send -X next-space-end",
"bind -Tcopy-mode-vi F command-prompt -1p'jump backward' \"send -X jump-backward '%%'\"",
"bind -Tcopy-mode-vi G send -X history-bottom",
"bind -Tcopy-mode-vi H send -X top-line",
"bind -Tcopy-mode-vi J send -X scroll-down",
"bind -Tcopy-mode-vi K send -X scroll-up",
"bind -Tcopy-mode-vi L send -X bottom-line",
"bind -Tcopy-mode-vi M send -X middle-line",
"bind -Tcopy-mode-vi N send -X search-reverse",
"bind -Tcopy-mode-vi T command-prompt -1p'jump to backward' \"send -X jump-to-backward '%%'\"",
"bind -Tcopy-mode-vi V send -X select-line",
"bind -Tcopy-mode-vi W send -X next-space",
"bind -Tcopy-mode-vi ^ send -X back-to-indentation",
"bind -Tcopy-mode-vi b send -X previous-word",
"bind -Tcopy-mode-vi e send -X next-word-end",
"bind -Tcopy-mode-vi f command-prompt -1p'jump forward' \"send -X jump-forward '%%'\"",
"bind -Tcopy-mode-vi g send -X history-top",
"bind -Tcopy-mode-vi h send -X cursor-left",
"bind -Tcopy-mode-vi j send -X cursor-down",
"bind -Tcopy-mode-vi k send -X cursor-up",
"bind -Tcopy-mode-vi l send -X cursor-right",
"bind -Tcopy-mode-vi n send -X search-again",
"bind -Tcopy-mode-vi o send -X other-end",
"bind -Tcopy-mode-vi q send -X cancel",
"bind -Tcopy-mode-vi t command-prompt -1p'jump to forward' \"send -X jump-to-forward '%%'\"",
"bind -Tcopy-mode-vi v send -X rectangle-toggle",
"bind -Tcopy-mode-vi w send -X next-word",
"bind -Tcopy-mode-vi { send -X previous-paragraph",
"bind -Tcopy-mode-vi } send -X next-paragraph",
"bind -Tcopy-mode-vi MouseDrag1Pane send -X begin-selection",
"bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel",
"bind -Tcopy-mode-vi WheelUpPane send -N5 -X scroll-up",
"bind -Tcopy-mode-vi WheelDownPane send -N5 -X scroll-down",
"bind -Tcopy-mode-vi DoubleClick1Pane send -X select-word",
"bind -Tcopy-mode-vi TripleClick1Pane send -X select-line",
"bind -Tcopy-mode-vi BSpace send -X cursor-left",
"bind -Tcopy-mode-vi NPage send -X page-down",
"bind -Tcopy-mode-vi PPage send -X page-up",
"bind -Tcopy-mode-vi Up send -X cursor-up",
"bind -Tcopy-mode-vi Down send -X cursor-down",
"bind -Tcopy-mode-vi Left send -X cursor-left",
"bind -Tcopy-mode-vi Right send -X cursor-right",
"bind -Tcopy-mode-vi C-Up send -X scroll-up",
"bind -Tcopy-mode-vi C-Down send -X scroll-down",
}; };
u_int i; u_int i;
struct cmd_list *cmdlist; struct cmd_list *cmdlist;

View File

@@ -25,7 +25,7 @@
static key_code key_string_search_table(const char *); static key_code key_string_search_table(const char *);
static key_code key_string_get_modifiers(const char **); static key_code key_string_get_modifiers(const char **);
const struct { static const struct {
const char *string; const char *string;
key_code key; key_code key;
} key_string_table[] = { } key_string_table[] = {
@@ -98,6 +98,12 @@ const struct {
KEYC_MOUSE_STRING(MOUSEDRAGEND3, MouseDragEnd3), KEYC_MOUSE_STRING(MOUSEDRAGEND3, MouseDragEnd3),
KEYC_MOUSE_STRING(WHEELUP, WheelUp), KEYC_MOUSE_STRING(WHEELUP, WheelUp),
KEYC_MOUSE_STRING(WHEELDOWN, WheelDown), KEYC_MOUSE_STRING(WHEELDOWN, WheelDown),
KEYC_MOUSE_STRING(DOUBLECLICK1, DoubleClick1),
KEYC_MOUSE_STRING(DOUBLECLICK2, DoubleClick2),
KEYC_MOUSE_STRING(DOUBLECLICK3, DoubleClick3),
KEYC_MOUSE_STRING(TRIPLECLICK1, TripleClick1),
KEYC_MOUSE_STRING(TRIPLECLICK2, TripleClick2),
KEYC_MOUSE_STRING(TRIPLECLICK3, TripleClick3),
}; };
/* Find key string in table. */ /* Find key string in table. */

View File

@@ -27,13 +27,13 @@
* one-off and generate a layout tree. * one-off and generate a layout tree.
*/ */
void layout_set_even_h(struct window *); static void layout_set_even_h(struct window *);
void layout_set_even_v(struct window *); static void layout_set_even_v(struct window *);
void layout_set_main_h(struct window *); static void layout_set_main_h(struct window *);
void layout_set_main_v(struct window *); static void layout_set_main_v(struct window *);
void layout_set_tiled(struct window *); static void layout_set_tiled(struct window *);
const struct { static const struct {
const char *name; const char *name;
void (*arrange)(struct window *); void (*arrange)(struct window *);
} layout_sets[] = { } layout_sets[] = {
@@ -114,7 +114,7 @@ layout_set_previous(struct window *w)
return (layout); return (layout);
} }
void static void
layout_set_even_h(struct window *w) layout_set_even_h(struct window *w)
{ {
struct window_pane *wp; struct window_pane *wp;
@@ -168,7 +168,7 @@ layout_set_even_h(struct window *w)
server_redraw_window(w); server_redraw_window(w);
} }
void static void
layout_set_even_v(struct window *w) layout_set_even_v(struct window *w)
{ {
struct window_pane *wp; struct window_pane *wp;
@@ -222,7 +222,7 @@ layout_set_even_v(struct window *w)
server_redraw_window(w); server_redraw_window(w);
} }
void static void
layout_set_main_h(struct window *w) layout_set_main_h(struct window *w)
{ {
struct window_pane *wp; struct window_pane *wp;
@@ -345,7 +345,7 @@ layout_set_main_h(struct window *w)
server_redraw_window(w); server_redraw_window(w);
} }
void static void
layout_set_main_v(struct window *w) layout_set_main_v(struct window *w)
{ {
struct window_pane *wp; struct window_pane *wp;

View File

@@ -38,6 +38,12 @@
* (any matching MODEKEYEDIT_SWITCHMODE*) are special-cased to do this. * (any matching MODEKEYEDIT_SWITCHMODE*) are special-cased to do this.
*/ */
/* Command to string mapping. */
struct mode_key_cmdstr {
enum mode_key_cmd cmd;
const char *name;
};
/* Entry in the default mode key tables. */ /* Entry in the default mode key tables. */
struct mode_key_entry { struct mode_key_entry {
key_code key; key_code key;
@@ -50,11 +56,10 @@ struct mode_key_entry {
*/ */
int mode; int mode;
enum mode_key_cmd cmd; enum mode_key_cmd cmd;
u_int repeat;
}; };
/* Edit keys command strings. */ /* Edit keys command strings. */
const struct mode_key_cmdstr mode_key_cmdstr_edit[] = { static const struct mode_key_cmdstr mode_key_cmdstr_edit[] = {
{ MODEKEYEDIT_BACKSPACE, "backspace" }, { MODEKEYEDIT_BACKSPACE, "backspace" },
{ MODEKEYEDIT_CANCEL, "cancel" }, { MODEKEYEDIT_CANCEL, "cancel" },
{ MODEKEYEDIT_COMPLETE, "complete" }, { MODEKEYEDIT_COMPLETE, "complete" },
@@ -89,7 +94,7 @@ const struct mode_key_cmdstr mode_key_cmdstr_edit[] = {
}; };
/* Choice keys command strings. */ /* Choice keys command strings. */
const struct mode_key_cmdstr mode_key_cmdstr_choice[] = { static const struct mode_key_cmdstr mode_key_cmdstr_choice[] = {
{ MODEKEYCHOICE_BACKSPACE, "backspace" }, { MODEKEYCHOICE_BACKSPACE, "backspace" },
{ MODEKEYCHOICE_BOTTOMLINE, "bottom-line"}, { MODEKEYCHOICE_BOTTOMLINE, "bottom-line"},
{ MODEKEYCHOICE_CANCEL, "cancel" }, { MODEKEYCHOICE_CANCEL, "cancel" },
@@ -113,416 +118,207 @@ const struct mode_key_cmdstr mode_key_cmdstr_choice[] = {
{ 0, NULL } { 0, NULL }
}; };
/* Copy keys command strings. */
const struct mode_key_cmdstr mode_key_cmdstr_copy[] = {
{ MODEKEYCOPY_APPENDSELECTION, "append-selection" },
{ MODEKEYCOPY_BACKTOINDENTATION, "back-to-indentation" },
{ MODEKEYCOPY_BOTTOMLINE, "bottom-line" },
{ MODEKEYCOPY_CANCEL, "cancel" },
{ MODEKEYCOPY_CLEARSELECTION, "clear-selection" },
{ MODEKEYCOPY_COPYPIPE, "copy-pipe" },
{ MODEKEYCOPY_COPYLINE, "copy-line" },
{ MODEKEYCOPY_COPYENDOFLINE, "copy-end-of-line" },
{ MODEKEYCOPY_COPYSELECTION, "copy-selection" },
{ MODEKEYCOPY_DOWN, "cursor-down" },
{ MODEKEYCOPY_ENDOFLINE, "end-of-line" },
{ MODEKEYCOPY_GOTOLINE, "goto-line" },
{ MODEKEYCOPY_HALFPAGEDOWN, "halfpage-down" },
{ MODEKEYCOPY_HALFPAGEUP, "halfpage-up" },
{ MODEKEYCOPY_HISTORYBOTTOM, "history-bottom" },
{ MODEKEYCOPY_HISTORYTOP, "history-top" },
{ MODEKEYCOPY_JUMP, "jump-forward" },
{ MODEKEYCOPY_JUMPAGAIN, "jump-again" },
{ MODEKEYCOPY_JUMPREVERSE, "jump-reverse" },
{ MODEKEYCOPY_JUMPBACK, "jump-backward" },
{ MODEKEYCOPY_JUMPTO, "jump-to-forward" },
{ MODEKEYCOPY_JUMPTOBACK, "jump-to-backward" },
{ MODEKEYCOPY_LEFT, "cursor-left" },
{ MODEKEYCOPY_RECTANGLETOGGLE, "rectangle-toggle" },
{ MODEKEYCOPY_MIDDLELINE, "middle-line" },
{ MODEKEYCOPY_NEXTPAGE, "page-down" },
{ MODEKEYCOPY_NEXTPARAGRAPH, "next-paragraph" },
{ MODEKEYCOPY_NEXTSPACE, "next-space" },
{ MODEKEYCOPY_NEXTSPACEEND, "next-space-end" },
{ MODEKEYCOPY_NEXTWORD, "next-word" },
{ MODEKEYCOPY_NEXTWORDEND, "next-word-end" },
{ MODEKEYCOPY_OTHEREND, "other-end" },
{ MODEKEYCOPY_PREVIOUSPAGE, "page-up" },
{ MODEKEYCOPY_PREVIOUSPARAGRAPH, "previous-paragraph" },
{ MODEKEYCOPY_PREVIOUSSPACE, "previous-space" },
{ MODEKEYCOPY_PREVIOUSWORD, "previous-word" },
{ MODEKEYCOPY_RIGHT, "cursor-right" },
{ MODEKEYCOPY_SCROLLDOWN, "scroll-down" },
{ MODEKEYCOPY_SCROLLUP, "scroll-up" },
{ MODEKEYCOPY_SEARCHAGAIN, "search-again" },
{ MODEKEYCOPY_SEARCHDOWN, "search-forward" },
{ MODEKEYCOPY_SEARCHREVERSE, "search-reverse" },
{ MODEKEYCOPY_SEARCHUP, "search-backward" },
{ MODEKEYCOPY_SELECTLINE, "select-line" },
{ MODEKEYCOPY_STARTNAMEDBUFFER, "start-named-buffer" },
{ MODEKEYCOPY_STARTNUMBERPREFIX, "start-number-prefix" },
{ MODEKEYCOPY_STARTOFLINE, "start-of-line" },
{ MODEKEYCOPY_STARTSELECTION, "begin-selection" },
{ MODEKEYCOPY_TOPLINE, "top-line" },
{ MODEKEYCOPY_UP, "cursor-up" },
{ 0, NULL }
};
/* vi editing keys. */ /* vi editing keys. */
const struct mode_key_entry mode_key_vi_edit[] = { static const struct mode_key_entry mode_key_vi_edit[] = {
{ '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL, 1 }, { '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL },
{ '\010' /* C-h */, 0, MODEKEYEDIT_BACKSPACE, 1 }, { '\010' /* C-h */, 0, MODEKEYEDIT_BACKSPACE },
{ '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE, 1 }, { '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE },
{ '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE, 1 }, { '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE },
{ '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD, 1 }, { '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD },
{ '\033' /* Escape */, 0, MODEKEYEDIT_SWITCHMODE, 1 }, { '\033' /* Escape */, 0, MODEKEYEDIT_SWITCHMODE },
{ '\n', 0, MODEKEYEDIT_ENTER, 1 }, { '\n', 0, MODEKEYEDIT_ENTER },
{ '\r', 0, MODEKEYEDIT_ENTER, 1 }, { '\r', 0, MODEKEYEDIT_ENTER },
{ KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE, 1 }, { KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE },
{ KEYC_DC, 0, MODEKEYEDIT_DELETE, 1 }, { KEYC_DC, 0, MODEKEYEDIT_DELETE },
{ KEYC_DOWN, 0, MODEKEYEDIT_HISTORYDOWN, 1 }, { KEYC_DOWN, 0, MODEKEYEDIT_HISTORYDOWN },
{ KEYC_LEFT, 0, MODEKEYEDIT_CURSORLEFT, 1 }, { KEYC_LEFT, 0, MODEKEYEDIT_CURSORLEFT },
{ KEYC_RIGHT, 0, MODEKEYEDIT_CURSORRIGHT, 1 }, { KEYC_RIGHT, 0, MODEKEYEDIT_CURSORRIGHT },
{ KEYC_UP, 0, MODEKEYEDIT_HISTORYUP, 1 }, { KEYC_UP, 0, MODEKEYEDIT_HISTORYUP },
{ KEYC_HOME, 0, MODEKEYEDIT_STARTOFLINE, 1 }, { KEYC_HOME, 0, MODEKEYEDIT_STARTOFLINE },
{ KEYC_END, 0, MODEKEYEDIT_ENDOFLINE, 1 }, { KEYC_END, 0, MODEKEYEDIT_ENDOFLINE },
{ '$', 1, MODEKEYEDIT_ENDOFLINE, 1 }, { '$', 1, MODEKEYEDIT_ENDOFLINE },
{ '0', 1, MODEKEYEDIT_STARTOFLINE, 1 }, { '0', 1, MODEKEYEDIT_STARTOFLINE },
{ 'A', 1, MODEKEYEDIT_SWITCHMODEAPPENDLINE, 1 }, { 'A', 1, MODEKEYEDIT_SWITCHMODEAPPENDLINE },
{ 'B', 1, MODEKEYEDIT_PREVIOUSSPACE, 1 }, { 'B', 1, MODEKEYEDIT_PREVIOUSSPACE },
{ 'C', 1, MODEKEYEDIT_SWITCHMODECHANGELINE, 1 }, { 'C', 1, MODEKEYEDIT_SWITCHMODECHANGELINE },
{ 'D', 1, MODEKEYEDIT_DELETETOENDOFLINE, 1 }, { 'D', 1, MODEKEYEDIT_DELETETOENDOFLINE },
{ 'E', 1, MODEKEYEDIT_NEXTSPACEEND, 1 }, { 'E', 1, MODEKEYEDIT_NEXTSPACEEND },
{ 'I', 1, MODEKEYEDIT_SWITCHMODEBEGINLINE, 1 }, { 'I', 1, MODEKEYEDIT_SWITCHMODEBEGINLINE },
{ 'S', 1, MODEKEYEDIT_SWITCHMODESUBSTITUTELINE, 1 }, { 'S', 1, MODEKEYEDIT_SWITCHMODESUBSTITUTELINE },
{ 'W', 1, MODEKEYEDIT_NEXTSPACE, 1 }, { 'W', 1, MODEKEYEDIT_NEXTSPACE },
{ 'X', 1, MODEKEYEDIT_BACKSPACE, 1 }, { 'X', 1, MODEKEYEDIT_BACKSPACE },
{ '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL, 1 }, { '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL },
{ '\010' /* C-h */, 1, MODEKEYEDIT_BACKSPACE, 1 }, { '\010' /* C-h */, 1, MODEKEYEDIT_BACKSPACE },
{ '\n', 1, MODEKEYEDIT_ENTER, 1 }, { '\n', 1, MODEKEYEDIT_ENTER },
{ '\r', 1, MODEKEYEDIT_ENTER, 1 }, { '\r', 1, MODEKEYEDIT_ENTER },
{ '^', 1, MODEKEYEDIT_STARTOFLINE, 1 }, { '^', 1, MODEKEYEDIT_STARTOFLINE },
{ 'a', 1, MODEKEYEDIT_SWITCHMODEAPPEND, 1 }, { 'a', 1, MODEKEYEDIT_SWITCHMODEAPPEND },
{ 'b', 1, MODEKEYEDIT_PREVIOUSWORD, 1 }, { 'b', 1, MODEKEYEDIT_PREVIOUSWORD },
{ 'd', 1, MODEKEYEDIT_DELETELINE, 1 }, { 'd', 1, MODEKEYEDIT_DELETELINE },
{ 'e', 1, MODEKEYEDIT_NEXTWORDEND, 1 }, { 'e', 1, MODEKEYEDIT_NEXTWORDEND },
{ 'h', 1, MODEKEYEDIT_CURSORLEFT, 1 }, { 'h', 1, MODEKEYEDIT_CURSORLEFT },
{ 'i', 1, MODEKEYEDIT_SWITCHMODE, 1 }, { 'i', 1, MODEKEYEDIT_SWITCHMODE },
{ 'j', 1, MODEKEYEDIT_HISTORYDOWN, 1 }, { 'j', 1, MODEKEYEDIT_HISTORYDOWN },
{ 'k', 1, MODEKEYEDIT_HISTORYUP, 1 }, { 'k', 1, MODEKEYEDIT_HISTORYUP },
{ 'l', 1, MODEKEYEDIT_CURSORRIGHT, 1 }, { 'l', 1, MODEKEYEDIT_CURSORRIGHT },
{ 'p', 1, MODEKEYEDIT_PASTE, 1 }, { 'p', 1, MODEKEYEDIT_PASTE },
{ 's', 1, MODEKEYEDIT_SWITCHMODESUBSTITUTE, 1 }, { 's', 1, MODEKEYEDIT_SWITCHMODESUBSTITUTE },
{ 'w', 1, MODEKEYEDIT_NEXTWORD, 1 }, { 'w', 1, MODEKEYEDIT_NEXTWORD },
{ 'x', 1, MODEKEYEDIT_DELETE, 1 }, { 'x', 1, MODEKEYEDIT_DELETE },
{ KEYC_BSPACE, 1, MODEKEYEDIT_BACKSPACE, 1 }, { KEYC_BSPACE, 1, MODEKEYEDIT_BACKSPACE },
{ KEYC_DC, 1, MODEKEYEDIT_DELETE, 1 }, { KEYC_DC, 1, MODEKEYEDIT_DELETE },
{ KEYC_DOWN, 1, MODEKEYEDIT_HISTORYDOWN, 1 }, { KEYC_DOWN, 1, MODEKEYEDIT_HISTORYDOWN },
{ KEYC_LEFT, 1, MODEKEYEDIT_CURSORLEFT, 1 }, { KEYC_LEFT, 1, MODEKEYEDIT_CURSORLEFT },
{ KEYC_RIGHT, 1, MODEKEYEDIT_CURSORRIGHT, 1 }, { KEYC_RIGHT, 1, MODEKEYEDIT_CURSORRIGHT },
{ KEYC_UP, 1, MODEKEYEDIT_HISTORYUP, 1 }, { KEYC_UP, 1, MODEKEYEDIT_HISTORYUP },
{ 0, -1, 0, 1 } { 0, -1, 0 }
}; };
struct mode_key_tree mode_key_tree_vi_edit; struct mode_key_tree mode_key_tree_vi_edit;
/* vi choice selection keys. */ /* vi choice selection keys. */
const struct mode_key_entry mode_key_vi_choice[] = { static const struct mode_key_entry mode_key_vi_choice[] = {
{ '0' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '0' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '1' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '1' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '2' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '2' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '3' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '3' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '4' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '4' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '5' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '5' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '6' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '6' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '7' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '7' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '8' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '8' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '9' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '9' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '\002' /* C-b */, 0, MODEKEYCHOICE_PAGEUP, 1 }, { '\002' /* C-b */, 0, MODEKEYCHOICE_PAGEUP },
{ '\003' /* C-c */, 0, MODEKEYCHOICE_CANCEL, 1 }, { '\003' /* C-c */, 0, MODEKEYCHOICE_CANCEL },
{ '\005' /* C-e */, 0, MODEKEYCHOICE_SCROLLDOWN, 1 }, { '\005' /* C-e */, 0, MODEKEYCHOICE_SCROLLDOWN },
{ '\006' /* C-f */, 0, MODEKEYCHOICE_PAGEDOWN, 1 }, { '\006' /* C-f */, 0, MODEKEYCHOICE_PAGEDOWN },
{ '\031' /* C-y */, 0, MODEKEYCHOICE_SCROLLUP, 1 }, { '\031' /* C-y */, 0, MODEKEYCHOICE_SCROLLUP },
{ '\n', 0, MODEKEYCHOICE_CHOOSE, 1 }, { '\n', 0, MODEKEYCHOICE_CHOOSE },
{ '\r', 0, MODEKEYCHOICE_CHOOSE, 1 }, { '\r', 0, MODEKEYCHOICE_CHOOSE },
{ 'j', 0, MODEKEYCHOICE_DOWN, 1 }, { 'j', 0, MODEKEYCHOICE_DOWN },
{ 'k', 0, MODEKEYCHOICE_UP, 1 }, { 'k', 0, MODEKEYCHOICE_UP },
{ 'q', 0, MODEKEYCHOICE_CANCEL, 1 }, { 'q', 0, MODEKEYCHOICE_CANCEL },
{ KEYC_HOME, 0, MODEKEYCHOICE_STARTOFLIST, 1 }, { KEYC_HOME, 0, MODEKEYCHOICE_STARTOFLIST },
{ 'g', 0, MODEKEYCHOICE_STARTOFLIST, 1 }, { 'g', 0, MODEKEYCHOICE_STARTOFLIST },
{ 'H', 0, MODEKEYCHOICE_TOPLINE, 1 }, { 'H', 0, MODEKEYCHOICE_TOPLINE },
{ 'L', 0, MODEKEYCHOICE_BOTTOMLINE, 1 }, { 'L', 0, MODEKEYCHOICE_BOTTOMLINE },
{ 'G', 0, MODEKEYCHOICE_ENDOFLIST, 1 }, { 'G', 0, MODEKEYCHOICE_ENDOFLIST },
{ KEYC_END, 0, MODEKEYCHOICE_ENDOFLIST, 1 }, { KEYC_END, 0, MODEKEYCHOICE_ENDOFLIST },
{ KEYC_BSPACE, 0, MODEKEYCHOICE_BACKSPACE, 1 }, { KEYC_BSPACE, 0, MODEKEYCHOICE_BACKSPACE },
{ KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLDOWN, 1 }, { KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLDOWN },
{ KEYC_DOWN, 0, MODEKEYCHOICE_DOWN, 1 }, { KEYC_DOWN, 0, MODEKEYCHOICE_DOWN },
{ KEYC_NPAGE, 0, MODEKEYCHOICE_PAGEDOWN, 1 }, { KEYC_NPAGE, 0, MODEKEYCHOICE_PAGEDOWN },
{ KEYC_PPAGE, 0, MODEKEYCHOICE_PAGEUP, 1 }, { KEYC_PPAGE, 0, MODEKEYCHOICE_PAGEUP },
{ KEYC_UP | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLUP, 1 }, { KEYC_UP | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLUP },
{ KEYC_UP, 0, MODEKEYCHOICE_UP, 1 }, { KEYC_UP, 0, MODEKEYCHOICE_UP },
{ ' ', 0, MODEKEYCHOICE_TREE_TOGGLE, 1 }, { ' ', 0, MODEKEYCHOICE_TREE_TOGGLE },
{ KEYC_LEFT, 0, MODEKEYCHOICE_TREE_COLLAPSE, 1 }, { KEYC_LEFT, 0, MODEKEYCHOICE_TREE_COLLAPSE },
{ KEYC_RIGHT, 0, MODEKEYCHOICE_TREE_EXPAND, 1 }, { KEYC_RIGHT, 0, MODEKEYCHOICE_TREE_EXPAND },
{ KEYC_LEFT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_COLLAPSE_ALL, 1 }, { KEYC_LEFT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_COLLAPSE_ALL },
{ KEYC_RIGHT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_EXPAND_ALL, 1 }, { KEYC_RIGHT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_EXPAND_ALL },
{ KEYC_MOUSEDOWN1_PANE, 0, MODEKEYCHOICE_CHOOSE, 1 }, { KEYC_MOUSEDOWN1_PANE, 0, MODEKEYCHOICE_CHOOSE },
{ KEYC_MOUSEDOWN3_PANE, 0, MODEKEYCHOICE_TREE_TOGGLE, 1 }, { KEYC_MOUSEDOWN3_PANE, 0, MODEKEYCHOICE_TREE_TOGGLE },
{ KEYC_WHEELUP_PANE, 0, MODEKEYCHOICE_UP, 1 }, { KEYC_WHEELUP_PANE, 0, MODEKEYCHOICE_UP },
{ KEYC_WHEELDOWN_PANE, 0, MODEKEYCHOICE_DOWN, 1 }, { KEYC_WHEELDOWN_PANE, 0, MODEKEYCHOICE_DOWN },
{ 0, -1, 0, 1 } { 0, -1, 0 }
}; };
struct mode_key_tree mode_key_tree_vi_choice; struct mode_key_tree mode_key_tree_vi_choice;
/* vi copy mode keys. */
const struct mode_key_entry mode_key_vi_copy[] = {
{ ' ', 0, MODEKEYCOPY_STARTSELECTION, 1 },
{ '"', 0, MODEKEYCOPY_STARTNAMEDBUFFER, 1 },
{ '$', 0, MODEKEYCOPY_ENDOFLINE, 1 },
{ ',', 0, MODEKEYCOPY_JUMPREVERSE, 1 },
{ ';', 0, MODEKEYCOPY_JUMPAGAIN, 1 },
{ '/', 0, MODEKEYCOPY_SEARCHDOWN, 1 },
{ '0', 0, MODEKEYCOPY_STARTOFLINE, 1 },
{ '1', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '2', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '3', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '4', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '5', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '6', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '7', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '8', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '9', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ ':', 0, MODEKEYCOPY_GOTOLINE, 1 },
{ '?', 0, MODEKEYCOPY_SEARCHUP, 1 },
{ 'A', 0, MODEKEYCOPY_APPENDSELECTION, 1 },
{ 'B', 0, MODEKEYCOPY_PREVIOUSSPACE, 1 },
{ 'D', 0, MODEKEYCOPY_COPYENDOFLINE, 1 },
{ 'E', 0, MODEKEYCOPY_NEXTSPACEEND, 1 },
{ 'F', 0, MODEKEYCOPY_JUMPBACK, 1 },
{ 'G', 0, MODEKEYCOPY_HISTORYBOTTOM, 1 },
{ 'H', 0, MODEKEYCOPY_TOPLINE, 1 },
{ 'J', 0, MODEKEYCOPY_SCROLLDOWN, 1 },
{ 'K', 0, MODEKEYCOPY_SCROLLUP, 1 },
{ 'L', 0, MODEKEYCOPY_BOTTOMLINE, 1 },
{ 'M', 0, MODEKEYCOPY_MIDDLELINE, 1 },
{ 'N', 0, MODEKEYCOPY_SEARCHREVERSE, 1 },
{ 'T', 0, MODEKEYCOPY_JUMPTOBACK, 1 },
{ 'V', 0, MODEKEYCOPY_SELECTLINE, 1 },
{ 'W', 0, MODEKEYCOPY_NEXTSPACE, 1 },
{ '\002' /* C-b */, 0, MODEKEYCOPY_PREVIOUSPAGE, 1 },
{ '\003' /* C-c */, 0, MODEKEYCOPY_CANCEL, 1 },
{ '\004' /* C-d */, 0, MODEKEYCOPY_HALFPAGEDOWN, 1 },
{ '\005' /* C-e */, 0, MODEKEYCOPY_SCROLLDOWN, 1 },
{ '\006' /* C-f */, 0, MODEKEYCOPY_NEXTPAGE, 1 },
{ '\010' /* C-h */, 0, MODEKEYCOPY_LEFT, 1 },
{ '\025' /* C-u */, 0, MODEKEYCOPY_HALFPAGEUP, 1 },
{ '\031' /* C-y */, 0, MODEKEYCOPY_SCROLLUP, 1 },
{ '\033' /* Escape */, 0, MODEKEYCOPY_CLEARSELECTION, 1 },
{ '\n', 0, MODEKEYCOPY_COPYSELECTION, 1 },
{ '\r', 0, MODEKEYCOPY_COPYSELECTION, 1 },
{ '^', 0, MODEKEYCOPY_BACKTOINDENTATION, 1 },
{ 'b', 0, MODEKEYCOPY_PREVIOUSWORD, 1 },
{ 'e', 0, MODEKEYCOPY_NEXTWORDEND, 1 },
{ 'f', 0, MODEKEYCOPY_JUMP, 1 },
{ 'g', 0, MODEKEYCOPY_HISTORYTOP, 1 },
{ 'h', 0, MODEKEYCOPY_LEFT, 1 },
{ 'j', 0, MODEKEYCOPY_DOWN, 1 },
{ 'k', 0, MODEKEYCOPY_UP, 1 },
{ 'l', 0, MODEKEYCOPY_RIGHT, 1 },
{ 'n', 0, MODEKEYCOPY_SEARCHAGAIN, 1 },
{ 'o', 0, MODEKEYCOPY_OTHEREND, 1 },
{ 't', 0, MODEKEYCOPY_JUMPTO, 1 },
{ 'q', 0, MODEKEYCOPY_CANCEL, 1 },
{ 'v', 0, MODEKEYCOPY_RECTANGLETOGGLE, 1 },
{ 'w', 0, MODEKEYCOPY_NEXTWORD, 1 },
{ '{', 0, MODEKEYCOPY_PREVIOUSPARAGRAPH, 1 },
{ '}', 0, MODEKEYCOPY_NEXTPARAGRAPH, 1 },
{ KEYC_BSPACE, 0, MODEKEYCOPY_LEFT, 1 },
{ KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLDOWN, 1 },
{ KEYC_DOWN, 0, MODEKEYCOPY_DOWN, 1 },
{ KEYC_LEFT, 0, MODEKEYCOPY_LEFT, 1 },
{ KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE, 1 },
{ KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE, 1 },
{ KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT, 1 },
{ KEYC_UP | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLUP, 1 },
{ KEYC_UP, 0, MODEKEYCOPY_UP, 1 },
{ KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP, 1 },
{ KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN, 1 },
{ KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION, 1 },
{ KEYC_MOUSEDRAGEND1_PANE, 0, MODEKEYCOPY_COPYSELECTION, 1 },
{ 0, -1, 0, 1 }
};
struct mode_key_tree mode_key_tree_vi_copy;
/* emacs editing keys. */ /* emacs editing keys. */
const struct mode_key_entry mode_key_emacs_edit[] = { static const struct mode_key_entry mode_key_emacs_edit[] = {
{ '\001' /* C-a */, 0, MODEKEYEDIT_STARTOFLINE, 1 }, { '\001' /* C-a */, 0, MODEKEYEDIT_STARTOFLINE },
{ '\002' /* C-b */, 0, MODEKEYEDIT_CURSORLEFT, 1 }, { '\002' /* C-b */, 0, MODEKEYEDIT_CURSORLEFT },
{ '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL, 1 }, { '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL },
{ '\004' /* C-d */, 0, MODEKEYEDIT_DELETE, 1 }, { '\004' /* C-d */, 0, MODEKEYEDIT_DELETE },
{ '\005' /* C-e */, 0, MODEKEYEDIT_ENDOFLINE, 1 }, { '\005' /* C-e */, 0, MODEKEYEDIT_ENDOFLINE },
{ '\006' /* C-f */, 0, MODEKEYEDIT_CURSORRIGHT, 1 }, { '\006' /* C-f */, 0, MODEKEYEDIT_CURSORRIGHT },
{ '\010' /* C-H */, 0, MODEKEYEDIT_BACKSPACE, 1 }, { '\010' /* C-H */, 0, MODEKEYEDIT_BACKSPACE },
{ '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE, 1 }, { '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE },
{ '\013' /* C-k */, 0, MODEKEYEDIT_DELETETOENDOFLINE, 1 }, { '\013' /* C-k */, 0, MODEKEYEDIT_DELETETOENDOFLINE },
{ '\016' /* C-n */, 0, MODEKEYEDIT_HISTORYDOWN, 1 }, { '\016' /* C-n */, 0, MODEKEYEDIT_HISTORYDOWN },
{ '\020' /* C-p */, 0, MODEKEYEDIT_HISTORYUP, 1 }, { '\020' /* C-p */, 0, MODEKEYEDIT_HISTORYUP },
{ '\024' /* C-t */, 0, MODEKEYEDIT_TRANSPOSECHARS, 1 }, { '\024' /* C-t */, 0, MODEKEYEDIT_TRANSPOSECHARS },
{ '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE, 1 }, { '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE },
{ '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD, 1 }, { '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD },
{ '\031' /* C-y */, 0, MODEKEYEDIT_PASTE, 1 }, { '\031' /* C-y */, 0, MODEKEYEDIT_PASTE },
{ '\033' /* Escape */, 0, MODEKEYEDIT_CANCEL, 1 }, { '\033' /* Escape */, 0, MODEKEYEDIT_CANCEL },
{ '\n', 0, MODEKEYEDIT_ENTER, 1 }, { '\n', 0, MODEKEYEDIT_ENTER },
{ '\r', 0, MODEKEYEDIT_ENTER, 1 }, { '\r', 0, MODEKEYEDIT_ENTER },
{ 'b' | KEYC_ESCAPE, 0, MODEKEYEDIT_PREVIOUSWORD, 1 }, { 'b' | KEYC_ESCAPE, 0, MODEKEYEDIT_PREVIOUSWORD },
{ 'f' | KEYC_ESCAPE, 0, MODEKEYEDIT_NEXTWORDEND, 1 }, { 'f' | KEYC_ESCAPE, 0, MODEKEYEDIT_NEXTWORDEND },
{ 'm' | KEYC_ESCAPE, 0, MODEKEYEDIT_STARTOFLINE, 1 }, { 'm' | KEYC_ESCAPE, 0, MODEKEYEDIT_STARTOFLINE },
{ KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE, 1 }, { KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE },
{ KEYC_DC, 0, MODEKEYEDIT_DELETE, 1 }, { KEYC_DC, 0, MODEKEYEDIT_DELETE },
{ KEYC_DOWN, 0, MODEKEYEDIT_HISTORYDOWN, 1 }, { KEYC_DOWN, 0, MODEKEYEDIT_HISTORYDOWN },
{ KEYC_LEFT, 0, MODEKEYEDIT_CURSORLEFT, 1 }, { KEYC_LEFT, 0, MODEKEYEDIT_CURSORLEFT },
{ KEYC_RIGHT, 0, MODEKEYEDIT_CURSORRIGHT, 1 }, { KEYC_RIGHT, 0, MODEKEYEDIT_CURSORRIGHT },
{ KEYC_UP, 0, MODEKEYEDIT_HISTORYUP, 1 }, { KEYC_UP, 0, MODEKEYEDIT_HISTORYUP },
{ KEYC_HOME, 0, MODEKEYEDIT_STARTOFLINE, 1 }, { KEYC_HOME, 0, MODEKEYEDIT_STARTOFLINE },
{ KEYC_END, 0, MODEKEYEDIT_ENDOFLINE, 1 }, { KEYC_END, 0, MODEKEYEDIT_ENDOFLINE },
{ 0, -1, 0, 1 } { 0, -1, 0 }
}; };
struct mode_key_tree mode_key_tree_emacs_edit; struct mode_key_tree mode_key_tree_emacs_edit;
/* emacs choice selection keys. */ /* emacs choice selection keys. */
const struct mode_key_entry mode_key_emacs_choice[] = { static const struct mode_key_entry mode_key_emacs_choice[] = {
{ '0' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '0' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '1' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '1' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '2' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '2' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '3' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '3' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '4' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '4' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '5' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '5' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '6' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '6' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '7' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '7' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '8' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '8' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '9' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, { '9' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
{ '\003' /* C-c */, 0, MODEKEYCHOICE_CANCEL, 1 }, { '\003' /* C-c */, 0, MODEKEYCHOICE_CANCEL },
{ '\016' /* C-n */, 0, MODEKEYCHOICE_DOWN, 1 }, { '\016' /* C-n */, 0, MODEKEYCHOICE_DOWN },
{ '\020' /* C-p */, 0, MODEKEYCHOICE_UP, 1 }, { '\020' /* C-p */, 0, MODEKEYCHOICE_UP },
{ '\026' /* C-v */, 0, MODEKEYCHOICE_PAGEDOWN, 1 }, { '\026' /* C-v */, 0, MODEKEYCHOICE_PAGEDOWN },
{ '\033' /* Escape */, 0, MODEKEYCHOICE_CANCEL, 1 }, { '\033' /* Escape */, 0, MODEKEYCHOICE_CANCEL },
{ '\n', 0, MODEKEYCHOICE_CHOOSE, 1 }, { '\n', 0, MODEKEYCHOICE_CHOOSE },
{ '\r', 0, MODEKEYCHOICE_CHOOSE, 1 }, { '\r', 0, MODEKEYCHOICE_CHOOSE },
{ 'q', 0, MODEKEYCHOICE_CANCEL, 1 }, { 'q', 0, MODEKEYCHOICE_CANCEL },
{ 'v' | KEYC_ESCAPE, 0, MODEKEYCHOICE_PAGEUP, 1 }, { 'v' | KEYC_ESCAPE, 0, MODEKEYCHOICE_PAGEUP },
{ KEYC_HOME, 0, MODEKEYCHOICE_STARTOFLIST, 1 }, { KEYC_HOME, 0, MODEKEYCHOICE_STARTOFLIST },
{ '<' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTOFLIST, 1 }, { '<' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTOFLIST },
{ 'R' | KEYC_ESCAPE, 0, MODEKEYCHOICE_TOPLINE, 1 }, { 'R' | KEYC_ESCAPE, 0, MODEKEYCHOICE_TOPLINE },
{ '>' | KEYC_ESCAPE, 0, MODEKEYCHOICE_ENDOFLIST, 1 }, { '>' | KEYC_ESCAPE, 0, MODEKEYCHOICE_ENDOFLIST },
{ KEYC_END, 0, MODEKEYCHOICE_ENDOFLIST, 1 }, { KEYC_END, 0, MODEKEYCHOICE_ENDOFLIST },
{ KEYC_BSPACE, 0, MODEKEYCHOICE_BACKSPACE, 1 }, { KEYC_BSPACE, 0, MODEKEYCHOICE_BACKSPACE },
{ KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLDOWN, 1 }, { KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLDOWN },
{ KEYC_DOWN, 0, MODEKEYCHOICE_DOWN, 1 }, { KEYC_DOWN, 0, MODEKEYCHOICE_DOWN },
{ KEYC_NPAGE, 0, MODEKEYCHOICE_PAGEDOWN, 1 }, { KEYC_NPAGE, 0, MODEKEYCHOICE_PAGEDOWN },
{ KEYC_PPAGE, 0, MODEKEYCHOICE_PAGEUP, 1 }, { KEYC_PPAGE, 0, MODEKEYCHOICE_PAGEUP },
{ KEYC_UP | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLUP, 1 }, { KEYC_UP | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLUP },
{ KEYC_UP, 0, MODEKEYCHOICE_UP, 1 }, { KEYC_UP, 0, MODEKEYCHOICE_UP },
{ ' ', 0, MODEKEYCHOICE_TREE_TOGGLE, 1 }, { ' ', 0, MODEKEYCHOICE_TREE_TOGGLE },
{ KEYC_LEFT, 0, MODEKEYCHOICE_TREE_COLLAPSE, 1 }, { KEYC_LEFT, 0, MODEKEYCHOICE_TREE_COLLAPSE },
{ KEYC_RIGHT, 0, MODEKEYCHOICE_TREE_EXPAND, 1 }, { KEYC_RIGHT, 0, MODEKEYCHOICE_TREE_EXPAND },
{ KEYC_LEFT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_COLLAPSE_ALL, 1 }, { KEYC_LEFT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_COLLAPSE_ALL },
{ KEYC_RIGHT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_EXPAND_ALL, 1 }, { KEYC_RIGHT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_EXPAND_ALL },
{ KEYC_MOUSEDOWN1_PANE, 0, MODEKEYCHOICE_CHOOSE, 1 }, { KEYC_MOUSEDOWN1_PANE, 0, MODEKEYCHOICE_CHOOSE },
{ KEYC_MOUSEDOWN3_PANE, 0, MODEKEYCHOICE_TREE_TOGGLE, 1 }, { KEYC_MOUSEDOWN3_PANE, 0, MODEKEYCHOICE_TREE_TOGGLE },
{ KEYC_WHEELUP_PANE, 0, MODEKEYCHOICE_UP, 5 }, { KEYC_WHEELUP_PANE, 0, MODEKEYCHOICE_UP },
{ KEYC_WHEELDOWN_PANE, 0, MODEKEYCHOICE_DOWN, 5 }, { KEYC_WHEELDOWN_PANE, 0, MODEKEYCHOICE_DOWN },
{ 0, -1, 0, 1 } { 0, -1, 0 }
}; };
struct mode_key_tree mode_key_tree_emacs_choice; struct mode_key_tree mode_key_tree_emacs_choice;
/* emacs copy mode keys. */
const struct mode_key_entry mode_key_emacs_copy[] = {
{ ' ', 0, MODEKEYCOPY_NEXTPAGE, 1 },
{ ',', 0, MODEKEYCOPY_JUMPREVERSE, 1 },
{ ';', 0, MODEKEYCOPY_JUMPAGAIN, 1 },
{ '1' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '2' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '3' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '4' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '5' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '6' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '7' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '8' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '9' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 },
{ '<' | KEYC_ESCAPE, 0, MODEKEYCOPY_HISTORYTOP, 1 },
{ '>' | KEYC_ESCAPE, 0, MODEKEYCOPY_HISTORYBOTTOM, 1 },
{ 'F', 0, MODEKEYCOPY_JUMPBACK, 1 },
{ 'N', 0, MODEKEYCOPY_SEARCHREVERSE, 1 },
{ 'R' | KEYC_ESCAPE, 0, MODEKEYCOPY_TOPLINE, 1 },
{ 'R', 0, MODEKEYCOPY_RECTANGLETOGGLE, 1 },
{ 'T', 0, MODEKEYCOPY_JUMPTOBACK, 1 },
{ '\000' /* C-Space */, 0, MODEKEYCOPY_STARTSELECTION, 1 },
{ '\001' /* C-a */, 0, MODEKEYCOPY_STARTOFLINE, 1 },
{ '\002' /* C-b */, 0, MODEKEYCOPY_LEFT, 1 },
{ '\003' /* C-c */, 0, MODEKEYCOPY_CANCEL, 1 },
{ '\005' /* C-e */, 0, MODEKEYCOPY_ENDOFLINE, 1 },
{ '\006' /* C-f */, 0, MODEKEYCOPY_RIGHT, 1 },
{ '\007' /* C-g */, 0, MODEKEYCOPY_CLEARSELECTION, 1 },
{ '\013' /* C-k */, 0, MODEKEYCOPY_COPYENDOFLINE, 1 },
{ '\016' /* C-n */, 0, MODEKEYCOPY_DOWN, 1 },
{ '\020' /* C-p */, 0, MODEKEYCOPY_UP, 1 },
{ '\022' /* C-r */, 0, MODEKEYCOPY_SEARCHUP, 1 },
{ '\023' /* C-s */, 0, MODEKEYCOPY_SEARCHDOWN, 1 },
{ '\026' /* C-v */, 0, MODEKEYCOPY_NEXTPAGE, 1 },
{ '\027' /* C-w */, 0, MODEKEYCOPY_COPYSELECTION, 1 },
{ '\033' /* Escape */, 0, MODEKEYCOPY_CANCEL, 1 },
{ 'b' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSWORD, 1 },
{ 'f', 0, MODEKEYCOPY_JUMP, 1 },
{ 'f' | KEYC_ESCAPE, 0, MODEKEYCOPY_NEXTWORDEND, 1 },
{ 'g', 0, MODEKEYCOPY_GOTOLINE, 1 },
{ 'm' | KEYC_ESCAPE, 0, MODEKEYCOPY_BACKTOINDENTATION, 1 },
{ 'n', 0, MODEKEYCOPY_SEARCHAGAIN, 1 },
{ 'q', 0, MODEKEYCOPY_CANCEL, 1 },
{ 'r' | KEYC_ESCAPE, 0, MODEKEYCOPY_MIDDLELINE, 1 },
{ 't', 0, MODEKEYCOPY_JUMPTO, 1 },
{ 'v' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPAGE, 1 },
{ 'w' | KEYC_ESCAPE, 0, MODEKEYCOPY_COPYSELECTION, 1 },
{ '{' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPARAGRAPH, 1 },
{ '}' | KEYC_ESCAPE, 0, MODEKEYCOPY_NEXTPARAGRAPH, 1 },
{ KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLDOWN, 1 },
{ KEYC_DOWN | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEDOWN, 1 },
{ KEYC_DOWN, 0, MODEKEYCOPY_DOWN, 1 },
{ KEYC_LEFT, 0, MODEKEYCOPY_LEFT, 1 },
{ KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE, 1 },
{ KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE, 1 },
{ KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT, 1 },
{ KEYC_UP | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLUP, 1 },
{ KEYC_UP | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEUP, 1 },
{ KEYC_UP, 0, MODEKEYCOPY_UP, 1 },
{ KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP, 5 },
{ KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN, 5 },
{ KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION, 1 },
{ KEYC_MOUSEDRAGEND1_PANE, 0, MODEKEYCOPY_COPYSELECTION, 1 },
{ 0, -1, 0, 1 }
};
struct mode_key_tree mode_key_tree_emacs_copy;
/* Table mapping key table names to default settings and trees. */ /* Table mapping key table names to default settings and trees. */
const struct mode_key_table mode_key_tables[] = { static const struct mode_key_table mode_key_tables[] = {
{ "vi-edit", mode_key_cmdstr_edit, { "vi-edit", mode_key_cmdstr_edit,
&mode_key_tree_vi_edit, mode_key_vi_edit }, &mode_key_tree_vi_edit, mode_key_vi_edit },
{ "vi-choice", mode_key_cmdstr_choice, { "vi-choice", mode_key_cmdstr_choice,
&mode_key_tree_vi_choice, mode_key_vi_choice }, &mode_key_tree_vi_choice, mode_key_vi_choice },
{ "vi-copy", mode_key_cmdstr_copy,
&mode_key_tree_vi_copy, mode_key_vi_copy },
{ "emacs-edit", mode_key_cmdstr_edit, { "emacs-edit", mode_key_cmdstr_edit,
&mode_key_tree_emacs_edit, mode_key_emacs_edit }, &mode_key_tree_emacs_edit, mode_key_emacs_edit },
{ "emacs-choice", mode_key_cmdstr_choice, { "emacs-choice", mode_key_cmdstr_choice,
&mode_key_tree_emacs_choice, mode_key_emacs_choice }, &mode_key_tree_emacs_choice, mode_key_emacs_choice },
{ "emacs-copy", mode_key_cmdstr_copy,
&mode_key_tree_emacs_copy, mode_key_emacs_copy },
{ NULL, NULL, NULL, NULL } { NULL, NULL, NULL, NULL }
}; };
@@ -587,10 +383,8 @@ mode_key_init_trees(void)
for (ment = mtab->table; ment->mode != -1; ment++) { for (ment = mtab->table; ment->mode != -1; ment++) {
mbind = xmalloc(sizeof *mbind); mbind = xmalloc(sizeof *mbind);
mbind->key = ment->key; mbind->key = ment->key;
mbind->repeat = ment->repeat;
mbind->mode = ment->mode; mbind->mode = ment->mode;
mbind->cmd = ment->cmd; mbind->cmd = ment->cmd;
mbind->arg = NULL;
RB_INSERT(mode_key_tree, mtab->tree, mbind); RB_INSERT(mode_key_tree, mtab->tree, mbind);
} }
} }
@@ -604,8 +398,7 @@ mode_key_init(struct mode_key_data *mdata, struct mode_key_tree *mtree)
} }
enum mode_key_cmd enum mode_key_cmd
mode_key_lookup(struct mode_key_data *mdata, key_code key, const char **arg, mode_key_lookup(struct mode_key_data *mdata, key_code key)
u_int *repeat)
{ {
struct mode_key_binding *mbind, mtmp; struct mode_key_binding *mbind, mtmp;
@@ -616,8 +409,6 @@ mode_key_lookup(struct mode_key_data *mdata, key_code key, const char **arg,
return (MODEKEY_NONE); return (MODEKEY_NONE);
return (MODEKEY_OTHER); return (MODEKEY_OTHER);
} }
if (repeat != NULL)
*repeat = mbind->repeat;
switch (mbind->cmd) { switch (mbind->cmd) {
case MODEKEYEDIT_SWITCHMODE: case MODEKEYEDIT_SWITCHMODE:
@@ -630,8 +421,6 @@ mode_key_lookup(struct mode_key_data *mdata, key_code key, const char **arg,
mdata->mode = 1 - mdata->mode; mdata->mode = 1 - mdata->mode;
/* FALLTHROUGH */ /* FALLTHROUGH */
default: default:
if (arg != NULL)
*arg = mbind->arg;
return (mbind->cmd); return (mbind->cmd);
} }
} }

12
names.c
View File

@@ -25,10 +25,12 @@
#include "tmux.h" #include "tmux.h"
void name_time_callback(int, short, void *); static void name_time_callback(int, short, void *);
int name_time_expired(struct window *, struct timeval *); static int name_time_expired(struct window *, struct timeval *);
void static char *format_window_name(struct window *);
static void
name_time_callback(__unused int fd, __unused short events, void *arg) name_time_callback(__unused int fd, __unused short events, void *arg)
{ {
struct window *w = arg; struct window *w = arg;
@@ -37,7 +39,7 @@ name_time_callback(__unused int fd, __unused short events, void *arg)
log_debug("@%u name timer expired", w->id); log_debug("@%u name timer expired", w->id);
} }
int static int
name_time_expired(struct window *w, struct timeval *tv) name_time_expired(struct window *w, struct timeval *tv)
{ {
struct timeval offset; struct timeval offset;
@@ -115,7 +117,7 @@ default_window_name(struct window *w)
return (s); return (s);
} }
char * static char *
format_window_name(struct window *w) format_window_name(struct window *w)
{ {
struct format_tree *ft; struct format_tree *ft;

View File

@@ -42,12 +42,13 @@ struct notify_entry {
TAILQ_ENTRY(notify_entry) entry; TAILQ_ENTRY(notify_entry) entry;
}; };
TAILQ_HEAD(, notify_entry) notify_queue = TAILQ_HEAD_INITIALIZER(notify_queue); TAILQ_HEAD(notify_queue, notify_entry);
int notify_enabled = 1; static struct notify_queue notify_queue = TAILQ_HEAD_INITIALIZER(notify_queue);
static int notify_enabled = 1;
void notify_drain(void); static void notify_drain(void);
void notify_add(enum notify_type, struct client *, struct session *, static void notify_add(enum notify_type, struct client *, struct session *,
struct window *); struct window *);
void void
notify_enable(void) notify_enable(void)
@@ -62,7 +63,7 @@ notify_disable(void)
notify_enabled = 0; notify_enabled = 0;
} }
void static void
notify_add(enum notify_type type, struct client *c, struct session *s, notify_add(enum notify_type type, struct client *c, struct session *s,
struct window *w) struct window *w)
{ {
@@ -83,7 +84,7 @@ notify_add(enum notify_type type, struct client *c, struct session *s,
w->references++; w->references++;
} }
void static void
notify_drain(void) notify_drain(void)
{ {
struct notify_entry *ne, *ne1; struct notify_entry *ne, *ne1;

View File

@@ -35,8 +35,7 @@ struct options {
}; };
static int options_cmp(struct options_entry *, struct options_entry *); static int options_cmp(struct options_entry *, struct options_entry *);
RB_PROTOTYPE(options_tree, options_entry, entry, options_cmp); RB_GENERATE_STATIC(options_tree, options_entry, entry, options_cmp);
RB_GENERATE(options_tree, options_entry, entry, options_cmp);
static void options_free1(struct options *, struct options_entry *); static void options_free1(struct options *, struct options_entry *);

View File

@@ -37,12 +37,12 @@
#define is_stopped(p) \ #define is_stopped(p) \
((p)->p_stat == SSTOP || (p)->p_stat == SDEAD) ((p)->p_stat == SSTOP || (p)->p_stat == SDEAD)
struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *); static struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
char *osdep_get_name(int, char *); char *osdep_get_name(int, char *);
char *osdep_get_cwd(int); char *osdep_get_cwd(int);
struct event_base *osdep_event_init(void); struct event_base *osdep_event_init(void);
struct kinfo_proc * static struct kinfo_proc *
cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2) cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2)
{ {
if (is_runnable(p1) && !is_runnable(p2)) if (is_runnable(p1) && !is_runnable(p2))

View File

@@ -45,8 +45,8 @@ struct paste_buffer {
static u_int paste_next_index; static u_int paste_next_index;
static u_int paste_next_order; static u_int paste_next_order;
static u_int paste_num_automatic; static u_int paste_num_automatic;
RB_HEAD(paste_name_tree, paste_buffer) paste_by_name; static RB_HEAD(paste_name_tree, paste_buffer) paste_by_name;
RB_HEAD(paste_time_tree, paste_buffer) paste_by_time; static RB_HEAD(paste_time_tree, paste_buffer) paste_by_time;
static int paste_cmp_names(const struct paste_buffer *, static int paste_cmp_names(const struct paste_buffer *,
const struct paste_buffer *); const struct paste_buffer *);

View File

@@ -22,21 +22,22 @@
#include "tmux.h" #include "tmux.h"
int screen_redraw_cell_border1(struct window_pane *, u_int, u_int); static int screen_redraw_cell_border1(struct window_pane *, u_int, u_int);
int screen_redraw_cell_border(struct client *, u_int, u_int); static int screen_redraw_cell_border(struct client *, u_int, u_int);
int screen_redraw_check_cell(struct client *, u_int, u_int, int, static int screen_redraw_check_cell(struct client *, u_int, u_int, int,
struct window_pane **); struct window_pane **);
int screen_redraw_check_is(u_int, u_int, int, int, struct window *, static int screen_redraw_check_is(u_int, u_int, int, int, struct window *,
struct window_pane *, struct window_pane *); struct window_pane *, struct window_pane *);
int screen_redraw_make_pane_status(struct client *, struct window *, static int screen_redraw_make_pane_status(struct client *, struct window *,
struct window_pane *); struct window_pane *);
void screen_redraw_draw_pane_status(struct client *, int); static void screen_redraw_draw_pane_status(struct client *, int);
void screen_redraw_draw_borders(struct client *, int, int, u_int); static void screen_redraw_draw_borders(struct client *, int, int, u_int);
void screen_redraw_draw_panes(struct client *, u_int); static void screen_redraw_draw_panes(struct client *, u_int);
void screen_redraw_draw_status(struct client *, u_int); static void screen_redraw_draw_status(struct client *, u_int);
void screen_redraw_draw_number(struct client *, struct window_pane *, u_int); static void screen_redraw_draw_number(struct client *, struct window_pane *,
u_int);
#define CELL_INSIDE 0 #define CELL_INSIDE 0
#define CELL_LEFTRIGHT 1 #define CELL_LEFTRIGHT 1
@@ -59,7 +60,7 @@ void screen_redraw_draw_number(struct client *, struct window_pane *, u_int);
#define CELL_STATUS_BOTTOM 2 #define CELL_STATUS_BOTTOM 2
/* Check if cell is on the border of a particular pane. */ /* Check if cell is on the border of a particular pane. */
int static int
screen_redraw_cell_border1(struct window_pane *wp, u_int px, u_int py) screen_redraw_cell_border1(struct window_pane *wp, u_int px, u_int py)
{ {
/* Inside pane. */ /* Inside pane. */
@@ -88,7 +89,7 @@ screen_redraw_cell_border1(struct window_pane *wp, u_int px, u_int py)
} }
/* Check if a cell is on the pane border. */ /* Check if a cell is on the pane border. */
int static int
screen_redraw_cell_border(struct client *c, u_int px, u_int py) screen_redraw_cell_border(struct client *c, u_int px, u_int py)
{ {
struct window *w = c->session->curw->window; struct window *w = c->session->curw->window;
@@ -107,7 +108,7 @@ screen_redraw_cell_border(struct client *c, u_int px, u_int py)
} }
/* Check if cell inside a pane. */ /* Check if cell inside a pane. */
int static int
screen_redraw_check_cell(struct client *c, u_int px, u_int py, int pane_status, screen_redraw_check_cell(struct client *c, u_int px, u_int py, int pane_status,
struct window_pane **wpp) struct window_pane **wpp)
{ {
@@ -116,6 +117,8 @@ screen_redraw_check_cell(struct client *c, u_int px, u_int py, int pane_status,
int borders; int borders;
u_int right, line; u_int right, line;
*wpp = NULL;
if (px > w->sx || py > w->sy) if (px > w->sx || py > w->sy)
return (CELL_OUTSIDE); return (CELL_OUTSIDE);
@@ -201,12 +204,11 @@ screen_redraw_check_cell(struct client *c, u_int px, u_int py, int pane_status,
} }
} }
*wpp = NULL;
return (CELL_OUTSIDE); return (CELL_OUTSIDE);
} }
/* Check if the border of a particular pane. */ /* Check if the border of a particular pane. */
int static int
screen_redraw_check_is(u_int px, u_int py, int type, int pane_status, screen_redraw_check_is(u_int px, u_int py, int type, int pane_status,
struct window *w, struct window_pane *wantwp, struct window_pane *wp) struct window *w, struct window_pane *wantwp, struct window_pane *wp)
{ {
@@ -259,7 +261,7 @@ screen_redraw_check_is(u_int px, u_int py, int type, int pane_status,
} }
/* Update pane status. */ /* Update pane status. */
int static int
screen_redraw_make_pane_status(struct client *c, struct window *w, screen_redraw_make_pane_status(struct client *c, struct window *w,
struct window_pane *wp) struct window_pane *wp)
{ {
@@ -303,7 +305,7 @@ screen_redraw_make_pane_status(struct client *c, struct window *w,
} }
/* Draw pane status. */ /* Draw pane status. */
void static void
screen_redraw_draw_pane_status(struct client *c, int pane_status) screen_redraw_draw_pane_status(struct client *c, int pane_status)
{ {
struct window *w = c->session->curw->window; struct window *w = c->session->curw->window;
@@ -418,7 +420,7 @@ screen_redraw_pane(struct client *c, struct window_pane *wp)
} }
/* Draw the borders. */ /* Draw the borders. */
void static void
screen_redraw_draw_borders(struct client *c, int status, int pane_status, screen_redraw_draw_borders(struct client *c, int status, int pane_status,
u_int top) u_int top)
{ {
@@ -505,7 +507,7 @@ screen_redraw_draw_borders(struct client *c, int status, int pane_status,
} }
/* Draw the panes. */ /* Draw the panes. */
void static void
screen_redraw_draw_panes(struct client *c, u_int top) screen_redraw_draw_panes(struct client *c, u_int top)
{ {
struct window *w = c->session->curw->window; struct window *w = c->session->curw->window;
@@ -524,7 +526,7 @@ screen_redraw_draw_panes(struct client *c, u_int top)
} }
/* Draw the status line. */ /* Draw the status line. */
void static void
screen_redraw_draw_status(struct client *c, u_int top) screen_redraw_draw_status(struct client *c, u_int top)
{ {
struct tty *tty = &c->tty; struct tty *tty = &c->tty;
@@ -536,7 +538,7 @@ screen_redraw_draw_status(struct client *c, u_int top)
} }
/* Draw number on a pane. */ /* Draw number on a pane. */
void static void
screen_redraw_draw_number(struct client *c, struct window_pane *wp, u_int top) screen_redraw_draw_number(struct client *c, struct window_pane *wp, u_int top)
{ {
struct tty *tty = &c->tty; struct tty *tty = &c->tty;

View File

@@ -24,8 +24,10 @@
#include "tmux.h" #include "tmux.h"
void screen_resize_x(struct screen *, u_int); static void screen_resize_x(struct screen *, u_int);
void screen_resize_y(struct screen *, u_int); static void screen_resize_y(struct screen *, u_int);
static void screen_reflow(struct screen *, u_int);
/* Create a new screen. */ /* Create a new screen. */
void void
@@ -139,7 +141,7 @@ screen_resize(struct screen *s, u_int sx, u_int sy, int reflow)
screen_reflow(s, sx); screen_reflow(s, sx);
} }
void static void
screen_resize_x(struct screen *s, u_int sx) screen_resize_x(struct screen *s, u_int sx)
{ {
struct grid *gd = s->grid; struct grid *gd = s->grid;
@@ -161,7 +163,7 @@ screen_resize_x(struct screen *s, u_int sx)
gd->sx = sx; gd->sx = sx;
} }
void static void
screen_resize_y(struct screen *s, u_int sy) screen_resize_y(struct screen *s, u_int sy)
{ {
struct grid *gd = s->grid; struct grid *gd = s->grid;
@@ -221,8 +223,8 @@ screen_resize_y(struct screen *s, u_int sy)
needed = sy - oldy; needed = sy - oldy;
/* /*
* Try to pull as much as possible out of scrolled history, if is * Try to pull as much as possible out of scrolled history, if
* is enabled. * is is enabled.
*/ */
available = gd->hscrolled; available = gd->hscrolled;
if (gd->flags & GRID_HISTORY && available > 0) { if (gd->flags & GRID_HISTORY && available > 0) {
@@ -370,7 +372,7 @@ screen_check_selection(struct screen *s, u_int px, u_int py)
} }
/* Reflow wrapped lines. */ /* Reflow wrapped lines. */
void static void
screen_reflow(struct screen *s, u_int new_x) screen_reflow(struct screen *s, u_int new_x)
{ {
struct grid *old = s->grid; struct grid *old = s->grid;

View File

@@ -30,21 +30,22 @@
#include "tmux.h" #include "tmux.h"
void server_client_free(int, short, void *); static void server_client_free(int, short, void *);
void server_client_check_focus(struct window_pane *); static void server_client_check_focus(struct window_pane *);
void server_client_check_resize(struct window_pane *); static void server_client_check_resize(struct window_pane *);
key_code server_client_check_mouse(struct client *); static key_code server_client_check_mouse(struct client *);
void server_client_repeat_timer(int, short, void *); static void server_client_repeat_timer(int, short, void *);
void server_client_check_exit(struct client *); static void server_client_click_timer(int, short, void *);
void server_client_check_redraw(struct client *); static void server_client_check_exit(struct client *);
void server_client_set_title(struct client *); static void server_client_check_redraw(struct client *);
void server_client_reset_state(struct client *); static void server_client_set_title(struct client *);
int server_client_assume_paste(struct session *); static void server_client_reset_state(struct client *);
static int server_client_assume_paste(struct session *);
void server_client_dispatch(struct imsg *, void *); static void server_client_dispatch(struct imsg *, void *);
void server_client_dispatch_command(struct client *, struct imsg *); static void server_client_dispatch_command(struct client *, struct imsg *);
void server_client_dispatch_identify(struct client *, struct imsg *); static void server_client_dispatch_identify(struct client *, struct imsg *);
void server_client_dispatch_shell(struct client *); static void server_client_dispatch_shell(struct client *);
/* Check if this client is inside this server. */ /* Check if this client is inside this server. */
int int
@@ -95,6 +96,13 @@ server_client_get_key_table(struct client *c)
return (name); return (name);
} }
/* Is this client using the default key table? */
int
server_client_is_default_key_table(struct client *c)
{
return (strcmp(c->keytable->name, server_client_get_key_table(c)) == 0);
}
/* Create a new client. */ /* Create a new client. */
void void
server_client_create(int fd) server_client_create(int fd)
@@ -146,6 +154,7 @@ server_client_create(int fd)
c->keytable->references++; c->keytable->references++;
evtimer_set(&c->repeat_timer, server_client_repeat_timer, c); evtimer_set(&c->repeat_timer, server_client_repeat_timer, c);
evtimer_set(&c->click_timer, server_client_click_timer, c);
TAILQ_INSERT_TAIL(&clients, c, entry); TAILQ_INSERT_TAIL(&clients, c, entry);
log_debug("new client %p", c); log_debug("new client %p", c);
@@ -214,6 +223,7 @@ server_client_lost(struct client *c)
free((void *)c->cwd); free((void *)c->cwd);
evtimer_del(&c->repeat_timer); evtimer_del(&c->repeat_timer);
evtimer_del(&c->click_timer);
key_bindings_unref_table(c->keytable); key_bindings_unref_table(c->keytable);
@@ -262,7 +272,7 @@ server_client_unref(struct client *c)
} }
/* Free dead client. */ /* Free dead client. */
void static void
server_client_free(__unused int fd, __unused short events, void *arg) server_client_free(__unused int fd, __unused short events, void *arg)
{ {
struct client *c = arg; struct client *c = arg;
@@ -287,17 +297,19 @@ server_client_detach(struct client *c, enum msgtype msgtype)
} }
/* Check for mouse keys. */ /* Check for mouse keys. */
key_code static key_code
server_client_check_mouse(struct client *c) server_client_check_mouse(struct client *c)
{ {
struct session *s = c->session; struct session *s = c->session;
struct mouse_event *m = &c->tty.mouse; struct mouse_event *m = &c->tty.mouse;
struct window *w; struct window *w;
struct window_pane *wp; struct window_pane *wp;
enum { NOTYPE, DOWN, UP, DRAG, WHEEL } type = NOTYPE; u_int x, y, b;
enum { NOWHERE, PANE, STATUS, BORDER } where = NOWHERE; int flag;
u_int x, y, b; key_code key;
key_code key; struct timeval tv;
enum { NOTYPE, DOWN, UP, DRAG, WHEEL, DOUBLE, TRIPLE } type = NOTYPE;
enum { NOWHERE, PANE, STATUS, BORDER } where = NOWHERE;
log_debug("mouse %02x at %u,%u (last %u,%u) (%d)", m->b, m->x, m->y, log_debug("mouse %02x at %u,%u (last %u,%u) (%d)", m->b, m->x, m->y,
m->lx, m->ly, c->tty.mouse_drag_flag); m->lx, m->ly, c->tty.mouse_drag_flag);
@@ -321,10 +333,45 @@ server_client_check_mouse(struct client *c)
x = m->x, y = m->y, b = m->lb; x = m->x, y = m->y, b = m->lb;
log_debug("up at %u,%u", x, y); log_debug("up at %u,%u", x, y);
} else { } else {
if (c->flags & CLIENT_DOUBLECLICK) {
evtimer_del(&c->click_timer);
c->flags &= ~CLIENT_DOUBLECLICK;
if (m->b == c->click_button) {
type = DOUBLE;
x = m->x, y = m->y, b = m->b;
log_debug("double-click at %u,%u", x, y);
flag = CLIENT_TRIPLECLICK;
goto add_timer;
}
} else if (c->flags & CLIENT_TRIPLECLICK) {
evtimer_del(&c->click_timer);
c->flags &= ~CLIENT_TRIPLECLICK;
if (m->b == c->click_button) {
type = TRIPLE;
x = m->x, y = m->y, b = m->b;
log_debug("triple-click at %u,%u", x, y);
goto have_event;
}
}
type = DOWN; type = DOWN;
x = m->x, y = m->y, b = m->b; x = m->x, y = m->y, b = m->b;
log_debug("down at %u,%u", x, y); log_debug("down at %u,%u", x, y);
flag = CLIENT_DOUBLECLICK;
add_timer:
if (KEYC_CLICK_TIMEOUT != 0) {
c->flags |= flag;
c->click_button = m->b;
tv.tv_sec = KEYC_CLICK_TIMEOUT / 1000;
tv.tv_usec = (KEYC_CLICK_TIMEOUT % 1000) * 1000L;
evtimer_del(&c->click_timer);
evtimer_add(&c->click_timer, &tv);
}
} }
have_event:
if (type == NOTYPE) if (type == NOTYPE)
return (KEYC_UNKNOWN); return (KEYC_UNKNOWN);
@@ -537,6 +584,62 @@ server_client_check_mouse(struct client *c)
break; break;
} }
break; break;
case DOUBLE:
switch (MOUSE_BUTTONS(b)) {
case 0:
if (where == PANE)
key = KEYC_DOUBLECLICK1_PANE;
if (where == STATUS)
key = KEYC_DOUBLECLICK1_STATUS;
if (where == BORDER)
key = KEYC_DOUBLECLICK1_BORDER;
break;
case 1:
if (where == PANE)
key = KEYC_DOUBLECLICK2_PANE;
if (where == STATUS)
key = KEYC_DOUBLECLICK2_STATUS;
if (where == BORDER)
key = KEYC_DOUBLECLICK2_BORDER;
break;
case 2:
if (where == PANE)
key = KEYC_DOUBLECLICK3_PANE;
if (where == STATUS)
key = KEYC_DOUBLECLICK3_STATUS;
if (where == BORDER)
key = KEYC_DOUBLECLICK3_BORDER;
break;
}
break;
case TRIPLE:
switch (MOUSE_BUTTONS(b)) {
case 0:
if (where == PANE)
key = KEYC_TRIPLECLICK1_PANE;
if (where == STATUS)
key = KEYC_TRIPLECLICK1_STATUS;
if (where == BORDER)
key = KEYC_TRIPLECLICK1_BORDER;
break;
case 1:
if (where == PANE)
key = KEYC_TRIPLECLICK2_PANE;
if (where == STATUS)
key = KEYC_TRIPLECLICK2_STATUS;
if (where == BORDER)
key = KEYC_TRIPLECLICK2_BORDER;
break;
case 2:
if (where == PANE)
key = KEYC_TRIPLECLICK3_PANE;
if (where == STATUS)
key = KEYC_TRIPLECLICK3_STATUS;
if (where == BORDER)
key = KEYC_TRIPLECLICK3_BORDER;
break;
}
break;
} }
if (key == KEYC_UNKNOWN) if (key == KEYC_UNKNOWN)
return (KEYC_UNKNOWN); return (KEYC_UNKNOWN);
@@ -553,7 +656,7 @@ server_client_check_mouse(struct client *c)
} }
/* Is this fast enough to probably be a paste? */ /* Is this fast enough to probably be a paste? */
int static int
server_client_assume_paste(struct session *s) server_client_assume_paste(struct session *s)
{ {
struct timeval tv; struct timeval tv;
@@ -585,6 +688,7 @@ server_client_handle_key(struct client *c, key_code key)
struct window *w; struct window *w;
struct window_pane *wp; struct window_pane *wp;
struct timeval tv; struct timeval tv;
const char *name;
struct key_table *table; struct key_table *table;
struct key_binding bd_find, *bd; struct key_binding bd_find, *bd;
int xtimeout; int xtimeout;
@@ -593,6 +697,10 @@ server_client_handle_key(struct client *c, key_code key)
if (s == NULL || (c->flags & (CLIENT_DEAD|CLIENT_SUSPENDED)) != 0) if (s == NULL || (c->flags & (CLIENT_DEAD|CLIENT_SUSPENDED)) != 0)
return; return;
w = s->curw->window; w = s->curw->window;
if (KEYC_IS_MOUSE(key))
wp = cmd_mouse_pane(m, NULL, NULL);
else
wp = w->active;
/* Update the activity timer. */ /* Update the activity timer. */
if (gettimeofday(&c->activity_time, NULL) != 0) if (gettimeofday(&c->activity_time, NULL) != 0)
@@ -643,9 +751,21 @@ server_client_handle_key(struct client *c, key_code key)
goto forward; goto forward;
retry: retry:
/*
* Work out the current key table. If the pane is in a mode, use
* the mode table instead of the default key table.
*/
name = NULL;
if (wp != NULL && wp->mode != NULL && wp->mode->key_table != NULL)
name = wp->mode->key_table(wp);
if (name == NULL || !server_client_is_default_key_table(c))
table = c->keytable;
else
table = key_bindings_get_table(name, 1);
/* Try to see if there is a key binding in the current table. */ /* Try to see if there is a key binding in the current table. */
bd_find.key = key; bd_find.key = key;
bd = RB_FIND(key_bindings, &c->keytable->key_bindings, &bd_find); bd = RB_FIND(key_bindings, &table->key_bindings, &bd_find);
if (bd != NULL) { if (bd != NULL) {
/* /*
* Key was matched in this table. If currently repeating but a * Key was matched in this table. If currently repeating but a
@@ -663,7 +783,6 @@ retry:
* Take a reference to this table to make sure the key binding * Take a reference to this table to make sure the key binding
* doesn't disappear. * doesn't disappear.
*/ */
table = c->keytable;
table->references++; table->references++;
/* /*
@@ -702,7 +821,7 @@ retry:
} }
/* If no match and we're not in the root table, that's it. */ /* If no match and we're not in the root table, that's it. */
if (strcmp(c->keytable->name, server_client_get_key_table(c)) != 0) { if (name == NULL && !server_client_is_default_key_table(c)) {
server_client_set_key_table(c, NULL); server_client_set_key_table(c, NULL);
server_status_client(c); server_status_client(c);
return; return;
@@ -722,10 +841,6 @@ retry:
forward: forward:
if (c->flags & CLIENT_READONLY) if (c->flags & CLIENT_READONLY)
return; return;
if (KEYC_IS_MOUSE(key))
wp = cmd_mouse_pane(m, NULL, NULL);
else
wp = w->active;
if (wp != NULL) if (wp != NULL)
window_pane_key(wp, c, s, key, m); window_pane_key(wp, c, s, key, m);
} }
@@ -795,7 +910,7 @@ server_client_resize_event(__unused int fd, __unused short events, void *data)
} }
/* Check if pane should be resized. */ /* Check if pane should be resized. */
void static void
server_client_check_resize(struct window_pane *wp) server_client_check_resize(struct window_pane *wp)
{ {
struct timeval tv = { .tv_usec = 250000 }; struct timeval tv = { .tv_usec = 250000 };
@@ -825,7 +940,7 @@ server_client_check_resize(struct window_pane *wp)
} }
/* Check whether pane should be focused. */ /* Check whether pane should be focused. */
void static void
server_client_check_focus(struct window_pane *wp) server_client_check_focus(struct window_pane *wp)
{ {
struct client *c; struct client *c;
@@ -886,7 +1001,7 @@ focused:
* tty_region/tty_reset/tty_update_mode already take care of not resetting * tty_region/tty_reset/tty_update_mode already take care of not resetting
* things that are already in their default state. * things that are already in their default state.
*/ */
void static void
server_client_reset_state(struct client *c) server_client_reset_state(struct client *c)
{ {
struct window *w = c->session->curw->window; struct window *w = c->session->curw->window;
@@ -922,7 +1037,7 @@ server_client_reset_state(struct client *c)
} }
/* Repeat time callback. */ /* Repeat time callback. */
void static void
server_client_repeat_timer(__unused int fd, __unused short events, void *data) server_client_repeat_timer(__unused int fd, __unused short events, void *data)
{ {
struct client *c = data; struct client *c = data;
@@ -934,8 +1049,17 @@ server_client_repeat_timer(__unused int fd, __unused short events, void *data)
} }
} }
/* Double-click callback. */
static void
server_client_click_timer(__unused int fd, __unused short events, void *data)
{
struct client *c = data;
c->flags &= ~(CLIENT_DOUBLECLICK|CLIENT_TRIPLECLICK);
}
/* Check if client should be exited. */ /* Check if client should be exited. */
void static void
server_client_check_exit(struct client *c) server_client_check_exit(struct client *c)
{ {
if (!(c->flags & CLIENT_EXIT)) if (!(c->flags & CLIENT_EXIT))
@@ -953,7 +1077,7 @@ server_client_check_exit(struct client *c)
} }
/* Check for client redraws. */ /* Check for client redraws. */
void static void
server_client_check_redraw(struct client *c) server_client_check_redraw(struct client *c)
{ {
struct session *s = c->session; struct session *s = c->session;
@@ -1009,7 +1133,7 @@ server_client_check_redraw(struct client *c)
} }
/* Set client title. */ /* Set client title. */
void static void
server_client_set_title(struct client *c) server_client_set_title(struct client *c)
{ {
struct session *s = c->session; struct session *s = c->session;
@@ -1034,7 +1158,7 @@ server_client_set_title(struct client *c)
} }
/* Dispatch message from client. */ /* Dispatch message from client. */
void static void
server_client_dispatch(struct imsg *imsg, void *arg) server_client_dispatch(struct imsg *imsg, void *arg)
{ {
struct client *c = arg; struct client *c = arg;
@@ -1138,7 +1262,7 @@ server_client_dispatch(struct imsg *imsg, void *arg)
} }
/* Handle command message. */ /* Handle command message. */
void static void
server_client_dispatch_command(struct client *c, struct imsg *imsg) server_client_dispatch_command(struct client *c, struct imsg *imsg)
{ {
struct msg_command_data data; struct msg_command_data data;
@@ -1191,7 +1315,7 @@ error:
} }
/* Handle identify message. */ /* Handle identify message. */
void static void
server_client_dispatch_identify(struct client *c, struct imsg *imsg) server_client_dispatch_identify(struct client *c, struct imsg *imsg)
{ {
const char *data, *home; const char *data, *home;
@@ -1303,7 +1427,7 @@ server_client_dispatch_identify(struct client *c, struct imsg *imsg)
} }
/* Handle shell message. */ /* Handle shell message. */
void static void
server_client_dispatch_shell(struct client *c) server_client_dispatch_shell(struct client *c)
{ {
const char *shell; const char *shell;

View File

@@ -26,8 +26,9 @@
#include "tmux.h" #include "tmux.h"
struct session *server_next_session(struct session *); static struct session *server_next_session(struct session *);
void server_callback_identify(int, short, void *); static void server_callback_identify(int, short, void *);
static void server_destroy_session_group(struct session *);
void void
server_fill_environ(struct session *s, struct environ *env) server_fill_environ(struct session *s, struct environ *env)
@@ -340,7 +341,7 @@ server_destroy_pane(struct window_pane *wp, int hooks)
server_redraw_window(w); server_redraw_window(w);
} }
void static void
server_destroy_session_group(struct session *s) server_destroy_session_group(struct session *s)
{ {
struct session_group *sg; struct session_group *sg;
@@ -356,7 +357,7 @@ server_destroy_session_group(struct session *s)
} }
} }
struct session * static struct session *
server_next_session(struct session *s) server_next_session(struct session *s)
{ {
struct session *s_loop, *s_out; struct session *s_loop, *s_out;
@@ -455,7 +456,7 @@ server_clear_identify(struct client *c, struct window_pane *wp)
server_redraw_client(c); server_redraw_client(c);
} }
void static void
server_callback_identify(__unused int fd, __unused short events, void *data) server_callback_identify(__unused int fd, __unused short events, void *data)
{ {
server_clear_identify(data, NULL); server_clear_identify(data, NULL);

View File

@@ -43,21 +43,20 @@
struct clients clients; struct clients clients;
struct tmuxproc *server_proc; struct tmuxproc *server_proc;
int server_fd; static int server_fd;
int server_exit; static int server_exit;
struct event server_ev_accept; static struct event server_ev_accept;
struct cmd_find_state marked_pane; struct cmd_find_state marked_pane;
int server_create_socket(void); static int server_create_socket(void);
int server_loop(void); static int server_loop(void);
int server_should_exit(void); static void server_send_exit(void);
void server_send_exit(void); static void server_accept(int, short, void *);
void server_accept(int, short, void *); static void server_signal(int);
void server_signal(int); static void server_child_signal(void);
void server_child_signal(void); static void server_child_exited(pid_t, int);
void server_child_exited(pid_t, int); static void server_child_stopped(pid_t, int);
void server_child_stopped(pid_t, int);
/* Set marked pane. */ /* Set marked pane. */
void void
@@ -98,7 +97,7 @@ server_check_marked(void)
} }
/* Create server socket. */ /* Create server socket. */
int static int
server_create_socket(void) server_create_socket(void)
{ {
struct sockaddr_un sa; struct sockaddr_un sa;
@@ -189,7 +188,7 @@ server_start(struct event_base *base, int lockfd, char *lockfile)
} }
/* Server loop callback. */ /* Server loop callback. */
int static int
server_loop(void) server_loop(void)
{ {
struct client *c; struct client *c;
@@ -218,7 +217,7 @@ server_loop(void)
} }
/* Exit the server by killing all clients and windows. */ /* Exit the server by killing all clients and windows. */
void static void
server_send_exit(void) server_send_exit(void)
{ {
struct client *c, *c1; struct client *c, *c1;
@@ -275,7 +274,7 @@ server_update_socket(void)
} }
/* Callback for server socket. */ /* Callback for server socket. */
void static void
server_accept(int fd, short events, __unused void *data) server_accept(int fd, short events, __unused void *data)
{ {
struct sockaddr_storage sa; struct sockaddr_storage sa;
@@ -328,7 +327,7 @@ server_add_accept(int timeout)
} }
/* Signal handler. */ /* Signal handler. */
void static void
server_signal(int sig) server_signal(int sig)
{ {
int fd; int fd;
@@ -355,7 +354,7 @@ server_signal(int sig)
} }
/* Handle SIGCHLD. */ /* Handle SIGCHLD. */
void static void
server_child_signal(void) server_child_signal(void)
{ {
int status; int status;
@@ -378,7 +377,7 @@ server_child_signal(void)
} }
/* Handle exited children. */ /* Handle exited children. */
void static void
server_child_exited(pid_t pid, int status) server_child_exited(pid_t pid, int status)
{ {
struct window *w, *w1; struct window *w, *w1;
@@ -404,7 +403,7 @@ server_child_exited(pid_t pid, int status)
} }
/* Handle stopped children. */ /* Handle stopped children. */
void static void
server_child_stopped(pid_t pid, int status) server_child_stopped(pid_t pid, int status)
{ {
struct window *w; struct window *w;

View File

@@ -26,16 +26,20 @@
#include "tmux.h" #include "tmux.h"
struct sessions sessions; struct sessions sessions;
u_int next_session_id; static u_int next_session_id;
struct session_groups session_groups; struct session_groups session_groups;
void session_free(int, short, void *); static void session_free(int, short, void *);
void session_lock_timer(int, short, void *); static void session_lock_timer(int, short, void *);
struct winlink *session_next_alert(struct winlink *); static struct winlink *session_next_alert(struct winlink *);
struct winlink *session_previous_alert(struct winlink *); static struct winlink *session_previous_alert(struct winlink *);
static void session_group_remove(struct session *);
static u_int session_group_count(struct session_group *);
static void session_group_synchronize1(struct session *, struct session *);
RB_GENERATE(sessions, session, entry, session_cmp); RB_GENERATE(sessions, session, entry, session_cmp);
@@ -181,7 +185,7 @@ session_unref(struct session *s)
} }
/* Free session. */ /* Free session. */
void static void
session_free(__unused int fd, __unused short events, void *arg) session_free(__unused int fd, __unused short events, void *arg)
{ {
struct session *s = arg; struct session *s = arg;
@@ -238,7 +242,7 @@ session_check_name(const char *name)
} }
/* Lock session if it has timed out. */ /* Lock session if it has timed out. */
void static void
session_lock_timer(__unused int fd, __unused short events, void *arg) session_lock_timer(__unused int fd, __unused short events, void *arg)
{ {
struct session *s = arg; struct session *s = arg;
@@ -425,7 +429,7 @@ session_is_linked(struct session *s, struct window *w)
return (w->references != 1); return (w->references != 1);
} }
struct winlink * static struct winlink *
session_next_alert(struct winlink *wl) session_next_alert(struct winlink *wl)
{ {
while (wl != NULL) { while (wl != NULL) {
@@ -456,7 +460,7 @@ session_next(struct session *s, int alert)
return (session_set_current(s, wl)); return (session_set_current(s, wl));
} }
struct winlink * static struct winlink *
session_previous_alert(struct winlink *wl) session_previous_alert(struct winlink *wl)
{ {
while (wl != NULL) { while (wl != NULL) {
@@ -581,7 +585,7 @@ session_group_add(struct session *target, struct session *s)
} }
/* Remove a session from its group and destroy the group if empty. */ /* Remove a session from its group and destroy the group if empty. */
void static void
session_group_remove(struct session *s) session_group_remove(struct session *s)
{ {
struct session_group *sg; struct session_group *sg;
@@ -598,7 +602,7 @@ session_group_remove(struct session *s)
} }
/* Count number of sessions in session group. */ /* Count number of sessions in session group. */
u_int static u_int
session_group_count(struct session_group *sg) session_group_count(struct session_group *sg)
{ {
struct session *s; struct session *s;
@@ -649,7 +653,7 @@ session_group_synchronize_from(struct session *target)
* winlinks then recreating them, then updating the current window, last window * winlinks then recreating them, then updating the current window, last window
* stack and alerts. * stack and alerts.
*/ */
void static void
session_group_synchronize1(struct session *target, struct session *s) session_group_synchronize1(struct session *target, struct session *s)
{ {
struct winlinks old_windows, *ww; struct winlinks old_windows, *ww;

View File

@@ -24,12 +24,12 @@
#include "tmux.h" #include "tmux.h"
struct event ev_sighup; static struct event ev_sighup;
struct event ev_sigchld; static struct event ev_sigchld;
struct event ev_sigcont; static struct event ev_sigcont;
struct event ev_sigterm; static struct event ev_sigterm;
struct event ev_sigusr1; static struct event ev_sigusr1;
struct event ev_sigwinch; static struct event ev_sigwinch;
void void
set_signals(void (*handler)(int, short, void *), void *arg) set_signals(void (*handler)(int, short, void *), void *arg)

382
status.c
View File

@@ -29,33 +29,33 @@
#include "tmux.h" #include "tmux.h"
char *status_redraw_get_left(struct client *, time_t, struct grid_cell *, static char *status_redraw_get_left(struct client *, time_t,
size_t *); struct grid_cell *, size_t *);
char *status_redraw_get_right(struct client *, time_t, struct grid_cell *, static char *status_redraw_get_right(struct client *, time_t,
size_t *); struct grid_cell *, size_t *);
char *status_print(struct client *, struct winlink *, time_t, static char *status_print(struct client *, struct winlink *, time_t,
struct grid_cell *); struct grid_cell *);
char *status_replace(struct client *, struct winlink *, const char *, time_t); static char *status_replace(struct client *, struct winlink *, const char *,
void status_message_callback(int, short, void *); time_t);
void status_timer_callback(int, short, void *); static void status_message_callback(int, short, void *);
static void status_timer_callback(int, short, void *);
const char *status_prompt_up_history(u_int *); static char *status_prompt_find_history_file(void);
const char *status_prompt_down_history(u_int *); static const char *status_prompt_up_history(u_int *);
void status_prompt_add_history(const char *); static const char *status_prompt_down_history(u_int *);
static void status_prompt_add_history(const char *);
const char **status_prompt_complete_list(u_int *, const char *); static const char **status_prompt_complete_list(u_int *, const char *);
char *status_prompt_complete_prefix(const char **, u_int); static char *status_prompt_complete_prefix(const char **, u_int);
char *status_prompt_complete(struct session *, const char *); static char *status_prompt_complete(struct session *, const char *);
char *status_prompt_find_history_file(void);
/* Status prompt history. */ /* Status prompt history. */
#define PROMPT_HISTORY 100 #define PROMPT_HISTORY 100
char **status_prompt_hlist; static char **status_prompt_hlist;
u_int status_prompt_hsize; static u_int status_prompt_hsize;
/* Find the history file to load/save from/to. */ /* Find the history file to load/save from/to. */
char * static char *
status_prompt_find_history_file(void) status_prompt_find_history_file(void)
{ {
const char *home, *history_file; const char *home, *history_file;
@@ -144,7 +144,7 @@ status_prompt_save_history(void)
} }
/* Status timer callback. */ /* Status timer callback. */
void static void
status_timer_callback(__unused int fd, __unused short events, void *arg) status_timer_callback(__unused int fd, __unused short events, void *arg)
{ {
struct client *c = arg; struct client *c = arg;
@@ -207,7 +207,7 @@ status_at_line(struct client *c)
} }
/* Retrieve options for left string. */ /* Retrieve options for left string. */
char * static char *
status_redraw_get_left(struct client *c, time_t t, struct grid_cell *gc, status_redraw_get_left(struct client *c, time_t t, struct grid_cell *gc,
size_t *size) size_t *size)
{ {
@@ -229,7 +229,7 @@ status_redraw_get_left(struct client *c, time_t t, struct grid_cell *gc,
} }
/* Retrieve options for right string. */ /* Retrieve options for right string. */
char * static char *
status_redraw_get_right(struct client *c, time_t t, struct grid_cell *gc, status_redraw_get_right(struct client *c, time_t t, struct grid_cell *gc,
size_t *size) size_t *size)
{ {
@@ -493,7 +493,7 @@ out:
} }
/* Replace special sequences in fmt. */ /* Replace special sequences in fmt. */
char * static char *
status_replace(struct client *c, struct winlink *wl, const char *fmt, time_t t) status_replace(struct client *c, struct winlink *wl, const char *fmt, time_t t)
{ {
struct format_tree *ft; struct format_tree *ft;
@@ -515,7 +515,7 @@ status_replace(struct client *c, struct winlink *wl, const char *fmt, time_t t)
} }
/* Return winlink status line entry and adjust gc as necessary. */ /* Return winlink status line entry and adjust gc as necessary. */
char * static char *
status_print(struct client *c, struct winlink *wl, time_t t, status_print(struct client *c, struct winlink *wl, time_t t,
struct grid_cell *gc) struct grid_cell *gc)
{ {
@@ -607,7 +607,7 @@ status_message_clear(struct client *c)
} }
/* Clear status line message after timer expires. */ /* Clear status line message after timer expires. */
void static void
status_message_callback(__unused int fd, __unused short event, void *data) status_message_callback(__unused int fd, __unused short event, void *data)
{ {
struct client *c = data; struct client *c = data;
@@ -662,18 +662,21 @@ status_prompt_set(struct client *c, const char *msg, const char *input,
struct format_tree *ft; struct format_tree *ft;
int keys; int keys;
time_t t; time_t t;
char *tmp;
ft = format_create(NULL, 0); ft = format_create(NULL, 0);
format_defaults(ft, c, NULL, NULL, NULL); format_defaults(ft, c, NULL, NULL, NULL);
t = time(NULL); t = time(NULL);
tmp = format_expand_time(ft, input, t);
status_message_clear(c); status_message_clear(c);
status_prompt_clear(c); status_prompt_clear(c);
c->prompt_string = format_expand_time(ft, msg, t); c->prompt_string = format_expand_time(ft, msg, t);
c->prompt_buffer = format_expand_time(ft, input, t); c->prompt_buffer = utf8_fromcstr(tmp);
c->prompt_index = strlen(c->prompt_buffer); c->prompt_index = utf8_strlen(c->prompt_buffer);
c->prompt_callbackfn = callbackfn; c->prompt_callbackfn = callbackfn;
c->prompt_freefn = freefn; c->prompt_freefn = freefn;
@@ -692,6 +695,7 @@ status_prompt_set(struct client *c, const char *msg, const char *input,
c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE); c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
free(tmp);
format_free(ft); format_free(ft);
} }
@@ -723,22 +727,26 @@ status_prompt_update(struct client *c, const char *msg, const char *input)
{ {
struct format_tree *ft; struct format_tree *ft;
time_t t; time_t t;
char *tmp;
ft = format_create(NULL, 0); ft = format_create(NULL, 0);
format_defaults(ft, c, NULL, NULL, NULL); format_defaults(ft, c, NULL, NULL, NULL);
t = time(NULL); t = time(NULL);
tmp = format_expand_time(ft, input, t);
free(c->prompt_string); free(c->prompt_string);
c->prompt_string = format_expand_time(ft, msg, t); c->prompt_string = format_expand_time(ft, msg, t);
free(c->prompt_buffer); free(c->prompt_buffer);
c->prompt_buffer = format_expand_time(ft, input, t); c->prompt_buffer = utf8_fromcstr(tmp);
c->prompt_index = strlen(c->prompt_buffer); c->prompt_index = utf8_strlen(c->prompt_buffer);
c->prompt_hindex = 0; c->prompt_hindex = 0;
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
free(tmp);
format_free(ft); format_free(ft);
} }
@@ -746,57 +754,80 @@ status_prompt_update(struct client *c, const char *msg, const char *input)
int int
status_prompt_redraw(struct client *c) status_prompt_redraw(struct client *c)
{ {
struct screen_write_ctx ctx; struct screen_write_ctx ctx;
struct session *s = c->session; struct session *s = c->session;
struct screen old_status; struct screen old_status;
size_t i, size, left, len, off; u_int i, offset, left, start, pcursor, pwidth, width;
struct grid_cell gc; struct grid_cell gc, cursorgc;
if (c->tty.sx == 0 || c->tty.sy == 0) if (c->tty.sx == 0 || c->tty.sy == 0)
return (0); return (0);
memcpy(&old_status, &c->status, sizeof old_status); memcpy(&old_status, &c->status, sizeof old_status);
screen_init(&c->status, c->tty.sx, 1, 0); screen_init(&c->status, c->tty.sx, 1, 0);
len = screen_write_strlen("%s", c->prompt_string);
if (len > c->tty.sx)
len = c->tty.sx;
off = 0;
/* Change colours for command mode. */
if (c->prompt_mdata.mode == 1) if (c->prompt_mdata.mode == 1)
style_apply(&gc, s->options, "message-command-style"); style_apply(&gc, s->options, "message-command-style");
else else
style_apply(&gc, s->options, "message-style"); style_apply(&gc, s->options, "message-style");
memcpy(&cursorgc, &gc, sizeof cursorgc);
cursorgc.attr ^= GRID_ATTR_REVERSE;
start = screen_write_strlen("%s", c->prompt_string);
if (start > c->tty.sx)
start = c->tty.sx;
screen_write_start(&ctx, NULL, &c->status); screen_write_start(&ctx, NULL, &c->status);
screen_write_cursormove(&ctx, 0, 0); screen_write_cursormove(&ctx, 0, 0);
screen_write_nputs(&ctx, len, &gc, "%s", c->prompt_string); screen_write_nputs(&ctx, start, &gc, "%s", c->prompt_string);
while (c->status.cx < screen_size_x(&c->status))
screen_write_putc(&ctx, &gc, ' ');
screen_write_cursormove(&ctx, start, 0);
left = c->tty.sx - len; left = c->tty.sx - start;
if (left != 0) { if (left == 0)
size = screen_write_strlen("%s", c->prompt_buffer); goto finished;
if (c->prompt_index >= left) {
off = c->prompt_index - left + 1; pcursor = utf8_strwidth(c->prompt_buffer, c->prompt_index);
if (c->prompt_index == size) pwidth = utf8_strwidth(c->prompt_buffer, -1);
left--; if (pcursor >= left) {
size = left; /*
* The cursor would be outside the screen so start drawing
* with it on the right.
*/
offset = (pcursor - left) + 1;
pwidth = left;
} else
offset = 0;
if (pwidth > left)
pwidth = left;
width = 0;
for (i = 0; c->prompt_buffer[i].size != 0; i++) {
if (width < offset) {
width += c->prompt_buffer[i].width;
continue;
} }
screen_write_nputs(&ctx, left, &gc, "%s", c->prompt_buffer + if (width >= offset + pwidth)
off); break;
width += c->prompt_buffer[i].width;
if (width > offset + pwidth)
break;
for (i = len + size; i < c->tty.sx; i++) if (i != c->prompt_index) {
screen_write_putc(&ctx, &gc, ' '); utf8_copy(&gc.data, &c->prompt_buffer[i]);
screen_write_cell(&ctx, &gc);
} else {
utf8_copy(&cursorgc.data, &c->prompt_buffer[i]);
screen_write_cell(&ctx, &cursorgc);
}
} }
if (c->status.cx < screen_size_x(&c->status) && c->prompt_index >= i)
screen_write_putc(&ctx, &cursorgc, ' ');
finished:
screen_write_stop(&ctx); screen_write_stop(&ctx);
/* Apply fake cursor. */
off = len + c->prompt_index - off;
grid_view_get_cell(c->status.grid, off, 0, &gc);
gc.attr ^= GRID_ATTR_REVERSE;
grid_view_set_cell(c->status.grid, off, 0, &gc);
if (grid_compare(c->status.grid, old_status.grid) == 0) { if (grid_compare(c->status.grid, old_status.grid) == 0) {
screen_free(&old_status); screen_free(&old_status);
return (0); return (0);
@@ -805,20 +836,38 @@ status_prompt_redraw(struct client *c)
return (1); return (1);
} }
/* Is this a separator? */
static int
status_prompt_in_list(const char *ws, const struct utf8_data *ud)
{
if (ud->size != 1 || ud->width != 1)
return (0);
return (strchr(ws, *ud->data) != NULL);
}
/* Is this a space? */
static int
status_prompt_space(const struct utf8_data *ud)
{
if (ud->size != 1 || ud->width != 1)
return (0);
return (*ud->data == ' ');
}
/* Handle keys in prompt. */ /* Handle keys in prompt. */
void void
status_prompt_key(struct client *c, key_code key) status_prompt_key(struct client *c, key_code key)
{ {
struct session *sess = c->session; struct options *oo = c->session->options;
struct options *oo = sess->options;
struct paste_buffer *pb; struct paste_buffer *pb;
char *s, *first, *last, word[64], swapc; char *s, word[64];
const char *histstr, *bufdata, *wsep = NULL; const char *histstr, *bufdata, *ws = NULL;
u_char ch; u_char ch;
size_t size, n, off, idx, bufsize; size_t size, n, off, idx, bufsize, used;
struct utf8_data tmp, *first, *last, *ud;
size = strlen(c->prompt_buffer); size = utf8_strlen(c->prompt_buffer);
switch (mode_key_lookup(&c->prompt_mdata, key, NULL, NULL)) { switch (mode_key_lookup(&c->prompt_mdata, key)) {
case MODEKEYEDIT_CURSORLEFT: case MODEKEYEDIT_CURSORLEFT:
if (c->prompt_index > 0) { if (c->prompt_index > 0) {
c->prompt_index--; c->prompt_index--;
@@ -856,7 +905,7 @@ status_prompt_key(struct client *c, key_code key)
} }
break; break;
case MODEKEYEDIT_COMPLETE: case MODEKEYEDIT_COMPLETE:
if (*c->prompt_buffer == '\0') if (c->prompt_buffer[0].size == 0)
break; break;
idx = c->prompt_index; idx = c->prompt_index;
@@ -864,40 +913,50 @@ status_prompt_key(struct client *c, key_code key)
idx--; idx--;
/* Find the word we are in. */ /* Find the word we are in. */
first = c->prompt_buffer + idx; first = &c->prompt_buffer[idx];
while (first > c->prompt_buffer && *first != ' ') while (first > c->prompt_buffer && !status_prompt_space(first))
first--; first--;
while (*first == ' ') while (first->size != 0 && status_prompt_space(first))
first++; first++;
last = c->prompt_buffer + idx; last = &c->prompt_buffer[idx];
while (*last != '\0' && *last != ' ') while (last->size != 0 && !status_prompt_space(last))
last++; last++;
while (*last == ' ') while (last > c->prompt_buffer && status_prompt_space(last))
last--; last--;
if (*last != '\0') if (last->size != 0)
last++; last++;
if (last <= first || if (last <= first)
((size_t) (last - first)) > (sizeof word) - 1)
break; break;
memcpy(word, first, last - first);
word[last - first] = '\0'; used = 0;
for (ud = first; ud < last; ud++) {
if (used + ud->size >= sizeof word)
break;
memcpy(word + used, ud->data, ud->size);
used += ud->size;
}
if (ud != last)
break;
word[used] = '\0';
/* And try to complete it. */ /* And try to complete it. */
if ((s = status_prompt_complete(sess, word)) == NULL) if ((s = status_prompt_complete(c->session, word)) == NULL)
break; break;
/* Trim out word. */ /* Trim out word. */
n = size - (last - c->prompt_buffer) + 1; /* with \0 */ n = size - (last - c->prompt_buffer) + 1; /* with \0 */
memmove(first, last, n); memmove(first, last, n * sizeof *c->prompt_buffer);
size -= last - first; size -= last - first;
/* Insert the new word. */ /* Insert the new word. */
size += strlen(s); size += strlen(s);
off = first - c->prompt_buffer; off = first - c->prompt_buffer;
c->prompt_buffer = xrealloc(c->prompt_buffer, size + 1); c->prompt_buffer = xreallocarray(c->prompt_buffer, size + 1,
sizeof *c->prompt_buffer);
first = c->prompt_buffer + off; first = c->prompt_buffer + off;
memmove(first + strlen(s), first, n); memmove(first + strlen(s), first, n * sizeof *c->prompt_buffer);
memcpy(first, s, strlen(s)); for (idx = 0; idx < strlen(s); idx++)
utf8_set(&first[idx], s[idx]);
c->prompt_index = (first - c->prompt_buffer) + strlen(s); c->prompt_index = (first - c->prompt_buffer) + strlen(s);
free(s); free(s);
@@ -907,11 +966,12 @@ status_prompt_key(struct client *c, key_code key)
case MODEKEYEDIT_BACKSPACE: case MODEKEYEDIT_BACKSPACE:
if (c->prompt_index != 0) { if (c->prompt_index != 0) {
if (c->prompt_index == size) if (c->prompt_index == size)
c->prompt_buffer[--c->prompt_index] = '\0'; c->prompt_buffer[--c->prompt_index].size = 0;
else { else {
memmove(c->prompt_buffer + c->prompt_index - 1, memmove(c->prompt_buffer + c->prompt_index - 1,
c->prompt_buffer + c->prompt_index, c->prompt_buffer + c->prompt_index,
size + 1 - c->prompt_index); (size + 1 - c->prompt_index) *
sizeof *c->prompt_buffer);
c->prompt_index--; c->prompt_index--;
} }
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
@@ -922,38 +982,39 @@ status_prompt_key(struct client *c, key_code key)
if (c->prompt_index != size) { if (c->prompt_index != size) {
memmove(c->prompt_buffer + c->prompt_index, memmove(c->prompt_buffer + c->prompt_index,
c->prompt_buffer + c->prompt_index + 1, c->prompt_buffer + c->prompt_index + 1,
size + 1 - c->prompt_index); (size + 1 - c->prompt_index) *
sizeof *c->prompt_buffer);
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
} }
break; break;
case MODEKEYEDIT_DELETELINE: case MODEKEYEDIT_DELETELINE:
case MODEKEYEDIT_SWITCHMODESUBSTITUTELINE: case MODEKEYEDIT_SWITCHMODESUBSTITUTELINE:
*c->prompt_buffer = '\0'; c->prompt_buffer[0].size = 0;
c->prompt_index = 0; c->prompt_index = 0;
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
break; break;
case MODEKEYEDIT_DELETETOENDOFLINE: case MODEKEYEDIT_DELETETOENDOFLINE:
case MODEKEYEDIT_SWITCHMODECHANGELINE: case MODEKEYEDIT_SWITCHMODECHANGELINE:
if (c->prompt_index < size) { if (c->prompt_index < size) {
c->prompt_buffer[c->prompt_index] = '\0'; c->prompt_buffer[c->prompt_index].size = 0;
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
} }
break; break;
case MODEKEYEDIT_DELETEWORD: case MODEKEYEDIT_DELETEWORD:
wsep = options_get_string(oo, "word-separators"); ws = options_get_string(oo, "word-separators");
idx = c->prompt_index; idx = c->prompt_index;
/* Find a non-separator. */ /* Find a non-separator. */
while (idx != 0) { while (idx != 0) {
idx--; idx--;
if (!strchr(wsep, c->prompt_buffer[idx])) if (!status_prompt_in_list(ws, &c->prompt_buffer[idx]))
break; break;
} }
/* Find the separator at the beginning of the word. */ /* Find the separator at the beginning of the word. */
while (idx != 0) { while (idx != 0) {
idx--; idx--;
if (strchr(wsep, c->prompt_buffer[idx])) { if (status_prompt_in_list(ws, &c->prompt_buffer[idx])) {
/* Go back to the word. */ /* Go back to the word. */
idx++; idx++;
break; break;
@@ -962,53 +1023,55 @@ status_prompt_key(struct client *c, key_code key)
memmove(c->prompt_buffer + idx, memmove(c->prompt_buffer + idx,
c->prompt_buffer + c->prompt_index, c->prompt_buffer + c->prompt_index,
size + 1 - c->prompt_index); (size + 1 - c->prompt_index) *
sizeof *c->prompt_buffer);
memset(c->prompt_buffer + size - (c->prompt_index - idx), memset(c->prompt_buffer + size - (c->prompt_index - idx),
'\0', c->prompt_index - idx); '\0', (c->prompt_index - idx) * sizeof *c->prompt_buffer);
c->prompt_index = idx; c->prompt_index = idx;
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
break; break;
case MODEKEYEDIT_NEXTSPACE: case MODEKEYEDIT_NEXTSPACE:
wsep = " "; ws = " ";
/* FALLTHROUGH */ /* FALLTHROUGH */
case MODEKEYEDIT_NEXTWORD: case MODEKEYEDIT_NEXTWORD:
if (wsep == NULL) if (ws == NULL)
wsep = options_get_string(oo, "word-separators"); ws = options_get_string(oo, "word-separators");
/* Find a separator. */ /* Find a separator. */
while (c->prompt_index != size) { while (c->prompt_index != size) {
c->prompt_index++; idx = ++c->prompt_index;
if (strchr(wsep, c->prompt_buffer[c->prompt_index])) if (status_prompt_in_list(ws, &c->prompt_buffer[idx]))
break; break;
} }
/* Find the word right after the separation. */ /* Find the word right after the separator. */
while (c->prompt_index != size) { while (c->prompt_index != size) {
c->prompt_index++; idx = ++c->prompt_index;
if (!strchr(wsep, c->prompt_buffer[c->prompt_index])) if (!status_prompt_in_list(ws, &c->prompt_buffer[idx]))
break; break;
} }
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
break; break;
case MODEKEYEDIT_NEXTSPACEEND: case MODEKEYEDIT_NEXTSPACEEND:
wsep = " "; ws = " ";
/* FALLTHROUGH */ /* FALLTHROUGH */
case MODEKEYEDIT_NEXTWORDEND: case MODEKEYEDIT_NEXTWORDEND:
if (wsep == NULL) if (ws == NULL)
wsep = options_get_string(oo, "word-separators"); ws = options_get_string(oo, "word-separators");
/* Find a word. */ /* Find a word. */
while (c->prompt_index != size) { while (c->prompt_index != size) {
c->prompt_index++; idx = ++c->prompt_index;
if (!strchr(wsep, c->prompt_buffer[c->prompt_index])) if (!status_prompt_in_list(ws, &c->prompt_buffer[idx]))
break; break;
} }
/* Find the separator at the end of the word. */ /* Find the separator at the end of the word. */
while (c->prompt_index != size) { while (c->prompt_index != size) {
c->prompt_index++; idx = ++c->prompt_index;
if (strchr(wsep, c->prompt_buffer[c->prompt_index])) if (status_prompt_in_list(ws, &c->prompt_buffer[idx]))
break; break;
} }
@@ -1020,23 +1083,23 @@ status_prompt_key(struct client *c, key_code key)
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
break; break;
case MODEKEYEDIT_PREVIOUSSPACE: case MODEKEYEDIT_PREVIOUSSPACE:
wsep = " "; ws = " ";
/* FALLTHROUGH */ /* FALLTHROUGH */
case MODEKEYEDIT_PREVIOUSWORD: case MODEKEYEDIT_PREVIOUSWORD:
if (wsep == NULL) if (ws == NULL)
wsep = options_get_string(oo, "word-separators"); ws = options_get_string(oo, "word-separators");
/* Find a non-separator. */ /* Find a non-separator. */
while (c->prompt_index != 0) { while (c->prompt_index != 0) {
c->prompt_index--; idx = --c->prompt_index;
if (!strchr(wsep, c->prompt_buffer[c->prompt_index])) if (!status_prompt_in_list(ws, &c->prompt_buffer[idx]))
break; break;
} }
/* Find the separator at the beginning of the word. */ /* Find the separator at the beginning of the word. */
while (c->prompt_index != 0) { while (c->prompt_index != 0) {
c->prompt_index--; idx = --c->prompt_index;
if (strchr(wsep, c->prompt_buffer[c->prompt_index])) { if (status_prompt_in_list(ws, &c->prompt_buffer[idx])) {
/* Go back to the word. */ /* Go back to the word. */
c->prompt_index++; c->prompt_index++;
break; break;
@@ -1050,8 +1113,8 @@ status_prompt_key(struct client *c, key_code key)
if (histstr == NULL) if (histstr == NULL)
break; break;
free(c->prompt_buffer); free(c->prompt_buffer);
c->prompt_buffer = xstrdup(histstr); c->prompt_buffer = utf8_fromcstr(histstr);
c->prompt_index = strlen(c->prompt_buffer); c->prompt_index = utf8_strlen(c->prompt_buffer);
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
break; break;
case MODEKEYEDIT_HISTORYDOWN: case MODEKEYEDIT_HISTORYDOWN:
@@ -1059,8 +1122,8 @@ status_prompt_key(struct client *c, key_code key)
if (histstr == NULL) if (histstr == NULL)
break; break;
free(c->prompt_buffer); free(c->prompt_buffer);
c->prompt_buffer = xstrdup(histstr); c->prompt_buffer = utf8_fromcstr(histstr);
c->prompt_index = strlen(c->prompt_buffer); c->prompt_index = utf8_strlen(c->prompt_buffer);
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
break; break;
case MODEKEYEDIT_PASTE: case MODEKEYEDIT_PASTE:
@@ -1069,20 +1132,28 @@ status_prompt_key(struct client *c, key_code key)
bufdata = paste_buffer_data(pb, &bufsize); bufdata = paste_buffer_data(pb, &bufsize);
for (n = 0; n < bufsize; n++) { for (n = 0; n < bufsize; n++) {
ch = (u_char)bufdata[n]; ch = (u_char)bufdata[n];
if (ch < 32 || ch == 127) if (ch < 32 || ch >= 127)
break; break;
} }
c->prompt_buffer = xrealloc(c->prompt_buffer, size + n + 1); c->prompt_buffer = xreallocarray(c->prompt_buffer, size + n + 1,
sizeof *c->prompt_buffer);
if (c->prompt_index == size) { if (c->prompt_index == size) {
memcpy(c->prompt_buffer + c->prompt_index, bufdata, n); for (idx = 0; idx < n; idx++) {
ud = &c->prompt_buffer[c->prompt_index + idx];
utf8_set(ud, bufdata[idx]);
}
c->prompt_index += n; c->prompt_index += n;
c->prompt_buffer[c->prompt_index] = '\0'; c->prompt_buffer[c->prompt_index].size = 0;
} else { } else {
memmove(c->prompt_buffer + c->prompt_index + n, memmove(c->prompt_buffer + c->prompt_index + n,
c->prompt_buffer + c->prompt_index, c->prompt_buffer + c->prompt_index,
size + 1 - c->prompt_index); (size + 1 - c->prompt_index) *
memcpy(c->prompt_buffer + c->prompt_index, bufdata, n); sizeof *c->prompt_buffer);
for (idx = 0; idx < n; idx++) {
ud = &c->prompt_buffer[c->prompt_index + idx];
utf8_set(ud, bufdata[idx]);
}
c->prompt_index += n; c->prompt_index += n;
} }
@@ -1093,42 +1164,55 @@ status_prompt_key(struct client *c, key_code key)
if (idx < size) if (idx < size)
idx++; idx++;
if (idx >= 2) { if (idx >= 2) {
swapc = c->prompt_buffer[idx - 2]; utf8_copy(&tmp, &c->prompt_buffer[idx - 2]);
c->prompt_buffer[idx - 2] = c->prompt_buffer[idx - 1]; utf8_copy(&c->prompt_buffer[idx - 2],
c->prompt_buffer[idx - 1] = swapc; &c->prompt_buffer[idx - 1]);
utf8_copy(&c->prompt_buffer[idx - 1], &tmp);
c->prompt_index = idx; c->prompt_index = idx;
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
} }
break; break;
case MODEKEYEDIT_ENTER: case MODEKEYEDIT_ENTER:
if (*c->prompt_buffer != '\0') s = utf8_tocstr(c->prompt_buffer);
status_prompt_add_history(c->prompt_buffer); if (*s != '\0')
if (c->prompt_callbackfn(c->prompt_data, c->prompt_buffer) == 0) status_prompt_add_history(s);
if (c->prompt_callbackfn(c->prompt_data, s) == 0)
status_prompt_clear(c); status_prompt_clear(c);
free(s);
break; break;
case MODEKEYEDIT_CANCEL: case MODEKEYEDIT_CANCEL:
if (c->prompt_callbackfn(c->prompt_data, NULL) == 0) if (c->prompt_callbackfn(c->prompt_data, NULL) == 0)
status_prompt_clear(c); status_prompt_clear(c);
break; break;
case MODEKEY_OTHER: case MODEKEY_OTHER:
if (key <= 0x1f || key >= 0x7f) if (key <= 0x1f || key >= KEYC_BASE)
break; break;
c->prompt_buffer = xrealloc(c->prompt_buffer, size + 2); if (utf8_split(key, &tmp) != UTF8_DONE)
break;
c->prompt_buffer = xreallocarray(c->prompt_buffer, size + 2,
sizeof *c->prompt_buffer);
if (c->prompt_index == size) { if (c->prompt_index == size) {
c->prompt_buffer[c->prompt_index++] = key; utf8_copy(&c->prompt_buffer[c->prompt_index], &tmp);
c->prompt_buffer[c->prompt_index] = '\0'; c->prompt_index++;
c->prompt_buffer[c->prompt_index].size = 0;
} else { } else {
memmove(c->prompt_buffer + c->prompt_index + 1, memmove(c->prompt_buffer + c->prompt_index + 1,
c->prompt_buffer + c->prompt_index, c->prompt_buffer + c->prompt_index,
size + 1 - c->prompt_index); (size + 1 - c->prompt_index) *
c->prompt_buffer[c->prompt_index++] = key; sizeof *c->prompt_buffer);
utf8_copy(&c->prompt_buffer[c->prompt_index], &tmp);
c->prompt_index++;
} }
if (c->prompt_flags & PROMPT_SINGLE) { if (c->prompt_flags & PROMPT_SINGLE) {
if (c->prompt_callbackfn(c->prompt_data, s = utf8_tocstr(c->prompt_buffer);
c->prompt_buffer) == 0) if (strlen(s) != 1)
status_prompt_clear(c); status_prompt_clear(c);
else if (c->prompt_callbackfn(c->prompt_data, s) == 0)
status_prompt_clear(c);
free(s);
} }
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
@@ -1139,7 +1223,7 @@ status_prompt_key(struct client *c, key_code key)
} }
/* Get previous line from the history. */ /* Get previous line from the history. */
const char * static const char *
status_prompt_up_history(u_int *idx) status_prompt_up_history(u_int *idx)
{ {
/* /*
@@ -1154,7 +1238,7 @@ status_prompt_up_history(u_int *idx)
} }
/* Get next line from the history. */ /* Get next line from the history. */
const char * static const char *
status_prompt_down_history(u_int *idx) status_prompt_down_history(u_int *idx)
{ {
if (status_prompt_hsize == 0 || *idx == 0) if (status_prompt_hsize == 0 || *idx == 0)
@@ -1166,7 +1250,7 @@ status_prompt_down_history(u_int *idx)
} }
/* Add line to the history. */ /* Add line to the history. */
void static void
status_prompt_add_history(const char *line) status_prompt_add_history(const char *line)
{ {
size_t size; size_t size;
@@ -1191,7 +1275,7 @@ status_prompt_add_history(const char *line)
} }
/* Build completion list. */ /* Build completion list. */
const char ** static const char **
status_prompt_complete_list(u_int *size, const char *s) status_prompt_complete_list(u_int *size, const char *s)
{ {
const char **list = NULL, **layout; const char **list = NULL, **layout;
@@ -1225,7 +1309,7 @@ status_prompt_complete_list(u_int *size, const char *s)
} }
/* Find longest prefix. */ /* Find longest prefix. */
char * static char *
status_prompt_complete_prefix(const char **list, u_int size) status_prompt_complete_prefix(const char **list, u_int size)
{ {
char *out; char *out;
@@ -1246,8 +1330,8 @@ status_prompt_complete_prefix(const char **list, u_int size)
} }
/* Complete word. */ /* Complete word. */
char * static char *
status_prompt_complete(struct session *sess, const char *s) status_prompt_complete(struct session *session, const char *s)
{ {
const char **list = NULL, *colon; const char **list = NULL, *colon;
u_int size = 0, i; u_int size = 0, i;
@@ -1300,7 +1384,7 @@ status_prompt_complete(struct session *sess, const char *s)
colon = ""; colon = "";
if (*s == ':') { if (*s == ':') {
RB_FOREACH(wl, winlinks, &sess->windows) { RB_FOREACH(wl, winlinks, &session->windows) {
xasprintf(&tmp, ":%s", wl->window->name); xasprintf(&tmp, ":%s", wl->window->name);
if (strncmp(tmp, s, strlen(s)) == 0){ if (strncmp(tmp, s, strlen(s)) == 0){
list = xreallocarray(list, size + 1, list = xreallocarray(list, size + 1,

204
tmux.1
View File

@@ -1006,63 +1006,76 @@ It is also entered when a command that produces output, such as
.Ic list-keys , .Ic list-keys ,
is executed from a key binding. is executed from a key binding.
.Pp .Pp
The keys available depend on whether emacs or vi mode is selected Commands are sent to copy mode using the
(see the .Fl X
flag to the
.Ic send-keys
command.
When a key is pressed, copy mode automatically uses one of two key tables,
depending on the
.Ic mode-keys .Ic mode-keys
option). option:
The following keys are supported as appropriate for the mode: .Ic copy-mode
.Bl -column "FunctionXXXXXXXXXXXXXXXXX" "viXXXXXXXXXX" "emacs" -offset indent for emacs, or
.It Sy "Function" Ta Sy "vi" Ta Sy "emacs" .Ic copy-mode-vi
.It Li "Append selection" Ta "A" Ta "" for vi.
.It Li "Back to indentation" Ta "^" Ta "M-m" Key tables may be viewed with the
.It Li "Bottom of history" Ta "G" Ta "M-<" .Ic list-keys
.It Li "Clear selection" Ta "Escape" Ta "C-g" command.
.It Li "Copy selection" Ta "Enter" Ta "M-w" .Pp
.It Li "Copy to named buffer" Ta \&" Ta "" The following commands are supported in copy mode:
.It Li "Cursor down" Ta "j" Ta "Down" .Bl -column "CommandXXXXXXXXXXXXXXXXX" "viXXXXXXXXXX" "emacs" -offset indent
.It Li "Cursor left" Ta "h" Ta "Left" .It Sy "Command" Ta Sy "vi" Ta Sy "emacs"
.It Li "Cursor right" Ta "l" Ta "Right" .It Li "append-selection" Ta "" Ta ""
.It Li "Cursor to bottom line" Ta "L" Ta "" .It Li "append-selection-and-cancel" Ta "A" Ta ""
.It Li "Cursor to middle line" Ta "M" Ta "M-r" .It Li "back-to-indentation" Ta "^" Ta "M-m"
.It Li "Cursor to top line" Ta "H" Ta "M-R" .It Li "begin-selection" Ta "Space" Ta "C-Space"
.It Li "Cursor up" Ta "k" Ta "Up" .It Li "bottom-line" Ta "L" Ta ""
.It Li "Delete entire line" Ta "d" Ta "C-u" .It Li "cancel" Ta "q" Ta "Escape"
.It Li "Delete/Copy to end of line" Ta "D" Ta "C-k" .It Li "clear-selection" Ta "Escape" Ta "C-g"
.It Li "End of line" Ta "$" Ta "C-e" .It Li "copy-end-of-line" Ta "D" Ta "C-k"
.It Li "Go to line" Ta ":" Ta "g" .It Li "copy-line" Ta "" Ta ""
.It Li "Half page down" Ta "C-d" Ta "M-Down" .It Li "copy-pipe <command>" Ta "" Ta ""
.It Li "Half page up" Ta "C-u" Ta "M-Up" .It Li "copy-selection" Ta "" Ta ""
.It Li "Jump again" Ta ";" Ta ";" .It Li "copy-selection-and-cancel" Ta "Enter" Ta "M-w"
.It Li "Jump again in reverse" Ta "," Ta "," .It Li "cursor-down" Ta "j" Ta "Down"
.It Li "Jump backward" Ta "F" Ta "F" .It Li "cursor-left" Ta "h" Ta "Left"
.It Li "Jump forward" Ta "f" Ta "f" .It Li "cursor-right" Ta "l" Ta "Right"
.It Li "Jump to backward" Ta "T" Ta "" .It Li "cursor-up" Ta "k" Ta "Up"
.It Li "Jump to forward" Ta "t" Ta "" .It Li "end-of-line" Ta "$" Ta "C-e"
.It Li "Next page" Ta "C-f" Ta "Page down" .It Li "goto-line <line>" Ta ":" Ta "g"
.It Li "Next paragraph" Ta "}" Ta "M-}" .It Li "halfpage-down" Ta "C-d" Ta "M-Down"
.It Li "Next space" Ta "W" Ta "" .It Li "halfpage-up" Ta "C-u" Ta "M-Up"
.It Li "Next space, end of word" Ta "E" Ta "" .It Li "history-bottom" Ta "G" Ta "M-<"
.It Li "Next word" Ta "w" Ta "" .It Li "history-top" Ta "g" Ta "M->"
.It Li "Next word end" Ta "e" Ta "M-f" .It Li "jump-again" Ta ";" Ta ";"
.It Li "Other end of selection" Ta "o" Ta "" .It Li "jump-backward <to>" Ta "F" Ta "F"
.It Li "Paste buffer" Ta "p" Ta "C-y" .It Li "jump-forward <to>" Ta "f" Ta "f"
.It Li "Previous page" Ta "C-b" Ta "Page up" .It Li "jump-reverse" Ta "," Ta ","
.It Li "Previous paragraph" Ta "{" Ta "M-{" .It Li "jump-to-backward <to>" Ta "T" Ta ""
.It Li "Previous space" Ta "B" Ta "" .It Li "jump-to-forward <to>" Ta "t" Ta ""
.It Li "Previous word" Ta "b" Ta "M-b" .It Li "middle-line" Ta "M" Ta "M-r"
.It Li "Quit mode" Ta "q" Ta "Escape" .It Li "next-paragraph" Ta "}" Ta "M-}"
.It Li "Rectangle toggle" Ta "v" Ta "R" .It Li "next-space" Ta "W" Ta ""
.It Li "Scroll down" Ta "C-Down or C-e" Ta "C-Down" .It Li "next-space-end" Ta "E" Ta ""
.It Li "Scroll up" Ta "C-Up or C-y" Ta "C-Up" .It Li "next-word" Ta "w" Ta ""
.It Li "Search again" Ta "n" Ta "n" .It Li "next-word-end" Ta "e" Ta "M-f"
.It Li "Search again in reverse" Ta "N" Ta "N" .It Li "other-end" Ta "o" Ta ""
.It Li "Search backward" Ta "?" Ta "C-r" .It Li "page-down" Ta "C-f" Ta "PageDown"
.It Li "Search forward" Ta "/" Ta "C-s" .It Li "page-up" Ta "C-b" Ta "PageUp"
.It Li "Select line" Ta "V" Ta "" .It Li "previous-paragraph" Ta "{" Ta "M-{"
.It Li "Start of line" Ta "0" Ta "C-a" .It Li "previous-space" Ta "B" Ta ""
.It Li "Start selection" Ta "Space" Ta "C-Space" .It Li "previous-word" Ta "b" Ta "M-b"
.It Li "Top of history" Ta "g" Ta "M->" .It Li "rectangle-toggle" Ta "v" Ta "R"
.It Li "Transpose characters" Ta "" Ta "C-t" .It Li "scroll-down" Ta "C-e" Ta "C-Down"
.It Li "scroll-up" Ta "C-y" Ta "C-Up"
.It Li "search-again" Ta "n" Ta "n"
.It Li "search-backward <for>" Ta "?" Ta "C-r"
.It Li "search-forward <for>" Ta "/" Ta "C-s"
.It Li "search-reverse" Ta "N" Ta "N"
.It Li "select-line" Ta "V" Ta ""
.It Li "start-of-line" Ta "0" Ta "C-a"
.It Li "top-line" Ta "H" Ta "M-R"
.El .El
.Pp .Pp
The next and previous word keys use space and the The next and previous word keys use space and the
@@ -1094,59 +1107,18 @@ will then jump to the next occurrence.
Commands in copy mode may be prefaced by an optional repeat count. Commands in copy mode may be prefaced by an optional repeat count.
With vi key bindings, a prefix is entered using the number keys; with With vi key bindings, a prefix is entered using the number keys; with
emacs, the Alt (meta) key and a number begins prefix entry. emacs, the Alt (meta) key and a number begins prefix entry.
For example, to move the cursor forward by ten words, use
.Ql M-1 0 M-f
in emacs mode, and
.Ql 10w
in vi.
.Pp .Pp
Mode key bindings are defined in a set of named tables: Mode key bindings are defined in a set of named tables:
.Em vi-edit .Em vi-edit
and and
.Em emacs-edit .Em emacs-edit
for keys used when line editing at the command prompt; for keys used when line editing at the command prompt; and
.Em vi-choice .Em vi-choice
and and
.Em emacs-choice .Em emacs-choice
for keys used when choosing from lists (such as produced by the for keys used when choosing from lists (such as produced by the
.Ic choose-window .Ic choose-window
command); and command).
.Em vi-copy
and
.Em emacs-copy
used in copy mode.
The tables may be viewed with the
.Ic list-keys
command and keys modified or removed with
.Ic bind-key
and
.Ic unbind-key .
If
.Ic append-selection ,
.Ic copy-selection ,
or
.Ic start-named-buffer
are given the
.Fl x
flag,
.Nm
will not exit copy mode after copying.
.Ic copy-pipe
copies the selection and pipes it to a command.
For example the following will bind
.Ql C-w
not to exit after copying and
.Ql C-q
to copy the selection into
.Pa /tmp
as well as the paste buffer:
.Bd -literal -offset indent
bind-key -temacs-copy C-w copy-selection -x
bind-key -temacs-copy C-q copy-pipe "cat >/tmp/out"
.Ed
.Pp
The paste buffer key pastes the first line from the top paste buffer on the
stack.
.Pp .Pp
The synopsis for the The synopsis for the
.Ic copy-mode .Ic copy-mode
@@ -2137,7 +2109,6 @@ Commands related to key bindings are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Xo Ic bind-key .It Xo Ic bind-key
.Op Fl cnr .Op Fl cnr
.Op Fl R Ar repeat-count
.Op Fl t Ar mode-table .Op Fl t Ar mode-table
.Op Fl T Ar key-table .Op Fl T Ar key-table
.Ar key Ar command Op Ar arguments .Ar key Ar command Op Ar arguments
@@ -2196,19 +2167,6 @@ is bound in
the binding for command mode with the binding for command mode with
.Fl c .Fl c
or for normal mode without. or for normal mode without.
For keys in the
.Em vi-copy
or
.Em emacs-copy
tables,
.Fl R
specifies how many times the command should be repeated.
.Pp
See the
.Sx WINDOWS AND PANES
section and the
.Ic list-keys
command for information on mode key bindings.
.Pp .Pp
To view the default bindings and possible commands, see the To view the default bindings and possible commands, see the
.Ic list-keys .Ic list-keys
@@ -2240,7 +2198,8 @@ are listed; this may be one of:
or or
.Em emacs-copy . .Em emacs-copy .
.It Xo Ic send-keys .It Xo Ic send-keys
.Op Fl lMR .Op Fl lMRX
.Op Fl N Ar repeat-count
.Op Fl t Ar target-pane .Op Fl t Ar target-pane
.Ar key Ar ... .Ar key Ar ...
.Xc .Xc
@@ -2265,6 +2224,14 @@ flag causes the terminal state to be reset.
.Fl M .Fl M
passes through a mouse event (only valid if bound to a mouse key binding, see passes through a mouse event (only valid if bound to a mouse key binding, see
.Sx MOUSE SUPPORT ) . .Sx MOUSE SUPPORT ) .
.Pp
.Fl X
is used to send a command into copy mode - see
the
.Sx WINDOWS AND PANES
section.
.Fl N
specifies a repeat count to a copy mode command.
.It Xo Ic send-prefix .It Xo Ic send-prefix
.Op Fl 2 .Op Fl 2
.Op Fl t Ar target-pane .Op Fl t Ar target-pane
@@ -3371,10 +3338,12 @@ for a pane border or
for the status line). for the status line).
The following mouse events are available: The following mouse events are available:
.Bl -column "MouseDown1" "MouseDrag1" "WheelDown" -offset indent .Bl -column "MouseDown1" "MouseDrag1" "WheelDown" -offset indent
.It Li "WheelUp" Ta "WheelDown" Ta ""
.It Li "MouseDown1" Ta "MouseUp1" Ta "MouseDrag1" Ta "MouseDragEnd1" .It Li "MouseDown1" Ta "MouseUp1" Ta "MouseDrag1" Ta "MouseDragEnd1"
.It Li "MouseDown2" Ta "MouseUp2" Ta "MouseDrag2" Ta "MouseDragEnd2" .It Li "MouseDown2" Ta "MouseUp2" Ta "MouseDrag2" Ta "MouseDragEnd2"
.It Li "MouseDown3" Ta "MouseUp3" Ta "MouseDrag3" Ta "MouseDragEnd3" .It Li "MouseDown3" Ta "MouseUp3" Ta "MouseDrag3" Ta "MouseDragEnd3"
.It Li "WheelUp" Ta "WheelDown" Ta "" Ta "" .It Li "DoubleClick1" Ta "DoubleClick2" Ta "DoubleClick3" Ta "WheelUp"
.It Li "TripleClick1" Ta "TripleClick2" Ta "TripleClick3" Ta "WheelDown"
.El .El
.Pp .Pp
Each should be suffixed with a location, for example Each should be suffixed with a location, for example
@@ -3784,6 +3753,7 @@ session option.
Commands related to the status line are as follows: Commands related to the status line are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Xo Ic command-prompt .It Xo Ic command-prompt
.Op Fl 1
.Op Fl I Ar inputs .Op Fl I Ar inputs
.Op Fl p Ar prompts .Op Fl p Ar prompts
.Op Fl t Ar target-client .Op Fl t Ar target-client
@@ -3833,6 +3803,10 @@ Up to nine prompt responses may be replaced
to to
.Ql %9 .Ql %9
.Pc . .Pc .
.Pp
.Fl 1
makes the prompt only accept one key press, in this case the resulting input
is a single character.
.It Xo Ic confirm-before .It Xo Ic confirm-before
.Op Fl p Ar prompt .Op Fl p Ar prompt
.Op Fl t Ar target-client .Op Fl t Ar target-client

13
tmux.c
View File

@@ -43,10 +43,13 @@ struct hooks *global_hooks;
struct timeval start_time; struct timeval start_time;
const char *socket_path; const char *socket_path;
__dead void usage(void); static __dead void usage(void);
static char *make_label(const char *); static char *make_label(const char *);
__dead void static const char *getshell(void);
static int checkshell(const char *);
static __dead void
usage(void) usage(void)
{ {
fprintf(stderr, fprintf(stderr,
@@ -56,7 +59,7 @@ usage(void)
exit(1); exit(1);
} }
const char * static const char *
getshell(void) getshell(void)
{ {
struct passwd *pw; struct passwd *pw;
@@ -73,7 +76,7 @@ getshell(void)
return (_PATH_BSHELL); return (_PATH_BSHELL);
} }
int static int
checkshell(const char *shell) checkshell(const char *shell)
{ {
if (shell == NULL || *shell == '\0' || *shell != '/') if (shell == NULL || *shell == '\0' || *shell != '/')

113
tmux.h
View File

@@ -40,9 +40,11 @@
extern char **environ; extern char **environ;
struct args;
struct client; struct client;
struct environ; struct environ;
struct input_ctx; struct input_ctx;
struct mode_key_cmdstr;
struct mouse_event; struct mouse_event;
struct options; struct options;
struct session; struct session;
@@ -106,6 +108,9 @@ struct tmuxproc;
#define KEYC_IS_MOUSE(key) (((key) & KEYC_MASK_KEY) >= KEYC_MOUSE && \ #define KEYC_IS_MOUSE(key) (((key) & KEYC_MASK_KEY) >= KEYC_MOUSE && \
((key) & KEYC_MASK_KEY) < KEYC_BSPACE) ((key) & KEYC_MASK_KEY) < KEYC_BSPACE)
/* Multiple click timeout. */
#define KEYC_CLICK_TIMEOUT 300
/* Mouse key codes. */ /* Mouse key codes. */
#define KEYC_MOUSE_KEY(name) \ #define KEYC_MOUSE_KEY(name) \
KEYC_ ## name ## _PANE, \ KEYC_ ## name ## _PANE, \
@@ -144,6 +149,12 @@ enum {
KEYC_MOUSE_KEY(MOUSEDRAGEND3), KEYC_MOUSE_KEY(MOUSEDRAGEND3),
KEYC_MOUSE_KEY(WHEELUP), KEYC_MOUSE_KEY(WHEELUP),
KEYC_MOUSE_KEY(WHEELDOWN), KEYC_MOUSE_KEY(WHEELDOWN),
KEYC_MOUSE_KEY(DOUBLECLICK1),
KEYC_MOUSE_KEY(DOUBLECLICK2),
KEYC_MOUSE_KEY(DOUBLECLICK3),
KEYC_MOUSE_KEY(TRIPLECLICK1),
KEYC_MOUSE_KEY(TRIPLECLICK2),
KEYC_MOUSE_KEY(TRIPLECLICK3),
/* Backspace key. */ /* Backspace key. */
KEYC_BSPACE, KEYC_BSPACE,
@@ -513,58 +524,6 @@ enum mode_key_cmd {
MODEKEYCHOICE_TREE_EXPAND_ALL, MODEKEYCHOICE_TREE_EXPAND_ALL,
MODEKEYCHOICE_TREE_TOGGLE, MODEKEYCHOICE_TREE_TOGGLE,
MODEKEYCHOICE_UP, MODEKEYCHOICE_UP,
/* Copy keys. */
MODEKEYCOPY_APPENDSELECTION,
MODEKEYCOPY_BACKTOINDENTATION,
MODEKEYCOPY_BOTTOMLINE,
MODEKEYCOPY_CANCEL,
MODEKEYCOPY_CLEARSELECTION,
MODEKEYCOPY_COPYPIPE,
MODEKEYCOPY_COPYLINE,
MODEKEYCOPY_COPYENDOFLINE,
MODEKEYCOPY_COPYSELECTION,
MODEKEYCOPY_DOWN,
MODEKEYCOPY_ENDOFLINE,
MODEKEYCOPY_GOTOLINE,
MODEKEYCOPY_HALFPAGEDOWN,
MODEKEYCOPY_HALFPAGEUP,
MODEKEYCOPY_HISTORYBOTTOM,
MODEKEYCOPY_HISTORYTOP,
MODEKEYCOPY_JUMP,
MODEKEYCOPY_JUMPAGAIN,
MODEKEYCOPY_JUMPREVERSE,
MODEKEYCOPY_JUMPBACK,
MODEKEYCOPY_JUMPTO,
MODEKEYCOPY_JUMPTOBACK,
MODEKEYCOPY_LEFT,
MODEKEYCOPY_MIDDLELINE,
MODEKEYCOPY_NEXTPAGE,
MODEKEYCOPY_NEXTPARAGRAPH,
MODEKEYCOPY_NEXTSPACE,
MODEKEYCOPY_NEXTSPACEEND,
MODEKEYCOPY_NEXTWORD,
MODEKEYCOPY_NEXTWORDEND,
MODEKEYCOPY_OTHEREND,
MODEKEYCOPY_PREVIOUSPAGE,
MODEKEYCOPY_PREVIOUSPARAGRAPH,
MODEKEYCOPY_PREVIOUSSPACE,
MODEKEYCOPY_PREVIOUSWORD,
MODEKEYCOPY_RECTANGLETOGGLE,
MODEKEYCOPY_RIGHT,
MODEKEYCOPY_SCROLLDOWN,
MODEKEYCOPY_SCROLLUP,
MODEKEYCOPY_SEARCHAGAIN,
MODEKEYCOPY_SEARCHDOWN,
MODEKEYCOPY_SEARCHREVERSE,
MODEKEYCOPY_SEARCHUP,
MODEKEYCOPY_SELECTLINE,
MODEKEYCOPY_STARTNAMEDBUFFER,
MODEKEYCOPY_STARTNUMBERPREFIX,
MODEKEYCOPY_STARTOFLINE,
MODEKEYCOPY_STARTSELECTION,
MODEKEYCOPY_TOPLINE,
MODEKEYCOPY_UP,
}; };
/* Data required while mode keys are in use. */ /* Data required while mode keys are in use. */
@@ -578,22 +537,14 @@ struct mode_key_data {
/* Binding between a key and a command. */ /* Binding between a key and a command. */
struct mode_key_binding { struct mode_key_binding {
key_code key; key_code key;
u_int repeat;
int mode; int mode;
enum mode_key_cmd cmd; enum mode_key_cmd cmd;
const char *arg;
RB_ENTRY(mode_key_binding) entry; RB_ENTRY(mode_key_binding) entry;
}; };
RB_HEAD(mode_key_tree, mode_key_binding); RB_HEAD(mode_key_tree, mode_key_binding);
/* Command to string mapping. */
struct mode_key_cmdstr {
enum mode_key_cmd cmd;
const char *name;
};
/* Named mode key table description. */ /* Named mode key table description. */
struct mode_key_entry; struct mode_key_entry;
struct mode_key_table { struct mode_key_table {
@@ -834,6 +785,10 @@ struct window_mode {
void (*resize)(struct window_pane *, u_int, u_int); void (*resize)(struct window_pane *, u_int, u_int);
void (*key)(struct window_pane *, struct client *, struct session *, void (*key)(struct window_pane *, struct client *, struct session *,
key_code, struct mouse_event *); key_code, struct mouse_event *);
const char *(*key_table)(struct window_pane *);
void (*command)(struct window_pane *, struct client *,
struct session *, struct args *, struct mouse_event *);
}; };
#define WINDOW_MODE_TIMEOUT 180 #define WINDOW_MODE_TIMEOUT 180
@@ -925,6 +880,7 @@ struct window_pane {
void *modedata; void *modedata;
struct event modetimer; struct event modetimer;
time_t modelast; time_t modelast;
u_int modeprefix;
TAILQ_ENTRY(window_pane) entry; TAILQ_ENTRY(window_pane) entry;
RB_ENTRY(window_pane) tree_entry; RB_ENTRY(window_pane) tree_entry;
@@ -1266,6 +1222,9 @@ struct client {
struct event repeat_timer; struct event repeat_timer;
struct event click_timer;
u_int click_button;
struct event status_timer; struct event status_timer;
struct screen status; struct screen status;
@@ -1289,6 +1248,8 @@ struct client {
#define CLIENT_256COLOURS 0x20000 #define CLIENT_256COLOURS 0x20000
#define CLIENT_IDENTIFIED 0x40000 #define CLIENT_IDENTIFIED 0x40000
#define CLIENT_STATUSFORCE 0x80000 #define CLIENT_STATUSFORCE 0x80000
#define CLIENT_DOUBLECLICK 0x100000
#define CLIENT_TRIPLECLICK 0x200000
int flags; int flags;
struct key_table *keytable; struct key_table *keytable;
@@ -1302,7 +1263,7 @@ struct client {
TAILQ_HEAD(, message_entry) message_log; TAILQ_HEAD(, message_entry) message_log;
char *prompt_string; char *prompt_string;
char *prompt_buffer; struct utf8_data *prompt_buffer;
size_t prompt_index; size_t prompt_index;
int (*prompt_callbackfn)(void *, const char *); int (*prompt_callbackfn)(void *, const char *);
void (*prompt_freefn)(void *); void (*prompt_freefn)(void *);
@@ -1556,8 +1517,6 @@ extern struct options *global_w_options;
extern struct environ *global_environ; extern struct environ *global_environ;
extern struct timeval start_time; extern struct timeval start_time;
extern const char *socket_path; extern const char *socket_path;
const char *getshell(void);
int checkshell(const char *);
int areshell(const char *); int areshell(const char *);
void setblocking(int, int); void setblocking(int, int);
const char *find_home(void); const char *find_home(void);
@@ -1636,13 +1595,10 @@ int printflike(4, 5) hooks_wait(struct hooks *, struct cmd_q *,
struct cmd_find_state *, const char *, ...); struct cmd_find_state *, const char *, ...);
/* mode-key.c */ /* mode-key.c */
extern const struct mode_key_table mode_key_tables[];
extern struct mode_key_tree mode_key_tree_vi_edit; extern struct mode_key_tree mode_key_tree_vi_edit;
extern struct mode_key_tree mode_key_tree_vi_choice; extern struct mode_key_tree mode_key_tree_vi_choice;
extern struct mode_key_tree mode_key_tree_vi_copy;
extern struct mode_key_tree mode_key_tree_emacs_edit; extern struct mode_key_tree mode_key_tree_emacs_edit;
extern struct mode_key_tree mode_key_tree_emacs_choice; extern struct mode_key_tree mode_key_tree_emacs_choice;
extern struct mode_key_tree mode_key_tree_emacs_copy;
int mode_key_cmp(struct mode_key_binding *, struct mode_key_binding *); int mode_key_cmp(struct mode_key_binding *, struct mode_key_binding *);
RB_PROTOTYPE(mode_key_tree, mode_key_binding, entry, mode_key_cmp); RB_PROTOTYPE(mode_key_tree, mode_key_binding, entry, mode_key_cmp);
const char *mode_key_tostring(const struct mode_key_cmdstr *, const char *mode_key_tostring(const struct mode_key_cmdstr *,
@@ -1652,8 +1608,7 @@ enum mode_key_cmd mode_key_fromstring(const struct mode_key_cmdstr *,
const struct mode_key_table *mode_key_findtable(const char *); const struct mode_key_table *mode_key_findtable(const char *);
void mode_key_init_trees(void); void mode_key_init_trees(void);
void mode_key_init(struct mode_key_data *, struct mode_key_tree *); void mode_key_init(struct mode_key_data *, struct mode_key_tree *);
enum mode_key_cmd mode_key_lookup(struct mode_key_data *, key_code, enum mode_key_cmd mode_key_lookup(struct mode_key_data *, key_code);
const char **, u_int *);
/* notify.c */ /* notify.c */
void notify_enable(void); void notify_enable(void);
@@ -1718,14 +1673,11 @@ void environ_log(struct environ *, const char *);
/* tty.c */ /* tty.c */
void tty_create_log(void); void tty_create_log(void);
void tty_init_termios(int, struct termios *, struct bufferevent *);
void tty_raw(struct tty *, const char *); void tty_raw(struct tty *, const char *);
void tty_attributes(struct tty *, const struct grid_cell *, void tty_attributes(struct tty *, const struct grid_cell *,
const struct window_pane *); const struct window_pane *);
void tty_reset(struct tty *); void tty_reset(struct tty *);
void tty_region_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
void tty_region(struct tty *, u_int, u_int); void tty_region(struct tty *, u_int, u_int);
void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
void tty_cursor(struct tty *, u_int, u_int); void tty_cursor(struct tty *, u_int, u_int);
void tty_putcode(struct tty *, enum tty_code_code); void tty_putcode(struct tty *, enum tty_code_code);
void tty_putcode1(struct tty *, enum tty_code_code, int); void tty_putcode1(struct tty *, enum tty_code_code, int);
@@ -1743,7 +1695,6 @@ void tty_start_tty(struct tty *);
void tty_stop_tty(struct tty *); void tty_stop_tty(struct tty *);
void tty_set_title(struct tty *, const char *); void tty_set_title(struct tty *, const char *);
void tty_update_mode(struct tty *, int, struct screen *); void tty_update_mode(struct tty *, int, struct screen *);
void tty_force_cursor_colour(struct tty *, const char *);
void tty_draw_pane(struct tty *, const struct window_pane *, u_int, u_int, void tty_draw_pane(struct tty *, const struct window_pane *, u_int, u_int,
u_int); u_int);
void tty_draw_line(struct tty *, const struct window_pane *, struct screen *, void tty_draw_line(struct tty *, const struct window_pane *, struct screen *,
@@ -1800,12 +1751,10 @@ void tty_keys_free(struct tty *);
key_code tty_keys_next(struct tty *); key_code tty_keys_next(struct tty *);
/* arguments.c */ /* arguments.c */
struct args *args_create(int, ...);
struct args *args_parse(const char *, int, char **); struct args *args_parse(const char *, int, char **);
void args_free(struct args *); void args_free(struct args *);
char *args_print(struct args *); char *args_print(struct args *);
int args_has(struct args *, u_char); int args_has(struct args *, u_char);
void args_set(struct args *, u_char, const char *);
const char *args_get(struct args *, u_char); const char *args_get(struct args *, u_char);
long long args_strtonum(struct args *, u_char, long long, long long, long long args_strtonum(struct args *, u_char, long long, long long,
char **); char **);
@@ -1869,7 +1818,6 @@ void cmdq_run(struct cmd_q *, struct cmd_list *,
void cmdq_append(struct cmd_q *, struct cmd_list *, void cmdq_append(struct cmd_q *, struct cmd_list *,
struct mouse_event *); struct mouse_event *);
int cmdq_continue(struct cmd_q *); int cmdq_continue(struct cmd_q *);
void cmdq_flush(struct cmd_q *);
/* cmd-string.c */ /* cmd-string.c */
int cmd_string_parse(const char *, struct cmd_list **, const char *, int cmd_string_parse(const char *, struct cmd_list **, const char *,
@@ -1922,6 +1870,7 @@ void server_add_accept(int);
/* server-client.c */ /* server-client.c */
void server_client_set_key_table(struct client *, const char *); void server_client_set_key_table(struct client *, const char *);
const char *server_client_get_key_table(struct client *); const char *server_client_get_key_table(struct client *);
int server_client_is_default_key_table(struct client *);
int server_client_check_nested(struct client *); int server_client_check_nested(struct client *);
void server_client_handle_key(struct client *, key_code); void server_client_handle_key(struct client *, key_code);
void server_client_create(int); void server_client_create(int);
@@ -1952,7 +1901,6 @@ int server_link_window(struct session *,
struct winlink *, struct session *, int, int, int, char **); struct winlink *, struct session *, int, int, int, char **);
void server_unlink_window(struct session *, struct winlink *); void server_unlink_window(struct session *, struct winlink *);
void server_destroy_pane(struct window_pane *, int); void server_destroy_pane(struct window_pane *, int);
void server_destroy_session_group(struct session *);
void server_destroy_session(struct session *); void server_destroy_session(struct session *);
void server_check_unattached(void); void server_check_unattached(void);
void server_set_identify(struct client *); void server_set_identify(struct client *);
@@ -2018,7 +1966,6 @@ void grid_collect_history(struct grid *);
void grid_scroll_history(struct grid *); void grid_scroll_history(struct grid *);
void grid_scroll_history_region(struct grid *, u_int, u_int); void grid_scroll_history_region(struct grid *, u_int, u_int);
void grid_clear_history(struct grid *); void grid_clear_history(struct grid *);
void grid_expand_line(struct grid *, u_int, u_int);
const struct grid_line *grid_peek_line(struct grid *, u_int); const struct grid_line *grid_peek_line(struct grid *, u_int);
void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *); void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *); void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
@@ -2114,7 +2061,6 @@ void screen_set_selection(struct screen *,
u_int, u_int, u_int, u_int, u_int, struct grid_cell *); u_int, u_int, u_int, u_int, u_int, struct grid_cell *);
void screen_clear_selection(struct screen *); void screen_clear_selection(struct screen *);
int screen_check_selection(struct screen *, u_int, u_int); int screen_check_selection(struct screen *, u_int, u_int);
void screen_reflow(struct screen *, u_int);
/* window.c */ /* window.c */
extern struct windows windows; extern struct windows windows;
@@ -2128,7 +2074,6 @@ RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
struct winlink *winlink_find_by_index(struct winlinks *, int); struct winlink *winlink_find_by_index(struct winlinks *, int);
struct winlink *winlink_find_by_window(struct winlinks *, struct window *); struct winlink *winlink_find_by_window(struct winlinks *, struct window *);
struct winlink *winlink_find_by_window_id(struct winlinks *, u_int); struct winlink *winlink_find_by_window_id(struct winlinks *, u_int);
int winlink_next_index(struct winlinks *, int);
u_int winlink_count(struct winlinks *); u_int winlink_count(struct winlinks *);
struct winlink *winlink_add(struct winlinks *, int); struct winlink *winlink_add(struct winlinks *, int);
void winlink_set_window(struct winlink *, struct window *); void winlink_set_window(struct winlink *, struct window *);
@@ -2172,8 +2117,6 @@ u_int window_count_panes(struct window *);
void window_destroy_panes(struct window *); void window_destroy_panes(struct window *);
struct window_pane *window_pane_find_by_id_str(const char *); struct window_pane *window_pane_find_by_id_str(const char *);
struct window_pane *window_pane_find_by_id(u_int); struct window_pane *window_pane_find_by_id(u_int);
struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
void window_pane_destroy(struct window_pane *);
int window_pane_spawn(struct window_pane *, int, char **, int window_pane_spawn(struct window_pane *, int, char **,
const char *, const char *, const char *, struct environ *, const char *, const char *, const char *, struct environ *,
struct termios *, char **); struct termios *, char **);
@@ -2259,7 +2202,6 @@ void window_choose_ready(struct window_pane *,
u_int, void (*)(struct window_choose_data *)); u_int, void (*)(struct window_choose_data *));
struct window_choose_data *window_choose_data_create (int, struct window_choose_data *window_choose_data_create (int,
struct client *, struct session *); struct client *, struct session *);
void window_choose_data_free(struct window_choose_data *);
void window_choose_data_run(struct window_choose_data *); void window_choose_data_run(struct window_choose_data *);
struct window_choose_data *window_choose_add_window(struct window_pane *, struct window_choose_data *window_choose_add_window(struct window_pane *,
struct client *, struct session *, struct winlink *, struct client *, struct session *, struct winlink *,
@@ -2268,13 +2210,11 @@ struct window_choose_data *window_choose_add_session(struct window_pane *,
struct client *, struct session *, const char *, struct client *, struct session *, const char *,
const char *, u_int); const char *, u_int);
void window_choose_expand_all(struct window_pane *); void window_choose_expand_all(struct window_pane *);
void window_choose_collapse_all(struct window_pane *);
void window_choose_set_current(struct window_pane *, u_int); void window_choose_set_current(struct window_pane *, u_int);
/* names.c */ /* names.c */
void check_window_name(struct window *); void check_window_name(struct window *);
char *default_window_name(struct window *); char *default_window_name(struct window *);
char *format_window_name(struct window *);
char *parse_window_name(const char *); char *parse_window_name(const char *);
/* signal.c */ /* signal.c */
@@ -2331,11 +2271,8 @@ int session_set_current(struct session *, struct winlink *);
struct session_group *session_group_find(struct session *); struct session_group *session_group_find(struct session *);
u_int session_group_index(struct session_group *); u_int session_group_index(struct session_group *);
void session_group_add(struct session *, struct session *); void session_group_add(struct session *, struct session *);
void session_group_remove(struct session *);
u_int session_group_count(struct session_group *);
void session_group_synchronize_to(struct session *); void session_group_synchronize_to(struct session *);
void session_group_synchronize_from(struct session *); void session_group_synchronize_from(struct session *);
void session_group_synchronize1(struct session *, struct session *);
void session_renumber_windows(struct session *); void session_renumber_windows(struct session *);
/* utf8.c */ /* utf8.c */
@@ -2347,6 +2284,8 @@ enum utf8_state utf8_combine(const struct utf8_data *, wchar_t *);
enum utf8_state utf8_split(wchar_t, struct utf8_data *); enum utf8_state utf8_split(wchar_t, struct utf8_data *);
int utf8_strvis(char *, const char *, size_t, int); int utf8_strvis(char *, const char *, size_t, int);
char *utf8_sanitize(const char *); char *utf8_sanitize(const char *);
size_t utf8_strlen(const struct utf8_data *);
u_int utf8_strwidth(const struct utf8_data *, ssize_t);
struct utf8_data *utf8_fromcstr(const char *); struct utf8_data *utf8_fromcstr(const char *);
char *utf8_tocstr(struct utf8_data *); char *utf8_tocstr(struct utf8_data *);
u_int utf8_cstrwidth(const char *); u_int utf8_cstrwidth(const char *);

View File

@@ -50,7 +50,7 @@ struct tty_default_key_raw {
const char *string; const char *string;
key_code key; key_code key;
}; };
const struct tty_default_key_raw tty_default_raw_keys[] = { static const struct tty_default_key_raw tty_default_raw_keys[] = {
/* /*
* Numeric keypad. Just use the vt100 escape sequences here and always * Numeric keypad. Just use the vt100 escape sequences here and always
* put the terminal into keypad_xmit mode. Translation of numbers * put the terminal into keypad_xmit mode. Translation of numbers
@@ -170,7 +170,7 @@ struct tty_default_key_code {
enum tty_code_code code; enum tty_code_code code;
key_code key; key_code key;
}; };
const struct tty_default_key_code tty_default_code_keys[] = { static const struct tty_default_key_code tty_default_code_keys[] = {
/* Function keys. */ /* Function keys. */
{ TTYC_KF1, KEYC_F1 }, { TTYC_KF1, KEYC_F1 },
{ TTYC_KF2, KEYC_F2 }, { TTYC_KF2, KEYC_F2 },

View File

@@ -30,8 +30,8 @@
#include "tmux.h" #include "tmux.h"
void tty_term_override(struct tty_term *, const char *); static void tty_term_override(struct tty_term *, const char *);
char *tty_term_strip(const char *); static char *tty_term_strip(const char *);
struct tty_terms tty_terms = LIST_HEAD_INITIALIZER(tty_terms); struct tty_terms tty_terms = LIST_HEAD_INITIALIZER(tty_terms);
@@ -56,7 +56,7 @@ struct tty_term_code_entry {
const char *name; const char *name;
}; };
const struct tty_term_code_entry tty_term_codes[] = { static const struct tty_term_code_entry tty_term_codes[] = {
[TTYC_ACSC] = { TTYCODE_STRING, "acsc" }, [TTYC_ACSC] = { TTYCODE_STRING, "acsc" },
[TTYC_AX] = { TTYCODE_FLAG, "AX" }, [TTYC_AX] = { TTYCODE_FLAG, "AX" },
[TTYC_BCE] = { TTYCODE_FLAG, "bce" }, [TTYC_BCE] = { TTYCODE_FLAG, "bce" },
@@ -267,7 +267,7 @@ tty_term_ncodes(void)
return (nitems(tty_term_codes)); return (nitems(tty_term_codes));
} }
char * static char *
tty_term_strip(const char *s) tty_term_strip(const char *s)
{ {
const char *ptr; const char *ptr;
@@ -296,7 +296,7 @@ tty_term_strip(const char *s)
return (xstrdup(buf)); return (xstrdup(buf));
} }
void static void
tty_term_override(struct tty_term *term, const char *overrides) tty_term_override(struct tty_term *term, const char *overrides)
{ {
const struct tty_term_code_entry *ent; const struct tty_term_code_entry *ent;

84
tty.c
View File

@@ -31,31 +31,39 @@
#include "tmux.h" #include "tmux.h"
static int tty_log_fd = -1; static int tty_log_fd = -1;
void tty_read_callback(struct bufferevent *, void *); static void tty_init_termios(int, struct termios *, struct bufferevent *);
void tty_error_callback(struct bufferevent *, short, void *);
static int tty_client_ready(struct client *, struct window_pane *); static void tty_read_callback(struct bufferevent *, void *);
static void tty_error_callback(struct bufferevent *, short, void *);
void tty_set_italics(struct tty *); static int tty_client_ready(struct client *, struct window_pane *);
int tty_try_colour(struct tty *, int, const char *);
void tty_colours(struct tty *, const struct grid_cell *); static void tty_set_italics(struct tty *);
void tty_check_fg(struct tty *, struct grid_cell *); static int tty_try_colour(struct tty *, int, const char *);
void tty_check_bg(struct tty *, struct grid_cell *); static void tty_force_cursor_colour(struct tty *, const char *);
void tty_colours_fg(struct tty *, const struct grid_cell *); static void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int,
void tty_colours_bg(struct tty *, const struct grid_cell *); u_int);
int tty_large_region(struct tty *, const struct tty_ctx *); static void tty_colours(struct tty *, const struct grid_cell *);
int tty_fake_bce(const struct tty *, const struct window_pane *); static void tty_check_fg(struct tty *, struct grid_cell *);
void tty_redraw_region(struct tty *, const struct tty_ctx *); static void tty_check_bg(struct tty *, struct grid_cell *);
void tty_emulate_repeat(struct tty *, enum tty_code_code, enum tty_code_code, static void tty_colours_fg(struct tty *, const struct grid_cell *);
u_int); static void tty_colours_bg(struct tty *, const struct grid_cell *);
void tty_repeat_space(struct tty *, u_int);
void tty_cell(struct tty *, const struct grid_cell *, static void tty_region_pane(struct tty *, const struct tty_ctx *, u_int,
const struct window_pane *); u_int);
void tty_default_colours(struct grid_cell *, const struct window_pane *); static int tty_large_region(struct tty *, const struct tty_ctx *);
static int tty_fake_bce(const struct tty *, const struct window_pane *);
static void tty_redraw_region(struct tty *, const struct tty_ctx *);
static void tty_emulate_repeat(struct tty *, enum tty_code_code,
enum tty_code_code, u_int);
static void tty_repeat_space(struct tty *, u_int);
static void tty_cell(struct tty *, const struct grid_cell *,
const struct window_pane *);
static void tty_default_colours(struct grid_cell *,
const struct window_pane *);
#define tty_use_acs(tty) \ #define tty_use_acs(tty) \
(tty_term_has((tty)->term, TTYC_ACSC) && !((tty)->flags & TTY_UTF8)) (tty_term_has((tty)->term, TTYC_ACSC) && !((tty)->flags & TTY_UTF8))
@@ -173,7 +181,7 @@ tty_open(struct tty *tty, char **cause)
return (0); return (0);
} }
void static void
tty_read_callback(__unused struct bufferevent *bufev, void *data) tty_read_callback(__unused struct bufferevent *bufev, void *data)
{ {
struct tty *tty = data; struct tty *tty = data;
@@ -182,13 +190,13 @@ tty_read_callback(__unused struct bufferevent *bufev, void *data)
; ;
} }
void static void
tty_error_callback(__unused struct bufferevent *bufev, __unused short what, tty_error_callback(__unused struct bufferevent *bufev, __unused short what,
__unused void *data) __unused void *data)
{ {
} }
void static void
tty_init_termios(int fd, struct termios *orig_tio, struct bufferevent *bufev) tty_init_termios(int fd, struct termios *orig_tio, struct bufferevent *bufev)
{ {
struct termios tio; struct termios tio;
@@ -450,7 +458,7 @@ tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)
tty->cx += width; tty->cx += width;
} }
void static void
tty_set_italics(struct tty *tty) tty_set_italics(struct tty *tty)
{ {
const char *s; const char *s;
@@ -477,7 +485,7 @@ tty_set_title(struct tty *tty, const char *title)
tty_putcode(tty, TTYC_FSL); tty_putcode(tty, TTYC_FSL);
} }
void static void
tty_force_cursor_colour(struct tty *tty, const char *ccolour) tty_force_cursor_colour(struct tty *tty, const char *ccolour)
{ {
if (*ccolour == '\0') if (*ccolour == '\0')
@@ -559,7 +567,7 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
tty->mode = mode; tty->mode = mode;
} }
void static void
tty_emulate_repeat(struct tty *tty, enum tty_code_code code, tty_emulate_repeat(struct tty *tty, enum tty_code_code code,
enum tty_code_code code1, u_int n) enum tty_code_code code1, u_int n)
{ {
@@ -571,7 +579,7 @@ tty_emulate_repeat(struct tty *tty, enum tty_code_code code,
} }
} }
void static void
tty_repeat_space(struct tty *tty, u_int n) tty_repeat_space(struct tty *tty, u_int n)
{ {
while (n-- > 0) while (n-- > 0)
@@ -583,7 +591,7 @@ tty_repeat_space(struct tty *tty, u_int n)
* probably several times now? Currently yes if it is more than 50% of the * probably several times now? Currently yes if it is more than 50% of the
* pane. * pane.
*/ */
int static int
tty_large_region(__unused struct tty *tty, const struct tty_ctx *ctx) tty_large_region(__unused struct tty *tty, const struct tty_ctx *ctx)
{ {
struct window_pane *wp = ctx->wp; struct window_pane *wp = ctx->wp;
@@ -595,7 +603,7 @@ tty_large_region(__unused struct tty *tty, const struct tty_ctx *ctx)
* Return if BCE is needed but the terminal doesn't have it - it'll need to be * Return if BCE is needed but the terminal doesn't have it - it'll need to be
* emulated. * emulated.
*/ */
int static int
tty_fake_bce(const struct tty *tty, const struct window_pane *wp) tty_fake_bce(const struct tty *tty, const struct window_pane *wp)
{ {
struct grid_cell gc; struct grid_cell gc;
@@ -614,7 +622,7 @@ tty_fake_bce(const struct tty *tty, const struct window_pane *wp)
* CSR not supported, or window is a pane that doesn't take up the full * CSR not supported, or window is a pane that doesn't take up the full
* width of the terminal. * width of the terminal.
*/ */
void static void
tty_redraw_region(struct tty *tty, const struct tty_ctx *ctx) tty_redraw_region(struct tty *tty, const struct tty_ctx *ctx)
{ {
struct window_pane *wp = ctx->wp; struct window_pane *wp = ctx->wp;
@@ -1129,7 +1137,7 @@ tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx)
tty_cursor(tty, 0, 0); tty_cursor(tty, 0, 0);
} }
void static void
tty_cell(struct tty *tty, const struct grid_cell *gc, tty_cell(struct tty *tty, const struct grid_cell *gc,
const struct window_pane *wp) const struct window_pane *wp)
{ {
@@ -1181,7 +1189,7 @@ tty_reset(struct tty *tty)
} }
/* Set region inside pane. */ /* Set region inside pane. */
void static void
tty_region_pane(struct tty *tty, const struct tty_ctx *ctx, u_int rupper, tty_region_pane(struct tty *tty, const struct tty_ctx *ctx, u_int rupper,
u_int rlower) u_int rlower)
{ {
@@ -1214,7 +1222,7 @@ tty_region(struct tty *tty, u_int rupper, u_int rlower)
} }
/* Move cursor inside pane. */ /* Move cursor inside pane. */
void static void
tty_cursor_pane(struct tty *tty, const struct tty_ctx *ctx, u_int cx, u_int cy) tty_cursor_pane(struct tty *tty, const struct tty_ctx *ctx, u_int cx, u_int cy)
{ {
tty_cursor(tty, ctx->xoff + cx, ctx->yoff + cy); tty_cursor(tty, ctx->xoff + cx, ctx->yoff + cy);
@@ -1419,7 +1427,7 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc,
tty_putcode(tty, TTYC_SMACS); tty_putcode(tty, TTYC_SMACS);
} }
void static void
tty_colours(struct tty *tty, const struct grid_cell *gc) tty_colours(struct tty *tty, const struct grid_cell *gc)
{ {
struct grid_cell *tc = &tty->cell; struct grid_cell *tc = &tty->cell;
@@ -1559,7 +1567,7 @@ tty_check_bg(struct tty *tty, struct grid_cell *gc)
gc->bg -= 90; gc->bg -= 90;
} }
void static void
tty_colours_fg(struct tty *tty, const struct grid_cell *gc) tty_colours_fg(struct tty *tty, const struct grid_cell *gc)
{ {
struct grid_cell *tc = &tty->cell; struct grid_cell *tc = &tty->cell;
@@ -1589,7 +1597,7 @@ save_fg:
tc->fg = gc->fg; tc->fg = gc->fg;
} }
void static void
tty_colours_bg(struct tty *tty, const struct grid_cell *gc) tty_colours_bg(struct tty *tty, const struct grid_cell *gc)
{ {
struct grid_cell *tc = &tty->cell; struct grid_cell *tc = &tty->cell;
@@ -1619,7 +1627,7 @@ save_bg:
tc->bg = gc->bg; tc->bg = gc->bg;
} }
int static int
tty_try_colour(struct tty *tty, int colour, const char *type) tty_try_colour(struct tty *tty, int colour, const char *type)
{ {
u_char r, g, b; u_char r, g, b;
@@ -1672,7 +1680,7 @@ fallback_256:
return (0); return (0);
} }
void static void
tty_default_colours(struct grid_cell *gc, const struct window_pane *wp) tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
{ {
struct window *w = wp->window; struct window *w = wp->window;

27
utf8.c
View File

@@ -261,6 +261,33 @@ utf8_sanitize(const char *src)
return (dst); return (dst);
} }
/* Get UTF-8 buffer length. */
size_t
utf8_strlen(const struct utf8_data *s)
{
size_t i;
for (i = 0; s[i].size != 0; i++)
/* nothing */;
return (i);
}
/* Get UTF-8 string width. */
u_int
utf8_strwidth(const struct utf8_data *s, ssize_t n)
{
ssize_t i;
u_int width;
width = 0;
for (i = 0; s[i].size != 0; i++) {
if (n != -1 && n == i)
break;
width += s[i].width;
}
return (width);
}
/* /*
* Convert a string into a buffer of UTF-8 characters. Terminated by size == 0. * Convert a string into a buffer of UTF-8 characters. Terminated by size == 0.
* Caller frees. * Caller frees.

View File

@@ -24,27 +24,32 @@
#include "tmux.h" #include "tmux.h"
struct screen *window_choose_init(struct window_pane *); static struct screen *window_choose_init(struct window_pane *);
void window_choose_free(struct window_pane *); static void window_choose_free(struct window_pane *);
void window_choose_resize(struct window_pane *, u_int, u_int); static void window_choose_resize(struct window_pane *, u_int, u_int);
void window_choose_key(struct window_pane *, struct client *, static void window_choose_key(struct window_pane *, struct client *,
struct session *, key_code, struct mouse_event *); struct session *, key_code, struct mouse_event *);
void window_choose_default_callback(struct window_choose_data *); static void window_choose_default_callback(struct window_choose_data *);
struct window_choose_mode_item *window_choose_get_item(struct window_pane *, static struct window_choose_mode_item *window_choose_get_item(
key_code, struct mouse_event *); struct window_pane *, key_code, struct mouse_event *);
void window_choose_fire_callback(struct window_pane *, static void window_choose_fire_callback(struct window_pane *,
struct window_choose_data *); struct window_choose_data *);
void window_choose_redraw_screen(struct window_pane *); static void window_choose_redraw_screen(struct window_pane *);
void window_choose_write_line(struct window_pane *, static void window_choose_write_line(struct window_pane *,
struct screen_write_ctx *, u_int); struct screen_write_ctx *, u_int);
void window_choose_scroll_up(struct window_pane *); static void window_choose_scroll_up(struct window_pane *);
void window_choose_scroll_down(struct window_pane *); static void window_choose_scroll_down(struct window_pane *);
void window_choose_collapse(struct window_pane *, struct session *, u_int); static void window_choose_collapse(struct window_pane *, struct session *,
void window_choose_expand(struct window_pane *, struct session *, u_int); u_int);
static void window_choose_expand(struct window_pane *, struct session *,
u_int);
static void window_choose_collapse_all(struct window_pane *);
static void window_choose_data_free(struct window_choose_data *);
enum window_choose_input_type { enum window_choose_input_type {
WINDOW_CHOOSE_NORMAL = -1, WINDOW_CHOOSE_NORMAL = -1,
@@ -52,10 +57,10 @@ enum window_choose_input_type {
}; };
const struct window_mode window_choose_mode = { const struct window_mode window_choose_mode = {
window_choose_init, .init = window_choose_init,
window_choose_free, .free = window_choose_free,
window_choose_resize, .resize = window_choose_resize,
window_choose_key, .key = window_choose_key,
}; };
struct window_choose_mode_item { struct window_choose_mode_item {
@@ -86,12 +91,14 @@ struct window_choose_mode_data {
void (*callbackfn)(struct window_choose_data *); void (*callbackfn)(struct window_choose_data *);
}; };
void window_choose_free1(struct window_choose_mode_data *); static void window_choose_free1(struct window_choose_mode_data *);
int window_choose_key_index(struct window_choose_mode_data *, u_int); static int window_choose_key_index(struct window_choose_mode_data *,
int window_choose_index_key(struct window_choose_mode_data *, key_code); u_int);
void window_choose_prompt_input(enum window_choose_input_type, static int window_choose_index_key(struct window_choose_mode_data *,
const char *, struct window_pane *, key_code); key_code);
void window_choose_reset_top(struct window_pane *, u_int); static void window_choose_prompt_input(enum window_choose_input_type,
const char *, struct window_pane *, key_code);
static void window_choose_reset_top(struct window_pane *, u_int);
void void
window_choose_add(struct window_pane *wp, struct window_choose_data *wcd) window_choose_add(struct window_pane *wp, struct window_choose_data *wcd)
@@ -122,7 +129,7 @@ window_choose_set_current(struct window_pane *wp, u_int cur)
window_choose_reset_top(wp, screen_size_y(s)); window_choose_reset_top(wp, screen_size_y(s));
} }
void static void
window_choose_reset_top(struct window_pane *wp, u_int sy) window_choose_reset_top(struct window_pane *wp, u_int sy)
{ {
struct window_choose_mode_data *data = wp->modedata; struct window_choose_mode_data *data = wp->modedata;
@@ -156,7 +163,7 @@ window_choose_ready(struct window_pane *wp, u_int cur,
window_choose_collapse_all(wp); window_choose_collapse_all(wp);
} }
struct screen * static struct screen *
window_choose_init(struct window_pane *wp) window_choose_init(struct window_pane *wp)
{ {
struct window_choose_mode_data *data; struct window_choose_mode_data *data;
@@ -218,7 +225,7 @@ window_choose_data_create(int type, struct client *c, struct session *s)
return (wcd); return (wcd);
} }
void static void
window_choose_data_free(struct window_choose_data *wcd) window_choose_data_free(struct window_choose_data *wcd)
{ {
server_client_unref(wcd->start_client); server_client_unref(wcd->start_client);
@@ -260,7 +267,7 @@ window_choose_data_run(struct window_choose_data *cdata)
cmd_list_free(cmdlist); cmd_list_free(cmdlist);
} }
void static void
window_choose_default_callback(struct window_choose_data *wcd) window_choose_default_callback(struct window_choose_data *wcd)
{ {
if (wcd == NULL) if (wcd == NULL)
@@ -271,14 +278,14 @@ window_choose_default_callback(struct window_choose_data *wcd)
window_choose_data_run(wcd); window_choose_data_run(wcd);
} }
void static void
window_choose_free(struct window_pane *wp) window_choose_free(struct window_pane *wp)
{ {
if (wp->modedata != NULL) if (wp->modedata != NULL)
window_choose_free1(wp->modedata); window_choose_free1(wp->modedata);
} }
void static void
window_choose_free1(struct window_choose_mode_data *data) window_choose_free1(struct window_choose_mode_data *data)
{ {
struct window_choose_mode_item *item; struct window_choose_mode_item *item;
@@ -301,7 +308,7 @@ window_choose_free1(struct window_choose_mode_data *data)
free(data); free(data);
} }
void static void
window_choose_resize(struct window_pane *wp, u_int sx, u_int sy) window_choose_resize(struct window_pane *wp, u_int sx, u_int sy)
{ {
struct window_choose_mode_data *data = wp->modedata; struct window_choose_mode_data *data = wp->modedata;
@@ -312,7 +319,7 @@ window_choose_resize(struct window_pane *wp, u_int sx, u_int sy)
window_choose_redraw_screen(wp); window_choose_redraw_screen(wp);
} }
void static void
window_choose_fire_callback(struct window_pane *wp, window_choose_fire_callback(struct window_pane *wp,
struct window_choose_data *wcd) struct window_choose_data *wcd)
{ {
@@ -326,7 +333,7 @@ window_choose_fire_callback(struct window_pane *wp,
window_choose_free1(data); window_choose_free1(data);
} }
void static void
window_choose_prompt_input(enum window_choose_input_type input_type, window_choose_prompt_input(enum window_choose_input_type input_type,
const char *prompt, struct window_pane *wp, key_code key) const char *prompt, struct window_pane *wp, key_code key)
{ {
@@ -344,7 +351,7 @@ window_choose_prompt_input(enum window_choose_input_type input_type,
window_choose_redraw_screen(wp); window_choose_redraw_screen(wp);
} }
void static void
window_choose_collapse(struct window_pane *wp, struct session *s, u_int pos) window_choose_collapse(struct window_pane *wp, struct session *s, u_int pos)
{ {
struct window_choose_mode_data *data = wp->modedata; struct window_choose_mode_data *data = wp->modedata;
@@ -395,7 +402,7 @@ window_choose_collapse(struct window_pane *wp, struct session *s, u_int pos)
} }
} }
void static void
window_choose_collapse_all(struct window_pane *wp) window_choose_collapse_all(struct window_pane *wp)
{ {
struct window_choose_mode_data *data = wp->modedata; struct window_choose_mode_data *data = wp->modedata;
@@ -446,7 +453,7 @@ window_choose_expand_all(struct window_pane *wp)
window_choose_reset_top(wp, screen_size_y(scr)); window_choose_reset_top(wp, screen_size_y(scr));
} }
void static void
window_choose_expand(struct window_pane *wp, struct session *s, u_int pos) window_choose_expand(struct window_pane *wp, struct session *s, u_int pos)
{ {
struct window_choose_mode_data *data = wp->modedata; struct window_choose_mode_data *data = wp->modedata;
@@ -518,7 +525,7 @@ window_choose_expand(struct window_pane *wp, struct session *s, u_int pos)
} }
} }
struct window_choose_mode_item * static struct window_choose_mode_item *
window_choose_get_item(struct window_pane *wp, key_code key, window_choose_get_item(struct window_pane *wp, key_code key,
struct mouse_event *m) struct mouse_event *m)
{ {
@@ -537,7 +544,7 @@ window_choose_get_item(struct window_pane *wp, key_code key,
return (&data->list[idx]); return (&data->list[idx]);
} }
void static void
window_choose_key(struct window_pane *wp, __unused struct client *c, window_choose_key(struct window_pane *wp, __unused struct client *c,
__unused struct session *sess, key_code key, struct mouse_event *m) __unused struct session *sess, key_code key, struct mouse_event *m)
{ {
@@ -552,7 +559,7 @@ window_choose_key(struct window_pane *wp, __unused struct client *c,
items = data->list_size; items = data->list_size;
if (data->input_type == WINDOW_CHOOSE_GOTO_ITEM) { if (data->input_type == WINDOW_CHOOSE_GOTO_ITEM) {
switch (mode_key_lookup(&data->mdata, key, NULL, NULL)) { switch (mode_key_lookup(&data->mdata, key)) {
case MODEKEYCHOICE_CANCEL: case MODEKEYCHOICE_CANCEL:
data->input_type = WINDOW_CHOOSE_NORMAL; data->input_type = WINDOW_CHOOSE_NORMAL;
window_choose_redraw_screen(wp); window_choose_redraw_screen(wp);
@@ -582,7 +589,7 @@ window_choose_key(struct window_pane *wp, __unused struct client *c,
return; return;
} }
switch (mode_key_lookup(&data->mdata, key, NULL, NULL)) { switch (mode_key_lookup(&data->mdata, key)) {
case MODEKEYCHOICE_CANCEL: case MODEKEYCHOICE_CANCEL:
window_choose_fire_callback(wp, NULL); window_choose_fire_callback(wp, NULL);
break; break;
@@ -769,7 +776,7 @@ window_choose_key(struct window_pane *wp, __unused struct client *c,
} }
} }
void static void
window_choose_write_line(struct window_pane *wp, struct screen_write_ctx *ctx, window_choose_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
u_int py) u_int py)
{ {
@@ -827,7 +834,7 @@ window_choose_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
} }
int static int
window_choose_key_index(struct window_choose_mode_data *data, u_int idx) window_choose_key_index(struct window_choose_mode_data *data, u_int idx)
{ {
static const char keys[] = "0123456789" static const char keys[] = "0123456789"
@@ -837,7 +844,7 @@ window_choose_key_index(struct window_choose_mode_data *data, u_int idx)
int mkey; int mkey;
for (ptr = keys; *ptr != '\0'; ptr++) { for (ptr = keys; *ptr != '\0'; ptr++) {
mkey = mode_key_lookup(&data->mdata, *ptr, NULL, NULL); mkey = mode_key_lookup(&data->mdata, *ptr);
if (mkey != MODEKEY_NONE && mkey != MODEKEY_OTHER) if (mkey != MODEKEY_NONE && mkey != MODEKEY_OTHER)
continue; continue;
if (idx-- == 0) if (idx-- == 0)
@@ -846,7 +853,7 @@ window_choose_key_index(struct window_choose_mode_data *data, u_int idx)
return (-1); return (-1);
} }
int static int
window_choose_index_key(struct window_choose_mode_data *data, key_code key) window_choose_index_key(struct window_choose_mode_data *data, key_code key)
{ {
static const char keys[] = "0123456789" static const char keys[] = "0123456789"
@@ -857,7 +864,7 @@ window_choose_index_key(struct window_choose_mode_data *data, key_code key)
u_int idx = 0; u_int idx = 0;
for (ptr = keys; *ptr != '\0'; ptr++) { for (ptr = keys; *ptr != '\0'; ptr++) {
mkey = mode_key_lookup(&data->mdata, *ptr, NULL, NULL); mkey = mode_key_lookup(&data->mdata, *ptr);
if (mkey != MODEKEY_NONE && mkey != MODEKEY_OTHER) if (mkey != MODEKEY_NONE && mkey != MODEKEY_OTHER)
continue; continue;
if (key == (key_code)*ptr) if (key == (key_code)*ptr)
@@ -867,7 +874,7 @@ window_choose_index_key(struct window_choose_mode_data *data, key_code key)
return (-1); return (-1);
} }
void static void
window_choose_redraw_screen(struct window_pane *wp) window_choose_redraw_screen(struct window_pane *wp)
{ {
struct window_choose_mode_data *data = wp->modedata; struct window_choose_mode_data *data = wp->modedata;
@@ -881,7 +888,7 @@ window_choose_redraw_screen(struct window_pane *wp)
screen_write_stop(&ctx); screen_write_stop(&ctx);
} }
void static void
window_choose_scroll_up(struct window_pane *wp) window_choose_scroll_up(struct window_pane *wp)
{ {
struct window_choose_mode_data *data = wp->modedata; struct window_choose_mode_data *data = wp->modedata;
@@ -900,7 +907,7 @@ window_choose_scroll_up(struct window_pane *wp)
screen_write_stop(&ctx); screen_write_stop(&ctx);
} }
void static void
window_choose_scroll_down(struct window_pane *wp) window_choose_scroll_down(struct window_pane *wp)
{ {
struct window_choose_mode_data *data = wp->modedata; struct window_choose_mode_data *data = wp->modedata;

View File

@@ -24,20 +24,20 @@
#include "tmux.h" #include "tmux.h"
struct screen *window_clock_init(struct window_pane *); static struct screen *window_clock_init(struct window_pane *);
void window_clock_free(struct window_pane *); static void window_clock_free(struct window_pane *);
void window_clock_resize(struct window_pane *, u_int, u_int); static void window_clock_resize(struct window_pane *, u_int, u_int);
void window_clock_key(struct window_pane *, struct client *, static void window_clock_key(struct window_pane *, struct client *,
struct session *, key_code, struct mouse_event *); struct session *, key_code, struct mouse_event *);
void window_clock_timer_callback(int, short, void *); static void window_clock_timer_callback(int, short, void *);
void window_clock_draw_screen(struct window_pane *); static void window_clock_draw_screen(struct window_pane *);
const struct window_mode window_clock_mode = { const struct window_mode window_clock_mode = {
window_clock_init, .init = window_clock_init,
window_clock_free, .free = window_clock_free,
window_clock_resize, .resize = window_clock_resize,
window_clock_key, .key = window_clock_key,
}; };
struct window_clock_mode_data { struct window_clock_mode_data {
@@ -119,7 +119,7 @@ const char window_clock_table[14][5][5] = {
{ 1,0,0,0,1 } }, { 1,0,0,0,1 } },
}; };
void static void
window_clock_timer_callback(__unused int fd, __unused short events, void *arg) window_clock_timer_callback(__unused int fd, __unused short events, void *arg)
{ {
struct window_pane *wp = arg; struct window_pane *wp = arg;
@@ -142,7 +142,7 @@ window_clock_timer_callback(__unused int fd, __unused short events, void *arg)
server_redraw_window(wp->window); server_redraw_window(wp->window);
} }
struct screen * static struct screen *
window_clock_init(struct window_pane *wp) window_clock_init(struct window_pane *wp)
{ {
struct window_clock_mode_data *data; struct window_clock_mode_data *data;
@@ -164,7 +164,7 @@ window_clock_init(struct window_pane *wp)
return (s); return (s);
} }
void static void
window_clock_free(struct window_pane *wp) window_clock_free(struct window_pane *wp)
{ {
struct window_clock_mode_data *data = wp->modedata; struct window_clock_mode_data *data = wp->modedata;
@@ -174,7 +174,7 @@ window_clock_free(struct window_pane *wp)
free(data); free(data);
} }
void static void
window_clock_resize(struct window_pane *wp, u_int sx, u_int sy) window_clock_resize(struct window_pane *wp, u_int sx, u_int sy)
{ {
struct window_clock_mode_data *data = wp->modedata; struct window_clock_mode_data *data = wp->modedata;
@@ -184,7 +184,7 @@ window_clock_resize(struct window_pane *wp, u_int sx, u_int sy)
window_clock_draw_screen(wp); window_clock_draw_screen(wp);
} }
void static void
window_clock_key(struct window_pane *wp, __unused struct client *c, window_clock_key(struct window_pane *wp, __unused struct client *c,
__unused struct session *sess, __unused key_code key, __unused struct session *sess, __unused key_code key,
__unused struct mouse_event *m) __unused struct mouse_event *m)
@@ -192,7 +192,7 @@ window_clock_key(struct window_pane *wp, __unused struct client *c,
window_pane_reset_mode(wp); window_pane_reset_mode(wp);
} }
void static void
window_clock_draw_screen(struct window_pane *wp) window_clock_draw_screen(struct window_pane *wp)
{ {
struct window_clock_mode_data *data = wp->modedata; struct window_clock_mode_data *data = wp->modedata;

File diff suppressed because it is too large Load Diff

View File

@@ -60,15 +60,23 @@ static u_int next_window_pane_id;
static u_int next_window_id; static u_int next_window_id;
static u_int next_active_point; static u_int next_active_point;
static struct window_pane *window_pane_create(struct window *, u_int, u_int,
u_int);
static void window_pane_destroy(struct window_pane *);
static void window_pane_set_watermark(struct window_pane *, size_t); static void window_pane_set_watermark(struct window_pane *, size_t);
static void window_pane_read_callback(struct bufferevent *, void *); static void window_pane_read_callback(struct bufferevent *, void *);
static void window_pane_error_callback(struct bufferevent *, short, void *); static void window_pane_error_callback(struct bufferevent *, short, void *);
static int winlink_next_index(struct winlinks *, int);
static struct window_pane *window_pane_choose_best(struct window_pane **, static struct window_pane *window_pane_choose_best(struct window_pane **,
u_int); u_int);
RB_GENERATE(windows, window, entry, window_cmp); RB_GENERATE(windows, window, entry, window_cmp);
RB_GENERATE(winlinks, winlink, entry, winlink_cmp);
RB_GENERATE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
int int
window_cmp(struct window *w1, struct window *w2) window_cmp(struct window *w1, struct window *w2)
@@ -76,16 +84,12 @@ window_cmp(struct window *w1, struct window *w2)
return (w1->id - w2->id); return (w1->id - w2->id);
} }
RB_GENERATE(winlinks, winlink, entry, winlink_cmp);
int int
winlink_cmp(struct winlink *wl1, struct winlink *wl2) winlink_cmp(struct winlink *wl1, struct winlink *wl2)
{ {
return (wl1->idx - wl2->idx); return (wl1->idx - wl2->idx);
} }
RB_GENERATE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
int int
window_pane_cmp(struct window_pane *wp1, struct window_pane *wp2) window_pane_cmp(struct window_pane *wp1, struct window_pane *wp2)
{ {
@@ -129,7 +133,7 @@ winlink_find_by_window_id(struct winlinks *wwl, u_int id)
return (NULL); return (NULL);
} }
int static int
winlink_next_index(struct winlinks *wwl, int idx) winlink_next_index(struct winlinks *wwl, int idx)
{ {
int i; int i;
@@ -731,7 +735,7 @@ window_pane_find_by_id(u_int id)
return (RB_FIND(window_pane_tree, &all_window_panes, &wp)); return (RB_FIND(window_pane_tree, &all_window_panes, &wp));
} }
struct window_pane * static struct window_pane *
window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit) window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
{ {
struct window_pane *wp; struct window_pane *wp;
@@ -782,7 +786,7 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
return (wp); return (wp);
} }
void static void
window_pane_destroy(struct window_pane *wp) window_pane_destroy(struct window_pane *wp)
{ {
window_pane_reset_mode(wp); window_pane_reset_mode(wp);
@@ -1139,6 +1143,7 @@ window_pane_reset_mode(struct window_pane *wp)
wp->mode->free(wp); wp->mode->free(wp);
wp->mode = NULL; wp->mode = NULL;
wp->modeprefix = 1;
wp->screen = &wp->base; wp->screen = &wp->base;
wp->flags |= (PANE_REDRAW|PANE_CHANGED); wp->flags |= (PANE_REDRAW|PANE_CHANGED);