aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/dvtm/dvtm.h
blob: f89f5178ef1183a097c9a9ec4c60c4d461104465 (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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
 /* 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 <vendor/curses.h>
#include <termios.h>

#include "vt.h"

/* types */
typedef struct Term   Term;
typedef struct Screen Screen;
typedef struct Layout Layout;
typedef struct Window Window;
typedef struct Client Client;

typedef struct Cmd        Cmd;
typedef struct CmdFifo    CmdFifo;
typedef struct Register   Register;
typedef struct Editor     Editor;

typedef struct Button     Button;
typedef struct KeyBinding KeyBinding;
typedef struct StatusBar  StatusBar;

struct Screen 
{
    Term    *backend;
	float    mfact;
	uint     nmaster;
	int      history;
	int      w, h;
	volatile sig_atomic_t need_resize;
};

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

struct Client 
{
	Window *window;
	Vt     *term;
	Vt     *editor, *app;
    /* meta data */
	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, y, w, h;
	bool has_title_line;
	bool minimized;
	bool urgent;
	volatile sig_atomic_t died;
	Client *next, *prev, *snext;
	uint tags;
};

#if 0
typedef struct {
	int fg;
	int bg;
	int fg256;
	int bg256;
	int pair;
} Color;

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

#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];

struct KeyBinding 
{
	KeyCombo keys;
	Action action;
};

struct Button 
{
	mmask_t mask;
	Action action;
};

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

enum { BAR_TOP, BAR_BOTTOM, BAR_OFF };

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

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

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

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

#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"