frame.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. typedef struct Frbox Frbox;
  10. typedef struct Frame Frame;
  11. enum{
  12. BACK,
  13. HIGH,
  14. BORD,
  15. TEXT,
  16. HTEXT,
  17. NCOL
  18. };
  19. #define FRTICKW 3
  20. struct Frbox
  21. {
  22. int32_t wid; /* in pixels */
  23. int32_t nrune; /* <0 ==> negate and treat as break char */
  24. union{
  25. uint8_t *ptr;
  26. struct{
  27. int16_t bc; /* break char */
  28. int16_t minwid;
  29. };
  30. };
  31. };
  32. struct Frame
  33. {
  34. Font *font; /* of chars in the frame */
  35. Display *display; /* on which frame appears */
  36. Image *b; /* on which frame appears */
  37. Image *cols[NCOL]; /* text and background colors */
  38. Rectangle r; /* in which text appears */
  39. Rectangle entire; /* of full frame */
  40. void (*scroll)(Frame*, int); /* scroll function provided by application */
  41. Frbox *box;
  42. uint32_t p0, p1; /* selection */
  43. uint16_t nbox, nalloc;
  44. uint16_t maxtab; /* max size of tab, in pixels */
  45. uint16_t nchars; /* # runes in frame */
  46. uint16_t nlines; /* # lines with text */
  47. uint16_t maxlines; /* total # lines in frame */
  48. uint16_t lastlinefull; /* last line fills frame */
  49. uint16_t modified; /* changed since frselect() */
  50. Image *tick; /* typing tick */
  51. Image *tickback; /* saved image under tick */
  52. int ticked; /* flag: is tick onscreen? */
  53. };
  54. uint32_t frcharofpt(Frame*, Point);
  55. Point frptofchar(Frame*, uint32_t);
  56. int frdelete(Frame*, uint32_t, uint32_t);
  57. void frinsert(Frame*, Rune*, Rune*, uint32_t);
  58. void frselect(Frame*, Mousectl*);
  59. void frselectpaint(Frame*, Point, Point, Image*);
  60. void frdrawsel(Frame*, Point, uint32_t, uint32_t, int);
  61. Point frdrawsel0(Frame*, Point, uint32_t, uint32_t, Image*, Image*);
  62. void frinit(Frame*, Rectangle, Font*, Image*, Image**);
  63. void frsetrects(Frame*, Rectangle, Image*);
  64. void frclear(Frame*, int);
  65. uint8_t *_frallocstr(Frame*, unsigned);
  66. void _frinsure(Frame*, int, unsigned);
  67. Point _frdraw(Frame*, Point);
  68. void _frgrowbox(Frame*, int);
  69. void _frfreebox(Frame*, int, int);
  70. void _frmergebox(Frame*, int);
  71. void _frdelbox(Frame*, int, int);
  72. void _frsplitbox(Frame*, int, int);
  73. int _frfindbox(Frame*, int, uint32_t, uint32_t);
  74. void _frclosebox(Frame*, int, int);
  75. int _frcanfit(Frame*, Point, Frbox*);
  76. void _frcklinewrap(Frame*, Point*, Frbox*);
  77. void _frcklinewrap0(Frame*, Point*, Frbox*);
  78. void _fradvance(Frame*, Point*, Frbox*);
  79. int _frnewwid(Frame*, Point, Frbox*);
  80. int _frnewwid0(Frame*, Point, Frbox*);
  81. void _frclean(Frame*, Point, int, int);
  82. void _frdrawtext(Frame*, Point, Image*, Image*);
  83. void _fraddbox(Frame*, int, int);
  84. Point _frptofcharptb(Frame*, uint32_t, Point, int);
  85. Point _frptofcharnb(Frame*, uint32_t, int);
  86. int _frstrlen(Frame*, int);
  87. void frtick(Frame*, Point, int);
  88. void frinittick(Frame*);
  89. void frredraw(Frame*);
  90. #define NRUNE(b) ((b)->nrune<0? 1 : (b)->nrune)
  91. #define NBYTE(b) strlen((char*)(b)->ptr)