aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/dvtm/dvtm.h
blob: c36cb875d8c44b87e35497dfcb9b3f798d24cdd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
 /* See LICENSE for details. */
#pragma once
#include <u.h>
#include <libn.h>

#include <locale.h>
#include <libgen.h>

#include <sys/select.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/types.h>

#include <termios.h>

#include "vt.h"

#ifdef PDCURSES
int ESCDELAY;
#endif

#ifndef NCURSES_REENTRANT
#define set_escdelay(d) (ESCDELAY = (d))
#endif

typedef struct {
	float mfact;
	uint nmaster;
	int history;
	int w;
	int h;
	volatile sig_atomic_t need_resize;
} Screen;

typedef struct {
	const char *symbol;
	void (*arrange)(void);
} Layout;

typedef struct Client Client;
struct Client {
	WINDOW *window;
	Vt *term;
	Vt *editor, *app;
	int editor_fds[2];
	volatile sig_atomic_t editor_died;
	const char *cmd;
	char title[255];
	int order;
	pid_t pid;
	ushort id;
	ushort x;
	ushort y;
	ushort w;
	ushort h;
	bool has_title_line;
	bool minimized;
	bool urgent;
	volatile sig_atomic_t died;
	Client *next;
	Client *prev;
	Client *snext;
	uint tags;
};

typedef struct {
	short fg;
	short bg;
	short fg256;
	short bg256;
	short pair;
} Color;

typedef struct {
	const char *title;
	attr_t attrs;
	Color *color;
} ColorRule;

#define ALT(k)      ((k) + (161 - 'a'))

#if defined CTRL && defined _AIX
#undef CTRL
#endif

#ifndef CTRL
#define CTRL(k)   ((k) & 0x1F)
#endif
#define CTRL_ALT(k) ((k) + (129 - 'a'))

#define MAX_ARGS 8

typedef struct {
	void (*cmd)(const char *args[]);
	const char *args[3];
} Action;

#define MAX_KEYS 3

typedef uint KeyCombo[MAX_KEYS];

typedef struct {
	KeyCombo keys;
	Action action;
} KeyBinding;

typedef struct {
	mmask_t mask;
	Action action;
} Button;

typedef struct {
	const char *name;
	Action action;
} Cmd;

enum { BAR_TOP, BAR_BOTTOM, BAR_OFF };

typedef struct {
	int fd;
	int pos, lastpos;
	bool autohide;
	ushort h;
	ushort y;
	char text[512];
	const char *file;
} StatusBar;

typedef struct {
	int fd;
	const char *file;
	ushort id;
} CmdFifo;

typedef struct {
	char *data;
	size_t len;
	size_t size;
} Register;

typedef struct {
	char *name;
	const char *argv[4];
	bool filter;
	bool color;
} Editor;

#define TAGMASK     ((1 << arrlen(tags)) - 1)

#ifdef NDEBUG
 #define debug(format, args...)
#else
 #define debug eprint
#endif

/* commands for use by keybindings */
void create(const char *args[]);
void copymode(const char *args[]);
void focusn(const char *args[]);
void focusid(const char *args[]);
void focusnext(const char *args[]);
void focusnextnm(const char *args[]);
void focusprev(const char *args[]);
void focusprevnm(const char *args[]);
void focuslast(const char *args[]);
void focusup(const char *args[]);
void focusdown(const char *args[]);
void focusleft(const char *args[]);
void focusright(const char *args[]);
void killclient(const char *args[]);
void paste(const char *args[]);
void quit(const char *args[]);
void redraw(const char *args[]);
void scrollback(const char *args[]);
void send(const char *args[]);
void setlayout(const char *args[]);
void incnmaster(const char *args[]);
void setmfact(const char *args[]);
void startup(const char *args[]);
void tag(const char *args[]);
void tagid(const char *args[]);
void togglebar(const char *args[]);
void togglebarpos(const char *args[]);
void toggleminimize(const char *args[]);
void togglemouse(const char *args[]);
void togglerunall(const char *args[]);
void toggletag(const char *args[]);
void toggleview(const char *args[]);
void viewprevtag(const char *args[]);
void view(const char *args[]);
void zoom(const char *args[]);

/* commands for use by mouse bindings */
void mouse_focus(const char *args[]);
void mouse_fullscreen(const char *args[]);
void mouse_minimize(const char *args[]);
void mouse_zoom(const char *args[]);

/* functions and variables available to layouts via config.h */
Client* nextvisible(Client *c);
void focus(Client *c);
void resize(Client *c, int x, int y, int w, int h);

extern Screen screen;
extern uint waw, wah, wax, way;
extern Client *clients;
extern char *title;

void fibonacci(int s);
void spiral(void);
void dwindle(void);
void fullscreen(void);
void grid(void);
void tile(void);
void tstack(void);
void bstack(void);
void vstack(void);

#include "config.h"