]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/rio/dat.h
dd7d560d530508bc2c0316329012b9de5a98adf8
[plan9front.git] / sys / src / cmd / rio / dat.h
1 enum
2 {
3         Qdir,                   /* /dev for this window */
4         Qcons,
5         Qconsctl,
6         Qcursor,
7         Qwdir,
8         Qwinid,
9         Qwinname,
10         Qkbdin,
11         Qlabel,
12         Qkbd,
13         Qmouse,
14         Qnew,
15         Qscreen,
16         Qsnarf,
17         Qtext,
18         Qwctl,
19         Qwindow,
20         Qwsys,          /* directory of window directories */
21         Qwsysdir,               /* window directory, child of wsys */
22
23         QMAX,
24 };
25
26 #define STACK   8192
27
28 typedef struct  Consreadmesg Consreadmesg;
29 typedef struct  Conswritemesg Conswritemesg;
30 typedef struct  Kbdreadmesg Kbdreadmesg;
31 typedef struct  Stringpair Stringpair;
32 typedef struct  Dirtab Dirtab;
33 typedef struct  Fid Fid;
34 typedef struct  Filsys Filsys;
35 typedef struct  Mouseinfo       Mouseinfo;
36 typedef struct  Mousereadmesg Mousereadmesg;
37 typedef struct  Mousestate      Mousestate;
38 typedef struct  Ref Ref;
39 typedef struct  Timer Timer;
40 typedef struct  Wctlmesg Wctlmesg;
41 typedef struct  Window Window;
42 typedef struct  Xfid Xfid;
43
44 enum
45 {
46         Selborder               = 4,            /* border of selected window */
47         Unselborder     = 1,            /* border of unselected window */
48         Scrollwid               = 12,           /* width of scroll bar */
49         Scrollgap               = 4,            /* gap right of scroll bar */
50         BIG                     = 3,            /* factor by which window dimension can exceed screen */
51         TRUE            = 1,
52         FALSE           = 0,
53 };
54
55 #define QID(w,q)        ((w<<8)|(q))
56 #define WIN(q)  ((((ulong)(q).path)>>8) & 0xFFFFFF)
57 #define FILE(q) (((ulong)(q).path) & 0xFF)
58
59 enum    /* control messages */
60 {
61         Wakeup,
62         Reshaped,
63         Moved,
64         Topped,
65         Repaint,
66         Refresh,
67         Movemouse,
68         Rawon,
69         Rawoff,
70         Holdon,
71         Holdoff,
72         Deleted,
73         Exited,
74 };
75
76 struct Wctlmesg
77 {
78         int             type;
79         Rectangle       r;
80         void            *p;
81 };
82
83 struct Conswritemesg
84 {
85         Channel *cw;            /* chan(Stringpair) */
86 };
87
88 struct Consreadmesg
89 {
90         Channel *c1;            /* chan(tuple(char*, int) == Stringpair) */
91         Channel *c2;            /* chan(tuple(char*, int) == Stringpair) */
92 };
93
94 struct Mousereadmesg
95 {
96         Channel *cm;            /* chan(Mouse) */
97 };
98
99 struct Kbdreadmesg
100 {
101         Channel *ck;            /* chan(char*) */
102 };
103
104 struct Stringpair       /* rune and nrune or byte and nbyte */
105 {
106         void            *s;
107         int             ns;
108 };
109
110 struct Mousestate
111 {
112         Mouse;
113         ulong   counter;        /* serial no. of mouse event */
114 };
115
116 struct Mouseinfo
117 {
118         Mousestate      queue[16];
119         int     ri;     /* read index into queue */
120         int     wi;     /* write index */
121         ulong   counter;        /* serial no. of last mouse event we received */
122         ulong   lastcounter;    /* serial no. of last mouse event sent to client */
123         int     lastb;  /* last button state we received */
124         uchar   qfull;  /* filled the queue; no more recording until client comes back */       
125 };      
126
127 struct Window
128 {
129         Ref;
130         QLock;
131         Frame;
132         Image           *i;             /* window image, nil when deleted */
133         Mousectl        mc;
134         Mouseinfo       mouse;
135         Channel         *ck;            /* chan(char*) */
136         Channel         *cctl;          /* chan(Wctlmesg)[4] */
137         Channel         *conswrite;     /* chan(Conswritemesg) */
138         Channel         *consread;      /* chan(Consreadmesg) */
139         Channel         *mouseread;     /* chan(Mousereadmesg) */
140         Channel         *wctlread;      /* chan(Consreadmesg) */
141         Channel         *kbdread;       /* chan(Kbdreadmesg) */
142         Channel         *complete;      /* chan(Completion*) */
143         Channel         *gone;          /* chan(char*) */
144         uint                    nr;                     /* number of runes in window */
145         uint                    maxr;           /* number of runes allocated in r */
146         Rune                    *r;
147         uint                    nraw;
148         Rune                    *raw;
149         uint                    org;
150         uint                    q0;
151         uint                    q1;
152         uint                    qh;
153         int                     id;
154         char                    name[32];
155         uint                    namecount;
156         Rectangle               scrollr;
157         /*
158          * Rio once used originwindow, so screenr could be different from i->r.
159          * Now they're always the same but the code doesn't assume so.
160         */
161         Rectangle               screenr;        /* screen coordinates of window */
162         int                     resized;
163         int                     wctlready;
164         Rectangle               lastsr;
165         int                     topped;
166         int                     notefd;
167         uchar           scrolling;
168         Cursor          cursor;
169         Cursor          *cursorp;
170         uchar           holding;
171         uchar           rawing;
172         uchar           ctlopen;
173         uchar           wctlopen;
174         uchar           deleted;
175         uchar           mouseopen;
176         uchar           kbdopen;
177         char                    *label;
178         char                    *dir;
179 };
180
181 int             winborder(Window*, Point);
182 void            winctl(void*);
183 void            winshell(void*);
184 Window* wlookid(int);
185 Window* wmk(Image*, Mousectl*, Channel*, Channel*, int);
186 Window* wpointto(Point);
187 Window* wtop(Point);
188 void            wtopme(Window*);
189 void            wbottomme(Window*);
190 char*   wcontents(Window*, int*);
191 int             wbswidth(Window*, Rune);
192 int             wclickmatch(Window*, int, int, int, uint*);
193 int             wclose(Window*);
194 int             wctlmesg(Window*, int, Rectangle, void*);
195 uint            wbacknl(Window*, uint, uint);
196 uint            winsert(Window*, Rune*, int, uint);
197 void            waddraw(Window*, Rune*, int);
198 void            wborder(Window*, int);
199 void            wclunk(Window*);
200 void            wclosewin(Window*);
201 void            wcurrent(Window*);
202 void            wcut(Window*);
203 void            wdelete(Window*, uint, uint);
204 void            wdoubleclick(Window*, uint*, uint*);
205 void            wfill(Window*);
206 void            wframescroll(Window*, int);
207 void            wkeyctl(Window*, Rune);
208 void            wmousectl(Window*);
209 void            wmovemouse(Window*, Point);
210 void            wpaste(Window*);
211 void            wplumb(Window*);
212 void            wrefresh(Window*, Rectangle);
213 void            wrepaint(Window*);
214 void            wresize(Window*, Image*, int);
215 void            wscrdraw(Window*);
216 void            wscroll(Window*, int);
217 void            wselect(Window*);
218 void            wsendctlmesg(Window*, int, Rectangle, void*);
219 void            wsetcursor(Window*, int);
220 void            wsetname(Window*);
221 void            wsetorigin(Window*, uint, int);
222 void            wsetpid(Window*, int, int);
223 void            wsetselect(Window*, uint, uint);
224 void            wshow(Window*, uint);
225 void            wsnarf(Window*);
226 void            wscrsleep(Window*, uint);
227 void            wsetcols(Window*, int);
228
229 struct Dirtab
230 {
231         char            *name;
232         uchar   type;
233         uint            qid;
234         uint            perm;
235 };
236
237 struct Fid
238 {
239         int             fid;
240         int             busy;
241         int             open;
242         int             mode;
243         Qid             qid;
244         Window  *w;
245         Dirtab  *dir;
246         Fid             *next;
247         int             nrpart;
248         uchar   rpart[UTFmax];
249 };
250
251 struct Xfid
252 {
253                 Ref;
254                 Xfid            *next;
255                 Xfid            *free;
256                 Fcall;
257                 Channel *c;     /* chan(void(*)(Xfid*)) */
258                 Fid             *f;
259                 uchar   *buf;
260                 Filsys  *fs;
261                 QLock   active;
262                 int             flushing;       /* another Xfid is trying to flush us */
263                 int             flushtag;       /* our tag, so flush can find us */
264                 Channel *flushc;        /* channel(int) to notify us we're being flushed */
265 };
266
267 Channel*        xfidinit(void);
268 void            xfidctl(void*);
269 void            xfidflush(Xfid*);
270 void            xfidattach(Xfid*);
271 void            xfidopen(Xfid*);
272 void            xfidclose(Xfid*);
273 void            xfidread(Xfid*);
274 void            xfidwrite(Xfid*);
275
276 enum
277 {
278         Nhash   = 16,
279 };
280
281 struct Filsys
282 {
283                 int             cfd;
284                 int             sfd;
285                 int             pid;
286                 char            *user;
287                 Channel *cxfidalloc;    /* chan(Xfid*) */
288                 Channel *csyncflush;    /* chan(int) */
289                 Fid             *fids[Nhash];
290 };
291
292 Filsys* filsysinit(Channel*);
293 int             filsysmount(Filsys*, int);
294 Xfid*           filsysrespond(Filsys*, Xfid*, Fcall*, char*);
295 void            filsyscancel(Xfid*);
296
297 void            wctlproc(void*);
298 void            wctlthread(void*);
299
300 void            deletetimeoutproc(void*);
301
302 struct Timer
303 {
304         int             dt;
305         int             cancel;
306         Channel *c;     /* chan(int) */
307         Timer   *next;
308 };
309
310 Font            *font;
311 Mousectl        *mousectl;
312 Mouse   *mouse;
313 Display *display;
314 Image   *view;
315 Screen  *wscreen;
316 Cursor  boxcursor;
317 Cursor  crosscursor;
318 Cursor  sightcursor;
319 Cursor  whitearrow;
320 Cursor  query;
321 Cursor  *corners[9];
322
323 Image   *background;
324 Image   *cols[NCOL];
325 Image   *titlecol;
326 Image   *lighttitlecol;
327 Image   *dholdcol;
328 Image   *holdcol;
329 Image   *lightholdcol;
330 Image   *paleholdcol;
331 Image   *paletextcol;
332 Image   *sizecol;
333 int     reverse;        /* there are no pastel paints in the dungeons and dragons world -- rob pike */
334
335 Window  **window;
336 Window  *wkeyboard;     /* window of simulated keyboard */
337 int             nwindow;
338 int             snarffd;
339 int             gotscreen;
340 Window  *input;
341 QLock   all;                    /* BUG */
342 Filsys  *filsys;
343 Window  *hidden[100];
344 int             nhidden;
345 int             nsnarf;
346 Rune*   snarf;
347 int             scrolling;
348 int             maxtab;
349 Channel*        winclosechan;
350 Channel*        deletechan;
351 char            *startdir;
352 int             sweeping;
353 int             wctlfd;
354 char            srvpipe[];
355 char            srvwctl[];
356 int             errorshouldabort;
357 int             menuing;                /* menu action is pending; waiting for window to be indicated */
358 int             snarfversion;   /* updated each time it is written */
359 int             messagesize;            /* negotiated in 9P version setup */
360 int             shiftdown;
361 int             debug;