2021-08-03 01:37:06 -04:00
|
|
|
/* line.h -- line centric interface */
|
|
|
|
#ifndef _LINE_H_
|
|
|
|
#define _LINE_H_
|
|
|
|
|
|
|
|
#include "names.h"
|
2012-07-11 13:43:16 -04:00
|
|
|
#include "utf8.h"
|
|
|
|
|
2021-08-12 23:06:58 -04:00
|
|
|
/* All text is kept in circularly linked lists of "struct line" structures.
|
|
|
|
These begin at the header line (which is the blank line beyond the end
|
|
|
|
of the buffer). This line is pointed to by the "struct buffer". Each
|
|
|
|
line contains a number of bytes in the line (the "used" size), the size
|
|
|
|
of the text array, and the text. The end of line is not stored as a
|
|
|
|
byte; it's implied. Future additions will include update hints, and a
|
|
|
|
list of marks into the line.
|
2010-11-14 21:10:03 -05:00
|
|
|
*/
|
2016-03-25 02:56:34 -04:00
|
|
|
typedef struct line {
|
2021-08-21 22:51:46 -04:00
|
|
|
struct line *l_fp ; /* Forward link to the next line */
|
|
|
|
struct line *l_bp ; /* Backward link to the previous line */
|
|
|
|
int l_size ; /* Allocated size */
|
|
|
|
int l_used ; /* Used size */
|
|
|
|
char l_text[] ; /* A bunch of characters */
|
2016-03-25 02:56:34 -04:00
|
|
|
} *line_p ;
|
2010-11-14 21:10:03 -05:00
|
|
|
|
|
|
|
#define lforw(lp) ((lp)->l_fp)
|
|
|
|
#define lback(lp) ((lp)->l_bp)
|
|
|
|
#define lgetc(lp, n) ((lp)->l_text[(n)]&0xFF)
|
|
|
|
#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
|
|
|
|
#define llength(lp) ((lp)->l_used)
|
|
|
|
|
2021-08-12 23:06:58 -04:00
|
|
|
extern int tabwidth ; /* Map to $tab, default to 8, can be set to [1, .. */
|
2013-10-09 23:42:33 -04:00
|
|
|
|
2021-07-31 03:28:32 -04:00
|
|
|
/* Bindable functions */
|
2021-08-12 23:06:58 -04:00
|
|
|
BBINDABLE( backchar) ;
|
|
|
|
BBINDABLE( forwchar) ;
|
|
|
|
BINDABLE( insspace) ;
|
|
|
|
BINDABLE( yank) ;
|
2013-06-13 23:53:59 -04:00
|
|
|
|
2013-05-18 20:43:30 -04:00
|
|
|
void lchange( int flag) ;
|
2021-08-22 00:35:39 -04:00
|
|
|
boolean linstr( char *instr) ;
|
2021-08-21 22:51:46 -04:00
|
|
|
boolean linsert( int n, unicode_t c) ;
|
2016-05-20 19:52:19 -04:00
|
|
|
boolean linsert_byte( int n, int c) ;
|
2021-08-22 00:35:39 -04:00
|
|
|
boolean lover( char *ostr) ;
|
2021-08-21 22:51:46 -04:00
|
|
|
boolean lnewline( void) ;
|
2016-05-19 02:02:43 -04:00
|
|
|
boolean ldelete( long n, boolean kflag) ;
|
|
|
|
boolean ldelchar( long n, boolean kflag) ;
|
2021-08-03 01:37:06 -04:00
|
|
|
int lgetchar( unicode_t *cref) ;
|
2013-05-18 20:43:30 -04:00
|
|
|
void kdelete( void) ;
|
|
|
|
int kinsert( int c) ;
|
2021-09-15 01:15:31 -04:00
|
|
|
line_p lalloc( int minsize) ; /* Allocate a line of at least minsize chars. */
|
|
|
|
void lfree( line_p lp) ; /* free a line, updating buffers and windows */
|
|
|
|
const char *getkill( void) ; /* get value of $kill */
|
2010-11-14 21:10:03 -05:00
|
|
|
|
2021-08-12 23:06:58 -04:00
|
|
|
boolean rdonly( void) ; /* Read Only error message */
|
2021-08-03 01:37:06 -04:00
|
|
|
|
2021-08-12 23:06:58 -04:00
|
|
|
#endif
|
2021-08-03 01:37:06 -04:00
|
|
|
/* end of line.h */
|