]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/acme/dat.h
Libflac: Tell it that we have stdint.h so it finds SIZE_MAX
[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 enum
228 {
229         SPACESINDENT    = 0,
230         AUTOINDENT,
231         NINDENT,
232 };
233
234 struct Window
235 {
236                 QLock;
237                 Ref;
238         Text            tag;
239         Text            body;
240         Rectangle       r;
241         uchar   isdir;
242         uchar   isscratch;
243         uchar   filemenu;
244         uchar   dirty;
245         uchar   indent[NINDENT];
246         uchar   showdel;
247         uint            noredraw;
248         int             id;
249         Range   addr;
250         Range   limit;
251         uchar   nopen[QMAX];
252         uchar   nomark;
253         uchar   noscroll;
254         Range   wrselrange;
255         int             rdselfd;
256         Column  *col;
257         Xfid            *eventx;
258         char            *events;
259         int             nevents;
260         int             owner;
261         int             maxlines;
262         Dirlist **dlp;
263         int             ndl;
264         int             putseq;
265         int             nincl;
266         Rune            **incl;
267         Reffont *reffont;
268         QLock   ctllock;
269         uint            ctlfid;
270         char            *dumpstr;
271         char            *dumpdir;
272         int             dumpid;
273         int             utflastqid;
274         int             utflastboff;
275         int             utflastq;
276         int             tagsafe;                /* taglines is correct */
277         int             tagexpand;
278         int             taglines;
279         Rectangle       tagtop;
280 };
281
282 void    wininit(Window*, Window*, Rectangle);
283 void    winlock(Window*, int);
284 void    winlock1(Window*, int);
285 void    winunlock(Window*);
286 void    wintype(Window*, Text*, Rune);
287 void    winundo(Window*, int);
288 void    winsetname(Window*, Rune*, int);
289 void    winsettag(Window*);
290 void    winsettag1(Window*);
291 void    wincommit(Window*, Text*);
292 int     winresize(Window*, Rectangle, int);
293 void    winclose(Window*);
294 void    windelete(Window*);
295 int     winclean(Window*, int);
296 void    windirfree(Window*);
297 void    winevent(Window*, char*, ...);
298 void    winmousebut(Window*);
299 void    winaddincl(Window*, Rune*, int);
300 void    wincleartag(Window*);
301 char    *winctlprint(Window*, char*, int);
302
303 struct Column
304 {
305         Rectangle r;
306         Text    tag;
307         Row             *row;
308         Window  **w;
309         int             nw;
310         int             safe;
311 };
312
313 void            colinit(Column*, Rectangle);
314 Window* coladd(Column*, Window*, Window*, int);
315 void            colclose(Column*, Window*, int);
316 void            colcloseall(Column*);
317 void            colresize(Column*, Rectangle);
318 Text*   colwhich(Column*, Point);
319 void            coldragwin(Column*, Window*, int);
320 void            colgrow(Column*, Window*, int);
321 int             colclean(Column*);
322 void            colsort(Column*);
323 void            colmousebut(Column*);
324
325 struct Row
326 {
327         QLock;
328         Rectangle r;
329         Text    tag;
330         Column  **col;
331         int             ncol;
332
333 };
334
335 void            rowinit(Row*, Rectangle);
336 Column* rowadd(Row*, Column *c, int);
337 void            rowclose(Row*, Column*, int);
338 Text*   rowwhich(Row*, Point);
339 Column* rowwhichcol(Row*, Point);
340 void            rowresize(Row*, Rectangle);
341 Text*   rowtype(Row*, Rune, Point);
342 void            rowdragcol(Row*, Column*, int but);
343 int             rowclean(Row*);
344 void            rowdump(Row*, char*);
345 int             rowload(Row*, char*, int);
346 void            rowloadfonts(char*);
347
348 struct Timer
349 {
350         int             dt;
351         int             cancel;
352         Channel *c;     /* chan(int) */
353         Timer   *next;
354 };
355
356 struct Command
357 {
358         int             pid;
359         Rune            *name;
360         int             nname;
361         char            *text;
362         char            **av;
363         int             iseditcmd;
364         Mntdir  *md;
365         Command *next;
366 };
367
368 struct Dirtab
369 {
370         char    *name;
371         uchar   type;
372         uint    qid;
373         uint    perm;
374 };
375
376 struct Mntdir
377 {
378         int             id;
379         int             ref;
380         Rune            *dir;
381         int             ndir;
382         Mntdir  *next;
383         int             nincl;
384         Rune            **incl;
385 };
386
387 struct Fid
388 {
389         int             fid;
390         int             busy;
391         int             open;
392         Qid             qid;
393         Window  *w;
394         Dirtab  *dir;
395         Fid             *next;
396         Mntdir  *mntdir;
397         int             nrpart;
398         uchar   rpart[UTFmax];
399 };
400
401
402 struct Xfid
403 {
404         void            *arg;   /* args to xfidinit */
405         Fcall;
406         Xfid    *next;
407         Channel *c;             /* chan(void(*)(Xfid*)) */
408         Fid     *f;
409         uchar   *buf;
410         int     flushed;
411
412 };
413
414 void            xfidctl(void *);
415 void            xfidflush(Xfid*);
416 void            xfidopen(Xfid*);
417 void            xfidclose(Xfid*);
418 void            xfidread(Xfid*);
419 void            xfidwrite(Xfid*);
420 void            xfidctlwrite(Xfid*, Window*);
421 void            xfideventread(Xfid*, Window*);
422 void            xfideventwrite(Xfid*, Window*);
423 void            xfidindexread(Xfid*);
424 void            xfidutfread(Xfid*, Text*, uint, int);
425 int             xfidruneread(Xfid*, Text*, uint, uint);
426
427 struct Reffont
428 {
429         Ref;
430         Font            *f;
431
432 };
433 Reffont *rfget(int, int, int, char*);
434 void            rfclose(Reffont*);
435
436 struct Rangeset
437 {
438         Range   r[NRange];
439 };
440
441 struct Dirlist
442 {
443         Rune    *r;
444         int             nr;
445         int             wid;
446 };
447
448 struct Expand
449 {
450         uint    q0;
451         uint    q1;
452         Rune    *name;
453         int     nname;
454         char    *bname;
455         int     jump;
456         union{
457                 Text    *at;
458                 Rune    *ar;
459         };
460         int     (*agetc)(void*, uint);
461         int     a0;
462         int     a1;
463 };
464
465 enum
466 {
467         /* fbufalloc() guarantees room off end of BUFSIZE */
468         BUFSIZE = Maxblock+IOHDRSZ,     /* size from fbufalloc() */
469         RBUFSIZE = BUFSIZE/sizeof(Rune),
470         EVENTSIZE = 256,
471         Scrollwid = 12, /* width of scroll bar */
472         Scrollgap = 4,  /* gap right of scroll bar */
473         Margin = 4,     /* margin around text */
474         Border = 2,     /* line between rows, cols, windows */
475 };
476
477 #define QID(w,q)        ((w<<8)|(q))
478 #define WIN(q)  ((((ulong)(q).path)>>8) & 0xFFFFFF)
479 #define FILE(q) ((q).path & 0xFF)
480
481 enum
482 {
483         FALSE,
484         TRUE,
485         XXX,
486 };
487
488 enum
489 {
490         Empty   = 0,
491         Null            = '-',
492         Delete  = 'd',
493         Insert  = 'i',
494         Replace = 'r',
495         Filename        = 'f',
496 };
497
498 enum    /* editing */
499 {
500         Inactive        = 0,
501         Inserting,
502         Collecting,
503 };
504
505 uint            globalincref;
506 uint            seq;
507 uint            maxtab; /* size of a tab, in units of the '0' character */
508
509 Display         *display;
510 Image           *screen;
511 Font                    *font;
512 Mouse           *mouse;
513 Mousectl                *mousectl;
514 Keyboardctl     *keyboardctl;
515 Reffont         reffont;
516 Image           *modbutton;
517 Image           *colbutton;
518 Image           *button;
519 Image           *but2col;
520 Image           *but3col;
521 Cursor          boxcursor;
522 Row                     row;
523 int                     timerpid;
524 Disk                    *disk;
525 Text                    *seltext;
526 Text                    *argtext;
527 Text                    *mousetext;     /* global because Text.close needs to clear it */
528 Text                    *typetext;              /* global because Text.close needs to clear it */
529 Text                    *barttext;              /* shared between mousetask and keyboardthread */
530 int                     bartflag;
531 Window          *activewin;
532 Column          *activecol;
533 Buffer          snarfbuf;
534 Rectangle               nullrect;
535 int                     fsyspid;
536 char                    *cputype;
537 char                    *objtype;
538 char                    *home;
539 char                    *fontnames[2];
540 char                    acmeerrorfile[128];
541 Image           *tagcols[NCOL];
542 Image           *textcols[NCOL];
543 int                     plumbsendfd;
544 int                     plumbeditfd;
545 char                    wdir[];
546 int                     editing;
547 int                     messagesize;            /* negotiated in 9P version setup */
548 int                     globalindent[NINDENT];
549
550 Channel *cplumb;                /* chan(Plumbmsg*) */
551 Channel *cwait;         /* chan(Waitmsg) */
552 Channel *ccommand;      /* chan(Command*) */
553 Channel *ckill;         /* chan(Rune*) */
554 Channel *cxfidalloc;    /* chan(Xfid*) */
555 Channel *cxfidfree;     /* chan(Xfid*) */
556 Channel *cnewwindow;    /* chan(Channel*) */
557 Channel *mouseexit0;    /* chan(int) */
558 Channel *mouseexit1;    /* chan(int) */
559 Channel *cexit;         /* chan(int) */
560 Channel *cerr;          /* chan(char*) */
561 Channel *cedit;         /* chan(int) */
562 Channel *cwarn;         /* chan(void*)[1] (really chan(unit)[1]) */
563
564 #define STACK   8192