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