diff --git a/src/Makefile b/src/Makefile index fc2c4ff..578c71a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -12,8 +12,9 @@ CFLAGS = -Wall \ -std=c99 SRC=$(wildcard *.c) +fn: $(SRC) + $(CC) -o $@ $^ $(CFLAGS) + clean: rm -f fn -fn: $(SRC) - $(CC) -o $@ $^ $(CFLAGS) diff --git a/src/file.c b/src/file.c index 48fe525..879b22f 100644 --- a/src/file.c +++ b/src/file.c @@ -2,25 +2,19 @@ #define _BSD_SOURCE #define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include // for errno +#include // for open, O_CREAT, O_RDWR +#include // for NULL, fclose, fopen, FILE +#include // for free +#include // for strdup, strerror +#include // for close, ftruncate, ssize_t +#include // for termios -#include "fn.h" #include "file.h" -#include "hl.h" -#include "terminal.h" -#include "row.h" +#include "fn.h" // for editorSetStatusMessage, E, editorConfig, edito... +#include "hl.h" // for editorSelectSyntaxHighlight +#include "row.h" // for editorRowsToString +#include "terminal.h" // for die void editorOpen(char *filename) { free(E.filename); diff --git a/src/fn.c b/src/fn.c index ae39d3b..f04b964 100644 --- a/src/fn.c +++ b/src/fn.c @@ -2,28 +2,15 @@ #define _BSD_SOURCE #define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include // for signal, SIGWINCH +#include // for NULL #include "fn.h" -#include "terminal.h" -#include "output.h" -#include "row.h" -#include "hl.h" -#include "search.h" -#include "file.h" -#include "input.h" +#include "file.h" // for editorOpen +#include "input.h" // for editorProcessKeypress +#include "output.h" // for editorRefreshScreen, editorSetStatusMessage +#include "terminal.h" // for die, setWindowSize, enableRawMode + // TODO: Put this somewhere else? void windowResizeCallback(int signum); diff --git a/src/fn.h b/src/fn.h index a0345d0..8294720 100644 --- a/src/fn.h +++ b/src/fn.h @@ -1,6 +1,9 @@ #ifndef _FN_H #define _FN_H +#include // for time_t +#include // for termios + #define FN_VERSION "0.2" #define FN_TAB_STOP 4 #define FN_QUIT_TIMES 2 diff --git a/src/hl.c b/src/hl.c index e4f1534..aa17bb3 100644 --- a/src/hl.c +++ b/src/hl.c @@ -1,19 +1,11 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include // for isdigit, isspace +#include // for NULL +#include // for realloc +#include // for memset, strlen, strncmp, strchr, strcmp, strrchr -#include "fn.h" #include "hl.h" +#include "fn.h" // for erow, E, editorConfig, editorSyntax, editorHighl... + char *C_HL_extensions[] = { ".c", ".h", ".cpp", NULL }; char *C_HL_keywords[] = { diff --git a/src/hl.h b/src/hl.h index 2e04a61..f56f72b 100644 --- a/src/hl.h +++ b/src/hl.h @@ -1,6 +1,9 @@ #ifndef _HL_H #define _HL_H +#include "fn.h" // for erow + + int is_separator(int c); void editorUpdateSyntax(erow *row); int editorSyntaxToColor(int hl); diff --git a/src/input.c b/src/input.c index 2645e77..5e0ba6b 100644 --- a/src/input.c +++ b/src/input.c @@ -1,24 +1,14 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include // for iscntrl +#include // for NULL +#include // for exit, free +#include // for STDOUT_FILENO -#include "fn.h" -#include "row.h" -#include "terminal.h" #include "input.h" -#include "output.h" -#include "file.h" -#include "search.h" +#include "file.h" // for editorSave +#include "fn.h" // for E, editorConfig, erow, CTRL_KEY, editorKey::AR... +#include "output.h" // for editorSetStatusMessage, editorDelChar, editorI... +#include "search.h" // for editorFind +#include "terminal.h" // for editorReadKey char *editorPrompt(char *prompt, void (*callback)(char *, int)) { diff --git a/src/output.c b/src/output.c index f32b944..ad43b5d 100644 --- a/src/output.c +++ b/src/output.c @@ -1,21 +1,15 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include // for iscntrl +#include // for va_list +#include // for snprintf, vsnprintf, NULL +#include // for strlen +#include // for time +#include // for STDOUT_FILENO -#include "fn.h" -#include "row.h" -#include "hl.h" #include "output.h" +#include "fn.h" // for E, editorConfig, erow, FN_VERSION, abuf, editorH... +#include "hl.h" // for editorSyntaxToColor +#include "row.h" // for abAppend, abFree, editorDelRow, editorRowCxToRx + void editorScroll() { E.rx = 0; diff --git a/src/output.h b/src/output.h index 373ae35..27cd693 100644 --- a/src/output.h +++ b/src/output.h @@ -1,6 +1,8 @@ #ifndef _OUTPUT_H #define _OUTPUT_H +struct abuf; + void editorScroll(); void editorDrawRows(struct abuf *ab); diff --git a/src/row.c b/src/row.c index 23b1225..d6f8dd1 100644 --- a/src/row.c +++ b/src/row.c @@ -1,20 +1,11 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include // for NULL +#include // for free, realloc, malloc +#include // for memmove, memcpy -#include "fn.h" -#include "hl.h" #include "row.h" +#include "fn.h" // for erow, E, editorConfig, FN_TAB_STOP, abuf +#include "hl.h" // for editorUpdateSyntax + void abAppend(struct abuf *ab, const char *s, int len) { char *new = realloc(ab->b, ab->len + len); diff --git a/src/row.h b/src/row.h index de04a68..8afb07f 100644 --- a/src/row.h +++ b/src/row.h @@ -1,8 +1,13 @@ #ifndef _ROW_H #define _ROW_H +#include // for NULL +#include "fn.h" // for erow + + #define ABUF_INIT {NULL, 0} + void abAppend(struct abuf *ab, const char *s, int len); void abFree(struct abuf *ab); diff --git a/src/search.c b/src/search.c index 25db62c..05c3a56 100644 --- a/src/search.c +++ b/src/search.c @@ -1,20 +1,10 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "fn.h" #include "search.h" -#include "row.h" +#include // for NULL +#include // for free, malloc +#include // for memcpy, memset, strlen, strstr +#include "fn.h" // for E, editorConfig, erow, editorPrompt, editorHighl... +#include "row.h" // for editorRowRxToCx + void editorFindCallback(char *query, int key) { static int last_match = -1; diff --git a/src/terminal.c b/src/terminal.c index 3e2ed31..b92cdab 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1,13 +1,12 @@ -#include -#include -#include -#include -#include -#include -#include +#include // for EAGAIN, errno +#include // for perror, sscanf +#include // for atexit, exit +#include // for winsize, ioctl, TIOCGWINSZ +#include // for termios, tcsetattr, tcgetattr, TCSAFLUSH, cc_t +#include // for STDIN_FILENO, STDOUT_FILENO -#include "fn.h" #include "terminal.h" +#include "fn.h" // for E, editorConfig, editorKey::END_KEY, editorKe... void die(const char *s) { write(STDOUT_FILENO, "\x1b[2J", 4);