#define _DEFAULT_SOURCE #define _BSD_SOURCE #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include "fn.h" #include "terminal.h" #include "output.h" #include "row.h" #include "hl.h" #include "search.h" #include "file.h" #include "input.h" // TODO: Put this somewhere else? void windowResizeCallback(int signum); void initEditor(); void windowResizeCallback(int signum) { if (signum != SIGWINCH) { return; } if (setWindowSize(&E.screenrows, &E.screencols) == -1) { die("setWindowSize"); } E.screenrows -= 2; editorRefreshScreen(); } void initEditor() { E.cx = 0; E.cy = 0; E.rx = 0; E.rowoff = 0; E.coloff = 0; E.numrows = 0; E.row = NULL; E.dirty = 0; E.filename = NULL; E.statusmsg[0] = '\0'; E.statusmsg_time = 0; E.syntax = NULL; if (setWindowSize(&E.screenrows, &E.screencols) == -1) { die("setWindowSize"); } E.screenrows -= 2; } int main(int argc, char *argv[]) { enableRawMode(); initEditor(); if (argc >= 2) { editorOpen(argv[1]); } editorSetStatusMessage("HELP: Ctrl-S = save | Ctrl-Q = Quit | Ctrl-F = find"); signal(SIGWINCH, windowResizeCallback); while (1) { editorRefreshScreen(); editorProcessKeypress(); } return 0; }