From deca6f4d03d36e4980715ae6709f244f381b1175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 9 Sep 2014 21:50:38 +0200 Subject: Cleanup header files --- Makefile | 2 +- editor.h | 30 +++--------------------------- syntax.h | 28 ++++++++++++++++++++++++++++ text.h | 2 ++ vis.c | 2 ++ window.c | 5 +++-- window.h | 4 ++-- 7 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 syntax.h diff --git a/Makefile b/Makefile index 85725d7..601bb94 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ include config.mk SRC = editor.c window.c text.c text-motions.c text-objects.c register.c -HDR := ${SRC:.c=.h} util.h config.def.h +HDR := ${SRC:.c=.h} syntax.h util.h config.def.h SRC += vis.c colors.c OBJ = ${SRC:.c=.o} ALL = ${SRC} ${HDR} config.mk Makefile LICENSE README vis.1 diff --git a/editor.h b/editor.h index 3bb67fc..1aa98ff 100644 --- a/editor.h +++ b/editor.h @@ -1,12 +1,12 @@ #ifndef EDITOR_H #define EDITOR_H +#include #include -#include -#include "text-motions.h" -#include "text-objects.h" +#include #include "window.h" #include "register.h" +#include "syntax.h" typedef struct Editor Editor; typedef struct EditorWin EditorWin; @@ -103,30 +103,6 @@ struct Editor { bool running; /* (TODO move elsewhere?) */ }; - -typedef struct { - short fg, bg; /* fore and background color */ - int attr; /* curses attributes */ -} Color; - -typedef struct { - char *rule; /* regex to search for */ - int cflags; /* compilation flags (REG_*) used when compiling */ - Color color; /* settings to apply in case of a match */ - regex_t regex; /* compiled form of the above rule */ -} SyntaxRule; - -#define SYNTAX_REGEX_RULES 10 - -typedef struct Syntax Syntax; - -struct Syntax { /* a syntax definition */ - char *name; /* syntax name */ - char *file; /* apply to files matching this regex */ - regex_t file_regex; /* compiled file name regex */ - SyntaxRule rules[SYNTAX_REGEX_RULES]; /* all rules for this file type */ -}; - Editor *editor_new(int width, int height); void editor_free(Editor*); void editor_resize(Editor*, int width, int height); diff --git a/syntax.h b/syntax.h new file mode 100644 index 0000000..a945389 --- /dev/null +++ b/syntax.h @@ -0,0 +1,28 @@ +#ifndef SYNTAX_H +#define SYNTAX_H + +#include + +#define SYNTAX_REGEX_RULES 10 + +typedef struct { + short fg, bg; /* fore and background color */ + int attr; /* curses attributes */ +} Color; + +typedef struct { + char *rule; /* regex to search for */ + int cflags; /* compilation flags (REG_*) used when compiling */ + Color color; /* settings to apply in case of a match */ + regex_t regex; /* compiled form of the above rule */ +} SyntaxRule; + +typedef struct Syntax Syntax; +struct Syntax { /* a syntax definition */ + char *name; /* syntax name */ + char *file; /* apply to files matching this regex */ + regex_t file_regex; /* compiled file name regex */ + SyntaxRule rules[SYNTAX_REGEX_RULES]; /* all rules for this file type */ +}; + +#endif diff --git a/text.h b/text.h index ea490b3..1b4bc2b 100644 --- a/text.h +++ b/text.h @@ -4,6 +4,8 @@ #include #include +typedef size_t Filepos; + typedef struct { size_t start, end; /* range in bytes from start of file */ } Filerange; diff --git a/vis.c b/vis.c index 2b87afa..3afa2fa 100644 --- a/vis.c +++ b/vis.c @@ -13,6 +13,8 @@ #include #include "editor.h" +#include "text-motions.h" +#include "text-objects.h" #include "util.h" #ifdef PDCURSES diff --git a/window.c b/window.c index aca60d3..a2209de 100644 --- a/window.c +++ b/window.c @@ -19,11 +19,12 @@ #include #include #include -#include "editor.h" +#include +#include #include "window.h" +#include "syntax.h" #include "text.h" #include "text-motions.h" -#include "text-objects.h" #include "util.h" typedef struct { /* used to calculate the display width of a character */ diff --git a/window.h b/window.h index 42079f1..2f5d5ee 100644 --- a/window.h +++ b/window.h @@ -1,12 +1,12 @@ #ifndef WINDOW_H #define WINDOW_H -#include +#include +#include #include "text.h" typedef struct Syntax Syntax; typedef struct Win Win; -typedef size_t Filepos; Win *window_new(Text*); void window_free(Win*); -- cgit v1.2.3