frame.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. };
  48. ulong frcharofpt(Frame*, Point);
  49. Point frptofchar(Frame*, ulong);
  50. int frdelete(Frame*, ulong, ulong);
  51. void frinsert(Frame*, Rune*, Rune*, ulong);
  52. void frselect(Frame*, Mousectl*);
  53. void frselectpaint(Frame*, Point, Point, Image*);
  54. void frdrawsel(Frame*, Point, ulong, ulong, int);
  55. Point frdrawsel0(Frame*, Point, ulong, ulong, Image*, Image*);
  56. void frinit(Frame*, Rectangle, Font*, Image*, Image**);
  57. void frsetrects(Frame*, Rectangle, Image*);
  58. void frclear(Frame*, int);
  59. uchar *_frallocstr(Frame*, unsigned);
  60. void _frinsure(Frame*, int, unsigned);
  61. Point _frdraw(Frame*, Point);
  62. void _frgrowbox(Frame*, int);
  63. void _frfreebox(Frame*, int, int);
  64. void _frmergebox(Frame*, int);
  65. void _frdelbox(Frame*, int, int);
  66. void _frsplitbox(Frame*, int, int);
  67. int _frfindbox(Frame*, int, ulong, ulong);
  68. void _frclosebox(Frame*, int, int);
  69. int _frcanfit(Frame*, Point, Frbox*);
  70. void _frcklinewrap(Frame*, Point*, Frbox*);
  71. void _frcklinewrap0(Frame*, Point*, Frbox*);
  72. void _fradvance(Frame*, Point*, Frbox*);
  73. int _frnewwid(Frame*, Point, Frbox*);
  74. int _frnewwid0(Frame*, Point, Frbox*);
  75. void _frclean(Frame*, Point, int, int);
  76. void _frdrawtext(Frame*, Point, Image*, Image*);
  77. void _fraddbox(Frame*, int, int);
  78. Point _frptofcharptb(Frame*, ulong, Point, int);
  79. Point _frptofcharnb(Frame*, ulong, int);
  80. int _frstrlen(Frame*, int);
  81. void frtick(Frame*, Point, int);
  82. void frinittick(Frame*);
  83. void frredraw(Frame*);
  84. #define NRUNE(b) ((b)->nrune<0? 1 : (b)->nrune)
  85. #define NBYTE(b) strlen((char*)(b)->ptr)