4 * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 #include <sys/queue.h>
26 #include <bitstring.h>
35 #include "tmux-protocol.h"
38 extern char **environ
;
41 struct args_command_state
;
44 struct cmd_find_state
;
51 struct format_job_tree
;
53 struct hyperlinks_uri
;
58 struct mode_tree_data
;
61 struct options_array_item
;
63 struct screen_write_citem
;
64 struct screen_write_cline
;
65 struct screen_write_ctx
;
74 /* Default configuration files and socket paths. */
76 #define TMUX_CONF "/etc/tmux.conf:~/.tmux.conf"
79 #define TMUX_SOCK "$TMUX_TMPDIR:" _PATH_TMP
81 #ifndef TMUX_SOCK_PERM
82 #define TMUX_SOCK_PERM (7 /* o+rwx */)
85 #define TMUX_TERM "screen"
88 /* Minimum layout cell size, NOT including border lines. */
89 #define PANE_MINIMUM 1
91 /* Minimum and maximum window size. */
92 #define WINDOW_MINIMUM PANE_MINIMUM
93 #define WINDOW_MAXIMUM 10000
95 /* Automatic name refresh interval, in microseconds. Must be < 1 second. */
96 #define NAME_INTERVAL 500000
98 /* Default pixel cell sizes. */
99 #define DEFAULT_XPIXEL 16
100 #define DEFAULT_YPIXEL 32
102 /* Attribute to make GCC check printf-like arguments. */
103 #define printflike(a, b) __attribute__ ((format (printf, a, b)))
105 /* Number of items in array. */
107 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
110 /* Alert option values. */
113 #define ALERT_CURRENT 2
114 #define ALERT_OTHER 3
116 /* Visual option values. */
119 #define VISUAL_BOTH 2
121 /* No key or unknown key. */
122 #define KEYC_NONE 0x000ff000000000ULL
123 #define KEYC_UNKNOWN 0x000fe000000000ULL
126 * Base for special (that is, not Unicode) keys. An enum must be at most a
127 * signed int, so these are based in the highest Unicode PUA.
129 #define KEYC_BASE 0x0000000010e000ULL
130 #define KEYC_USER 0x0000000010f000ULL
131 #define KEYC_USER_END (KEYC_USER + KEYC_NUSER)
133 /* Key modifier bits. */
134 #define KEYC_META 0x00100000000000ULL
135 #define KEYC_CTRL 0x00200000000000ULL
136 #define KEYC_SHIFT 0x00400000000000ULL
139 #define KEYC_LITERAL 0x01000000000000ULL
140 #define KEYC_KEYPAD 0x02000000000000ULL
141 #define KEYC_CURSOR 0x04000000000000ULL
142 #define KEYC_IMPLIED_META 0x08000000000000ULL
143 #define KEYC_BUILD_MODIFIERS 0x10000000000000ULL
144 #define KEYC_VI 0x20000000000000ULL
145 #define KEYC_SENT 0x40000000000000ULL
147 /* Masks for key bits. */
148 #define KEYC_MASK_MODIFIERS 0x00f00000000000ULL
149 #define KEYC_MASK_FLAGS 0xff000000000000ULL
150 #define KEYC_MASK_KEY 0x000fffffffffffULL
152 /* Available user keys. */
153 #define KEYC_NUSER 1000
155 /* Is this a mouse key? */
156 #define KEYC_IS_MOUSE(key) \
157 (((key) & KEYC_MASK_KEY) >= KEYC_MOUSE && \
158 ((key) & KEYC_MASK_KEY) < KEYC_BSPACE)
160 /* Is this a Unicode key? */
161 #define KEYC_IS_UNICODE(key) \
162 (((key) & KEYC_MASK_KEY) > 0x7f && \
163 (((key) & KEYC_MASK_KEY) < KEYC_BASE || \
164 ((key) & KEYC_MASK_KEY) >= KEYC_BASE_END) && \
165 (((key) & KEYC_MASK_KEY) < KEYC_USER || \
166 ((key) & KEYC_MASK_KEY) >= KEYC_USER_END))
168 /* Multiple click timeout. */
169 #define KEYC_CLICK_TIMEOUT 300
171 /* Mouse key codes. */
172 #define KEYC_MOUSE_KEY(name) \
173 KEYC_ ## name ## _PANE, \
174 KEYC_ ## name ## _STATUS, \
175 KEYC_ ## name ## _STATUS_LEFT, \
176 KEYC_ ## name ## _STATUS_RIGHT, \
177 KEYC_ ## name ## _STATUS_DEFAULT, \
178 KEYC_ ## name ## _BORDER
179 #define KEYC_MOUSE_STRING(name, s) \
180 { #s "Pane", KEYC_ ## name ## _PANE }, \
181 { #s "Status", KEYC_ ## name ## _STATUS }, \
182 { #s "StatusLeft", KEYC_ ## name ## _STATUS_LEFT }, \
183 { #s "StatusRight", KEYC_ ## name ## _STATUS_RIGHT }, \
184 { #s "StatusDefault", KEYC_ ## name ## _STATUS_DEFAULT }, \
185 { #s "Border", KEYC_ ## name ## _BORDER }
188 * A single key. This can be ASCII or Unicode or one of the keys between
189 * KEYC_BASE and KEYC_BASE_END.
191 typedef unsigned long long key_code
;
193 /* C0 control characters */
229 /* Special key codes. */
232 KEYC_FOCUS_IN
= KEYC_BASE
,
235 /* "Any" key, used if not found in key table. */
238 /* Paste brackets. */
243 KEYC_MOUSE
, /* unclassified mouse event */
244 KEYC_DRAGGING
, /* dragging in progress */
245 KEYC_DOUBLECLICK
, /* double click complete */
246 KEYC_MOUSE_KEY(MOUSEMOVE
),
247 KEYC_MOUSE_KEY(MOUSEDOWN1
),
248 KEYC_MOUSE_KEY(MOUSEDOWN2
),
249 KEYC_MOUSE_KEY(MOUSEDOWN3
),
250 KEYC_MOUSE_KEY(MOUSEDOWN6
),
251 KEYC_MOUSE_KEY(MOUSEDOWN7
),
252 KEYC_MOUSE_KEY(MOUSEDOWN8
),
253 KEYC_MOUSE_KEY(MOUSEDOWN9
),
254 KEYC_MOUSE_KEY(MOUSEDOWN10
),
255 KEYC_MOUSE_KEY(MOUSEDOWN11
),
256 KEYC_MOUSE_KEY(MOUSEUP1
),
257 KEYC_MOUSE_KEY(MOUSEUP2
),
258 KEYC_MOUSE_KEY(MOUSEUP3
),
259 KEYC_MOUSE_KEY(MOUSEUP6
),
260 KEYC_MOUSE_KEY(MOUSEUP7
),
261 KEYC_MOUSE_KEY(MOUSEUP8
),
262 KEYC_MOUSE_KEY(MOUSEUP9
),
263 KEYC_MOUSE_KEY(MOUSEUP10
),
264 KEYC_MOUSE_KEY(MOUSEUP11
),
265 KEYC_MOUSE_KEY(MOUSEDRAG1
),
266 KEYC_MOUSE_KEY(MOUSEDRAG2
),
267 KEYC_MOUSE_KEY(MOUSEDRAG3
),
268 KEYC_MOUSE_KEY(MOUSEDRAG6
),
269 KEYC_MOUSE_KEY(MOUSEDRAG7
),
270 KEYC_MOUSE_KEY(MOUSEDRAG8
),
271 KEYC_MOUSE_KEY(MOUSEDRAG9
),
272 KEYC_MOUSE_KEY(MOUSEDRAG10
),
273 KEYC_MOUSE_KEY(MOUSEDRAG11
),
274 KEYC_MOUSE_KEY(MOUSEDRAGEND1
),
275 KEYC_MOUSE_KEY(MOUSEDRAGEND2
),
276 KEYC_MOUSE_KEY(MOUSEDRAGEND3
),
277 KEYC_MOUSE_KEY(MOUSEDRAGEND6
),
278 KEYC_MOUSE_KEY(MOUSEDRAGEND7
),
279 KEYC_MOUSE_KEY(MOUSEDRAGEND8
),
280 KEYC_MOUSE_KEY(MOUSEDRAGEND9
),
281 KEYC_MOUSE_KEY(MOUSEDRAGEND10
),
282 KEYC_MOUSE_KEY(MOUSEDRAGEND11
),
283 KEYC_MOUSE_KEY(WHEELUP
),
284 KEYC_MOUSE_KEY(WHEELDOWN
),
285 KEYC_MOUSE_KEY(SECONDCLICK1
),
286 KEYC_MOUSE_KEY(SECONDCLICK2
),
287 KEYC_MOUSE_KEY(SECONDCLICK3
),
288 KEYC_MOUSE_KEY(SECONDCLICK6
),
289 KEYC_MOUSE_KEY(SECONDCLICK7
),
290 KEYC_MOUSE_KEY(SECONDCLICK8
),
291 KEYC_MOUSE_KEY(SECONDCLICK9
),
292 KEYC_MOUSE_KEY(SECONDCLICK10
),
293 KEYC_MOUSE_KEY(SECONDCLICK11
),
294 KEYC_MOUSE_KEY(DOUBLECLICK1
),
295 KEYC_MOUSE_KEY(DOUBLECLICK2
),
296 KEYC_MOUSE_KEY(DOUBLECLICK3
),
297 KEYC_MOUSE_KEY(DOUBLECLICK6
),
298 KEYC_MOUSE_KEY(DOUBLECLICK7
),
299 KEYC_MOUSE_KEY(DOUBLECLICK8
),
300 KEYC_MOUSE_KEY(DOUBLECLICK9
),
301 KEYC_MOUSE_KEY(DOUBLECLICK10
),
302 KEYC_MOUSE_KEY(DOUBLECLICK11
),
303 KEYC_MOUSE_KEY(TRIPLECLICK1
),
304 KEYC_MOUSE_KEY(TRIPLECLICK2
),
305 KEYC_MOUSE_KEY(TRIPLECLICK3
),
306 KEYC_MOUSE_KEY(TRIPLECLICK6
),
307 KEYC_MOUSE_KEY(TRIPLECLICK7
),
308 KEYC_MOUSE_KEY(TRIPLECLICK8
),
309 KEYC_MOUSE_KEY(TRIPLECLICK9
),
310 KEYC_MOUSE_KEY(TRIPLECLICK10
),
311 KEYC_MOUSE_KEY(TRIPLECLICK11
),
343 /* Numeric keypad. */
361 /* End of special keys. */
601 /* Character classes. */
602 #define WHITESPACE " "
605 #define MODEKEY_EMACS 0
609 #define MODE_CURSOR 0x1
610 #define MODE_INSERT 0x2
611 #define MODE_KCURSOR 0x4
612 #define MODE_KKEYPAD 0x8
613 #define MODE_WRAP 0x10
614 #define MODE_MOUSE_STANDARD 0x20
615 #define MODE_MOUSE_BUTTON 0x40
616 #define MODE_CURSOR_BLINKING 0x80
617 #define MODE_MOUSE_UTF8 0x100
618 #define MODE_MOUSE_SGR 0x200
619 #define MODE_BRACKETPASTE 0x400
620 #define MODE_FOCUSON 0x800
621 #define MODE_MOUSE_ALL 0x1000
622 #define MODE_ORIGIN 0x2000
623 #define MODE_CRLF 0x4000
624 #define MODE_KEYS_EXTENDED 0x8000
625 #define MODE_CURSOR_VERY_VISIBLE 0x10000
626 #define MODE_CURSOR_BLINKING_SET 0x20000
627 #define MODE_KEYS_EXTENDED_2 0x40000
629 #define ALL_MODES 0xffffff
630 #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
631 #define MOTION_MOUSE_MODES (MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
632 #define CURSOR_MODES (MODE_CURSOR|MODE_CURSOR_BLINKING|MODE_CURSOR_VERY_VISIBLE)
633 #define EXTENDED_KEY_MODES (MODE_KEYS_EXTENDED|MODE_KEYS_EXTENDED_2)
635 /* Mouse protocol constants. */
636 #define MOUSE_PARAM_MAX 0xff
637 #define MOUSE_PARAM_UTF8_MAX 0x7ff
638 #define MOUSE_PARAM_BTN_OFF 0x20
639 #define MOUSE_PARAM_POS_OFF 0x21
641 /* A single UTF-8 character. */
642 typedef u_int utf8_char
;
645 * An expanded UTF-8 character. UTF8_SIZE must be big enough to hold combining
646 * characters as well. It can't be more than 32 bytes without changes to how
647 * characters are stored.
651 u_char data
[UTF8_SIZE
];
656 u_char width
; /* 0xff if invalid */
665 #define COLOUR_FLAG_256 0x01000000
666 #define COLOUR_FLAG_RGB 0x02000000
668 /* Special colours. */
669 #define COLOUR_DEFAULT(c) ((c) == 8 || (c) == 9)
671 /* Replacement palette. */
672 struct colour_palette
{
677 int *default_palette
;
680 /* Grid attributes. Anything above 0xff is stored in an extended cell. */
681 #define GRID_ATTR_BRIGHT 0x1
682 #define GRID_ATTR_DIM 0x2
683 #define GRID_ATTR_UNDERSCORE 0x4
684 #define GRID_ATTR_BLINK 0x8
685 #define GRID_ATTR_REVERSE 0x10
686 #define GRID_ATTR_HIDDEN 0x20
687 #define GRID_ATTR_ITALICS 0x40
688 #define GRID_ATTR_CHARSET 0x80 /* alternative character set */
689 #define GRID_ATTR_STRIKETHROUGH 0x100
690 #define GRID_ATTR_UNDERSCORE_2 0x200
691 #define GRID_ATTR_UNDERSCORE_3 0x400
692 #define GRID_ATTR_UNDERSCORE_4 0x800
693 #define GRID_ATTR_UNDERSCORE_5 0x1000
694 #define GRID_ATTR_OVERLINE 0x2000
696 /* All underscore attributes. */
697 #define GRID_ATTR_ALL_UNDERSCORE \
698 (GRID_ATTR_UNDERSCORE| \
699 GRID_ATTR_UNDERSCORE_2| \
700 GRID_ATTR_UNDERSCORE_3| \
701 GRID_ATTR_UNDERSCORE_4| \
702 GRID_ATTR_UNDERSCORE_5)
705 #define GRID_FLAG_FG256 0x1
706 #define GRID_FLAG_BG256 0x2
707 #define GRID_FLAG_PADDING 0x4
708 #define GRID_FLAG_EXTENDED 0x8
709 #define GRID_FLAG_SELECTED 0x10
710 #define GRID_FLAG_NOPALETTE 0x20
711 #define GRID_FLAG_CLEARED 0x40
713 /* Grid line flags. */
714 #define GRID_LINE_WRAPPED 0x1
715 #define GRID_LINE_EXTENDED 0x2
716 #define GRID_LINE_DEAD 0x4
717 #define GRID_LINE_START_PROMPT 0x8
718 #define GRID_LINE_START_OUTPUT 0x10
720 /* Grid string flags. */
721 #define GRID_STRING_WITH_SEQUENCES 0x1
722 #define GRID_STRING_ESCAPE_SEQUENCES 0x2
723 #define GRID_STRING_TRIM_SPACES 0x4
724 #define GRID_STRING_USED_ONLY 0x8
725 #define GRID_STRING_EMPTY_CELLS 0x10
727 /* Cell positions. */
728 #define CELL_INSIDE 0
729 #define CELL_TOPBOTTOM 1
730 #define CELL_LEFTRIGHT 2
731 #define CELL_TOPLEFT 3
732 #define CELL_TOPRIGHT 4
733 #define CELL_BOTTOMLEFT 5
734 #define CELL_BOTTOMRIGHT 6
735 #define CELL_TOPJOIN 7
736 #define CELL_BOTTOMJOIN 8
737 #define CELL_LEFTJOIN 9
738 #define CELL_RIGHTJOIN 10
740 #define CELL_OUTSIDE 12
743 #define CELL_BORDERS " xqlkmjwvtun~"
744 #define SIMPLE_BORDERS " |-+++++++++."
745 #define PADDED_BORDERS " "
747 /* Grid cell data. */
749 struct utf8_data data
;
758 /* Grid extended cell entry. */
759 struct grid_extd_entry
{
769 /* Grid cell entry. */
770 struct grid_cell_entry
{
785 struct grid_cell_entry
*celldata
;
789 struct grid_extd_entry
*extddata
;
796 /* Entire grid of cells. */
799 #define GRID_HISTORY 0x1 /* scroll lines into history */
808 struct grid_line
*linedata
;
811 /* Virtual cursor in a grid. */
818 /* Style alignment. */
824 STYLE_ALIGN_ABSOLUTE_CENTRE
832 STYLE_LIST_LEFT_MARKER
,
833 STYLE_LIST_RIGHT_MARKER
,
837 enum style_range_type
{
847 enum style_range_type type
;
852 u_int end
; /* not included */
854 TAILQ_ENTRY(style_range
) entry
;
856 TAILQ_HEAD(style_ranges
, style_range
);
859 enum style_default_type
{
871 enum style_align align
;
872 enum style_list list
;
874 enum style_range_type range_type
;
875 u_int range_argument
;
876 char range_string
[16];
878 enum style_default_type default_type
;
882 enum screen_cursor_style
{
883 SCREEN_CURSOR_DEFAULT
,
885 SCREEN_CURSOR_UNDERLINE
,
889 /* Virtual screen. */
891 struct screen_titles
;
895 struct screen_titles
*titles
;
897 struct grid
*grid
; /* grid data */
899 u_int cx
; /* cursor x */
900 u_int cy
; /* cursor y */
902 enum screen_cursor_style cstyle
; /* cursor style */
903 enum screen_cursor_style default_cstyle
;
904 int ccolour
; /* cursor colour */
907 u_int rupper
; /* scroll region top */
908 u_int rlower
; /* scroll region bottom */
915 struct grid
*saved_grid
;
916 struct grid_cell saved_cell
;
920 struct screen_sel
*sel
;
922 struct screen_write_cline
*write_list
;
924 struct hyperlinks
*hyperlinks
;
927 /* Screen write context. */
928 typedef void (*screen_write_init_ctx_cb
)(struct screen_write_ctx
*,
930 struct screen_write_ctx
{
931 struct window_pane
*wp
;
935 #define SCREEN_WRITE_SYNC 0x1
937 screen_write_init_ctx_cb init_ctx_cb
;
940 struct screen_write_citem
*item
;
945 /* Box border lines option. */
947 BOX_LINES_DEFAULT
= -1,
957 /* Pane border lines option. */
966 /* Pane border indicator option. */
967 #define PANE_BORDER_OFF 0
968 #define PANE_BORDER_COLOUR 1
969 #define PANE_BORDER_ARROWS 2
970 #define PANE_BORDER_BOTH 3
972 /* Mode returned by window_pane_mode function. */
973 #define WINDOW_PANE_NO_MODE 0
974 #define WINDOW_PANE_COPY_MODE 1
975 #define WINDOW_PANE_VIEW_MODE 2
977 /* Screen redraw context. */
978 struct screen_redraw_ctx
{
985 enum pane_lines pane_lines
;
987 struct grid_cell no_pane_gc
;
997 #define screen_size_x(s) ((s)->grid->sx)
998 #define screen_size_y(s) ((s)->grid->sy)
999 #define screen_hsize(s) ((s)->grid->hsize)
1000 #define screen_hlimit(s) ((s)->grid->hlimit)
1006 const char *command
;
1010 struct menu_item
*items
;
1014 typedef void (*menu_choice_cb
)(struct menu
*, u_int
, key_code
, void *);
1017 * Window mode. Windows can be in several modes and this is used to call the
1018 * right function to handle input and output.
1020 struct window_mode_entry
;
1021 struct window_mode
{
1023 const char *default_format
;
1025 struct screen
*(*init
)(struct window_mode_entry
*,
1026 struct cmd_find_state
*, struct args
*);
1027 void (*free
)(struct window_mode_entry
*);
1028 void (*resize
)(struct window_mode_entry
*, u_int
, u_int
);
1029 void (*update
)(struct window_mode_entry
*);
1030 void (*key
)(struct window_mode_entry
*, struct client
*,
1031 struct session
*, struct winlink
*, key_code
,
1032 struct mouse_event
*);
1034 const char *(*key_table
)(struct window_mode_entry
*);
1035 void (*command
)(struct window_mode_entry
*, struct client
*,
1036 struct session
*, struct winlink
*, struct args
*,
1037 struct mouse_event
*);
1038 void (*formats
)(struct window_mode_entry
*,
1039 struct format_tree
*);
1042 /* Active window mode. */
1043 struct window_mode_entry
{
1044 struct window_pane
*wp
;
1045 struct window_pane
*swp
;
1047 const struct window_mode
*mode
;
1050 struct screen
*screen
;
1053 TAILQ_ENTRY(window_mode_entry
) entry
;
1056 /* Offsets into pane buffer. */
1057 struct window_pane_offset
{
1061 /* Queued pane resize. */
1062 struct window_pane_resize
{
1069 TAILQ_ENTRY(window_pane_resize
) entry
;
1071 TAILQ_HEAD(window_pane_resizes
, window_pane_resize
);
1073 /* Child window structure. */
1074 struct window_pane
{
1078 struct window
*window
;
1079 struct options
*options
;
1081 struct layout_cell
*layout_cell
;
1082 struct layout_cell
*saved_layout_cell
;
1091 #define PANE_REDRAW 0x1
1092 #define PANE_DROP 0x2
1093 #define PANE_FOCUSED 0x4
1094 #define PANE_VISITED 0x8
1097 #define PANE_INPUTOFF 0x40
1098 #define PANE_CHANGED 0x80
1099 #define PANE_EXITED 0x100
1100 #define PANE_STATUSREADY 0x200
1101 #define PANE_STATUSDRAWN 0x400
1102 #define PANE_EMPTY 0x800
1103 #define PANE_STYLECHANGED 0x1000
1104 #define PANE_UNSEENCHANGES 0x2000
1112 char tty
[TTY_NAME_MAX
];
1114 struct timeval dead_time
;
1117 struct bufferevent
*event
;
1119 struct window_pane_offset offset
;
1122 struct window_pane_resizes resize_queue
;
1123 struct event resize_timer
;
1125 struct input_ctx
*ictx
;
1127 struct grid_cell cached_gc
;
1128 struct grid_cell cached_active_gc
;
1129 struct colour_palette palette
;
1132 struct bufferevent
*pipe_event
;
1133 struct window_pane_offset pipe_offset
;
1135 struct screen
*screen
;
1138 struct screen status_screen
;
1141 TAILQ_HEAD(, window_mode_entry
) modes
;
1147 struct grid_cell border_gc
;
1152 TAILQ_ENTRY(window_pane
) entry
; /* link in list of all panes */
1153 TAILQ_ENTRY(window_pane
) sentry
; /* link in list of last visited */
1154 RB_ENTRY(window_pane
) tree_entry
;
1156 TAILQ_HEAD(window_panes
, window_pane
);
1157 RB_HEAD(window_pane_tree
, window_pane
);
1159 /* Window structure. */
1165 struct event name_event
;
1166 struct timeval name_time
;
1168 struct event alerts_timer
;
1169 struct event offset_timer
;
1171 struct timeval activity_time
;
1173 struct window_pane
*active
;
1174 struct window_panes last_panes
;
1175 struct window_panes panes
;
1178 struct layout_cell
*layout_root
;
1179 struct layout_cell
*saved_layout_root
;
1194 struct utf8_data
*fill_character
;
1196 #define WINDOW_BELL 0x1
1197 #define WINDOW_ACTIVITY 0x2
1198 #define WINDOW_SILENCE 0x4
1199 #define WINDOW_ZOOMED 0x8
1200 #define WINDOW_WASZOOMED 0x10
1201 #define WINDOW_RESIZE 0x20
1202 #define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
1205 TAILQ_ENTRY(window
) alerts_entry
;
1207 struct options
*options
;
1210 TAILQ_HEAD(, winlink
) winlinks
;
1212 RB_ENTRY(window
) entry
;
1214 RB_HEAD(windows
, window
);
1216 /* Entry on local window list. */
1219 struct session
*session
;
1220 struct window
*window
;
1223 #define WINLINK_BELL 0x1
1224 #define WINLINK_ACTIVITY 0x2
1225 #define WINLINK_SILENCE 0x4
1226 #define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_SILENCE)
1227 #define WINLINK_VISITED 0x8
1229 RB_ENTRY(winlink
) entry
;
1230 TAILQ_ENTRY(winlink
) wentry
;
1231 TAILQ_ENTRY(winlink
) sentry
;
1233 RB_HEAD(winlinks
, winlink
);
1234 TAILQ_HEAD(winlink_stack
, winlink
);
1236 /* Window size option. */
1237 #define WINDOW_SIZE_LARGEST 0
1238 #define WINDOW_SIZE_SMALLEST 1
1239 #define WINDOW_SIZE_MANUAL 2
1240 #define WINDOW_SIZE_LATEST 3
1242 /* Pane border status option. */
1243 #define PANE_STATUS_OFF 0
1244 #define PANE_STATUS_TOP 1
1245 #define PANE_STATUS_BOTTOM 2
1247 /* Layout direction. */
1254 /* Layout cells queue. */
1255 TAILQ_HEAD(layout_cells
, layout_cell
);
1258 struct layout_cell
{
1259 enum layout_type type
;
1261 struct layout_cell
*parent
;
1269 struct window_pane
*wp
;
1270 struct layout_cells cells
;
1272 TAILQ_ENTRY(layout_cell
) entry
;
1275 /* Environment variable. */
1276 struct environ_entry
{
1281 #define ENVIRON_HIDDEN 0x1
1283 RB_ENTRY(environ_entry
) entry
;
1286 /* Client session. */
1287 struct session_group
{
1289 TAILQ_HEAD(, session
) sessions
;
1291 RB_ENTRY(session_group
) entry
;
1293 RB_HEAD(session_groups
, session_group
);
1301 struct timeval creation_time
;
1302 struct timeval last_attached_time
;
1303 struct timeval activity_time
;
1304 struct timeval last_activity_time
;
1306 struct event lock_timer
;
1308 struct winlink
*curw
;
1309 struct winlink_stack lastw
;
1310 struct winlinks windows
;
1315 struct options
*options
;
1317 #define SESSION_ALERTED 0x1
1322 struct termios
*tio
;
1324 struct environ
*environ
;
1328 TAILQ_ENTRY(session
) gentry
;
1329 RB_ENTRY(session
) entry
;
1331 RB_HEAD(sessions
, session
);
1333 /* Mouse button masks. */
1334 #define MOUSE_MASK_BUTTONS 195
1335 #define MOUSE_MASK_SHIFT 4
1336 #define MOUSE_MASK_META 8
1337 #define MOUSE_MASK_CTRL 16
1338 #define MOUSE_MASK_DRAG 32
1339 #define MOUSE_MASK_MODIFIERS (MOUSE_MASK_SHIFT|MOUSE_MASK_META|MOUSE_MASK_CTRL)
1341 /* Mouse wheel type. */
1342 #define MOUSE_WHEEL_UP 64
1343 #define MOUSE_WHEEL_DOWN 65
1345 /* Mouse button type. */
1346 #define MOUSE_BUTTON_1 0
1347 #define MOUSE_BUTTON_2 1
1348 #define MOUSE_BUTTON_3 2
1349 #define MOUSE_BUTTON_6 66
1350 #define MOUSE_BUTTON_7 67
1351 #define MOUSE_BUTTON_8 128
1352 #define MOUSE_BUTTON_9 129
1353 #define MOUSE_BUTTON_10 130
1354 #define MOUSE_BUTTON_11 131
1356 /* Mouse helpers. */
1357 #define MOUSE_BUTTONS(b) ((b) & MOUSE_MASK_BUTTONS)
1358 #define MOUSE_WHEEL(b) \
1359 (((b) & MOUSE_MASK_BUTTONS) == MOUSE_WHEEL_UP || \
1360 ((b) & MOUSE_MASK_BUTTONS) == MOUSE_WHEEL_DOWN)
1361 #define MOUSE_DRAG(b) ((b) & MOUSE_MASK_DRAG)
1362 #define MOUSE_RELEASE(b) (((b) & MOUSE_MASK_BUTTONS) == 3)
1365 struct mouse_event
{
1396 struct mouse_event m
;
1402 /* Terminal definition. */
1408 char acs
[UCHAR_MAX
+ 1][2];
1410 struct tty_code
*codes
;
1412 #define TERM_256COLOURS 0x1
1413 #define TERM_NOAM 0x2
1414 #define TERM_DECSLRM 0x4
1415 #define TERM_DECFRA 0x8
1416 #define TERM_RGBCOLOURS 0x10
1417 #define TERM_VT100LIKE 0x20
1418 #define TERM_SIXEL 0x40
1421 LIST_ENTRY(tty_term
) entry
;
1423 LIST_HEAD(tty_terms
, tty_term
);
1425 /* Client terminal. */
1427 struct client
*client
;
1428 struct event start_timer
;
1429 struct event clipboard_timer
;
1430 time_t last_requests
;
1439 enum screen_cursor_style cstyle
;
1458 struct event event_in
;
1459 struct evbuffer
*in
;
1460 struct event event_out
;
1461 struct evbuffer
*out
;
1467 struct grid_cell cell
;
1468 struct grid_cell last_cell
;
1470 #define TTY_NOCURSOR 0x1
1471 #define TTY_FREEZE 0x2
1472 #define TTY_TIMER 0x4
1473 #define TTY_NOBLOCK 0x8
1474 #define TTY_STARTED 0x10
1475 #define TTY_OPENED 0x20
1476 #define TTY_OSC52QUERY 0x40
1477 #define TTY_BLOCK 0x80
1478 #define TTY_HAVEDA 0x100 /* Primary DA. */
1479 #define TTY_HAVEXDA 0x200
1480 #define TTY_SYNCING 0x400
1481 #define TTY_HAVEDA2 0x800 /* Secondary DA. */
1482 #define TTY_WINSIZEQUERY 0x1000
1483 #define TTY_ALL_REQUEST_FLAGS \
1484 (TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA)
1487 struct tty_term
*term
;
1492 int mouse_drag_flag
;
1493 void (*mouse_drag_update
)(struct client
*,
1494 struct mouse_event
*);
1495 void (*mouse_drag_release
)(struct client
*,
1496 struct mouse_event
*);
1498 struct event key_timer
;
1499 struct tty_key
*key_tree
;
1502 /* Terminal command context. */
1503 typedef void (*tty_ctx_redraw_cb
)(const struct tty_ctx
*);
1504 typedef int (*tty_ctx_set_client_cb
)(struct tty_ctx
*, struct client
*);
1508 tty_ctx_redraw_cb redraw_cb
;
1509 tty_ctx_set_client_cb set_client_cb
;
1512 const struct grid_cell
*cell
;
1520 * Whether this command should be sent even when the pane is not
1521 * visible (used for a passthrough sequence when allow-passthrough is
1524 int allow_invisible_panes
;
1527 * Cursor and region position before the screen was updated - this is
1528 * where the command should be applied; the values in the screen have
1529 * already been updated.
1537 /* Target region (usually pane) offset and size. */
1545 /* The background colour used for clearing (erasing). */
1548 /* The default colours and palette. */
1549 struct grid_cell defaults
;
1550 struct colour_palette
*palette
;
1552 /* Containing region (usually window) offset and size. */
1560 /* Saved message entry. */
1561 struct message_entry
{
1564 struct timeval msg_time
;
1566 TAILQ_ENTRY(message_entry
) entry
;
1568 TAILQ_HEAD(message_list
, message_entry
);
1570 /* Argument type. */
1577 /* Argument value. */
1579 enum args_type type
;
1582 struct cmd_list
*cmdlist
;
1585 TAILQ_ENTRY(args_value
) entry
;
1588 /* Arguments set. */
1590 RB_HEAD(args_tree
, args_entry
);
1592 /* Arguments parsing type. */
1593 enum args_parse_type
{
1596 ARGS_PARSE_COMMANDS_OR_STRING
,
1600 /* Arguments parsing state. */
1601 typedef enum args_parse_type (*args_parse_cb
)(struct args
*, u_int
, char **);
1603 const char *template;
1609 /* Command find structures. */
1610 enum cmd_find_type
{
1615 struct cmd_find_state
{
1617 struct cmd_find_state
*current
;
1622 struct window_pane
*wp
;
1626 /* Command find flags. */
1627 #define CMD_FIND_PREFER_UNATTACHED 0x1
1628 #define CMD_FIND_QUIET 0x2
1629 #define CMD_FIND_WINDOW_INDEX 0x4
1630 #define CMD_FIND_DEFAULT_MARKED 0x8
1631 #define CMD_FIND_EXACT_SESSION 0x10
1632 #define CMD_FIND_EXACT_WINDOW 0x20
1633 #define CMD_FIND_CANFAIL 0x40
1635 /* List of commands. */
1642 /* Command return values. */
1644 CMD_RETURN_ERROR
= -1,
1645 CMD_RETURN_NORMAL
= 0,
1650 /* Command parse result. */
1651 enum cmd_parse_status
{
1655 struct cmd_parse_result
{
1656 enum cmd_parse_status status
;
1657 struct cmd_list
*cmdlist
;
1660 struct cmd_parse_input
{
1662 #define CMD_PARSE_QUIET 0x1
1663 #define CMD_PARSE_PARSEONLY 0x2
1664 #define CMD_PARSE_NOALIAS 0x4
1665 #define CMD_PARSE_VERBOSE 0x8
1666 #define CMD_PARSE_ONEGROUP 0x10
1671 struct cmdq_item
*item
;
1673 struct cmd_find_state fs
;
1676 /* Command queue flags. */
1677 #define CMDQ_STATE_REPEAT 0x1
1678 #define CMDQ_STATE_CONTROL 0x2
1679 #define CMDQ_STATE_NOHOOKS 0x4
1681 /* Command queue callback. */
1682 typedef enum cmd_retval (*cmdq_cb
) (struct cmdq_item
*, void *);
1684 /* Command definition flag. */
1685 struct cmd_entry_flag
{
1687 enum cmd_find_type type
;
1691 /* Command definition. */
1696 struct args_parse args
;
1699 struct cmd_entry_flag source
;
1700 struct cmd_entry_flag target
;
1702 #define CMD_STARTSERVER 0x1
1703 #define CMD_READONLY 0x2
1704 #define CMD_AFTERHOOK 0x4
1705 #define CMD_CLIENT_CFLAG 0x8
1706 #define CMD_CLIENT_TFLAG 0x10
1707 #define CMD_CLIENT_CANFAIL 0x20
1710 enum cmd_retval (*exec
)(struct cmd
*, struct cmdq_item
*);
1714 #define STATUS_LINES_LIMIT 5
1715 struct status_line_entry
{
1717 struct style_ranges ranges
;
1719 struct status_line
{
1722 struct screen screen
;
1723 struct screen
*active
;
1726 struct grid_cell style
;
1727 struct status_line_entry entries
[STATUS_LINES_LIMIT
];
1731 #define PROMPT_NTYPES 4
1733 PROMPT_TYPE_COMMAND
,
1736 PROMPT_TYPE_WINDOW_TARGET
,
1737 PROMPT_TYPE_INVALID
= 0xff
1740 /* File in client. */
1741 typedef void (*client_file_cb
) (struct client
*, const char *, int, int,
1742 struct evbuffer
*, void *);
1743 struct client_file
{
1745 struct tmuxpeer
*peer
;
1746 struct client_files
*tree
;
1751 struct evbuffer
*buffer
;
1752 struct bufferevent
*event
;
1761 RB_ENTRY(client_file
) entry
;
1763 RB_HEAD(client_files
, client_file
);
1765 /* Client window. */
1766 struct client_window
{
1768 struct window_pane
*pane
;
1773 RB_ENTRY(client_window
) entry
;
1775 RB_HEAD(client_windows
, client_window
);
1777 /* Visible areas not obstructed by overlays. */
1778 #define OVERLAY_MAX_RANGES 3
1779 struct overlay_ranges
{
1780 u_int px
[OVERLAY_MAX_RANGES
];
1781 u_int nx
[OVERLAY_MAX_RANGES
];
1784 /* Client connection. */
1785 typedef int (*prompt_input_cb
)(struct client
*, void *, const char *, int);
1786 typedef void (*prompt_free_cb
)(void *);
1787 typedef void (*overlay_check_cb
)(struct client
*, void *, u_int
, u_int
, u_int
,
1788 struct overlay_ranges
*);
1789 typedef struct screen
*(*overlay_mode_cb
)(struct client
*, void *, u_int
*,
1791 typedef void (*overlay_draw_cb
)(struct client
*, void *,
1792 struct screen_redraw_ctx
*);
1793 typedef int (*overlay_key_cb
)(struct client
*, void *, struct key_event
*);
1794 typedef void (*overlay_free_cb
)(struct client
*, void *);
1795 typedef void (*overlay_resize_cb
)(struct client
*, void *);
1798 struct tmuxpeer
*peer
;
1799 struct cmdq_list
*queue
;
1801 struct client_windows windows
;
1803 struct control_state
*control_state
;
1812 struct timeval creation_time
;
1813 struct timeval activity_time
;
1814 struct timeval last_activity_time
;
1816 struct environ
*environ
;
1817 struct format_job_tree
*jobs
;
1836 struct event repeat_timer
;
1838 struct event click_timer
;
1840 struct mouse_event click_event
;
1842 struct status_line status
;
1844 #define CLIENT_TERMINAL 0x1
1845 #define CLIENT_LOGIN 0x2
1846 #define CLIENT_EXIT 0x4
1847 #define CLIENT_REDRAWWINDOW 0x8
1848 #define CLIENT_REDRAWSTATUS 0x10
1849 #define CLIENT_REPEAT 0x20
1850 #define CLIENT_SUSPENDED 0x40
1851 #define CLIENT_ATTACHED 0x80
1852 #define CLIENT_EXITED 0x100
1853 #define CLIENT_DEAD 0x200
1854 #define CLIENT_REDRAWBORDERS 0x400
1855 #define CLIENT_READONLY 0x800
1856 #define CLIENT_NOSTARTSERVER 0x1000
1857 #define CLIENT_CONTROL 0x2000
1858 #define CLIENT_CONTROLCONTROL 0x4000
1859 #define CLIENT_FOCUSED 0x8000
1860 #define CLIENT_UTF8 0x10000
1861 #define CLIENT_IGNORESIZE 0x20000
1862 #define CLIENT_IDENTIFIED 0x40000
1863 #define CLIENT_STATUSFORCE 0x80000
1864 #define CLIENT_DOUBLECLICK 0x100000
1865 #define CLIENT_TRIPLECLICK 0x200000
1866 #define CLIENT_SIZECHANGED 0x400000
1867 #define CLIENT_STATUSOFF 0x800000
1868 #define CLIENT_REDRAWSTATUSALWAYS 0x1000000
1869 #define CLIENT_REDRAWOVERLAY 0x2000000
1870 #define CLIENT_CONTROL_NOOUTPUT 0x4000000
1871 #define CLIENT_DEFAULTSOCKET 0x8000000
1872 #define CLIENT_STARTSERVER 0x10000000
1873 #define CLIENT_REDRAWPANES 0x20000000
1874 #define CLIENT_NOFORK 0x40000000
1875 #define CLIENT_ACTIVEPANE 0x80000000ULL
1876 #define CLIENT_CONTROL_PAUSEAFTER 0x100000000ULL
1877 #define CLIENT_CONTROL_WAITEXIT 0x200000000ULL
1878 #define CLIENT_WINDOWSIZECHANGED 0x400000000ULL
1879 #define CLIENT_CLIPBOARDBUFFER 0x800000000ULL
1880 #define CLIENT_BRACKETPASTING 0x1000000000ULL
1881 #define CLIENT_ASSUMEPASTING 0x2000000000ULL
1882 #define CLIENT_ALLREDRAWFLAGS \
1883 (CLIENT_REDRAWWINDOW| \
1884 CLIENT_REDRAWSTATUS| \
1885 CLIENT_REDRAWSTATUSALWAYS| \
1886 CLIENT_REDRAWBORDERS| \
1887 CLIENT_REDRAWOVERLAY| \
1889 #define CLIENT_UNATTACHEDFLAGS \
1893 #define CLIENT_NODETACHFLAGS \
1896 #define CLIENT_NOSIZEFLAGS \
1904 CLIENT_EXIT_SHUTDOWN
,
1907 enum msgtype exit_msgtype
;
1911 struct key_table
*keytable
;
1914 uint64_t redraw_panes
;
1916 int message_ignore_keys
;
1917 int message_ignore_styles
;
1918 char *message_string
;
1919 struct event message_timer
;
1921 char *prompt_string
;
1922 struct utf8_data
*prompt_buffer
;
1924 size_t prompt_index
;
1925 prompt_input_cb prompt_inputcb
;
1926 prompt_free_cb prompt_freecb
;
1928 u_int prompt_hindex
[PROMPT_NTYPES
];
1933 struct utf8_data
*prompt_saved
;
1934 #define PROMPT_SINGLE 0x1
1935 #define PROMPT_NUMERIC 0x2
1936 #define PROMPT_INCREMENTAL 0x4
1937 #define PROMPT_NOFORMAT 0x8
1938 #define PROMPT_KEY 0x10
1939 #define PROMPT_ACCEPT 0x20
1941 enum prompt_type prompt_type
;
1944 struct session
*session
;
1945 struct session
*last_session
;
1953 overlay_check_cb overlay_check
;
1954 overlay_mode_cb overlay_mode
;
1955 overlay_draw_cb overlay_draw
;
1956 overlay_key_cb overlay_key
;
1957 overlay_free_cb overlay_free
;
1958 overlay_resize_cb overlay_resize
;
1960 struct event overlay_timer
;
1962 struct client_files files
;
1964 u_int
*clipboard_panes
;
1965 u_int clipboard_npanes
;
1967 TAILQ_ENTRY(client
) entry
;
1969 TAILQ_HEAD(clients
, client
);
1971 /* Control mode subscription type. */
1972 enum control_sub_type
{
1973 CONTROL_SUB_SESSION
,
1975 CONTROL_SUB_ALL_PANES
,
1977 CONTROL_SUB_ALL_WINDOWS
1980 /* Key binding and key table. */
1981 struct key_binding
{
1983 struct cmd_list
*cmdlist
;
1987 #define KEY_BINDING_REPEAT 0x1
1989 RB_ENTRY(key_binding
) entry
;
1991 RB_HEAD(key_bindings
, key_binding
);
1995 struct timeval activity_time
;
1996 struct key_bindings key_bindings
;
1997 struct key_bindings default_key_bindings
;
2001 RB_ENTRY(key_table
) entry
;
2003 RB_HEAD(key_tables
, key_table
);
2006 RB_HEAD(options_array
, options_array_item
);
2007 union options_value
{
2011 struct options_array array
;
2012 struct cmd_list
*cmdlist
;
2015 /* Option table entries. */
2016 enum options_table_type
{
2017 OPTIONS_TABLE_STRING
,
2018 OPTIONS_TABLE_NUMBER
,
2020 OPTIONS_TABLE_COLOUR
,
2022 OPTIONS_TABLE_CHOICE
,
2023 OPTIONS_TABLE_COMMAND
2026 #define OPTIONS_TABLE_NONE 0
2027 #define OPTIONS_TABLE_SERVER 0x1
2028 #define OPTIONS_TABLE_SESSION 0x2
2029 #define OPTIONS_TABLE_WINDOW 0x4
2030 #define OPTIONS_TABLE_PANE 0x8
2032 #define OPTIONS_TABLE_IS_ARRAY 0x1
2033 #define OPTIONS_TABLE_IS_HOOK 0x2
2034 #define OPTIONS_TABLE_IS_STYLE 0x4
2036 struct options_table_entry
{
2038 const char *alternative_name
;
2039 enum options_table_type type
;
2045 const char **choices
;
2047 const char *default_str
;
2048 long long default_num
;
2049 const char **default_arr
;
2051 const char *separator
;
2052 const char *pattern
;
2058 struct options_name_map
{
2063 /* Common command usages. */
2064 #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
2065 #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
2066 #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
2067 #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
2068 #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
2069 #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
2070 #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
2071 #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
2072 #define CMD_BUFFER_USAGE "[-b buffer-name]"
2074 /* Spawn common context. */
2075 struct spawn_context
{
2076 struct cmdq_item
*item
;
2082 struct window_pane
*wp0
;
2083 struct layout_cell
*lc
;
2088 struct environ
*environ
;
2094 #define SPAWN_KILL 0x1
2095 #define SPAWN_DETACHED 0x2
2096 #define SPAWN_RESPAWN 0x4
2097 #define SPAWN_BEFORE 0x8
2098 #define SPAWN_NONOTIFY 0x10
2099 #define SPAWN_FULLSIZE 0x20
2100 #define SPAWN_EMPTY 0x40
2101 #define SPAWN_ZOOM 0x80
2104 /* Mode tree sort order. */
2105 struct mode_tree_sort_criteria
{
2111 extern struct options
*global_options
;
2112 extern struct options
*global_s_options
;
2113 extern struct options
*global_w_options
;
2114 extern struct environ
*global_environ
;
2115 extern struct timeval start_time
;
2116 extern const char *socket_path
;
2117 extern const char *shell_command
;
2119 extern const char *shell_command
;
2120 int checkshell(const char *);
2121 void setblocking(int, int);
2122 char *shell_argv0(const char *, int);
2123 uint64_t get_timer(void);
2124 const char *sig2name(int);
2125 const char *find_cwd(void);
2126 const char *find_home(void);
2127 const char *getversion(void);
2131 int proc_send(struct tmuxpeer
*, enum msgtype
, int, const void *, size_t);
2132 struct tmuxproc
*proc_start(const char *);
2133 void proc_loop(struct tmuxproc
*, int (*)(void));
2134 void proc_exit(struct tmuxproc
*);
2135 void proc_set_signals(struct tmuxproc
*, void(*)(int));
2136 void proc_clear_signals(struct tmuxproc
*, int);
2137 struct tmuxpeer
*proc_add_peer(struct tmuxproc
*, int,
2138 void (*)(struct imsg
*, void *), void *);
2139 void proc_remove_peer(struct tmuxpeer
*);
2140 void proc_kill_peer(struct tmuxpeer
*);
2141 void proc_flush_peer(struct tmuxpeer
*);
2142 void proc_toggle_log(struct tmuxproc
*);
2143 pid_t
proc_fork_and_daemon(int *);
2144 uid_t
proc_get_peer_uid(struct tmuxpeer
*);
2147 extern int cfg_finished
;
2148 extern struct client
*cfg_client
;
2149 extern char **cfg_files
;
2150 extern u_int cfg_nfiles
;
2151 extern int cfg_quiet
;
2152 void start_cfg(void);
2153 int load_cfg(const char *, struct client
*, struct cmdq_item
*,
2154 struct cmd_find_state
*, int, struct cmdq_item
**);
2155 int load_cfg_from_buffer(const void *, size_t, const char *,
2156 struct client
*, struct cmdq_item
*, struct cmd_find_state
*,
2157 int, struct cmdq_item
**);
2158 void printflike(1, 2) cfg_add_cause(const char *, ...);
2159 void cfg_print_causes(struct cmdq_item
*);
2160 void cfg_show_causes(struct session
*);
2163 struct paste_buffer
;
2164 const char *paste_buffer_name(struct paste_buffer
*);
2165 u_int
paste_buffer_order(struct paste_buffer
*);
2166 time_t paste_buffer_created(struct paste_buffer
*);
2167 const char *paste_buffer_data(struct paste_buffer
*, size_t *);
2168 struct paste_buffer
*paste_walk(struct paste_buffer
*);
2169 int paste_is_empty(void);
2170 struct paste_buffer
*paste_get_top(const char **);
2171 struct paste_buffer
*paste_get_name(const char *);
2172 void paste_free(struct paste_buffer
*);
2173 void paste_add(const char *, char *, size_t);
2174 int paste_rename(const char *, const char *, char **);
2175 int paste_set(char *, size_t, const char *, char **);
2176 void paste_replace(struct paste_buffer
*, char *, size_t);
2177 char *paste_make_sample(struct paste_buffer
*);
2180 #define FORMAT_STATUS 0x1
2181 #define FORMAT_FORCE 0x2
2182 #define FORMAT_NOJOBS 0x4
2183 #define FORMAT_VERBOSE 0x8
2184 #define FORMAT_NONE 0
2185 #define FORMAT_PANE 0x80000000U
2186 #define FORMAT_WINDOW 0x40000000U
2188 struct format_modifier
;
2189 typedef void *(*format_cb
)(struct format_tree
*);
2190 void format_tidy_jobs(void);
2191 const char *format_skip(const char *, const char *);
2192 int format_true(const char *);
2193 struct format_tree
*format_create(struct client
*, struct cmdq_item
*, int,
2195 void format_free(struct format_tree
*);
2196 void format_merge(struct format_tree
*, struct format_tree
*);
2197 struct window_pane
*format_get_pane(struct format_tree
*);
2198 void printflike(3, 4) format_add(struct format_tree
*, const char *,
2200 void format_add_tv(struct format_tree
*, const char *,
2202 void format_add_cb(struct format_tree
*, const char *, format_cb
);
2203 void format_log_debug(struct format_tree
*, const char *);
2204 void format_each(struct format_tree
*, void (*)(const char *,
2205 const char *, void *), void *);
2206 char *format_pretty_time(time_t, int);
2207 char *format_expand_time(struct format_tree
*, const char *);
2208 char *format_expand(struct format_tree
*, const char *);
2209 char *format_single(struct cmdq_item
*, const char *,
2210 struct client
*, struct session
*, struct winlink
*,
2211 struct window_pane
*);
2212 char *format_single_from_state(struct cmdq_item
*, const char *,
2213 struct client
*, struct cmd_find_state
*);
2214 char *format_single_from_target(struct cmdq_item
*, const char *);
2215 struct format_tree
*format_create_defaults(struct cmdq_item
*, struct client
*,
2216 struct session
*, struct winlink
*, struct window_pane
*);
2217 struct format_tree
*format_create_from_state(struct cmdq_item
*,
2218 struct client
*, struct cmd_find_state
*);
2219 struct format_tree
*format_create_from_target(struct cmdq_item
*);
2220 void format_defaults(struct format_tree
*, struct client
*,
2221 struct session
*, struct winlink
*, struct window_pane
*);
2222 void format_defaults_window(struct format_tree
*, struct window
*);
2223 void format_defaults_pane(struct format_tree
*,
2224 struct window_pane
*);
2225 void format_defaults_paste_buffer(struct format_tree
*,
2226 struct paste_buffer
*);
2227 void format_lost_client(struct client
*);
2228 char *format_grid_word(struct grid
*, u_int
, u_int
);
2229 char *format_grid_hyperlink(struct grid
*, u_int
, u_int
,
2231 char *format_grid_line(struct grid
*, u_int
);
2234 void format_draw(struct screen_write_ctx
*,
2235 const struct grid_cell
*, u_int
, const char *,
2236 struct style_ranges
*, int);
2237 u_int
format_width(const char *);
2238 char *format_trim_left(const char *, u_int
);
2239 char *format_trim_right(const char *, u_int
);
2242 void notify_hook(struct cmdq_item
*, const char *);
2243 void notify_client(const char *, struct client
*);
2244 void notify_session(const char *, struct session
*);
2245 void notify_winlink(const char *, struct winlink
*);
2246 void notify_session_window(const char *, struct session
*, struct window
*);
2247 void notify_window(const char *, struct window
*);
2248 void notify_pane(const char *, struct window_pane
*);
2249 void notify_paste_buffer(const char *, int);
2252 struct options
*options_create(struct options
*);
2253 void options_free(struct options
*);
2254 struct options
*options_get_parent(struct options
*);
2255 void options_set_parent(struct options
*, struct options
*);
2256 struct options_entry
*options_first(struct options
*);
2257 struct options_entry
*options_next(struct options_entry
*);
2258 struct options_entry
*options_empty(struct options
*,
2259 const struct options_table_entry
*);
2260 struct options_entry
*options_default(struct options
*,
2261 const struct options_table_entry
*);
2262 char *options_default_to_string(const struct options_table_entry
*);
2263 const char *options_name(struct options_entry
*);
2264 struct options
*options_owner(struct options_entry
*);
2265 const struct options_table_entry
*options_table_entry(struct options_entry
*);
2266 struct options_entry
*options_get_only(struct options
*, const char *);
2267 struct options_entry
*options_get(struct options
*, const char *);
2268 void options_array_clear(struct options_entry
*);
2269 union options_value
*options_array_get(struct options_entry
*, u_int
);
2270 int options_array_set(struct options_entry
*, u_int
, const char *,
2272 int options_array_assign(struct options_entry
*, const char *,
2274 struct options_array_item
*options_array_first(struct options_entry
*);
2275 struct options_array_item
*options_array_next(struct options_array_item
*);
2276 u_int
options_array_item_index(struct options_array_item
*);
2277 union options_value
*options_array_item_value(struct options_array_item
*);
2278 int options_is_array(struct options_entry
*);
2279 int options_is_string(struct options_entry
*);
2280 char *options_to_string(struct options_entry
*, int, int);
2281 char *options_parse(const char *, int *);
2282 struct options_entry
*options_parse_get(struct options
*, const char *, int *,
2284 char *options_match(const char *, int *, int *);
2285 struct options_entry
*options_match_get(struct options
*, const char *, int *,
2287 const char *options_get_string(struct options
*, const char *);
2288 long long options_get_number(struct options
*, const char *);
2289 struct options_entry
* printflike(4, 5) options_set_string(struct options
*,
2290 const char *, int, const char *, ...);
2291 struct options_entry
*options_set_number(struct options
*, const char *,
2293 int options_scope_from_name(struct args
*, int,
2294 const char *, struct cmd_find_state
*, struct options
**,
2296 int options_scope_from_flags(struct args
*, int,
2297 struct cmd_find_state
*, struct options
**, char **);
2298 struct style
*options_string_to_style(struct options
*, const char *,
2299 struct format_tree
*);
2300 int options_from_string(struct options
*,
2301 const struct options_table_entry
*, const char *,
2302 const char *, int, char **);
2303 int options_find_choice(const struct options_table_entry
*,
2304 const char *, char **);
2305 void options_push_changes(const char *);
2306 int options_remove_or_default(struct options_entry
*, int,
2309 /* options-table.c */
2310 extern const struct options_table_entry options_table
[];
2311 extern const struct options_name_map options_other_names
[];
2314 typedef void (*job_update_cb
) (struct job
*);
2315 typedef void (*job_complete_cb
) (struct job
*);
2316 typedef void (*job_free_cb
) (void *);
2317 #define JOB_NOWAIT 0x1
2318 #define JOB_KEEPWRITE 0x2
2320 #define JOB_DEFAULTSHELL 0x8
2321 struct job
*job_run(const char *, int, char **, struct environ
*,
2322 struct session
*, const char *, job_update_cb
,
2323 job_complete_cb
, job_free_cb
, void *, int, int, int);
2324 void job_free(struct job
*);
2325 int job_transfer(struct job
*, pid_t
*, char *, size_t);
2326 void job_resize(struct job
*, u_int
, u_int
);
2327 void job_check_died(pid_t
, int);
2328 int job_get_status(struct job
*);
2329 void *job_get_data(struct job
*);
2330 struct bufferevent
*job_get_event(struct job
*);
2331 void job_kill_all(void);
2332 int job_still_running(void);
2333 void job_print_summary(struct cmdq_item
*, int);
2336 struct environ
*environ_create(void);
2337 void environ_free(struct environ
*);
2338 struct environ_entry
*environ_first(struct environ
*);
2339 struct environ_entry
*environ_next(struct environ_entry
*);
2340 void environ_copy(struct environ
*, struct environ
*);
2341 struct environ_entry
*environ_find(struct environ
*, const char *);
2342 void printflike(4, 5) environ_set(struct environ
*, const char *, int,
2344 void environ_clear(struct environ
*, const char *);
2345 void environ_put(struct environ
*, const char *, int);
2346 void environ_unset(struct environ
*, const char *);
2347 void environ_update(struct options
*, struct environ
*, struct environ
*);
2348 void environ_push(struct environ
*);
2349 void printflike(2, 3) environ_log(struct environ
*, const char *, ...);
2350 struct environ
*environ_for_session(struct session
*, int);
2353 void tty_create_log(void);
2354 int tty_window_bigger(struct tty
*);
2355 int tty_window_offset(struct tty
*, u_int
*, u_int
*, u_int
*, u_int
*);
2356 void tty_update_window_offset(struct window
*);
2357 void tty_update_client_offset(struct client
*);
2358 void tty_raw(struct tty
*, const char *);
2359 void tty_attributes(struct tty
*, const struct grid_cell
*,
2360 const struct grid_cell
*, struct colour_palette
*,
2361 struct hyperlinks
*);
2362 void tty_reset(struct tty
*);
2363 void tty_region_off(struct tty
*);
2364 void tty_margin_off(struct tty
*);
2365 void tty_cursor(struct tty
*, u_int
, u_int
);
2366 void tty_clipboard_query(struct tty
*);
2367 void tty_putcode(struct tty
*, enum tty_code_code
);
2368 void tty_putcode_i(struct tty
*, enum tty_code_code
, int);
2369 void tty_putcode_ii(struct tty
*, enum tty_code_code
, int, int);
2370 void tty_putcode_iii(struct tty
*, enum tty_code_code
, int, int, int);
2371 void tty_putcode_s(struct tty
*, enum tty_code_code
, const char *);
2372 void tty_putcode_ss(struct tty
*, enum tty_code_code
, const char *,
2374 void tty_puts(struct tty
*, const char *);
2375 void tty_putc(struct tty
*, u_char
);
2376 void tty_putn(struct tty
*, const void *, size_t, u_int
);
2377 void tty_cell(struct tty
*, const struct grid_cell
*,
2378 const struct grid_cell
*, struct colour_palette
*,
2379 struct hyperlinks
*);
2380 int tty_init(struct tty
*, struct client
*);
2381 void tty_resize(struct tty
*);
2382 void tty_set_size(struct tty
*, u_int
, u_int
, u_int
, u_int
);
2383 void tty_invalidate(struct tty
*);
2384 void tty_start_tty(struct tty
*);
2385 void tty_send_requests(struct tty
*);
2386 void tty_repeat_requests(struct tty
*);
2387 void tty_stop_tty(struct tty
*);
2388 void tty_set_title(struct tty
*, const char *);
2389 void tty_set_path(struct tty
*, const char *);
2390 void tty_update_mode(struct tty
*, int, struct screen
*);
2391 void tty_draw_line(struct tty
*, struct screen
*, u_int
, u_int
, u_int
,
2392 u_int
, u_int
, const struct grid_cell
*, struct colour_palette
*);
2393 void tty_sync_start(struct tty
*);
2394 void tty_sync_end(struct tty
*);
2395 int tty_open(struct tty
*, char **);
2396 void tty_close(struct tty
*);
2397 void tty_free(struct tty
*);
2398 void tty_update_features(struct tty
*);
2399 void tty_set_selection(struct tty
*, const char *, const char *, size_t);
2400 void tty_write(void (*)(struct tty
*, const struct tty_ctx
*),
2402 void tty_cmd_alignmenttest(struct tty
*, const struct tty_ctx
*);
2403 void tty_cmd_cell(struct tty
*, const struct tty_ctx
*);
2404 void tty_cmd_cells(struct tty
*, const struct tty_ctx
*);
2405 void tty_cmd_clearendofline(struct tty
*, const struct tty_ctx
*);
2406 void tty_cmd_clearendofscreen(struct tty
*, const struct tty_ctx
*);
2407 void tty_cmd_clearline(struct tty
*, const struct tty_ctx
*);
2408 void tty_cmd_clearscreen(struct tty
*, const struct tty_ctx
*);
2409 void tty_cmd_clearstartofline(struct tty
*, const struct tty_ctx
*);
2410 void tty_cmd_clearstartofscreen(struct tty
*, const struct tty_ctx
*);
2411 void tty_cmd_deletecharacter(struct tty
*, const struct tty_ctx
*);
2412 void tty_cmd_clearcharacter(struct tty
*, const struct tty_ctx
*);
2413 void tty_cmd_deleteline(struct tty
*, const struct tty_ctx
*);
2414 void tty_cmd_insertcharacter(struct tty
*, const struct tty_ctx
*);
2415 void tty_cmd_insertline(struct tty
*, const struct tty_ctx
*);
2416 void tty_cmd_linefeed(struct tty
*, const struct tty_ctx
*);
2417 void tty_cmd_scrollup(struct tty
*, const struct tty_ctx
*);
2418 void tty_cmd_scrolldown(struct tty
*, const struct tty_ctx
*);
2419 void tty_cmd_reverseindex(struct tty
*, const struct tty_ctx
*);
2420 void tty_cmd_setselection(struct tty
*, const struct tty_ctx
*);
2421 void tty_cmd_rawstring(struct tty
*, const struct tty_ctx
*);
2422 void tty_cmd_syncstart(struct tty
*, const struct tty_ctx
*);
2423 void tty_default_colours(struct grid_cell
*, struct window_pane
*);
2426 extern struct tty_terms tty_terms
;
2427 u_int
tty_term_ncodes(void);
2428 void tty_term_apply(struct tty_term
*, const char *, int);
2429 void tty_term_apply_overrides(struct tty_term
*);
2430 struct tty_term
*tty_term_create(struct tty
*, char *, char **, u_int
, int *,
2432 void tty_term_free(struct tty_term
*);
2433 int tty_term_read_list(const char *, int, char ***, u_int
*,
2435 void tty_term_free_list(char **, u_int
);
2436 int tty_term_has(struct tty_term
*, enum tty_code_code
);
2437 const char *tty_term_string(struct tty_term
*, enum tty_code_code
);
2438 const char *tty_term_string_i(struct tty_term
*, enum tty_code_code
, int);
2439 const char *tty_term_string_ii(struct tty_term
*, enum tty_code_code
, int,
2441 const char *tty_term_string_iii(struct tty_term
*, enum tty_code_code
, int,
2443 const char *tty_term_string_s(struct tty_term
*, enum tty_code_code
,
2445 const char *tty_term_string_ss(struct tty_term
*, enum tty_code_code
,
2446 const char *, const char *);
2447 int tty_term_number(struct tty_term
*, enum tty_code_code
);
2448 int tty_term_flag(struct tty_term
*, enum tty_code_code
);
2449 const char *tty_term_describe(struct tty_term
*, enum tty_code_code
);
2451 /* tty-features.c */
2452 void tty_add_features(int *, const char *, const char *);
2453 const char *tty_get_features(int);
2454 int tty_apply_features(struct tty_term
*, int);
2455 void tty_default_features(int *, const char *, u_int
);
2458 int tty_acs_needed(struct tty
*);
2459 const char *tty_acs_get(struct tty
*, u_char
);
2460 int tty_acs_reverse_get(struct tty
*, const char *, size_t);
2461 const struct utf8_data
*tty_acs_double_borders(int);
2462 const struct utf8_data
*tty_acs_heavy_borders(int);
2463 const struct utf8_data
*tty_acs_rounded_borders(int);
2466 void tty_keys_build(struct tty
*);
2467 void tty_keys_free(struct tty
*);
2468 int tty_keys_next(struct tty
*);
2469 int tty_keys_colours(struct tty
*, const char *, size_t, size_t *,
2473 void args_set(struct args
*, u_char
, struct args_value
*, int);
2474 struct args
*args_create(void);
2475 struct args
*args_parse(const struct args_parse
*, struct args_value
*,
2477 struct args
*args_copy(struct args
*, int, char **);
2478 void args_to_vector(struct args
*, int *, char ***);
2479 struct args_value
*args_from_vector(int, char **);
2480 void args_free_value(struct args_value
*);
2481 void args_free_values(struct args_value
*, u_int
);
2482 void args_free(struct args
*);
2483 char *args_print(struct args
*);
2484 char *args_escape(const char *);
2485 int args_has(struct args
*, u_char
);
2486 const char *args_get(struct args
*, u_char
);
2487 u_char
args_first(struct args
*, struct args_entry
**);
2488 u_char
args_next(struct args_entry
**);
2489 u_int
args_count(struct args
*);
2490 struct args_value
*args_values(struct args
*);
2491 struct args_value
*args_value(struct args
*, u_int
);
2492 const char *args_string(struct args
*, u_int
);
2493 struct cmd_list
*args_make_commands_now(struct cmd
*, struct cmdq_item
*,
2495 struct args_command_state
*args_make_commands_prepare(struct cmd
*,
2496 struct cmdq_item
*, u_int
, const char *, int, int);
2497 struct cmd_list
*args_make_commands(struct args_command_state
*, int, char **,
2499 void args_make_commands_free(struct args_command_state
*);
2500 char *args_make_commands_get_command(struct args_command_state
*);
2501 struct args_value
*args_first_value(struct args
*, u_char
);
2502 struct args_value
*args_next_value(struct args_value
*);
2503 long long args_strtonum(struct args
*, u_char
, long long, long long,
2505 long long args_strtonum_and_expand(struct args
*, u_char
, long long,
2506 long long, struct cmdq_item
*, char **);
2507 long long args_percentage(struct args
*, u_char
, long long,
2508 long long, long long, char **);
2509 long long args_string_percentage(const char *, long long, long long,
2510 long long, char **);
2511 long long args_percentage_and_expand(struct args
*, u_char
, long long,
2512 long long, long long, struct cmdq_item
*, char **);
2513 long long args_string_percentage_and_expand(const char *, long long,
2514 long long, long long, struct cmdq_item
*, char **);
2517 int cmd_find_target(struct cmd_find_state
*, struct cmdq_item
*,
2518 const char *, enum cmd_find_type
, int);
2519 struct client
*cmd_find_best_client(struct session
*);
2520 struct client
*cmd_find_client(struct cmdq_item
*, const char *, int);
2521 void cmd_find_clear_state(struct cmd_find_state
*, int);
2522 int cmd_find_empty_state(struct cmd_find_state
*);
2523 int cmd_find_valid_state(struct cmd_find_state
*);
2524 void cmd_find_copy_state(struct cmd_find_state
*,
2525 struct cmd_find_state
*);
2526 void cmd_find_from_session(struct cmd_find_state
*,
2527 struct session
*, int);
2528 void cmd_find_from_winlink(struct cmd_find_state
*,
2529 struct winlink
*, int);
2530 int cmd_find_from_session_window(struct cmd_find_state
*,
2531 struct session
*, struct window
*, int);
2532 int cmd_find_from_window(struct cmd_find_state
*, struct window
*,
2534 void cmd_find_from_winlink_pane(struct cmd_find_state
*,
2535 struct winlink
*, struct window_pane
*, int);
2536 int cmd_find_from_pane(struct cmd_find_state
*,
2537 struct window_pane
*, int);
2538 int cmd_find_from_client(struct cmd_find_state
*, struct client
*,
2540 int cmd_find_from_mouse(struct cmd_find_state
*,
2541 struct mouse_event
*, int);
2542 int cmd_find_from_nothing(struct cmd_find_state
*, int);
2545 extern const struct cmd_entry
*cmd_table
[];
2546 void printflike(3, 4) cmd_log_argv(int, char **, const char *, ...);
2547 void cmd_prepend_argv(int *, char ***, const char *);
2548 void cmd_append_argv(int *, char ***, const char *);
2549 int cmd_pack_argv(int, char **, char *, size_t);
2550 int cmd_unpack_argv(char *, size_t, int, char ***);
2551 char **cmd_copy_argv(int, char **);
2552 void cmd_free_argv(int, char **);
2553 char *cmd_stringify_argv(int, char **);
2554 char *cmd_get_alias(const char *);
2555 const struct cmd_entry
*cmd_get_entry(struct cmd
*);
2556 struct args
*cmd_get_args(struct cmd
*);
2557 u_int
cmd_get_group(struct cmd
*);
2558 void cmd_get_source(struct cmd
*, const char **, u_int
*);
2559 struct cmd
*cmd_parse(struct args_value
*, u_int
, const char *, u_int
,
2561 struct cmd
*cmd_copy(struct cmd
*, int, char **);
2562 void cmd_free(struct cmd
*);
2563 char *cmd_print(struct cmd
*);
2564 struct cmd_list
*cmd_list_new(void);
2565 struct cmd_list
*cmd_list_copy(struct cmd_list
*, int, char **);
2566 void cmd_list_append(struct cmd_list
*, struct cmd
*);
2567 void cmd_list_append_all(struct cmd_list
*, struct cmd_list
*);
2568 void cmd_list_move(struct cmd_list
*, struct cmd_list
*);
2569 void cmd_list_free(struct cmd_list
*);
2570 char *cmd_list_print(struct cmd_list
*, int);
2571 struct cmd
*cmd_list_first(struct cmd_list
*);
2572 struct cmd
*cmd_list_next(struct cmd
*);
2573 int cmd_list_all_have(struct cmd_list
*, int);
2574 int cmd_list_any_have(struct cmd_list
*, int);
2575 int cmd_mouse_at(struct window_pane
*, struct mouse_event
*,
2576 u_int
*, u_int
*, int);
2577 struct winlink
*cmd_mouse_window(struct mouse_event
*, struct session
**);
2578 struct window_pane
*cmd_mouse_pane(struct mouse_event
*, struct session
**,
2580 char *cmd_template_replace(const char *, const char *, int);
2582 /* cmd-attach-session.c */
2583 enum cmd_retval
cmd_attach_session(struct cmdq_item
*, const char *, int, int,
2584 int, const char *, int, const char *);
2587 struct cmd_parse_result
*cmd_parse_from_file(FILE *, struct cmd_parse_input
*);
2588 struct cmd_parse_result
*cmd_parse_from_string(const char *,
2589 struct cmd_parse_input
*);
2590 enum cmd_parse_status
cmd_parse_and_insert(const char *,
2591 struct cmd_parse_input
*, struct cmdq_item
*,
2592 struct cmdq_state
*, char **);
2593 enum cmd_parse_status
cmd_parse_and_append(const char *,
2594 struct cmd_parse_input
*, struct client
*,
2595 struct cmdq_state
*, char **);
2596 struct cmd_parse_result
*cmd_parse_from_buffer(const void *, size_t,
2597 struct cmd_parse_input
*);
2598 struct cmd_parse_result
*cmd_parse_from_arguments(struct args_value
*, u_int
,
2599 struct cmd_parse_input
*);
2602 struct cmdq_state
*cmdq_new_state(struct cmd_find_state
*, struct key_event
*,
2604 struct cmdq_state
*cmdq_link_state(struct cmdq_state
*);
2605 struct cmdq_state
*cmdq_copy_state(struct cmdq_state
*,
2606 struct cmd_find_state
*);
2607 void cmdq_free_state(struct cmdq_state
*);
2608 void printflike(3, 4) cmdq_add_format(struct cmdq_state
*, const char *,
2610 void cmdq_add_formats(struct cmdq_state
*, struct format_tree
*);
2611 void cmdq_merge_formats(struct cmdq_item
*, struct format_tree
*);
2612 struct cmdq_list
*cmdq_new(void);
2613 void cmdq_free(struct cmdq_list
*);
2614 const char *cmdq_get_name(struct cmdq_item
*);
2615 struct client
*cmdq_get_client(struct cmdq_item
*);
2616 struct client
*cmdq_get_target_client(struct cmdq_item
*);
2617 struct cmdq_state
*cmdq_get_state(struct cmdq_item
*);
2618 struct cmd_find_state
*cmdq_get_target(struct cmdq_item
*);
2619 struct cmd_find_state
*cmdq_get_source(struct cmdq_item
*);
2620 struct key_event
*cmdq_get_event(struct cmdq_item
*);
2621 struct cmd_find_state
*cmdq_get_current(struct cmdq_item
*);
2622 int cmdq_get_flags(struct cmdq_item
*);
2623 struct cmdq_item
*cmdq_get_command(struct cmd_list
*, struct cmdq_state
*);
2624 #define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data)
2625 struct cmdq_item
*cmdq_get_callback1(const char *, cmdq_cb
, void *);
2626 struct cmdq_item
*cmdq_get_error(const char *);
2627 struct cmdq_item
*cmdq_insert_after(struct cmdq_item
*, struct cmdq_item
*);
2628 struct cmdq_item
*cmdq_append(struct client
*, struct cmdq_item
*);
2629 void printflike(4, 5) cmdq_insert_hook(struct session
*, struct cmdq_item
*,
2630 struct cmd_find_state
*, const char *, ...);
2631 void cmdq_continue(struct cmdq_item
*);
2632 u_int
cmdq_next(struct client
*);
2633 struct cmdq_item
*cmdq_running(struct client
*);
2634 void cmdq_guard(struct cmdq_item
*, const char *, int);
2635 void printflike(2, 3) cmdq_print(struct cmdq_item
*, const char *, ...);
2636 void cmdq_print_data(struct cmdq_item
*, int, struct evbuffer
*);
2637 void printflike(2, 3) cmdq_error(struct cmdq_item
*, const char *, ...);
2639 /* cmd-wait-for.c */
2640 void cmd_wait_for_flush(void);
2643 int client_main(struct event_base
*, int, char **, uint64_t, int);
2645 /* key-bindings.c */
2646 struct key_table
*key_bindings_get_table(const char *, int);
2647 struct key_table
*key_bindings_first_table(void);
2648 struct key_table
*key_bindings_next_table(struct key_table
*);
2649 void key_bindings_unref_table(struct key_table
*);
2650 struct key_binding
*key_bindings_get(struct key_table
*, key_code
);
2651 struct key_binding
*key_bindings_get_default(struct key_table
*, key_code
);
2652 struct key_binding
*key_bindings_first(struct key_table
*);
2653 struct key_binding
*key_bindings_next(struct key_table
*, struct key_binding
*);
2654 void key_bindings_add(const char *, key_code
, const char *, int,
2656 void key_bindings_remove(const char *, key_code
);
2657 void key_bindings_reset(const char *, key_code
);
2658 void key_bindings_remove_table(const char *);
2659 void key_bindings_reset_table(const char *);
2660 void key_bindings_init(void);
2661 struct cmdq_item
*key_bindings_dispatch(struct key_binding
*,
2662 struct cmdq_item
*, struct client
*, struct key_event
*,
2663 struct cmd_find_state
*);
2666 key_code
key_string_lookup_string(const char *);
2667 const char *key_string_lookup_key(key_code
, int);
2670 void alerts_reset_all(void);
2671 void alerts_queue(struct window
*, int);
2672 void alerts_check_session(struct session
*);
2675 int file_cmp(struct client_file
*, struct client_file
*);
2676 RB_PROTOTYPE(client_files
, client_file
, entry
, file_cmp
);
2677 struct client_file
*file_create_with_peer(struct tmuxpeer
*,
2678 struct client_files
*, int, client_file_cb
, void *);
2679 struct client_file
*file_create_with_client(struct client
*, int,
2680 client_file_cb
, void *);
2681 void file_free(struct client_file
*);
2682 void file_fire_done(struct client_file
*);
2683 void file_fire_read(struct client_file
*);
2684 int file_can_print(struct client
*);
2685 void printflike(2, 3) file_print(struct client
*, const char *, ...);
2686 void printflike(2, 0) file_vprint(struct client
*, const char *, va_list);
2687 void file_print_buffer(struct client
*, void *, size_t);
2688 void printflike(2, 3) file_error(struct client
*, const char *, ...);
2689 void file_write(struct client
*, const char *, int, const void *, size_t,
2690 client_file_cb
, void *);
2691 struct client_file
*file_read(struct client
*, const char *, client_file_cb
,
2693 void file_cancel(struct client_file
*);
2694 void file_push(struct client_file
*);
2695 int file_write_left(struct client_files
*);
2696 void file_write_open(struct client_files
*, struct tmuxpeer
*,
2697 struct imsg
*, int, int, client_file_cb
, void *);
2698 void file_write_data(struct client_files
*, struct imsg
*);
2699 void file_write_close(struct client_files
*, struct imsg
*);
2700 void file_read_open(struct client_files
*, struct tmuxpeer
*, struct imsg
*,
2701 int, int, client_file_cb
, void *);
2702 void file_write_ready(struct client_files
*, struct imsg
*);
2703 void file_read_data(struct client_files
*, struct imsg
*);
2704 void file_read_done(struct client_files
*, struct imsg
*);
2705 void file_read_cancel(struct client_files
*, struct imsg
*);
2708 extern struct tmuxproc
*server_proc
;
2709 extern struct clients clients
;
2710 extern struct cmd_find_state marked_pane
;
2711 extern struct message_list message_log
;
2712 extern time_t current_time
;
2713 void server_set_marked(struct session
*, struct winlink
*,
2714 struct window_pane
*);
2715 void server_clear_marked(void);
2716 int server_is_marked(struct session
*, struct winlink
*,
2717 struct window_pane
*);
2718 int server_check_marked(void);
2719 int server_start(struct tmuxproc
*, uint64_t, struct event_base
*, int,
2721 void server_update_socket(void);
2722 void server_add_accept(int);
2723 void printflike(1, 2) server_add_message(const char *, ...);
2724 int server_create_socket(uint64_t, char **);
2726 /* server-client.c */
2727 RB_PROTOTYPE(client_windows
, client_window
, entry
, server_client_window_cmp
);
2728 u_int
server_client_how_many(void);
2729 void server_client_set_overlay(struct client
*, u_int
, overlay_check_cb
,
2730 overlay_mode_cb
, overlay_draw_cb
, overlay_key_cb
,
2731 overlay_free_cb
, overlay_resize_cb
, void *);
2732 void server_client_clear_overlay(struct client
*);
2733 void server_client_overlay_range(u_int
, u_int
, u_int
, u_int
, u_int
, u_int
,
2734 u_int
, struct overlay_ranges
*);
2735 void server_client_set_key_table(struct client
*, const char *);
2736 const char *server_client_get_key_table(struct client
*);
2737 int server_client_check_nested(struct client
*);
2738 int server_client_handle_key(struct client
*, struct key_event
*);
2739 struct client
*server_client_create(int);
2740 int server_client_open(struct client
*, char **);
2741 void server_client_unref(struct client
*);
2742 void server_client_set_session(struct client
*, struct session
*);
2743 void server_client_lost(struct client
*);
2744 void server_client_suspend(struct client
*);
2745 void server_client_detach(struct client
*, enum msgtype
);
2746 void server_client_exec(struct client
*, const char *);
2747 void server_client_loop(void);
2748 const char *server_client_get_cwd(struct client
*, struct session
*);
2749 void server_client_set_flags(struct client
*, const char *);
2750 const char *server_client_get_flags(struct client
*);
2751 struct client_window
*server_client_get_client_window(struct client
*, u_int
);
2752 struct client_window
*server_client_add_client_window(struct client
*, u_int
);
2753 struct window_pane
*server_client_get_pane(struct client
*);
2754 void server_client_set_pane(struct client
*, struct window_pane
*);
2755 void server_client_remove_pane(struct window_pane
*);
2756 void server_client_print(struct client
*, int, struct evbuffer
*);
2759 void server_redraw_client(struct client
*);
2760 void server_status_client(struct client
*);
2761 void server_redraw_session(struct session
*);
2762 void server_redraw_session_group(struct session
*);
2763 void server_status_session(struct session
*);
2764 void server_status_session_group(struct session
*);
2765 void server_redraw_window(struct window
*);
2766 void server_redraw_window_borders(struct window
*);
2767 void server_status_window(struct window
*);
2768 void server_lock(void);
2769 void server_lock_session(struct session
*);
2770 void server_lock_client(struct client
*);
2771 void server_kill_pane(struct window_pane
*);
2772 void server_kill_window(struct window
*, int);
2773 void server_renumber_session(struct session
*);
2774 void server_renumber_all(void);
2775 int server_link_window(struct session
*,
2776 struct winlink
*, struct session
*, int, int, int, char **);
2777 void server_unlink_window(struct session
*, struct winlink
*);
2778 void server_destroy_pane(struct window_pane
*, int);
2779 void server_destroy_session(struct session
*);
2780 void server_check_unattached(void);
2781 void server_unzoom_window(struct window
*);
2784 extern char **status_prompt_hlist
[];
2785 extern u_int status_prompt_hsize
[];
2786 void status_timer_start(struct client
*);
2787 void status_timer_start_all(void);
2788 void status_update_cache(struct session
*);
2789 int status_at_line(struct client
*);
2790 u_int
status_line_size(struct client
*);
2791 struct style_range
*status_get_range(struct client
*, u_int
, u_int
);
2792 void status_init(struct client
*);
2793 void status_free(struct client
*);
2794 int status_redraw(struct client
*);
2795 void printflike(5, 6) status_message_set(struct client
*, int, int, int,
2797 void status_message_clear(struct client
*);
2798 int status_message_redraw(struct client
*);
2799 void status_prompt_set(struct client
*, struct cmd_find_state
*,
2800 const char *, const char *, prompt_input_cb
, prompt_free_cb
,
2801 void *, int, enum prompt_type
);
2802 void status_prompt_clear(struct client
*);
2803 int status_prompt_redraw(struct client
*);
2804 int status_prompt_key(struct client
*, key_code
);
2805 void status_prompt_update(struct client
*, const char *, const char *);
2806 void status_prompt_load_history(void);
2807 void status_prompt_save_history(void);
2808 const char *status_prompt_type_string(u_int
);
2809 enum prompt_type
status_prompt_type(const char *type
);
2812 void resize_window(struct window
*, u_int
, u_int
, int, int);
2813 void default_window_size(struct client
*, struct session
*, struct window
*,
2814 u_int
*, u_int
*, u_int
*, u_int
*, int);
2815 void recalculate_size(struct window
*, int);
2816 void recalculate_sizes(void);
2817 void recalculate_sizes_now(int);
2820 struct input_ctx
*input_init(struct window_pane
*, struct bufferevent
*,
2821 struct colour_palette
*);
2822 void input_free(struct input_ctx
*);
2823 void input_reset(struct input_ctx
*, int);
2824 struct evbuffer
*input_pending(struct input_ctx
*);
2825 void input_parse_pane(struct window_pane
*);
2826 void input_parse_buffer(struct window_pane
*, u_char
*, size_t);
2827 void input_parse_screen(struct input_ctx
*, struct screen
*,
2828 screen_write_init_ctx_cb
, void *, u_char
*, size_t);
2829 void input_reply_clipboard(struct bufferevent
*, const char *, size_t,
2833 void input_key_build(void);
2834 int input_key_pane(struct window_pane
*, key_code
, struct mouse_event
*);
2835 int input_key(struct screen
*, struct bufferevent
*, key_code
);
2836 int input_key_get_mouse(struct screen
*, struct mouse_event
*, u_int
,
2837 u_int
, const char **, size_t *);
2840 int colour_find_rgb(u_char
, u_char
, u_char
);
2841 int colour_join_rgb(u_char
, u_char
, u_char
);
2842 void colour_split_rgb(int, u_char
*, u_char
*, u_char
*);
2843 int colour_force_rgb(int);
2844 const char *colour_tostring(int);
2845 int colour_fromstring(const char *s
);
2846 int colour_256toRGB(int);
2847 int colour_256to16(int);
2848 int colour_byname(const char *);
2849 int colour_parseX11(const char *);
2850 void colour_palette_init(struct colour_palette
*);
2851 void colour_palette_clear(struct colour_palette
*);
2852 void colour_palette_free(struct colour_palette
*);
2853 int colour_palette_get(struct colour_palette
*, int);
2854 int colour_palette_set(struct colour_palette
*, int, int);
2855 void colour_palette_from_option(struct colour_palette
*, struct options
*);
2858 const char *attributes_tostring(int);
2859 int attributes_fromstring(const char *);
2862 extern const struct grid_cell grid_default_cell
;
2863 void grid_empty_line(struct grid
*, u_int
, u_int
);
2864 int grid_cells_equal(const struct grid_cell
*, const struct grid_cell
*);
2865 int grid_cells_look_equal(const struct grid_cell
*,
2866 const struct grid_cell
*);
2867 struct grid
*grid_create(u_int
, u_int
, u_int
);
2868 void grid_destroy(struct grid
*);
2869 int grid_compare(struct grid
*, struct grid
*);
2870 void grid_collect_history(struct grid
*);
2871 void grid_remove_history(struct grid
*, u_int
);
2872 void grid_scroll_history(struct grid
*, u_int
);
2873 void grid_scroll_history_region(struct grid
*, u_int
, u_int
, u_int
);
2874 void grid_clear_history(struct grid
*);
2875 const struct grid_line
*grid_peek_line(struct grid
*, u_int
);
2876 void grid_get_cell(struct grid
*, u_int
, u_int
, struct grid_cell
*);
2877 void grid_set_cell(struct grid
*, u_int
, u_int
, const struct grid_cell
*);
2878 void grid_set_padding(struct grid
*, u_int
, u_int
);
2879 void grid_set_cells(struct grid
*, u_int
, u_int
, const struct grid_cell
*,
2880 const char *, size_t);
2881 struct grid_line
*grid_get_line(struct grid
*, u_int
);
2882 void grid_adjust_lines(struct grid
*, u_int
);
2883 void grid_clear(struct grid
*, u_int
, u_int
, u_int
, u_int
, u_int
);
2884 void grid_clear_lines(struct grid
*, u_int
, u_int
, u_int
);
2885 void grid_move_lines(struct grid
*, u_int
, u_int
, u_int
, u_int
);
2886 void grid_move_cells(struct grid
*, u_int
, u_int
, u_int
, u_int
, u_int
);
2887 char *grid_string_cells(struct grid
*, u_int
, u_int
, u_int
,
2888 struct grid_cell
**, int, struct screen
*);
2889 void grid_duplicate_lines(struct grid
*, u_int
, struct grid
*, u_int
,
2891 void grid_reflow(struct grid
*, u_int
);
2892 void grid_wrap_position(struct grid
*, u_int
, u_int
, u_int
*, u_int
*);
2893 void grid_unwrap_position(struct grid
*, u_int
*, u_int
*, u_int
, u_int
);
2894 u_int
grid_line_length(struct grid
*, u_int
);
2897 void grid_reader_start(struct grid_reader
*, struct grid
*, u_int
, u_int
);
2898 void grid_reader_get_cursor(struct grid_reader
*, u_int
*, u_int
*);
2899 u_int
grid_reader_line_length(struct grid_reader
*);
2900 int grid_reader_in_set(struct grid_reader
*, const char *);
2901 void grid_reader_cursor_right(struct grid_reader
*, int, int);
2902 void grid_reader_cursor_left(struct grid_reader
*, int);
2903 void grid_reader_cursor_down(struct grid_reader
*);
2904 void grid_reader_cursor_up(struct grid_reader
*);
2905 void grid_reader_cursor_start_of_line(struct grid_reader
*, int);
2906 void grid_reader_cursor_end_of_line(struct grid_reader
*, int, int);
2907 void grid_reader_cursor_next_word(struct grid_reader
*, const char *);
2908 void grid_reader_cursor_next_word_end(struct grid_reader
*, const char *);
2909 void grid_reader_cursor_previous_word(struct grid_reader
*, const char *,
2911 int grid_reader_cursor_jump(struct grid_reader
*,
2912 const struct utf8_data
*);
2913 int grid_reader_cursor_jump_back(struct grid_reader
*,
2914 const struct utf8_data
*);
2915 void grid_reader_cursor_back_to_indentation(struct grid_reader
*);
2918 void grid_view_get_cell(struct grid
*, u_int
, u_int
, struct grid_cell
*);
2919 void grid_view_set_cell(struct grid
*, u_int
, u_int
,
2920 const struct grid_cell
*);
2921 void grid_view_set_padding(struct grid
*, u_int
, u_int
);
2922 void grid_view_set_cells(struct grid
*, u_int
, u_int
,
2923 const struct grid_cell
*, const char *, size_t);
2924 void grid_view_clear_history(struct grid
*, u_int
);
2925 void grid_view_clear(struct grid
*, u_int
, u_int
, u_int
, u_int
, u_int
);
2926 void grid_view_scroll_region_up(struct grid
*, u_int
, u_int
, u_int
);
2927 void grid_view_scroll_region_down(struct grid
*, u_int
, u_int
, u_int
);
2928 void grid_view_insert_lines(struct grid
*, u_int
, u_int
, u_int
);
2929 void grid_view_insert_lines_region(struct grid
*, u_int
, u_int
, u_int
,
2931 void grid_view_delete_lines(struct grid
*, u_int
, u_int
, u_int
);
2932 void grid_view_delete_lines_region(struct grid
*, u_int
, u_int
, u_int
,
2934 void grid_view_insert_cells(struct grid
*, u_int
, u_int
, u_int
, u_int
);
2935 void grid_view_delete_cells(struct grid
*, u_int
, u_int
, u_int
, u_int
);
2936 char *grid_view_string_cells(struct grid
*, u_int
, u_int
, u_int
);
2938 /* screen-write.c */
2939 void screen_write_make_list(struct screen
*);
2940 void screen_write_free_list(struct screen
*);
2941 void screen_write_start_pane(struct screen_write_ctx
*,
2942 struct window_pane
*, struct screen
*);
2943 void screen_write_start(struct screen_write_ctx
*, struct screen
*);
2944 void screen_write_start_callback(struct screen_write_ctx
*, struct screen
*,
2945 screen_write_init_ctx_cb
, void *);
2946 void screen_write_stop(struct screen_write_ctx
*);
2947 void screen_write_reset(struct screen_write_ctx
*);
2948 size_t printflike(1, 2) screen_write_strlen(const char *, ...);
2949 int printflike(7, 8) screen_write_text(struct screen_write_ctx
*, u_int
, u_int
,
2950 u_int
, int, const struct grid_cell
*, const char *, ...);
2951 void printflike(3, 4) screen_write_puts(struct screen_write_ctx
*,
2952 const struct grid_cell
*, const char *, ...);
2953 void printflike(4, 5) screen_write_nputs(struct screen_write_ctx
*,
2954 ssize_t
, const struct grid_cell
*, const char *, ...);
2955 void printflike(4, 0) screen_write_vnputs(struct screen_write_ctx
*, ssize_t
,
2956 const struct grid_cell
*, const char *, va_list);
2957 void screen_write_putc(struct screen_write_ctx
*, const struct grid_cell
*,
2959 void screen_write_fast_copy(struct screen_write_ctx
*, struct screen
*,
2960 u_int
, u_int
, u_int
, u_int
);
2961 void screen_write_hline(struct screen_write_ctx
*, u_int
, int, int,
2962 enum box_lines
, const struct grid_cell
*);
2963 void screen_write_vline(struct screen_write_ctx
*, u_int
, int, int);
2964 void screen_write_menu(struct screen_write_ctx
*, struct menu
*, int,
2965 enum box_lines
, const struct grid_cell
*, const struct grid_cell
*,
2966 const struct grid_cell
*);
2967 void screen_write_box(struct screen_write_ctx
*, u_int
, u_int
,
2968 enum box_lines
, const struct grid_cell
*, const char *);
2969 void screen_write_preview(struct screen_write_ctx
*, struct screen
*, u_int
,
2971 void screen_write_backspace(struct screen_write_ctx
*);
2972 void screen_write_mode_set(struct screen_write_ctx
*, int);
2973 void screen_write_mode_clear(struct screen_write_ctx
*, int);
2974 void screen_write_cursorup(struct screen_write_ctx
*, u_int
);
2975 void screen_write_cursordown(struct screen_write_ctx
*, u_int
);
2976 void screen_write_cursorright(struct screen_write_ctx
*, u_int
);
2977 void screen_write_cursorleft(struct screen_write_ctx
*, u_int
);
2978 void screen_write_alignmenttest(struct screen_write_ctx
*);
2979 void screen_write_insertcharacter(struct screen_write_ctx
*, u_int
, u_int
);
2980 void screen_write_deletecharacter(struct screen_write_ctx
*, u_int
, u_int
);
2981 void screen_write_clearcharacter(struct screen_write_ctx
*, u_int
, u_int
);
2982 void screen_write_insertline(struct screen_write_ctx
*, u_int
, u_int
);
2983 void screen_write_deleteline(struct screen_write_ctx
*, u_int
, u_int
);
2984 void screen_write_clearline(struct screen_write_ctx
*, u_int
);
2985 void screen_write_clearendofline(struct screen_write_ctx
*, u_int
);
2986 void screen_write_clearstartofline(struct screen_write_ctx
*, u_int
);
2987 void screen_write_cursormove(struct screen_write_ctx
*, int, int, int);
2988 void screen_write_reverseindex(struct screen_write_ctx
*, u_int
);
2989 void screen_write_scrollregion(struct screen_write_ctx
*, u_int
, u_int
);
2990 void screen_write_linefeed(struct screen_write_ctx
*, int, u_int
);
2991 void screen_write_scrollup(struct screen_write_ctx
*, u_int
, u_int
);
2992 void screen_write_scrolldown(struct screen_write_ctx
*, u_int
, u_int
);
2993 void screen_write_carriagereturn(struct screen_write_ctx
*);
2994 void screen_write_clearendofscreen(struct screen_write_ctx
*, u_int
);
2995 void screen_write_clearstartofscreen(struct screen_write_ctx
*, u_int
);
2996 void screen_write_clearscreen(struct screen_write_ctx
*, u_int
);
2997 void screen_write_clearhistory(struct screen_write_ctx
*);
2998 void screen_write_fullredraw(struct screen_write_ctx
*);
2999 void screen_write_collect_end(struct screen_write_ctx
*);
3000 void screen_write_collect_add(struct screen_write_ctx
*,
3001 const struct grid_cell
*);
3002 void screen_write_cell(struct screen_write_ctx
*, const struct grid_cell
*);
3003 void screen_write_setselection(struct screen_write_ctx
*, const char *,
3005 void screen_write_rawstring(struct screen_write_ctx
*, u_char
*, u_int
,
3007 void screen_write_alternateon(struct screen_write_ctx
*,
3008 struct grid_cell
*, int);
3009 void screen_write_alternateoff(struct screen_write_ctx
*,
3010 struct grid_cell
*, int);
3012 /* screen-redraw.c */
3013 void screen_redraw_screen(struct client
*);
3014 void screen_redraw_pane(struct client
*, struct window_pane
*);
3017 void screen_init(struct screen
*, u_int
, u_int
, u_int
);
3018 void screen_reinit(struct screen
*);
3019 void screen_free(struct screen
*);
3020 void screen_reset_tabs(struct screen
*);
3021 void screen_reset_hyperlinks(struct screen
*);
3022 void screen_set_default_cursor(struct screen
*, struct options
*);
3023 void screen_set_cursor_style(u_int
, enum screen_cursor_style
*, int *);
3024 void screen_set_cursor_colour(struct screen
*, int);
3025 int screen_set_title(struct screen
*, const char *);
3026 void screen_set_path(struct screen
*, const char *);
3027 void screen_push_title(struct screen
*);
3028 void screen_pop_title(struct screen
*);
3029 void screen_resize(struct screen
*, u_int
, u_int
, int);
3030 void screen_resize_cursor(struct screen
*, u_int
, u_int
, int, int, int);
3031 void screen_set_selection(struct screen
*, u_int
, u_int
, u_int
, u_int
,
3032 u_int
, int, struct grid_cell
*);
3033 void screen_clear_selection(struct screen
*);
3034 void screen_hide_selection(struct screen
*);
3035 int screen_check_selection(struct screen
*, u_int
, u_int
);
3036 void screen_select_cell(struct screen
*, struct grid_cell
*,
3037 const struct grid_cell
*);
3038 void screen_alternate_on(struct screen
*, struct grid_cell
*, int);
3039 void screen_alternate_off(struct screen
*, struct grid_cell
*, int);
3040 const char *screen_mode_to_string(int);
3043 extern struct windows windows
;
3044 extern struct window_pane_tree all_window_panes
;
3045 int window_cmp(struct window
*, struct window
*);
3046 RB_PROTOTYPE(windows
, window
, entry
, window_cmp
);
3047 int winlink_cmp(struct winlink
*, struct winlink
*);
3048 RB_PROTOTYPE(winlinks
, winlink
, entry
, winlink_cmp
);
3049 int window_pane_cmp(struct window_pane
*, struct window_pane
*);
3050 RB_PROTOTYPE(window_pane_tree
, window_pane
, tree_entry
, window_pane_cmp
);
3051 struct winlink
*winlink_find_by_index(struct winlinks
*, int);
3052 struct winlink
*winlink_find_by_window(struct winlinks
*, struct window
*);
3053 struct winlink
*winlink_find_by_window_id(struct winlinks
*, u_int
);
3054 u_int
winlink_count(struct winlinks
*);
3055 struct winlink
*winlink_add(struct winlinks
*, int);
3056 void winlink_set_window(struct winlink
*, struct window
*);
3057 void winlink_remove(struct winlinks
*, struct winlink
*);
3058 struct winlink
*winlink_next(struct winlink
*);
3059 struct winlink
*winlink_previous(struct winlink
*);
3060 struct winlink
*winlink_next_by_number(struct winlink
*, struct session
*,
3062 struct winlink
*winlink_previous_by_number(struct winlink
*, struct session
*,
3064 void winlink_stack_push(struct winlink_stack
*, struct winlink
*);
3065 void winlink_stack_remove(struct winlink_stack
*, struct winlink
*);
3066 struct window
*window_find_by_id_str(const char *);
3067 struct window
*window_find_by_id(u_int
);
3068 void window_update_activity(struct window
*);
3069 struct window
*window_create(u_int
, u_int
, u_int
, u_int
);
3070 void window_pane_set_event(struct window_pane
*);
3071 struct window_pane
*window_get_active_at(struct window
*, u_int
, u_int
);
3072 struct window_pane
*window_find_string(struct window
*, const char *);
3073 int window_has_pane(struct window
*, struct window_pane
*);
3074 int window_set_active_pane(struct window
*, struct window_pane
*,
3076 void window_update_focus(struct window
*);
3077 void window_pane_update_focus(struct window_pane
*);
3078 void window_redraw_active_switch(struct window
*,
3079 struct window_pane
*);
3080 struct window_pane
*window_add_pane(struct window
*, struct window_pane
*,
3082 void window_resize(struct window
*, u_int
, u_int
, int, int);
3083 void window_pane_send_resize(struct window_pane
*, u_int
, u_int
);
3084 int window_zoom(struct window_pane
*);
3085 int window_unzoom(struct window
*, int);
3086 int window_push_zoom(struct window
*, int, int);
3087 int window_pop_zoom(struct window
*);
3088 void window_lost_pane(struct window
*, struct window_pane
*);
3089 void window_remove_pane(struct window
*, struct window_pane
*);
3090 struct window_pane
*window_pane_at_index(struct window
*, u_int
);
3091 struct window_pane
*window_pane_next_by_number(struct window
*,
3092 struct window_pane
*, u_int
);
3093 struct window_pane
*window_pane_previous_by_number(struct window
*,
3094 struct window_pane
*, u_int
);
3095 int window_pane_index(struct window_pane
*, u_int
*);
3096 u_int
window_count_panes(struct window
*);
3097 void window_destroy_panes(struct window
*);
3098 struct window_pane
*window_pane_find_by_id_str(const char *);
3099 struct window_pane
*window_pane_find_by_id(u_int
);
3100 int window_pane_destroy_ready(struct window_pane
*);
3101 void window_pane_resize(struct window_pane
*, u_int
, u_int
);
3102 int window_pane_set_mode(struct window_pane
*,
3103 struct window_pane
*, const struct window_mode
*,
3104 struct cmd_find_state
*, struct args
*);
3105 void window_pane_reset_mode(struct window_pane
*);
3106 void window_pane_reset_mode_all(struct window_pane
*);
3107 int window_pane_key(struct window_pane
*, struct client
*,
3108 struct session
*, struct winlink
*, key_code
,
3109 struct mouse_event
*);
3110 void window_pane_paste(struct window_pane
*, char *, size_t);
3111 int window_pane_visible(struct window_pane
*);
3112 int window_pane_exited(struct window_pane
*);
3113 u_int
window_pane_search(struct window_pane
*, const char *, int,
3115 const char *window_printable_flags(struct winlink
*, int);
3116 struct window_pane
*window_pane_find_up(struct window_pane
*);
3117 struct window_pane
*window_pane_find_down(struct window_pane
*);
3118 struct window_pane
*window_pane_find_left(struct window_pane
*);
3119 struct window_pane
*window_pane_find_right(struct window_pane
*);
3120 void window_pane_stack_push(struct window_panes
*,
3121 struct window_pane
*);
3122 void window_pane_stack_remove(struct window_panes
*,
3123 struct window_pane
*);
3124 void window_set_name(struct window
*, const char *);
3125 void window_add_ref(struct window
*, const char *);
3126 void window_remove_ref(struct window
*, const char *);
3127 void winlink_clear_flags(struct winlink
*);
3128 int winlink_shuffle_up(struct session
*, struct winlink
*, int);
3129 int window_pane_start_input(struct window_pane
*,
3130 struct cmdq_item
*, char **);
3131 void *window_pane_get_new_data(struct window_pane
*,
3132 struct window_pane_offset
*, size_t *);
3133 void window_pane_update_used_data(struct window_pane
*,
3134 struct window_pane_offset
*, size_t);
3135 void window_set_fill_character(struct window
*);
3136 void window_pane_default_cursor(struct window_pane
*);
3137 int window_pane_mode(struct window_pane
*);
3140 u_int
layout_count_cells(struct layout_cell
*);
3141 struct layout_cell
*layout_create_cell(struct layout_cell
*);
3142 void layout_free_cell(struct layout_cell
*);
3143 void layout_print_cell(struct layout_cell
*, const char *, u_int
);
3144 void layout_destroy_cell(struct window
*, struct layout_cell
*,
3145 struct layout_cell
**);
3146 void layout_resize_layout(struct window
*, struct layout_cell
*,
3147 enum layout_type
, int, int);
3148 struct layout_cell
*layout_search_by_border(struct layout_cell
*, u_int
, u_int
);
3149 void layout_set_size(struct layout_cell
*, u_int
, u_int
, u_int
,
3151 void layout_make_leaf(struct layout_cell
*, struct window_pane
*);
3152 void layout_make_node(struct layout_cell
*, enum layout_type
);
3153 void layout_fix_offsets(struct window
*);
3154 void layout_fix_panes(struct window
*, struct window_pane
*);
3155 void layout_resize_adjust(struct window
*, struct layout_cell
*,
3156 enum layout_type
, int);
3157 void layout_init(struct window
*, struct window_pane
*);
3158 void layout_free(struct window
*);
3159 void layout_resize(struct window
*, u_int
, u_int
);
3160 void layout_resize_pane(struct window_pane
*, enum layout_type
,
3162 void layout_resize_pane_to(struct window_pane
*, enum layout_type
,
3164 void layout_assign_pane(struct layout_cell
*, struct window_pane
*,
3166 struct layout_cell
*layout_split_pane(struct window_pane
*, enum layout_type
,
3168 void layout_close_pane(struct window_pane
*);
3169 int layout_spread_cell(struct window
*, struct layout_cell
*);
3170 void layout_spread_out(struct window_pane
*);
3172 /* layout-custom.c */
3173 char *layout_dump(struct layout_cell
*);
3174 int layout_parse(struct window
*, const char *, char **);
3177 int layout_set_lookup(const char *);
3178 u_int
layout_set_select(struct window
*, u_int
);
3179 u_int
layout_set_next(struct window
*);
3180 u_int
layout_set_previous(struct window
*);
3183 typedef void (*mode_tree_build_cb
)(void *, struct mode_tree_sort_criteria
*,
3184 uint64_t *, const char *);
3185 typedef void (*mode_tree_draw_cb
)(void *, void *, struct screen_write_ctx
*,
3187 typedef int (*mode_tree_search_cb
)(void *, void *, const char *);
3188 typedef void (*mode_tree_menu_cb
)(void *, struct client
*, key_code
);
3189 typedef u_int (*mode_tree_height_cb
)(void *, u_int
);
3190 typedef key_code (*mode_tree_key_cb
)(void *, void *, u_int
);
3191 typedef void (*mode_tree_each_cb
)(void *, void *, struct client
*, key_code
);
3192 u_int
mode_tree_count_tagged(struct mode_tree_data
*);
3193 void *mode_tree_get_current(struct mode_tree_data
*);
3194 const char *mode_tree_get_current_name(struct mode_tree_data
*);
3195 void mode_tree_expand_current(struct mode_tree_data
*);
3196 void mode_tree_collapse_current(struct mode_tree_data
*);
3197 void mode_tree_expand(struct mode_tree_data
*, uint64_t);
3198 int mode_tree_set_current(struct mode_tree_data
*, uint64_t);
3199 void mode_tree_each_tagged(struct mode_tree_data
*, mode_tree_each_cb
,
3200 struct client
*, key_code
, int);
3201 void mode_tree_up(struct mode_tree_data
*, int);
3202 int mode_tree_down(struct mode_tree_data
*, int);
3203 struct mode_tree_data
*mode_tree_start(struct window_pane
*, struct args
*,
3204 mode_tree_build_cb
, mode_tree_draw_cb
, mode_tree_search_cb
,
3205 mode_tree_menu_cb
, mode_tree_height_cb
, mode_tree_key_cb
, void *,
3206 const struct menu_item
*, const char **, u_int
, struct screen
**);
3207 void mode_tree_zoom(struct mode_tree_data
*, struct args
*);
3208 void mode_tree_build(struct mode_tree_data
*);
3209 void mode_tree_free(struct mode_tree_data
*);
3210 void mode_tree_resize(struct mode_tree_data
*, u_int
, u_int
);
3211 struct mode_tree_item
*mode_tree_add(struct mode_tree_data
*,
3212 struct mode_tree_item
*, void *, uint64_t, const char *,
3214 void mode_tree_draw_as_parent(struct mode_tree_item
*);
3215 void mode_tree_no_tag(struct mode_tree_item
*);
3216 void mode_tree_remove(struct mode_tree_data
*, struct mode_tree_item
*);
3217 void mode_tree_draw(struct mode_tree_data
*);
3218 int mode_tree_key(struct mode_tree_data
*, struct client
*, key_code
*,
3219 struct mouse_event
*, u_int
*, u_int
*);
3220 void mode_tree_run_command(struct client
*, struct cmd_find_state
*,
3221 const char *, const char *);
3223 /* window-buffer.c */
3224 extern const struct window_mode window_buffer_mode
;
3227 extern const struct window_mode window_tree_mode
;
3229 /* window-clock.c */
3230 extern const struct window_mode window_clock_mode
;
3231 extern const char window_clock_table
[14][5][5];
3233 /* window-client.c */
3234 extern const struct window_mode window_client_mode
;
3237 extern const struct window_mode window_copy_mode
;
3238 extern const struct window_mode window_view_mode
;
3239 void printflike(3, 4) window_copy_add(struct window_pane
*, int, const char *,
3241 void printflike(3, 0) window_copy_vadd(struct window_pane
*, int, const char *,
3243 void window_copy_pageup(struct window_pane
*, int);
3244 void window_copy_pagedown(struct window_pane
*, int, int);
3245 void window_copy_start_drag(struct client
*, struct mouse_event
*);
3246 char *window_copy_get_word(struct window_pane
*, u_int
, u_int
);
3247 char *window_copy_get_line(struct window_pane
*, u_int
);
3249 /* window-option.c */
3250 extern const struct window_mode window_customize_mode
;
3253 void check_window_name(struct window
*);
3254 char *default_window_name(struct window
*);
3255 char *parse_window_name(const char *);
3258 void control_discard(struct client
*);
3259 void control_start(struct client
*);
3260 void control_ready(struct client
*);
3261 void control_stop(struct client
*);
3262 void control_set_pane_on(struct client
*, struct window_pane
*);
3263 void control_set_pane_off(struct client
*, struct window_pane
*);
3264 void control_continue_pane(struct client
*, struct window_pane
*);
3265 void control_pause_pane(struct client
*, struct window_pane
*);
3266 struct window_pane_offset
*control_pane_offset(struct client
*,
3267 struct window_pane
*, int *);
3268 void control_reset_offsets(struct client
*);
3269 void printflike(2, 3) control_write(struct client
*, const char *, ...);
3270 void control_write_output(struct client
*, struct window_pane
*);
3271 int control_all_done(struct client
*);
3272 void control_add_sub(struct client
*, const char *, enum control_sub_type
,
3274 void control_remove_sub(struct client
*, const char *);
3276 /* control-notify.c */
3277 void control_notify_pane_mode_changed(int);
3278 void control_notify_window_layout_changed(struct window
*);
3279 void control_notify_window_pane_changed(struct window
*);
3280 void control_notify_window_unlinked(struct session
*, struct window
*);
3281 void control_notify_window_linked(struct session
*, struct window
*);
3282 void control_notify_window_renamed(struct window
*);
3283 void control_notify_client_session_changed(struct client
*);
3284 void control_notify_client_detached(struct client
*);
3285 void control_notify_session_renamed(struct session
*);
3286 void control_notify_session_created(struct session
*);
3287 void control_notify_session_closed(struct session
*);
3288 void control_notify_session_window_changed(struct session
*);
3289 void control_notify_paste_buffer_changed(const char *);
3290 void control_notify_paste_buffer_deleted(const char *);
3293 extern struct sessions sessions
;
3294 extern u_int next_session_id
;
3295 int session_cmp(struct session
*, struct session
*);
3296 RB_PROTOTYPE(sessions
, session
, entry
, session_cmp
);
3297 int session_alive(struct session
*);
3298 struct session
*session_find(const char *);
3299 struct session
*session_find_by_id_str(const char *);
3300 struct session
*session_find_by_id(u_int
);
3301 struct session
*session_create(const char *, const char *, const char *,
3302 struct environ
*, struct options
*, struct termios
*);
3303 void session_destroy(struct session
*, int, const char *);
3304 void session_add_ref(struct session
*, const char *);
3305 void session_remove_ref(struct session
*, const char *);
3306 char *session_check_name(const char *);
3307 void session_update_activity(struct session
*, struct timeval
*);
3308 struct session
*session_next_session(struct session
*);
3309 struct session
*session_previous_session(struct session
*);
3310 struct winlink
*session_attach(struct session
*, struct window
*, int,
3312 int session_detach(struct session
*, struct winlink
*);
3313 int session_has(struct session
*, struct window
*);
3314 int session_is_linked(struct session
*, struct window
*);
3315 int session_next(struct session
*, int);
3316 int session_previous(struct session
*, int);
3317 int session_select(struct session
*, int);
3318 int session_last(struct session
*);
3319 int session_set_current(struct session
*, struct winlink
*);
3320 struct session_group
*session_group_contains(struct session
*);
3321 struct session_group
*session_group_find(const char *);
3322 struct session_group
*session_group_new(const char *);
3323 void session_group_add(struct session_group
*, struct session
*);
3324 void session_group_synchronize_to(struct session
*);
3325 void session_group_synchronize_from(struct session
*);
3326 u_int
session_group_count(struct session_group
*);
3327 u_int
session_group_attached_count(struct session_group
*);
3328 void session_renumber_windows(struct session
*);
3331 enum utf8_state
utf8_towc (const struct utf8_data
*, wchar_t *);
3332 enum utf8_state
utf8_fromwc(wchar_t wc
, struct utf8_data
*);
3333 int utf8_in_table(wchar_t, const wchar_t *, u_int
);
3334 utf8_char
utf8_build_one(u_char
);
3335 enum utf8_state
utf8_from_data(const struct utf8_data
*, utf8_char
*);
3336 void utf8_to_data(utf8_char
, struct utf8_data
*);
3337 void utf8_set(struct utf8_data
*, u_char
);
3338 void utf8_copy(struct utf8_data
*, const struct utf8_data
*);
3339 enum utf8_state
utf8_open(struct utf8_data
*, u_char
);
3340 enum utf8_state
utf8_append(struct utf8_data
*, u_char
);
3341 int utf8_isvalid(const char *);
3342 int utf8_strvis(char *, const char *, size_t, int);
3343 int utf8_stravis(char **, const char *, int);
3344 int utf8_stravisx(char **, const char *, size_t, int);
3345 char *utf8_sanitize(const char *);
3346 size_t utf8_strlen(const struct utf8_data
*);
3347 u_int
utf8_strwidth(const struct utf8_data
*, ssize_t
);
3348 struct utf8_data
*utf8_fromcstr(const char *);
3349 char *utf8_tocstr(struct utf8_data
*);
3350 u_int
utf8_cstrwidth(const char *);
3351 char *utf8_padcstr(const char *, u_int
);
3352 char *utf8_rpadcstr(const char *, u_int
);
3353 int utf8_cstrhas(const char *, const struct utf8_data
*);
3355 /* utf8-combined.c */
3356 int utf8_has_zwj(const struct utf8_data
*);
3357 int utf8_is_zwj(const struct utf8_data
*);
3358 int utf8_is_vs(const struct utf8_data
*);
3359 int utf8_is_modifier(const struct utf8_data
*);
3362 char *get_proc_name(int, char *);
3363 char *get_proc_cwd(int);
3366 void log_add_level(void);
3367 int log_get_level(void);
3368 void log_open(const char *);
3369 void log_toggle(const char *);
3370 void log_close(void);
3371 void printflike(1, 2) log_debug(const char *, ...);
3372 __dead
void printflike(1, 2) fatal(const char *, ...);
3373 __dead
void printflike(1, 2) fatalx(const char *, ...);
3376 #define MENU_NOMOUSE 0x1
3377 #define MENU_TAB 0x2
3378 #define MENU_STAYOPEN 0x4
3379 struct menu
*menu_create(const char *);
3380 void menu_add_items(struct menu
*, const struct menu_item
*,
3381 struct cmdq_item
*, struct client
*,
3382 struct cmd_find_state
*);
3383 void menu_add_item(struct menu
*, const struct menu_item
*,
3384 struct cmdq_item
*, struct client
*,
3385 struct cmd_find_state
*);
3386 void menu_free(struct menu
*);
3387 struct menu_data
*menu_prepare(struct menu
*, int, int, struct cmdq_item
*,
3388 u_int
, u_int
, struct client
*, enum box_lines
, const char *,
3389 const char *, const char *, struct cmd_find_state
*,
3390 menu_choice_cb
, void *);
3391 int menu_display(struct menu
*, int, int, struct cmdq_item
*,
3392 u_int
, u_int
, struct client
*, enum box_lines
, const char *,
3393 const char *, const char *, struct cmd_find_state
*,
3394 menu_choice_cb
, void *);
3395 struct screen
*menu_mode_cb(struct client
*, void *, u_int
*, u_int
*);
3396 void menu_check_cb(struct client
*, void *, u_int
, u_int
, u_int
,
3397 struct overlay_ranges
*);
3398 void menu_draw_cb(struct client
*, void *,
3399 struct screen_redraw_ctx
*);
3400 void menu_free_cb(struct client
*, void *);
3401 int menu_key_cb(struct client
*, void *, struct key_event
*);
3404 #define POPUP_CLOSEEXIT 0x1
3405 #define POPUP_CLOSEEXITZERO 0x2
3406 #define POPUP_INTERNAL 0x4
3407 typedef void (*popup_close_cb
)(int, void *);
3408 typedef void (*popup_finish_edit_cb
)(char *, size_t, void *);
3409 int popup_display(int, enum box_lines
, struct cmdq_item
*, u_int
,
3410 u_int
, u_int
, u_int
, struct environ
*, const char *, int,
3411 char **, const char *, const char *, struct client
*,
3412 struct session
*, const char *, const char *,
3413 popup_close_cb
, void *);
3414 int popup_editor(struct client
*, const char *, size_t,
3415 popup_finish_edit_cb
, void *);
3418 int style_parse(struct style
*,const struct grid_cell
*,
3420 const char *style_tostring(struct style
*);
3421 void style_add(struct grid_cell
*, struct options
*,
3422 const char *, struct format_tree
*);
3423 void style_apply(struct grid_cell
*, struct options
*,
3424 const char *, struct format_tree
*);
3425 void style_set(struct style
*, const struct grid_cell
*);
3426 void style_copy(struct style
*, struct style
*);
3429 struct winlink
*spawn_window(struct spawn_context
*, char **);
3430 struct window_pane
*spawn_pane(struct spawn_context
*, char **);
3433 char *regsub(const char *, const char *, const char *, int);
3436 void server_acl_init(void);
3437 struct server_acl_user
*server_acl_user_find(uid_t
);
3438 void server_acl_display(struct cmdq_item
*);
3439 void server_acl_user_allow(uid_t
);
3440 void server_acl_user_deny(uid_t
);
3441 void server_acl_user_allow_write(uid_t
);
3442 void server_acl_user_deny_write(uid_t
);
3443 int server_acl_join(struct client
*);
3444 uid_t
server_acl_get_uid(struct server_acl_user
*);
3447 u_int
hyperlinks_put(struct hyperlinks
*, const char *,
3449 int hyperlinks_get(struct hyperlinks
*, u_int
,
3450 const char **, const char **, const char **);
3451 struct hyperlinks
*hyperlinks_init(void);
3452 struct hyperlinks
*hyperlinks_copy(struct hyperlinks
*);
3453 void hyperlinks_reset(struct hyperlinks
*);
3454 void hyperlinks_free(struct hyperlinks
*);