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