1
0

frame.h 2.7 KB

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