diff options
author | KatolaZ <katolaz@freaknet.org> | 2019-07-27 06:57:29 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2019-07-27 06:57:29 +0100 |
commit | f678684b470f02d9fed4818eb92c2a925380c428 (patch) | |
tree | fc26ae9768e6c72827b03e973dbf0479b0a0431d /gramscii.h | |
parent | 8b67bd6c5f4e175721b44d4733d1a5a6fc1a2561 (diff) | |
parent | 8e3d23b921d9bbcb7c53017bacff8a3050a34b55 (diff) |
Merge branch 'devel' into master
Diffstat (limited to 'gramscii.h')
-rw-r--r-- | gramscii.h | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/gramscii.h b/gramscii.h new file mode 100644 index 0000000..0b2c81f --- /dev/null +++ b/gramscii.h @@ -0,0 +1,138 @@ +#ifndef __GRAMSCII_H__ +#define __GRAMSCII_H__ + +#include <stdio.h> +#include <termios.h> +#include <unistd.h> + +/** types **/ + +typedef struct{ + int sz; + int lst; + char *s; +} line_t; + +/** constants **/ + +#define MOVE 0x00 +#define BOX 0x01 +#define ARROW 0x02 +#define TEXT 0x04 +#define DEL 0x08 +#define VIS 0x10 + +#define DIR_N 0x00 +#define DIR_R 0x01 +#define DIR_U 0x02 +#define DIR_D 0x04 +#define DIR_L 0x08 + +#define DIR_HOR (DIR_R | DIR_L) +#define DIR_VER (DIR_D | DIR_U) + + +#define NOFIX 0x0 +#define FIX 0x1 + +#define BG ' ' +#define PTR '+' +#define UND '_' +#define ARR_L '<' +#define ARR_R '>' +#define ARR_U '^' +#define ARR_D 'v' + +#define HOME 0x01 +#define END 0x02 +#define MIDDLE 0x04 + +#define VIDEO_NRM 0 +#define VIDEO_REV 7 + + +/** MACROS **/ + +#define MIN(x,y) (x) < (y) ? (x) : (y) +#define MAX(x,y) (x) > (y) ? (x) : (y) + +#define progr_x(d) ((d) == DIR_L ? -1 : (d) == DIR_R ? 1 : 0) +#define progr_y(d) ((d) == DIR_U ? -1 : (d) == DIR_D ? 1 : 0) + +/* #define DEBUG 1 */ + +/** global variables **/ + +line_t *screen; +int num_lines; +int WIDTH, HEIGHT; + +int mode; +int dir; +int x; +int y; +int step; +int mult; +int force_new; +char cursor; +char corner; + +int hlines_sz; +int vlines_sz; +int corners_sz; +int stmarks_sz; +int endmarks_sz; + +int cur_hl, cur_vl, cur_corn, cur_start, cur_end; +char line_h; +char line_v; +char mark_st; +char mark_end; + +char modified; +char fname[256]; + +char visual; +char silent; +char autoend; + +struct termios t1, t2, t3; + +/** screen-related functions **/ +void reset_styles(); +void redraw(); +int move_around(char c, FILE *fc); +void check_bound(); +void status_bar(); +void show_cursor(); +void set_cur(char c); +void update_current(); +void set_xy(int _x, int _y, char c); +void draw_xy(int x, int y, char c); +char get_mark(char dir); +void set_video(int v); +char get_key(FILE *fc, char *msg); +void get_string(FILE *fc, char *msg, char *s, int sz); +void erase_box(int x1, int y1, char c); +int is_yes(char c); +void init_screen(); +void erase_line(char *s); +void erase_screen(); +void go_to(int where); + +/** drawing-related functions **/ +int change_style(char c); +void get_text(FILE *fc); +void get_box(FILE *fc); +void get_arrow(FILE *fc); +void erase(FILE *fc); +void visual_box(FILE *fc); + +/** file-related functions **/ +void write_file(FILE *fc); +void check_modified(FILE *fc); +void load_file(FILE *fc); +void new_file(FILE *fc); + + +#endif |