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>
34 #include "tmux-protocol.h"
37 extern char **environ
;
40 struct args_command_state
;
43 struct cmd_find_state
;
50 struct format_job_tree
;
52 struct hyperlinks_uri
;
57 struct mode_tree_data
;
60 struct options_array_item
;
62 struct screen_write_citem
;
63 struct screen_write_cline
;
64 struct screen_write_ctx
;
73 /* Default configuration files and socket paths. */
75 #define TMUX_CONF "/etc/tmux.conf:~/.tmux.conf"
78 #define TMUX_SOCK "$TMUX_TMPDIR:" _PATH_TMP
81 #define TMUX_TERM "screen"
84 /* Minimum layout cell size, NOT including border lines. */
85 #define PANE_MINIMUM 1
87 /* Minimum and maximum window size. */
88 #define WINDOW_MINIMUM PANE_MINIMUM
89 #define WINDOW_MAXIMUM 10000
91 /* Automatic name refresh interval, in microseconds. Must be < 1 second. */
92 #define NAME_INTERVAL 500000
94 /* Default pixel cell sizes. */
95 #define DEFAULT_XPIXEL 16
96 #define DEFAULT_YPIXEL 32
98 /* Attribute to make GCC check printf-like arguments. */
99 #define printflike(a, b) __attribute__ ((format (printf, a, b)))
101 /* Number of items in array. */
103 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
106 /* Alert option values. */
109 #define ALERT_CURRENT 2
110 #define ALERT_OTHER 3
112 /* Visual option values. */
115 #define VISUAL_BOTH 2
117 /* No key or unknown key. */
118 #define KEYC_NONE 0x000ff000000000ULL
119 #define KEYC_UNKNOWN 0x000fe000000000ULL
122 * Base for special (that is, not Unicode) keys. An enum must be at most a
123 * signed int, so these are based in the highest Unicode PUA.
125 #define KEYC_BASE 0x0000000010e000ULL
126 #define KEYC_USER 0x0000000010f000ULL
128 /* Key modifier bits. */
129 #define KEYC_META 0x00100000000000ULL
130 #define KEYC_CTRL 0x00200000000000ULL
131 #define KEYC_SHIFT 0x00400000000000ULL
134 #define KEYC_LITERAL 0x01000000000000ULL
135 #define KEYC_KEYPAD 0x02000000000000ULL
136 #define KEYC_CURSOR 0x04000000000000ULL
137 #define KEYC_IMPLIED_META 0x08000000000000ULL
138 #define KEYC_BUILD_MODIFIERS 0x10000000000000ULL
139 #define KEYC_VI 0x20000000000000ULL
141 /* Masks for key bits. */
142 #define KEYC_MASK_MODIFIERS 0x00f00000000000ULL
143 #define KEYC_MASK_FLAGS 0xff000000000000ULL
144 #define KEYC_MASK_KEY 0x000fffffffffffULL
146 /* Available user keys. */
147 #define KEYC_NUSER 1000
149 /* Is this a mouse key? */
150 #define KEYC_IS_MOUSE(key) \
151 (((key) & KEYC_MASK_KEY) >= KEYC_MOUSE && \
152 ((key) & KEYC_MASK_KEY) < KEYC_BSPACE)
154 /* Is this a Unicode key? */
155 #define KEYC_IS_UNICODE(key) \
156 (((key) & KEYC_MASK_KEY) > 0x7f && \
157 (((key) & KEYC_MASK_KEY) < KEYC_BASE || \
158 ((key) & KEYC_MASK_KEY) >= KEYC_BASE_END))
160 /* Multiple click timeout. */
161 #define KEYC_CLICK_TIMEOUT 300
163 /* Mouse key codes. */
164 #define KEYC_MOUSE_KEY(name) \
165 KEYC_ ## name ## _PANE, \
166 KEYC_ ## name ## _STATUS, \
167 KEYC_ ## name ## _STATUS_LEFT, \
168 KEYC_ ## name ## _STATUS_RIGHT, \
169 KEYC_ ## name ## _STATUS_DEFAULT, \
170 KEYC_ ## name ## _BORDER
171 #define KEYC_MOUSE_STRING(name, s) \
172 { #s "Pane", KEYC_ ## name ## _PANE }, \
173 { #s "Status", KEYC_ ## name ## _STATUS }, \
174 { #s "StatusLeft", KEYC_ ## name ## _STATUS_LEFT }, \
175 { #s "StatusRight", KEYC_ ## name ## _STATUS_RIGHT }, \
176 { #s "StatusDefault", KEYC_ ## name ## _STATUS_DEFAULT }, \
177 { #s "Border", KEYC_ ## name ## _BORDER }
180 * A single key. This can be ASCII or Unicode or one of the keys between
181 * KEYC_BASE and KEYC_BASE_END.
183 typedef unsigned long long key_code
;
185 /* Special key codes. */
188 KEYC_FOCUS_IN
= KEYC_BASE
,
191 /* "Any" key, used if not found in key table. */
194 /* Paste brackets. */
199 KEYC_MOUSE
, /* unclassified mouse event */
200 KEYC_DRAGGING
, /* dragging in progress */
201 KEYC_DOUBLECLICK
, /* double click complete */
202 KEYC_MOUSE_KEY(MOUSEMOVE
),
203 KEYC_MOUSE_KEY(MOUSEDOWN1
),
204 KEYC_MOUSE_KEY(MOUSEDOWN2
),
205 KEYC_MOUSE_KEY(MOUSEDOWN3
),
206 KEYC_MOUSE_KEY(MOUSEDOWN6
),
207 KEYC_MOUSE_KEY(MOUSEDOWN7
),
208 KEYC_MOUSE_KEY(MOUSEDOWN8
),
209 KEYC_MOUSE_KEY(MOUSEDOWN9
),
210 KEYC_MOUSE_KEY(MOUSEDOWN10
),
211 KEYC_MOUSE_KEY(MOUSEDOWN11
),
212 KEYC_MOUSE_KEY(MOUSEUP1
),
213 KEYC_MOUSE_KEY(MOUSEUP2
),
214 KEYC_MOUSE_KEY(MOUSEUP3
),
215 KEYC_MOUSE_KEY(MOUSEUP6
),
216 KEYC_MOUSE_KEY(MOUSEUP7
),
217 KEYC_MOUSE_KEY(MOUSEUP8
),
218 KEYC_MOUSE_KEY(MOUSEUP9
),
219 KEYC_MOUSE_KEY(MOUSEUP10
),
220 KEYC_MOUSE_KEY(MOUSEUP11
),
221 KEYC_MOUSE_KEY(MOUSEDRAG1
),
222 KEYC_MOUSE_KEY(MOUSEDRAG2
),
223 KEYC_MOUSE_KEY(MOUSEDRAG3
),
224 KEYC_MOUSE_KEY(MOUSEDRAG6
),
225 KEYC_MOUSE_KEY(MOUSEDRAG7
),
226 KEYC_MOUSE_KEY(MOUSEDRAG8
),
227 KEYC_MOUSE_KEY(MOUSEDRAG9
),
228 KEYC_MOUSE_KEY(MOUSEDRAG10
),
229 KEYC_MOUSE_KEY(MOUSEDRAG11
),
230 KEYC_MOUSE_KEY(MOUSEDRAGEND1
),
231 KEYC_MOUSE_KEY(MOUSEDRAGEND2
),
232 KEYC_MOUSE_KEY(MOUSEDRAGEND3
),
233 KEYC_MOUSE_KEY(MOUSEDRAGEND6
),
234 KEYC_MOUSE_KEY(MOUSEDRAGEND7
),
235 KEYC_MOUSE_KEY(MOUSEDRAGEND8
),
236 KEYC_MOUSE_KEY(MOUSEDRAGEND9
),
237 KEYC_MOUSE_KEY(MOUSEDRAGEND10
),
238 KEYC_MOUSE_KEY(MOUSEDRAGEND11
),
239 KEYC_MOUSE_KEY(WHEELUP
),
240 KEYC_MOUSE_KEY(WHEELDOWN
),
241 KEYC_MOUSE_KEY(SECONDCLICK1
),
242 KEYC_MOUSE_KEY(SECONDCLICK2
),
243 KEYC_MOUSE_KEY(SECONDCLICK3
),
244 KEYC_MOUSE_KEY(SECONDCLICK6
),
245 KEYC_MOUSE_KEY(SECONDCLICK7
),
246 KEYC_MOUSE_KEY(SECONDCLICK8
),
247 KEYC_MOUSE_KEY(SECONDCLICK9
),
248 KEYC_MOUSE_KEY(SECONDCLICK10
),
249 KEYC_MOUSE_KEY(SECONDCLICK11
),
250 KEYC_MOUSE_KEY(DOUBLECLICK1
),
251 KEYC_MOUSE_KEY(DOUBLECLICK2
),
252 KEYC_MOUSE_KEY(DOUBLECLICK3
),
253 KEYC_MOUSE_KEY(DOUBLECLICK6
),
254 KEYC_MOUSE_KEY(DOUBLECLICK7
),
255 KEYC_MOUSE_KEY(DOUBLECLICK8
),
256 KEYC_MOUSE_KEY(DOUBLECLICK9
),
257 KEYC_MOUSE_KEY(DOUBLECLICK10
),
258 KEYC_MOUSE_KEY(DOUBLECLICK11
),
259 KEYC_MOUSE_KEY(TRIPLECLICK1
),
260 KEYC_MOUSE_KEY(TRIPLECLICK2
),
261 KEYC_MOUSE_KEY(TRIPLECLICK3
),
262 KEYC_MOUSE_KEY(TRIPLECLICK6
),
263 KEYC_MOUSE_KEY(TRIPLECLICK7
),
264 KEYC_MOUSE_KEY(TRIPLECLICK8
),
265 KEYC_MOUSE_KEY(TRIPLECLICK9
),
266 KEYC_MOUSE_KEY(TRIPLECLICK10
),
267 KEYC_MOUSE_KEY(TRIPLECLICK11
),
299 /* Numeric keypad. */
317 /* End of special keys. */
554 /* Character classes. */
555 #define WHITESPACE " "
558 #define MODEKEY_EMACS 0
562 #define MODE_CURSOR 0x1
563 #define MODE_INSERT 0x2
564 #define MODE_KCURSOR 0x4
565 #define MODE_KKEYPAD 0x8
566 #define MODE_WRAP 0x10
567 #define MODE_MOUSE_STANDARD 0x20
568 #define MODE_MOUSE_BUTTON 0x40
569 #define MODE_CURSOR_BLINKING 0x80
570 #define MODE_MOUSE_UTF8 0x100
571 #define MODE_MOUSE_SGR 0x200
572 #define MODE_BRACKETPASTE 0x400
573 #define MODE_FOCUSON 0x800
574 #define MODE_MOUSE_ALL 0x1000
575 #define MODE_ORIGIN 0x2000
576 #define MODE_CRLF 0x4000
577 #define MODE_KEXTENDED 0x8000
578 #define MODE_CURSOR_VERY_VISIBLE 0x10000
579 #define MODE_CURSOR_BLINKING_SET 0x20000
581 #define ALL_MODES 0xffffff
582 #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
583 #define MOTION_MOUSE_MODES (MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
584 #define CURSOR_MODES (MODE_CURSOR|MODE_CURSOR_BLINKING|MODE_CURSOR_VERY_VISIBLE)
586 /* Mouse protocol constants. */
587 #define MOUSE_PARAM_MAX 0xff
588 #define MOUSE_PARAM_UTF8_MAX 0x7ff
589 #define MOUSE_PARAM_BTN_OFF 0x20
590 #define MOUSE_PARAM_POS_OFF 0x21
592 /* A single UTF-8 character. */
593 typedef u_int utf8_char
;
596 * An expanded UTF-8 character. UTF8_SIZE must be big enough to hold combining
597 * characters as well. It can't be more than 32 bytes without changes to how
598 * characters are stored.
602 u_char data
[UTF8_SIZE
];
607 u_char width
; /* 0xff if invalid */
616 #define COLOUR_FLAG_256 0x01000000
617 #define COLOUR_FLAG_RGB 0x02000000
619 /* Special colours. */
620 #define COLOUR_DEFAULT(c) ((c) == 8 || (c) == 9)
622 /* Replacement palette. */
623 struct colour_palette
{
628 int *default_palette
;
631 /* Grid attributes. Anything above 0xff is stored in an extended cell. */
632 #define GRID_ATTR_BRIGHT 0x1
633 #define GRID_ATTR_DIM 0x2
634 #define GRID_ATTR_UNDERSCORE 0x4
635 #define GRID_ATTR_BLINK 0x8
636 #define GRID_ATTR_REVERSE 0x10
637 #define GRID_ATTR_HIDDEN 0x20
638 #define GRID_ATTR_ITALICS 0x40
639 #define GRID_ATTR_CHARSET 0x80 /* alternative character set */
640 #define GRID_ATTR_STRIKETHROUGH 0x100
641 #define GRID_ATTR_UNDERSCORE_2 0x200
642 #define GRID_ATTR_UNDERSCORE_3 0x400
643 #define GRID_ATTR_UNDERSCORE_4 0x800
644 #define GRID_ATTR_UNDERSCORE_5 0x1000
645 #define GRID_ATTR_OVERLINE 0x2000
647 /* All underscore attributes. */
648 #define GRID_ATTR_ALL_UNDERSCORE \
649 (GRID_ATTR_UNDERSCORE| \
650 GRID_ATTR_UNDERSCORE_2| \
651 GRID_ATTR_UNDERSCORE_3| \
652 GRID_ATTR_UNDERSCORE_4| \
653 GRID_ATTR_UNDERSCORE_5)
656 #define GRID_FLAG_FG256 0x1
657 #define GRID_FLAG_BG256 0x2
658 #define GRID_FLAG_PADDING 0x4
659 #define GRID_FLAG_EXTENDED 0x8
660 #define GRID_FLAG_SELECTED 0x10
661 #define GRID_FLAG_NOPALETTE 0x20
662 #define GRID_FLAG_CLEARED 0x40
664 /* Grid line flags. */
665 #define GRID_LINE_WRAPPED 0x1
666 #define GRID_LINE_EXTENDED 0x2
667 #define GRID_LINE_DEAD 0x4
669 #define CELL_INSIDE 0
670 #define CELL_TOPBOTTOM 1
671 #define CELL_LEFTRIGHT 2
672 #define CELL_TOPLEFT 3
673 #define CELL_TOPRIGHT 4
674 #define CELL_BOTTOMLEFT 5
675 #define CELL_BOTTOMRIGHT 6
676 #define CELL_TOPJOIN 7
677 #define CELL_BOTTOMJOIN 8
678 #define CELL_LEFTJOIN 9
679 #define CELL_RIGHTJOIN 10
681 #define CELL_OUTSIDE 12
683 #define CELL_BORDERS " xqlkmjwvtun~"
684 #define SIMPLE_BORDERS " |-+++++++++."
685 #define PADDED_BORDERS " "
687 /* Grid cell data. */
689 struct utf8_data data
;
698 /* Grid extended cell entry. */
699 struct grid_extd_entry
{
709 /* Grid cell entry. */
710 struct grid_cell_entry
{
725 struct grid_cell_entry
*celldata
;
729 struct grid_extd_entry
*extddata
;
736 /* Entire grid of cells. */
739 #define GRID_HISTORY 0x1 /* scroll lines into history */
748 struct grid_line
*linedata
;
751 /* Virtual cursor in a grid. */
758 /* Style alignment. */
764 STYLE_ALIGN_ABSOLUTE_CENTRE
772 STYLE_LIST_LEFT_MARKER
,
773 STYLE_LIST_RIGHT_MARKER
,
777 enum style_range_type
{
784 enum style_range_type type
;
788 u_int end
; /* not included */
790 TAILQ_ENTRY(style_range
) entry
;
792 TAILQ_HEAD(style_ranges
, style_range
);
795 enum style_default_type
{
807 enum style_align align
;
808 enum style_list list
;
810 enum style_range_type range_type
;
811 u_int range_argument
;
813 enum style_default_type default_type
;
817 enum screen_cursor_style
{
818 SCREEN_CURSOR_DEFAULT
,
820 SCREEN_CURSOR_UNDERLINE
,
824 /* Virtual screen. */
826 struct screen_titles
;
830 struct screen_titles
*titles
;
832 struct grid
*grid
; /* grid data */
834 u_int cx
; /* cursor x */
835 u_int cy
; /* cursor y */
837 enum screen_cursor_style cstyle
; /* cursor style */
838 enum screen_cursor_style default_cstyle
;
839 int ccolour
; /* cursor colour */
842 u_int rupper
; /* scroll region top */
843 u_int rlower
; /* scroll region bottom */
850 struct grid
*saved_grid
;
851 struct grid_cell saved_cell
;
855 struct screen_sel
*sel
;
857 struct screen_write_cline
*write_list
;
859 struct hyperlinks
*hyperlinks
;
862 /* Screen write context. */
863 typedef void (*screen_write_init_ctx_cb
)(struct screen_write_ctx
*,
865 struct screen_write_ctx
{
866 struct window_pane
*wp
;
870 #define SCREEN_WRITE_SYNC 0x1
871 #define SCREEN_WRITE_ZWJ 0x2
873 screen_write_init_ctx_cb init_ctx_cb
;
876 struct screen_write_citem
*item
;
881 /* Box border lines option. */
883 BOX_LINES_DEFAULT
= -1,
893 /* Pane border lines option. */
902 /* Pane border indicator option. */
903 #define PANE_BORDER_OFF 0
904 #define PANE_BORDER_COLOUR 1
905 #define PANE_BORDER_ARROWS 2
906 #define PANE_BORDER_BOTH 3
908 /* Screen redraw context. */
909 struct screen_redraw_ctx
{
916 enum pane_lines pane_lines
;
918 struct grid_cell no_pane_gc
;
928 #define screen_size_x(s) ((s)->grid->sx)
929 #define screen_size_y(s) ((s)->grid->sy)
930 #define screen_hsize(s) ((s)->grid->hsize)
931 #define screen_hlimit(s) ((s)->grid->hlimit)
941 struct menu_item
*items
;
945 typedef void (*menu_choice_cb
)(struct menu
*, u_int
, key_code
, void *);
948 * Window mode. Windows can be in several modes and this is used to call the
949 * right function to handle input and output.
951 struct window_mode_entry
;
954 const char *default_format
;
956 struct screen
*(*init
)(struct window_mode_entry
*,
957 struct cmd_find_state
*, struct args
*);
958 void (*free
)(struct window_mode_entry
*);
959 void (*resize
)(struct window_mode_entry
*, u_int
, u_int
);
960 void (*update
)(struct window_mode_entry
*);
961 void (*key
)(struct window_mode_entry
*, struct client
*,
962 struct session
*, struct winlink
*, key_code
,
963 struct mouse_event
*);
965 const char *(*key_table
)(struct window_mode_entry
*);
966 void (*command
)(struct window_mode_entry
*, struct client
*,
967 struct session
*, struct winlink
*, struct args
*,
968 struct mouse_event
*);
969 void (*formats
)(struct window_mode_entry
*,
970 struct format_tree
*);
973 /* Active window mode. */
974 struct window_mode_entry
{
975 struct window_pane
*wp
;
976 struct window_pane
*swp
;
978 const struct window_mode
*mode
;
981 struct screen
*screen
;
984 TAILQ_ENTRY(window_mode_entry
) entry
;
987 /* Offsets into pane buffer. */
988 struct window_pane_offset
{
992 /* Queued pane resize. */
993 struct window_pane_resize
{
1000 TAILQ_ENTRY(window_pane_resize
) entry
;
1002 TAILQ_HEAD(window_pane_resizes
, window_pane_resize
);
1004 /* Child window structure. */
1005 struct window_pane
{
1009 struct window
*window
;
1010 struct options
*options
;
1012 struct layout_cell
*layout_cell
;
1013 struct layout_cell
*saved_layout_cell
;
1022 #define PANE_REDRAW 0x1
1023 #define PANE_DROP 0x2
1024 #define PANE_FOCUSED 0x4
1028 #define PANE_INPUTOFF 0x40
1029 #define PANE_CHANGED 0x80
1030 #define PANE_EXITED 0x100
1031 #define PANE_STATUSREADY 0x200
1032 #define PANE_STATUSDRAWN 0x400
1033 #define PANE_EMPTY 0x800
1034 #define PANE_STYLECHANGED 0x1000
1042 char tty
[TTY_NAME_MAX
];
1044 struct timeval dead_time
;
1047 struct bufferevent
*event
;
1049 struct window_pane_offset offset
;
1052 struct window_pane_resizes resize_queue
;
1053 struct event resize_timer
;
1055 struct input_ctx
*ictx
;
1057 struct grid_cell cached_gc
;
1058 struct grid_cell cached_active_gc
;
1059 struct colour_palette palette
;
1062 struct bufferevent
*pipe_event
;
1063 struct window_pane_offset pipe_offset
;
1065 struct screen
*screen
;
1068 struct screen status_screen
;
1071 TAILQ_HEAD(, window_mode_entry
) modes
;
1077 struct grid_cell border_gc
;
1079 TAILQ_ENTRY(window_pane
) entry
;
1080 RB_ENTRY(window_pane
) tree_entry
;
1082 TAILQ_HEAD(window_panes
, window_pane
);
1083 RB_HEAD(window_pane_tree
, window_pane
);
1085 /* Window structure. */
1091 struct event name_event
;
1092 struct timeval name_time
;
1094 struct event alerts_timer
;
1095 struct event offset_timer
;
1097 struct timeval activity_time
;
1099 struct window_pane
*active
;
1100 struct window_pane
*last
;
1101 struct window_panes panes
;
1104 struct layout_cell
*layout_root
;
1105 struct layout_cell
*saved_layout_root
;
1120 struct utf8_data
*fill_character
;
1122 #define WINDOW_BELL 0x1
1123 #define WINDOW_ACTIVITY 0x2
1124 #define WINDOW_SILENCE 0x4
1125 #define WINDOW_ZOOMED 0x8
1126 #define WINDOW_WASZOOMED 0x10
1127 #define WINDOW_RESIZE 0x20
1128 #define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
1131 TAILQ_ENTRY(window
) alerts_entry
;
1133 struct options
*options
;
1136 TAILQ_HEAD(, winlink
) winlinks
;
1138 RB_ENTRY(window
) entry
;
1140 RB_HEAD(windows
, window
);
1142 /* Entry on local window list. */
1145 struct session
*session
;
1146 struct window
*window
;
1149 #define WINLINK_BELL 0x1
1150 #define WINLINK_ACTIVITY 0x2
1151 #define WINLINK_SILENCE 0x4
1152 #define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_SILENCE)
1154 RB_ENTRY(winlink
) entry
;
1155 TAILQ_ENTRY(winlink
) wentry
;
1156 TAILQ_ENTRY(winlink
) sentry
;
1158 RB_HEAD(winlinks
, winlink
);
1159 TAILQ_HEAD(winlink_stack
, winlink
);
1161 /* Window size option. */
1162 #define WINDOW_SIZE_LARGEST 0
1163 #define WINDOW_SIZE_SMALLEST 1
1164 #define WINDOW_SIZE_MANUAL 2
1165 #define WINDOW_SIZE_LATEST 3
1167 /* Pane border status option. */
1168 #define PANE_STATUS_OFF 0
1169 #define PANE_STATUS_TOP 1
1170 #define PANE_STATUS_BOTTOM 2
1172 /* Layout direction. */
1179 /* Layout cells queue. */
1180 TAILQ_HEAD(layout_cells
, layout_cell
);
1183 struct layout_cell
{
1184 enum layout_type type
;
1186 struct layout_cell
*parent
;
1194 struct window_pane
*wp
;
1195 struct layout_cells cells
;
1197 TAILQ_ENTRY(layout_cell
) entry
;
1200 /* Environment variable. */
1201 struct environ_entry
{
1206 #define ENVIRON_HIDDEN 0x1
1208 RB_ENTRY(environ_entry
) entry
;
1211 /* Client session. */
1212 struct session_group
{
1214 TAILQ_HEAD(, session
) sessions
;
1216 RB_ENTRY(session_group
) entry
;
1218 RB_HEAD(session_groups
, session_group
);
1226 struct timeval creation_time
;
1227 struct timeval last_attached_time
;
1228 struct timeval activity_time
;
1229 struct timeval last_activity_time
;
1231 struct event lock_timer
;
1233 struct winlink
*curw
;
1234 struct winlink_stack lastw
;
1235 struct winlinks windows
;
1240 struct options
*options
;
1242 #define SESSION_PASTING 0x1
1243 #define SESSION_ALERTED 0x2
1248 struct termios
*tio
;
1250 struct environ
*environ
;
1254 TAILQ_ENTRY(session
) gentry
;
1255 RB_ENTRY(session
) entry
;
1257 RB_HEAD(sessions
, session
);
1259 /* Mouse button masks. */
1260 #define MOUSE_MASK_BUTTONS 195
1261 #define MOUSE_MASK_SHIFT 4
1262 #define MOUSE_MASK_META 8
1263 #define MOUSE_MASK_CTRL 16
1264 #define MOUSE_MASK_DRAG 32
1265 #define MOUSE_MASK_MODIFIERS (MOUSE_MASK_SHIFT|MOUSE_MASK_META|MOUSE_MASK_CTRL)
1267 /* Mouse wheel type. */
1268 #define MOUSE_WHEEL_UP 64
1269 #define MOUSE_WHEEL_DOWN 65
1271 /* Mouse button type. */
1272 #define MOUSE_BUTTON_1 0
1273 #define MOUSE_BUTTON_2 1
1274 #define MOUSE_BUTTON_3 2
1275 #define MOUSE_BUTTON_6 66
1276 #define MOUSE_BUTTON_7 67
1277 #define MOUSE_BUTTON_8 128
1278 #define MOUSE_BUTTON_9 129
1279 #define MOUSE_BUTTON_10 130
1280 #define MOUSE_BUTTON_11 131
1282 /* Mouse helpers. */
1283 #define MOUSE_BUTTONS(b) ((b) & MOUSE_MASK_BUTTONS)
1284 #define MOUSE_WHEEL(b) \
1285 (((b) & MOUSE_MASK_BUTTONS) == MOUSE_WHEEL_UP || \
1286 ((b) & MOUSE_MASK_BUTTONS) == MOUSE_WHEEL_DOWN)
1287 #define MOUSE_DRAG(b) ((b) & MOUSE_MASK_DRAG)
1288 #define MOUSE_RELEASE(b) (((b) & MOUSE_MASK_BUTTONS) == 3)
1291 struct mouse_event
{
1322 struct mouse_event m
;
1325 /* Terminal definition. */
1331 char acs
[UCHAR_MAX
+ 1][2];
1333 struct tty_code
*codes
;
1335 #define TERM_256COLOURS 0x1
1336 #define TERM_NOAM 0x2
1337 #define TERM_DECSLRM 0x4
1338 #define TERM_DECFRA 0x8
1339 #define TERM_RGBCOLOURS 0x10
1340 #define TERM_VT100LIKE 0x20
1343 LIST_ENTRY(tty_term
) entry
;
1345 LIST_HEAD(tty_terms
, tty_term
);
1347 /* Client terminal. */
1349 struct client
*client
;
1350 struct event start_timer
;
1351 struct event clipboard_timer
;
1360 enum screen_cursor_style cstyle
;
1377 struct event event_in
;
1378 struct evbuffer
*in
;
1379 struct event event_out
;
1380 struct evbuffer
*out
;
1386 struct grid_cell cell
;
1387 struct grid_cell last_cell
;
1389 #define TTY_NOCURSOR 0x1
1390 #define TTY_FREEZE 0x2
1391 #define TTY_TIMER 0x4
1392 #define TTY_NOBLOCK 0x8
1393 #define TTY_STARTED 0x10
1394 #define TTY_OPENED 0x20
1395 #define TTY_OSC52QUERY 0x40
1396 #define TTY_BLOCK 0x80
1397 #define TTY_HAVEDA 0x100
1398 #define TTY_HAVEXDA 0x200
1399 #define TTY_SYNCING 0x400
1402 struct tty_term
*term
;
1407 int mouse_drag_flag
;
1408 void (*mouse_drag_update
)(struct client
*,
1409 struct mouse_event
*);
1410 void (*mouse_drag_release
)(struct client
*,
1411 struct mouse_event
*);
1413 struct event key_timer
;
1414 struct tty_key
*key_tree
;
1417 /* Terminal command context. */
1418 typedef void (*tty_ctx_redraw_cb
)(const struct tty_ctx
*);
1419 typedef int (*tty_ctx_set_client_cb
)(struct tty_ctx
*, struct client
*);
1423 tty_ctx_redraw_cb redraw_cb
;
1424 tty_ctx_set_client_cb set_client_cb
;
1427 const struct grid_cell
*cell
;
1435 * Cursor and region position before the screen was updated - this is
1436 * where the command should be applied; the values in the screen have
1437 * already been updated.
1445 /* Target region (usually pane) offset and size. */
1453 /* The background colour used for clearing (erasing). */
1456 /* The default colours and palette. */
1457 struct grid_cell defaults
;
1458 struct colour_palette
*palette
;
1460 /* Containing region (usually window) offset and size. */
1468 /* Saved message entry. */
1469 struct message_entry
{
1472 struct timeval msg_time
;
1474 TAILQ_ENTRY(message_entry
) entry
;
1476 TAILQ_HEAD(message_list
, message_entry
);
1478 /* Argument type. */
1485 /* Argument value. */
1487 enum args_type type
;
1490 struct cmd_list
*cmdlist
;
1493 TAILQ_ENTRY(args_value
) entry
;
1496 /* Arguments set. */
1498 RB_HEAD(args_tree
, args_entry
);
1500 /* Arguments parsing type. */
1501 enum args_parse_type
{
1504 ARGS_PARSE_COMMANDS_OR_STRING
,
1508 /* Arguments parsing state. */
1509 typedef enum args_parse_type (*args_parse_cb
)(struct args
*, u_int
, char **);
1511 const char *template;
1517 /* Command find structures. */
1518 enum cmd_find_type
{
1523 struct cmd_find_state
{
1525 struct cmd_find_state
*current
;
1530 struct window_pane
*wp
;
1534 /* Command find flags. */
1535 #define CMD_FIND_PREFER_UNATTACHED 0x1
1536 #define CMD_FIND_QUIET 0x2
1537 #define CMD_FIND_WINDOW_INDEX 0x4
1538 #define CMD_FIND_DEFAULT_MARKED 0x8
1539 #define CMD_FIND_EXACT_SESSION 0x10
1540 #define CMD_FIND_EXACT_WINDOW 0x20
1541 #define CMD_FIND_CANFAIL 0x40
1543 /* List of commands. */
1550 /* Command return values. */
1552 CMD_RETURN_ERROR
= -1,
1553 CMD_RETURN_NORMAL
= 0,
1558 /* Command parse result. */
1559 enum cmd_parse_status
{
1563 struct cmd_parse_result
{
1564 enum cmd_parse_status status
;
1565 struct cmd_list
*cmdlist
;
1568 struct cmd_parse_input
{
1570 #define CMD_PARSE_QUIET 0x1
1571 #define CMD_PARSE_PARSEONLY 0x2
1572 #define CMD_PARSE_NOALIAS 0x4
1573 #define CMD_PARSE_VERBOSE 0x8
1574 #define CMD_PARSE_ONEGROUP 0x10
1579 struct cmdq_item
*item
;
1581 struct cmd_find_state fs
;
1584 /* Command queue flags. */
1585 #define CMDQ_STATE_REPEAT 0x1
1586 #define CMDQ_STATE_CONTROL 0x2
1587 #define CMDQ_STATE_NOHOOKS 0x4
1589 /* Command queue callback. */
1590 typedef enum cmd_retval (*cmdq_cb
) (struct cmdq_item
*, void *);
1592 /* Command definition flag. */
1593 struct cmd_entry_flag
{
1595 enum cmd_find_type type
;
1599 /* Command definition. */
1604 struct args_parse args
;
1607 struct cmd_entry_flag source
;
1608 struct cmd_entry_flag target
;
1610 #define CMD_STARTSERVER 0x1
1611 #define CMD_READONLY 0x2
1612 #define CMD_AFTERHOOK 0x4
1613 #define CMD_CLIENT_CFLAG 0x8
1614 #define CMD_CLIENT_TFLAG 0x10
1615 #define CMD_CLIENT_CANFAIL 0x20
1618 enum cmd_retval (*exec
)(struct cmd
*, struct cmdq_item
*);
1622 #define STATUS_LINES_LIMIT 5
1623 struct status_line_entry
{
1625 struct style_ranges ranges
;
1627 struct status_line
{
1630 struct screen screen
;
1631 struct screen
*active
;
1634 struct grid_cell style
;
1635 struct status_line_entry entries
[STATUS_LINES_LIMIT
];
1639 #define PROMPT_NTYPES 4
1641 PROMPT_TYPE_COMMAND
,
1644 PROMPT_TYPE_WINDOW_TARGET
,
1645 PROMPT_TYPE_INVALID
= 0xff
1648 /* File in client. */
1649 typedef void (*client_file_cb
) (struct client
*, const char *, int, int,
1650 struct evbuffer
*, void *);
1651 struct client_file
{
1653 struct tmuxpeer
*peer
;
1654 struct client_files
*tree
;
1659 struct evbuffer
*buffer
;
1660 struct bufferevent
*event
;
1669 RB_ENTRY(client_file
) entry
;
1671 RB_HEAD(client_files
, client_file
);
1673 /* Client window. */
1674 struct client_window
{
1676 struct window_pane
*pane
;
1681 RB_ENTRY(client_window
) entry
;
1683 RB_HEAD(client_windows
, client_window
);
1685 /* Visible areas not obstructed by overlays. */
1686 #define OVERLAY_MAX_RANGES 3
1687 struct overlay_ranges
{
1688 u_int px
[OVERLAY_MAX_RANGES
];
1689 u_int nx
[OVERLAY_MAX_RANGES
];
1692 /* Client connection. */
1693 typedef int (*prompt_input_cb
)(struct client
*, void *, const char *, int);
1694 typedef void (*prompt_free_cb
)(void *);
1695 typedef void (*overlay_check_cb
)(struct client
*, void *, u_int
, u_int
, u_int
,
1696 struct overlay_ranges
*);
1697 typedef struct screen
*(*overlay_mode_cb
)(struct client
*, void *, u_int
*,
1699 typedef void (*overlay_draw_cb
)(struct client
*, void *,
1700 struct screen_redraw_ctx
*);
1701 typedef int (*overlay_key_cb
)(struct client
*, void *, struct key_event
*);
1702 typedef void (*overlay_free_cb
)(struct client
*, void *);
1703 typedef void (*overlay_resize_cb
)(struct client
*, void *);
1706 struct tmuxpeer
*peer
;
1707 struct cmdq_list
*queue
;
1709 struct client_windows windows
;
1711 struct control_state
*control_state
;
1720 struct timeval creation_time
;
1721 struct timeval activity_time
;
1723 struct environ
*environ
;
1724 struct format_job_tree
*jobs
;
1743 struct event repeat_timer
;
1745 struct event click_timer
;
1747 struct mouse_event click_event
;
1749 struct status_line status
;
1751 #define CLIENT_TERMINAL 0x1
1752 #define CLIENT_LOGIN 0x2
1753 #define CLIENT_EXIT 0x4
1754 #define CLIENT_REDRAWWINDOW 0x8
1755 #define CLIENT_REDRAWSTATUS 0x10
1756 #define CLIENT_REPEAT 0x20
1757 #define CLIENT_SUSPENDED 0x40
1758 #define CLIENT_ATTACHED 0x80
1759 #define CLIENT_EXITED 0x100
1760 #define CLIENT_DEAD 0x200
1761 #define CLIENT_REDRAWBORDERS 0x400
1762 #define CLIENT_READONLY 0x800
1763 #define CLIENT_NOSTARTSERVER 0x1000
1764 #define CLIENT_CONTROL 0x2000
1765 #define CLIENT_CONTROLCONTROL 0x4000
1766 #define CLIENT_FOCUSED 0x8000
1767 #define CLIENT_UTF8 0x10000
1768 #define CLIENT_IGNORESIZE 0x20000
1769 #define CLIENT_IDENTIFIED 0x40000
1770 #define CLIENT_STATUSFORCE 0x80000
1771 #define CLIENT_DOUBLECLICK 0x100000
1772 #define CLIENT_TRIPLECLICK 0x200000
1773 #define CLIENT_SIZECHANGED 0x400000
1774 #define CLIENT_STATUSOFF 0x800000
1775 #define CLIENT_REDRAWSTATUSALWAYS 0x1000000
1776 #define CLIENT_REDRAWOVERLAY 0x2000000
1777 #define CLIENT_CONTROL_NOOUTPUT 0x4000000
1778 #define CLIENT_DEFAULTSOCKET 0x8000000
1779 #define CLIENT_STARTSERVER 0x10000000
1780 #define CLIENT_REDRAWPANES 0x20000000
1781 #define CLIENT_NOFORK 0x40000000
1782 #define CLIENT_ACTIVEPANE 0x80000000ULL
1783 #define CLIENT_CONTROL_PAUSEAFTER 0x100000000ULL
1784 #define CLIENT_CONTROL_WAITEXIT 0x200000000ULL
1785 #define CLIENT_WINDOWSIZECHANGED 0x400000000ULL
1786 #define CLIENT_CLIPBOARDBUFFER 0x800000000ULL
1787 #define CLIENT_ALLREDRAWFLAGS \
1788 (CLIENT_REDRAWWINDOW| \
1789 CLIENT_REDRAWSTATUS| \
1790 CLIENT_REDRAWSTATUSALWAYS| \
1791 CLIENT_REDRAWBORDERS| \
1792 CLIENT_REDRAWOVERLAY| \
1794 #define CLIENT_UNATTACHEDFLAGS \
1798 #define CLIENT_NODETACHFLAGS \
1801 #define CLIENT_NOSIZEFLAGS \
1809 CLIENT_EXIT_SHUTDOWN
,
1812 enum msgtype exit_msgtype
;
1816 struct key_table
*keytable
;
1818 uint64_t redraw_panes
;
1820 int message_ignore_keys
;
1821 int message_ignore_styles
;
1822 char *message_string
;
1823 struct event message_timer
;
1825 char *prompt_string
;
1826 struct utf8_data
*prompt_buffer
;
1828 size_t prompt_index
;
1829 prompt_input_cb prompt_inputcb
;
1830 prompt_free_cb prompt_freecb
;
1832 u_int prompt_hindex
[PROMPT_NTYPES
];
1837 struct utf8_data
*prompt_saved
;
1838 #define PROMPT_SINGLE 0x1
1839 #define PROMPT_NUMERIC 0x2
1840 #define PROMPT_INCREMENTAL 0x4
1841 #define PROMPT_NOFORMAT 0x8
1842 #define PROMPT_KEY 0x10
1844 enum prompt_type prompt_type
;
1847 struct session
*session
;
1848 struct session
*last_session
;
1856 overlay_check_cb overlay_check
;
1857 overlay_mode_cb overlay_mode
;
1858 overlay_draw_cb overlay_draw
;
1859 overlay_key_cb overlay_key
;
1860 overlay_free_cb overlay_free
;
1861 overlay_resize_cb overlay_resize
;
1863 struct event overlay_timer
;
1865 struct client_files files
;
1867 u_int
*clipboard_panes
;
1868 u_int clipboard_npanes
;
1870 TAILQ_ENTRY(client
) entry
;
1872 TAILQ_HEAD(clients
, client
);
1874 /* Control mode subscription type. */
1875 enum control_sub_type
{
1876 CONTROL_SUB_SESSION
,
1878 CONTROL_SUB_ALL_PANES
,
1880 CONTROL_SUB_ALL_WINDOWS
1883 /* Key binding and key table. */
1884 struct key_binding
{
1886 struct cmd_list
*cmdlist
;
1890 #define KEY_BINDING_REPEAT 0x1
1892 RB_ENTRY(key_binding
) entry
;
1894 RB_HEAD(key_bindings
, key_binding
);
1898 struct key_bindings key_bindings
;
1899 struct key_bindings default_key_bindings
;
1903 RB_ENTRY(key_table
) entry
;
1905 RB_HEAD(key_tables
, key_table
);
1908 RB_HEAD(options_array
, options_array_item
);
1909 union options_value
{
1913 struct options_array array
;
1914 struct cmd_list
*cmdlist
;
1917 /* Option table entries. */
1918 enum options_table_type
{
1919 OPTIONS_TABLE_STRING
,
1920 OPTIONS_TABLE_NUMBER
,
1922 OPTIONS_TABLE_COLOUR
,
1924 OPTIONS_TABLE_CHOICE
,
1925 OPTIONS_TABLE_COMMAND
1928 #define OPTIONS_TABLE_NONE 0
1929 #define OPTIONS_TABLE_SERVER 0x1
1930 #define OPTIONS_TABLE_SESSION 0x2
1931 #define OPTIONS_TABLE_WINDOW 0x4
1932 #define OPTIONS_TABLE_PANE 0x8
1934 #define OPTIONS_TABLE_IS_ARRAY 0x1
1935 #define OPTIONS_TABLE_IS_HOOK 0x2
1936 #define OPTIONS_TABLE_IS_STYLE 0x4
1938 struct options_table_entry
{
1940 const char *alternative_name
;
1941 enum options_table_type type
;
1947 const char **choices
;
1949 const char *default_str
;
1950 long long default_num
;
1951 const char **default_arr
;
1953 const char *separator
;
1954 const char *pattern
;
1960 struct options_name_map
{
1965 /* Common command usages. */
1966 #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
1967 #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
1968 #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
1969 #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
1970 #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
1971 #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
1972 #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
1973 #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
1974 #define CMD_BUFFER_USAGE "[-b buffer-name]"
1976 /* Spawn common context. */
1977 struct spawn_context
{
1978 struct cmdq_item
*item
;
1984 struct window_pane
*wp0
;
1985 struct layout_cell
*lc
;
1990 struct environ
*environ
;
1996 #define SPAWN_KILL 0x1
1997 #define SPAWN_DETACHED 0x2
1998 #define SPAWN_RESPAWN 0x4
1999 #define SPAWN_BEFORE 0x8
2000 #define SPAWN_NONOTIFY 0x10
2001 #define SPAWN_FULLSIZE 0x20
2002 #define SPAWN_EMPTY 0x40
2003 #define SPAWN_ZOOM 0x80
2006 /* Mode tree sort order. */
2007 struct mode_tree_sort_criteria
{
2013 extern struct options
*global_options
;
2014 extern struct options
*global_s_options
;
2015 extern struct options
*global_w_options
;
2016 extern struct environ
*global_environ
;
2017 extern struct timeval start_time
;
2018 extern const char *socket_path
;
2019 extern const char *shell_command
;
2021 extern const char *shell_command
;
2022 int checkshell(const char *);
2023 void setblocking(int, int);
2024 uint64_t get_timer(void);
2025 const char *sig2name(int);
2026 const char *find_cwd(void);
2027 const char *find_home(void);
2028 const char *getversion(void);
2032 int proc_send(struct tmuxpeer
*, enum msgtype
, int, const void *, size_t);
2033 struct tmuxproc
*proc_start(const char *);
2034 void proc_loop(struct tmuxproc
*, int (*)(void));
2035 void proc_exit(struct tmuxproc
*);
2036 void proc_set_signals(struct tmuxproc
*, void(*)(int));
2037 void proc_clear_signals(struct tmuxproc
*, int);
2038 struct tmuxpeer
*proc_add_peer(struct tmuxproc
*, int,
2039 void (*)(struct imsg
*, void *), void *);
2040 void proc_remove_peer(struct tmuxpeer
*);
2041 void proc_kill_peer(struct tmuxpeer
*);
2042 void proc_flush_peer(struct tmuxpeer
*);
2043 void proc_toggle_log(struct tmuxproc
*);
2044 pid_t
proc_fork_and_daemon(int *);
2045 uid_t
proc_get_peer_uid(struct tmuxpeer
*);
2048 extern int cfg_finished
;
2049 extern struct client
*cfg_client
;
2050 extern char **cfg_files
;
2051 extern u_int cfg_nfiles
;
2052 extern int cfg_quiet
;
2053 void start_cfg(void);
2054 int load_cfg(const char *, struct client
*, struct cmdq_item
*, int,
2055 struct cmdq_item
**);
2056 int load_cfg_from_buffer(const void *, size_t, const char *,
2057 struct client
*, struct cmdq_item
*, int, struct cmdq_item
**);
2058 void printflike(1, 2) cfg_add_cause(const char *, ...);
2059 void cfg_print_causes(struct cmdq_item
*);
2060 void cfg_show_causes(struct session
*);
2063 struct paste_buffer
;
2064 const char *paste_buffer_name(struct paste_buffer
*);
2065 u_int
paste_buffer_order(struct paste_buffer
*);
2066 time_t paste_buffer_created(struct paste_buffer
*);
2067 const char *paste_buffer_data(struct paste_buffer
*, size_t *);
2068 struct paste_buffer
*paste_walk(struct paste_buffer
*);
2069 int paste_is_empty(void);
2070 struct paste_buffer
*paste_get_top(const char **);
2071 struct paste_buffer
*paste_get_name(const char *);
2072 void paste_free(struct paste_buffer
*);
2073 void paste_add(const char *, char *, size_t);
2074 int paste_rename(const char *, const char *, char **);
2075 int paste_set(char *, size_t, const char *, char **);
2076 void paste_replace(struct paste_buffer
*, char *, size_t);
2077 char *paste_make_sample(struct paste_buffer
*);
2080 #define FORMAT_STATUS 0x1
2081 #define FORMAT_FORCE 0x2
2082 #define FORMAT_NOJOBS 0x4
2083 #define FORMAT_VERBOSE 0x8
2084 #define FORMAT_NONE 0
2085 #define FORMAT_PANE 0x80000000U
2086 #define FORMAT_WINDOW 0x40000000U
2088 struct format_modifier
;
2089 typedef void *(*format_cb
)(struct format_tree
*);
2090 void format_tidy_jobs(void);
2091 const char *format_skip(const char *, const char *);
2092 int format_true(const char *);
2093 struct format_tree
*format_create(struct client
*, struct cmdq_item
*, int,
2095 void format_free(struct format_tree
*);
2096 void format_merge(struct format_tree
*, struct format_tree
*);
2097 struct window_pane
*format_get_pane(struct format_tree
*);
2098 void printflike(3, 4) format_add(struct format_tree
*, const char *,
2100 void format_add_tv(struct format_tree
*, const char *,
2102 void format_add_cb(struct format_tree
*, const char *, format_cb
);
2103 void format_log_debug(struct format_tree
*, const char *);
2104 void format_each(struct format_tree
*, void (*)(const char *,
2105 const char *, void *), void *);
2106 char *format_pretty_time(time_t, int);
2107 char *format_expand_time(struct format_tree
*, const char *);
2108 char *format_expand(struct format_tree
*, const char *);
2109 char *format_single(struct cmdq_item
*, const char *,
2110 struct client
*, struct session
*, struct winlink
*,
2111 struct window_pane
*);
2112 char *format_single_from_state(struct cmdq_item
*, const char *,
2113 struct client
*, struct cmd_find_state
*);
2114 char *format_single_from_target(struct cmdq_item
*, const char *);
2115 struct format_tree
*format_create_defaults(struct cmdq_item
*, struct client
*,
2116 struct session
*, struct winlink
*, struct window_pane
*);
2117 struct format_tree
*format_create_from_state(struct cmdq_item
*,
2118 struct client
*, struct cmd_find_state
*);
2119 struct format_tree
*format_create_from_target(struct cmdq_item
*);
2120 void format_defaults(struct format_tree
*, struct client
*,
2121 struct session
*, struct winlink
*, struct window_pane
*);
2122 void format_defaults_window(struct format_tree
*, struct window
*);
2123 void format_defaults_pane(struct format_tree
*,
2124 struct window_pane
*);
2125 void format_defaults_paste_buffer(struct format_tree
*,
2126 struct paste_buffer
*);
2127 void format_lost_client(struct client
*);
2128 char *format_grid_word(struct grid
*, u_int
, u_int
);
2129 char *format_grid_hyperlink(struct grid
*, u_int
, u_int
,
2131 char *format_grid_line(struct grid
*, u_int
);
2134 void format_draw(struct screen_write_ctx
*,
2135 const struct grid_cell
*, u_int
, const char *,
2136 struct style_ranges
*, int);
2137 u_int
format_width(const char *);
2138 char *format_trim_left(const char *, u_int
);
2139 char *format_trim_right(const char *, u_int
);
2142 void notify_hook(struct cmdq_item
*, const char *);
2143 void notify_client(const char *, struct client
*);
2144 void notify_session(const char *, struct session
*);
2145 void notify_winlink(const char *, struct winlink
*);
2146 void notify_session_window(const char *, struct session
*, struct window
*);
2147 void notify_window(const char *, struct window
*);
2148 void notify_pane(const char *, struct window_pane
*);
2151 struct options
*options_create(struct options
*);
2152 void options_free(struct options
*);
2153 struct options
*options_get_parent(struct options
*);
2154 void options_set_parent(struct options
*, struct options
*);
2155 struct options_entry
*options_first(struct options
*);
2156 struct options_entry
*options_next(struct options_entry
*);
2157 struct options_entry
*options_empty(struct options
*,
2158 const struct options_table_entry
*);
2159 struct options_entry
*options_default(struct options
*,
2160 const struct options_table_entry
*);
2161 char *options_default_to_string(const struct options_table_entry
*);
2162 const char *options_name(struct options_entry
*);
2163 struct options
*options_owner(struct options_entry
*);
2164 const struct options_table_entry
*options_table_entry(struct options_entry
*);
2165 struct options_entry
*options_get_only(struct options
*, const char *);
2166 struct options_entry
*options_get(struct options
*, const char *);
2167 void options_array_clear(struct options_entry
*);
2168 union options_value
*options_array_get(struct options_entry
*, u_int
);
2169 int options_array_set(struct options_entry
*, u_int
, const char *,
2171 int options_array_assign(struct options_entry
*, const char *,
2173 struct options_array_item
*options_array_first(struct options_entry
*);
2174 struct options_array_item
*options_array_next(struct options_array_item
*);
2175 u_int
options_array_item_index(struct options_array_item
*);
2176 union options_value
*options_array_item_value(struct options_array_item
*);
2177 int options_is_array(struct options_entry
*);
2178 int options_is_string(struct options_entry
*);
2179 char *options_to_string(struct options_entry
*, int, int);
2180 char *options_parse(const char *, int *);
2181 struct options_entry
*options_parse_get(struct options
*, const char *, int *,
2183 char *options_match(const char *, int *, int *);
2184 struct options_entry
*options_match_get(struct options
*, const char *, int *,
2186 const char *options_get_string(struct options
*, const char *);
2187 long long options_get_number(struct options
*, const char *);
2188 struct options_entry
* printflike(4, 5) options_set_string(struct options
*,
2189 const char *, int, const char *, ...);
2190 struct options_entry
*options_set_number(struct options
*, const char *,
2192 int options_scope_from_name(struct args
*, int,
2193 const char *, struct cmd_find_state
*, struct options
**,
2195 int options_scope_from_flags(struct args
*, int,
2196 struct cmd_find_state
*, struct options
**, char **);
2197 struct style
*options_string_to_style(struct options
*, const char *,
2198 struct format_tree
*);
2199 int options_from_string(struct options
*,
2200 const struct options_table_entry
*, const char *,
2201 const char *, int, char **);
2202 int options_find_choice(const struct options_table_entry
*,
2203 const char *, char **);
2204 void options_push_changes(const char *);
2205 int options_remove_or_default(struct options_entry
*, int,
2208 /* options-table.c */
2209 extern const struct options_table_entry options_table
[];
2210 extern const struct options_name_map options_other_names
[];
2213 typedef void (*job_update_cb
) (struct job
*);
2214 typedef void (*job_complete_cb
) (struct job
*);
2215 typedef void (*job_free_cb
) (void *);
2216 #define JOB_NOWAIT 0x1
2217 #define JOB_KEEPWRITE 0x2
2219 struct job
*job_run(const char *, int, char **, struct environ
*,
2220 struct session
*, const char *, job_update_cb
,
2221 job_complete_cb
, job_free_cb
, void *, int, int, int);
2222 void job_free(struct job
*);
2223 int job_transfer(struct job
*, pid_t
*, char *, size_t);
2224 void job_resize(struct job
*, u_int
, u_int
);
2225 void job_check_died(pid_t
, int);
2226 int job_get_status(struct job
*);
2227 void *job_get_data(struct job
*);
2228 struct bufferevent
*job_get_event(struct job
*);
2229 void job_kill_all(void);
2230 int job_still_running(void);
2231 void job_print_summary(struct cmdq_item
*, int);
2234 struct environ
*environ_create(void);
2235 void environ_free(struct environ
*);
2236 struct environ_entry
*environ_first(struct environ
*);
2237 struct environ_entry
*environ_next(struct environ_entry
*);
2238 void environ_copy(struct environ
*, struct environ
*);
2239 struct environ_entry
*environ_find(struct environ
*, const char *);
2240 void printflike(4, 5) environ_set(struct environ
*, const char *, int,
2242 void environ_clear(struct environ
*, const char *);
2243 void environ_put(struct environ
*, const char *, int);
2244 void environ_unset(struct environ
*, const char *);
2245 void environ_update(struct options
*, struct environ
*, struct environ
*);
2246 void environ_push(struct environ
*);
2247 void printflike(2, 3) environ_log(struct environ
*, const char *, ...);
2248 struct environ
*environ_for_session(struct session
*, int);
2251 void tty_create_log(void);
2252 int tty_window_bigger(struct tty
*);
2253 int tty_window_offset(struct tty
*, u_int
*, u_int
*, u_int
*, u_int
*);
2254 void tty_update_window_offset(struct window
*);
2255 void tty_update_client_offset(struct client
*);
2256 void tty_raw(struct tty
*, const char *);
2257 void tty_attributes(struct tty
*, const struct grid_cell
*,
2258 const struct grid_cell
*, struct colour_palette
*,
2259 struct hyperlinks
*);
2260 void tty_reset(struct tty
*);
2261 void tty_region_off(struct tty
*);
2262 void tty_margin_off(struct tty
*);
2263 void tty_cursor(struct tty
*, u_int
, u_int
);
2264 void tty_clipboard_query(struct tty
*);
2265 void tty_putcode(struct tty
*, enum tty_code_code
);
2266 void tty_putcode1(struct tty
*, enum tty_code_code
, int);
2267 void tty_putcode2(struct tty
*, enum tty_code_code
, int, int);
2268 void tty_putcode3(struct tty
*, enum tty_code_code
, int, int, int);
2269 void tty_putcode_ptr1(struct tty
*, enum tty_code_code
, const void *);
2270 void tty_putcode_ptr2(struct tty
*, enum tty_code_code
, const void *,
2272 void tty_puts(struct tty
*, const char *);
2273 void tty_putc(struct tty
*, u_char
);
2274 void tty_putn(struct tty
*, const void *, size_t, u_int
);
2275 void tty_cell(struct tty
*, const struct grid_cell
*,
2276 const struct grid_cell
*, struct colour_palette
*,
2277 struct hyperlinks
*);
2278 int tty_init(struct tty
*, struct client
*);
2279 void tty_resize(struct tty
*);
2280 void tty_set_size(struct tty
*, u_int
, u_int
, u_int
, u_int
);
2281 void tty_start_tty(struct tty
*);
2282 void tty_send_requests(struct tty
*);
2283 void tty_stop_tty(struct tty
*);
2284 void tty_set_title(struct tty
*, const char *);
2285 void tty_set_path(struct tty
*, const char *);
2286 void tty_update_mode(struct tty
*, int, struct screen
*);
2287 void tty_draw_line(struct tty
*, struct screen
*, u_int
, u_int
, u_int
,
2288 u_int
, u_int
, const struct grid_cell
*, struct colour_palette
*);
2289 void tty_sync_start(struct tty
*);
2290 void tty_sync_end(struct tty
*);
2291 int tty_open(struct tty
*, char **);
2292 void tty_close(struct tty
*);
2293 void tty_free(struct tty
*);
2294 void tty_update_features(struct tty
*);
2295 void tty_set_selection(struct tty
*, const char *, const char *, size_t);
2296 void tty_write(void (*)(struct tty
*, const struct tty_ctx
*),
2298 void tty_cmd_alignmenttest(struct tty
*, const struct tty_ctx
*);
2299 void tty_cmd_cell(struct tty
*, const struct tty_ctx
*);
2300 void tty_cmd_cells(struct tty
*, const struct tty_ctx
*);
2301 void tty_cmd_clearendofline(struct tty
*, const struct tty_ctx
*);
2302 void tty_cmd_clearendofscreen(struct tty
*, const struct tty_ctx
*);
2303 void tty_cmd_clearline(struct tty
*, const struct tty_ctx
*);
2304 void tty_cmd_clearscreen(struct tty
*, const struct tty_ctx
*);
2305 void tty_cmd_clearstartofline(struct tty
*, const struct tty_ctx
*);
2306 void tty_cmd_clearstartofscreen(struct tty
*, const struct tty_ctx
*);
2307 void tty_cmd_deletecharacter(struct tty
*, const struct tty_ctx
*);
2308 void tty_cmd_clearcharacter(struct tty
*, const struct tty_ctx
*);
2309 void tty_cmd_deleteline(struct tty
*, const struct tty_ctx
*);
2310 void tty_cmd_erasecharacter(struct tty
*, const struct tty_ctx
*);
2311 void tty_cmd_insertcharacter(struct tty
*, const struct tty_ctx
*);
2312 void tty_cmd_insertline(struct tty
*, const struct tty_ctx
*);
2313 void tty_cmd_linefeed(struct tty
*, const struct tty_ctx
*);
2314 void tty_cmd_scrollup(struct tty
*, const struct tty_ctx
*);
2315 void tty_cmd_scrolldown(struct tty
*, const struct tty_ctx
*);
2316 void tty_cmd_reverseindex(struct tty
*, const struct tty_ctx
*);
2317 void tty_cmd_setselection(struct tty
*, const struct tty_ctx
*);
2318 void tty_cmd_rawstring(struct tty
*, const struct tty_ctx
*);
2319 void tty_cmd_syncstart(struct tty
*, const struct tty_ctx
*);
2320 void tty_default_colours(struct grid_cell
*, struct window_pane
*);
2323 extern struct tty_terms tty_terms
;
2324 u_int
tty_term_ncodes(void);
2325 void tty_term_apply(struct tty_term
*, const char *, int);
2326 void tty_term_apply_overrides(struct tty_term
*);
2327 struct tty_term
*tty_term_create(struct tty
*, char *, char **, u_int
, int *,
2329 void tty_term_free(struct tty_term
*);
2330 int tty_term_read_list(const char *, int, char ***, u_int
*,
2332 void tty_term_free_list(char **, u_int
);
2333 int tty_term_has(struct tty_term
*, enum tty_code_code
);
2334 const char *tty_term_string(struct tty_term
*, enum tty_code_code
);
2335 const char *tty_term_string1(struct tty_term
*, enum tty_code_code
, int);
2336 const char *tty_term_string2(struct tty_term
*, enum tty_code_code
, int,
2338 const char *tty_term_string3(struct tty_term
*, enum tty_code_code
, int,
2340 const char *tty_term_ptr1(struct tty_term
*, enum tty_code_code
,
2342 const char *tty_term_ptr2(struct tty_term
*, enum tty_code_code
,
2343 const void *, const void *);
2344 int tty_term_number(struct tty_term
*, enum tty_code_code
);
2345 int tty_term_flag(struct tty_term
*, enum tty_code_code
);
2346 const char *tty_term_describe(struct tty_term
*, enum tty_code_code
);
2348 /* tty-features.c */
2349 void tty_add_features(int *, const char *, const char *);
2350 const char *tty_get_features(int);
2351 int tty_apply_features(struct tty_term
*, int);
2352 void tty_default_features(int *, const char *, u_int
);
2355 int tty_acs_needed(struct tty
*);
2356 const char *tty_acs_get(struct tty
*, u_char
);
2357 int tty_acs_reverse_get(struct tty
*, const char *, size_t);
2358 const struct utf8_data
*tty_acs_double_borders(int);
2359 const struct utf8_data
*tty_acs_heavy_borders(int);
2360 const struct utf8_data
*tty_acs_rounded_borders(int);
2363 void tty_keys_build(struct tty
*);
2364 void tty_keys_free(struct tty
*);
2365 int tty_keys_next(struct tty
*);
2368 void args_set(struct args
*, u_char
, struct args_value
*);
2369 struct args
*args_create(void);
2370 struct args
*args_parse(const struct args_parse
*, struct args_value
*,
2372 struct args
*args_copy(struct args
*, int, char **);
2373 void args_to_vector(struct args
*, int *, char ***);
2374 struct args_value
*args_from_vector(int, char **);
2375 void args_free_value(struct args_value
*);
2376 void args_free_values(struct args_value
*, u_int
);
2377 void args_free(struct args
*);
2378 char *args_print(struct args
*);
2379 char *args_escape(const char *);
2380 int args_has(struct args
*, u_char
);
2381 const char *args_get(struct args
*, u_char
);
2382 u_char
args_first(struct args
*, struct args_entry
**);
2383 u_char
args_next(struct args_entry
**);
2384 u_int
args_count(struct args
*);
2385 struct args_value
*args_values(struct args
*);
2386 struct args_value
*args_value(struct args
*, u_int
);
2387 const char *args_string(struct args
*, u_int
);
2388 struct cmd_list
*args_make_commands_now(struct cmd
*, struct cmdq_item
*,
2390 struct args_command_state
*args_make_commands_prepare(struct cmd
*,
2391 struct cmdq_item
*, u_int
, const char *, int, int);
2392 struct cmd_list
*args_make_commands(struct args_command_state
*, int, char **,
2394 void args_make_commands_free(struct args_command_state
*);
2395 char *args_make_commands_get_command(struct args_command_state
*);
2396 struct args_value
*args_first_value(struct args
*, u_char
);
2397 struct args_value
*args_next_value(struct args_value
*);
2398 long long args_strtonum(struct args
*, u_char
, long long, long long,
2400 long long args_strtonum_and_expand(struct args
*, u_char
, long long,
2401 long long, struct cmdq_item
*, char **);
2402 long long args_percentage(struct args
*, u_char
, long long,
2403 long long, long long, char **);
2404 long long args_string_percentage(const char *, long long, long long,
2405 long long, char **);
2406 long long args_percentage_and_expand(struct args
*, u_char
, long long,
2407 long long, long long, struct cmdq_item
*, char **);
2408 long long args_string_percentage_and_expand(const char *, long long,
2409 long long, long long, struct cmdq_item
*, char **);
2412 int cmd_find_target(struct cmd_find_state
*, struct cmdq_item
*,
2413 const char *, enum cmd_find_type
, int);
2414 struct client
*cmd_find_best_client(struct session
*);
2415 struct client
*cmd_find_client(struct cmdq_item
*, const char *, int);
2416 void cmd_find_clear_state(struct cmd_find_state
*, int);
2417 int cmd_find_empty_state(struct cmd_find_state
*);
2418 int cmd_find_valid_state(struct cmd_find_state
*);
2419 void cmd_find_copy_state(struct cmd_find_state
*,
2420 struct cmd_find_state
*);
2421 void cmd_find_from_session(struct cmd_find_state
*,
2422 struct session
*, int);
2423 void cmd_find_from_winlink(struct cmd_find_state
*,
2424 struct winlink
*, int);
2425 int cmd_find_from_session_window(struct cmd_find_state
*,
2426 struct session
*, struct window
*, int);
2427 int cmd_find_from_window(struct cmd_find_state
*, struct window
*,
2429 void cmd_find_from_winlink_pane(struct cmd_find_state
*,
2430 struct winlink
*, struct window_pane
*, int);
2431 int cmd_find_from_pane(struct cmd_find_state
*,
2432 struct window_pane
*, int);
2433 int cmd_find_from_client(struct cmd_find_state
*, struct client
*,
2435 int cmd_find_from_mouse(struct cmd_find_state
*,
2436 struct mouse_event
*, int);
2437 int cmd_find_from_nothing(struct cmd_find_state
*, int);
2440 extern const struct cmd_entry
*cmd_table
[];
2441 void printflike(3, 4) cmd_log_argv(int, char **, const char *, ...);
2442 void cmd_prepend_argv(int *, char ***, const char *);
2443 void cmd_append_argv(int *, char ***, const char *);
2444 int cmd_pack_argv(int, char **, char *, size_t);
2445 int cmd_unpack_argv(char *, size_t, int, char ***);
2446 char **cmd_copy_argv(int, char **);
2447 void cmd_free_argv(int, char **);
2448 char *cmd_stringify_argv(int, char **);
2449 char *cmd_get_alias(const char *);
2450 const struct cmd_entry
*cmd_get_entry(struct cmd
*);
2451 struct args
*cmd_get_args(struct cmd
*);
2452 u_int
cmd_get_group(struct cmd
*);
2453 void cmd_get_source(struct cmd
*, const char **, u_int
*);
2454 struct cmd
*cmd_parse(struct args_value
*, u_int
, const char *, u_int
,
2456 struct cmd
*cmd_copy(struct cmd
*, int, char **);
2457 void cmd_free(struct cmd
*);
2458 char *cmd_print(struct cmd
*);
2459 struct cmd_list
*cmd_list_new(void);
2460 struct cmd_list
*cmd_list_copy(struct cmd_list
*, int, char **);
2461 void cmd_list_append(struct cmd_list
*, struct cmd
*);
2462 void cmd_list_append_all(struct cmd_list
*, struct cmd_list
*);
2463 void cmd_list_move(struct cmd_list
*, struct cmd_list
*);
2464 void cmd_list_free(struct cmd_list
*);
2465 char *cmd_list_print(struct cmd_list
*, int);
2466 struct cmd
*cmd_list_first(struct cmd_list
*);
2467 struct cmd
*cmd_list_next(struct cmd
*);
2468 int cmd_list_all_have(struct cmd_list
*, int);
2469 int cmd_list_any_have(struct cmd_list
*, int);
2470 int cmd_mouse_at(struct window_pane
*, struct mouse_event
*,
2471 u_int
*, u_int
*, int);
2472 struct winlink
*cmd_mouse_window(struct mouse_event
*, struct session
**);
2473 struct window_pane
*cmd_mouse_pane(struct mouse_event
*, struct session
**,
2475 char *cmd_template_replace(const char *, const char *, int);
2477 /* cmd-attach-session.c */
2478 enum cmd_retval
cmd_attach_session(struct cmdq_item
*, const char *, int, int,
2479 int, const char *, int, const char *);
2482 void cmd_parse_empty(struct cmd_parse_input
*);
2483 struct cmd_parse_result
*cmd_parse_from_file(FILE *, struct cmd_parse_input
*);
2484 struct cmd_parse_result
*cmd_parse_from_string(const char *,
2485 struct cmd_parse_input
*);
2486 enum cmd_parse_status
cmd_parse_and_insert(const char *,
2487 struct cmd_parse_input
*, struct cmdq_item
*,
2488 struct cmdq_state
*, char **);
2489 enum cmd_parse_status
cmd_parse_and_append(const char *,
2490 struct cmd_parse_input
*, struct client
*,
2491 struct cmdq_state
*, char **);
2492 struct cmd_parse_result
*cmd_parse_from_buffer(const void *, size_t,
2493 struct cmd_parse_input
*);
2494 struct cmd_parse_result
*cmd_parse_from_arguments(struct args_value
*, u_int
,
2495 struct cmd_parse_input
*);
2498 struct cmdq_state
*cmdq_new_state(struct cmd_find_state
*, struct key_event
*,
2500 struct cmdq_state
*cmdq_link_state(struct cmdq_state
*);
2501 struct cmdq_state
*cmdq_copy_state(struct cmdq_state
*);
2502 void cmdq_free_state(struct cmdq_state
*);
2503 void printflike(3, 4) cmdq_add_format(struct cmdq_state
*, const char *,
2505 void cmdq_add_formats(struct cmdq_state
*, struct format_tree
*);
2506 void cmdq_merge_formats(struct cmdq_item
*, struct format_tree
*);
2507 struct cmdq_list
*cmdq_new(void);
2508 void cmdq_free(struct cmdq_list
*);
2509 const char *cmdq_get_name(struct cmdq_item
*);
2510 struct client
*cmdq_get_client(struct cmdq_item
*);
2511 struct client
*cmdq_get_target_client(struct cmdq_item
*);
2512 struct cmdq_state
*cmdq_get_state(struct cmdq_item
*);
2513 struct cmd_find_state
*cmdq_get_target(struct cmdq_item
*);
2514 struct cmd_find_state
*cmdq_get_source(struct cmdq_item
*);
2515 struct key_event
*cmdq_get_event(struct cmdq_item
*);
2516 struct cmd_find_state
*cmdq_get_current(struct cmdq_item
*);
2517 int cmdq_get_flags(struct cmdq_item
*);
2518 struct cmdq_item
*cmdq_get_command(struct cmd_list
*, struct cmdq_state
*);
2519 #define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data)
2520 struct cmdq_item
*cmdq_get_callback1(const char *, cmdq_cb
, void *);
2521 struct cmdq_item
*cmdq_get_error(const char *);
2522 struct cmdq_item
*cmdq_insert_after(struct cmdq_item
*, struct cmdq_item
*);
2523 struct cmdq_item
*cmdq_append(struct client
*, struct cmdq_item
*);
2524 void printflike(4, 5) cmdq_insert_hook(struct session
*, struct cmdq_item
*,
2525 struct cmd_find_state
*, const char *, ...);
2526 void cmdq_continue(struct cmdq_item
*);
2527 u_int
cmdq_next(struct client
*);
2528 struct cmdq_item
*cmdq_running(struct client
*);
2529 void cmdq_guard(struct cmdq_item
*, const char *, int);
2530 void printflike(2, 3) cmdq_print(struct cmdq_item
*, const char *, ...);
2531 void printflike(2, 3) cmdq_error(struct cmdq_item
*, const char *, ...);
2533 /* cmd-wait-for.c */
2534 void cmd_wait_for_flush(void);
2537 int client_main(struct event_base
*, int, char **, uint64_t, int);
2539 /* key-bindings.c */
2540 struct key_table
*key_bindings_get_table(const char *, int);
2541 struct key_table
*key_bindings_first_table(void);
2542 struct key_table
*key_bindings_next_table(struct key_table
*);
2543 void key_bindings_unref_table(struct key_table
*);
2544 struct key_binding
*key_bindings_get(struct key_table
*, key_code
);
2545 struct key_binding
*key_bindings_get_default(struct key_table
*, key_code
);
2546 struct key_binding
*key_bindings_first(struct key_table
*);
2547 struct key_binding
*key_bindings_next(struct key_table
*, struct key_binding
*);
2548 void key_bindings_add(const char *, key_code
, const char *, int,
2550 void key_bindings_remove(const char *, key_code
);
2551 void key_bindings_reset(const char *, key_code
);
2552 void key_bindings_remove_table(const char *);
2553 void key_bindings_reset_table(const char *);
2554 void key_bindings_init(void);
2555 struct cmdq_item
*key_bindings_dispatch(struct key_binding
*,
2556 struct cmdq_item
*, struct client
*, struct key_event
*,
2557 struct cmd_find_state
*);
2560 key_code
key_string_lookup_string(const char *);
2561 const char *key_string_lookup_key(key_code
, int);
2564 void alerts_reset_all(void);
2565 void alerts_queue(struct window
*, int);
2566 void alerts_check_session(struct session
*);
2569 int file_cmp(struct client_file
*, struct client_file
*);
2570 RB_PROTOTYPE(client_files
, client_file
, entry
, file_cmp
);
2571 struct client_file
*file_create_with_peer(struct tmuxpeer
*,
2572 struct client_files
*, int, client_file_cb
, void *);
2573 struct client_file
*file_create_with_client(struct client
*, int,
2574 client_file_cb
, void *);
2575 void file_free(struct client_file
*);
2576 void file_fire_done(struct client_file
*);
2577 void file_fire_read(struct client_file
*);
2578 int file_can_print(struct client
*);
2579 void printflike(2, 3) file_print(struct client
*, const char *, ...);
2580 void printflike(2, 0) file_vprint(struct client
*, const char *, va_list);
2581 void file_print_buffer(struct client
*, void *, size_t);
2582 void printflike(2, 3) file_error(struct client
*, const char *, ...);
2583 void file_write(struct client
*, const char *, int, const void *, size_t,
2584 client_file_cb
, void *);
2585 void file_read(struct client
*, const char *, client_file_cb
, void *);
2586 void file_push(struct client_file
*);
2587 int file_write_left(struct client_files
*);
2588 void file_write_open(struct client_files
*, struct tmuxpeer
*,
2589 struct imsg
*, int, int, client_file_cb
, void *);
2590 void file_write_data(struct client_files
*, struct imsg
*);
2591 void file_write_close(struct client_files
*, struct imsg
*);
2592 void file_read_open(struct client_files
*, struct tmuxpeer
*, struct imsg
*,
2593 int, int, client_file_cb
, void *);
2594 void file_write_ready(struct client_files
*, struct imsg
*);
2595 void file_read_data(struct client_files
*, struct imsg
*);
2596 void file_read_done(struct client_files
*, struct imsg
*);
2599 extern struct tmuxproc
*server_proc
;
2600 extern struct clients clients
;
2601 extern struct cmd_find_state marked_pane
;
2602 extern struct message_list message_log
;
2603 extern time_t current_time
;
2604 void server_set_marked(struct session
*, struct winlink
*,
2605 struct window_pane
*);
2606 void server_clear_marked(void);
2607 int server_is_marked(struct session
*, struct winlink
*,
2608 struct window_pane
*);
2609 int server_check_marked(void);
2610 int server_start(struct tmuxproc
*, int, struct event_base
*, int, char *);
2611 void server_update_socket(void);
2612 void server_add_accept(int);
2613 void printflike(1, 2) server_add_message(const char *, ...);
2615 /* server-client.c */
2616 RB_PROTOTYPE(client_windows
, client_window
, entry
, server_client_window_cmp
);
2617 u_int
server_client_how_many(void);
2618 void server_client_set_overlay(struct client
*, u_int
, overlay_check_cb
,
2619 overlay_mode_cb
, overlay_draw_cb
, overlay_key_cb
,
2620 overlay_free_cb
, overlay_resize_cb
, void *);
2621 void server_client_clear_overlay(struct client
*);
2622 void server_client_overlay_range(u_int
, u_int
, u_int
, u_int
, u_int
, u_int
,
2623 u_int
, struct overlay_ranges
*);
2624 void server_client_set_key_table(struct client
*, const char *);
2625 const char *server_client_get_key_table(struct client
*);
2626 int server_client_check_nested(struct client
*);
2627 int server_client_handle_key(struct client
*, struct key_event
*);
2628 struct client
*server_client_create(int);
2629 int server_client_open(struct client
*, char **);
2630 void server_client_unref(struct client
*);
2631 void server_client_set_session(struct client
*, struct session
*);
2632 void server_client_lost(struct client
*);
2633 void server_client_suspend(struct client
*);
2634 void server_client_detach(struct client
*, enum msgtype
);
2635 void server_client_exec(struct client
*, const char *);
2636 void server_client_loop(void);
2637 void server_client_push_stdout(struct client
*);
2638 void server_client_push_stderr(struct client
*);
2639 const char *server_client_get_cwd(struct client
*, struct session
*);
2640 void server_client_set_flags(struct client
*, const char *);
2641 const char *server_client_get_flags(struct client
*);
2642 struct client_window
*server_client_get_client_window(struct client
*, u_int
);
2643 struct client_window
*server_client_add_client_window(struct client
*, u_int
);
2644 struct window_pane
*server_client_get_pane(struct client
*);
2645 void server_client_set_pane(struct client
*, struct window_pane
*);
2646 void server_client_remove_pane(struct window_pane
*);
2649 void server_redraw_client(struct client
*);
2650 void server_status_client(struct client
*);
2651 void server_redraw_session(struct session
*);
2652 void server_redraw_session_group(struct session
*);
2653 void server_status_session(struct session
*);
2654 void server_status_session_group(struct session
*);
2655 void server_redraw_window(struct window
*);
2656 void server_redraw_window_borders(struct window
*);
2657 void server_status_window(struct window
*);
2658 void server_lock(void);
2659 void server_lock_session(struct session
*);
2660 void server_lock_client(struct client
*);
2661 void server_kill_pane(struct window_pane
*);
2662 void server_kill_window(struct window
*, int);
2663 void server_renumber_session(struct session
*);
2664 void server_renumber_all(void);
2665 int server_link_window(struct session
*,
2666 struct winlink
*, struct session
*, int, int, int, char **);
2667 void server_unlink_window(struct session
*, struct winlink
*);
2668 void server_destroy_pane(struct window_pane
*, int);
2669 void server_destroy_session(struct session
*);
2670 void server_check_unattached(void);
2671 void server_unzoom_window(struct window
*);
2674 extern char **status_prompt_hlist
[];
2675 extern u_int status_prompt_hsize
[];
2676 void status_timer_start(struct client
*);
2677 void status_timer_start_all(void);
2678 void status_update_cache(struct session
*);
2679 int status_at_line(struct client
*);
2680 u_int
status_line_size(struct client
*);
2681 struct style_range
*status_get_range(struct client
*, u_int
, u_int
);
2682 void status_init(struct client
*);
2683 void status_free(struct client
*);
2684 int status_redraw(struct client
*);
2685 void printflike(5, 6) status_message_set(struct client
*, int, int, int,
2687 void status_message_clear(struct client
*);
2688 int status_message_redraw(struct client
*);
2689 void status_prompt_set(struct client
*, struct cmd_find_state
*,
2690 const char *, const char *, prompt_input_cb
, prompt_free_cb
,
2691 void *, int, enum prompt_type
);
2692 void status_prompt_clear(struct client
*);
2693 int status_prompt_redraw(struct client
*);
2694 int status_prompt_key(struct client
*, key_code
);
2695 void status_prompt_update(struct client
*, const char *, const char *);
2696 void status_prompt_load_history(void);
2697 void status_prompt_save_history(void);
2698 const char *status_prompt_type_string(u_int
);
2699 enum prompt_type
status_prompt_type(const char *type
);
2702 void resize_window(struct window
*, u_int
, u_int
, int, int);
2703 void default_window_size(struct client
*, struct session
*, struct window
*,
2704 u_int
*, u_int
*, u_int
*, u_int
*, int);
2705 void recalculate_size(struct window
*, int);
2706 void recalculate_sizes(void);
2707 void recalculate_sizes_now(int);
2710 struct input_ctx
*input_init(struct window_pane
*, struct bufferevent
*,
2711 struct colour_palette
*);
2712 void input_free(struct input_ctx
*);
2713 void input_reset(struct input_ctx
*, int);
2714 struct evbuffer
*input_pending(struct input_ctx
*);
2715 void input_parse_pane(struct window_pane
*);
2716 void input_parse_buffer(struct window_pane
*, u_char
*, size_t);
2717 void input_parse_screen(struct input_ctx
*, struct screen
*,
2718 screen_write_init_ctx_cb
, void *, u_char
*, size_t);
2719 void input_reply_clipboard(struct bufferevent
*, const char *, size_t,
2723 void input_key_build(void);
2724 int input_key_pane(struct window_pane
*, key_code
, struct mouse_event
*);
2725 int input_key(struct screen
*, struct bufferevent
*, key_code
);
2726 int input_key_get_mouse(struct screen
*, struct mouse_event
*, u_int
,
2727 u_int
, const char **, size_t *);
2730 int colour_find_rgb(u_char
, u_char
, u_char
);
2731 int colour_join_rgb(u_char
, u_char
, u_char
);
2732 void colour_split_rgb(int, u_char
*, u_char
*, u_char
*);
2733 int colour_force_rgb(int);
2734 const char *colour_tostring(int);
2735 int colour_fromstring(const char *s
);
2736 int colour_256toRGB(int);
2737 int colour_256to16(int);
2738 int colour_byname(const char *);
2739 void colour_palette_init(struct colour_palette
*);
2740 void colour_palette_clear(struct colour_palette
*);
2741 void colour_palette_free(struct colour_palette
*);
2742 int colour_palette_get(struct colour_palette
*, int);
2743 int colour_palette_set(struct colour_palette
*, int, int);
2744 void colour_palette_from_option(struct colour_palette
*, struct options
*);
2747 const char *attributes_tostring(int);
2748 int attributes_fromstring(const char *);
2751 extern const struct grid_cell grid_default_cell
;
2752 void grid_empty_line(struct grid
*, u_int
, u_int
);
2753 int grid_cells_equal(const struct grid_cell
*, const struct grid_cell
*);
2754 int grid_cells_look_equal(const struct grid_cell
*,
2755 const struct grid_cell
*);
2756 struct grid
*grid_create(u_int
, u_int
, u_int
);
2757 void grid_destroy(struct grid
*);
2758 int grid_compare(struct grid
*, struct grid
*);
2759 void grid_collect_history(struct grid
*);
2760 void grid_remove_history(struct grid
*, u_int
);
2761 void grid_scroll_history(struct grid
*, u_int
);
2762 void grid_scroll_history_region(struct grid
*, u_int
, u_int
, u_int
);
2763 void grid_clear_history(struct grid
*);
2764 const struct grid_line
*grid_peek_line(struct grid
*, u_int
);
2765 void grid_get_cell(struct grid
*, u_int
, u_int
, struct grid_cell
*);
2766 void grid_set_cell(struct grid
*, u_int
, u_int
, const struct grid_cell
*);
2767 void grid_set_padding(struct grid
*, u_int
, u_int
);
2768 void grid_set_cells(struct grid
*, u_int
, u_int
, const struct grid_cell
*,
2769 const char *, size_t);
2770 struct grid_line
*grid_get_line(struct grid
*, u_int
);
2771 void grid_adjust_lines(struct grid
*, u_int
);
2772 void grid_clear(struct grid
*, u_int
, u_int
, u_int
, u_int
, u_int
);
2773 void grid_clear_lines(struct grid
*, u_int
, u_int
, u_int
);
2774 void grid_move_lines(struct grid
*, u_int
, u_int
, u_int
, u_int
);
2775 void grid_move_cells(struct grid
*, u_int
, u_int
, u_int
, u_int
, u_int
);
2776 char *grid_string_cells(struct grid
*, u_int
, u_int
, u_int
,
2777 struct grid_cell
**, int, int, int, struct screen
*);
2778 void grid_duplicate_lines(struct grid
*, u_int
, struct grid
*, u_int
,
2780 void grid_reflow(struct grid
*, u_int
);
2781 void grid_wrap_position(struct grid
*, u_int
, u_int
, u_int
*, u_int
*);
2782 void grid_unwrap_position(struct grid
*, u_int
*, u_int
*, u_int
, u_int
);
2783 u_int
grid_line_length(struct grid
*, u_int
);
2786 void grid_reader_start(struct grid_reader
*, struct grid
*, u_int
, u_int
);
2787 void grid_reader_get_cursor(struct grid_reader
*, u_int
*, u_int
*);
2788 u_int
grid_reader_line_length(struct grid_reader
*);
2789 int grid_reader_in_set(struct grid_reader
*, const char *);
2790 void grid_reader_cursor_right(struct grid_reader
*, int, int);
2791 void grid_reader_cursor_left(struct grid_reader
*, int);
2792 void grid_reader_cursor_down(struct grid_reader
*);
2793 void grid_reader_cursor_up(struct grid_reader
*);
2794 void grid_reader_cursor_start_of_line(struct grid_reader
*, int);
2795 void grid_reader_cursor_end_of_line(struct grid_reader
*, int, int);
2796 void grid_reader_cursor_next_word(struct grid_reader
*, const char *);
2797 void grid_reader_cursor_next_word_end(struct grid_reader
*, const char *);
2798 void grid_reader_cursor_previous_word(struct grid_reader
*, const char *,
2800 int grid_reader_cursor_jump(struct grid_reader
*,
2801 const struct utf8_data
*);
2802 int grid_reader_cursor_jump_back(struct grid_reader
*,
2803 const struct utf8_data
*);
2804 void grid_reader_cursor_back_to_indentation(struct grid_reader
*);
2807 void grid_view_get_cell(struct grid
*, u_int
, u_int
, struct grid_cell
*);
2808 void grid_view_set_cell(struct grid
*, u_int
, u_int
,
2809 const struct grid_cell
*);
2810 void grid_view_set_padding(struct grid
*, u_int
, u_int
);
2811 void grid_view_set_cells(struct grid
*, u_int
, u_int
,
2812 const struct grid_cell
*, const char *, size_t);
2813 void grid_view_clear_history(struct grid
*, u_int
);
2814 void grid_view_clear(struct grid
*, u_int
, u_int
, u_int
, u_int
, u_int
);
2815 void grid_view_scroll_region_up(struct grid
*, u_int
, u_int
, u_int
);
2816 void grid_view_scroll_region_down(struct grid
*, u_int
, u_int
, u_int
);
2817 void grid_view_insert_lines(struct grid
*, u_int
, u_int
, u_int
);
2818 void grid_view_insert_lines_region(struct grid
*, u_int
, u_int
, u_int
,
2820 void grid_view_delete_lines(struct grid
*, u_int
, u_int
, u_int
);
2821 void grid_view_delete_lines_region(struct grid
*, u_int
, u_int
, u_int
,
2823 void grid_view_insert_cells(struct grid
*, u_int
, u_int
, u_int
, u_int
);
2824 void grid_view_delete_cells(struct grid
*, u_int
, u_int
, u_int
, u_int
);
2825 char *grid_view_string_cells(struct grid
*, u_int
, u_int
, u_int
);
2827 /* screen-write.c */
2828 void screen_write_make_list(struct screen
*);
2829 void screen_write_free_list(struct screen
*);
2830 void screen_write_start_pane(struct screen_write_ctx
*,
2831 struct window_pane
*, struct screen
*);
2832 void screen_write_start(struct screen_write_ctx
*, struct screen
*);
2833 void screen_write_start_callback(struct screen_write_ctx
*, struct screen
*,
2834 screen_write_init_ctx_cb
, void *);
2835 void screen_write_stop(struct screen_write_ctx
*);
2836 void screen_write_reset(struct screen_write_ctx
*);
2837 size_t printflike(1, 2) screen_write_strlen(const char *, ...);
2838 int printflike(7, 8) screen_write_text(struct screen_write_ctx
*, u_int
, u_int
,
2839 u_int
, int, const struct grid_cell
*, const char *, ...);
2840 void printflike(3, 4) screen_write_puts(struct screen_write_ctx
*,
2841 const struct grid_cell
*, const char *, ...);
2842 void printflike(4, 5) screen_write_nputs(struct screen_write_ctx
*,
2843 ssize_t
, const struct grid_cell
*, const char *, ...);
2844 void printflike(4, 0) screen_write_vnputs(struct screen_write_ctx
*, ssize_t
,
2845 const struct grid_cell
*, const char *, va_list);
2846 void screen_write_putc(struct screen_write_ctx
*, const struct grid_cell
*,
2848 void screen_write_fast_copy(struct screen_write_ctx
*, struct screen
*,
2849 u_int
, u_int
, u_int
, u_int
);
2850 void screen_write_hline(struct screen_write_ctx
*, u_int
, int, int);
2851 void screen_write_vline(struct screen_write_ctx
*, u_int
, int, int);
2852 void screen_write_menu(struct screen_write_ctx
*, struct menu
*, int,
2853 const struct grid_cell
*);
2854 void screen_write_box(struct screen_write_ctx
*, u_int
, u_int
, int,
2855 const struct grid_cell
*, const char *);
2856 void screen_write_preview(struct screen_write_ctx
*, struct screen
*, u_int
,
2858 void screen_write_backspace(struct screen_write_ctx
*);
2859 void screen_write_mode_set(struct screen_write_ctx
*, int);
2860 void screen_write_mode_clear(struct screen_write_ctx
*, int);
2861 void screen_write_cursorup(struct screen_write_ctx
*, u_int
);
2862 void screen_write_cursordown(struct screen_write_ctx
*, u_int
);
2863 void screen_write_cursorright(struct screen_write_ctx
*, u_int
);
2864 void screen_write_cursorleft(struct screen_write_ctx
*, u_int
);
2865 void screen_write_alignmenttest(struct screen_write_ctx
*);
2866 void screen_write_insertcharacter(struct screen_write_ctx
*, u_int
, u_int
);
2867 void screen_write_deletecharacter(struct screen_write_ctx
*, u_int
, u_int
);
2868 void screen_write_clearcharacter(struct screen_write_ctx
*, u_int
, u_int
);
2869 void screen_write_insertline(struct screen_write_ctx
*, u_int
, u_int
);
2870 void screen_write_deleteline(struct screen_write_ctx
*, u_int
, u_int
);
2871 void screen_write_clearline(struct screen_write_ctx
*, u_int
);
2872 void screen_write_clearendofline(struct screen_write_ctx
*, u_int
);
2873 void screen_write_clearstartofline(struct screen_write_ctx
*, u_int
);
2874 void screen_write_cursormove(struct screen_write_ctx
*, int, int, int);
2875 void screen_write_reverseindex(struct screen_write_ctx
*, u_int
);
2876 void screen_write_scrollregion(struct screen_write_ctx
*, u_int
, u_int
);
2877 void screen_write_linefeed(struct screen_write_ctx
*, int, u_int
);
2878 void screen_write_scrollup(struct screen_write_ctx
*, u_int
, u_int
);
2879 void screen_write_scrolldown(struct screen_write_ctx
*, u_int
, u_int
);
2880 void screen_write_carriagereturn(struct screen_write_ctx
*);
2881 void screen_write_clearendofscreen(struct screen_write_ctx
*, u_int
);
2882 void screen_write_clearstartofscreen(struct screen_write_ctx
*, u_int
);
2883 void screen_write_clearscreen(struct screen_write_ctx
*, u_int
);
2884 void screen_write_clearhistory(struct screen_write_ctx
*);
2885 void screen_write_fullredraw(struct screen_write_ctx
*);
2886 void screen_write_collect_end(struct screen_write_ctx
*);
2887 void screen_write_collect_add(struct screen_write_ctx
*,
2888 const struct grid_cell
*);
2889 void screen_write_cell(struct screen_write_ctx
*, const struct grid_cell
*);
2890 void screen_write_setselection(struct screen_write_ctx
*, const char *,
2892 void screen_write_rawstring(struct screen_write_ctx
*, u_char
*, u_int
);
2893 void screen_write_alternateon(struct screen_write_ctx
*,
2894 struct grid_cell
*, int);
2895 void screen_write_alternateoff(struct screen_write_ctx
*,
2896 struct grid_cell
*, int);
2898 /* screen-redraw.c */
2899 void screen_redraw_screen(struct client
*);
2900 void screen_redraw_pane(struct client
*, struct window_pane
*);
2903 void screen_init(struct screen
*, u_int
, u_int
, u_int
);
2904 void screen_reinit(struct screen
*);
2905 void screen_free(struct screen
*);
2906 void screen_reset_tabs(struct screen
*);
2907 void screen_reset_hyperlinks(struct screen
*);
2908 void screen_set_cursor_style(u_int
, enum screen_cursor_style
*, int *);
2909 void screen_set_cursor_colour(struct screen
*, int);
2910 int screen_set_title(struct screen
*, const char *);
2911 void screen_set_path(struct screen
*, const char *);
2912 void screen_push_title(struct screen
*);
2913 void screen_pop_title(struct screen
*);
2914 void screen_resize(struct screen
*, u_int
, u_int
, int);
2915 void screen_resize_cursor(struct screen
*, u_int
, u_int
, int, int, int);
2916 void screen_set_selection(struct screen
*, u_int
, u_int
, u_int
, u_int
,
2917 u_int
, int, struct grid_cell
*);
2918 void screen_clear_selection(struct screen
*);
2919 void screen_hide_selection(struct screen
*);
2920 int screen_check_selection(struct screen
*, u_int
, u_int
);
2921 void screen_select_cell(struct screen
*, struct grid_cell
*,
2922 const struct grid_cell
*);
2923 void screen_alternate_on(struct screen
*, struct grid_cell
*, int);
2924 void screen_alternate_off(struct screen
*, struct grid_cell
*, int);
2925 const char *screen_mode_to_string(int);
2928 extern struct windows windows
;
2929 extern struct window_pane_tree all_window_panes
;
2930 int window_cmp(struct window
*, struct window
*);
2931 RB_PROTOTYPE(windows
, window
, entry
, window_cmp
);
2932 int winlink_cmp(struct winlink
*, struct winlink
*);
2933 RB_PROTOTYPE(winlinks
, winlink
, entry
, winlink_cmp
);
2934 int window_pane_cmp(struct window_pane
*, struct window_pane
*);
2935 RB_PROTOTYPE(window_pane_tree
, window_pane
, tree_entry
, window_pane_cmp
);
2936 struct winlink
*winlink_find_by_index(struct winlinks
*, int);
2937 struct winlink
*winlink_find_by_window(struct winlinks
*, struct window
*);
2938 struct winlink
*winlink_find_by_window_id(struct winlinks
*, u_int
);
2939 u_int
winlink_count(struct winlinks
*);
2940 struct winlink
*winlink_add(struct winlinks
*, int);
2941 void winlink_set_window(struct winlink
*, struct window
*);
2942 void winlink_remove(struct winlinks
*, struct winlink
*);
2943 struct winlink
*winlink_next(struct winlink
*);
2944 struct winlink
*winlink_previous(struct winlink
*);
2945 struct winlink
*winlink_next_by_number(struct winlink
*, struct session
*,
2947 struct winlink
*winlink_previous_by_number(struct winlink
*, struct session
*,
2949 void winlink_stack_push(struct winlink_stack
*, struct winlink
*);
2950 void winlink_stack_remove(struct winlink_stack
*, struct winlink
*);
2951 struct window
*window_find_by_id_str(const char *);
2952 struct window
*window_find_by_id(u_int
);
2953 void window_update_activity(struct window
*);
2954 struct window
*window_create(u_int
, u_int
, u_int
, u_int
);
2955 void window_pane_set_event(struct window_pane
*);
2956 struct window_pane
*window_get_active_at(struct window
*, u_int
, u_int
);
2957 struct window_pane
*window_find_string(struct window
*, const char *);
2958 int window_has_pane(struct window
*, struct window_pane
*);
2959 int window_set_active_pane(struct window
*, struct window_pane
*,
2961 void window_update_focus(struct window
*);
2962 void window_pane_update_focus(struct window_pane
*);
2963 void window_redraw_active_switch(struct window
*,
2964 struct window_pane
*);
2965 struct window_pane
*window_add_pane(struct window
*, struct window_pane
*,
2967 void window_resize(struct window
*, u_int
, u_int
, int, int);
2968 void window_pane_send_resize(struct window_pane
*, u_int
, u_int
);
2969 int window_zoom(struct window_pane
*);
2970 int window_unzoom(struct window
*);
2971 int window_push_zoom(struct window
*, int, int);
2972 int window_pop_zoom(struct window
*);
2973 void window_lost_pane(struct window
*, struct window_pane
*);
2974 void window_remove_pane(struct window
*, struct window_pane
*);
2975 struct window_pane
*window_pane_at_index(struct window
*, u_int
);
2976 struct window_pane
*window_pane_next_by_number(struct window
*,
2977 struct window_pane
*, u_int
);
2978 struct window_pane
*window_pane_previous_by_number(struct window
*,
2979 struct window_pane
*, u_int
);
2980 int window_pane_index(struct window_pane
*, u_int
*);
2981 u_int
window_count_panes(struct window
*);
2982 void window_destroy_panes(struct window
*);
2983 struct window_pane
*window_pane_find_by_id_str(const char *);
2984 struct window_pane
*window_pane_find_by_id(u_int
);
2985 int window_pane_destroy_ready(struct window_pane
*);
2986 void window_pane_resize(struct window_pane
*, u_int
, u_int
);
2987 int window_pane_set_mode(struct window_pane
*,
2988 struct window_pane
*, const struct window_mode
*,
2989 struct cmd_find_state
*, struct args
*);
2990 void window_pane_reset_mode(struct window_pane
*);
2991 void window_pane_reset_mode_all(struct window_pane
*);
2992 int window_pane_key(struct window_pane
*, struct client
*,
2993 struct session
*, struct winlink
*, key_code
,
2994 struct mouse_event
*);
2995 int window_pane_visible(struct window_pane
*);
2996 u_int
window_pane_search(struct window_pane
*, const char *, int,
2998 const char *window_printable_flags(struct winlink
*, int);
2999 struct window_pane
*window_pane_find_up(struct window_pane
*);
3000 struct window_pane
*window_pane_find_down(struct window_pane
*);
3001 struct window_pane
*window_pane_find_left(struct window_pane
*);
3002 struct window_pane
*window_pane_find_right(struct window_pane
*);
3003 void window_set_name(struct window
*, const char *);
3004 void window_add_ref(struct window
*, const char *);
3005 void window_remove_ref(struct window
*, const char *);
3006 void winlink_clear_flags(struct winlink
*);
3007 int winlink_shuffle_up(struct session
*, struct winlink
*, int);
3008 int window_pane_start_input(struct window_pane
*,
3009 struct cmdq_item
*, char **);
3010 void *window_pane_get_new_data(struct window_pane
*,
3011 struct window_pane_offset
*, size_t *);
3012 void window_pane_update_used_data(struct window_pane
*,
3013 struct window_pane_offset
*, size_t);
3014 void window_set_fill_character(struct window
*);
3015 void window_pane_default_cursor(struct window_pane
*);
3018 u_int
layout_count_cells(struct layout_cell
*);
3019 struct layout_cell
*layout_create_cell(struct layout_cell
*);
3020 void layout_free_cell(struct layout_cell
*);
3021 void layout_print_cell(struct layout_cell
*, const char *, u_int
);
3022 void layout_destroy_cell(struct window
*, struct layout_cell
*,
3023 struct layout_cell
**);
3024 void layout_resize_layout(struct window
*, struct layout_cell
*,
3025 enum layout_type
, int, int);
3026 struct layout_cell
*layout_search_by_border(struct layout_cell
*, u_int
, u_int
);
3027 void layout_set_size(struct layout_cell
*, u_int
, u_int
, u_int
,
3029 void layout_make_leaf(struct layout_cell
*, struct window_pane
*);
3030 void layout_make_node(struct layout_cell
*, enum layout_type
);
3031 void layout_fix_offsets(struct window
*);
3032 void layout_fix_panes(struct window
*, struct window_pane
*);
3033 void layout_resize_adjust(struct window
*, struct layout_cell
*,
3034 enum layout_type
, int);
3035 void layout_init(struct window
*, struct window_pane
*);
3036 void layout_free(struct window
*);
3037 void layout_resize(struct window
*, u_int
, u_int
);
3038 void layout_resize_pane(struct window_pane
*, enum layout_type
,
3040 void layout_resize_pane_to(struct window_pane
*, enum layout_type
,
3042 void layout_assign_pane(struct layout_cell
*, struct window_pane
*,
3044 struct layout_cell
*layout_split_pane(struct window_pane
*, enum layout_type
,
3046 void layout_close_pane(struct window_pane
*);
3047 int layout_spread_cell(struct window
*, struct layout_cell
*);
3048 void layout_spread_out(struct window_pane
*);
3050 /* layout-custom.c */
3051 char *layout_dump(struct layout_cell
*);
3052 int layout_parse(struct window
*, const char *, char **);
3055 int layout_set_lookup(const char *);
3056 u_int
layout_set_select(struct window
*, u_int
);
3057 u_int
layout_set_next(struct window
*);
3058 u_int
layout_set_previous(struct window
*);
3061 typedef void (*mode_tree_build_cb
)(void *, struct mode_tree_sort_criteria
*,
3062 uint64_t *, const char *);
3063 typedef void (*mode_tree_draw_cb
)(void *, void *, struct screen_write_ctx
*,
3065 typedef int (*mode_tree_search_cb
)(void *, void *, const char *);
3066 typedef void (*mode_tree_menu_cb
)(void *, struct client
*, key_code
);
3067 typedef u_int (*mode_tree_height_cb
)(void *, u_int
);
3068 typedef key_code (*mode_tree_key_cb
)(void *, void *, u_int
);
3069 typedef void (*mode_tree_each_cb
)(void *, void *, struct client
*, key_code
);
3070 u_int
mode_tree_count_tagged(struct mode_tree_data
*);
3071 void *mode_tree_get_current(struct mode_tree_data
*);
3072 const char *mode_tree_get_current_name(struct mode_tree_data
*);
3073 void mode_tree_expand_current(struct mode_tree_data
*);
3074 void mode_tree_collapse_current(struct mode_tree_data
*);
3075 void mode_tree_expand(struct mode_tree_data
*, uint64_t);
3076 int mode_tree_set_current(struct mode_tree_data
*, uint64_t);
3077 void mode_tree_each_tagged(struct mode_tree_data
*, mode_tree_each_cb
,
3078 struct client
*, key_code
, int);
3079 void mode_tree_up(struct mode_tree_data
*, int);
3080 void mode_tree_down(struct mode_tree_data
*, int);
3081 struct mode_tree_data
*mode_tree_start(struct window_pane
*, struct args
*,
3082 mode_tree_build_cb
, mode_tree_draw_cb
, mode_tree_search_cb
,
3083 mode_tree_menu_cb
, mode_tree_height_cb
, mode_tree_key_cb
, void *,
3084 const struct menu_item
*, const char **, u_int
, struct screen
**);
3085 void mode_tree_zoom(struct mode_tree_data
*, struct args
*);
3086 void mode_tree_build(struct mode_tree_data
*);
3087 void mode_tree_free(struct mode_tree_data
*);
3088 void mode_tree_resize(struct mode_tree_data
*, u_int
, u_int
);
3089 struct mode_tree_item
*mode_tree_add(struct mode_tree_data
*,
3090 struct mode_tree_item
*, void *, uint64_t, const char *,
3092 void mode_tree_draw_as_parent(struct mode_tree_item
*);
3093 void mode_tree_no_tag(struct mode_tree_item
*);
3094 void mode_tree_remove(struct mode_tree_data
*, struct mode_tree_item
*);
3095 void mode_tree_draw(struct mode_tree_data
*);
3096 int mode_tree_key(struct mode_tree_data
*, struct client
*, key_code
*,
3097 struct mouse_event
*, u_int
*, u_int
*);
3098 void mode_tree_run_command(struct client
*, struct cmd_find_state
*,
3099 const char *, const char *);
3101 /* window-buffer.c */
3102 extern const struct window_mode window_buffer_mode
;
3105 extern const struct window_mode window_tree_mode
;
3107 /* window-clock.c */
3108 extern const struct window_mode window_clock_mode
;
3109 extern const char window_clock_table
[14][5][5];
3111 /* window-client.c */
3112 extern const struct window_mode window_client_mode
;
3115 extern const struct window_mode window_copy_mode
;
3116 extern const struct window_mode window_view_mode
;
3117 void printflike(3, 4) window_copy_add(struct window_pane
*, int, const char *,
3119 void printflike(3, 0) window_copy_vadd(struct window_pane
*, int, const char *,
3121 void window_copy_pageup(struct window_pane
*, int);
3122 void window_copy_start_drag(struct client
*, struct mouse_event
*);
3123 char *window_copy_get_word(struct window_pane
*, u_int
, u_int
);
3124 char *window_copy_get_line(struct window_pane
*, u_int
);
3126 /* window-option.c */
3127 extern const struct window_mode window_customize_mode
;
3130 void check_window_name(struct window
*);
3131 char *default_window_name(struct window
*);
3132 char *parse_window_name(const char *);
3135 void control_discard(struct client
*);
3136 void control_start(struct client
*);
3137 void control_stop(struct client
*);
3138 void control_set_pane_on(struct client
*, struct window_pane
*);
3139 void control_set_pane_off(struct client
*, struct window_pane
*);
3140 void control_continue_pane(struct client
*, struct window_pane
*);
3141 void control_pause_pane(struct client
*, struct window_pane
*);
3142 struct window_pane_offset
*control_pane_offset(struct client
*,
3143 struct window_pane
*, int *);
3144 void control_reset_offsets(struct client
*);
3145 void printflike(2, 3) control_write(struct client
*, const char *, ...);
3146 void control_write_output(struct client
*, struct window_pane
*);
3147 int control_all_done(struct client
*);
3148 void control_add_sub(struct client
*, const char *, enum control_sub_type
,
3150 void control_remove_sub(struct client
*, const char *);
3152 /* control-notify.c */
3153 void control_notify_input(struct client
*, struct window_pane
*,
3154 const u_char
*, size_t);
3155 void control_notify_pane_mode_changed(int);
3156 void control_notify_window_layout_changed(struct window
*);
3157 void control_notify_window_pane_changed(struct window
*);
3158 void control_notify_window_unlinked(struct session
*, struct window
*);
3159 void control_notify_window_linked(struct session
*, struct window
*);
3160 void control_notify_window_renamed(struct window
*);
3161 void control_notify_client_session_changed(struct client
*);
3162 void control_notify_client_detached(struct client
*);
3163 void control_notify_session_renamed(struct session
*);
3164 void control_notify_session_created(struct session
*);
3165 void control_notify_session_closed(struct session
*);
3166 void control_notify_session_window_changed(struct session
*);
3169 extern struct sessions sessions
;
3170 extern u_int next_session_id
;
3171 int session_cmp(struct session
*, struct session
*);
3172 RB_PROTOTYPE(sessions
, session
, entry
, session_cmp
);
3173 int session_alive(struct session
*);
3174 struct session
*session_find(const char *);
3175 struct session
*session_find_by_id_str(const char *);
3176 struct session
*session_find_by_id(u_int
);
3177 struct session
*session_create(const char *, const char *, const char *,
3178 struct environ
*, struct options
*, struct termios
*);
3179 void session_destroy(struct session
*, int, const char *);
3180 void session_add_ref(struct session
*, const char *);
3181 void session_remove_ref(struct session
*, const char *);
3182 char *session_check_name(const char *);
3183 void session_update_activity(struct session
*, struct timeval
*);
3184 struct session
*session_next_session(struct session
*);
3185 struct session
*session_previous_session(struct session
*);
3186 struct winlink
*session_new(struct session
*, const char *, int, char **,
3187 const char *, const char *, int, char **);
3188 struct winlink
*session_attach(struct session
*, struct window
*, int,
3190 int session_detach(struct session
*, struct winlink
*);
3191 int session_has(struct session
*, struct window
*);
3192 int session_is_linked(struct session
*, struct window
*);
3193 int session_next(struct session
*, int);
3194 int session_previous(struct session
*, int);
3195 int session_select(struct session
*, int);
3196 int session_last(struct session
*);
3197 int session_set_current(struct session
*, struct winlink
*);
3198 struct session_group
*session_group_contains(struct session
*);
3199 struct session_group
*session_group_find(const char *);
3200 struct session_group
*session_group_new(const char *);
3201 void session_group_add(struct session_group
*, struct session
*);
3202 void session_group_synchronize_to(struct session
*);
3203 void session_group_synchronize_from(struct session
*);
3204 u_int
session_group_count(struct session_group
*);
3205 u_int
session_group_attached_count(struct session_group
*);
3206 void session_renumber_windows(struct session
*);
3209 utf8_char
utf8_build_one(u_char
);
3210 enum utf8_state
utf8_from_data(const struct utf8_data
*, utf8_char
*);
3211 void utf8_to_data(utf8_char
, struct utf8_data
*);
3212 void utf8_set(struct utf8_data
*, u_char
);
3213 void utf8_copy(struct utf8_data
*, const struct utf8_data
*);
3214 enum utf8_state
utf8_open(struct utf8_data
*, u_char
);
3215 enum utf8_state
utf8_append(struct utf8_data
*, u_char
);
3216 int utf8_isvalid(const char *);
3217 int utf8_strvis(char *, const char *, size_t, int);
3218 int utf8_stravis(char **, const char *, int);
3219 int utf8_stravisx(char **, const char *, size_t, int);
3220 char *utf8_sanitize(const char *);
3221 size_t utf8_strlen(const struct utf8_data
*);
3222 u_int
utf8_strwidth(const struct utf8_data
*, ssize_t
);
3223 struct utf8_data
*utf8_fromcstr(const char *);
3224 char *utf8_tocstr(struct utf8_data
*);
3225 u_int
utf8_cstrwidth(const char *);
3226 char *utf8_padcstr(const char *, u_int
);
3227 char *utf8_rpadcstr(const char *, u_int
);
3228 int utf8_cstrhas(const char *, const struct utf8_data
*);
3231 char *get_proc_name(int, char *);
3232 char *get_proc_cwd(int);
3235 void log_add_level(void);
3236 int log_get_level(void);
3237 void log_open(const char *);
3238 void log_toggle(const char *);
3239 void log_close(void);
3240 void printflike(1, 2) log_debug(const char *, ...);
3241 __dead
void printflike(1, 2) fatal(const char *, ...);
3242 __dead
void printflike(1, 2) fatalx(const char *, ...);
3245 #define MENU_NOMOUSE 0x1
3246 #define MENU_TAB 0x2
3247 #define MENU_STAYOPEN 0x4
3248 struct menu
*menu_create(const char *);
3249 void menu_add_items(struct menu
*, const struct menu_item
*,
3250 struct cmdq_item
*, struct client
*,
3251 struct cmd_find_state
*);
3252 void menu_add_item(struct menu
*, const struct menu_item
*,
3253 struct cmdq_item
*, struct client
*,
3254 struct cmd_find_state
*);
3255 void menu_free(struct menu
*);
3256 struct menu_data
*menu_prepare(struct menu
*, int, struct cmdq_item
*, u_int
,
3257 u_int
, struct client
*, struct cmd_find_state
*,
3258 menu_choice_cb
, void *);
3259 int menu_display(struct menu
*, int, struct cmdq_item
*, u_int
,
3260 u_int
, struct client
*, struct cmd_find_state
*,
3261 menu_choice_cb
, void *);
3262 struct screen
*menu_mode_cb(struct client
*, void *, u_int
*, u_int
*);
3263 void menu_check_cb(struct client
*, void *, u_int
, u_int
, u_int
,
3264 struct overlay_ranges
*);
3265 void menu_draw_cb(struct client
*, void *,
3266 struct screen_redraw_ctx
*);
3267 void menu_free_cb(struct client
*, void *);
3268 int menu_key_cb(struct client
*, void *, struct key_event
*);
3271 #define POPUP_CLOSEEXIT 0x1
3272 #define POPUP_CLOSEEXITZERO 0x2
3273 #define POPUP_INTERNAL 0x4
3274 typedef void (*popup_close_cb
)(int, void *);
3275 typedef void (*popup_finish_edit_cb
)(char *, size_t, void *);
3276 int popup_display(int, int, struct cmdq_item
*, u_int
, u_int
,
3277 u_int
, u_int
, struct environ
*, const char *, int, char **,
3278 const char *, const char *, struct client
*,
3279 struct session
*, const char *, const char *,
3280 popup_close_cb
, void *);
3281 int popup_editor(struct client
*, const char *, size_t,
3282 popup_finish_edit_cb
, void *);
3285 int style_parse(struct style
*,const struct grid_cell
*,
3287 const char *style_tostring(struct style
*);
3288 void style_add(struct grid_cell
*, struct options
*,
3289 const char *, struct format_tree
*);
3290 void style_apply(struct grid_cell
*, struct options
*,
3291 const char *, struct format_tree
*);
3292 void style_set(struct style
*, const struct grid_cell
*);
3293 void style_copy(struct style
*, struct style
*);
3296 struct winlink
*spawn_window(struct spawn_context
*, char **);
3297 struct window_pane
*spawn_pane(struct spawn_context
*, char **);
3300 char *regsub(const char *, const char *, const char *, int);
3303 void server_acl_init(void);
3304 struct server_acl_user
*server_acl_user_find(uid_t
);
3305 void server_acl_display(struct cmdq_item
*);
3306 void server_acl_user_allow(uid_t
);
3307 void server_acl_user_deny(uid_t
);
3308 void server_acl_user_allow_write(uid_t
);
3309 void server_acl_user_deny_write(uid_t
);
3310 int server_acl_join(struct client
*);
3311 uid_t
server_acl_get_uid(struct server_acl_user
*);
3314 u_int
hyperlinks_put(struct hyperlinks
*, const char *,
3316 int hyperlinks_get(struct hyperlinks
*, u_int
,
3317 const char **, const char **, const char **);
3318 struct hyperlinks
*hyperlinks_init(void);
3319 void hyperlinks_reset(struct hyperlinks
*);
3320 void hyperlinks_free(struct hyperlinks
*);