Compare commits
3 commits
a92c9cd07a
...
8541312ec0
Author | SHA1 | Date | |
---|---|---|---|
8541312ec0 | |||
2ec48d0ed4 | |||
f072889a49 |
2 changed files with 39 additions and 6 deletions
10
config.h
10
config.h
|
@ -46,11 +46,17 @@ enum keys {
|
||||||
PAGE_DOWN
|
PAGE_DOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum actions {
|
||||||
|
COUNTING = 500,
|
||||||
|
DELETE
|
||||||
|
};
|
||||||
|
|
||||||
enum modes {
|
enum modes {
|
||||||
NORMAL,
|
NORMAL,
|
||||||
INSERT,
|
INSERT,
|
||||||
VISUAL,
|
VISUAL,
|
||||||
COMMAND
|
COMMAND,
|
||||||
|
PENDING0,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum highlight {
|
enum highlight {
|
||||||
|
@ -121,4 +127,4 @@ language_t langs[] = {
|
||||||
#define LANGS_LEN (sizeof(langs) / sizeof(langs[0]))
|
#define LANGS_LEN (sizeof(langs) / sizeof(langs[0]))
|
||||||
|
|
||||||
#define CTRL_KEY(k) ((k) & 0x1f)
|
#define CTRL_KEY(k) ((k) & 0x1f)
|
||||||
#define COLOR_LEN 19
|
#define MAX_COMMAND_SIZE 512
|
||||||
|
|
35
vip.c
35
vip.c
|
@ -23,6 +23,9 @@ int rows, cols;
|
||||||
editor_t editor[9];
|
editor_t editor[9];
|
||||||
int editors = 0;
|
int editors = 0;
|
||||||
editor_t *cur_editor;
|
editor_t *cur_editor;
|
||||||
|
int action = DEFAULT;
|
||||||
|
char cmd[MAX_COMMAND_SIZE];
|
||||||
|
int cmd_len = 0;
|
||||||
|
|
||||||
void draw_status_bar(void);
|
void draw_status_bar(void);
|
||||||
void refresh_screen(void);
|
void refresh_screen(void);
|
||||||
|
@ -182,8 +185,8 @@ void refresh_screen(void)
|
||||||
draw_rows();
|
draw_rows();
|
||||||
if (!cat_mode) {
|
if (!cat_mode) {
|
||||||
draw_status_bar();
|
draw_status_bar();
|
||||||
move_cursor((cur_editor->y - cur_editor->rowoff) + 1,
|
move_cursor(cur_editor->y - cur_editor->rowoff + 1,
|
||||||
(cur_editor->rx - cur_editor->coloff) + 1);
|
cur_editor->rx - cur_editor->coloff + 1 + 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1076,6 +1079,16 @@ int main(int argc, char **argv)
|
||||||
insert_new_line();
|
insert_new_line();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case '1': case '2': case '3': case '4': case '5': case '6': case '7':
|
||||||
|
case '8': case '9':
|
||||||
|
action = COUNTING;
|
||||||
|
cmd[cmd_len++] = c;
|
||||||
|
cmd[cmd_len] = '\0';
|
||||||
|
/* cmd occupy 10 char and add a trailing space*/
|
||||||
|
int lpadding = cols - 11;
|
||||||
|
wpprintw("%*s%-10s ", lpadding, "", cmd);
|
||||||
|
break;
|
||||||
|
|
||||||
case HOME_KEY:
|
case HOME_KEY:
|
||||||
cur_editor->x = 0;
|
cur_editor->x = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -1211,7 +1224,16 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
case 'j': /* PASSTHROUGH */
|
case 'j': /* PASSTHROUGH */
|
||||||
if (cur_editor->mode != INSERT) {
|
if (cur_editor->mode != INSERT) {
|
||||||
move_xy(ARROW_DOWN);
|
if (action == COUNTING) {
|
||||||
|
for (int i = 0; i < atoi(cmd); i++) {
|
||||||
|
move_xy(ARROW_DOWN);
|
||||||
|
}
|
||||||
|
action = DEFAULT;
|
||||||
|
cmd_len = 0;
|
||||||
|
memset(&cmd, 0, MAX_COMMAND_SIZE);
|
||||||
|
} else {
|
||||||
|
move_xy(ARROW_DOWN);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1243,7 +1265,12 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
case '0': /* PASSTHROUGH */
|
case '0': /* PASSTHROUGH */
|
||||||
if (cur_editor->mode == NORMAL) {
|
if (cur_editor->mode == NORMAL) {
|
||||||
cur_editor->x = 0;
|
if (cmd_len == 0) {
|
||||||
|
cur_editor->x = 0;
|
||||||
|
} else {
|
||||||
|
action = COUNTING;
|
||||||
|
cmd[cmd_len++] = c;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue