1 /* 2 * $Id: api.h,v 1.16 2020/01/17 23:11:59 tom Exp $ 3 */ 4 5 /* 6 * The VileBuf structure is used by an extension language (such 7 * as Perl) interface to provide an interface to BUFFER. In this 8 * structure, we have a pointer to a BUFFER as well as other fields. 9 * 10 * In particular, the fwp (fake window pointer) is needed because 11 * most of vile's editing operations will not work right unless there 12 * is also an associated window. We don't necessarily want to change 13 * the user visible windows, so we create a fake window (and then 14 * later destroy it) for the express purpose of fooling the rest of 15 * vile into thinking that it's working on a real window. Care 16 * must be taken not to enter any display code, however, since these 17 * fake windows use negative numbers to denote the top line of the 18 * screen. 19 */ 20 21 typedef struct { 22 BUFFER * bp; 23 WINDOW * fwp; /* fake window pointer */ 24 REGION region; /* Region to traverse */ 25 REGIONSHAPE regionshape; 26 int inplace_edit; /* Delete after get? */ 27 int dot_inited; /* Has dot been initialized 28 for api_dotgline? */ 29 int changed; /* Were any changes done? */ 30 int dot_changed; /* DOT explicitly changed -- 31 implies that DOT should 32 be propagated */ 33 B_COUNT ndel; /* number of characters to delete upon 34 setup; related to the inplace_edit 35 stuff */ 36 #if OPT_PERL 37 void * perl_handle; /* perl visible handle to this 38 data structure */ 39 #endif 40 } VileBuf; 41 42 /* 43 * A VileWin is a good deal simpler. It is simply a Window *. But 44 * to perl (and other extension languages as well), the window is 45 * represented by its id. When the actual window is needed, we use 46 * id2win (see window.c) to convert the id to the window. 47 */ 48 typedef WINDOW *VileWin; 49 50 extern int api_aline(VileBuf *, int, char *, int); 51 extern int api_edit(char *fname, VileBuf **retspp); 52 extern int api_dline(VileBuf *, int); 53 extern int api_gline(VileBuf *, int, char **, int *); 54 extern int api_sline(VileBuf *, int, char *, int); 55 extern int api_iline(VileBuf *, int, char *, int); 56 extern int api_lline(VileBuf *, int *); 57 extern int api_swscreen(VileBuf *, VileBuf *); 58 extern VileBuf *api_fscreen(char *); 59 extern VileBuf *api_bp2vbp(BUFFER *bp); 60 extern void api_command_cleanup(void); 61 extern int api_dotinsert(VileBuf *sp, char *text, int len); 62 extern int api_dotgline(VileBuf *, char **, B_COUNT *, int *); 63 extern int api_gotoline(VileBuf *sp, int lno); 64 extern void api_setup_fake_win(VileBuf *sp, int do_delete); 65 extern int api_delregion(VileBuf *vbp); 66 extern int api_motion(VileBuf *vbp, char *mstr); 67 extern void api_update(void); 68 69 extern WINDOW *curwp_visible; 70 71 #define vbp2bp(sp) (((VileBuf *)(sp))->bp) 72 #define bp2vbp(bp) ((VileBuf *) (bp)->b_api_private) 73