updoot
This commit is contained in:
parent
d4a5b16f6d
commit
f298b0b5fd
20
kilo.c
20
kilo.c
@ -11,6 +11,8 @@
|
||||
|
||||
/*** defines ***/
|
||||
|
||||
#define KILO_VERSION "0.0.1"
|
||||
|
||||
#define CTRL_KEY(k) ((k) & 0x1f)
|
||||
|
||||
/*** data ***/
|
||||
@ -123,8 +125,23 @@ void abFree(struct abuf *ab) {
|
||||
void editorDrawRows(struct abuf *ab) {
|
||||
int y;
|
||||
for (y = 0; y < E.screenrows; y++) {
|
||||
abAppend(ab, "~", 1);
|
||||
if (y == E.screenrows / 3) {
|
||||
char welcome[80];
|
||||
int welcomelen = snprintf(welcome, sizeof(welcome),
|
||||
"Kilo editor -- version %s", KILO_VERSION);
|
||||
if (welcomelen > E.screencols) welcomelen = E.screencols;
|
||||
int padding = (E.screencols - welcomelen) / 2;
|
||||
if (padding) {
|
||||
abAppend(ab, "~", 1);
|
||||
padding--;
|
||||
}
|
||||
while (padding--) abAppend(ab, " ", 1);
|
||||
abAppend(ab, welcome, welcomelen);
|
||||
} else {
|
||||
abAppend(ab, "~", 1);
|
||||
}
|
||||
|
||||
abAppend(ab, "\x1b[K", 3);
|
||||
if (y < E.screenrows - 1) {
|
||||
abAppend(ab, "\r\n", 2);
|
||||
}
|
||||
@ -135,7 +152,6 @@ void editorRefreshScreen() {
|
||||
struct abuf ab = ABUF_INIT;
|
||||
|
||||
abAppend(&ab, "\x1b[?25l", 6);
|
||||
abAppend(&ab, "\x1b[2J", 4);
|
||||
abAppend(&ab, "\x1b[H" , 3);
|
||||
|
||||
editorDrawRows(&ab);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user