frame.h 2.9 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. i32 wid; /* in pixels */
  23. i32 nrune; /* <0 ==> negate and treat as break char */
  24. union{
  25. u8 *ptr;
  26. struct{
  27. i16 bc; /* break char */
  28. i16 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. u32 p0, p1; /* selection */
  43. u16 nbox, nalloc;
  44. u16 maxtab; /* max size of tab, in pixels */
  45. u16 nchars; /* # runes in frame */
  46. u16 nlines; /* # lines with text */
  47. u16 maxlines; /* total # lines in frame */
  48. u16 lastlinefull; /* last line fills frame */
  49. u16 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. u32 frcharofpt(Frame*, Point);
  55. Point frptofchar(Frame*, u32);
  56. int frdelete(Frame*, u32, u32);
  57. void frinsert(Frame*, Rune*, Rune*, u32);
  58. void frselect(Frame*, Mousectl*);
  59. void frselectpaint(Frame*, Point, Point, Image*);
  60. void frdrawsel(Frame*, Point, u32, u32, int);
  61. Point frdrawsel0(Frame*, Point, u32, u32, Image*, Image*);
  62. void frinit(Frame*, Rectangle, Font*, Image*, Image**);
  63. void frsetrects(Frame*, Rectangle, Image*);
  64. void frclear(Frame*, int);
  65. u8 *_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, u32, u32);
  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*, u32, Point, int);
  85. Point _frptofcharnb(Frame*, u32, 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)