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
82 #define TMUX_TERM "screen"
85 /* Minimum layout cell size, NOT including border lines. */
86 #define PANE_MINIMUM 1
88 /* Minimum and maximum window size. */
89 #define WINDOW_MINIMUM PANE_MINIMUM
90 #define WINDOW_MAXIMUM 10000
92 /* Automatic name refresh interval, in microseconds. Must be < 1 second. */
93 #define NAME_INTERVAL 500000
95 /* Default pixel cell sizes. */
96 #define DEFAULT_XPIXEL 16
97 #define DEFAULT_YPIXEL 32
99 /* Attribute to make GCC check printf-like arguments. */
100 #define printflike(a, b) __attribute__ ((format (printf, a, b)))
102 /* Number of items in array. */
104 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
107 /* Alert option values. */
110 #define ALERT_CURRENT 2
111 #define ALERT_OTHER 3
113 /* Visual option values. */
116 #define VISUAL_BOTH 2
118 /* No key or unknown key. */
119 #define KEYC_NONE 0x000ff000000000ULL
120 #define KEYC_UNKNOWN 0x000fe000000000ULL
123 * Base for special (that is, not Unicode) keys. An enum must be at most a
124 * signed int, so these are based in the highest Unicode PUA.
126 #define KEYC_BASE 0x0000000010e000ULL
127 #define KEYC_USER 0x0000000010f000ULL
129 /* Key modifier bits. */
130 #define KEYC_META 0x00100000000000ULL
131 #define KEYC_CTRL 0x00200000000000ULL
132 #define KEYC_SHIFT 0x00400000000000ULL
135 #define KEYC_LITERAL 0x01000000000000ULL
136 #define KEYC_KEYPAD 0x02000000000000ULL
137 #define KEYC_CURSOR 0x04000000000000ULL
138 #define KEYC_IMPLIED_META 0x08000000000000ULL
139 #define KEYC_BUILD_MODIFIERS 0x10000000000000ULL
140 #define KEYC_VI 0x20000000000000ULL
141 #define KEYC_SENT 0x40000000000000ULL
143 /* Masks for key bits. */
144 #define KEYC_MASK_MODIFIERS 0x00f00000000000ULL
145 #define KEYC_MASK_FLAGS 0xff000000000000ULL
146 #define KEYC_MASK_KEY 0x000fffffffffffULL
148 /* Available user keys. */
149 #define KEYC_NUSER 1000
151 /* Is this a mouse key? */
152 #define KEYC_IS_MOUSE(key) \
153 (((key) & KEYC_MASK_KEY) >= KEYC_MOUSE && \
154 ((key) & KEYC_MASK_KEY) < KEYC_BSPACE)
156 /* Is this a Unicode key? */
157 #define KEYC_IS_UNICODE(key) \
158 (((key) & KEYC_MASK_KEY) > 0x7f && \
159 (((key) & KEYC_MASK_KEY) < KEYC_BASE || \
160 ((key) & KEYC_MASK_KEY) >= KEYC_BASE_END) && \
161 (((key) & KEYC_MASK_KEY) < KEYC_USER || \
162 ((key) & KEYC_MASK_KEY) >= KEYC_USER + KEYC_NUSER))
164 /* Multiple click timeout. */
165 #define KEYC_CLICK_TIMEOUT 300
167 /* Mouse key codes. */
168 #define KEYC_MOUSE_KEY(name) \
169 KEYC_ ## name ## _PANE, \
170 KEYC_ ## name ## _STATUS, \
171 KEYC_ ## name ## _STATUS_LEFT, \
172 KEYC_ ## name ## _STATUS_RIGHT, \
173 KEYC_ ## name ## _STATUS_DEFAULT, \
174 KEYC_ ## name ## _BORDER
175 #define KEYC_MOUSE_STRING(name, s) \
176 { #s "Pane", KEYC_ ## name ## _PANE }, \
177 { #s "Status", KEYC_ ## name ## _STATUS }, \
178 { #s "StatusLeft", KEYC_ ## name ## _STATUS_LEFT }, \
179 { #s "StatusRight", KEYC_ ## name ## _STATUS_RIGHT }, \
180 { #s "StatusDefault", KEYC_ ## name ## _STATUS_DEFAULT }, \
181 { #s "Border", KEYC_ ## name ## _BORDER }
184 * A single key. This can be ASCII or Unicode or one of the keys between
185 * KEYC_BASE and KEYC_BASE_END.
187 typedef unsigned long long key_code
;
189 /* C0 control characters */
225 /* Special key codes. */
228 KEYC_FOCUS_IN
= KEYC_BASE
,
231 /* "Any" key, used if not found in key table. */
234 /* Paste brackets. */
239 KEYC_MOUSE
, /* unclassified mouse event */
240 KEYC_DRAGGING
, /* dragging in progress */
241 KEYC_DOUBLECLICK
, /* double click complete */
242 KEYC_MOUSE_KEY(MOUSEMOVE
),
243 KEYC_MOUSE_KEY(MOUSEDOWN1
),
244 KEYC_MOUSE_KEY(MOUSEDOWN2
),
245 KEYC_MOUSE_KEY(MOUSEDOWN3
),
246 KEYC_MOUSE_KEY(MOUSEDOWN6
),
247 KEYC_MOUSE_KEY(MOUSEDOWN7
),
248 KEYC_MOUSE_KEY(MOUSEDOWN8
),
249 KEYC_MOUSE_KEY(MOUSEDOWN9
),
250 KEYC_MOUSE_KEY(MOUSEDOWN10
),
251 KEYC_MOUSE_KEY(MOUSEDOWN11
),
252 KEYC_MOUSE_KEY(MOUSEUP1
),
253 KEYC_MOUSE_KEY(MOUSEUP2
),
254 KEYC_MOUSE_KEY(MOUSEUP3
),
255 KEYC_MOUSE_KEY(MOUSEUP6
),
256 KEYC_MOUSE_KEY(MOUSEUP7
),
257 KEYC_MOUSE_KEY(MOUSEUP8
),
258 KEYC_MOUSE_KEY(MOUSEUP9
),
259 KEYC_MOUSE_KEY(MOUSEUP10
),
260 KEYC_MOUSE_KEY(MOUSEUP11
),
261 KEYC_MOUSE_KEY(MOUSEDRAG1
),
262 KEYC_MOUSE_KEY(MOUSEDRAG2
),
263 KEYC_MOUSE_KEY(MOUSEDRAG3
),
264 KEYC_MOUSE_KEY(MOUSEDRAG6
),
265 KEYC_MOUSE_KEY(MOUSEDRAG7
),
266 KEYC_MOUSE_KEY(MOUSEDRAG8
),
267 KEYC_MOUSE_KEY(MOUSEDRAG9
),
268 KEYC_MOUSE_KEY(MOUSEDRAG10
),
269 KEYC_MOUSE_KEY(MOUSEDRAG11
),
270 KEYC_MOUSE_KEY(MOUSEDRAGEND1
),
271 KEYC_MOUSE_KEY(MOUSEDRAGEND2
),
272 KEYC_MOUSE_KEY(MOUSEDRAGEND3
),
273 KEYC_MOUSE_KEY(MOUSEDRAGEND6
),
274 KEYC_MOUSE_KEY(MOUSEDRAGEND7
),
275 KEYC_MOUSE_KEY(MOUSEDRAGEND8
),
276 KEYC_MOUSE_KEY(MOUSEDRAGEND9
),
277 KEYC_MOUSE_KEY(MOUSEDRAGEND10
),
278 KEYC_MOUSE_KEY(MOUSEDRAGEND11
),
279 KEYC_MOUSE_KEY(WHEELUP
),
280 KEYC_MOUSE_KEY(WHEELDOWN
),
281 KEYC_MOUSE_KEY(SECONDCLICK1
),
282 KEYC_MOUSE_KEY(SECONDCLICK2
),
283 KEYC_MOUSE_KEY(SECONDCLICK3
),
284 KEYC_MOUSE_KEY(SECONDCLICK6
),
285 KEYC_MOUSE_KEY(SECONDCLICK7
),
286 KEYC_MOUSE_KEY(SECONDCLICK8
),
287 KEYC_MOUSE_KEY(SECONDCLICK9
),
288 KEYC_MOUSE_KEY(SECONDCLICK10
),
289 KEYC_MOUSE_KEY(SECONDCLICK11
),
290 KEYC_MOUSE_KEY(DOUBLECLICK1
),
291 KEYC_MOUSE_KEY(DOUBLECLICK2
),
292 KEYC_MOUSE_KEY(DOUBLECLICK3
),
293 KEYC_MOUSE_KEY(DOUBLECLICK6
),
294 KEYC_MOUSE_KEY(DOUBLECLICK7
),
295 KEYC_MOUSE_KEY(DOUBLECLICK8
),
296 KEYC_MOUSE_KEY(DOUBLECLICK9
),
297 KEYC_MOUSE_KEY(DOUBLECLICK10
),
298 KEYC_MOUSE_KEY(DOUBLECLICK11
),
299 KEYC_MOUSE_KEY(TRIPLECLICK1
),
300 KEYC_MOUSE_KEY(TRIPLECLICK2
),
301 KEYC_MOUSE_KEY(TRIPLECLICK3
),
302 KEYC_MOUSE_KEY(TRIPLECLICK6
),
303 KEYC_MOUSE_KEY(TRIPLECLICK7
),
304 KEYC_MOUSE_KEY(TRIPLECLICK8
),
305 KEYC_MOUSE_KEY(TRIPLECLICK9
),
306 KEYC_MOUSE_KEY(TRIPLECLICK10
),
307 KEYC_MOUSE_KEY(TRIPLECLICK11
),
339 /* Numeric keypad. */
357 /* End of special keys. */
597 /* Character classes. */
598 #define WHITESPACE " "
601 #define MODEKEY_EMACS 0
605 #define MODE_CURSOR 0x1
606 #define MODE_INSERT 0x2
607 #define MODE_KCURSOR 0x4
608 #define MODE_KKEYPAD 0x8
609 #define MODE_WRAP 0x10
610 #define MODE_MOUSE_STANDARD 0x20
611 #define MODE_MOUSE_BUTTON 0x40
612 #define MODE_CURSOR_BLINKING 0x80
613 #define MODE_MOUSE_UTF8 0x100
614 #define MODE_MOUSE_SGR 0x200
615 #define MODE_BRACKETPASTE 0x400
616 #define MODE_FOCUSON 0x800
617 #define MODE_MOUSE_ALL 0x1000
618 #define MODE_ORIGIN 0x2000
619 #define MODE_CRLF 0x4000
620 #define MODE_KEYS_EXTENDED 0x8000
621 #define MODE_CURSOR_VERY_VISIBLE 0x10000
622 #define MODE_CURSOR_BLINKING_SET 0x20000
623 #define MODE_KEYS_EXTENDED_2 0x40000
625 #define ALL_MODES 0xffffff
626 #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
627 #define MOTION_MOUSE_MODES (MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
628 #define CURSOR_MODES (MODE_CURSOR|MODE_CURSOR_BLINKING|MODE_CURSOR_VERY_VISIBLE)
629 #define EXTENDED_KEY_MODES (MODE_KEYS_EXTENDED|MODE_KEYS_EXTENDED_2)
631 /* Mouse protocol constants. */
632 #define MOUSE_PARAM_MAX 0xff
633 #define MOUSE_PARAM_UTF8_MAX 0x7ff
634 #define MOUSE_PARAM_BTN_OFF 0x20
635 #define MOUSE_PARAM_POS_OFF 0x21
637 /* A single UTF-8 character. */
638 typedef u_int utf8_char
;
641 * An expanded UTF-8 character. UTF8_SIZE must be big enough to hold combining
642 * characters as well. It can't be more than 32 bytes without changes to how
643 * characters are stored.
647 u_char data
[UTF8_SIZE
];
652 u_char width
; /* 0xff if invalid */
661 #define COLOUR_FLAG_256 0x01000000
662 #define COLOUR_FLAG_RGB 0x02000000
664 /* Special colours. */
665 #define COLOUR_DEFAULT(c) ((c) == 8 || (c) == 9)
667 /* Replacement palette. */
668 struct colour_palette
{
673 int *default_palette
;
676 /* Grid attributes. Anything above 0xff is stored in an extended cell. */
677 #define GRID_ATTR_BRIGHT 0x1
678 #define GRID_ATTR_DIM 0x2
679 #define GRID_ATTR_UNDERSCORE 0x4
680 #define GRID_ATTR_BLINK 0x8
681 #define GRID_ATTR_REVERSE 0x10
682 #define GRID_ATTR_HIDDEN 0x20
683 #define GRID_ATTR_ITALICS 0x40
684 #define GRID_ATTR_CHARSET 0x80 /* alternative character set */
685 #define GRID_ATTR_STRIKETHROUGH 0x100
686 #define GRID_ATTR_UNDERSCORE_2 0x200
687 #define GRID_ATTR_UNDERSCORE_3 0x400
688 #define GRID_ATTR_UNDERSCORE_4 0x800
689 #define GRID_ATTR_UNDERSCORE_5 0x1000
690 #define GRID_ATTR_OVERLINE 0x2000
692 /* All underscore attributes. */
693 #define GRID_ATTR_ALL_UNDERSCORE \
694 (GRID_ATTR_UNDERSCORE| \
695 GRID_ATTR_UNDERSCORE_2| \
696 GRID_ATTR_UNDERSCORE_3| \
697 GRID_ATTR_UNDERSCORE_4| \
698 GRID_ATTR_UNDERSCORE_5)
701 #define GRID_FLAG_FG256 0x1
702 #define GRID_FLAG_BG256 0x2
703 #define GRID_FLAG_PADDING 0x4
704 #define GRID_FLAG_EXTENDED 0x8
705 #define GRID_FLAG_SELECTED 0x10
706 #define GRID_FLAG_NOPALETTE 0x20
707 #define GRID_FLAG_CLEARED 0x40
709 /* Grid line flags. */
710 #define GRID_LINE_WRAPPED 0x1
711 #define GRID_LINE_EXTENDED 0x2
712 #define GRID_LINE_DEAD 0x4
713 #define GRID_LINE_START_PROMPT 0x8
714 #define GRID_LINE_START_OUTPUT 0x10
716 /* Grid string flags. */
717 #define GRID_STRING_WITH_SEQUENCES 0x1
718 #define GRID_STRING_ESCAPE_SEQUENCES 0x2
719 #define GRID_STRING_TRIM_SPACES 0x4
720 #define GRID_STRING_USED_ONLY 0x8
721 #define GRID_STRING_EMPTY_CELLS 0x10
723 /* Cell positions. */
724 #define CELL_INSIDE 0
725 #define CELL_TOPBOTTOM 1
726 #define CELL_LEFTRIGHT 2
727 #define CELL_TOPLEFT 3
728 #define CELL_TOPRIGHT 4
729 #define CELL_BOTTOMLEFT 5
730 #define CELL_BOTTOMRIGHT 6
731 #define CELL_TOPJOIN 7
732 #define CELL_BOTTOMJOIN 8
733 #define CELL_LEFTJOIN 9
734 #define CELL_RIGHTJOIN 10
736 #define CELL_OUTSIDE 12
739 #define CELL_BORDERS " xqlkmjwvtun~"
740 #define SIMPLE_BORDERS " |-+++++++++."
741 #define PADDED_BORDERS " "
743 /* Grid cell data. */
745 struct utf8_data data
;
754 /* Grid extended cell entry. */
755 struct grid_extd_entry
{
765 /* Grid cell entry. */
766 struct grid_cell_entry
{
781 struct grid_cell_entry
*celldata
;
785 struct grid_extd_entry
*extddata
;
792 /* Entire grid of cells. */
795 #define GRID_HISTORY 0x1 /* scroll lines into history */
804 struct grid_line
*linedata
;
807 /* Virtual cursor in a grid. */
814 /* Style alignment. */
820 STYLE_ALIGN_ABSOLUTE_CENTRE
828 STYLE_LIST_LEFT_MARKER
,
829 STYLE_LIST_RIGHT_MARKER
,
833 enum style_range_type
{
843 enum style_range_type type
;
848 u_int end
; /* not included */
850 TAILQ_ENTRY(style_range
) entry
;
852 TAILQ_HEAD(style_ranges
, style_range
);
855 enum style_default_type
{
867 enum style_align align
;
868 enum style_list list
;
870 enum style_range_type range_type
;
871 u_int range_argument
;
872 char range_string
[16];
874 enum style_default_type default_type
;
878 enum screen_cursor_style
{
879 SCREEN_CURSOR_DEFAULT
,
881 SCREEN_CURSOR_UNDERLINE
,
885 /* Virtual screen. */
887 struct screen_titles
;
891 struct screen_titles
*titles
;
893 struct grid
*grid
; /* grid data */
895 u_int cx
; /* cursor x */
896 u_int cy
; /* cursor y */
898 enum screen_cursor_style cstyle
; /* cursor style */
899 enum screen_cursor_style default_cstyle
;
900 int ccolour
; /* cursor colour */
903 u_int rupper
; /* scroll region top */
904 u_int rlower
; /* scroll region bottom */
911 struct grid
*saved_grid
;
912 struct grid_cell saved_cell
;
916 struct screen_sel
*sel
;
918 struct screen_write_cline
*write_list
;
920 struct hyperlinks
*hyperlinks
;
923 /* Screen write context. */
924 typedef void (*screen_write_init_ctx_cb
)(struct screen_write_ctx
*,
926 struct screen_write_ctx
{
927 struct window_pane
*wp
;
931 #define SCREEN_WRITE_SYNC 0x1
933 screen_write_init_ctx_cb init_ctx_cb
;
936 struct screen_write_citem
*item
;
941 /* Box border lines option. */
943 BOX_LINES_DEFAULT
= -1,
953 /* Pane border lines option. */
962 /* Pane border indicator option. */
963 #define PANE_BORDER_OFF 0
964 #define PANE_BORDER_COLOUR 1
965 #define PANE_BORDER_ARROWS 2
966 #define PANE_BORDER_BOTH 3
968 /* Screen redraw context. */
969 struct screen_redraw_ctx
{
976 enum pane_lines pane_lines
;
978 struct grid_cell no_pane_gc
;
988 #define screen_size_x(s) ((s)->grid->sx)
989 #define screen_size_y(s) ((s)->grid->sy)
990 #define screen_hsize(s) ((s)->grid->hsize)
991 #define screen_hlimit(s) ((s)->grid->hlimit)
1001 struct menu_item
*items
;
1005 typedef void (*menu_choice_cb
)(struct menu
*, u_int
, key_code
, void *);
1008 * Window mode. Windows can be in several modes and this is used to call the
1009 * right function to handle input and output.
1011 struct window_mode_entry
;
1012 struct window_mode
{
1014 const char *default_format
;
1016 struct screen
*(*init
)(struct window_mode_entry
*,
1017 struct cmd_find_state
*, struct args
*);
1018 void (*free
)(struct window_mode_entry
*);
1019 void (*resize
)(struct window_mode_entry
*, u_int
, u_int
);
1020 void (*update
)(struct window_mode_entry
*);
1021 void (*key
)(struct window_mode_entry
*, struct client
*,
1022 struct session
*, struct winlink
*, key_code
,
1023 struct mouse_event
*);
1025 const char *(*key_table
)(struct window_mode_entry
*);
1026 void (*command
)(struct window_mode_entry
*, struct client
*,
1027 struct session
*, struct winlink
*, struct args
*,
1028 struct mouse_event
*);
1029 void (*formats
)(struct window_mode_entry
*,
1030 struct format_tree
*);
1033 /* Active window mode. */
1034 struct window_mode_entry
{
1035 struct window_pane
*wp
;
1036 struct window_pane
*swp
;
1038 const struct window_mode
*mode
;
1041 struct screen
*screen
;
1044 TAILQ_ENTRY(window_mode_entry
) entry
;
1047 /* Offsets into pane buffer. */
1048 struct window_pane_offset
{
1052 /* Queued pane resize. */
1053 struct window_pane_resize
{
1060 TAILQ_ENTRY(window_pane_resize
) entry
;
1062 TAILQ_HEAD(window_pane_resizes
, window_pane_resize
);
1064 /* Child window structure. */
1065 struct window_pane
{
1069 struct window
*window
;
1070 struct options
*options
;
1072 struct layout_cell
*layout_cell
;
1073 struct layout_cell
*saved_layout_cell
;
1082 #define PANE_REDRAW 0x1
1083 #define PANE_DROP 0x2
1084 #define PANE_FOCUSED 0x4
1085 #define PANE_VISITED 0x8
1088 #define PANE_INPUTOFF 0x40
1089 #define PANE_CHANGED 0x80
1090 #define PANE_EXITED 0x100
1091 #define PANE_STATUSREADY 0x200
1092 #define PANE_STATUSDRAWN 0x400
1093 #define PANE_EMPTY 0x800
1094 #define PANE_STYLECHANGED 0x1000
1095 #define PANE_UNSEENCHANGES 0x2000
1103 char tty
[TTY_NAME_MAX
];
1105 struct timeval dead_time
;
1108 struct bufferevent
*event
;
1110 struct window_pane_offset offset
;
1113 struct window_pane_resizes resize_queue
;
1114 struct event resize_timer
;
1116 struct input_ctx
*ictx
;
1118 struct grid_cell cached_gc
;
1119 struct grid_cell cached_active_gc
;
1120 struct colour_palette palette
;
1123 struct bufferevent
*pipe_event
;
1124 struct window_pane_offset pipe_offset
;
1126 struct screen
*screen
;
1129 struct screen status_screen
;
1132 TAILQ_HEAD(, window_mode_entry
) modes
;
1138 struct grid_cell border_gc
;
1143 TAILQ_ENTRY(window_pane
) entry
; /* link in list of all panes */
1144 TAILQ_ENTRY(window_pane
) sentry
; /* link in list of last visited */
1145 RB_ENTRY(window_pane
) tree_entry
;
1147 TAILQ_HEAD(window_panes
, window_pane
);
1148 RB_HEAD(window_pane_tree
, window_pane
);
1150 /* Window structure. */
1156 struct event name_event
;
1157 struct timeval name_time
;
1159 struct event alerts_timer
;
1160 struct event offset_timer
;
1162 struct timeval activity_time
;
1164 struct window_pane
*active
;
1165 struct window_panes last_panes
;
1166 struct window_panes panes
;
1169 struct layout_cell
*layout_root
;
1170 struct layout_cell
*saved_layout_root
;
1185 struct utf8_data
*fill_character
;
1187 #define WINDOW_BELL 0x1
1188 #define WINDOW_ACTIVITY 0x2
1189 #define WINDOW_SILENCE 0x4
1190 #define WINDOW_ZOOMED 0x8
1191 #define WINDOW_WASZOOMED 0x10
1192 #define WINDOW_RESIZE 0x20
1193 #define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
1196 TAILQ_ENTRY(window
) alerts_entry
;
1198 struct options
*options
;
1201 TAILQ_HEAD(, winlink
) winlinks
;
1203 RB_ENTRY(window
) entry
;
1205 RB_HEAD(windows
, window
);
1207 /* Entry on local window list. */
1210 struct session
*session
;
1211 struct window
*window
;
1214 #define WINLINK_BELL 0x1
1215 #define WINLINK_ACTIVITY 0x2
1216 #define WINLINK_SILENCE 0x4
1217 #define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_SILENCE)
1218 #define WINLINK_VISITED 0x8
1220 RB_ENTRY(winlink
) entry
;
1221 TAILQ_ENTRY(winlink
) wentry
;
1222 TAILQ_ENTRY(winlink
) sentry
;
1224 RB_HEAD(winlinks
, winlink
);
1225 TAILQ_HEAD(winlink_stack
, winlink
);
1227 /* Window size option. */
1228 #define WINDOW_SIZE_LARGEST 0
1229 #define WINDOW_SIZE_SMALLEST 1
1230 #define WINDOW_SIZE_MANUAL 2
1231 #define WINDOW_SIZE_LATEST 3
1233 /* Pane border status option. */
1234 #define PANE_STATUS_OFF 0
1235 #define PANE_STATUS_TOP 1
1236 #define PANE_STATUS_BOTTOM 2
1238 /* Layout direction. */
1245 /* Layout cells queue. */
1246 TAILQ_HEAD(layout_cells
, layout_cell
);
1249 struct layout_cell
{
1250 enum layout_type type
;
1252 struct layout_cell
*parent
;
1260 struct window_pane
*wp
;
1261 struct layout_cells cells
;
1263 TAILQ_ENTRY(layout_cell
) entry
;
1266 /* Environment variable. */
1267 struct environ_entry
{
1272 #define ENVIRON_HIDDEN 0x1
1274 RB_ENTRY(environ_entry
) entry
;
1277 /* Client session. */
1278 struct session_group
{
1280 TAILQ_HEAD(, session
) sessions
;
1282 RB_ENTRY(session_group
) entry
;
1284 RB_HEAD(session_groups
, session_group
);
1292 struct timeval creation_time
;
1293 struct timeval last_attached_time
;
1294 struct timeval activity_time
;
1295 struct timeval last_activity_time
;
1297 struct event lock_timer
;
1299 struct winlink
*curw
;
1300 struct winlink_stack lastw
;
1301 struct winlinks windows
;
1306 struct options
*options
;
1308 #define SESSION_PASTING 0x1
1309 #define SESSION_ALERTED 0x2
1314 struct termios
*tio
;
1316 struct environ
*environ
;
1320 TAILQ_ENTRY(session
) gentry
;
1321 RB_ENTRY(session
) entry
;
1323 RB_HEAD(sessions
, session
);
1325 /* Mouse button masks. */
1326 #define MOUSE_MASK_BUTTONS 195
1327 #define MOUSE_MASK_SHIFT 4
1328 #define MOUSE_MASK_META 8
1329 #define MOUSE_MASK_CTRL 16
1330 #define MOUSE_MASK_DRAG 32
1331 #define MOUSE_MASK_MODIFIERS (MOUSE_MASK_SHIFT|MOUSE_MASK_META|MOUSE_MASK_CTRL)
1333 /* Mouse wheel type. */
1334 #define MOUSE_WHEEL_UP 64
1335 #define MOUSE_WHEEL_DOWN 65
1337 /* Mouse button type. */
1338 #define MOUSE_BUTTON_1 0
1339 #define MOUSE_BUTTON_2 1
1340 #define MOUSE_BUTTON_3 2
1341 #define MOUSE_BUTTON_6 66
1342 #define MOUSE_BUTTON_7 67
1343 #define MOUSE_BUTTON_8 128
1344 #define MOUSE_BUTTON_9 129
1345 #define MOUSE_BUTTON_10 130
1346 #define MOUSE_BUTTON_11 131
1348 /* Mouse helpers. */
1349 #define MOUSE_BUTTONS(b) ((b) & MOUSE_MASK_BUTTONS)
1350 #define MOUSE_WHEEL(b) \
1351 (((b) & MOUSE_MASK_BUTTONS) == MOUSE_WHEEL_UP || \
1352 ((b) & MOUSE_MASK_BUTTONS) == MOUSE_WHEEL_DOWN)
1353 #define MOUSE_DRAG(b) ((b) & MOUSE_MASK_DRAG)
1354 #define MOUSE_RELEASE(b) (((b) & MOUSE_MASK_BUTTONS) == 3)
1357 struct mouse_event
{
1388 struct mouse_event m
;
1391 /* Terminal definition. */
1397 char acs
[UCHAR_MAX
+ 1][2];
1399 struct tty_code
*codes
;
1401 #define TERM_256COLOURS 0x1
1402 #define TERM_NOAM 0x2
1403 #define TERM_DECSLRM 0x4
1404 #define TERM_DECFRA 0x8
1405 #define TERM_RGBCOLOURS 0x10
1406 #define TERM_VT100LIKE 0x20
1407 #define TERM_SIXEL 0x40
1410 LIST_ENTRY(tty_term
) entry
;
1412 LIST_HEAD(tty_terms
, tty_term
);
1414 /* Client terminal. */
1416 struct client
*client
;
1417 struct event start_timer
;
1418 struct event clipboard_timer
;
1419 time_t last_requests
;
1428 enum screen_cursor_style cstyle
;
1447 struct event event_in
;
1448 struct evbuffer
*in
;
1449 struct event event_out
;
1450 struct evbuffer
*out
;
1456 struct grid_cell cell
;
1457 struct grid_cell last_cell
;
1459 #define TTY_NOCURSOR 0x1
1460 #define TTY_FREEZE 0x2
1461 #define TTY_TIMER 0x4
1462 #define TTY_NOBLOCK 0x8
1463 #define TTY_STARTED 0x10
1464 #define TTY_OPENED 0x20
1465 #define TTY_OSC52QUERY 0x40
1466 #define TTY_BLOCK 0x80
1467 #define TTY_HAVEDA 0x100 /* Primary DA. */
1468 #define TTY_HAVEXDA 0x200
1469 #define TTY_SYNCING 0x400
1470 #define TTY_HAVEDA2 0x800 /* Secondary DA. */
1471 #define TTY_ALL_REQUEST_FLAGS \
1472 (TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA)
1475 struct tty_term
*term
;
1480 int mouse_drag_flag
;
1481 void (*mouse_drag_update
)(struct client
*,
1482 struct mouse_event
*);
1483 void (*mouse_drag_release
)(struct client
*,
1484 struct mouse_event
*);
1486 struct event key_timer
;
1487 struct tty_key
*key_tree
;
1490 /* Terminal command context. */
1491 typedef void (*tty_ctx_redraw_cb
)(const struct tty_ctx
*);
1492 typedef int (*tty_ctx_set_client_cb
)(struct tty_ctx
*, struct client
*);
1496 tty_ctx_redraw_cb redraw_cb
;
1497 tty_ctx_set_client_cb set_client_cb
;
1500 const struct grid_cell
*cell
;
1508 * Whether this command should be sent even when the pane is not
1509 * visible (used for a passthrough sequence when allow-passthrough is
1512 int allow_invisible_panes
;
1515 * Cursor and region position before the screen was updated - this is
1516 * where the command should be applied; the values in the screen have
1517 * already been updated.
1525 /* Target region (usually pane) offset and size. */
1533 /* The background colour used for clearing (erasing). */
1536 /* The default colours and palette. */
1537 struct grid_cell defaults
;
1538 struct colour_palette
*palette
;
1540 /* Containing region (usually window) offset and size. */
1548 /* Saved message entry. */
1549 struct message_entry
{
1552 struct timeval msg_time
;
1554 TAILQ_ENTRY(message_entry
) entry
;
1556 TAILQ_HEAD(message_list
, message_entry
);
1558 /* Argument type. */
1565 /* Argument value. */
1567 enum args_type type
;
1570 struct cmd_list
*cmdlist
;
1573 TAILQ_ENTRY(args_value
) entry
;
1576 /* Arguments set. */
1578 RB_HEAD(args_tree
, args_entry
);
1580 /* Arguments parsing type. */
1581 enum args_parse_type
{
1584 ARGS_PARSE_COMMANDS_OR_STRING
,
1588 /* Arguments parsing state. */
1589 typedef enum args_parse_type (*args_parse_cb
)(struct args
*, u_int
, char **);
1591 const char *template;
1597 /* Command find structures. */
1598 enum cmd_find_type
{
1603 struct cmd_find_state
{
1605 struct cmd_find_state
*current
;
1610 struct window_pane
*wp
;
1614 /* Command find flags. */
1615 #define CMD_FIND_PREFER_UNATTACHED 0x1
1616 #define CMD_FIND_QUIET 0x2
1617 #define CMD_FIND_WINDOW_INDEX 0x4
1618 #define CMD_FIND_DEFAULT_MARKED 0x8
1619 #define CMD_FIND_EXACT_SESSION 0x10
1620 #define CMD_FIND_EXACT_WINDOW 0x20
1621 #define CMD_FIND_CANFAIL 0x40
1623 /* List of commands. */
1630 /* Command return values. */
1632 CMD_RETURN_ERROR
= -1,
1633 CMD_RETURN_NORMAL
= 0,
1638 /* Command parse result. */
1639 enum cmd_parse_status
{
1643 struct cmd_parse_result
{
1644 enum cmd_parse_status status
;
1645 struct cmd_list
*cmdlist
;
1648 struct cmd_parse_input
{
1650 #define CMD_PARSE_QUIET 0x1
1651 #define CMD_PARSE_PARSEONLY 0x2
1652 #define CMD_PARSE_NOALIAS 0x4
1653 #define CMD_PARSE_VERBOSE 0x8
1654 #define CMD_PARSE_ONEGROUP 0x10
1659 struct cmdq_item
*item
;
1661 struct cmd_find_state fs
;
1664 /* Command queue flags. */
1665 #define CMDQ_STATE_REPEAT 0x1
1666 #define CMDQ_STATE_CONTROL 0x2
1667 #define CMDQ_STATE_NOHOOKS 0x4
1669 /* Command queue callback. */
1670 typedef enum cmd_retval (*cmdq_cb
) (struct cmdq_item
*, void *);
1672 /* Command definition flag. */
1673 struct cmd_entry_flag
{
1675 enum cmd_find_type type
;
1679 /* Command definition. */
1684 struct args_parse args
;
1687 struct cmd_entry_flag source
;
1688 struct cmd_entry_flag target
;
1690 #define CMD_STARTSERVER 0x1
1691 #define CMD_READONLY 0x2
1692 #define CMD_AFTERHOOK 0x4
1693 #define CMD_CLIENT_CFLAG 0x8
1694 #define CMD_CLIENT_TFLAG 0x10
1695 #define CMD_CLIENT_CANFAIL 0x20
1698 enum cmd_retval (*exec
)(struct cmd
*, struct cmdq_item
*);
1702 #define STATUS_LINES_LIMIT 5
1703 struct status_line_entry
{
1705 struct style_ranges ranges
;
1707 struct status_line
{
1710 struct screen screen
;
1711 struct screen
*active
;
1714 struct grid_cell style
;
1715 struct status_line_entry entries
[STATUS_LINES_LIMIT
];
1719 #define PROMPT_NTYPES 4
1721 PROMPT_TYPE_COMMAND
,
1724 PROMPT_TYPE_WINDOW_TARGET
,
1725 PROMPT_TYPE_INVALID
= 0xff
1728 /* File in client. */
1729 typedef void (*client_file_cb
) (struct client
*, const char *, int, int,
1730 struct evbuffer
*, void *);
1731 struct client_file
{
1733 struct tmuxpeer
*peer
;
1734 struct client_files
*tree
;
1739 struct evbuffer
*buffer
;
1740 struct bufferevent
*event
;
1749 RB_ENTRY(client_file
) entry
;
1751 RB_HEAD(client_files
, client_file
);
1753 /* Client window. */
1754 struct client_window
{
1756 struct window_pane
*pane
;
1761 RB_ENTRY(client_window
) entry
;
1763 RB_HEAD(client_windows
, client_window
);
1765 /* Visible areas not obstructed by overlays. */
1766 #define OVERLAY_MAX_RANGES 3
1767 struct overlay_ranges
{
1768 u_int px
[OVERLAY_MAX_RANGES
];
1769 u_int nx
[OVERLAY_MAX_RANGES
];
1772 /* Client connection. */
1773 typedef int (*prompt_input_cb
)(struct client
*, void *, const char *, int);
1774 typedef void (*prompt_free_cb
)(void *);
1775 typedef void (*overlay_check_cb
)(struct client
*, void *, u_int
, u_int
, u_int
,
1776 struct overlay_ranges
*);
1777 typedef struct screen
*(*overlay_mode_cb
)(struct client
*, void *, u_int
*,
1779 typedef void (*overlay_draw_cb
)(struct client
*, void *,
1780 struct screen_redraw_ctx
*);
1781 typedef int (*overlay_key_cb
)(struct client
*, void *, struct key_event
*);
1782 typedef void (*overlay_free_cb
)(struct client
*, void *);
1783 typedef void (*overlay_resize_cb
)(struct client
*, void *);
1786 struct tmuxpeer
*peer
;
1787 struct cmdq_list
*queue
;
1789 struct client_windows windows
;
1791 struct control_state
*control_state
;
1800 struct timeval creation_time
;
1801 struct timeval activity_time
;
1803 struct environ
*environ
;
1804 struct format_job_tree
*jobs
;
1823 struct event repeat_timer
;
1825 struct event click_timer
;
1827 struct mouse_event click_event
;
1829 struct status_line status
;
1831 #define CLIENT_TERMINAL 0x1
1832 #define CLIENT_LOGIN 0x2
1833 #define CLIENT_EXIT 0x4
1834 #define CLIENT_REDRAWWINDOW 0x8
1835 #define CLIENT_REDRAWSTATUS 0x10
1836 #define CLIENT_REPEAT 0x20
1837 #define CLIENT_SUSPENDED 0x40
1838 #define CLIENT_ATTACHED 0x80
1839 #define CLIENT_EXITED 0x100
1840 #define CLIENT_DEAD 0x200
1841 #define CLIENT_REDRAWBORDERS 0x400
1842 #define CLIENT_READONLY 0x800
1843 #define CLIENT_NOSTARTSERVER 0x1000
1844 #define CLIENT_CONTROL 0x2000
1845 #define CLIENT_CONTROLCONTROL 0x4000
1846 #define CLIENT_FOCUSED 0x8000
1847 #define CLIENT_UTF8 0x10000
1848 #define CLIENT_IGNORESIZE 0x20000
1849 #define CLIENT_IDENTIFIED 0x40000
1850 #define CLIENT_STATUSFORCE 0x80000
1851 #define CLIENT_DOUBLECLICK 0x100000
1852 #define CLIENT_TRIPLECLICK 0x200000
1853 #define CLIENT_SIZECHANGED 0x400000
1854 #define CLIENT_STATUSOFF 0x800000
1855 #define CLIENT_REDRAWSTATUSALWAYS 0x1000000
1856 #define CLIENT_REDRAWOVERLAY 0x2000000
1857 #define CLIENT_CONTROL_NOOUTPUT 0x4000000
1858 #define CLIENT_DEFAULTSOCKET 0x8000000
1859 #define CLIENT_STARTSERVER 0x10000000
1860 #define CLIENT_REDRAWPANES 0x20000000
1861 #define CLIENT_NOFORK 0x40000000
1862 #define CLIENT_ACTIVEPANE 0x80000000ULL
1863 #define CLIENT_CONTROL_PAUSEAFTER 0x100000000ULL
1864 #define CLIENT_CONTROL_WAITEXIT 0x200000000ULL
1865 #define CLIENT_WINDOWSIZECHANGED 0x400000000ULL
1866 #define CLIENT_CLIPBOARDBUFFER 0x800000000ULL
1867 #define CLIENT_BRACKETPASTING 0x1000000000ULL
1868 #define CLIENT_ALLREDRAWFLAGS \
1869 (CLIENT_REDRAWWINDOW| \
1870 CLIENT_REDRAWSTATUS| \
1871 CLIENT_REDRAWSTATUSALWAYS| \
1872 CLIENT_REDRAWBORDERS| \
1873 CLIENT_REDRAWOVERLAY| \
1875 #define CLIENT_UNATTACHEDFLAGS \
1879 #define CLIENT_NODETACHFLAGS \
1882 #define CLIENT_NOSIZEFLAGS \
1890 CLIENT_EXIT_SHUTDOWN
,
1893 enum msgtype exit_msgtype
;
1897 struct key_table
*keytable
;
1899 uint64_t redraw_panes
;
1901 int message_ignore_keys
;
1902 int message_ignore_styles
;
1903 char *message_string
;
1904 struct event message_timer
;
1906 char *prompt_string
;
1907 struct utf8_data
*prompt_buffer
;
1909 size_t prompt_index
;
1910 prompt_input_cb prompt_inputcb
;
1911 prompt_free_cb prompt_freecb
;
1913 u_int prompt_hindex
[PROMPT_NTYPES
];
1918 struct utf8_data
*prompt_saved
;
1919 #define PROMPT_SINGLE 0x1
1920 #define PROMPT_NUMERIC 0x2
1921 #define PROMPT_INCREMENTAL 0x4
1922 #define PROMPT_NOFORMAT 0x8
1923 #define PROMPT_KEY 0x10
1925 enum prompt_type prompt_type
;
1928 struct session
*session
;
1929 struct session
*last_session
;
1937 overlay_check_cb overlay_check
;
1938 overlay_mode_cb overlay_mode
;
1939 overlay_draw_cb overlay_draw
;
1940 overlay_key_cb overlay_key
;
1941 overlay_free_cb overlay_free
;
1942 overlay_resize_cb overlay_resize
;
1944 struct event overlay_timer
;
1946 struct client_files files
;
1948 u_int
*clipboard_panes
;
1949 u_int clipboard_npanes
;
1951 TAILQ_ENTRY(client
) entry
;
1953 TAILQ_HEAD(clients
, client
);
1955 /* Control mode subscription type. */
1956 enum control_sub_type
{
1957 CONTROL_SUB_SESSION
,
1959 CONTROL_SUB_ALL_PANES
,
1961 CONTROL_SUB_ALL_WINDOWS
1964 /* Key binding and key table. */
1965 struct key_binding
{
1967 struct cmd_list
*cmdlist
;
1971 #define KEY_BINDING_REPEAT 0x1
1973 RB_ENTRY(key_binding
) entry
;
1975 RB_HEAD(key_bindings
, key_binding
);
1979 struct key_bindings key_bindings
;
1980 struct key_bindings default_key_bindings
;
1984 RB_ENTRY(key_table
) entry
;
1986 RB_HEAD(key_tables
, key_table
);
1989 RB_HEAD(options_array
, options_array_item
);
1990 union options_value
{
1994 struct options_array array
;
1995 struct cmd_list
*cmdlist
;
1998 /* Option table entries. */
1999 enum options_table_type
{
2000 OPTIONS_TABLE_STRING
,
2001 OPTIONS_TABLE_NUMBER
,
2003 OPTIONS_TABLE_COLOUR
,
2005 OPTIONS_TABLE_CHOICE
,
2006 OPTIONS_TABLE_COMMAND
2009 #define OPTIONS_TABLE_NONE 0
2010 #define OPTIONS_TABLE_SERVER 0x1
2011 #define OPTIONS_TABLE_SESSION 0x2
2012 #define OPTIONS_TABLE_WINDOW 0x4
2013 #define OPTIONS_TABLE_PANE 0x8
2015 #define OPTIONS_TABLE_IS_ARRAY 0x1
2016 #define OPTIONS_TABLE_IS_HOOK 0x2
2017 #define OPTIONS_TABLE_IS_STYLE 0x4
2019 struct options_table_entry
{
2021 const char *alternative_name
;
2022 enum options_table_type type
;
2028 const char **choices
;
2030 const char *default_str
;
2031 long long default_num
;
2032 const char **default_arr
;
2034 const char *separator
;
2035 const char *pattern
;
2041 struct options_name_map
{
2046 /* Common command usages. */
2047 #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
2048 #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
2049 #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
2050 #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
2051 #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
2052 #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
2053 #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
2054 #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
2055 #define CMD_BUFFER_USAGE "[-b buffer-name]"
2057 /* Spawn common context. */
2058 struct spawn_context
{
2059 struct cmdq_item
*item
;
2065 struct window_pane
*wp0
;
2066 struct layout_cell
*lc
;
2071 struct environ
*environ
;
2077 #define SPAWN_KILL 0x1
2078 #define SPAWN_DETACHED 0x2
2079 #define SPAWN_RESPAWN 0x4
2080 #define SPAWN_BEFORE 0x8
2081 #define SPAWN_NONOTIFY 0x10
2082 #define SPAWN_FULLSIZE 0x20
2083 #define SPAWN_EMPTY 0x40
2084 #define SPAWN_ZOOM 0x80
2087 /* Mode tree sort order. */
2088 struct mode_tree_sort_criteria
{
2094 extern struct options
*global_options
;
2095 extern struct options
*global_s_options
;
2096 extern struct options
*global_w_options
;
2097 extern struct environ
*global_environ
;
2098 extern struct timeval start_time
;
2099 extern const char *socket_path
;
2100 extern const char *shell_command
;
2102 extern const char *shell_command
;
2103 int checkshell(const char *);
2104 void setblocking(int, int);
2105 char *shell_argv0(const char *, int);
2106 uint64_t get_timer(void);
2107 const char *sig2name(int);
2108 const char *find_cwd(void);
2109 const char *find_home(void);
2110 const char *getversion(void);
2114 int proc_send(struct tmuxpeer
*, enum msgtype
, int, const void *, size_t);
2115 struct tmuxproc
*proc_start(const char *);
2116 void proc_loop(struct tmuxproc
*, int (*)(void));
2117 void proc_exit(struct tmuxproc
*);
2118 void proc_set_signals(struct tmuxproc
*, void(*)(int));
2119 void proc_clear_signals(struct tmuxproc
*, int);
2120 struct tmuxpeer
*proc_add_peer(struct tmuxproc
*, int,
2121 void (*)(struct imsg
*, void *), void *);
2122 void proc_remove_peer(struct tmuxpeer
*);
2123 void proc_kill_peer(struct tmuxpeer
*);
2124 void proc_flush_peer(struct tmuxpeer
*);
2125 void proc_toggle_log(struct tmuxproc
*);
2126 pid_t
proc_fork_and_daemon(int *);
2127 uid_t
proc_get_peer_uid(struct tmuxpeer
*);
2130 extern int cfg_finished
;
2131 extern struct client
*cfg_client
;
2132 extern char **cfg_files
;
2133 extern u_int cfg_nfiles
;
2134 extern int cfg_quiet
;
2135 void start_cfg(void);
2136 int load_cfg(const char *, struct client
*, struct cmdq_item
*,
2137 struct cmd_find_state
*, int, struct cmdq_item
**);
2138 int load_cfg_from_buffer(const void *, size_t, const char *,
2139 struct client
*, struct cmdq_item
*, struct cmd_find_state
*,
2140 int, struct cmdq_item
**);
2141 void printflike(1, 2) cfg_add_cause(const char *, ...);
2142 void cfg_print_causes(struct cmdq_item
*);
2143 void cfg_show_causes(struct session
*);
2146 struct paste_buffer
;
2147 const char *paste_buffer_name(struct paste_buffer
*);
2148 u_int
paste_buffer_order(struct paste_buffer
*);
2149 time_t paste_buffer_created(struct paste_buffer
*);
2150 const char *paste_buffer_data(struct paste_buffer
*, size_t *);
2151 struct paste_buffer
*paste_walk(struct paste_buffer
*);
2152 int paste_is_empty(void);
2153 struct paste_buffer
*paste_get_top(const char **);
2154 struct paste_buffer
*paste_get_name(const char *);
2155 void paste_free(struct paste_buffer
*);
2156 void paste_add(const char *, char *, size_t);
2157 int paste_rename(const char *, const char *, char **);
2158 int paste_set(char *, size_t, const char *, char **);
2159 void paste_replace(struct paste_buffer
*, char *, size_t);
2160 char *paste_make_sample(struct paste_buffer
*);
2163 #define FORMAT_STATUS 0x1
2164 #define FORMAT_FORCE 0x2
2165 #define FORMAT_NOJOBS 0x4
2166 #define FORMAT_VERBOSE 0x8
2167 #define FORMAT_NONE 0
2168 #define FORMAT_PANE 0x80000000U
2169 #define FORMAT_WINDOW 0x40000000U
2171 struct format_modifier
;
2172 typedef void *(*format_cb
)(struct format_tree
*);
2173 void format_tidy_jobs(void);
2174 const char *format_skip(const char *, const char *);
2175 int format_true(const char *);
2176 struct format_tree
*format_create(struct client
*, struct cmdq_item
*, int,
2178 void format_free(struct format_tree
*);
2179 void format_merge(struct format_tree
*, struct format_tree
*);
2180 struct window_pane
*format_get_pane(struct format_tree
*);
2181 void printflike(3, 4) format_add(struct format_tree
*, const char *,
2183 void format_add_tv(struct format_tree
*, const char *,
2185 void format_add_cb(struct format_tree
*, const char *, format_cb
);
2186 void format_log_debug(struct format_tree
*, const char *);
2187 void format_each(struct format_tree
*, void (*)(const char *,
2188 const char *, void *), void *);
2189 char *format_pretty_time(time_t, int);
2190 char *format_expand_time(struct format_tree
*, const char *);
2191 char *format_expand(struct format_tree
*, const char *);
2192 char *format_single(struct cmdq_item
*, const char *,
2193 struct client
*, struct session
*, struct winlink
*,
2194 struct window_pane
*);
2195 char *format_single_from_state(struct cmdq_item
*, const char *,
2196 struct client
*, struct cmd_find_state
*);
2197 char *format_single_from_target(struct cmdq_item
*, const char *);
2198 struct format_tree
*format_create_defaults(struct cmdq_item
*, struct client
*,
2199 struct session
*, struct winlink
*, struct window_pane
*);
2200 struct format_tree
*format_create_from_state(struct cmdq_item
*,
2201 struct client
*, struct cmd_find_state
*);
2202 struct format_tree
*format_create_from_target(struct cmdq_item
*);
2203 void format_defaults(struct format_tree
*, struct client
*,
2204 struct session
*, struct winlink
*, struct window_pane
*);
2205 void format_defaults_window(struct format_tree
*, struct window
*);
2206 void format_defaults_pane(struct format_tree
*,
2207 struct window_pane
*);
2208 void format_defaults_paste_buffer(struct format_tree
*,
2209 struct paste_buffer
*);
2210 void format_lost_client(struct client
*);
2211 char *format_grid_word(struct grid
*, u_int
, u_int
);
2212 char *format_grid_hyperlink(struct grid
*, u_int
, u_int
,
2214 char *format_grid_line(struct grid
*, u_int
);
2217 void format_draw(struct screen_write_ctx
*,
2218 const struct grid_cell
*, u_int
, const char *,
2219 struct style_ranges
*, int);
2220 u_int
format_width(const char *);
2221 char *format_trim_left(const char *, u_int
);
2222 char *format_trim_right(const char *, u_int
);
2225 void notify_hook(struct cmdq_item
*, const char *);
2226 void notify_client(const char *, struct client
*);
2227 void notify_session(const char *, struct session
*);
2228 void notify_winlink(const char *, struct winlink
*);
2229 void notify_session_window(const char *, struct session
*, struct window
*);
2230 void notify_window(const char *, struct window
*);
2231 void notify_pane(const char *, struct window_pane
*);
2232 void notify_paste_buffer(const char *, int);
2235 struct options
*options_create(struct options
*);
2236 void options_free(struct options
*);
2237 struct options
*options_get_parent(struct options
*);
2238 void options_set_parent(struct options
*, struct options
*);
2239 struct options_entry
*options_first(struct options
*);
2240 struct options_entry
*options_next(struct options_entry
*);
2241 struct options_entry
*options_empty(struct options
*,
2242 const struct options_table_entry
*);
2243 struct options_entry
*options_default(struct options
*,
2244 const struct options_table_entry
*);
2245 char *options_default_to_string(const struct options_table_entry
*);
2246 const char *options_name(struct options_entry
*);
2247 struct options
*options_owner(struct options_entry
*);
2248 const struct options_table_entry
*options_table_entry(struct options_entry
*);
2249 struct options_entry
*options_get_only(struct options
*, const char *);
2250 struct options_entry
*options_get(struct options
*, const char *);
2251 void options_array_clear(struct options_entry
*);
2252 union options_value
*options_array_get(struct options_entry
*, u_int
);
2253 int options_array_set(struct options_entry
*, u_int
, const char *,
2255 int options_array_assign(struct options_entry
*, const char *,
2257 struct options_array_item
*options_array_first(struct options_entry
*);
2258 struct options_array_item
*options_array_next(struct options_array_item
*);
2259 u_int
options_array_item_index(struct options_array_item
*);
2260 union options_value
*options_array_item_value(struct options_array_item
*);
2261 int options_is_array(struct options_entry
*);
2262 int options_is_string(struct options_entry
*);
2263 char *options_to_string(struct options_entry
*, int, int);
2264 char *options_parse(const char *, int *);
2265 struct options_entry
*options_parse_get(struct options
*, const char *, int *,
2267 char *options_match(const char *, int *, int *);
2268 struct options_entry
*options_match_get(struct options
*, const char *, int *,
2270 const char *options_get_string(struct options
*, const char *);
2271 long long options_get_number(struct options
*, const char *);
2272 struct options_entry
* printflike(4, 5) options_set_string(struct options
*,
2273 const char *, int, const char *, ...);
2274 struct options_entry
*options_set_number(struct options
*, const char *,
2276 int options_scope_from_name(struct args
*, int,
2277 const char *, struct cmd_find_state
*, struct options
**,
2279 int options_scope_from_flags(struct args
*, int,
2280 struct cmd_find_state
*, struct options
**, char **);
2281 struct style
*options_string_to_style(struct options
*, const char *,
2282 struct format_tree
*);
2283 int options_from_string(struct options
*,
2284 const struct options_table_entry
*, const char *,
2285 const char *, int, char **);
2286 int options_find_choice(const struct options_table_entry
*,
2287 const char *, char **);
2288 void options_push_changes(const char *);
2289 int options_remove_or_default(struct options_entry
*, int,
2292 /* options-table.c */
2293 extern const struct options_table_entry options_table
[];
2294 extern const struct options_name_map options_other_names
[];
2297 typedef void (*job_update_cb
) (struct job
*);
2298 typedef void (*job_complete_cb
) (struct job
*);
2299 typedef void (*job_free_cb
) (void *);
2300 #define JOB_NOWAIT 0x1
2301 #define JOB_KEEPWRITE 0x2
2303 struct job
*job_run(const char *, int, char **, struct environ
*,
2304 struct session
*, const char *, job_update_cb
,
2305 job_complete_cb
, job_free_cb
, void *, int, int, int);
2306 void job_free(struct job
*);
2307 int job_transfer(struct job
*, pid_t
*, char *, size_t);
2308 void job_resize(struct job
*, u_int
, u_int
);
2309 void job_check_died(pid_t
, int);
2310 int job_get_status(struct job
*);
2311 void *job_get_data(struct job
*);
2312 struct bufferevent
*job_get_event(struct job
*);
2313 void job_kill_all(void);
2314 int job_still_running(void);
2315 void job_print_summary(struct cmdq_item
*, int);
2318 struct environ
*environ_create(void);
2319 void environ_free(struct environ
*);
2320 struct environ_entry
*environ_first(struct environ
*);
2321 struct environ_entry
*environ_next(struct environ_entry
*);
2322 void environ_copy(struct environ
*, struct environ
*);
2323 struct environ_entry
*environ_find(struct environ
*, const char *);
2324 void printflike(4, 5) environ_set(struct environ
*, const char *, int,
2326 void environ_clear(struct environ
*, const char *);
2327 void environ_put(struct environ
*, const char *, int);
2328 void environ_unset(struct environ
*, const char *);
2329 void environ_update(struct options
*, struct environ
*, struct environ
*);
2330 void environ_push(struct environ
*);
2331 void printflike(2, 3) environ_log(struct environ
*, const char *, ...);
2332 struct environ
*environ_for_session(struct session
*, int);
2335 void tty_create_log(void);
2336 int tty_window_bigger(struct tty
*);
2337 int tty_window_offset(struct tty
*, u_int
*, u_int
*, u_int
*, u_int
*);
2338 void tty_update_window_offset(struct window
*);
2339 void tty_update_client_offset(struct client
*);
2340 void tty_raw(struct tty
*, const char *);
2341 void tty_attributes(struct tty
*, const struct grid_cell
*,
2342 const struct grid_cell
*, struct colour_palette
*,
2343 struct hyperlinks
*);
2344 void tty_reset(struct tty
*);
2345 void tty_region_off(struct tty
*);
2346 void tty_margin_off(struct tty
*);
2347 void tty_cursor(struct tty
*, u_int
, u_int
);
2348 void tty_clipboard_query(struct tty
*);
2349 void tty_putcode(struct tty
*, enum tty_code_code
);
2350 void tty_putcode_i(struct tty
*, enum tty_code_code
, int);
2351 void tty_putcode_ii(struct tty
*, enum tty_code_code
, int, int);
2352 void tty_putcode_iii(struct tty
*, enum tty_code_code
, int, int, int);
2353 void tty_putcode_s(struct tty
*, enum tty_code_code
, const char *);
2354 void tty_putcode_ss(struct tty
*, enum tty_code_code
, const char *,
2356 void tty_puts(struct tty
*, const char *);
2357 void tty_putc(struct tty
*, u_char
);
2358 void tty_putn(struct tty
*, const void *, size_t, u_int
);
2359 void tty_cell(struct tty
*, const struct grid_cell
*,
2360 const struct grid_cell
*, struct colour_palette
*,
2361 struct hyperlinks
*);
2362 int tty_init(struct tty
*, struct client
*);
2363 void tty_resize(struct tty
*);
2364 void tty_set_size(struct tty
*, u_int
, u_int
, u_int
, u_int
);
2365 void tty_start_tty(struct tty
*);
2366 void tty_send_requests(struct tty
*);
2367 void tty_repeat_requests(struct tty
*);
2368 void tty_stop_tty(struct tty
*);
2369 void tty_set_title(struct tty
*, const char *);
2370 void tty_set_path(struct tty
*, const char *);
2371 void tty_update_mode(struct tty
*, int, struct screen
*);
2372 void tty_draw_line(struct tty
*, struct screen
*, u_int
, u_int
, u_int
,
2373 u_int
, u_int
, const struct grid_cell
*, struct colour_palette
*);
2374 void tty_sync_start(struct tty
*);
2375 void tty_sync_end(struct tty
*);
2376 int tty_open(struct tty
*, char **);
2377 void tty_close(struct tty
*);
2378 void tty_free(struct tty
*);
2379 void tty_update_features(struct tty
*);
2380 void tty_set_selection(struct tty
*, const char *, const char *, size_t);
2381 void tty_write(void (*)(struct tty
*, const struct tty_ctx
*),
2383 void tty_cmd_alignmenttest(struct tty
*, const struct tty_ctx
*);
2384 void tty_cmd_cell(struct tty
*, const struct tty_ctx
*);
2385 void tty_cmd_cells(struct tty
*, const struct tty_ctx
*);
2386 void tty_cmd_clearendofline(struct tty
*, const struct tty_ctx
*);
2387 void tty_cmd_clearendofscreen(struct tty
*, const struct tty_ctx
*);
2388 void tty_cmd_clearline(struct tty
*, const struct tty_ctx
*);
2389 void tty_cmd_clearscreen(struct tty
*, const struct tty_ctx
*);
2390 void tty_cmd_clearstartofline(struct tty
*, const struct tty_ctx
*);
2391 void tty_cmd_clearstartofscreen(struct tty
*, const struct tty_ctx
*);
2392 void tty_cmd_deletecharacter(struct tty
*, const struct tty_ctx
*);
2393 void tty_cmd_clearcharacter(struct tty
*, const struct tty_ctx
*);
2394 void tty_cmd_deleteline(struct tty
*, const struct tty_ctx
*);
2395 void tty_cmd_insertcharacter(struct tty
*, const struct tty_ctx
*);
2396 void tty_cmd_insertline(struct tty
*, const struct tty_ctx
*);
2397 void tty_cmd_linefeed(struct tty
*, const struct tty_ctx
*);
2398 void tty_cmd_scrollup(struct tty
*, const struct tty_ctx
*);
2399 void tty_cmd_scrolldown(struct tty
*, const struct tty_ctx
*);
2400 void tty_cmd_reverseindex(struct tty
*, const struct tty_ctx
*);
2401 void tty_cmd_setselection(struct tty
*, const struct tty_ctx
*);
2402 void tty_cmd_rawstring(struct tty
*, const struct tty_ctx
*);
2403 void tty_cmd_syncstart(struct tty
*, const struct tty_ctx
*);
2404 void tty_default_colours(struct grid_cell
*, struct window_pane
*);
2407 extern struct tty_terms tty_terms
;
2408 u_int
tty_term_ncodes(void);
2409 void tty_term_apply(struct tty_term
*, const char *, int);
2410 void tty_term_apply_overrides(struct tty_term
*);
2411 struct tty_term
*tty_term_create(struct tty
*, char *, char **, u_int
, int *,
2413 void tty_term_free(struct tty_term
*);
2414 int tty_term_read_list(const char *, int, char ***, u_int
*,
2416 void tty_term_free_list(char **, u_int
);
2417 int tty_term_has(struct tty_term
*, enum tty_code_code
);
2418 const char *tty_term_string(struct tty_term
*, enum tty_code_code
);
2419 const char *tty_term_string_i(struct tty_term
*, enum tty_code_code
, int);
2420 const char *tty_term_string_ii(struct tty_term
*, enum tty_code_code
, int,
2422 const char *tty_term_string_iii(struct tty_term
*, enum tty_code_code
, int,
2424 const char *tty_term_string_s(struct tty_term
*, enum tty_code_code
,
2426 const char *tty_term_string_ss(struct tty_term
*, enum tty_code_code
,
2427 const char *, const char *);
2428 int tty_term_number(struct tty_term
*, enum tty_code_code
);
2429 int tty_term_flag(struct tty_term
*, enum tty_code_code
);
2430 const char *tty_term_describe(struct tty_term
*, enum tty_code_code
);
2432 /* tty-features.c */
2433 void tty_add_features(int *, const char *, const char *);
2434 const char *tty_get_features(int);
2435 int tty_apply_features(struct tty_term
*, int);
2436 void tty_default_features(int *, const char *, u_int
);
2439 int tty_acs_needed(struct tty
*);
2440 const char *tty_acs_get(struct tty
*, u_char
);
2441 int tty_acs_reverse_get(struct tty
*, const char *, size_t);
2442 const struct utf8_data
*tty_acs_double_borders(int);
2443 const struct utf8_data
*tty_acs_heavy_borders(int);
2444 const struct utf8_data
*tty_acs_rounded_borders(int);
2447 void tty_keys_build(struct tty
*);
2448 void tty_keys_free(struct tty
*);
2449 int tty_keys_next(struct tty
*);
2450 int tty_keys_colours(struct tty
*, const char *, size_t, size_t *,
2454 void args_set(struct args
*, u_char
, struct args_value
*, int);
2455 struct args
*args_create(void);
2456 struct args
*args_parse(const struct args_parse
*, struct args_value
*,
2458 struct args
*args_copy(struct args
*, int, char **);
2459 void args_to_vector(struct args
*, int *, char ***);
2460 struct args_value
*args_from_vector(int, char **);
2461 void args_free_value(struct args_value
*);
2462 void args_free_values(struct args_value
*, u_int
);
2463 void args_free(struct args
*);
2464 char *args_print(struct args
*);
2465 char *args_escape(const char *);
2466 int args_has(struct args
*, u_char
);
2467 const char *args_get(struct args
*, u_char
);
2468 u_char
args_first(struct args
*, struct args_entry
**);
2469 u_char
args_next(struct args_entry
**);
2470 u_int
args_count(struct args
*);
2471 struct args_value
*args_values(struct args
*);
2472 struct args_value
*args_value(struct args
*, u_int
);
2473 const char *args_string(struct args
*, u_int
);
2474 struct cmd_list
*args_make_commands_now(struct cmd
*, struct cmdq_item
*,
2476 struct args_command_state
*args_make_commands_prepare(struct cmd
*,
2477 struct cmdq_item
*, u_int
, const char *, int, int);
2478 struct cmd_list
*args_make_commands(struct args_command_state
*, int, char **,
2480 void args_make_commands_free(struct args_command_state
*);
2481 char *args_make_commands_get_command(struct args_command_state
*);
2482 struct args_value
*args_first_value(struct args
*, u_char
);
2483 struct args_value
*args_next_value(struct args_value
*);
2484 long long args_strtonum(struct args
*, u_char
, long long, long long,
2486 long long args_strtonum_and_expand(struct args
*, u_char
, long long,
2487 long long, struct cmdq_item
*, char **);
2488 long long args_percentage(struct args
*, u_char
, long long,
2489 long long, long long, char **);
2490 long long args_string_percentage(const char *, long long, long long,
2491 long long, char **);
2492 long long args_percentage_and_expand(struct args
*, u_char
, long long,
2493 long long, long long, struct cmdq_item
*, char **);
2494 long long args_string_percentage_and_expand(const char *, long long,
2495 long long, long long, struct cmdq_item
*, char **);
2498 int cmd_find_target(struct cmd_find_state
*, struct cmdq_item
*,
2499 const char *, enum cmd_find_type
, int);
2500 struct client
*cmd_find_best_client(struct session
*);
2501 struct client
*cmd_find_client(struct cmdq_item
*, const char *, int);
2502 void cmd_find_clear_state(struct cmd_find_state
*, int);
2503 int cmd_find_empty_state(struct cmd_find_state
*);
2504 int cmd_find_valid_state(struct cmd_find_state
*);
2505 void cmd_find_copy_state(struct cmd_find_state
*,
2506 struct cmd_find_state
*);
2507 void cmd_find_from_session(struct cmd_find_state
*,
2508 struct session
*, int);
2509 void cmd_find_from_winlink(struct cmd_find_state
*,
2510 struct winlink
*, int);
2511 int cmd_find_from_session_window(struct cmd_find_state
*,
2512 struct session
*, struct window
*, int);
2513 int cmd_find_from_window(struct cmd_find_state
*, struct window
*,
2515 void cmd_find_from_winlink_pane(struct cmd_find_state
*,
2516 struct winlink
*, struct window_pane
*, int);
2517 int cmd_find_from_pane(struct cmd_find_state
*,
2518 struct window_pane
*, int);
2519 int cmd_find_from_client(struct cmd_find_state
*, struct client
*,
2521 int cmd_find_from_mouse(struct cmd_find_state
*,
2522 struct mouse_event
*, int);
2523 int cmd_find_from_nothing(struct cmd_find_state
*, int);
2526 extern const struct cmd_entry
*cmd_table
[];
2527 void printflike(3, 4) cmd_log_argv(int, char **, const char *, ...);
2528 void cmd_prepend_argv(int *, char ***, const char *);
2529 void cmd_append_argv(int *, char ***, const char *);
2530 int cmd_pack_argv(int, char **, char *, size_t);
2531 int cmd_unpack_argv(char *, size_t, int, char ***);
2532 char **cmd_copy_argv(int, char **);
2533 void cmd_free_argv(int, char **);
2534 char *cmd_stringify_argv(int, char **);
2535 char *cmd_get_alias(const char *);
2536 const struct cmd_entry
*cmd_get_entry(struct cmd
*);
2537 struct args
*cmd_get_args(struct cmd
*);
2538 u_int
cmd_get_group(struct cmd
*);
2539 void cmd_get_source(struct cmd
*, const char **, u_int
*);
2540 struct cmd
*cmd_parse(struct args_value
*, u_int
, const char *, u_int
,
2542 struct cmd
*cmd_copy(struct cmd
*, int, char **);
2543 void cmd_free(struct cmd
*);
2544 char *cmd_print(struct cmd
*);
2545 struct cmd_list
*cmd_list_new(void);
2546 struct cmd_list
*cmd_list_copy(struct cmd_list
*, int, char **);
2547 void cmd_list_append(struct cmd_list
*, struct cmd
*);
2548 void cmd_list_append_all(struct cmd_list
*, struct cmd_list
*);
2549 void cmd_list_move(struct cmd_list
*, struct cmd_list
*);
2550 void cmd_list_free(struct cmd_list
*);
2551 char *cmd_list_print(struct cmd_list
*, int);
2552 struct cmd
*cmd_list_first(struct cmd_list
*);
2553 struct cmd
*cmd_list_next(struct cmd
*);
2554 int cmd_list_all_have(struct cmd_list
*, int);
2555 int cmd_list_any_have(struct cmd_list
*, int);
2556 int cmd_mouse_at(struct window_pane
*, struct mouse_event
*,
2557 u_int
*, u_int
*, int);
2558 struct winlink
*cmd_mouse_window(struct mouse_event
*, struct session
**);
2559 struct window_pane
*cmd_mouse_pane(struct mouse_event
*, struct session
**,
2561 char *cmd_template_replace(const char *, const char *, int);
2563 /* cmd-attach-session.c */
2564 enum cmd_retval
cmd_attach_session(struct cmdq_item
*, const char *, int, int,
2565 int, const char *, int, const char *);
2568 struct cmd_parse_result
*cmd_parse_from_file(FILE *, struct cmd_parse_input
*);
2569 struct cmd_parse_result
*cmd_parse_from_string(const char *,
2570 struct cmd_parse_input
*);
2571 enum cmd_parse_status
cmd_parse_and_insert(const char *,
2572 struct cmd_parse_input
*, struct cmdq_item
*,
2573 struct cmdq_state
*, char **);
2574 enum cmd_parse_status
cmd_parse_and_append(const char *,
2575 struct cmd_parse_input
*, struct client
*,
2576 struct cmdq_state
*, char **);
2577 struct cmd_parse_result
*cmd_parse_from_buffer(const void *, size_t,
2578 struct cmd_parse_input
*);
2579 struct cmd_parse_result
*cmd_parse_from_arguments(struct args_value
*, u_int
,
2580 struct cmd_parse_input
*);
2583 struct cmdq_state
*cmdq_new_state(struct cmd_find_state
*, struct key_event
*,
2585 struct cmdq_state
*cmdq_link_state(struct cmdq_state
*);
2586 struct cmdq_state
*cmdq_copy_state(struct cmdq_state
*,
2587 struct cmd_find_state
*);
2588 void cmdq_free_state(struct cmdq_state
*);
2589 void printflike(3, 4) cmdq_add_format(struct cmdq_state
*, const char *,
2591 void cmdq_add_formats(struct cmdq_state
*, struct format_tree
*);
2592 void cmdq_merge_formats(struct cmdq_item
*, struct format_tree
*);
2593 struct cmdq_list
*cmdq_new(void);
2594 void cmdq_free(struct cmdq_list
*);
2595 const char *cmdq_get_name(struct cmdq_item
*);
2596 struct client
*cmdq_get_client(struct cmdq_item
*);
2597 struct client
*cmdq_get_target_client(struct cmdq_item
*);
2598 struct cmdq_state
*cmdq_get_state(struct cmdq_item
*);
2599 struct cmd_find_state
*cmdq_get_target(struct cmdq_item
*);
2600 struct cmd_find_state
*cmdq_get_source(struct cmdq_item
*);
2601 struct key_event
*cmdq_get_event(struct cmdq_item
*);
2602 struct cmd_find_state
*cmdq_get_current(struct cmdq_item
*);
2603 int cmdq_get_flags(struct cmdq_item
*);
2604 struct cmdq_item
*cmdq_get_command(struct cmd_list
*, struct cmdq_state
*);
2605 #define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data)
2606 struct cmdq_item
*cmdq_get_callback1(const char *, cmdq_cb
, void *);
2607 struct cmdq_item
*cmdq_get_error(const char *);
2608 struct cmdq_item
*cmdq_insert_after(struct cmdq_item
*, struct cmdq_item
*);
2609 struct cmdq_item
*cmdq_append(struct client
*, struct cmdq_item
*);
2610 void printflike(4, 5) cmdq_insert_hook(struct session
*, struct cmdq_item
*,
2611 struct cmd_find_state
*, const char *, ...);
2612 void cmdq_continue(struct cmdq_item
*);
2613 u_int
cmdq_next(struct client
*);
2614 struct cmdq_item
*cmdq_running(struct client
*);
2615 void cmdq_guard(struct cmdq_item
*, const char *, int);
2616 void printflike(2, 3) cmdq_print(struct cmdq_item
*, const char *, ...);
2617 void cmdq_print_data(struct cmdq_item
*, int, struct evbuffer
*);
2618 void printflike(2, 3) cmdq_error(struct cmdq_item
*, const char *, ...);
2620 /* cmd-wait-for.c */
2621 void cmd_wait_for_flush(void);
2624 int client_main(struct event_base
*, int, char **, uint64_t, int);
2626 /* key-bindings.c */
2627 struct key_table
*key_bindings_get_table(const char *, int);
2628 struct key_table
*key_bindings_first_table(void);
2629 struct key_table
*key_bindings_next_table(struct key_table
*);
2630 void key_bindings_unref_table(struct key_table
*);
2631 struct key_binding
*key_bindings_get(struct key_table
*, key_code
);
2632 struct key_binding
*key_bindings_get_default(struct key_table
*, key_code
);
2633 struct key_binding
*key_bindings_first(struct key_table
*);
2634 struct key_binding
*key_bindings_next(struct key_table
*, struct key_binding
*);
2635 void key_bindings_add(const char *, key_code
, const char *, int,
2637 void key_bindings_remove(const char *, key_code
);
2638 void key_bindings_reset(const char *, key_code
);
2639 void key_bindings_remove_table(const char *);
2640 void key_bindings_reset_table(const char *);
2641 void key_bindings_init(void);
2642 struct cmdq_item
*key_bindings_dispatch(struct key_binding
*,
2643 struct cmdq_item
*, struct client
*, struct key_event
*,
2644 struct cmd_find_state
*);
2647 key_code
key_string_lookup_string(const char *);
2648 const char *key_string_lookup_key(key_code
, int);
2651 void alerts_reset_all(void);
2652 void alerts_queue(struct window
*, int);
2653 void alerts_check_session(struct session
*);
2656 int file_cmp(struct client_file
*, struct client_file
*);
2657 RB_PROTOTYPE(client_files
, client_file
, entry
, file_cmp
);
2658 struct client_file
*file_create_with_peer(struct tmuxpeer
*,
2659 struct client_files
*, int, client_file_cb
, void *);
2660 struct client_file
*file_create_with_client(struct client
*, int,
2661 client_file_cb
, void *);
2662 void file_free(struct client_file
*);
2663 void file_fire_done(struct client_file
*);
2664 void file_fire_read(struct client_file
*);
2665 int file_can_print(struct client
*);
2666 void printflike(2, 3) file_print(struct client
*, const char *, ...);
2667 void printflike(2, 0) file_vprint(struct client
*, const char *, va_list);
2668 void file_print_buffer(struct client
*, void *, size_t);
2669 void printflike(2, 3) file_error(struct client
*, const char *, ...);
2670 void file_write(struct client
*, const char *, int, const void *, size_t,
2671 client_file_cb
, void *);
2672 struct client_file
*file_read(struct client
*, const char *, client_file_cb
,
2674 void file_cancel(struct client_file
*);
2675 void file_push(struct client_file
*);
2676 int file_write_left(struct client_files
*);
2677 void file_write_open(struct client_files
*, struct tmuxpeer
*,
2678 struct imsg
*, int, int, client_file_cb
, void *);
2679 void file_write_data(struct client_files
*, struct imsg
*);
2680 void file_write_close(struct client_files
*, struct imsg
*);
2681 void file_read_open(struct client_files
*, struct tmuxpeer
*, struct imsg
*,
2682 int, int, client_file_cb
, void *);
2683 void file_write_ready(struct client_files
*, struct imsg
*);
2684 void file_read_data(struct client_files
*, struct imsg
*);
2685 void file_read_done(struct client_files
*, struct imsg
*);
2686 void file_read_cancel(struct client_files
*, struct imsg
*);
2689 extern struct tmuxproc
*server_proc
;
2690 extern struct clients clients
;
2691 extern struct cmd_find_state marked_pane
;
2692 extern struct message_list message_log
;
2693 extern time_t current_time
;
2694 void server_set_marked(struct session
*, struct winlink
*,
2695 struct window_pane
*);
2696 void server_clear_marked(void);
2697 int server_is_marked(struct session
*, struct winlink
*,
2698 struct window_pane
*);
2699 int server_check_marked(void);
2700 int server_start(struct tmuxproc
*, int, struct event_base
*, int, char *);
2701 void server_update_socket(void);
2702 void server_add_accept(int);
2703 void printflike(1, 2) server_add_message(const char *, ...);
2705 /* server-client.c */
2706 RB_PROTOTYPE(client_windows
, client_window
, entry
, server_client_window_cmp
);
2707 u_int
server_client_how_many(void);
2708 void server_client_set_overlay(struct client
*, u_int
, overlay_check_cb
,
2709 overlay_mode_cb
, overlay_draw_cb
, overlay_key_cb
,
2710 overlay_free_cb
, overlay_resize_cb
, void *);
2711 void server_client_clear_overlay(struct client
*);
2712 void server_client_overlay_range(u_int
, u_int
, u_int
, u_int
, u_int
, u_int
,
2713 u_int
, struct overlay_ranges
*);
2714 void server_client_set_key_table(struct client
*, const char *);
2715 const char *server_client_get_key_table(struct client
*);
2716 int server_client_check_nested(struct client
*);
2717 int server_client_handle_key(struct client
*, struct key_event
*);
2718 struct client
*server_client_create(int);
2719 int server_client_open(struct client
*, char **);
2720 void server_client_unref(struct client
*);
2721 void server_client_set_session(struct client
*, struct session
*);
2722 void server_client_lost(struct client
*);
2723 void server_client_suspend(struct client
*);
2724 void server_client_detach(struct client
*, enum msgtype
);
2725 void server_client_exec(struct client
*, const char *);
2726 void server_client_loop(void);
2727 const char *server_client_get_cwd(struct client
*, struct session
*);
2728 void server_client_set_flags(struct client
*, const char *);
2729 const char *server_client_get_flags(struct client
*);
2730 struct client_window
*server_client_get_client_window(struct client
*, u_int
);
2731 struct client_window
*server_client_add_client_window(struct client
*, u_int
);
2732 struct window_pane
*server_client_get_pane(struct client
*);
2733 void server_client_set_pane(struct client
*, struct window_pane
*);
2734 void server_client_remove_pane(struct window_pane
*);
2735 void server_client_print(struct client
*, int, struct evbuffer
*);
2738 void server_redraw_client(struct client
*);
2739 void server_status_client(struct client
*);
2740 void server_redraw_session(struct session
*);
2741 void server_redraw_session_group(struct session
*);
2742 void server_status_session(struct session
*);
2743 void server_status_session_group(struct session
*);
2744 void server_redraw_window(struct window
*);
2745 void server_redraw_window_borders(struct window
*);
2746 void server_status_window(struct window
*);
2747 void server_lock(void);
2748 void server_lock_session(struct session
*);
2749 void server_lock_client(struct client
*);
2750 void server_kill_pane(struct window_pane
*);
2751 void server_kill_window(struct window
*, int);
2752 void server_renumber_session(struct session
*);
2753 void server_renumber_all(void);
2754 int server_link_window(struct session
*,
2755 struct winlink
*, struct session
*, int, int, int, char **);
2756 void server_unlink_window(struct session
*, struct winlink
*);
2757 void server_destroy_pane(struct window_pane
*, int);
2758 void server_destroy_session(struct session
*);
2759 void server_check_unattached(void);
2760 void server_unzoom_window(struct window
*);
2763 extern char **status_prompt_hlist
[];
2764 extern u_int status_prompt_hsize
[];
2765 void status_timer_start(struct client
*);
2766 void status_timer_start_all(void);
2767 void status_update_cache(struct session
*);
2768 int status_at_line(struct client
*);
2769 u_int
status_line_size(struct client
*);
2770 struct style_range
*status_get_range(struct client
*, u_int
, u_int
);
2771 void status_init(struct client
*);
2772 void status_free(struct client
*);
2773 int status_redraw(struct client
*);
2774 void printflike(5, 6) status_message_set(struct client
*, int, int, int,
2776 void status_message_clear(struct client
*);
2777 int status_message_redraw(struct client
*);
2778 void status_prompt_set(struct client
*, struct cmd_find_state
*,
2779 const char *, const char *, prompt_input_cb
, prompt_free_cb
,
2780 void *, int, enum prompt_type
);
2781 void status_prompt_clear(struct client
*);
2782 int status_prompt_redraw(struct client
*);
2783 int status_prompt_key(struct client
*, key_code
);
2784 void status_prompt_update(struct client
*, const char *, const char *);
2785 void status_prompt_load_history(void);
2786 void status_prompt_save_history(void);
2787 const char *status_prompt_type_string(u_int
);
2788 enum prompt_type
status_prompt_type(const char *type
);
2791 void resize_window(struct window
*, u_int
, u_int
, int, int);
2792 void default_window_size(struct client
*, struct session
*, struct window
*,
2793 u_int
*, u_int
*, u_int
*, u_int
*, int);
2794 void recalculate_size(struct window
*, int);
2795 void recalculate_sizes(void);
2796 void recalculate_sizes_now(int);
2799 struct input_ctx
*input_init(struct window_pane
*, struct bufferevent
*,
2800 struct colour_palette
*);
2801 void input_free(struct input_ctx
*);
2802 void input_reset(struct input_ctx
*, int);
2803 struct evbuffer
*input_pending(struct input_ctx
*);
2804 void input_parse_pane(struct window_pane
*);
2805 void input_parse_buffer(struct window_pane
*, u_char
*, size_t);
2806 void input_parse_screen(struct input_ctx
*, struct screen
*,
2807 screen_write_init_ctx_cb
, void *, u_char
*, size_t);
2808 void input_reply_clipboard(struct bufferevent
*, const char *, size_t,
2812 void input_key_build(void);
2813 int input_key_pane(struct window_pane
*, key_code
, struct mouse_event
*);
2814 int input_key(struct screen
*, struct bufferevent
*, key_code
);
2815 int input_key_get_mouse(struct screen
*, struct mouse_event
*, u_int
,
2816 u_int
, const char **, size_t *);
2819 int colour_find_rgb(u_char
, u_char
, u_char
);
2820 int colour_join_rgb(u_char
, u_char
, u_char
);
2821 void colour_split_rgb(int, u_char
*, u_char
*, u_char
*);
2822 int colour_force_rgb(int);
2823 const char *colour_tostring(int);
2824 int colour_fromstring(const char *s
);
2825 int colour_256toRGB(int);
2826 int colour_256to16(int);
2827 int colour_byname(const char *);
2828 int colour_parseX11(const char *);
2829 void colour_palette_init(struct colour_palette
*);
2830 void colour_palette_clear(struct colour_palette
*);
2831 void colour_palette_free(struct colour_palette
*);
2832 int colour_palette_get(struct colour_palette
*, int);
2833 int colour_palette_set(struct colour_palette
*, int, int);
2834 void colour_palette_from_option(struct colour_palette
*, struct options
*);
2837 const char *attributes_tostring(int);
2838 int attributes_fromstring(const char *);
2841 extern const struct grid_cell grid_default_cell
;
2842 void grid_empty_line(struct grid
*, u_int
, u_int
);
2843 int grid_cells_equal(const struct grid_cell
*, const struct grid_cell
*);
2844 int grid_cells_look_equal(const struct grid_cell
*,
2845 const struct grid_cell
*);
2846 struct grid
*grid_create(u_int
, u_int
, u_int
);
2847 void grid_destroy(struct grid
*);
2848 int grid_compare(struct grid
*, struct grid
*);
2849 void grid_collect_history(struct grid
*);
2850 void grid_remove_history(struct grid
*, u_int
);
2851 void grid_scroll_history(struct grid
*, u_int
);
2852 void grid_scroll_history_region(struct grid
*, u_int
, u_int
, u_int
);
2853 void grid_clear_history(struct grid
*);
2854 const struct grid_line
*grid_peek_line(struct grid
*, u_int
);
2855 void grid_get_cell(struct grid
*, u_int
, u_int
, struct grid_cell
*);
2856 void grid_set_cell(struct grid
*, u_int
, u_int
, const struct grid_cell
*);
2857 void grid_set_padding(struct grid
*, u_int
, u_int
);
2858 void grid_set_cells(struct grid
*, u_int
, u_int
, const struct grid_cell
*,
2859 const char *, size_t);
2860 struct grid_line
*grid_get_line(struct grid
*, u_int
);
2861 void grid_adjust_lines(struct grid
*, u_int
);
2862 void grid_clear(struct grid
*, u_int
, u_int
, u_int
, u_int
, u_int
);
2863 void grid_clear_lines(struct grid
*, u_int
, u_int
, u_int
);
2864 void grid_move_lines(struct grid
*, u_int
, u_int
, u_int
, u_int
);
2865 void grid_move_cells(struct grid
*, u_int
, u_int
, u_int
, u_int
, u_int
);
2866 char *grid_string_cells(struct grid
*, u_int
, u_int
, u_int
,
2867 struct grid_cell
**, int, struct screen
*);
2868 void grid_duplicate_lines(struct grid
*, u_int
, struct grid
*, u_int
,
2870 void grid_reflow(struct grid
*, u_int
);
2871 void grid_wrap_position(struct grid
*, u_int
, u_int
, u_int
*, u_int
*);
2872 void grid_unwrap_position(struct grid
*, u_int
*, u_int
*, u_int
, u_int
);
2873 u_int
grid_line_length(struct grid
*, u_int
);
2876 void grid_reader_start(struct grid_reader
*, struct grid
*, u_int
, u_int
);
2877 void grid_reader_get_cursor(struct grid_reader
*, u_int
*, u_int
*);
2878 u_int
grid_reader_line_length(struct grid_reader
*);
2879 int grid_reader_in_set(struct grid_reader
*, const char *);
2880 void grid_reader_cursor_right(struct grid_reader
*, int, int);
2881 void grid_reader_cursor_left(struct grid_reader
*, int);
2882 void grid_reader_cursor_down(struct grid_reader
*);
2883 void grid_reader_cursor_up(struct grid_reader
*);
2884 void grid_reader_cursor_start_of_line(struct grid_reader
*, int);
2885 void grid_reader_cursor_end_of_line(struct grid_reader
*, int, int);
2886 void grid_reader_cursor_next_word(struct grid_reader
*, const char *);
2887 void grid_reader_cursor_next_word_end(struct grid_reader
*, const char *);
2888 void grid_reader_cursor_previous_word(struct grid_reader
*, const char *,
2890 int grid_reader_cursor_jump(struct grid_reader
*,
2891 const struct utf8_data
*);
2892 int grid_reader_cursor_jump_back(struct grid_reader
*,
2893 const struct utf8_data
*);
2894 void grid_reader_cursor_back_to_indentation(struct grid_reader
*);
2897 void grid_view_get_cell(struct grid
*, u_int
, u_int
, struct grid_cell
*);
2898 void grid_view_set_cell(struct grid
*, u_int
, u_int
,
2899 const struct grid_cell
*);
2900 void grid_view_set_padding(struct grid
*, u_int
, u_int
);
2901 void grid_view_set_cells(struct grid
*, u_int
, u_int
,
2902 const struct grid_cell
*, const char *, size_t);
2903 void grid_view_clear_history(struct grid
*, u_int
);
2904 void grid_view_clear(struct grid
*, u_int
, u_int
, u_int
, u_int
, u_int
);
2905 void grid_view_scroll_region_up(struct grid
*, u_int
, u_int
, u_int
);
2906 void grid_view_scroll_region_down(struct grid
*, u_int
, u_int
, u_int
);
2907 void grid_view_insert_lines(struct grid
*, u_int
, u_int
, u_int
);
2908 void grid_view_insert_lines_region(struct grid
*, u_int
, u_int
, u_int
,
2910 void grid_view_delete_lines(struct grid
*, u_int
, u_int
, u_int
);
2911 void grid_view_delete_lines_region(struct grid
*, u_int
, u_int
, u_int
,
2913 void grid_view_insert_cells(struct grid
*, u_int
, u_int
, u_int
, u_int
);
2914 void grid_view_delete_cells(struct grid
*, u_int
, u_int
, u_int
, u_int
);
2915 char *grid_view_string_cells(struct grid
*, u_int
, u_int
, u_int
);
2917 /* screen-write.c */
2918 void screen_write_make_list(struct screen
*);
2919 void screen_write_free_list(struct screen
*);
2920 void screen_write_start_pane(struct screen_write_ctx
*,
2921 struct window_pane
*, struct screen
*);
2922 void screen_write_start(struct screen_write_ctx
*, struct screen
*);
2923 void screen_write_start_callback(struct screen_write_ctx
*, struct screen
*,
2924 screen_write_init_ctx_cb
, void *);
2925 void screen_write_stop(struct screen_write_ctx
*);
2926 void screen_write_reset(struct screen_write_ctx
*);
2927 size_t printflike(1, 2) screen_write_strlen(const char *, ...);
2928 int printflike(7, 8) screen_write_text(struct screen_write_ctx
*, u_int
, u_int
,
2929 u_int
, int, const struct grid_cell
*, const char *, ...);
2930 void printflike(3, 4) screen_write_puts(struct screen_write_ctx
*,
2931 const struct grid_cell
*, const char *, ...);
2932 void printflike(4, 5) screen_write_nputs(struct screen_write_ctx
*,
2933 ssize_t
, const struct grid_cell
*, const char *, ...);
2934 void printflike(4, 0) screen_write_vnputs(struct screen_write_ctx
*, ssize_t
,
2935 const struct grid_cell
*, const char *, va_list);
2936 void screen_write_putc(struct screen_write_ctx
*, const struct grid_cell
*,
2938 void screen_write_fast_copy(struct screen_write_ctx
*, struct screen
*,
2939 u_int
, u_int
, u_int
, u_int
);
2940 void screen_write_hline(struct screen_write_ctx
*, u_int
, int, int,
2941 enum box_lines
, const struct grid_cell
*);
2942 void screen_write_vline(struct screen_write_ctx
*, u_int
, int, int);
2943 void screen_write_menu(struct screen_write_ctx
*, struct menu
*, int,
2944 enum box_lines
, const struct grid_cell
*, const struct grid_cell
*,
2945 const struct grid_cell
*);
2946 void screen_write_box(struct screen_write_ctx
*, u_int
, u_int
,
2947 enum box_lines
, const struct grid_cell
*, const char *);
2948 void screen_write_preview(struct screen_write_ctx
*, struct screen
*, u_int
,
2950 void screen_write_backspace(struct screen_write_ctx
*);
2951 void screen_write_mode_set(struct screen_write_ctx
*, int);
2952 void screen_write_mode_clear(struct screen_write_ctx
*, int);
2953 void screen_write_cursorup(struct screen_write_ctx
*, u_int
);
2954 void screen_write_cursordown(struct screen_write_ctx
*, u_int
);
2955 void screen_write_cursorright(struct screen_write_ctx
*, u_int
);
2956 void screen_write_cursorleft(struct screen_write_ctx
*, u_int
);
2957 void screen_write_alignmenttest(struct screen_write_ctx
*);
2958 void screen_write_insertcharacter(struct screen_write_ctx
*, u_int
, u_int
);
2959 void screen_write_deletecharacter(struct screen_write_ctx
*, u_int
, u_int
);
2960 void screen_write_clearcharacter(struct screen_write_ctx
*, u_int
, u_int
);
2961 void screen_write_insertline(struct screen_write_ctx
*, u_int
, u_int
);
2962 void screen_write_deleteline(struct screen_write_ctx
*, u_int
, u_int
);
2963 void screen_write_clearline(struct screen_write_ctx
*, u_int
);
2964 void screen_write_clearendofline(struct screen_write_ctx
*, u_int
);
2965 void screen_write_clearstartofline(struct screen_write_ctx
*, u_int
);
2966 void screen_write_cursormove(struct screen_write_ctx
*, int, int, int);
2967 void screen_write_reverseindex(struct screen_write_ctx
*, u_int
);
2968 void screen_write_scrollregion(struct screen_write_ctx
*, u_int
, u_int
);
2969 void screen_write_linefeed(struct screen_write_ctx
*, int, u_int
);
2970 void screen_write_scrollup(struct screen_write_ctx
*, u_int
, u_int
);
2971 void screen_write_scrolldown(struct screen_write_ctx
*, u_int
, u_int
);
2972 void screen_write_carriagereturn(struct screen_write_ctx
*);
2973 void screen_write_clearendofscreen(struct screen_write_ctx
*, u_int
);
2974 void screen_write_clearstartofscreen(struct screen_write_ctx
*, u_int
);
2975 void screen_write_clearscreen(struct screen_write_ctx
*, u_int
);
2976 void screen_write_clearhistory(struct screen_write_ctx
*);
2977 void screen_write_fullredraw(struct screen_write_ctx
*);
2978 void screen_write_collect_end(struct screen_write_ctx
*);
2979 void screen_write_collect_add(struct screen_write_ctx
*,
2980 const struct grid_cell
*);
2981 void screen_write_cell(struct screen_write_ctx
*, const struct grid_cell
*);
2982 void screen_write_setselection(struct screen_write_ctx
*, const char *,
2984 void screen_write_rawstring(struct screen_write_ctx
*, u_char
*, u_int
,
2986 void screen_write_alternateon(struct screen_write_ctx
*,
2987 struct grid_cell
*, int);
2988 void screen_write_alternateoff(struct screen_write_ctx
*,
2989 struct grid_cell
*, int);
2991 /* screen-redraw.c */
2992 void screen_redraw_screen(struct client
*);
2993 void screen_redraw_pane(struct client
*, struct window_pane
*);
2996 void screen_init(struct screen
*, u_int
, u_int
, u_int
);
2997 void screen_reinit(struct screen
*);
2998 void screen_free(struct screen
*);
2999 void screen_reset_tabs(struct screen
*);
3000 void screen_reset_hyperlinks(struct screen
*);
3001 void screen_set_cursor_style(u_int
, enum screen_cursor_style
*, int *);
3002 void screen_set_cursor_colour(struct screen
*, int);
3003 int screen_set_title(struct screen
*, const char *);
3004 void screen_set_path(struct screen
*, const char *);
3005 void screen_push_title(struct screen
*);
3006 void screen_pop_title(struct screen
*);
3007 void screen_resize(struct screen
*, u_int
, u_int
, int);
3008 void screen_resize_cursor(struct screen
*, u_int
, u_int
, int, int, int);
3009 void screen_set_selection(struct screen
*, u_int
, u_int
, u_int
, u_int
,
3010 u_int
, int, struct grid_cell
*);
3011 void screen_clear_selection(struct screen
*);
3012 void screen_hide_selection(struct screen
*);
3013 int screen_check_selection(struct screen
*, u_int
, u_int
);
3014 void screen_select_cell(struct screen
*, struct grid_cell
*,
3015 const struct grid_cell
*);
3016 void screen_alternate_on(struct screen
*, struct grid_cell
*, int);
3017 void screen_alternate_off(struct screen
*, struct grid_cell
*, int);
3018 const char *screen_mode_to_string(int);
3021 extern struct windows windows
;
3022 extern struct window_pane_tree all_window_panes
;
3023 int window_cmp(struct window
*, struct window
*);
3024 RB_PROTOTYPE(windows
, window
, entry
, window_cmp
);
3025 int winlink_cmp(struct winlink
*, struct winlink
*);
3026 RB_PROTOTYPE(winlinks
, winlink
, entry
, winlink_cmp
);
3027 int window_pane_cmp(struct window_pane
*, struct window_pane
*);
3028 RB_PROTOTYPE(window_pane_tree
, window_pane
, tree_entry
, window_pane_cmp
);
3029 struct winlink
*winlink_find_by_index(struct winlinks
*, int);
3030 struct winlink
*winlink_find_by_window(struct winlinks
*, struct window
*);
3031 struct winlink
*winlink_find_by_window_id(struct winlinks
*, u_int
);
3032 u_int
winlink_count(struct winlinks
*);
3033 struct winlink
*winlink_add(struct winlinks
*, int);
3034 void winlink_set_window(struct winlink
*, struct window
*);
3035 void winlink_remove(struct winlinks
*, struct winlink
*);
3036 struct winlink
*winlink_next(struct winlink
*);
3037 struct winlink
*winlink_previous(struct winlink
*);
3038 struct winlink
*winlink_next_by_number(struct winlink
*, struct session
*,
3040 struct winlink
*winlink_previous_by_number(struct winlink
*, struct session
*,
3042 void winlink_stack_push(struct winlink_stack
*, struct winlink
*);
3043 void winlink_stack_remove(struct winlink_stack
*, struct winlink
*);
3044 struct window
*window_find_by_id_str(const char *);
3045 struct window
*window_find_by_id(u_int
);
3046 void window_update_activity(struct window
*);
3047 struct window
*window_create(u_int
, u_int
, u_int
, u_int
);
3048 void window_pane_set_event(struct window_pane
*);
3049 struct window_pane
*window_get_active_at(struct window
*, u_int
, u_int
);
3050 struct window_pane
*window_find_string(struct window
*, const char *);
3051 int window_has_pane(struct window
*, struct window_pane
*);
3052 int window_set_active_pane(struct window
*, struct window_pane
*,
3054 void window_update_focus(struct window
*);
3055 void window_pane_update_focus(struct window_pane
*);
3056 void window_redraw_active_switch(struct window
*,
3057 struct window_pane
*);
3058 struct window_pane
*window_add_pane(struct window
*, struct window_pane
*,
3060 void window_resize(struct window
*, u_int
, u_int
, int, int);
3061 void window_pane_send_resize(struct window_pane
*, u_int
, u_int
);
3062 int window_zoom(struct window_pane
*);
3063 int window_unzoom(struct window
*, int);
3064 int window_push_zoom(struct window
*, int, int);
3065 int window_pop_zoom(struct window
*);
3066 void window_lost_pane(struct window
*, struct window_pane
*);
3067 void window_remove_pane(struct window
*, struct window_pane
*);
3068 struct window_pane
*window_pane_at_index(struct window
*, u_int
);
3069 struct window_pane
*window_pane_next_by_number(struct window
*,
3070 struct window_pane
*, u_int
);
3071 struct window_pane
*window_pane_previous_by_number(struct window
*,
3072 struct window_pane
*, u_int
);
3073 int window_pane_index(struct window_pane
*, u_int
*);
3074 u_int
window_count_panes(struct window
*);
3075 void window_destroy_panes(struct window
*);
3076 struct window_pane
*window_pane_find_by_id_str(const char *);
3077 struct window_pane
*window_pane_find_by_id(u_int
);
3078 int window_pane_destroy_ready(struct window_pane
*);
3079 void window_pane_resize(struct window_pane
*, u_int
, u_int
);
3080 int window_pane_set_mode(struct window_pane
*,
3081 struct window_pane
*, const struct window_mode
*,
3082 struct cmd_find_state
*, struct args
*);
3083 void window_pane_reset_mode(struct window_pane
*);
3084 void window_pane_reset_mode_all(struct window_pane
*);
3085 int window_pane_key(struct window_pane
*, struct client
*,
3086 struct session
*, struct winlink
*, key_code
,
3087 struct mouse_event
*);
3088 int window_pane_visible(struct window_pane
*);
3089 int window_pane_exited(struct window_pane
*);
3090 u_int
window_pane_search(struct window_pane
*, const char *, int,
3092 const char *window_printable_flags(struct winlink
*, int);
3093 struct window_pane
*window_pane_find_up(struct window_pane
*);
3094 struct window_pane
*window_pane_find_down(struct window_pane
*);
3095 struct window_pane
*window_pane_find_left(struct window_pane
*);
3096 struct window_pane
*window_pane_find_right(struct window_pane
*);
3097 void window_pane_stack_push(struct window_panes
*,
3098 struct window_pane
*);
3099 void window_pane_stack_remove(struct window_panes
*,
3100 struct window_pane
*);
3101 void window_set_name(struct window
*, const char *);
3102 void window_add_ref(struct window
*, const char *);
3103 void window_remove_ref(struct window
*, const char *);
3104 void winlink_clear_flags(struct winlink
*);
3105 int winlink_shuffle_up(struct session
*, struct winlink
*, int);
3106 int window_pane_start_input(struct window_pane
*,
3107 struct cmdq_item
*, char **);
3108 void *window_pane_get_new_data(struct window_pane
*,
3109 struct window_pane_offset
*, size_t *);
3110 void window_pane_update_used_data(struct window_pane
*,
3111 struct window_pane_offset
*, size_t);
3112 void window_set_fill_character(struct window
*);
3113 void window_pane_default_cursor(struct window_pane
*);
3116 u_int
layout_count_cells(struct layout_cell
*);
3117 struct layout_cell
*layout_create_cell(struct layout_cell
*);
3118 void layout_free_cell(struct layout_cell
*);
3119 void layout_print_cell(struct layout_cell
*, const char *, u_int
);
3120 void layout_destroy_cell(struct window
*, struct layout_cell
*,
3121 struct layout_cell
**);
3122 void layout_resize_layout(struct window
*, struct layout_cell
*,
3123 enum layout_type
, int, int);
3124 struct layout_cell
*layout_search_by_border(struct layout_cell
*, u_int
, u_int
);
3125 void layout_set_size(struct layout_cell
*, u_int
, u_int
, u_int
,
3127 void layout_make_leaf(struct layout_cell
*, struct window_pane
*);
3128 void layout_make_node(struct layout_cell
*, enum layout_type
);
3129 void layout_fix_offsets(struct window
*);
3130 void layout_fix_panes(struct window
*, struct window_pane
*);
3131 void layout_resize_adjust(struct window
*, struct layout_cell
*,
3132 enum layout_type
, int);
3133 void layout_init(struct window
*, struct window_pane
*);
3134 void layout_free(struct window
*);
3135 void layout_resize(struct window
*, u_int
, u_int
);
3136 void layout_resize_pane(struct window_pane
*, enum layout_type
,
3138 void layout_resize_pane_to(struct window_pane
*, enum layout_type
,
3140 void layout_assign_pane(struct layout_cell
*, struct window_pane
*,
3142 struct layout_cell
*layout_split_pane(struct window_pane
*, enum layout_type
,
3144 void layout_close_pane(struct window_pane
*);
3145 int layout_spread_cell(struct window
*, struct layout_cell
*);
3146 void layout_spread_out(struct window_pane
*);
3148 /* layout-custom.c */
3149 char *layout_dump(struct layout_cell
*);
3150 int layout_parse(struct window
*, const char *, char **);
3153 int layout_set_lookup(const char *);
3154 u_int
layout_set_select(struct window
*, u_int
);
3155 u_int
layout_set_next(struct window
*);
3156 u_int
layout_set_previous(struct window
*);
3159 typedef void (*mode_tree_build_cb
)(void *, struct mode_tree_sort_criteria
*,
3160 uint64_t *, const char *);
3161 typedef void (*mode_tree_draw_cb
)(void *, void *, struct screen_write_ctx
*,
3163 typedef int (*mode_tree_search_cb
)(void *, void *, const char *);
3164 typedef void (*mode_tree_menu_cb
)(void *, struct client
*, key_code
);
3165 typedef u_int (*mode_tree_height_cb
)(void *, u_int
);
3166 typedef key_code (*mode_tree_key_cb
)(void *, void *, u_int
);
3167 typedef void (*mode_tree_each_cb
)(void *, void *, struct client
*, key_code
);
3168 u_int
mode_tree_count_tagged(struct mode_tree_data
*);
3169 void *mode_tree_get_current(struct mode_tree_data
*);
3170 const char *mode_tree_get_current_name(struct mode_tree_data
*);
3171 void mode_tree_expand_current(struct mode_tree_data
*);
3172 void mode_tree_collapse_current(struct mode_tree_data
*);
3173 void mode_tree_expand(struct mode_tree_data
*, uint64_t);
3174 int mode_tree_set_current(struct mode_tree_data
*, uint64_t);
3175 void mode_tree_each_tagged(struct mode_tree_data
*, mode_tree_each_cb
,
3176 struct client
*, key_code
, int);
3177 void mode_tree_up(struct mode_tree_data
*, int);
3178 int mode_tree_down(struct mode_tree_data
*, int);
3179 struct mode_tree_data
*mode_tree_start(struct window_pane
*, struct args
*,
3180 mode_tree_build_cb
, mode_tree_draw_cb
, mode_tree_search_cb
,
3181 mode_tree_menu_cb
, mode_tree_height_cb
, mode_tree_key_cb
, void *,
3182 const struct menu_item
*, const char **, u_int
, struct screen
**);
3183 void mode_tree_zoom(struct mode_tree_data
*, struct args
*);
3184 void mode_tree_build(struct mode_tree_data
*);
3185 void mode_tree_free(struct mode_tree_data
*);
3186 void mode_tree_resize(struct mode_tree_data
*, u_int
, u_int
);
3187 struct mode_tree_item
*mode_tree_add(struct mode_tree_data
*,
3188 struct mode_tree_item
*, void *, uint64_t, const char *,
3190 void mode_tree_draw_as_parent(struct mode_tree_item
*);
3191 void mode_tree_no_tag(struct mode_tree_item
*);
3192 void mode_tree_remove(struct mode_tree_data
*, struct mode_tree_item
*);
3193 void mode_tree_draw(struct mode_tree_data
*);
3194 int mode_tree_key(struct mode_tree_data
*, struct client
*, key_code
*,
3195 struct mouse_event
*, u_int
*, u_int
*);
3196 void mode_tree_run_command(struct client
*, struct cmd_find_state
*,
3197 const char *, const char *);
3199 /* window-buffer.c */
3200 extern const struct window_mode window_buffer_mode
;
3203 extern const struct window_mode window_tree_mode
;
3205 /* window-clock.c */
3206 extern const struct window_mode window_clock_mode
;
3207 extern const char window_clock_table
[14][5][5];
3209 /* window-client.c */
3210 extern const struct window_mode window_client_mode
;
3213 extern const struct window_mode window_copy_mode
;
3214 extern const struct window_mode window_view_mode
;
3215 void printflike(3, 4) window_copy_add(struct window_pane
*, int, const char *,
3217 void printflike(3, 0) window_copy_vadd(struct window_pane
*, int, const char *,
3219 void window_copy_pageup(struct window_pane
*, int);
3220 void window_copy_start_drag(struct client
*, struct mouse_event
*);
3221 char *window_copy_get_word(struct window_pane
*, u_int
, u_int
);
3222 char *window_copy_get_line(struct window_pane
*, u_int
);
3224 /* window-option.c */
3225 extern const struct window_mode window_customize_mode
;
3228 void check_window_name(struct window
*);
3229 char *default_window_name(struct window
*);
3230 char *parse_window_name(const char *);
3233 void control_discard(struct client
*);
3234 void control_start(struct client
*);
3235 void control_ready(struct client
*);
3236 void control_stop(struct client
*);
3237 void control_set_pane_on(struct client
*, struct window_pane
*);
3238 void control_set_pane_off(struct client
*, struct window_pane
*);
3239 void control_continue_pane(struct client
*, struct window_pane
*);
3240 void control_pause_pane(struct client
*, struct window_pane
*);
3241 struct window_pane_offset
*control_pane_offset(struct client
*,
3242 struct window_pane
*, int *);
3243 void control_reset_offsets(struct client
*);
3244 void printflike(2, 3) control_write(struct client
*, const char *, ...);
3245 void control_write_output(struct client
*, struct window_pane
*);
3246 int control_all_done(struct client
*);
3247 void control_add_sub(struct client
*, const char *, enum control_sub_type
,
3249 void control_remove_sub(struct client
*, const char *);
3251 /* control-notify.c */
3252 void control_notify_pane_mode_changed(int);
3253 void control_notify_window_layout_changed(struct window
*);
3254 void control_notify_window_pane_changed(struct window
*);
3255 void control_notify_window_unlinked(struct session
*, struct window
*);
3256 void control_notify_window_linked(struct session
*, struct window
*);
3257 void control_notify_window_renamed(struct window
*);
3258 void control_notify_client_session_changed(struct client
*);
3259 void control_notify_client_detached(struct client
*);
3260 void control_notify_session_renamed(struct session
*);
3261 void control_notify_session_created(struct session
*);
3262 void control_notify_session_closed(struct session
*);
3263 void control_notify_session_window_changed(struct session
*);
3264 void control_notify_paste_buffer_changed(const char *);
3265 void control_notify_paste_buffer_deleted(const char *);
3268 extern struct sessions sessions
;
3269 extern u_int next_session_id
;
3270 int session_cmp(struct session
*, struct session
*);
3271 RB_PROTOTYPE(sessions
, session
, entry
, session_cmp
);
3272 int session_alive(struct session
*);
3273 struct session
*session_find(const char *);
3274 struct session
*session_find_by_id_str(const char *);
3275 struct session
*session_find_by_id(u_int
);
3276 struct session
*session_create(const char *, const char *, const char *,
3277 struct environ
*, struct options
*, struct termios
*);
3278 void session_destroy(struct session
*, int, const char *);
3279 void session_add_ref(struct session
*, const char *);
3280 void session_remove_ref(struct session
*, const char *);
3281 char *session_check_name(const char *);
3282 void session_update_activity(struct session
*, struct timeval
*);
3283 struct session
*session_next_session(struct session
*);
3284 struct session
*session_previous_session(struct session
*);
3285 struct winlink
*session_attach(struct session
*, struct window
*, int,
3287 int session_detach(struct session
*, struct winlink
*);
3288 int session_has(struct session
*, struct window
*);
3289 int session_is_linked(struct session
*, struct window
*);
3290 int session_next(struct session
*, int);
3291 int session_previous(struct session
*, int);
3292 int session_select(struct session
*, int);
3293 int session_last(struct session
*);
3294 int session_set_current(struct session
*, struct winlink
*);
3295 struct session_group
*session_group_contains(struct session
*);
3296 struct session_group
*session_group_find(const char *);
3297 struct session_group
*session_group_new(const char *);
3298 void session_group_add(struct session_group
*, struct session
*);
3299 void session_group_synchronize_to(struct session
*);
3300 void session_group_synchronize_from(struct session
*);
3301 u_int
session_group_count(struct session_group
*);
3302 u_int
session_group_attached_count(struct session_group
*);
3303 void session_renumber_windows(struct session
*);
3306 enum utf8_state
utf8_towc (const struct utf8_data
*, wchar_t *);
3307 enum utf8_state
utf8_fromwc(wchar_t wc
, struct utf8_data
*);
3308 int utf8_in_table(wchar_t, const wchar_t *, u_int
);
3309 utf8_char
utf8_build_one(u_char
);
3310 enum utf8_state
utf8_from_data(const struct utf8_data
*, utf8_char
*);
3311 void utf8_to_data(utf8_char
, struct utf8_data
*);
3312 void utf8_set(struct utf8_data
*, u_char
);
3313 void utf8_copy(struct utf8_data
*, const struct utf8_data
*);
3314 enum utf8_state
utf8_open(struct utf8_data
*, u_char
);
3315 enum utf8_state
utf8_append(struct utf8_data
*, u_char
);
3316 int utf8_isvalid(const char *);
3317 int utf8_strvis(char *, const char *, size_t, int);
3318 int utf8_stravis(char **, const char *, int);
3319 int utf8_stravisx(char **, const char *, size_t, int);
3320 char *utf8_sanitize(const char *);
3321 size_t utf8_strlen(const struct utf8_data
*);
3322 u_int
utf8_strwidth(const struct utf8_data
*, ssize_t
);
3323 struct utf8_data
*utf8_fromcstr(const char *);
3324 char *utf8_tocstr(struct utf8_data
*);
3325 u_int
utf8_cstrwidth(const char *);
3326 char *utf8_padcstr(const char *, u_int
);
3327 char *utf8_rpadcstr(const char *, u_int
);
3328 int utf8_cstrhas(const char *, const struct utf8_data
*);
3330 /* utf8-combined.c */
3331 int utf8_has_zwj(const struct utf8_data
*);
3332 int utf8_is_zwj(const struct utf8_data
*);
3333 int utf8_is_vs(const struct utf8_data
*);
3334 int utf8_is_modifier(const struct utf8_data
*);
3337 char *get_proc_name(int, char *);
3338 char *get_proc_cwd(int);
3341 void log_add_level(void);
3342 int log_get_level(void);
3343 void log_open(const char *);
3344 void log_toggle(const char *);
3345 void log_close(void);
3346 void printflike(1, 2) log_debug(const char *, ...);
3347 __dead
void printflike(1, 2) fatal(const char *, ...);
3348 __dead
void printflike(1, 2) fatalx(const char *, ...);
3351 #define MENU_NOMOUSE 0x1
3352 #define MENU_TAB 0x2
3353 #define MENU_STAYOPEN 0x4
3354 struct menu
*menu_create(const char *);
3355 void menu_add_items(struct menu
*, const struct menu_item
*,
3356 struct cmdq_item
*, struct client
*,
3357 struct cmd_find_state
*);
3358 void menu_add_item(struct menu
*, const struct menu_item
*,
3359 struct cmdq_item
*, struct client
*,
3360 struct cmd_find_state
*);
3361 void menu_free(struct menu
*);
3362 struct menu_data
*menu_prepare(struct menu
*, int, int, struct cmdq_item
*,
3363 u_int
, u_int
, struct client
*, enum box_lines
, const char *,
3364 const char *, const char *, struct cmd_find_state
*,
3365 menu_choice_cb
, void *);
3366 int menu_display(struct menu
*, int, int, struct cmdq_item
*,
3367 u_int
, u_int
, struct client
*, enum box_lines
, const char *,
3368 const char *, const char *, struct cmd_find_state
*,
3369 menu_choice_cb
, void *);
3370 struct screen
*menu_mode_cb(struct client
*, void *, u_int
*, u_int
*);
3371 void menu_check_cb(struct client
*, void *, u_int
, u_int
, u_int
,
3372 struct overlay_ranges
*);
3373 void menu_draw_cb(struct client
*, void *,
3374 struct screen_redraw_ctx
*);
3375 void menu_free_cb(struct client
*, void *);
3376 int menu_key_cb(struct client
*, void *, struct key_event
*);
3379 #define POPUP_CLOSEEXIT 0x1
3380 #define POPUP_CLOSEEXITZERO 0x2
3381 #define POPUP_INTERNAL 0x4
3382 typedef void (*popup_close_cb
)(int, void *);
3383 typedef void (*popup_finish_edit_cb
)(char *, size_t, void *);
3384 int popup_display(int, enum box_lines
, struct cmdq_item
*, u_int
,
3385 u_int
, u_int
, u_int
, struct environ
*, const char *, int,
3386 char **, const char *, const char *, struct client
*,
3387 struct session
*, const char *, const char *,
3388 popup_close_cb
, void *);
3389 int popup_editor(struct client
*, const char *, size_t,
3390 popup_finish_edit_cb
, void *);
3393 int style_parse(struct style
*,const struct grid_cell
*,
3395 const char *style_tostring(struct style
*);
3396 void style_add(struct grid_cell
*, struct options
*,
3397 const char *, struct format_tree
*);
3398 void style_apply(struct grid_cell
*, struct options
*,
3399 const char *, struct format_tree
*);
3400 void style_set(struct style
*, const struct grid_cell
*);
3401 void style_copy(struct style
*, struct style
*);
3404 struct winlink
*spawn_window(struct spawn_context
*, char **);
3405 struct window_pane
*spawn_pane(struct spawn_context
*, char **);
3408 char *regsub(const char *, const char *, const char *, int);
3411 void server_acl_init(void);
3412 struct server_acl_user
*server_acl_user_find(uid_t
);
3413 void server_acl_display(struct cmdq_item
*);
3414 void server_acl_user_allow(uid_t
);
3415 void server_acl_user_deny(uid_t
);
3416 void server_acl_user_allow_write(uid_t
);
3417 void server_acl_user_deny_write(uid_t
);
3418 int server_acl_join(struct client
*);
3419 uid_t
server_acl_get_uid(struct server_acl_user
*);
3422 u_int
hyperlinks_put(struct hyperlinks
*, const char *,
3424 int hyperlinks_get(struct hyperlinks
*, u_int
,
3425 const char **, const char **, const char **);
3426 struct hyperlinks
*hyperlinks_init(void);
3427 void hyperlinks_reset(struct hyperlinks
*);
3428 void hyperlinks_free(struct hyperlinks
*);