plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

frame.h (2850B)


      1 #ifndef _FRAME_H_
      2 #define _FRAME_H_ 1
      3 #if defined(__cplusplus)
      4 extern "C" {
      5 #endif
      6 
      7 AUTOLIB(frame)
      8 
      9 typedef struct Frbox Frbox;
     10 typedef struct Frame Frame;
     11 
     12 enum{
     13 	BACK,
     14 	HIGH,
     15 	BORD,
     16 	TEXT,
     17 	HTEXT,
     18 	NCOL
     19 };
     20 
     21 #define	FRTICKW	3
     22 struct Frbox
     23 {
     24 	long		wid;		/* in pixels */
     25 	long		nrune;		/* <0 ==> negate and treat as break char */
     26 	uchar	*ptr;
     27 	short	bc;	/* break char */
     28 	short	minwid;
     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 	int			tickscale;	/* tick scaling factor */
     54 };
     55 
     56 ulong	frcharofpt(Frame*, Point);
     57 Point	frptofchar(Frame*, ulong);
     58 int	frdelete(Frame*, ulong, ulong);
     59 void	frinsert(Frame*, Rune*, Rune*, ulong);
     60 void	frselect(Frame*, Mousectl*);
     61 void	frselectpaint(Frame*, Point, Point, Image*);
     62 void	frdrawsel(Frame*, Point, ulong, ulong, int);
     63 Point	frdrawsel0(Frame*, Point, ulong, ulong, Image*, Image*);
     64 void	frinit(Frame*, Rectangle, Font*, Image*, Image**);
     65 void	frsetrects(Frame*, Rectangle, Image*);
     66 void	frclear(Frame*, int);
     67 void	frredraw(Frame*);
     68 
     69 uchar	*_frallocstr(Frame*, unsigned);
     70 void	_frinsure(Frame*, int, unsigned);
     71 Point	_frdraw(Frame*, Point);
     72 void	_frgrowbox(Frame*, int);
     73 void	_frfreebox(Frame*, int, int);
     74 void	_frmergebox(Frame*, int);
     75 void	_frdelbox(Frame*, int, int);
     76 void	_frsplitbox(Frame*, int, int);
     77 int	_frfindbox(Frame*, int, ulong, ulong);
     78 void	_frclosebox(Frame*, int, int);
     79 int	_frcanfit(Frame*, Point, Frbox*);
     80 void	_frcklinewrap(Frame*, Point*, Frbox*);
     81 void	_frcklinewrap0(Frame*, Point*, Frbox*);
     82 void	_fradvance(Frame*, Point*, Frbox*);
     83 int	_frnewwid(Frame*, Point, Frbox*);
     84 int	_frnewwid0(Frame*, Point, Frbox*);
     85 void	_frclean(Frame*, Point, int, int);
     86 void	_frdrawtext(Frame*, Point, Image*, Image*);
     87 void	_fraddbox(Frame*, int, int);
     88 Point	_frptofcharptb(Frame*, ulong, Point, int);
     89 Point	_frptofcharnb(Frame*, ulong, int);
     90 int	_frstrlen(Frame*, int);
     91 void	frtick(Frame*, Point, int);
     92 void	frinittick(Frame*);
     93 
     94 #define	NRUNE(b)	((b)->nrune<0? 1 : (b)->nrune)
     95 #define	NBYTE(b)	strlen((char*)(b)->ptr)
     96 #if defined(__cplusplus)
     97 }
     98 #endif
     99 #endif