mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-23 00:23:08 +01:00
Merge branch 'obsd-master'
Conflicts: Makefile cmd-list-commands.c cmd-suspend-client.c job.c tmux.h xmalloc.c
This commit is contained in:
commit
562af864bd
@ -82,7 +82,6 @@ dist_tmux_SOURCES = \
|
||||
cmd-display-message.c \
|
||||
cmd-display-panes.c \
|
||||
cmd-find-window.c \
|
||||
cmd-has-session.c \
|
||||
cmd-if-shell.c \
|
||||
cmd-join-pane.c \
|
||||
cmd-kill-pane.c \
|
||||
@ -92,7 +91,6 @@ dist_tmux_SOURCES = \
|
||||
cmd-link-window.c \
|
||||
cmd-list-buffers.c \
|
||||
cmd-list-clients.c \
|
||||
cmd-list-commands.c \
|
||||
cmd-list-keys.c \
|
||||
cmd-list-panes.c \
|
||||
cmd-list-sessions.c \
|
||||
@ -128,7 +126,6 @@ dist_tmux_SOURCES = \
|
||||
cmd-source-file.c \
|
||||
cmd-split-window.c \
|
||||
cmd-string.c \
|
||||
cmd-suspend-client.c \
|
||||
cmd-swap-pane.c \
|
||||
cmd-swap-window.c \
|
||||
cmd-switch-client.c \
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
4
array.h
4
array.h
@ -39,10 +39,10 @@
|
||||
fatalx("size too big"); \
|
||||
if ((a)->space == 0) { \
|
||||
(a)->space = ARRAY_INITIALSPACE(a); \
|
||||
(a)->list = xrealloc((a)->list, 1, (a)->space); \
|
||||
(a)->list = xrealloc((a)->list, (a)->space); \
|
||||
} \
|
||||
while ((a)->space <= ((a)->num + (n)) * ARRAY_ITEMSIZE(a)) { \
|
||||
(a)->list = xrealloc((a)->list, 2, (a)->space); \
|
||||
(a)->list = xreallocarray((a)->list, 2, (a)->space); \
|
||||
(a)->space *= 2; \
|
||||
} \
|
||||
} while (0)
|
||||
|
13
client.c
13
client.c
@ -26,6 +26,7 @@
|
||||
#include <errno.h>
|
||||
#include <event.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
@ -437,15 +438,11 @@ client_signal(int sig, unused short events, unused void *data)
|
||||
struct sigaction sigact;
|
||||
int status;
|
||||
|
||||
if (!client_attached) {
|
||||
switch (sig) {
|
||||
case SIGCHLD:
|
||||
waitpid(WAIT_ANY, &status, WNOHANG);
|
||||
break;
|
||||
case SIGTERM:
|
||||
if (sig == SIGCHLD)
|
||||
waitpid(WAIT_ANY, &status, WNOHANG);
|
||||
else if (!client_attached) {
|
||||
if (sig == SIGTERM)
|
||||
event_loopexit(NULL);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (sig) {
|
||||
case SIGHUP:
|
||||
|
@ -37,7 +37,6 @@ const struct cmd_entry cmd_attach_session_entry = {
|
||||
"c:drt:", 0, 0,
|
||||
"[-dr] [-c working-directory] " CMD_TARGET_SESSION_USAGE,
|
||||
CMD_CANTNEST|CMD_STARTSERVER,
|
||||
NULL,
|
||||
cmd_attach_session_exec
|
||||
};
|
||||
|
||||
|
@ -36,7 +36,6 @@ const struct cmd_entry cmd_bind_key_entry = {
|
||||
"cnrt:", 1, -1,
|
||||
"[-cnr] [-t mode-table] key command [arguments]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_bind_key_exec
|
||||
};
|
||||
|
||||
|
@ -26,6 +26,8 @@
|
||||
* Break pane off into a window.
|
||||
*/
|
||||
|
||||
#define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
||||
|
||||
enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_break_pane_entry = {
|
||||
@ -33,7 +35,6 @@ const struct cmd_entry cmd_break_pane_entry = {
|
||||
"dPF:t:", 0, 0,
|
||||
"[-dP] [-F format] " CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_break_pane_exec
|
||||
};
|
||||
|
||||
|
@ -41,14 +41,13 @@ const struct cmd_entry cmd_capture_pane_entry = {
|
||||
"[-aCeJpPq] " CMD_BUFFER_USAGE " [-E end-line] [-S start-line]"
|
||||
CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_capture_pane_exec
|
||||
};
|
||||
|
||||
char *
|
||||
cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen)
|
||||
{
|
||||
buf = xrealloc(buf, 1, *len + linelen + 1);
|
||||
buf = xrealloc(buf, *len + linelen + 1);
|
||||
memcpy(buf + *len, line, linelen);
|
||||
*len += linelen;
|
||||
return (buf);
|
||||
|
@ -27,6 +27,9 @@
|
||||
* Enter choice mode to choose a buffer.
|
||||
*/
|
||||
|
||||
#define CHOOSE_BUFFER_TEMPLATE \
|
||||
"#{buffer_name}: #{buffer_size} bytes: #{buffer_sample}"
|
||||
|
||||
enum cmd_retval cmd_choose_buffer_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_choose_buffer_entry = {
|
||||
@ -34,7 +37,6 @@ const struct cmd_entry cmd_choose_buffer_entry = {
|
||||
"F:t:", 0, 1,
|
||||
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_choose_buffer_exec
|
||||
};
|
||||
|
||||
|
@ -27,6 +27,12 @@
|
||||
* Enter choice mode to choose a client.
|
||||
*/
|
||||
|
||||
#define CHOOSE_CLIENT_TEMPLATE \
|
||||
"#{client_tty}: #{session_name} " \
|
||||
"[#{client_width}x#{client_height} #{client_termname}]" \
|
||||
"#{?client_utf8, (utf8),}#{?client_readonly, (ro),} " \
|
||||
"(last used #{client_activity_string})"
|
||||
|
||||
enum cmd_retval cmd_choose_client_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
void cmd_choose_client_callback(struct window_choose_data *);
|
||||
@ -36,7 +42,6 @@ const struct cmd_entry cmd_choose_client_entry = {
|
||||
"F:t:", 0, 1,
|
||||
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_choose_client_exec
|
||||
};
|
||||
|
||||
|
@ -32,6 +32,15 @@
|
||||
* Enter choice mode to choose a session and/or window.
|
||||
*/
|
||||
|
||||
#define CHOOSE_TREE_SESSION_TEMPLATE \
|
||||
"#{session_name}: #{session_windows} windows" \
|
||||
"#{?session_grouped, (group ,}" \
|
||||
"#{session_group}#{?session_grouped,),}" \
|
||||
"#{?session_attached, (attached),}"
|
||||
#define CHOOSE_TREE_WINDOW_TEMPLATE \
|
||||
"#{window_index}: #{window_name}#{window_flags} " \
|
||||
"\"#{pane_title}\""
|
||||
|
||||
enum cmd_retval cmd_choose_tree_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_choose_tree_entry = {
|
||||
@ -40,7 +49,6 @@ const struct cmd_entry cmd_choose_tree_entry = {
|
||||
"[-suw] [-b session-template] [-c window template] [-S format] " \
|
||||
"[-W format] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_choose_tree_exec
|
||||
};
|
||||
|
||||
@ -49,7 +57,6 @@ const struct cmd_entry cmd_choose_session_entry = {
|
||||
"F:t:", 0, 1,
|
||||
CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_choose_tree_exec
|
||||
};
|
||||
|
||||
@ -58,7 +65,6 @@ const struct cmd_entry cmd_choose_window_entry = {
|
||||
"F:t:", 0, 1,
|
||||
CMD_TARGET_WINDOW_USAGE "[-F format] [template]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_choose_tree_exec
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,6 @@ const struct cmd_entry cmd_clear_history_entry = {
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_clear_history_exec
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,6 @@ const struct cmd_entry cmd_clock_mode_entry = {
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_clock_mode_exec
|
||||
};
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
* Prompt for command in client.
|
||||
*/
|
||||
|
||||
void cmd_command_prompt_key_binding(struct cmd *, int);
|
||||
enum cmd_retval cmd_command_prompt_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
int cmd_command_prompt_callback(void *, const char *);
|
||||
@ -40,7 +39,6 @@ const struct cmd_entry cmd_command_prompt_entry = {
|
||||
"I:p:t:", 0, 1,
|
||||
"[-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " [template]",
|
||||
0,
|
||||
cmd_command_prompt_key_binding,
|
||||
cmd_command_prompt_exec
|
||||
};
|
||||
|
||||
@ -54,34 +52,6 @@ struct cmd_command_prompt_cdata {
|
||||
int idx;
|
||||
};
|
||||
|
||||
void
|
||||
cmd_command_prompt_key_binding(struct cmd *self, int key)
|
||||
{
|
||||
switch (key) {
|
||||
case '$':
|
||||
self->args = args_create(1, "rename-session '%%'");
|
||||
args_set(self->args, 'I', "#S");
|
||||
break;
|
||||
case ',':
|
||||
self->args = args_create(1, "rename-window '%%'");
|
||||
args_set(self->args, 'I', "#W");
|
||||
break;
|
||||
case '.':
|
||||
self->args = args_create(1, "move-window -t '%%'");
|
||||
break;
|
||||
case 'f':
|
||||
self->args = args_create(1, "find-window '%%'");
|
||||
break;
|
||||
case '\'':
|
||||
self->args = args_create(1, "select-window -t ':%%'");
|
||||
args_set(self->args, 'p', "index");
|
||||
break;
|
||||
default:
|
||||
self->args = args_create(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
|
@ -16,6 +16,8 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -26,7 +28,6 @@
|
||||
* Asks for confirmation before executing a command.
|
||||
*/
|
||||
|
||||
void cmd_confirm_before_key_binding(struct cmd *, int);
|
||||
enum cmd_retval cmd_confirm_before_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
int cmd_confirm_before_callback(void *, const char *);
|
||||
@ -37,7 +38,6 @@ const struct cmd_entry cmd_confirm_before_entry = {
|
||||
"p:t:", 1, 1,
|
||||
"[-p prompt] " CMD_TARGET_CLIENT_USAGE " command",
|
||||
0,
|
||||
cmd_confirm_before_key_binding,
|
||||
cmd_confirm_before_exec
|
||||
};
|
||||
|
||||
@ -46,24 +46,6 @@ struct cmd_confirm_before_data {
|
||||
struct client *client;
|
||||
};
|
||||
|
||||
void
|
||||
cmd_confirm_before_key_binding(struct cmd *self, int key)
|
||||
{
|
||||
switch (key) {
|
||||
case '&':
|
||||
self->args = args_create(1, "kill-window");
|
||||
args_set(self->args, 'p', "kill-window #W? (y/n)");
|
||||
break;
|
||||
case 'x':
|
||||
self->args = args_create(1, "kill-pane");
|
||||
args_set(self->args, 'p', "kill-pane #P? (y/n)");
|
||||
break;
|
||||
default:
|
||||
self->args = args_create(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
|
@ -24,7 +24,6 @@
|
||||
* Enter copy mode.
|
||||
*/
|
||||
|
||||
void cmd_copy_mode_key_binding(struct cmd *, int);
|
||||
enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_copy_mode_entry = {
|
||||
@ -32,18 +31,9 @@ const struct cmd_entry cmd_copy_mode_entry = {
|
||||
"t:u", 0, 0,
|
||||
"[-u] " CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
cmd_copy_mode_key_binding,
|
||||
cmd_copy_mode_exec
|
||||
};
|
||||
|
||||
void
|
||||
cmd_copy_mode_key_binding(struct cmd *self, int key)
|
||||
{
|
||||
self->args = args_create(0);
|
||||
if (key == KEYC_PPAGE)
|
||||
args_set(self->args, 'u', NULL);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
|
@ -33,7 +33,6 @@ const struct cmd_entry cmd_delete_buffer_entry = {
|
||||
"b:", 0, 0,
|
||||
CMD_BUFFER_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_delete_buffer_exec
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,14 @@ const struct cmd_entry cmd_detach_client_entry = {
|
||||
"as:t:P", 0, 0,
|
||||
"[-P] [-a] [-s target-session] " CMD_TARGET_CLIENT_USAGE,
|
||||
CMD_READONLY,
|
||||
NULL,
|
||||
cmd_detach_client_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_suspend_client_entry = {
|
||||
"suspend-client", "suspendc",
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_CLIENT_USAGE,
|
||||
0,
|
||||
cmd_detach_client_exec
|
||||
};
|
||||
|
||||
@ -46,6 +53,15 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
enum msgtype msgtype;
|
||||
u_int i;
|
||||
|
||||
if (self->entry == &cmd_suspend_client_entry) {
|
||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
tty_stop_tty(&c->tty);
|
||||
c->flags |= CLIENT_SUSPENDED;
|
||||
server_write_client(c, MSG_SUSPEND, NULL, 0);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 'P'))
|
||||
msgtype = MSG_DETACHKILL;
|
||||
else
|
||||
|
@ -27,6 +27,11 @@
|
||||
* Displays a message in the status line.
|
||||
*/
|
||||
|
||||
#define DISPLAY_MESSAGE_TEMPLATE \
|
||||
"[#{session_name}] #{window_index}:" \
|
||||
"#{window_name}, current pane #{pane_index} " \
|
||||
"- (%H:%M %d-%b-%y)"
|
||||
|
||||
enum cmd_retval cmd_display_message_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_display_message_entry = {
|
||||
@ -35,7 +40,6 @@ const struct cmd_entry cmd_display_message_entry = {
|
||||
"[-p] [-c target-client] [-F format] " CMD_TARGET_PANE_USAGE
|
||||
" [message]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_display_message_exec
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,6 @@ const struct cmd_entry cmd_display_panes_entry = {
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_CLIENT_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_display_panes_exec
|
||||
};
|
||||
|
||||
|
@ -28,6 +28,11 @@
|
||||
* Find window containing text.
|
||||
*/
|
||||
|
||||
#define FIND_WINDOW_TEMPLATE \
|
||||
"#{window_index}: #{window_name} " \
|
||||
"[#{window_width}x#{window_height}] " \
|
||||
"(#{window_panes} panes) #{window_find_matches}"
|
||||
|
||||
enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
void cmd_find_window_callback(struct window_choose_data *);
|
||||
@ -47,7 +52,6 @@ const struct cmd_entry cmd_find_window_entry = {
|
||||
"F:CNt:T", 1, 4,
|
||||
"[-CNT] [-F format] " CMD_TARGET_WINDOW_USAGE " match-string",
|
||||
0,
|
||||
NULL,
|
||||
cmd_find_window_exec
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,6 @@ const struct cmd_entry cmd_has_session_entry = {
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_has_session_exec
|
||||
};
|
||||
|
||||
|
@ -40,7 +40,6 @@ const struct cmd_entry cmd_if_shell_entry = {
|
||||
"bt:", 2, 3,
|
||||
"[-b] " CMD_TARGET_PANE_USAGE " shell-command command [command]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_if_shell_exec
|
||||
};
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
* Join or move a pane into another (like split/swap/kill).
|
||||
*/
|
||||
|
||||
void cmd_join_pane_key_binding(struct cmd *, int);
|
||||
enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
enum cmd_retval join_pane(struct cmd *, struct cmd_q *, int);
|
||||
@ -38,7 +37,6 @@ const struct cmd_entry cmd_join_pane_entry = {
|
||||
"bdhvp:l:s:t:", 0, 0,
|
||||
"[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
|
||||
0,
|
||||
cmd_join_pane_key_binding,
|
||||
cmd_join_pane_exec
|
||||
};
|
||||
|
||||
@ -47,24 +45,9 @@ const struct cmd_entry cmd_move_pane_entry = {
|
||||
"bdhvp:l:s:t:", 0, 0,
|
||||
"[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_join_pane_exec
|
||||
};
|
||||
|
||||
void
|
||||
cmd_join_pane_key_binding(struct cmd *self, int key)
|
||||
{
|
||||
switch (key) {
|
||||
case '%':
|
||||
self->args = args_create(0);
|
||||
args_set(self->args, 'h', NULL);
|
||||
break;
|
||||
default:
|
||||
self->args = args_create(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_join_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
|
@ -33,7 +33,6 @@ const struct cmd_entry cmd_kill_pane_entry = {
|
||||
"at:", 0, 0,
|
||||
"[-a] " CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_kill_pane_exec
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,6 @@ const struct cmd_entry cmd_kill_server_entry = {
|
||||
"", 0, 0,
|
||||
"",
|
||||
0,
|
||||
NULL,
|
||||
cmd_kill_server_exec
|
||||
};
|
||||
|
||||
@ -43,7 +42,6 @@ const struct cmd_entry cmd_start_server_entry = {
|
||||
"", 0, 0,
|
||||
"",
|
||||
CMD_STARTSERVER,
|
||||
NULL,
|
||||
cmd_kill_server_exec
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,6 @@ const struct cmd_entry cmd_kill_session_entry = {
|
||||
"at:", 0, 0,
|
||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_kill_session_exec
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,6 @@ const struct cmd_entry cmd_kill_window_entry = {
|
||||
"at:", 0, 0,
|
||||
"[-a] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_kill_window_exec
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,6 @@ const struct cmd_entry cmd_link_window_entry = {
|
||||
"dks:t:", 0, 0,
|
||||
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_link_window_exec
|
||||
};
|
||||
|
||||
|
@ -27,6 +27,9 @@
|
||||
* List paste buffers.
|
||||
*/
|
||||
|
||||
#define LIST_BUFFERS_TEMPLATE \
|
||||
"#{buffer_name}: #{buffer_size} bytes: \"#{buffer_sample}\""
|
||||
|
||||
enum cmd_retval cmd_list_buffers_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_list_buffers_entry = {
|
||||
@ -34,7 +37,6 @@ const struct cmd_entry cmd_list_buffers_entry = {
|
||||
"F:", 0, 0,
|
||||
"[-F format]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_list_buffers_exec
|
||||
};
|
||||
|
||||
|
@ -28,6 +28,11 @@
|
||||
* List all clients.
|
||||
*/
|
||||
|
||||
#define LIST_CLIENTS_TEMPLATE \
|
||||
"#{client_tty}: #{session_name} " \
|
||||
"[#{client_width}x#{client_height} #{client_termname}]" \
|
||||
"#{?client_utf8, (utf8),} #{?client_readonly, (ro),}"
|
||||
|
||||
enum cmd_retval cmd_list_clients_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_list_clients_entry = {
|
||||
@ -35,7 +40,6 @@ const struct cmd_entry cmd_list_clients_entry = {
|
||||
"F:t:", 0, 0,
|
||||
"[-F format] " CMD_TARGET_SESSION_USAGE,
|
||||
CMD_READONLY,
|
||||
NULL,
|
||||
cmd_list_clients_exec
|
||||
};
|
||||
|
||||
|
@ -1,54 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* List all commands with usages.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_list_commands_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_list_commands_entry = {
|
||||
"list-commands", "lscm",
|
||||
"", 0, 0,
|
||||
"",
|
||||
0,
|
||||
NULL,
|
||||
cmd_list_commands_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_list_commands_exec(unused struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
const struct cmd_entry **entryp;
|
||||
|
||||
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
||||
if ((*entryp)->alias != NULL) {
|
||||
cmdq_print(cmdq, "%s (%s) %s", (*entryp)->name,
|
||||
(*entryp)->alias, (*entryp)->usage);
|
||||
} else {
|
||||
cmdq_print(cmdq, "%s %s", (*entryp)->name,
|
||||
(*entryp)->usage);
|
||||
}
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
@ -27,14 +27,23 @@
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
enum cmd_retval cmd_list_keys_table(struct cmd *, struct cmd_q *);
|
||||
enum cmd_retval cmd_list_keys_commands(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_list_keys_entry = {
|
||||
"list-keys", "lsk",
|
||||
"t:", 0, 0,
|
||||
"[-t key-table]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_list_keys_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_list_commands_entry = {
|
||||
"list-commands", "lscm",
|
||||
"", 0, 0,
|
||||
"",
|
||||
0,
|
||||
cmd_list_keys_exec
|
||||
};
|
||||
|
||||
@ -48,6 +57,9 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
size_t used;
|
||||
int width, keywidth;
|
||||
|
||||
if (self->entry == &cmd_list_commands_entry)
|
||||
return (cmd_list_keys_commands(self, cmdq));
|
||||
|
||||
if (args_has(args, 't'))
|
||||
return (cmd_list_keys_table(self, cmdq));
|
||||
|
||||
@ -148,3 +160,22 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_list_keys_commands(unused struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
const struct cmd_entry **entryp;
|
||||
const struct cmd_entry *entry;
|
||||
|
||||
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
||||
entry = *entryp;
|
||||
if (entry->alias == NULL) {
|
||||
cmdq_print(cmdq, "%s %s", entry->name, entry->usage);
|
||||
continue;
|
||||
}
|
||||
cmdq_print(cmdq, "%s (%s) %s", entry->name, entry->alias,
|
||||
entry->usage);
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ const struct cmd_entry cmd_list_panes_entry = {
|
||||
"asF:t:", 0, 0,
|
||||
"[-as] [-F format] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_list_panes_exec
|
||||
};
|
||||
|
||||
|
@ -28,6 +28,14 @@
|
||||
* List all sessions.
|
||||
*/
|
||||
|
||||
#define LIST_SESSIONS_TEMPLATE \
|
||||
"#{session_name}: #{session_windows} windows " \
|
||||
"(created #{session_created_string}) " \
|
||||
"[#{session_width}x#{session_height}]" \
|
||||
"#{?session_grouped, (group ,}" \
|
||||
"#{session_group}#{?session_grouped,),}" \
|
||||
"#{?session_attached, (attached),}"
|
||||
|
||||
enum cmd_retval cmd_list_sessions_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_list_sessions_entry = {
|
||||
@ -35,7 +43,6 @@ const struct cmd_entry cmd_list_sessions_entry = {
|
||||
"F:", 0, 0,
|
||||
"[-F format]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_list_sessions_exec
|
||||
};
|
||||
|
||||
|
@ -27,18 +27,29 @@
|
||||
* List windows on given session.
|
||||
*/
|
||||
|
||||
#define LIST_WINDOWS_TEMPLATE \
|
||||
"#{window_index}: #{window_name}#{window_flags} " \
|
||||
"(#{window_panes} panes) " \
|
||||
"[#{window_width}x#{window_height}] " \
|
||||
"[layout #{window_layout}] #{window_id}" \
|
||||
"#{?window_active, (active),}";
|
||||
#define LIST_WINDOWS_WITH_SESSION_TEMPLATE \
|
||||
"#{session_name}:" \
|
||||
"#{window_index}: #{window_name}#{window_flags} " \
|
||||
"(#{window_panes} panes) " \
|
||||
"[#{window_width}x#{window_height}] "
|
||||
|
||||
enum cmd_retval cmd_list_windows_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
void cmd_list_windows_server(struct cmd *, struct cmd_q *);
|
||||
void cmd_list_windows_session(
|
||||
struct cmd *, struct session *, struct cmd_q *, int);
|
||||
void cmd_list_windows_session(struct cmd *, struct session *,
|
||||
struct cmd_q *, int);
|
||||
|
||||
const struct cmd_entry cmd_list_windows_entry = {
|
||||
"list-windows", "lsw",
|
||||
"F:at:", 0, 0,
|
||||
"[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_list_windows_exec
|
||||
};
|
||||
|
||||
|
@ -39,7 +39,6 @@ const struct cmd_entry cmd_load_buffer_entry = {
|
||||
"b:", 1, 1,
|
||||
CMD_BUFFER_USAGE " path",
|
||||
0,
|
||||
NULL,
|
||||
cmd_load_buffer_exec
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,6 @@ const struct cmd_entry cmd_lock_server_entry = {
|
||||
"", 0, 0,
|
||||
"",
|
||||
0,
|
||||
NULL,
|
||||
cmd_lock_server_exec
|
||||
};
|
||||
|
||||
@ -40,7 +39,6 @@ const struct cmd_entry cmd_lock_session_entry = {
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_lock_server_exec
|
||||
};
|
||||
|
||||
@ -49,7 +47,6 @@ const struct cmd_entry cmd_lock_client_entry = {
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_CLIENT_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_lock_server_exec
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,6 @@ const struct cmd_entry cmd_move_window_entry = {
|
||||
"dkrs:t:", 0, 0,
|
||||
"[-dkr] " CMD_SRCDST_WINDOW_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_move_window_exec
|
||||
};
|
||||
|
||||
|
@ -31,6 +31,8 @@
|
||||
* Create a new session and attach to the current terminal unless -d is given.
|
||||
*/
|
||||
|
||||
#define NEW_SESSION_TEMPLATE "#{session_name}:"
|
||||
|
||||
enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_new_session_entry = {
|
||||
@ -40,7 +42,14 @@ const struct cmd_entry cmd_new_session_entry = {
|
||||
"[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "
|
||||
"[-y height] [command]",
|
||||
CMD_STARTSERVER|CMD_CANTNEST,
|
||||
NULL,
|
||||
cmd_new_session_exec
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_has_session_entry = {
|
||||
"has-session", "has",
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
cmd_new_session_exec
|
||||
};
|
||||
|
||||
@ -62,6 +71,12 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
struct format_tree *ft;
|
||||
struct environ_entry *envent;
|
||||
|
||||
if (self->entry == &cmd_has_session_entry) {
|
||||
if (cmd_find_session(cmdq, args_get(args, 't'), 0) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) {
|
||||
cmdq_error(cmdq, "command or window name given with target");
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
@ -30,6 +30,8 @@
|
||||
* Create a new window.
|
||||
*/
|
||||
|
||||
#define NEW_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
||||
|
||||
enum cmd_retval cmd_new_window_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_new_window_entry = {
|
||||
@ -38,7 +40,6 @@ const struct cmd_entry cmd_new_window_entry = {
|
||||
"[-adkP] [-c start-directory] [-F format] [-n window-name] "
|
||||
CMD_TARGET_WINDOW_USAGE " [command]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_new_window_exec
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,6 @@ const struct cmd_entry cmd_paste_buffer_entry = {
|
||||
"db:prs:t:", 0, 0,
|
||||
"[-dpr] [-s separator] " CMD_BUFFER_USAGE " " CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_paste_buffer_exec
|
||||
};
|
||||
|
||||
|
@ -40,7 +40,6 @@ const struct cmd_entry cmd_pipe_pane_entry = {
|
||||
"ot:", 0, 1,
|
||||
"[-o] " CMD_TARGET_PANE_USAGE " [command]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_pipe_pane_exec
|
||||
};
|
||||
|
||||
|
@ -57,7 +57,7 @@ cmdq_free(struct cmd_q *cmdq)
|
||||
}
|
||||
|
||||
/* Show message from command. */
|
||||
void printflike2
|
||||
void
|
||||
cmdq_print(struct cmd_q *cmdq, const char *fmt, ...)
|
||||
{
|
||||
struct client *c = cmdq->client;
|
||||
@ -87,7 +87,7 @@ cmdq_print(struct cmd_q *cmdq, const char *fmt, ...)
|
||||
}
|
||||
|
||||
/* Show error from command. */
|
||||
void printflike2
|
||||
void
|
||||
cmdq_error(struct cmd_q *cmdq, const char *fmt, ...)
|
||||
{
|
||||
struct client *c = cmdq->client;
|
||||
|
@ -31,7 +31,6 @@ const struct cmd_entry cmd_refresh_client_entry = {
|
||||
"C:St:", 0, 0,
|
||||
"[-S] [-C size] " CMD_TARGET_CLIENT_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_refresh_client_exec
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,6 @@ const struct cmd_entry cmd_rename_session_entry = {
|
||||
"t:", 1, 1,
|
||||
CMD_TARGET_SESSION_USAGE " new-name",
|
||||
0,
|
||||
NULL,
|
||||
cmd_rename_session_exec
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,6 @@ const struct cmd_entry cmd_rename_window_entry = {
|
||||
"t:", 1, 1,
|
||||
CMD_TARGET_WINDOW_USAGE " new-name",
|
||||
0,
|
||||
NULL,
|
||||
cmd_rename_window_exec
|
||||
};
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
* Increase or decrease pane size.
|
||||
*/
|
||||
|
||||
void cmd_resize_pane_key_binding(struct cmd *, int);
|
||||
enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_resize_pane_entry = {
|
||||
@ -34,56 +33,9 @@ const struct cmd_entry cmd_resize_pane_entry = {
|
||||
"DLRt:Ux:y:Z", 0, 1,
|
||||
"[-DLRUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " [adjustment]",
|
||||
0,
|
||||
cmd_resize_pane_key_binding,
|
||||
cmd_resize_pane_exec
|
||||
};
|
||||
|
||||
void
|
||||
cmd_resize_pane_key_binding(struct cmd *self, int key)
|
||||
{
|
||||
switch (key) {
|
||||
case KEYC_UP | KEYC_CTRL:
|
||||
self->args = args_create(0);
|
||||
args_set(self->args, 'U', NULL);
|
||||
break;
|
||||
case KEYC_DOWN | KEYC_CTRL:
|
||||
self->args = args_create(0);
|
||||
args_set(self->args, 'D', NULL);
|
||||
break;
|
||||
case KEYC_LEFT | KEYC_CTRL:
|
||||
self->args = args_create(0);
|
||||
args_set(self->args, 'L', NULL);
|
||||
break;
|
||||
case KEYC_RIGHT | KEYC_CTRL:
|
||||
self->args = args_create(0);
|
||||
args_set(self->args, 'R', NULL);
|
||||
break;
|
||||
case KEYC_UP | KEYC_ESCAPE:
|
||||
self->args = args_create(1, "5");
|
||||
args_set(self->args, 'U', NULL);
|
||||
break;
|
||||
case KEYC_DOWN | KEYC_ESCAPE:
|
||||
self->args = args_create(1, "5");
|
||||
args_set(self->args, 'D', NULL);
|
||||
break;
|
||||
case KEYC_LEFT | KEYC_ESCAPE:
|
||||
self->args = args_create(1, "5");
|
||||
args_set(self->args, 'L', NULL);
|
||||
break;
|
||||
case KEYC_RIGHT | KEYC_ESCAPE:
|
||||
self->args = args_create(1, "5");
|
||||
args_set(self->args, 'R', NULL);
|
||||
break;
|
||||
case 'z':
|
||||
self->args = args_create(0);
|
||||
args_set(self->args, 'Z', NULL);
|
||||
break;
|
||||
default:
|
||||
self->args = args_create(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
|
@ -35,7 +35,6 @@ const struct cmd_entry cmd_respawn_pane_entry = {
|
||||
"kt:", 0, -1,
|
||||
"[-k] " CMD_TARGET_PANE_USAGE " [command]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_respawn_pane_exec
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,6 @@ const struct cmd_entry cmd_respawn_window_entry = {
|
||||
"kt:", 0, -1,
|
||||
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_respawn_window_exec
|
||||
};
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
* Rotate the panes in a window.
|
||||
*/
|
||||
|
||||
void cmd_rotate_window_key_binding(struct cmd *, int);
|
||||
enum cmd_retval cmd_rotate_window_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_rotate_window_entry = {
|
||||
@ -32,18 +31,9 @@ const struct cmd_entry cmd_rotate_window_entry = {
|
||||
"Dt:U", 0, 0,
|
||||
"[-DU] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_rotate_window_key_binding,
|
||||
cmd_rotate_window_exec
|
||||
};
|
||||
|
||||
void
|
||||
cmd_rotate_window_key_binding(struct cmd *self, int key)
|
||||
{
|
||||
self->args = args_create(0);
|
||||
if (key == ('o' | KEYC_ESCAPE))
|
||||
args_set(self->args, 'D', NULL);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_rotate_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
|
@ -40,7 +40,6 @@ const struct cmd_entry cmd_run_shell_entry = {
|
||||
"bt:", 1, 1,
|
||||
"[-b] " CMD_TARGET_PANE_USAGE " shell-command",
|
||||
0,
|
||||
NULL,
|
||||
cmd_run_shell_exec
|
||||
};
|
||||
|
||||
|
@ -38,7 +38,6 @@ const struct cmd_entry cmd_save_buffer_entry = {
|
||||
"ab:", 1, 1,
|
||||
"[-a] " CMD_BUFFER_USAGE " path",
|
||||
0,
|
||||
NULL,
|
||||
cmd_save_buffer_exec
|
||||
};
|
||||
|
||||
@ -47,7 +46,6 @@ const struct cmd_entry cmd_show_buffer_entry = {
|
||||
"b:", 0, 0,
|
||||
CMD_BUFFER_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_save_buffer_exec
|
||||
};
|
||||
|
||||
@ -146,7 +144,7 @@ do_print:
|
||||
size = pb->size - used;
|
||||
|
||||
msglen = size * 4 + 1;
|
||||
msg = xrealloc(msg, 1, msglen);
|
||||
msg = xrealloc(msg, msglen);
|
||||
|
||||
strvisx(msg, start, size, VIS_OCTAL|VIS_TAB);
|
||||
cmdq_print(cmdq, "%s", msg);
|
||||
|
@ -24,7 +24,6 @@
|
||||
* Switch window to selected layout.
|
||||
*/
|
||||
|
||||
void cmd_select_layout_key_binding(struct cmd *, int);
|
||||
enum cmd_retval cmd_select_layout_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_select_layout_entry = {
|
||||
@ -32,7 +31,6 @@ const struct cmd_entry cmd_select_layout_entry = {
|
||||
"npt:", 0, 1,
|
||||
"[-np] " CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
||||
0,
|
||||
cmd_select_layout_key_binding,
|
||||
cmd_select_layout_exec
|
||||
};
|
||||
|
||||
@ -41,7 +39,6 @@ const struct cmd_entry cmd_next_layout_entry = {
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_select_layout_exec
|
||||
};
|
||||
|
||||
@ -50,35 +47,9 @@ const struct cmd_entry cmd_previous_layout_entry = {
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_select_layout_exec
|
||||
};
|
||||
|
||||
void
|
||||
cmd_select_layout_key_binding(struct cmd *self, int key)
|
||||
{
|
||||
switch (key) {
|
||||
case '1' | KEYC_ESCAPE:
|
||||
self->args = args_create(1, "even-horizontal");
|
||||
break;
|
||||
case '2' | KEYC_ESCAPE:
|
||||
self->args = args_create(1, "even-vertical");
|
||||
break;
|
||||
case '3' | KEYC_ESCAPE:
|
||||
self->args = args_create(1, "main-horizontal");
|
||||
break;
|
||||
case '4' | KEYC_ESCAPE:
|
||||
self->args = args_create(1, "main-vertical");
|
||||
break;
|
||||
case '5' | KEYC_ESCAPE:
|
||||
self->args = args_create(1, "tiled");
|
||||
break;
|
||||
default:
|
||||
self->args = args_create(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
|
@ -24,7 +24,6 @@
|
||||
* Select pane.
|
||||
*/
|
||||
|
||||
void cmd_select_pane_key_binding(struct cmd *, int);
|
||||
enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_select_pane_entry = {
|
||||
@ -32,7 +31,6 @@ const struct cmd_entry cmd_select_pane_entry = {
|
||||
"DdeLlRt:U", 0, 0,
|
||||
"[-DdeLlRU] " CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
cmd_select_pane_key_binding,
|
||||
cmd_select_pane_exec
|
||||
};
|
||||
|
||||
@ -41,26 +39,9 @@ const struct cmd_entry cmd_last_pane_entry = {
|
||||
"det:", 0, 0,
|
||||
"[-de] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_select_pane_exec
|
||||
};
|
||||
|
||||
void
|
||||
cmd_select_pane_key_binding(struct cmd *self, int key)
|
||||
{
|
||||
self->args = args_create(0);
|
||||
if (key == KEYC_UP)
|
||||
args_set(self->args, 'U', NULL);
|
||||
if (key == KEYC_DOWN)
|
||||
args_set(self->args, 'D', NULL);
|
||||
if (key == KEYC_LEFT)
|
||||
args_set(self->args, 'L', NULL);
|
||||
if (key == KEYC_RIGHT)
|
||||
args_set(self->args, 'R', NULL);
|
||||
if (key == 'o')
|
||||
args_set(self->args, 't', ":.+");
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
|
@ -26,7 +26,6 @@
|
||||
* Select window by index.
|
||||
*/
|
||||
|
||||
void cmd_select_window_key_binding(struct cmd *, int);
|
||||
enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_select_window_entry = {
|
||||
@ -34,7 +33,6 @@ const struct cmd_entry cmd_select_window_entry = {
|
||||
"lnpTt:", 0, 0,
|
||||
"[-lnpT] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
cmd_select_window_key_binding,
|
||||
cmd_select_window_exec
|
||||
};
|
||||
|
||||
@ -43,7 +41,6 @@ const struct cmd_entry cmd_next_window_entry = {
|
||||
"at:", 0, 0,
|
||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
cmd_select_window_key_binding,
|
||||
cmd_select_window_exec
|
||||
};
|
||||
|
||||
@ -52,7 +49,6 @@ const struct cmd_entry cmd_previous_window_entry = {
|
||||
"at:", 0, 0,
|
||||
"[-a] " CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
cmd_select_window_key_binding,
|
||||
cmd_select_window_exec
|
||||
};
|
||||
|
||||
@ -61,24 +57,9 @@ const struct cmd_entry cmd_last_window_entry = {
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_SESSION_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_select_window_exec
|
||||
};
|
||||
|
||||
void
|
||||
cmd_select_window_key_binding(struct cmd *self, int key)
|
||||
{
|
||||
char tmp[16];
|
||||
|
||||
self->args = args_create(0);
|
||||
if (key >= '0' && key <= '9') {
|
||||
xsnprintf(tmp, sizeof tmp, ":%d", key - '0');
|
||||
args_set(self->args, 't', tmp);
|
||||
}
|
||||
if (key == ('n' | KEYC_ESCAPE) || key == ('p' | KEYC_ESCAPE))
|
||||
args_set(self->args, 'a', NULL);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_select_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
|
@ -34,7 +34,6 @@ const struct cmd_entry cmd_send_keys_entry = {
|
||||
"lRt:", 0, -1,
|
||||
"[-lR] " CMD_TARGET_PANE_USAGE " key ...",
|
||||
0,
|
||||
NULL,
|
||||
cmd_send_keys_exec
|
||||
};
|
||||
|
||||
@ -43,7 +42,6 @@ const struct cmd_entry cmd_send_prefix_entry = {
|
||||
"2t:", 0, 0,
|
||||
"[-2] " CMD_TARGET_PANE_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_send_keys_exec
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,6 @@ const struct cmd_entry cmd_set_buffer_entry = {
|
||||
"ab:n:", 0, 1,
|
||||
"[-a] " CMD_BUFFER_USAGE " [-n new-buffer-name] data",
|
||||
0,
|
||||
NULL,
|
||||
cmd_set_buffer_exec
|
||||
};
|
||||
|
||||
@ -104,7 +103,7 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
memcpy(pdata, pb->data, psize);
|
||||
}
|
||||
|
||||
pdata = xrealloc(pdata, 1, psize + newsize);
|
||||
pdata = xrealloc(pdata, psize + newsize);
|
||||
memcpy(pdata + psize, args->argv[0], newsize);
|
||||
psize += newsize;
|
||||
|
||||
|
@ -34,7 +34,6 @@ const struct cmd_entry cmd_set_environment_entry = {
|
||||
"grt:u", 1, 2,
|
||||
"[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_set_environment_exec
|
||||
};
|
||||
|
||||
|
@ -69,7 +69,6 @@ const struct cmd_entry cmd_set_option_entry = {
|
||||
"agoqst:uw", 1, 2,
|
||||
"[-agosquw] [-t target-session|target-window] option [value]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_set_option_exec
|
||||
};
|
||||
|
||||
@ -78,7 +77,6 @@ const struct cmd_entry cmd_set_window_option_entry = {
|
||||
"agoqt:u", 1, 2,
|
||||
"[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_set_option_exec
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,6 @@ const struct cmd_entry cmd_show_environment_entry = {
|
||||
"gt:", 0, 1,
|
||||
"[-g] " CMD_TARGET_SESSION_USAGE " [name]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_show_environment_exec
|
||||
};
|
||||
|
||||
|
@ -35,7 +35,6 @@ const struct cmd_entry cmd_show_messages_entry = {
|
||||
"IJTt:", 0, 0,
|
||||
"[-IJT] " CMD_TARGET_CLIENT_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_show_messages_exec
|
||||
};
|
||||
|
||||
@ -44,7 +43,6 @@ const struct cmd_entry cmd_server_info_entry = {
|
||||
"", 0, 0,
|
||||
"",
|
||||
0,
|
||||
NULL,
|
||||
cmd_show_messages_exec
|
||||
};
|
||||
|
||||
|
@ -39,7 +39,6 @@ const struct cmd_entry cmd_show_options_entry = {
|
||||
"gqst:vw", 0, 1,
|
||||
"[-gqsvw] [-t target-session|target-window] [option]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_show_options_exec
|
||||
};
|
||||
|
||||
@ -48,7 +47,6 @@ const struct cmd_entry cmd_show_window_options_entry = {
|
||||
"gvt:", 0, 1,
|
||||
"[-gv] " CMD_TARGET_WINDOW_USAGE " [option]",
|
||||
0,
|
||||
NULL,
|
||||
cmd_show_options_exec
|
||||
};
|
||||
|
||||
|
@ -36,7 +36,6 @@ const struct cmd_entry cmd_source_file_entry = {
|
||||
"", 1, 1,
|
||||
"path",
|
||||
0,
|
||||
NULL,
|
||||
cmd_source_file_exec
|
||||
};
|
||||
|
||||
|
@ -30,7 +30,8 @@
|
||||
* Split a window (add a new pane).
|
||||
*/
|
||||
|
||||
void cmd_split_window_key_binding(struct cmd *, int);
|
||||
#define SPLIT_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
||||
|
||||
enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_split_window_entry = {
|
||||
@ -39,18 +40,9 @@ const struct cmd_entry cmd_split_window_entry = {
|
||||
"[-dhvP] [-c start-directory] [-F format] [-p percentage|-l size] "
|
||||
CMD_TARGET_PANE_USAGE " [command]",
|
||||
0,
|
||||
cmd_split_window_key_binding,
|
||||
cmd_split_window_exec
|
||||
};
|
||||
|
||||
void
|
||||
cmd_split_window_key_binding(struct cmd *self, int key)
|
||||
{
|
||||
self->args = args_create(0);
|
||||
if (key == '%')
|
||||
args_set(self->args, 'h', NULL);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
|
19
cmd-string.c
19
cmd-string.c
@ -107,10 +107,11 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file,
|
||||
case ' ':
|
||||
case '\t':
|
||||
if (buf != NULL) {
|
||||
buf = xrealloc(buf, 1, len + 1);
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len] = '\0';
|
||||
|
||||
argv = xrealloc(argv, argc + 1, sizeof *argv);
|
||||
argv = xreallocarray(argv, argc + 1,
|
||||
sizeof *argv);
|
||||
argv[argc++] = buf;
|
||||
|
||||
buf = NULL;
|
||||
@ -151,7 +152,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file,
|
||||
if (len >= SIZE_MAX - 2)
|
||||
goto error;
|
||||
|
||||
buf = xrealloc(buf, 1, len + 1);
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len++] = ch;
|
||||
break;
|
||||
}
|
||||
@ -179,7 +180,7 @@ cmd_string_copy(char **dst, char *src, size_t *len)
|
||||
|
||||
srclen = strlen(src);
|
||||
|
||||
*dst = xrealloc(*dst, 1, *len + srclen + 1);
|
||||
*dst = xrealloc(*dst, *len + srclen + 1);
|
||||
strlcpy(*dst + *len, src, srclen + 1);
|
||||
|
||||
*len += srclen;
|
||||
@ -231,11 +232,11 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
|
||||
|
||||
if (len >= SIZE_MAX - 2)
|
||||
goto error;
|
||||
buf = xrealloc(buf, 1, len + 1);
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len++] = ch;
|
||||
}
|
||||
|
||||
buf = xrealloc(buf, 1, len + 1);
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len] = '\0';
|
||||
return (buf);
|
||||
|
||||
@ -278,7 +279,7 @@ cmd_string_variable(const char *s, size_t *p)
|
||||
return (t);
|
||||
}
|
||||
|
||||
buf = xrealloc(buf, 1, len + 1);
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len++] = ch;
|
||||
|
||||
for (;;) {
|
||||
@ -288,7 +289,7 @@ cmd_string_variable(const char *s, size_t *p)
|
||||
else {
|
||||
if (len >= SIZE_MAX - 3)
|
||||
goto error;
|
||||
buf = xrealloc(buf, 1, len + 1);
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len++] = ch;
|
||||
}
|
||||
}
|
||||
@ -299,7 +300,7 @@ cmd_string_variable(const char *s, size_t *p)
|
||||
if (ch != EOF && fch != '{')
|
||||
cmd_string_ungetc(p); /* ch */
|
||||
|
||||
buf = xrealloc(buf, 1, len + 1);
|
||||
buf = xrealloc(buf, len + 1);
|
||||
buf[len] = '\0';
|
||||
|
||||
envent = environ_find(&global_environ, buf);
|
||||
|
@ -1,55 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Suspend client with SIGTSTP.
|
||||
*/
|
||||
|
||||
enum cmd_retval cmd_suspend_client_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_suspend_client_entry = {
|
||||
"suspend-client", "suspendc",
|
||||
"t:", 0, 0,
|
||||
CMD_TARGET_CLIENT_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_suspend_client_exec
|
||||
};
|
||||
|
||||
enum cmd_retval
|
||||
cmd_suspend_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
|
||||
if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
tty_stop_tty(&c->tty);
|
||||
c->flags |= CLIENT_SUSPENDED;
|
||||
server_write_client(c, MSG_SUSPEND, NULL, 0);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
@ -26,7 +26,6 @@
|
||||
* Swap two panes.
|
||||
*/
|
||||
|
||||
void cmd_swap_pane_key_binding(struct cmd *, int);
|
||||
enum cmd_retval cmd_swap_pane_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_swap_pane_entry = {
|
||||
@ -34,20 +33,9 @@ const struct cmd_entry cmd_swap_pane_entry = {
|
||||
"dDs:t:U", 0, 0,
|
||||
"[-dDU] " CMD_SRCDST_PANE_USAGE,
|
||||
0,
|
||||
cmd_swap_pane_key_binding,
|
||||
cmd_swap_pane_exec
|
||||
};
|
||||
|
||||
void
|
||||
cmd_swap_pane_key_binding(struct cmd *self, int key)
|
||||
{
|
||||
self->args = args_create(0);
|
||||
if (key == '{')
|
||||
args_set(self->args, 'U', NULL);
|
||||
else if (key == '}')
|
||||
args_set(self->args, 'D', NULL);
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
|
@ -33,7 +33,6 @@ const struct cmd_entry cmd_swap_window_entry = {
|
||||
"ds:t:", 0, 0,
|
||||
"[-d] " CMD_SRCDST_WINDOW_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_swap_window_exec
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
* Switch client to a different session.
|
||||
*/
|
||||
|
||||
void cmd_switch_client_key_binding(struct cmd *, int);
|
||||
enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_switch_client_entry = {
|
||||
@ -35,27 +34,9 @@ const struct cmd_entry cmd_switch_client_entry = {
|
||||
"lc:npt:r", 0, 0,
|
||||
"[-lnpr] [-c target-client] [-t target-session]",
|
||||
CMD_READONLY,
|
||||
cmd_switch_client_key_binding,
|
||||
cmd_switch_client_exec
|
||||
};
|
||||
|
||||
void
|
||||
cmd_switch_client_key_binding(struct cmd *self, int key)
|
||||
{
|
||||
self->args = args_create(0);
|
||||
switch (key) {
|
||||
case '(':
|
||||
args_set(self->args, 'p', NULL);
|
||||
break;
|
||||
case ')':
|
||||
args_set(self->args, 'n', NULL);
|
||||
break;
|
||||
case 'L':
|
||||
args_set(self->args, 'l', NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
enum cmd_retval
|
||||
cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
{
|
||||
|
@ -34,7 +34,6 @@ const struct cmd_entry cmd_unbind_key_entry = {
|
||||
"acnt:", 0, 1,
|
||||
"[-acn] [-t mode-table] key",
|
||||
0,
|
||||
NULL,
|
||||
cmd_unbind_key_exec
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,6 @@ const struct cmd_entry cmd_unlink_window_entry = {
|
||||
"kt:", 0, 0,
|
||||
"[-k] " CMD_TARGET_WINDOW_USAGE,
|
||||
0,
|
||||
NULL,
|
||||
cmd_unlink_window_exec
|
||||
};
|
||||
|
||||
|
@ -35,7 +35,6 @@ const struct cmd_entry cmd_wait_for_entry = {
|
||||
"LSU", 1, 1,
|
||||
"[-L|-S|-U] channel",
|
||||
0,
|
||||
NULL,
|
||||
cmd_wait_for_exec
|
||||
};
|
||||
|
||||
|
99
cmd.c
99
cmd.c
@ -120,7 +120,7 @@ struct session *cmd_choose_session_list(struct sessionslist *);
|
||||
struct session *cmd_choose_session(int);
|
||||
struct client *cmd_choose_client(struct clients *);
|
||||
struct client *cmd_lookup_client(const char *);
|
||||
struct session *cmd_lookup_session(const char *, int *);
|
||||
struct session *cmd_lookup_session(struct cmd_q *, const char *, int *);
|
||||
struct session *cmd_lookup_session_id(const char *);
|
||||
struct winlink *cmd_lookup_window(struct session *, const char *, int *);
|
||||
int cmd_lookup_index(struct session *, const char *, int *);
|
||||
@ -221,7 +221,7 @@ cmd_stringify_argv(int argc, char **argv)
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
len += strlen(argv[i]) + 1;
|
||||
buf = xrealloc(buf, 1, len);
|
||||
buf = xrealloc(buf, len);
|
||||
|
||||
if (i == 0)
|
||||
*buf = '\0';
|
||||
@ -584,9 +584,11 @@ cmd_lookup_session_id(const char *arg)
|
||||
|
||||
/* Lookup a session by name. If no session is found, NULL is returned. */
|
||||
struct session *
|
||||
cmd_lookup_session(const char *name, int *ambiguous)
|
||||
cmd_lookup_session(struct cmd_q *cmdq, const char *name, int *ambiguous)
|
||||
{
|
||||
struct session *s, *sfound;
|
||||
struct session *s, *sfound;
|
||||
struct window *w;
|
||||
struct window_pane *wp;
|
||||
|
||||
*ambiguous = 0;
|
||||
|
||||
@ -594,6 +596,12 @@ cmd_lookup_session(const char *name, int *ambiguous)
|
||||
if ((s = cmd_lookup_session_id(name)) != NULL)
|
||||
return (s);
|
||||
|
||||
/* Try as pane or window id. */
|
||||
if ((wp = cmd_lookup_paneid(name)) != NULL)
|
||||
return (cmd_window_session(cmdq, wp->window, NULL));
|
||||
if ((w = cmd_lookup_windowid(name)) != NULL)
|
||||
return (cmd_window_session(cmdq, w, NULL));
|
||||
|
||||
/*
|
||||
* Look for matches. First look for exact matches - session names must
|
||||
* be unique so an exact match can't be ambigious and can just be
|
||||
@ -629,16 +637,30 @@ cmd_lookup_session(const char *name, int *ambiguous)
|
||||
struct winlink *
|
||||
cmd_lookup_window(struct session *s, const char *name, int *ambiguous)
|
||||
{
|
||||
struct winlink *wl, *wlfound;
|
||||
const char *errstr;
|
||||
u_int idx;
|
||||
struct winlink *wl, *wlfound;
|
||||
struct window *w;
|
||||
struct window_pane *wp;
|
||||
const char *errstr;
|
||||
u_int idx;
|
||||
|
||||
*ambiguous = 0;
|
||||
|
||||
/* Try as a window id. */
|
||||
/* Try as pane or window id. */
|
||||
if ((wl = cmd_lookup_winlink_windowid(s, name)) != NULL)
|
||||
return (wl);
|
||||
|
||||
/* Lookup as pane or window id. */
|
||||
if ((wp = cmd_lookup_paneid(name)) != NULL) {
|
||||
wl = winlink_find_by_window(&s->windows, wp->window);
|
||||
if (wl != NULL)
|
||||
return (wl);
|
||||
}
|
||||
if ((w = cmd_lookup_windowid(name)) != NULL) {
|
||||
wl = winlink_find_by_window(&s->windows, w);
|
||||
if (wl != NULL)
|
||||
return (wl);
|
||||
}
|
||||
|
||||
/* First see if this is a valid window index in this session. */
|
||||
idx = strtonum(name, 0, INT_MAX, &errstr);
|
||||
if (errstr == NULL) {
|
||||
@ -785,13 +807,11 @@ cmd_window_session(struct cmd_q *cmdq, struct window *w, struct winlink **wlp)
|
||||
struct session *
|
||||
cmd_find_session(struct cmd_q *cmdq, const char *arg, int prefer_unattached)
|
||||
{
|
||||
struct session *s;
|
||||
struct window_pane *wp;
|
||||
struct window *w;
|
||||
struct client *c;
|
||||
char *tmparg;
|
||||
size_t arglen;
|
||||
int ambiguous;
|
||||
struct session *s;
|
||||
struct client *c;
|
||||
char *tmparg;
|
||||
size_t arglen;
|
||||
int ambiguous;
|
||||
|
||||
/* A NULL argument means the current session. */
|
||||
if (arg == NULL) {
|
||||
@ -800,12 +820,6 @@ cmd_find_session(struct cmd_q *cmdq, const char *arg, int prefer_unattached)
|
||||
return (s);
|
||||
}
|
||||
|
||||
/* Lookup as pane id or window id. */
|
||||
if ((wp = cmd_lookup_paneid(arg)) != NULL)
|
||||
return (cmd_window_session(cmdq, wp->window, NULL));
|
||||
if ((w = cmd_lookup_windowid(arg)) != NULL)
|
||||
return (cmd_window_session(cmdq, w, NULL));
|
||||
|
||||
/* Trim a single trailing colon if any. */
|
||||
tmparg = xstrdup(arg);
|
||||
arglen = strlen(tmparg);
|
||||
@ -821,7 +835,7 @@ cmd_find_session(struct cmd_q *cmdq, const char *arg, int prefer_unattached)
|
||||
}
|
||||
|
||||
/* Find the session, if any. */
|
||||
s = cmd_lookup_session(tmparg, &ambiguous);
|
||||
s = cmd_lookup_session(cmdq, tmparg, &ambiguous);
|
||||
|
||||
/* If it doesn't, try to match it as a client. */
|
||||
if (s == NULL && (c = cmd_lookup_client(tmparg)) != NULL)
|
||||
@ -843,12 +857,11 @@ cmd_find_session(struct cmd_q *cmdq, const char *arg, int prefer_unattached)
|
||||
struct winlink *
|
||||
cmd_find_window(struct cmd_q *cmdq, const char *arg, struct session **sp)
|
||||
{
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
struct window_pane *wp;
|
||||
const char *winptr;
|
||||
char *sessptr = NULL;
|
||||
int ambiguous = 0;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
const char *winptr;
|
||||
char *sessptr = NULL;
|
||||
int ambiguous = 0;
|
||||
|
||||
/*
|
||||
* Find the current session. There must always be a current session, if
|
||||
@ -866,14 +879,6 @@ cmd_find_window(struct cmd_q *cmdq, const char *arg, struct session **sp)
|
||||
return (s->curw);
|
||||
}
|
||||
|
||||
/* Lookup as pane id. */
|
||||
if ((wp = cmd_lookup_paneid(arg)) != NULL) {
|
||||
s = cmd_window_session(cmdq, wp->window, &wl);
|
||||
if (sp != NULL)
|
||||
*sp = s;
|
||||
return (wl);
|
||||
}
|
||||
|
||||
/* Time to look at the argument. If it is empty, that is an error. */
|
||||
if (*arg == '\0')
|
||||
goto not_found;
|
||||
@ -888,7 +893,7 @@ cmd_find_window(struct cmd_q *cmdq, const char *arg, struct session **sp)
|
||||
|
||||
/* Try to lookup the session if present. */
|
||||
if (*sessptr != '\0') {
|
||||
if ((s = cmd_lookup_session(sessptr, &ambiguous)) == NULL)
|
||||
if ((s = cmd_lookup_session(cmdq, sessptr, &ambiguous)) == NULL)
|
||||
goto no_session;
|
||||
}
|
||||
if (sp != NULL)
|
||||
@ -939,7 +944,8 @@ no_colon:
|
||||
lookup_session:
|
||||
if (ambiguous)
|
||||
goto not_found;
|
||||
if (*arg != '\0' && (s = cmd_lookup_session(arg, &ambiguous)) == NULL)
|
||||
if (*arg != '\0' &&
|
||||
(s = cmd_lookup_session(cmdq, arg, &ambiguous)) == NULL)
|
||||
goto no_session;
|
||||
|
||||
if (sp != NULL)
|
||||
@ -1029,7 +1035,7 @@ cmd_find_index(struct cmd_q *cmdq, const char *arg, struct session **sp)
|
||||
|
||||
/* Try to lookup the session if present. */
|
||||
if (sessptr != NULL && *sessptr != '\0') {
|
||||
if ((s = cmd_lookup_session(sessptr, &ambiguous)) == NULL)
|
||||
if ((s = cmd_lookup_session(cmdq, sessptr, &ambiguous)) == NULL)
|
||||
goto no_session;
|
||||
}
|
||||
if (sp != NULL)
|
||||
@ -1077,7 +1083,8 @@ no_colon:
|
||||
lookup_session:
|
||||
if (ambiguous)
|
||||
goto not_found;
|
||||
if (*arg != '\0' && (s = cmd_lookup_session(arg, &ambiguous)) == NULL)
|
||||
if (*arg != '\0' &&
|
||||
(s = cmd_lookup_session(cmdq, arg, &ambiguous)) == NULL)
|
||||
goto no_session;
|
||||
|
||||
if (sp != NULL)
|
||||
@ -1191,7 +1198,13 @@ cmd_find_pane(struct cmd_q *cmdq,
|
||||
*wpp = wl->window->active;
|
||||
else if (paneptr[0] == '+' || paneptr[0] == '-')
|
||||
*wpp = cmd_find_pane_offset(paneptr, wl);
|
||||
else {
|
||||
else if (paneptr[0] == '!' && paneptr[1] == '\0') {
|
||||
if (wl->window->last == NULL) {
|
||||
cmdq_error(cmdq, "no last pane");
|
||||
goto error;
|
||||
}
|
||||
*wpp = wl->window->last;
|
||||
} else {
|
||||
idx = strtonum(paneptr, 0, INT_MAX, &errstr);
|
||||
if (errstr != NULL)
|
||||
goto lookup_string;
|
||||
@ -1288,11 +1301,11 @@ cmd_template_replace(const char *template, const char *s, int idx)
|
||||
ptr++;
|
||||
|
||||
len += strlen(s);
|
||||
buf = xrealloc(buf, 1, len + 1);
|
||||
buf = xrealloc(buf, len + 1);
|
||||
strlcat(buf, s, len + 1);
|
||||
continue;
|
||||
}
|
||||
buf = xrealloc(buf, 1, len + 2);
|
||||
buf = xrealloc(buf, len + 2);
|
||||
buf[len++] = ch;
|
||||
buf[len] = '\0';
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "tmux.h"
|
||||
|
||||
/* Write a line. */
|
||||
void printflike2
|
||||
void
|
||||
control_write(struct client *c, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
9
format.c
9
format.c
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
@ -267,7 +268,7 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
|
||||
|
||||
/* Expand the buffer and copy in the value. */
|
||||
while (*len - *off < valuelen + 1) {
|
||||
*buf = xrealloc(*buf, 2, *len);
|
||||
*buf = xreallocarray(*buf, 2, *len);
|
||||
*len *= 2;
|
||||
}
|
||||
memcpy(*buf + *off, value, valuelen);
|
||||
@ -298,7 +299,7 @@ format_expand(struct format_tree *ft, const char *fmt)
|
||||
while (*fmt != '\0') {
|
||||
if (*fmt != '#') {
|
||||
while (len - off < 2) {
|
||||
buf = xrealloc(buf, 2, len);
|
||||
buf = xreallocarray(buf, 2, len);
|
||||
len *= 2;
|
||||
}
|
||||
buf[off++] = *fmt++;
|
||||
@ -326,7 +327,7 @@ format_expand(struct format_tree *ft, const char *fmt)
|
||||
continue;
|
||||
case '#':
|
||||
while (len - off < 2) {
|
||||
buf = xrealloc(buf, 2, len);
|
||||
buf = xreallocarray(buf, 2, len);
|
||||
len *= 2;
|
||||
}
|
||||
buf[off++] = '#';
|
||||
@ -339,7 +340,7 @@ format_expand(struct format_tree *ft, const char *fmt)
|
||||
s = format_lower[ch - 'a'];
|
||||
if (s == NULL) {
|
||||
while (len - off < 3) {
|
||||
buf = xrealloc(buf, 2, len);
|
||||
buf = xreallocarray(buf, 2, len);
|
||||
len *= 2;
|
||||
}
|
||||
buf[off++] = '#';
|
||||
|
15
grid.c
15
grid.c
@ -172,7 +172,8 @@ grid_scroll_history(struct grid *gd)
|
||||
u_int yy;
|
||||
|
||||
yy = gd->hsize + gd->sy;
|
||||
gd->linedata = xrealloc(gd->linedata, yy + 1, sizeof *gd->linedata);
|
||||
gd->linedata = xreallocarray(gd->linedata, yy + 1,
|
||||
sizeof *gd->linedata);
|
||||
memset(&gd->linedata[yy], 0, sizeof gd->linedata[yy]);
|
||||
|
||||
gd->hsize++;
|
||||
@ -187,7 +188,8 @@ grid_scroll_history_region(struct grid *gd, u_int upper, u_int lower)
|
||||
|
||||
/* Create a space for a new line. */
|
||||
yy = gd->hsize + gd->sy;
|
||||
gd->linedata = xrealloc(gd->linedata, yy + 1, sizeof *gd->linedata);
|
||||
gd->linedata = xreallocarray(gd->linedata, yy + 1,
|
||||
sizeof *gd->linedata);
|
||||
|
||||
/* Move the entire screen down to free a space for this line. */
|
||||
gl_history = &gd->linedata[gd->hsize];
|
||||
@ -221,7 +223,7 @@ grid_expand_line(struct grid *gd, u_int py, u_int sx)
|
||||
if (sx <= gl->cellsize)
|
||||
return;
|
||||
|
||||
gl->celldata = xrealloc(gl->celldata, sx, sizeof *gl->celldata);
|
||||
gl->celldata = xreallocarray(gl->celldata, sx, sizeof *gl->celldata);
|
||||
for (xx = gl->cellsize; xx < sx; xx++)
|
||||
grid_put_cell(gd, xx, py, &grid_default_cell);
|
||||
gl->cellsize = sx;
|
||||
@ -610,7 +612,7 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx,
|
||||
}
|
||||
|
||||
while (len < off + size + codelen + 1) {
|
||||
buf = xrealloc(buf, 2, len);
|
||||
buf = xreallocarray(buf, 2, len);
|
||||
len *= 2;
|
||||
}
|
||||
|
||||
@ -685,7 +687,7 @@ grid_reflow_join(struct grid *dst, u_int *py, struct grid_line *src_gl,
|
||||
nx = ox + to_copy;
|
||||
|
||||
/* Resize the destination line. */
|
||||
dst_gl->celldata = xrealloc(dst_gl->celldata, nx,
|
||||
dst_gl->celldata = xreallocarray(dst_gl->celldata, nx,
|
||||
sizeof *dst_gl->celldata);
|
||||
dst_gl->cellsize = nx;
|
||||
|
||||
@ -724,7 +726,8 @@ grid_reflow_split(struct grid *dst, u_int *py, struct grid_line *src_gl,
|
||||
to_copy = src_gl->cellsize;
|
||||
|
||||
/* Expand destination line. */
|
||||
dst_gl->celldata = xmalloc(to_copy * sizeof *dst_gl->celldata);
|
||||
dst_gl->celldata = xreallocarray(NULL, to_copy,
|
||||
sizeof *dst_gl->celldata);
|
||||
dst_gl->cellsize = to_copy;
|
||||
dst_gl->flags |= GRID_LINE_WRAPPED;
|
||||
|
||||
|
4
input.c
4
input.c
@ -909,7 +909,7 @@ input_ground(struct input_ctx *ictx)
|
||||
|
||||
if (ictx->input_space > INPUT_BUF_START) {
|
||||
ictx->input_space = INPUT_BUF_START;
|
||||
ictx->input_buf = xrealloc(ictx->input_buf, 1, INPUT_BUF_START);
|
||||
ictx->input_buf = xrealloc(ictx->input_buf, INPUT_BUF_START);
|
||||
}
|
||||
}
|
||||
|
||||
@ -974,7 +974,7 @@ input_input(struct input_ctx *ictx)
|
||||
ictx->flags |= INPUT_DISCARD;
|
||||
return (0);
|
||||
}
|
||||
ictx->input_buf = xrealloc(ictx->input_buf, 1, available);
|
||||
ictx->input_buf = xrealloc(ictx->input_buf, available);
|
||||
ictx->input_space = available;
|
||||
}
|
||||
ictx->input_buf[ictx->input_len++] = ictx->ch;
|
||||
|
1
job.c
1
job.c
@ -23,6 +23,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
|
180
key-bindings.c
180
key-bindings.c
@ -84,107 +84,99 @@ key_bindings_remove(int key)
|
||||
void
|
||||
key_bindings_init(void)
|
||||
{
|
||||
static const struct {
|
||||
int key;
|
||||
int can_repeat;
|
||||
const struct cmd_entry *entry;
|
||||
} table[] = {
|
||||
{ ' ', 0, &cmd_next_layout_entry },
|
||||
{ '!', 0, &cmd_break_pane_entry },
|
||||
{ '"', 0, &cmd_split_window_entry },
|
||||
{ '#', 0, &cmd_list_buffers_entry },
|
||||
{ '$', 0, &cmd_command_prompt_entry },
|
||||
{ '%', 0, &cmd_split_window_entry },
|
||||
{ '&', 0, &cmd_confirm_before_entry },
|
||||
{ '(', 0, &cmd_switch_client_entry },
|
||||
{ ')', 0, &cmd_switch_client_entry },
|
||||
{ ',', 0, &cmd_command_prompt_entry },
|
||||
{ '-', 0, &cmd_delete_buffer_entry },
|
||||
{ '.', 0, &cmd_command_prompt_entry },
|
||||
{ '0', 0, &cmd_select_window_entry },
|
||||
{ '1', 0, &cmd_select_window_entry },
|
||||
{ '2', 0, &cmd_select_window_entry },
|
||||
{ '3', 0, &cmd_select_window_entry },
|
||||
{ '4', 0, &cmd_select_window_entry },
|
||||
{ '5', 0, &cmd_select_window_entry },
|
||||
{ '6', 0, &cmd_select_window_entry },
|
||||
{ '7', 0, &cmd_select_window_entry },
|
||||
{ '8', 0, &cmd_select_window_entry },
|
||||
{ '9', 0, &cmd_select_window_entry },
|
||||
{ ':', 0, &cmd_command_prompt_entry },
|
||||
{ ';', 0, &cmd_last_pane_entry },
|
||||
{ '=', 0, &cmd_choose_buffer_entry },
|
||||
{ '?', 0, &cmd_list_keys_entry },
|
||||
{ 'D', 0, &cmd_choose_client_entry },
|
||||
{ 'L', 0, &cmd_switch_client_entry },
|
||||
{ '[', 0, &cmd_copy_mode_entry },
|
||||
{ '\'', 0, &cmd_command_prompt_entry },
|
||||
{ '\002', /* C-b */ 0, &cmd_send_prefix_entry },
|
||||
{ '\017', /* C-o */ 0, &cmd_rotate_window_entry },
|
||||
{ '\032', /* C-z */ 0, &cmd_suspend_client_entry },
|
||||
{ ']', 0, &cmd_paste_buffer_entry },
|
||||
{ 'c', 0, &cmd_new_window_entry },
|
||||
{ 'd', 0, &cmd_detach_client_entry },
|
||||
{ 'f', 0, &cmd_command_prompt_entry },
|
||||
{ 'i', 0, &cmd_display_message_entry },
|
||||
{ 'l', 0, &cmd_last_window_entry },
|
||||
{ 'n', 0, &cmd_next_window_entry },
|
||||
{ 'o', 0, &cmd_select_pane_entry },
|
||||
{ 'p', 0, &cmd_previous_window_entry },
|
||||
{ 'q', 0, &cmd_display_panes_entry },
|
||||
{ 'r', 0, &cmd_refresh_client_entry },
|
||||
{ 's', 0, &cmd_choose_tree_entry },
|
||||
{ 't', 0, &cmd_clock_mode_entry },
|
||||
{ 'w', 0, &cmd_choose_window_entry },
|
||||
{ 'x', 0, &cmd_confirm_before_entry },
|
||||
{ 'z', 0, &cmd_resize_pane_entry },
|
||||
{ '{', 0, &cmd_swap_pane_entry },
|
||||
{ '}', 0, &cmd_swap_pane_entry },
|
||||
{ '~', 0, &cmd_show_messages_entry },
|
||||
{ '1' | KEYC_ESCAPE, 0, &cmd_select_layout_entry },
|
||||
{ '2' | KEYC_ESCAPE, 0, &cmd_select_layout_entry },
|
||||
{ '3' | KEYC_ESCAPE, 0, &cmd_select_layout_entry },
|
||||
{ '4' | KEYC_ESCAPE, 0, &cmd_select_layout_entry },
|
||||
{ '5' | KEYC_ESCAPE, 0, &cmd_select_layout_entry },
|
||||
{ KEYC_PPAGE, 0, &cmd_copy_mode_entry },
|
||||
{ 'n' | KEYC_ESCAPE, 0, &cmd_next_window_entry },
|
||||
{ 'o' | KEYC_ESCAPE, 0, &cmd_rotate_window_entry },
|
||||
{ 'p' | KEYC_ESCAPE, 0, &cmd_previous_window_entry },
|
||||
{ KEYC_UP, 1, &cmd_select_pane_entry },
|
||||
{ KEYC_DOWN, 1, &cmd_select_pane_entry },
|
||||
{ KEYC_LEFT, 1, &cmd_select_pane_entry },
|
||||
{ KEYC_RIGHT, 1, &cmd_select_pane_entry },
|
||||
{ KEYC_UP | KEYC_ESCAPE, 1, &cmd_resize_pane_entry },
|
||||
{ KEYC_DOWN | KEYC_ESCAPE, 1, &cmd_resize_pane_entry },
|
||||
{ KEYC_LEFT | KEYC_ESCAPE, 1, &cmd_resize_pane_entry },
|
||||
{ KEYC_RIGHT | KEYC_ESCAPE, 1, &cmd_resize_pane_entry },
|
||||
{ KEYC_UP | KEYC_CTRL, 1, &cmd_resize_pane_entry },
|
||||
{ KEYC_DOWN | KEYC_CTRL, 1, &cmd_resize_pane_entry },
|
||||
{ KEYC_LEFT | KEYC_CTRL, 1, &cmd_resize_pane_entry },
|
||||
{ KEYC_RIGHT | KEYC_CTRL, 1, &cmd_resize_pane_entry },
|
||||
static const char* defaults[] = {
|
||||
"bind C-b send-prefix",
|
||||
"bind C-o rotate-window",
|
||||
"bind C-z suspend-client",
|
||||
"bind Space next-layout",
|
||||
"bind ! break-pane",
|
||||
"bind '\"' split-window",
|
||||
"bind '#' list-buffers",
|
||||
"bind '$' command-prompt -I'#S' \"rename-session '%%'\"",
|
||||
"bind % split-window -h",
|
||||
"bind & confirm-before -p\"kill-window #W? (y/n)\" kill-window",
|
||||
"bind \"'\" command-prompt -pindex \"select-window -t ':%%'\"",
|
||||
"bind ( switch-client -p",
|
||||
"bind ) switch-client -n",
|
||||
"bind , command-prompt -I'#W' \"rename-window '%%'\"",
|
||||
"bind - delete-buffer",
|
||||
"bind . command-prompt \"move-window -t '%%'\"",
|
||||
"bind 0 select-window -t:0",
|
||||
"bind 1 select-window -t:1",
|
||||
"bind 2 select-window -t:2",
|
||||
"bind 3 select-window -t:3",
|
||||
"bind 4 select-window -t:4",
|
||||
"bind 5 select-window -t:5",
|
||||
"bind 6 select-window -t:6",
|
||||
"bind 7 select-window -t:7",
|
||||
"bind 8 select-window -t:8",
|
||||
"bind 9 select-window -t:9",
|
||||
"bind : command-prompt",
|
||||
"bind \\; last-pane",
|
||||
"bind = choose-buffer",
|
||||
"bind ? list-keys",
|
||||
"bind D choose-client",
|
||||
"bind L switch-client -l",
|
||||
"bind [ copy-mode",
|
||||
"bind ] paste-buffer",
|
||||
"bind c new-window",
|
||||
"bind d detach-client",
|
||||
"bind f command-prompt \"find-window '%%'\"",
|
||||
"bind i display-message",
|
||||
"bind l last-window",
|
||||
"bind n next-window",
|
||||
"bind o select-pane -t:.+",
|
||||
"bind p previous-window",
|
||||
"bind q display-panes",
|
||||
"bind r refresh-client",
|
||||
"bind s choose-tree",
|
||||
"bind t clock-mode",
|
||||
"bind w choose-window",
|
||||
"bind x confirm-before -p\"kill-pane #P? (y/n)\" kill-pane",
|
||||
"bind z resize-pane -Z",
|
||||
"bind { swap-pane -U",
|
||||
"bind } swap-pane -D",
|
||||
"bind '~' show-messages",
|
||||
"bind PPage copy-mode -u",
|
||||
"bind -r Up select-pane -U",
|
||||
"bind -r Down select-pane -D",
|
||||
"bind -r Left select-pane -L",
|
||||
"bind -r Right select-pane -R",
|
||||
"bind M-1 select-layout even-horizontal",
|
||||
"bind M-2 select-layout even-vertical",
|
||||
"bind M-3 select-layout main-horizontal",
|
||||
"bind M-4 select-layout main-vertical",
|
||||
"bind M-5 select-layout tiled",
|
||||
"bind M-n next-window -a",
|
||||
"bind M-o rotate-window -D",
|
||||
"bind M-p previous-window -a",
|
||||
"bind -r M-Up resize-pane -U 5",
|
||||
"bind -r M-Down resize-pane -D 5",
|
||||
"bind -r M-Left resize-pane -L 5",
|
||||
"bind -r M-Right resize-pane -R 5",
|
||||
"bind -r C-Up resize-pane -U",
|
||||
"bind -r C-Down resize-pane -D",
|
||||
"bind -r C-Left resize-pane -L",
|
||||
"bind -r C-Right resize-pane -R",
|
||||
};
|
||||
u_int i;
|
||||
struct cmd *cmd;
|
||||
struct cmd_list *cmdlist;
|
||||
char* cause;
|
||||
int error;
|
||||
struct cmd_q *cmdq;
|
||||
|
||||
RB_INIT(&key_bindings);
|
||||
|
||||
for (i = 0; i < nitems(table); i++) {
|
||||
cmdlist = xcalloc(1, sizeof *cmdlist);
|
||||
cmdlist->references = 1;
|
||||
TAILQ_INIT(&cmdlist->list);
|
||||
|
||||
cmd = xcalloc(1, sizeof *cmd);
|
||||
cmd->entry = table[i].entry;
|
||||
if (cmd->entry->key_binding != NULL)
|
||||
cmd->entry->key_binding(cmd, table[i].key);
|
||||
else
|
||||
cmd->args = args_create(0);
|
||||
TAILQ_INSERT_HEAD(&cmdlist->list, cmd, qentry);
|
||||
|
||||
key_bindings_add(
|
||||
table[i].key | KEYC_PREFIX, table[i].can_repeat, cmdlist);
|
||||
cmdq = cmdq_new (NULL);
|
||||
for (i = 0; i < nitems(defaults); i++) {
|
||||
error = cmd_string_parse(defaults[i], &cmdlist,
|
||||
"<default-keys>", i, &cause);
|
||||
if (error != 0)
|
||||
fatalx("bad default key");
|
||||
cmdq_run (cmdq, cmdlist);
|
||||
cmd_list_free (cmdlist);
|
||||
}
|
||||
cmdq_free (cmdq);
|
||||
}
|
||||
|
||||
void
|
||||
|
6
log.c
6
log.c
@ -81,7 +81,7 @@ log_vwrite(const char *msg, va_list ap)
|
||||
}
|
||||
|
||||
/* Log a debug message. */
|
||||
void printflike1
|
||||
void
|
||||
log_debug(const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@ -92,7 +92,7 @@ log_debug(const char *msg, ...)
|
||||
}
|
||||
|
||||
/* Log a critical error with error string and die. */
|
||||
__dead void printflike1
|
||||
__dead void
|
||||
log_fatal(const char *msg, ...)
|
||||
{
|
||||
char *fmt;
|
||||
@ -106,7 +106,7 @@ log_fatal(const char *msg, ...)
|
||||
}
|
||||
|
||||
/* Log a critical error and die. */
|
||||
__dead void printflike1
|
||||
__dead void
|
||||
log_fatalx(const char *msg, ...)
|
||||
{
|
||||
char *fmt;
|
||||
|
@ -99,7 +99,7 @@ options_remove(struct options *oo, const char *name)
|
||||
free(o);
|
||||
}
|
||||
|
||||
struct options_entry *printflike3
|
||||
struct options_entry *
|
||||
options_set_string(struct options *oo, const char *name, const char *fmt, ...)
|
||||
{
|
||||
struct options_entry *o;
|
||||
|
@ -50,7 +50,7 @@ osdep_get_name(int fd, unused char *tty)
|
||||
while ((ch = fgetc(f)) != EOF) {
|
||||
if (ch == '\0')
|
||||
break;
|
||||
buf = xrealloc(buf, 1, len + 2);
|
||||
buf = xrealloc(buf, len + 2);
|
||||
buf[len++] = ch;
|
||||
}
|
||||
if (buf != NULL)
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <event.h>
|
||||
#include <stdio.h>
|
||||
@ -50,7 +51,7 @@ osdep_get_name(int fd, unused char *tty)
|
||||
while ((ch = fgetc(f)) != EOF) {
|
||||
if (ch == '\0')
|
||||
break;
|
||||
buf = xrealloc(buf, 1, len + 2);
|
||||
buf = xrealloc(buf, len + 2);
|
||||
buf[len++] = ch;
|
||||
}
|
||||
if (buf != NULL)
|
||||
|
2
paste.c
2
paste.c
@ -278,7 +278,7 @@ paste_make_sample(struct paste_buffer *pb, int utf8flag)
|
||||
len = pb->size;
|
||||
if (len > width)
|
||||
len = width;
|
||||
buf = xmalloc(len * 4 + 4);
|
||||
buf = xreallocarray(NULL, len, 4 + 4);
|
||||
|
||||
if (utf8flag)
|
||||
used = utf8_strvis(buf, pb->data, len, flags);
|
||||
|
@ -25,13 +25,13 @@
|
||||
|
||||
void screen_write_initctx(struct screen_write_ctx *, struct tty_ctx *, int);
|
||||
void screen_write_overwrite(struct screen_write_ctx *, u_int);
|
||||
int screen_write_combine(
|
||||
struct screen_write_ctx *, const struct utf8_data *);
|
||||
int screen_write_combine(struct screen_write_ctx *,
|
||||
const struct utf8_data *);
|
||||
|
||||
/* Initialise writing with a window. */
|
||||
void
|
||||
screen_write_start(
|
||||
struct screen_write_ctx *ctx, struct window_pane *wp, struct screen *s)
|
||||
screen_write_start(struct screen_write_ctx *ctx, struct window_pane *wp,
|
||||
struct screen *s)
|
||||
{
|
||||
ctx->wp = wp;
|
||||
if (wp != NULL && s == NULL)
|
||||
@ -73,7 +73,7 @@ screen_write_putc(struct screen_write_ctx *ctx, struct grid_cell *gc,
|
||||
}
|
||||
|
||||
/* Calculate string length, with embedded formatting. */
|
||||
size_t printflike2
|
||||
size_t
|
||||
screen_write_cstrlen(int utf8flag, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@ -108,7 +108,7 @@ screen_write_cstrlen(int utf8flag, const char *fmt, ...)
|
||||
}
|
||||
|
||||
/* Calculate string length. */
|
||||
size_t printflike2
|
||||
size_t
|
||||
screen_write_strlen(int utf8flag, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@ -145,9 +145,9 @@ screen_write_strlen(int utf8flag, const char *fmt, ...)
|
||||
}
|
||||
|
||||
/* Write simple string (no UTF-8 or maximum length). */
|
||||
void printflike3
|
||||
screen_write_puts(
|
||||
struct screen_write_ctx *ctx, struct grid_cell *gc, const char *fmt, ...)
|
||||
void
|
||||
screen_write_puts(struct screen_write_ctx *ctx, struct grid_cell *gc,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -157,9 +157,9 @@ screen_write_puts(
|
||||
}
|
||||
|
||||
/* Write string with length limit (-1 for unlimited). */
|
||||
void printflike5
|
||||
screen_write_nputs(struct screen_write_ctx *ctx,
|
||||
ssize_t maxlen, struct grid_cell *gc, int utf8flag, const char *fmt, ...)
|
||||
void
|
||||
screen_write_nputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
||||
struct grid_cell *gc, int utf8flag, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -221,7 +221,7 @@ screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
||||
}
|
||||
|
||||
/* Write string, similar to nputs, but with embedded formatting (#[]). */
|
||||
void printflike5
|
||||
void
|
||||
screen_write_cnputs(struct screen_write_ctx *ctx,
|
||||
ssize_t maxlen, struct grid_cell *gc, int utf8flag, const char *fmt, ...)
|
||||
{
|
||||
@ -990,6 +990,8 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
|
||||
memcpy(&tmp_gc, &s->sel.cell, sizeof tmp_gc);
|
||||
grid_cell_get(gc, &ud);
|
||||
grid_cell_set(&tmp_gc, &ud);
|
||||
tmp_gc.attr = tmp_gc.attr & ~GRID_ATTR_CHARSET;
|
||||
tmp_gc.attr |= gc->attr & GRID_ATTR_CHARSET;
|
||||
tmp_gc.flags = gc->flags & ~(GRID_FLAG_FG256|GRID_FLAG_BG256);
|
||||
tmp_gc.flags |= s->sel.cell.flags &
|
||||
(GRID_FLAG_FG256|GRID_FLAG_BG256);
|
||||
|
10
screen.c
10
screen.c
@ -32,12 +32,12 @@ void screen_resize_y(struct screen *, u_int);
|
||||
void
|
||||
screen_init(struct screen *s, u_int sx, u_int sy, u_int hlimit)
|
||||
{
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
char host[HOST_NAME_MAX];
|
||||
|
||||
s->grid = grid_create(sx, sy, hlimit);
|
||||
|
||||
if (gethostname(hn, MAXHOSTNAMELEN) == 0)
|
||||
s->title = xstrdup(hn);
|
||||
if (gethostname(host, HOST_NAME_MAX) == 0)
|
||||
s->title = xstrdup(host);
|
||||
else
|
||||
s->title = xstrdup("");
|
||||
|
||||
@ -216,8 +216,8 @@ screen_resize_y(struct screen *s, u_int sy)
|
||||
}
|
||||
|
||||
/* Resize line arrays. */
|
||||
gd->linedata = xrealloc(
|
||||
gd->linedata, gd->hsize + sy, sizeof *gd->linedata);
|
||||
gd->linedata = xreallocarray(gd->linedata, gd->hsize + sy,
|
||||
sizeof *gd->linedata);
|
||||
|
||||
/* Size increasing. */
|
||||
if (sy > oldy) {
|
||||
|
@ -328,6 +328,7 @@ server_client_check_mouse(struct client *c, struct window_pane *wp)
|
||||
if (options_get_number(oo, "mouse-select-pane") &&
|
||||
(m->event == MOUSE_EVENT_DOWN || m->event == MOUSE_EVENT_WHEEL)) {
|
||||
window_set_active_at(wp->window, m->x, m->y);
|
||||
server_status_window(wp->window);
|
||||
server_redraw_window_borders(wp->window);
|
||||
wp = wp->window->active; /* may have changed */
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ void server_callback_identify(int, short, void *);
|
||||
void
|
||||
server_fill_environ(struct session *s, struct environ *env)
|
||||
{
|
||||
char var[MAXPATHLEN], *term;
|
||||
char var[PATH_MAX], *term;
|
||||
u_int idx;
|
||||
long pid;
|
||||
|
||||
|
2
signal.c
2
signal.c
@ -17,6 +17,8 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
15
status.c
15
status.c
@ -121,12 +121,17 @@ status_set_window_at(struct client *c, u_int x)
|
||||
{
|
||||
struct session *s = c->session;
|
||||
struct winlink *wl;
|
||||
struct options *oo;
|
||||
size_t len;
|
||||
|
||||
x += c->wlmouse;
|
||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||
oo = &wl->window->options;
|
||||
|
||||
len = strlen(options_get_string(oo, "window-status-separator"));
|
||||
if (x < wl->status_width && session_select(s, wl->idx) == 0)
|
||||
server_redraw_session(s);
|
||||
x -= wl->status_width + 1;
|
||||
x -= wl->status_width + len;
|
||||
}
|
||||
}
|
||||
|
||||
@ -646,7 +651,7 @@ status_print(
|
||||
}
|
||||
|
||||
/* Set a status line message. */
|
||||
void printflike2
|
||||
void
|
||||
status_message_set(struct client *c, const char *fmt, ...)
|
||||
{
|
||||
struct timeval tv;
|
||||
@ -987,7 +992,7 @@ status_prompt_key(struct client *c, int key)
|
||||
/* Insert the new word. */
|
||||
size += strlen(s);
|
||||
off = first - c->prompt_buffer;
|
||||
c->prompt_buffer = xrealloc(c->prompt_buffer, 1, size + 1);
|
||||
c->prompt_buffer = xrealloc(c->prompt_buffer, size + 1);
|
||||
first = c->prompt_buffer + off;
|
||||
memmove(first + strlen(s), first, n);
|
||||
memcpy(first, s, strlen(s));
|
||||
@ -1165,7 +1170,7 @@ status_prompt_key(struct client *c, int key)
|
||||
break;
|
||||
}
|
||||
|
||||
c->prompt_buffer = xrealloc(c->prompt_buffer, 1, size + n + 1);
|
||||
c->prompt_buffer = xrealloc(c->prompt_buffer, size + n + 1);
|
||||
if (c->prompt_index == size) {
|
||||
memcpy(c->prompt_buffer + c->prompt_index, pb->data, n);
|
||||
c->prompt_index += n;
|
||||
@ -1205,7 +1210,7 @@ status_prompt_key(struct client *c, int key)
|
||||
case MODEKEY_OTHER:
|
||||
if ((key & 0xff00) != 0 || key < 32 || key == 127)
|
||||
break;
|
||||
c->prompt_buffer = xrealloc(c->prompt_buffer, 1, size + 2);
|
||||
c->prompt_buffer = xrealloc(c->prompt_buffer, size + 2);
|
||||
|
||||
if (c->prompt_index == size) {
|
||||
c->prompt_buffer[c->prompt_index++] = key;
|
||||
|
2
style.c
2
style.c
@ -17,6 +17,8 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
17
tmux.1
17
tmux.1
@ -439,10 +439,11 @@ first attempts to use the argument as a pane index; if that fails, it is looked
|
||||
up as for
|
||||
.Ar target-window .
|
||||
A
|
||||
.Ql +
|
||||
or
|
||||
.Ql + ,
|
||||
.Ql -
|
||||
indicate the next or previous pane index, respectively.
|
||||
or
|
||||
.Ql \&!
|
||||
indicate the next, previous or last pane.
|
||||
One of the strings
|
||||
.Em top ,
|
||||
.Em bottom ,
|
||||
@ -1859,7 +1860,7 @@ In addition, the following special key names are accepted:
|
||||
.Em Escape ,
|
||||
.Em F1
|
||||
to
|
||||
.Em F20 ,
|
||||
.Em F12 ,
|
||||
.Em Home ,
|
||||
.Em IC
|
||||
(Insert),
|
||||
@ -3652,7 +3653,7 @@ to change the cursor colour from inside
|
||||
$ printf '\e033]12;red\e033\e\e'
|
||||
.Ed
|
||||
.It Em \&Ss , Se
|
||||
Change the cursor style.
|
||||
Set or reset the cursor style.
|
||||
If set, a sequence such as this may be used
|
||||
to change the cursor to an underline:
|
||||
.Bd -literal -offset indent
|
||||
@ -3660,10 +3661,8 @@ $ printf '\e033[4 q'
|
||||
.Ed
|
||||
.Pp
|
||||
If
|
||||
.Em Csr
|
||||
is set, it will be used to reset the cursor style instead
|
||||
of
|
||||
.Em Cs .
|
||||
.Em Se
|
||||
is not set, \&Ss with argument 0 will be used to reset the cursor style instead.
|
||||
.It Em \&Ms
|
||||
This sequence can be used by
|
||||
.Nm
|
||||
|
7
tmux.c
7
tmux.c
@ -22,6 +22,7 @@
|
||||
#include <errno.h>
|
||||
#include <event.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <locale.h>
|
||||
#include <pwd.h>
|
||||
#include <stdlib.h>
|
||||
@ -45,7 +46,7 @@ char *cfg_file;
|
||||
char *shell_cmd;
|
||||
int debug_level;
|
||||
time_t start_time;
|
||||
char socket_path[MAXPATHLEN];
|
||||
char socket_path[PATH_MAX];
|
||||
int login_shell;
|
||||
char *environ_path;
|
||||
|
||||
@ -127,7 +128,7 @@ areshell(const char *shell)
|
||||
char *
|
||||
makesocketpath(const char *label)
|
||||
{
|
||||
char base[MAXPATHLEN], realbase[MAXPATHLEN], *path, *s;
|
||||
char base[PATH_MAX], realbase[PATH_MAX], *path, *s;
|
||||
struct stat sb;
|
||||
u_int uid;
|
||||
|
||||
@ -205,7 +206,7 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct passwd *pw;
|
||||
char *s, *path, *label, **var, tmp[MAXPATHLEN];
|
||||
char *s, *path, *label, **var, tmp[PATH_MAX];
|
||||
char in[256];
|
||||
const char *home;
|
||||
long long pid;
|
||||
|
126
tmux.h
126
tmux.h
@ -21,13 +21,11 @@
|
||||
|
||||
#define PROTOCOL_VERSION 8
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <event.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
@ -69,89 +67,13 @@ extern char **environ;
|
||||
#define unused __attribute__ ((unused))
|
||||
|
||||
/* Attribute to make gcc check printf-like arguments. */
|
||||
#define printflike1 __attribute__ ((format (printf, 1, 2)))
|
||||
#define printflike2 __attribute__ ((format (printf, 2, 3)))
|
||||
#define printflike3 __attribute__ ((format (printf, 3, 4)))
|
||||
#define printflike4 __attribute__ ((format (printf, 4, 5)))
|
||||
#define printflike5 __attribute__ ((format (printf, 5, 6)))
|
||||
#define printflike(a, b) __attribute__ ((format (printf, a, b)))
|
||||
|
||||
/* Number of items in array. */
|
||||
#ifndef nitems
|
||||
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
|
||||
#endif
|
||||
|
||||
/* Default template for choose-buffer. */
|
||||
#define CHOOSE_BUFFER_TEMPLATE \
|
||||
"#{buffer_name}: #{buffer_size} bytes: #{buffer_sample}"
|
||||
|
||||
/* Default template for choose-client. */
|
||||
#define CHOOSE_CLIENT_TEMPLATE \
|
||||
"#{client_tty}: #{session_name} " \
|
||||
"[#{client_width}x#{client_height} #{client_termname}]" \
|
||||
"#{?client_utf8, (utf8),}#{?client_readonly, (ro),} " \
|
||||
"(last used #{client_activity_string})"
|
||||
|
||||
/* Default templates for choose-tree. */
|
||||
#define CHOOSE_TREE_SESSION_TEMPLATE \
|
||||
"#{session_name}: #{session_windows} windows" \
|
||||
"#{?session_grouped, (group ,}" \
|
||||
"#{session_group}#{?session_grouped,),}" \
|
||||
"#{?session_attached, (attached),}"
|
||||
#define CHOOSE_TREE_WINDOW_TEMPLATE \
|
||||
"#{window_index}: #{window_name}#{window_flags} " \
|
||||
"\"#{pane_title}\""
|
||||
|
||||
/* Default template for display-message. */
|
||||
#define DISPLAY_MESSAGE_TEMPLATE \
|
||||
"[#{session_name}] #{window_index}:" \
|
||||
"#{window_name}, current pane #{pane_index} " \
|
||||
"- (%H:%M %d-%b-%y)"
|
||||
|
||||
/* Default template for find-window. */
|
||||
#define FIND_WINDOW_TEMPLATE \
|
||||
"#{window_index}: #{window_name} " \
|
||||
"[#{window_width}x#{window_height}] " \
|
||||
"(#{window_panes} panes) #{window_find_matches}"
|
||||
|
||||
/* Default template for list-buffers. */
|
||||
#define LIST_BUFFERS_TEMPLATE \
|
||||
"#{buffer_name}: #{buffer_size} bytes: " \
|
||||
"\"#{buffer_sample}\""
|
||||
|
||||
/* Default template for list-clients. */
|
||||
#define LIST_CLIENTS_TEMPLATE \
|
||||
"#{client_tty}: #{session_name} " \
|
||||
"[#{client_width}x#{client_height} #{client_termname}]" \
|
||||
"#{?client_utf8, (utf8),} #{?client_readonly, (ro),}"
|
||||
|
||||
/* Default template for list-sessions. */
|
||||
#define LIST_SESSIONS_TEMPLATE \
|
||||
"#{session_name}: #{session_windows} windows " \
|
||||
"(created #{session_created_string}) " \
|
||||
"[#{session_width}x#{session_height}]" \
|
||||
"#{?session_grouped, (group ,}" \
|
||||
"#{session_group}#{?session_grouped,),}" \
|
||||
"#{?session_attached, (attached),}"
|
||||
|
||||
/* Default templates for list-windows. */
|
||||
#define LIST_WINDOWS_TEMPLATE \
|
||||
"#{window_index}: #{window_name}#{window_flags} " \
|
||||
"(#{window_panes} panes) " \
|
||||
"[#{window_width}x#{window_height}] " \
|
||||
"[layout #{window_layout}] #{window_id}" \
|
||||
"#{?window_active, (active),}";
|
||||
#define LIST_WINDOWS_WITH_SESSION_TEMPLATE \
|
||||
"#{session_name}:" \
|
||||
"#{window_index}: #{window_name}#{window_flags} " \
|
||||
"(#{window_panes} panes) " \
|
||||
"[#{window_width}x#{window_height}] "
|
||||
|
||||
/* Default templates for break-pane, new-window and split-window. */
|
||||
#define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
||||
#define NEW_SESSION_TEMPLATE "#{session_name}:"
|
||||
#define NEW_WINDOW_TEMPLATE BREAK_PANE_TEMPLATE
|
||||
#define SPLIT_WINDOW_TEMPLATE BREAK_PANE_TEMPLATE
|
||||
|
||||
/* Bell option values. */
|
||||
#define BELL_NONE 0
|
||||
#define BELL_ANY 1
|
||||
@ -1489,7 +1411,6 @@ struct cmd_entry {
|
||||
#define CMD_READONLY 0x4
|
||||
int flags;
|
||||
|
||||
void (*key_binding)(struct cmd *, int);
|
||||
enum cmd_retval (*exec)(struct cmd *, struct cmd_q *);
|
||||
};
|
||||
|
||||
@ -1563,7 +1484,7 @@ extern char *cfg_file;
|
||||
extern char *shell_cmd;
|
||||
extern int debug_level;
|
||||
extern time_t start_time;
|
||||
extern char socket_path[MAXPATHLEN];
|
||||
extern char socket_path[PATH_MAX];
|
||||
extern int login_shell;
|
||||
extern char *environ_path;
|
||||
void logfile(const char *);
|
||||
@ -1588,8 +1509,8 @@ int format_cmp(struct format_entry *, struct format_entry *);
|
||||
RB_PROTOTYPE(format_tree, format_entry, entry, format_cmp);
|
||||
struct format_tree *format_create(void);
|
||||
void format_free(struct format_tree *);
|
||||
void printflike3 format_add(struct format_tree *, const char *, const char *,
|
||||
...);
|
||||
void printflike(3, 4) format_add(struct format_tree *, const char *,
|
||||
const char *, ...);
|
||||
const char *format_find(struct format_tree *, const char *);
|
||||
char *format_expand(struct format_tree *, const char *);
|
||||
void format_session(struct format_tree *, struct session *);
|
||||
@ -1642,7 +1563,7 @@ void options_free(struct options *);
|
||||
struct options_entry *options_find1(struct options *, const char *);
|
||||
struct options_entry *options_find(struct options *, const char *);
|
||||
void options_remove(struct options *, const char *);
|
||||
struct options_entry *printflike3 options_set_string(struct options *,
|
||||
struct options_entry *printflike(3, 4) options_set_string(struct options *,
|
||||
const char *, const char *, ...);
|
||||
char *options_get_string(struct options *, const char *);
|
||||
struct options_entry *options_set_number(struct options *, const char *,
|
||||
@ -1909,8 +1830,8 @@ size_t cmd_list_print(struct cmd_list *, char *, size_t);
|
||||
/* cmd-queue.c */
|
||||
struct cmd_q *cmdq_new(struct client *);
|
||||
int cmdq_free(struct cmd_q *);
|
||||
void printflike2 cmdq_print(struct cmd_q *, const char *, ...);
|
||||
void printflike2 cmdq_error(struct cmd_q *, const char *, ...);
|
||||
void printflike(2, 3) cmdq_print(struct cmd_q *, const char *, ...);
|
||||
void printflike(2, 3) cmdq_error(struct cmd_q *, const char *, ...);
|
||||
int cmdq_guard(struct cmd_q *, const char *, int);
|
||||
void cmdq_run(struct cmd_q *, struct cmd_list *);
|
||||
void cmdq_append(struct cmd_q *, struct cmd_list *);
|
||||
@ -2005,9 +1926,9 @@ void status_free_jobs(struct status_out_tree *);
|
||||
void status_update_jobs(struct client *);
|
||||
void status_set_window_at(struct client *, u_int);
|
||||
int status_redraw(struct client *);
|
||||
char *status_replace(struct client *, struct session *,
|
||||
struct winlink *, struct window_pane *, const char *, time_t, int);
|
||||
void printflike2 status_message_set(struct client *, const char *, ...);
|
||||
char *status_replace(struct client *, struct session *, struct winlink *,
|
||||
struct window_pane *, const char *, time_t, int);
|
||||
void printflike(2, 3) status_message_set(struct client *, const char *, ...);
|
||||
void status_message_clear(struct client *);
|
||||
int status_message_redraw(struct client *);
|
||||
void status_prompt_set(struct client *, const char *, const char *,
|
||||
@ -2097,13 +2018,13 @@ void screen_write_start(
|
||||
struct screen_write_ctx *, struct window_pane *, struct screen *);
|
||||
void screen_write_stop(struct screen_write_ctx *);
|
||||
void screen_write_reset(struct screen_write_ctx *);
|
||||
size_t printflike2 screen_write_cstrlen(int, const char *, ...);
|
||||
void printflike5 screen_write_cnputs(struct screen_write_ctx *,
|
||||
size_t printflike(2, 3) screen_write_cstrlen(int, const char *, ...);
|
||||
void printflike(5, 6) screen_write_cnputs(struct screen_write_ctx *,
|
||||
ssize_t, struct grid_cell *, int, const char *, ...);
|
||||
size_t printflike2 screen_write_strlen(int, const char *, ...);
|
||||
void printflike3 screen_write_puts(struct screen_write_ctx *,
|
||||
size_t printflike(2, 3) screen_write_strlen(int, const char *, ...);
|
||||
void printflike(3, 4) screen_write_puts(struct screen_write_ctx *,
|
||||
struct grid_cell *, const char *, ...);
|
||||
void printflike5 screen_write_nputs(struct screen_write_ctx *,
|
||||
void printflike(5, 6) screen_write_nputs(struct screen_write_ctx *,
|
||||
ssize_t, struct grid_cell *, int, const char *, ...);
|
||||
void screen_write_vnputs(struct screen_write_ctx *,
|
||||
ssize_t, struct grid_cell *, int, const char *, va_list);
|
||||
@ -2287,7 +2208,7 @@ extern const char window_clock_table[14][5][5];
|
||||
extern const struct window_mode window_copy_mode;
|
||||
void window_copy_init_from_pane(struct window_pane *);
|
||||
void window_copy_init_for_output(struct window_pane *);
|
||||
void printflike2 window_copy_add(struct window_pane *, const char *, ...);
|
||||
void printflike(2, 3) window_copy_add(struct window_pane *, const char *, ...);
|
||||
void window_copy_vadd(struct window_pane *, const char *, va_list);
|
||||
void window_copy_pageup(struct window_pane *);
|
||||
|
||||
@ -2326,7 +2247,7 @@ void clear_signals(int);
|
||||
|
||||
/* control.c */
|
||||
void control_callback(struct client *, int, void *);
|
||||
void printflike2 control_write(struct client *, const char *, ...);
|
||||
void printflike(2, 3) control_write(struct client *, const char *, ...);
|
||||
void control_write_buffer(struct client *, struct evbuffer *);
|
||||
|
||||
/* control-notify.c */
|
||||
@ -2399,18 +2320,19 @@ struct event_base *osdep_event_init(void);
|
||||
/* log.c */
|
||||
void log_open(const char *);
|
||||
void log_close(void);
|
||||
void printflike1 log_debug(const char *, ...);
|
||||
__dead void printflike1 log_fatal(const char *, ...);
|
||||
__dead void printflike1 log_fatalx(const char *, ...);
|
||||
void printflike(1, 2) log_debug(const char *, ...);
|
||||
__dead void printflike(1, 2) log_fatal(const char *, ...);
|
||||
__dead void printflike(1, 2) log_fatalx(const char *, ...);
|
||||
|
||||
/* xmalloc.c */
|
||||
char *xstrdup(const char *);
|
||||
void *xcalloc(size_t, size_t);
|
||||
void *xmalloc(size_t);
|
||||
void *xrealloc(void *, size_t, size_t);
|
||||
int printflike2 xasprintf(char **, const char *, ...);
|
||||
void *xrealloc(void *, size_t);
|
||||
void *xreallocarray(void *, size_t, size_t);
|
||||
int printflike(2, 3) xasprintf(char **, const char *, ...);
|
||||
int xvasprintf(char **, const char *, va_list);
|
||||
int printflike3 xsnprintf(char *, size_t, const char *, ...);
|
||||
int printflike(3, 4) xsnprintf(char *, size_t, const char *, ...);
|
||||
int xvsnprintf(char *, size_t, const char *, va_list);
|
||||
|
||||
/* style.c */
|
||||
|
@ -81,7 +81,7 @@ tty_acs_get(struct tty *tty, u_char ch)
|
||||
struct tty_acs_entry *entry;
|
||||
|
||||
/* If not a UTF-8 terminal, use the ACS set. */
|
||||
if (!(tty->flags & TTY_UTF8)) {
|
||||
if (tty != NULL && !(tty->flags & TTY_UTF8)) {
|
||||
if (tty->term->acs[ch][0] == '\0')
|
||||
return (NULL);
|
||||
return (&tty->term->acs[ch][0]);
|
||||
|
8
utf8.c
8
utf8.c
@ -420,7 +420,7 @@ utf8_fromcstr(const char *src)
|
||||
|
||||
n = 0;
|
||||
while (*src != '\0') {
|
||||
dst = xrealloc(dst, n + 1, sizeof *dst);
|
||||
dst = xreallocarray(dst, n + 1, sizeof *dst);
|
||||
if (utf8_open(&dst[n], *src)) {
|
||||
more = 1;
|
||||
while (*++src != '\0' && more)
|
||||
@ -437,7 +437,7 @@ utf8_fromcstr(const char *src)
|
||||
n++;
|
||||
}
|
||||
|
||||
dst = xrealloc(dst, n + 1, sizeof *dst);
|
||||
dst = xreallocarray(dst, n + 1, sizeof *dst);
|
||||
dst[n].size = 0;
|
||||
return (dst);
|
||||
}
|
||||
@ -453,12 +453,12 @@ utf8_tocstr(struct utf8_data *src)
|
||||
|
||||
n = 0;
|
||||
for(; src->size != 0; src++) {
|
||||
dst = xrealloc(dst, n + src->size, 1);
|
||||
dst = xreallocarray(dst, n + src->size, 1);
|
||||
memcpy(dst + n, src->data, src->size);
|
||||
n += src->size;
|
||||
}
|
||||
|
||||
dst = xrealloc(dst, n + 1, 1);
|
||||
dst = xreallocarray(dst, n + 1, 1);
|
||||
dst[n] = '\0';
|
||||
return (dst);
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ window_choose_prompt_input(enum window_choose_input_type input_type,
|
||||
data->input_prompt = prompt;
|
||||
input_len = strlen(data->input_str) + 2;
|
||||
|
||||
data->input_str = xrealloc(data->input_str, 1, input_len);
|
||||
data->input_str = xrealloc(data->input_str, input_len);
|
||||
data->input_str[input_len - 2] = key;
|
||||
data->input_str[input_len - 1] = '\0';
|
||||
|
||||
|
@ -794,7 +794,7 @@ window_copy_key_input(struct window_pane *wp, int key)
|
||||
}
|
||||
inputlen = strlen(data->inputstr);
|
||||
|
||||
data->inputstr = xrealloc(data->inputstr, 1, inputlen + n + 1);
|
||||
data->inputstr = xrealloc(data->inputstr, inputlen + n + 1);
|
||||
memcpy(data->inputstr + inputlen, pb->data, n);
|
||||
data->inputstr[inputlen + n] = '\0';
|
||||
break;
|
||||
@ -840,7 +840,7 @@ window_copy_key_input(struct window_pane *wp, int key)
|
||||
break;
|
||||
inputlen = strlen(data->inputstr) + 2;
|
||||
|
||||
data->inputstr = xrealloc(data->inputstr, 1, inputlen);
|
||||
data->inputstr = xrealloc(data->inputstr, inputlen);
|
||||
data->inputstr[inputlen - 2] = key;
|
||||
data->inputstr[inputlen - 1] = '\0';
|
||||
break;
|
||||
@ -1533,7 +1533,7 @@ window_copy_append_selection(struct window_pane *wp, const char *bufname)
|
||||
} else
|
||||
pb = paste_get_name(bufname);
|
||||
if (pb != NULL) {
|
||||
buf = xrealloc(buf, 1, len + pb->size);
|
||||
buf = xrealloc(buf, len + pb->size);
|
||||
memmove(buf + pb->size, buf, len);
|
||||
memcpy(buf, pb->data, pb->size);
|
||||
len += pb->size;
|
||||
@ -1552,6 +1552,7 @@ window_copy_copy_line(struct window_pane *wp,
|
||||
struct grid_line *gl;
|
||||
struct utf8_data ud;
|
||||
u_int i, xx, wrapped = 0;
|
||||
const char *s;
|
||||
|
||||
if (sx > ex)
|
||||
return;
|
||||
@ -1580,8 +1581,15 @@ window_copy_copy_line(struct window_pane *wp,
|
||||
if (gc->flags & GRID_FLAG_PADDING)
|
||||
continue;
|
||||
grid_cell_get(gc, &ud);
|
||||
if (ud.size == 1 && (gc->attr & GRID_ATTR_CHARSET)) {
|
||||
s = tty_acs_get(NULL, ud.data[0]);
|
||||
if (s != NULL && strlen(s) <= sizeof ud.data) {
|
||||
ud.size = strlen(s);
|
||||
memcpy (ud.data, s, ud.size);
|
||||
}
|
||||
}
|
||||
|
||||
*buf = xrealloc(*buf, 1, (*off) + ud.size);
|
||||
*buf = xrealloc(*buf, (*off) + ud.size);
|
||||
memcpy(*buf + *off, ud.data, ud.size);
|
||||
*off += ud.size;
|
||||
}
|
||||
@ -1589,7 +1597,7 @@ window_copy_copy_line(struct window_pane *wp,
|
||||
|
||||
/* Only add a newline if the line wasn't wrapped. */
|
||||
if (!wrapped || ex != xx) {
|
||||
*buf = xrealloc(*buf, 1, (*off) + 1);
|
||||
*buf = xrealloc(*buf, (*off) + 1);
|
||||
(*buf)[(*off)++] = '\n';
|
||||
}
|
||||
}
|
||||
|
26
xmalloc.c
26
xmalloc.c
@ -16,10 +16,9 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <libgen.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -67,7 +66,20 @@ xmalloc(size_t size)
|
||||
}
|
||||
|
||||
void *
|
||||
xrealloc(void *oldptr, size_t nmemb, size_t size)
|
||||
xrealloc(void *oldptr, size_t newsize)
|
||||
{
|
||||
void *newptr;
|
||||
|
||||
if (newsize == 0)
|
||||
fatalx("zero size");
|
||||
if ((newptr = realloc(oldptr, newsize)) == NULL)
|
||||
fatal("xrealloc failed");
|
||||
|
||||
return (newptr);
|
||||
}
|
||||
|
||||
void *
|
||||
xreallocarray(void *oldptr, size_t nmemb, size_t size)
|
||||
{
|
||||
size_t newsize = nmemb * size;
|
||||
void *newptr;
|
||||
@ -77,12 +89,12 @@ xrealloc(void *oldptr, size_t nmemb, size_t size)
|
||||
if (SIZE_MAX / nmemb < size)
|
||||
fatalx("nmemb * size > SIZE_MAX");
|
||||
if ((newptr = realloc(oldptr, newsize)) == NULL)
|
||||
fatal("xrealloc failed");
|
||||
fatal("xreallocarray failed");
|
||||
|
||||
return (newptr);
|
||||
}
|
||||
|
||||
int printflike2
|
||||
int
|
||||
xasprintf(char **ret, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@ -107,7 +119,7 @@ xvasprintf(char **ret, const char *fmt, va_list ap)
|
||||
return (i);
|
||||
}
|
||||
|
||||
int printflike3
|
||||
int
|
||||
xsnprintf(char *buf, size_t len, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
Loading…
Reference in New Issue
Block a user