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