]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/acme/dat.h
usb lib: add maxpkt and ntds to Altc struct
[plan9front.git] / sys / src / cmd / acme / dat.h
1 enum
2 {
3         Qdir,
4         Qacme,
5         Qcons,
6         Qconsctl,
7         Qdraw,
8         Qeditout,
9         Qindex,
10         Qlabel,
11         Qnew,
12
13         QWaddr,
14         QWbody,
15         QWctl,
16         QWdata,
17         QWeditout,
18         QWerrors,
19         QWevent,
20         QWrdsel,
21         QWwrsel,
22         QWtag,
23         QWxdata,
24         QMAX,
25 };
26
27 enum
28 {
29         Blockincr =     256,
30         Maxblock =      8*1024,
31         NRange =                10,
32         Infinity =              0x7FFFFFFF,     /* huge value for regexp address */
33 };
34
35 typedef struct  Block Block;
36 typedef struct  Buffer Buffer;
37 typedef struct  Command Command;
38 typedef struct  Column Column;
39 typedef struct  Dirlist Dirlist;
40 typedef struct  Dirtab Dirtab;
41 typedef struct  Disk Disk;
42 typedef struct  Expand Expand;
43 typedef struct  Fid Fid;
44 typedef struct  File File;
45 typedef struct  Elog Elog;
46 typedef struct  Mntdir Mntdir;
47 typedef struct  Range Range;
48 typedef struct  Rangeset Rangeset;
49 typedef struct  Reffont Reffont;
50 typedef struct  Row Row;
51 typedef struct  Runestr Runestr;
52 typedef struct  Text Text;
53 typedef struct  Timer Timer;
54 typedef struct  Window Window;
55 typedef struct  Xfid Xfid;
56
57 struct Runestr
58 {
59         Rune    *r;
60         int     nr;
61 };
62
63 struct Range
64 {
65         int     q0;
66         int     q1;
67 };
68
69 struct Block
70 {
71         uint            addr;   /* disk address in bytes */
72         union
73         {
74                 uint    n;              /* number of used runes in block */
75                 Block   *next;  /* pointer to next in free list */
76         };
77 };
78
79 struct Disk
80 {
81         int             fd;
82         uint            addr;   /* length of temp file */
83         Block   *free[Maxblock/Blockincr+1];
84 };
85
86 Disk*   diskinit(void);
87 Block*  disknewblock(Disk*, uint);
88 void            diskrelease(Disk*, Block*);
89 void            diskread(Disk*, Block*, Rune*, uint);
90 void            diskwrite(Disk*, Block**, Rune*, uint);
91
92 struct Buffer
93 {
94         uint    nc;
95         Rune    *c;                     /* cache */
96         uint    cnc;                    /* bytes in cache */
97         uint    cmax;           /* size of allocated cache */
98         uint    cq;                     /* position of cache */
99         int             cdirty; /* cache needs to be written */
100         uint    cbi;                    /* index of cache Block */
101         Block   **bl;           /* array of blocks */
102         uint    nbl;                    /* number of blocks */
103 };
104 void            bufinsert(Buffer*, uint, Rune*, uint);
105 void            bufdelete(Buffer*, uint, uint);
106 uint            bufload(Buffer*, uint, int, int*);
107 void            bufread(Buffer*, uint, Rune*, uint);
108 void            bufclose(Buffer*);
109 void            bufreset(Buffer*);
110
111 struct Elog
112 {
113         short   type;           /* Delete, Insert, Filename */
114         uint            q0;             /* location of change (unused in f) */
115         uint            nd;             /* number of deleted characters */
116         uint            nr;             /* # runes in string or file name */
117         Rune            *r;
118 };
119 void    elogterm(File*);
120 void    elogclose(File*);
121 void    eloginsert(File*, int, Rune*, int);
122 void    elogdelete(File*, int, int);
123 void    elogreplace(File*, int, int, Rune*, int);
124 void    elogapply(File*);
125
126 struct File
127 {
128         Buffer;                 /* the data */
129         Buffer  delta;  /* transcript of changes */
130         Buffer  epsilon;        /* inversion of delta for redo */
131         Buffer  *elogbuf;       /* log of pending editor changes */
132         Elog            elog;           /* current pending change */
133         Rune            *name;  /* name of associated file */
134         int             nname;  /* size of name */
135         uvlong  qidpath;        /* of file when read */
136         uint            mtime;  /* of file when read */
137         int             dev;            /* of file when read */
138         int             unread; /* file has not been read from disk */
139         int             editclean;      /* mark clean after edit command */
140
141         int             seq;            /* if seq==0, File acts like Buffer */
142         int             mod;
143         Text            *curtext;       /* most recently used associated text */
144         Text            **text; /* list of associated texts */
145         int             ntext;
146         int             dumpid; /* used in dumping zeroxed windows */
147 };
148 File*           fileaddtext(File*, Text*);
149 void            fileclose(File*);
150 void            filedelete(File*, uint, uint);
151 void            filedeltext(File*, Text*);
152 void            fileinsert(File*, uint, Rune*, uint);
153 uint            fileload(File*, uint, int, int*);
154 void            filemark(File*);
155 void            filereset(File*);
156 void            filesetname(File*, Rune*, int);
157 void            fileundelete(File*, Buffer*, uint, uint);
158 void            fileuninsert(File*, Buffer*, uint, uint);
159 void            fileunsetname(File*, Buffer*);
160 void            fileundo(File*, int, uint*, uint*);
161 uint            fileredoseq(File*);
162
163 enum    /* Text.what */
164 {
165         Columntag,
166         Rowtag,
167         Tag,
168         Body,
169 };
170
171 struct Text
172 {
173         File            *file;
174         Frame;
175         Reffont *reffont;
176         uint    org;
177         uint    q0;
178         uint    q1;
179         int     what;
180         int     tabstop;
181         Window  *w;
182         Rectangle scrollr;
183         Rectangle lastsr;
184         Rectangle all;
185         Row             *row;
186         Column  *col;
187
188         uint    eq0;    /* start of typing for ESC */
189         uint    cq0;    /* cache position */
190         int             ncache; /* storage for insert */
191         int             ncachealloc;
192         Rune    *cache;
193         int     nofill;
194         int     needundo;
195 };
196
197 uint            textbacknl(Text*, uint, uint);
198 uint            textbsinsert(Text*, uint, Rune*, uint, int, int*);
199 int             textbswidth(Text*, Rune);
200 int             textclickmatch(Text*, int, int, int, uint*);
201 void            textclose(Text*);
202 void            textcolumnate(Text*, Dirlist**, int);
203 void            textcommit(Text*, int);
204 void            textconstrain(Text*, uint, uint, uint*, uint*);
205 void            textdelete(Text*, uint, uint, int);
206 void            textdoubleclick(Text*, uint*, uint*);
207 void            textfill(Text*);
208 void            textframescroll(Text*, int);
209 void            textinit(Text*, File*, Rectangle, Reffont*, Image**);
210 void            textinsert(Text*, uint, Rune*, uint, int);
211 uint            textload(Text*, uint, char*, int);
212 Rune            textreadc(Text*, uint);
213 void            textredraw(Text*, Rectangle, Font*, Image*, int);
214 void            textreset(Text*);
215 int             textresize(Text*, Rectangle);
216 void            textscrdraw(Text*);
217 void            textscroll(Text*, int);
218 void            textselect(Text*);
219 int             textselect2(Text*, uint*, uint*, Text**);
220 int             textselect23(Text*, uint*, uint*, Image*, int);
221 int             textselect3(Text*, uint*, uint*);
222 void            textsetorigin(Text*, uint, int);
223 void            textsetselect(Text*, uint, uint);
224 void            textshow(Text*, uint, uint, int);
225 void            texttype(Text*, Rune);
226
227 struct Window
228 {
229                 QLock;
230                 Ref;
231         Text            tag;
232         Text            body;
233         Rectangle       r;
234         uchar   isdir;
235         uchar   isscratch;
236         uchar   filemenu;
237         uchar   dirty;
238         uchar   autoindent;
239         uchar   showdel;
240         uint            noredraw;
241         int             id;
242         Range   addr;
243         Range   limit;
244         uchar   nopen[QMAX];
245         uchar   nomark;
246         uchar   noscroll;
247         Range   wrselrange;
248         int             rdselfd;
249         Column  *col;
250         Xfid            *eventx;
251         char            *events;
252         int             nevents;
253         int             owner;
254         int             maxlines;
255         Dirlist **dlp;
256         int             ndl;
257         int             putseq;
258         int             nincl;
259         Rune            **incl;
260         Reffont *reffont;
261         QLock   ctllock;
262         uint            ctlfid;
263         char            *dumpstr;
264         char            *dumpdir;
265         int             dumpid;
266         int             utflastqid;
267         int             utflastboff;
268         int             utflastq;
269         int             tagsafe;                /* taglines is correct */
270         int             tagexpand;
271         int             taglines;
272         Rectangle       tagtop;
273 };
274
275 void    wininit(Window*, Window*, Rectangle);
276 void    winlock(Window*, int);
277 void    winlock1(Window*, int);
278 void    winunlock(Window*);
279 void    wintype(Window*, Text*, Rune);
280 void    winundo(Window*, int);
281 void    winsetname(Window*, Rune*, int);
282 void    winsettag(Window*);
283 void    winsettag1(Window*);
284 void    wincommit(Window*, Text*);
285 int     winresize(Window*, Rectangle, int);
286 void    winclose(Window*);
287 void    windelete(Window*);
288 int     winclean(Window*, int);
289 void    windirfree(Window*);
290 void    winevent(Window*, char*, ...);
291 void    winmousebut(Window*);
292 void    winaddincl(Window*, Rune*, int);
293 void    wincleartag(Window*);
294 char    *winctlprint(Window*, char*, int);
295
296 struct Column
297 {
298         Rectangle r;
299         Text    tag;
300         Row             *row;
301         Window  **w;
302         int             nw;
303         int             safe;
304 };
305
306 void            colinit(Column*, Rectangle);
307 Window* coladd(Column*, Window*, Window*, int);
308 void            colclose(Column*, Window*, int);
309 void            colcloseall(Column*);
310 void            colresize(Column*, Rectangle);
311 Text*   colwhich(Column*, Point);
312 void            coldragwin(Column*, Window*, int);
313 void            colgrow(Column*, Window*, int);
314 int             colclean(Column*);
315 void            colsort(Column*);
316 void            colmousebut(Column*);
317
318 struct Row
319 {
320         QLock;
321         Rectangle r;
322         Text    tag;
323         Column  **col;
324         int             ncol;
325
326 };
327
328 void            rowinit(Row*, Rectangle);
329 Column* rowadd(Row*, Column *c, int);
330 void            rowclose(Row*, Column*, int);
331 Text*   rowwhich(Row*, Point);
332 Column* rowwhichcol(Row*, Point);
333 void            rowresize(Row*, Rectangle);
334 Text*   rowtype(Row*, Rune, Point);
335 void            rowdragcol(Row*, Column*, int but);
336 int             rowclean(Row*);
337 void            rowdump(Row*, char*);
338 int             rowload(Row*, char*, int);
339 void            rowloadfonts(char*);
340
341 struct Timer
342 {
343         int             dt;
344         int             cancel;
345         Channel *c;     /* chan(int) */
346         Timer   *next;
347 };
348
349 struct Command
350 {
351         int             pid;
352         Rune            *name;
353         int             nname;
354         char            *text;
355         char            **av;
356         int             iseditcmd;
357         Mntdir  *md;
358         Command *next;
359 };
360
361 struct Dirtab
362 {
363         char    *name;
364         uchar   type;
365         uint    qid;
366         uint    perm;
367 };
368
369 struct Mntdir
370 {
371         int             id;
372         int             ref;
373         Rune            *dir;
374         int             ndir;
375         Mntdir  *next;
376         int             nincl;
377         Rune            **incl;
378 };
379
380 struct Fid
381 {
382         int             fid;
383         int             busy;
384         int             open;
385         Qid             qid;
386         Window  *w;
387         Dirtab  *dir;
388         Fid             *next;
389         Mntdir  *mntdir;
390         int             nrpart;
391         uchar   rpart[UTFmax];
392 };
393
394
395 struct Xfid
396 {
397         void            *arg;   /* args to xfidinit */
398         Fcall;
399         Xfid    *next;
400         Channel *c;             /* chan(void(*)(Xfid*)) */
401         Fid     *f;
402         uchar   *buf;
403         int     flushed;
404
405 };
406
407 void            xfidctl(void *);
408 void            xfidflush(Xfid*);
409 void            xfidopen(Xfid*);
410 void            xfidclose(Xfid*);
411 void            xfidread(Xfid*);
412 void            xfidwrite(Xfid*);
413 void            xfidctlwrite(Xfid*, Window*);
414 void            xfideventread(Xfid*, Window*);
415 void            xfideventwrite(Xfid*, Window*);
416 void            xfidindexread(Xfid*);
417 void            xfidutfread(Xfid*, Text*, uint, int);
418 int             xfidruneread(Xfid*, Text*, uint, uint);
419
420 struct Reffont
421 {
422         Ref;
423         Font            *f;
424
425 };
426 Reffont *rfget(int, int, int, char*);
427 void            rfclose(Reffont*);
428
429 struct Rangeset
430 {
431         Range   r[NRange];
432 };
433
434 struct Dirlist
435 {
436         Rune    *r;
437         int             nr;
438         int             wid;
439 };
440
441 struct Expand
442 {
443         uint    q0;
444         uint    q1;
445         Rune    *name;
446         int     nname;
447         char    *bname;
448         int     jump;
449         union{
450                 Text    *at;
451                 Rune    *ar;
452         };
453         int     (*agetc)(void*, uint);
454         int     a0;
455         int     a1;
456 };
457
458 enum
459 {
460         /* fbufalloc() guarantees room off end of BUFSIZE */
461         BUFSIZE = Maxblock+IOHDRSZ,     /* size from fbufalloc() */
462         RBUFSIZE = BUFSIZE/sizeof(Rune),
463         EVENTSIZE = 256,
464         Scrollwid = 12, /* width of scroll bar */
465         Scrollgap = 4,  /* gap right of scroll bar */
466         Margin = 4,     /* margin around text */
467         Border = 2,     /* line between rows, cols, windows */
468 };
469
470 #define QID(w,q)        ((w<<8)|(q))
471 #define WIN(q)  ((((ulong)(q).path)>>8) & 0xFFFFFF)
472 #define FILE(q) ((q).path & 0xFF)
473
474 enum
475 {
476         FALSE,
477         TRUE,
478         XXX,
479 };
480
481 enum
482 {
483         Empty   = 0,
484         Null            = '-',
485         Delete  = 'd',
486         Insert  = 'i',
487         Replace = 'r',
488         Filename        = 'f',
489 };
490
491 enum    /* editing */
492 {
493         Inactive        = 0,
494         Inserting,
495         Collecting,
496 };
497
498 uint            globalincref;
499 uint            seq;
500 uint            maxtab; /* size of a tab, in units of the '0' character */
501
502 Display         *display;
503 Image           *screen;
504 Font                    *font;
505 Mouse           *mouse;
506 Mousectl                *mousectl;
507 Keyboardctl     *keyboardctl;
508 Reffont         reffont;
509 Image           *modbutton;
510 Image           *colbutton;
511 Image           *button;
512 Image           *but2col;
513 Image           *but3col;
514 Cursor          boxcursor;
515 Row                     row;
516 int                     timerpid;
517 Disk                    *disk;
518 Text                    *seltext;
519 Text                    *argtext;
520 Text                    *mousetext;     /* global because Text.close needs to clear it */
521 Text                    *typetext;              /* global because Text.close needs to clear it */
522 Text                    *barttext;              /* shared between mousetask and keyboardthread */
523 int                     bartflag;
524 Window          *activewin;
525 Column          *activecol;
526 Buffer          snarfbuf;
527 Rectangle               nullrect;
528 int                     fsyspid;
529 char                    *cputype;
530 char                    *objtype;
531 char                    *home;
532 char                    *fontnames[2];
533 char                    acmeerrorfile[128];
534 Image           *tagcols[NCOL];
535 Image           *textcols[NCOL];
536 int                     plumbsendfd;
537 int                     plumbeditfd;
538 char                    wdir[];
539 int                     editing;
540 int                     messagesize;            /* negotiated in 9P version setup */
541 int                     globalautoindent;
542
543 Channel *cplumb;                /* chan(Plumbmsg*) */
544 Channel *cwait;         /* chan(Waitmsg) */
545 Channel *ccommand;      /* chan(Command*) */
546 Channel *ckill;         /* chan(Rune*) */
547 Channel *cxfidalloc;    /* chan(Xfid*) */
548 Channel *cxfidfree;     /* chan(Xfid*) */
549 Channel *cnewwindow;    /* chan(Channel*) */
550 Channel *mouseexit0;    /* chan(int) */
551 Channel *mouseexit1;    /* chan(int) */
552 Channel *cexit;         /* chan(int) */
553 Channel *cerr;          /* chan(char*) */
554 Channel *cedit;         /* chan(int) */
555 Channel *cwarn;         /* chan(void*)[1] (really chan(unit)[1]) */
556
557 #define STACK   8192