gitignore, reformat
This commit is contained in:
parent
5332dd8809
commit
d9d2fc4a36
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
cmake-*
|
8
kilo.c
8
kilo.c
@ -15,6 +15,7 @@
|
||||
|
||||
/*** data ***/
|
||||
struct editorConfig {
|
||||
int cx, cy;
|
||||
int screenrows;
|
||||
int screencols;
|
||||
struct termios orig_termios;
|
||||
@ -87,12 +88,14 @@ int getWindowSize(int *rows, int *cols) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*** append buffer ***/
|
||||
struct abuf {
|
||||
char *b;
|
||||
int len;
|
||||
};
|
||||
#define ABUF_INIT {NULL, 0}
|
||||
|
||||
void abAppend(struct abuf *ab, const char *s, int len) {
|
||||
char *new = realloc(ab->b, ab->len + len);
|
||||
|
||||
@ -101,6 +104,7 @@ void abAppend(struct abuf *ab, const char *s, int len) {
|
||||
ab->b = new;
|
||||
ab->len += len;
|
||||
}
|
||||
|
||||
void abFree(struct abuf *ab) {
|
||||
free(ab->b);
|
||||
}
|
||||
@ -130,6 +134,7 @@ void editorDrawRows(struct abuf *ab) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void editorRefreshScreen() {
|
||||
struct abuf ab = ABUF_INIT;
|
||||
abAppend(&ab, "\x1b[?25l", 6);
|
||||
@ -157,8 +162,11 @@ void editorProcessKeypress() {
|
||||
|
||||
/*** init ***/
|
||||
void initEditor() {
|
||||
E.cx = 0;
|
||||
E.cy = 0;
|
||||
if (getWindowSize(&E.screenrows, &E.screencols) == -1) die("getWindowSize");
|
||||
}
|
||||
|
||||
int main() {
|
||||
enableRawMode();
|
||||
initEditor();
|
||||
|
Loading…
Reference in New Issue
Block a user