ste/src/fbuffer.h

46 lines
1.1 KiB
C
Raw Normal View History

2019-11-18 23:54:59 +01:00
#ifndef _FBUFFER_H_
#define _FBUFFER_H_
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE /* See feature_test_macros(7) */
#endif
2019-11-18 23:54:59 +01:00
/* Row structure, defines actual and
* render chars, actual and render size
* and difference between render and
* real size of the row
* Utf-8 continuation chars */
typedef struct Row {
2019-11-18 23:54:59 +01:00
int size;
int r_size;
int utf;
char *chars;
char *render;
} Row;
2019-11-18 23:54:59 +01:00
/* Empty row initializer */
#define EROW {0, 0, 0, NULL, NULL}
/* Rows structure (or file buffer)
* defines rows and teh number of rows */
typedef struct FileBuffer{
Row *rw;
2019-11-18 23:54:59 +01:00
int rownum;
} FileBuffer;
2019-11-18 23:54:59 +01:00
void bufInit (FileBuffer *b);
2019-11-18 23:54:59 +01:00
void rowAddChar (Row *rw, char c, int pos);
int rowDeleteChar (Row *rw, int select, int pos);
void rowCpy (Row *to, Row *from);
void rowAddRow (FileBuffer *b, int pos, int cur);
void rowFree (Row *rw);
void rowAppendString (Row *rw, char *s, int len);
void rowDeleteRow (FileBuffer *b, int pos);
void rowAddLast (FileBuffer *b, char *s, int len);
2019-11-18 23:54:59 +01:00
void updateRender (Row *rw);
2019-11-18 23:54:59 +01:00
int isUtf (int c);
int isCont (int c);
int isStart (int c);
#endif