frame.h - sam - An updated version of the sam text editor. | |
git clone git://vernunftzentrum.de/sam.git | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
frame.h (2791B) | |
--- | |
1 /* Copyright (c) 1998 Lucent Technologies - All rights reserved. */ | |
2 | |
3 typedef struct Frbox Frbox; | |
4 typedef struct Frame Frame; | |
5 | |
6 struct Frbox | |
7 { | |
8 int64_t wid; /* in pixels */ | |
9 int64_t nrune; /* <0 ==> negate and treat as break char … | |
10 union{ | |
11 uint8_t *ptr; | |
12 struct{ | |
13 int16_t bc; /* break char */ | |
14 int16_t minwid; | |
15 } b; | |
16 } a; | |
17 }; | |
18 | |
19 /* note that we track background color, but not foreground | |
20 * this is because the foreground color is the same for all frames | |
21 */ | |
22 struct Frame | |
23 { | |
24 uint64_t bg; /* background color */ | |
25 XftFont *font; /* of chars in the frame */ | |
26 Bitmap *b; /* on which frame appears */ | |
27 Rectangle r; /* in which text appears */ | |
28 Rectangle entire; /* of full frame */ | |
29 Frbox *box; | |
30 uint64_t p0, p1; /* selection */ | |
31 int16_t left; /* left edge of text */ | |
32 uint16_t nbox, nalloc; | |
33 uint16_t maxtab; /* max size of tab, in pixels */ | |
34 uint16_t fheight; /* font height, in pixels */ | |
35 uint16_t nchars; /* # runes in frame */ | |
36 uint16_t nlines; /* # lines with text */ | |
37 uint16_t maxlines; /* total # lines in frame */ | |
38 bool lastlinefull; /* last line fills frame */ | |
39 bool modified; /* changed since frselect() */ | |
40 }; | |
41 | |
42 uint64_t frcharofpt(Frame*, Point); | |
43 Point frptofchar(Frame*, uint64_t); | |
44 int frdelete(Frame*, uint64_t, uint64_t); | |
45 void frinsert(Frame*, wchar_t*, wchar_t*, uint64_t); | |
46 void frselect(Frame*, Mouse*); | |
47 void frselectp(Frame*, Fcode); | |
48 void frselectf(Frame*, Point, Point, Fcode); | |
49 void frinit(Frame*, Rectangle, XftFont*, Bitmap*, uint64_t); | |
50 void frsetrects(Frame*, Rectangle, Bitmap*); | |
51 void frclear(Frame*); | |
52 void frgetmouse(void); | |
53 | |
54 uint8_t *_frallocstr(unsigned); | |
55 void _frinsure(Frame*, int, unsigned); | |
56 Point _frdraw(Frame*, Point); | |
57 void _frgrowbox(Frame*, int); | |
58 void _frfreebox(Frame*, int, int); | |
59 void _frmergebox(Frame*, int); | |
60 void _frdelbox(Frame*, int, int); | |
61 void _frsplitbox(Frame*, int, int); | |
62 int _frfindbox(Frame*, int, uint64_t, uint64_t); | |
63 void _frclosebox(Frame*, int, int); | |
64 int _frcanfit(Frame*, Point, Frbox*); | |
65 void _frcklinewrap(Frame*, Point*, Frbox*); | |
66 void _frcklinewrap0(Frame*, Point*, Frbox*); | |
67 void _fradvance(Frame*, Point*, Frbox*); | |
68 int _frnewwid(Frame*, Point, Frbox*); | |
69 void _frclean(Frame*, Point, int, int); | |
70 void _frredraw(Frame*, Point); | |
71 void _fraddbox(Frame*, int, int); | |
72 Point _frptofcharptb(Frame*, uint64_t, Point, int); | |
73 Point _frptofcharnb(Frame*, uint64_t, int); | |
74 int _frstrlen(Frame*, int); | |
75 | |
76 extern int tabwidth; | |
77 | |
78 #define NRUNE(b) ((b)->nrune<0? 1 : (b)->nrune) | |
79 #define NBYTE(b) strlen((char*)(b)->a.ptr) |