1 #pragma src "/sys/src/libframe" 2 #pragma lib "libframe.a" 3 4 typedef struct Frbox Frbox; 5 typedef struct Frame Frame; 6 7 struct Frbox 8 { 9 long wid; /* in pixels */ 10 long nrune; /* <0 ==> negate and treat as break char */ 11 union{ 12 uchar *ptr; 13 struct{ 14 short bc; /* break char */ 15 short minwid; 16 }; 17 }; 18 }; 19 20 struct Frame 21 { 22 Font *font; /* of chars in the frame */ 23 Bitmap *b; /* on which frame appears */ 24 Rectangle r; /* in which text appears */ 25 Rectangle entire; /* of full frame */ 26 Frbox *box; 27 ulong p0, p1; /* selection */ 28 short left; /* left edge of text */ 29 ushort nbox, nalloc; 30 ushort maxtab; /* max size of tab, in pixels */ 31 ushort nchars; /* # runes in frame */ 32 ushort nlines; /* # lines with text */ 33 ushort maxlines; /* total # lines in frame */ 34 ushort lastlinefull; /* last line fills frame */ 35 ushort modified; /* changed since frselect() */ 36 }; 37 38 ulong frcharofpt(Frame*, Point); 39 Point frptofchar(Frame*, ulong); 40 int frdelete(Frame*, ulong, ulong); 41 void frinsert(Frame*, Rune*, Rune*, ulong); 42 void frselect(Frame*, Mouse*); 43 void frselectp(Frame*, Fcode); 44 void frselectf(Frame*, Point, Point, Fcode); 45 void frinit(Frame*, Rectangle, Font*, Bitmap*); 46 void frsetrects(Frame*, Rectangle, Bitmap*); 47 void frclear(Frame*); 48 void frgetmouse(void); 49 50 uchar *_frallocstr(unsigned); 51 void _frinsure(Frame*, int, unsigned); 52 Point _frdraw(Frame*, Point); 53 void _frgrowbox(Frame*, int); 54 void _frfreebox(Frame*, int, int); 55 void _frmergebox(Frame*, int); 56 void _frdelbox(Frame*, int, int); 57 void _frsplitbox(Frame*, int, int); 58 int _frfindbox(Frame*, int, ulong, ulong); 59 void _frclosebox(Frame*, int, int); 60 int _frcanfit(Frame*, Point, Frbox*); 61 void _frcklinewrap(Frame*, Point*, Frbox*); 62 void _frcklinewrap0(Frame*, Point*, Frbox*); 63 void _fradvance(Frame*, Point*, Frbox*); 64 int _frnewwid(Frame*, Point, Frbox*); 65 void _frclean(Frame*, Point, int, int); 66 void _frredraw(Frame*, Point); 67 void _fraddbox(Frame*, int, int); 68 Point _frptofcharptb(Frame*, ulong, Point, int); 69 Point _frptofcharnb(Frame*, ulong, int); 70 int _frstrlen(Frame*, int); 71 72 #define NRUNE(b) ((b)->nrune<0? 1 : (b)->nrune) 73 #define NBYTE(b) strlen((char*)(b)->ptr) 74