Blob


1 #ifndef _FRAME_H_
2 #define _FRAME_H_ 1
3 #if defined(__cplusplus)
4 extern "C" {
5 #endif
7 typedef struct Frbox Frbox;
8 typedef struct Frame Frame;
10 enum{
11 BACK,
12 HIGH,
13 BORD,
14 TEXT,
15 HTEXT,
16 NCOL
17 };
19 #define FRTICKW 3
21 struct Frbox
22 {
23 long wid; /* in pixels */
24 long nrune; /* <0 ==> negate and treat as break char */
25 uchar *ptr;
26 short bc; /* break char */
27 short minwid;
28 };
30 struct Frame
31 {
32 Font *font; /* of chars in the frame */
33 Display *display; /* on which frame appears */
34 Image *b; /* on which frame appears */
35 Image *cols[NCOL]; /* text and background colors */
36 Rectangle r; /* in which text appears */
37 Rectangle entire; /* of full frame */
38 void (*scroll)(Frame*, int); /* scroll function provided by application */
39 Frbox *box;
40 ulong p0, p1; /* selection */
41 ushort nbox, nalloc;
42 ushort maxtab; /* max size of tab, in pixels */
43 ushort nchars; /* # runes in frame */
44 ushort nlines; /* # lines with text */
45 ushort maxlines; /* total # lines in frame */
46 ushort lastlinefull; /* last line fills frame */
47 ushort modified; /* changed since frselect() */
48 Image *tick; /* typing tick */
49 Image *tickback; /* saved image under tick */
50 int ticked; /* flag: is tick onscreen? */
51 };
53 ulong frcharofpt(Frame*, Point);
54 Point frptofchar(Frame*, ulong);
55 int frdelete(Frame*, ulong, ulong);
56 void frinsert(Frame*, Rune*, Rune*, ulong);
57 void frselect(Frame*, Mousectl*);
58 void frselectpaint(Frame*, Point, Point, Image*);
59 void frdrawsel(Frame*, Point, ulong, ulong, int);
60 void frdrawsel0(Frame*, Point, ulong, ulong, Image*, Image*);
61 void frinit(Frame*, Rectangle, Font*, Image*, Image**);
62 void frsetrects(Frame*, Rectangle, Image*);
63 void frclear(Frame*, int);
65 uchar *_frallocstr(Frame*, unsigned);
66 void _frinsure(Frame*, int, unsigned);
67 Point _frdraw(Frame*, Point);
68 void _frgrowbox(Frame*, int);
69 void _frfreebox(Frame*, int, int);
70 void _frmergebox(Frame*, int);
71 void _frdelbox(Frame*, int, int);
72 void _frsplitbox(Frame*, int, int);
73 int _frfindbox(Frame*, int, ulong, ulong);
74 void _frclosebox(Frame*, int, int);
75 int _frcanfit(Frame*, Point, Frbox*);
76 void _frcklinewrap(Frame*, Point*, Frbox*);
77 void _frcklinewrap0(Frame*, Point*, Frbox*);
78 void _fradvance(Frame*, Point*, Frbox*);
79 int _frnewwid(Frame*, Point, Frbox*);
80 int _frnewwid0(Frame*, Point, Frbox*);
81 void _frclean(Frame*, Point, int, int);
82 void _frredraw(Frame*, Point);
83 void _fraddbox(Frame*, int, int);
84 Point _frptofcharptb(Frame*, ulong, Point, int);
85 Point _frptofcharnb(Frame*, ulong, int);
86 int _frstrlen(Frame*, int);
87 void frtick(Frame*, Point, int);
88 void frinittick(Frame*);
90 #define NRUNE(b) ((b)->nrune<0? 1 : (b)->nrune)
91 #define NBYTE(b) strlen((char*)(b)->ptr)
92 #if defined(__cplusplus)
93 }
94 #endif
95 #endif