reindent with vim
This commit is contained in:
parent
53308203a2
commit
3b54366bb4
30
kilo.c
30
kilo.c
|
@ -160,7 +160,7 @@ int editorReadKey() {
|
|||
if (nread == -1 && errno != EAGAIN)
|
||||
die("read");
|
||||
}
|
||||
|
||||
|
||||
if (c == '\x1b') {
|
||||
char seq[3];
|
||||
|
||||
|
@ -430,12 +430,12 @@ int editorRowRxToCx(erow *row, int rx) {
|
|||
int cur_rx = 0;
|
||||
int cx;
|
||||
for (cx = 0; cx < row->size; cx++) {
|
||||
if (row->chars[cx] == '\t')
|
||||
cur_rx += (KILO_TAB_STOP - 1) - (cur_rx % KILO_TAB_STOP);
|
||||
cur_rx++;
|
||||
if (row->chars[cx] == '\t')
|
||||
cur_rx += (KILO_TAB_STOP - 1) - (cur_rx % KILO_TAB_STOP);
|
||||
cur_rx++;
|
||||
|
||||
if (cur_rx > rx)
|
||||
return cx;
|
||||
if (cur_rx > rx)
|
||||
return cx;
|
||||
}
|
||||
return cx;
|
||||
}
|
||||
|
@ -617,7 +617,7 @@ void editorOpen(char *filename) {
|
|||
ssize_t linelen;
|
||||
while ((linelen = getline(&line, &linecap, fp)) != -1) {
|
||||
while (linelen > 0 && (line[linelen - 1] == '\n' ||
|
||||
line[linelen - 1] == '\r'))
|
||||
line[linelen - 1] == '\r'))
|
||||
linelen--;
|
||||
|
||||
editorInsertRow(E.numrows, line, linelen);
|
||||
|
@ -722,7 +722,7 @@ void editorFind() {
|
|||
int saved_rowoff = E.rowoff;
|
||||
|
||||
char *query = editorPrompt("search: %s (esc/arrows/enter)",
|
||||
editorFindCallback);
|
||||
editorFindCallback);
|
||||
|
||||
if (query) {
|
||||
free(query);
|
||||
|
@ -788,7 +788,7 @@ void editorDrawRows(struct abuf *ab) {
|
|||
if (E.numrows == 0 && y == E.screenrows / 3) {
|
||||
char welcome[80];
|
||||
int welcomelen = snprintf(welcome, sizeof(welcome),
|
||||
"kilo editor -- version %s", KILO_VERSION);
|
||||
"kilo editor -- version %s", KILO_VERSION);
|
||||
if (welcomelen > E.screencols)
|
||||
welcomelen = E.screencols;
|
||||
int padding = (E.screencols - welcomelen) / 2;
|
||||
|
@ -852,10 +852,10 @@ void editorDrawStatusBar(struct abuf *ab) {
|
|||
abAppend(ab, "\x1b[7m", 4);
|
||||
char status[80], rstatus[80];
|
||||
int len = snprintf(status, sizeof(status), "%.20s - %d lines %s",
|
||||
E.filename ? E.filename : "[No Name]", E.numrows,
|
||||
E.dirty ? "(modified)" : "");
|
||||
E.filename ? E.filename : "[No Name]", E.numrows,
|
||||
E.dirty ? "(modified)" : "");
|
||||
int rlen = snprintf(rstatus, sizeof(rstatus), "%s | %d/%d",
|
||||
E.syntax ? E.syntax->filetype : "no ft", E.cy + 1, E.numrows);
|
||||
E.syntax ? E.syntax->filetype : "no ft", E.cy + 1, E.numrows);
|
||||
if (len > E.screencols)
|
||||
len = E.screencols;
|
||||
abAppend(ab, status, len);
|
||||
|
@ -895,7 +895,7 @@ void editorRefreshScreen() {
|
|||
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "\x1b[%d;%dH", (E.cy - E.rowoff) + 1,
|
||||
(E.rx - E.coloff) + 1);
|
||||
(E.rx - E.coloff) + 1);
|
||||
abAppend(&ab, buf, strlen(buf));
|
||||
|
||||
abAppend(&ab, "\x1b[?25h", 6);
|
||||
|
@ -1006,7 +1006,7 @@ void editorProcessKeypress() {
|
|||
case CTRL_KEY('q'):
|
||||
if (E.dirty && quit_times > 0) {
|
||||
editorSetStatusMessage("WARNING!!! file has unsaved changes. "
|
||||
"press ctrl-q %d more times to quit.", quit_times);
|
||||
"press ctrl-q %d more times to quit.", quit_times);
|
||||
quit_times--;
|
||||
return;
|
||||
}
|
||||
|
@ -1105,7 +1105,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
editorSetStatusMessage(
|
||||
"help: ctrl-q = quit | ctrl-s = save | ctrl-f = find");
|
||||
"help: ctrl-q = quit | ctrl-s = save | ctrl-f = find");
|
||||
|
||||
while (1) {
|
||||
editorRefreshScreen();
|
||||
|
|
Loading…
Reference in New Issue