Compare commits
No commits in common. "a92c9cd07a75c45271adcf6fedaba47adb1bb189" and "6d6f1e2524e7269d612d50a31b93ef7cf204a627" have entirely different histories.
a92c9cd07a
...
6d6f1e2524
4 changed files with 7 additions and 47 deletions
28
README.md
28
README.md
|
@ -1,38 +1,12 @@
|
||||||
# vip
|
# vip
|
||||||
Small, fast and featureful vim-insipired text editor with strictly no dependency.
|
Small, fast and featureful vim-insipired text editor with strictly no dependency.
|
||||||
|
|
||||||
It has colorful syntax highlighting and integrate with [ccc](https://github.com/night0721/ccc) for picking files
|
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
```sh
|
```sh
|
||||||
vip -c file # Cat mode
|
|
||||||
vip file
|
vip file
|
||||||
|
vip -c file
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
|
||||||
LEFT/h: left
|
|
||||||
DOWN/j: down
|
|
||||||
UP/k: up
|
|
||||||
RIGHT/l: right
|
|
||||||
HOME/0: start of line
|
|
||||||
END/$: end of line
|
|
||||||
PAGEUP: jump up a page
|
|
||||||
PAGEDOWN: jump down a page
|
|
||||||
Backspace/ctrl+h/del: delete char
|
|
||||||
:w: save file
|
|
||||||
:q(!): quit
|
|
||||||
i: insert mode
|
|
||||||
v: visual mode
|
|
||||||
ESC: normal mode
|
|
||||||
gg: start of file
|
|
||||||
G: end of file
|
|
||||||
dd: delete line
|
|
||||||
/: search
|
|
||||||
O: create new line above cursor
|
|
||||||
o: create new line below cursor
|
|
||||||
pv: open ccc
|
|
||||||
|
|
||||||
```
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
None
|
None
|
||||||
|
|
||||||
|
|
6
TODO
6
TODO
|
@ -1,6 +0,0 @@
|
||||||
Line number
|
|
||||||
Auto indent
|
|
||||||
soft wrap lines
|
|
||||||
copy paste
|
|
||||||
multiple buffer information
|
|
||||||
keybinding in config
|
|
3
config.h
3
config.h
|
@ -5,8 +5,7 @@
|
||||||
/* THEME */
|
/* THEME */
|
||||||
/* 38 and 48 is reversed as bar's color is reversed */
|
/* 38 and 48 is reversed as bar's color is reversed */
|
||||||
|
|
||||||
#define SURFACE_0_BG "\033[38;2;49;50;68m"
|
#define SURFACE_1_BG "\033[38;2;049;050;068m"
|
||||||
#define SURFACE_1_BG "\033[38;2;69;71;90m"
|
|
||||||
#define OVERLAY_2_BG "\033[38;2;147;153;178m"
|
#define OVERLAY_2_BG "\033[38;2;147;153;178m"
|
||||||
#define BLACK_FG "\033[40m"
|
#define BLACK_FG "\033[40m"
|
||||||
#define BLACK_BG "\033[30m"
|
#define BLACK_BG "\033[30m"
|
||||||
|
|
17
vip.c
17
vip.c
|
@ -100,7 +100,7 @@ void draw_status_bar(void)
|
||||||
}
|
}
|
||||||
int coord_len = snprintf(coord, sizeof(coord), " %d:%d ", cur_editor->y + 1, cur_editor->x + 1);
|
int coord_len = snprintf(coord, sizeof(coord), " %d:%d ", cur_editor->y + 1, cur_editor->x + 1);
|
||||||
|
|
||||||
bprintf(SURFACE_0_BG); /* background */
|
bprintf(SURFACE_1_BG); /* background */
|
||||||
/* text */
|
/* text */
|
||||||
switch (cur_editor->mode) {
|
switch (cur_editor->mode) {
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
|
@ -120,7 +120,7 @@ void draw_status_bar(void)
|
||||||
|
|
||||||
while (file_len < cols) {
|
while (file_len < cols) {
|
||||||
if (cols - mode_len - git_len - file_len == info_len + lines_len + coord_len) {
|
if (cols - mode_len - git_len - file_len == info_len + lines_len + coord_len) {
|
||||||
bprintf("%s%s", info, SURFACE_0_BG);
|
bprintf("%s%s", info, SURFACE_1_BG);
|
||||||
if (cur_editor->mode == NORMAL) {
|
if (cur_editor->mode == NORMAL) {
|
||||||
bprintf(BLUE_FG);
|
bprintf(BLUE_FG);
|
||||||
} else if (cur_editor->mode == INSERT) {
|
} else if (cur_editor->mode == INSERT) {
|
||||||
|
@ -585,19 +585,11 @@ void draw_rows(void)
|
||||||
char *c = &cur_editor->row[filerow].render[cur_editor->coloff];
|
char *c = &cur_editor->row[filerow].render[cur_editor->coloff];
|
||||||
unsigned char *hl = &cur_editor->row[filerow].hl[cur_editor->coloff];
|
unsigned char *hl = &cur_editor->row[filerow].hl[cur_editor->coloff];
|
||||||
|
|
||||||
int absydiff = abs(filerow - cur_editor->y);
|
|
||||||
if (absydiff == 0) {
|
|
||||||
int num_digits = snprintf(NULL, 0, "%d", cur_editor->y + 1);
|
|
||||||
int left_padding = (6 - num_digits) / 2;
|
|
||||||
int right_padding = 6 - num_digits - left_padding;
|
|
||||||
|
|
||||||
bprintf("%s%*s%d%*s ", SURFACE_1_BG, left_padding, "", cur_editor->y + 1, right_padding, "");
|
|
||||||
} else {
|
|
||||||
bprintf("%s%6d ", SURFACE_1_BG, absydiff);
|
|
||||||
}
|
|
||||||
for (int j = 0; j < len; j++) {
|
for (int j = 0; j < len; j++) {
|
||||||
if (iscntrl(c[j])) {
|
if (iscntrl(c[j])) {
|
||||||
bprintf("%s%c\033[m", OVERLAY_2_BG, '@' + c[j]);
|
bprintf("%s%c\033[m", OVERLAY_2_BG, '@' + c[j]);
|
||||||
|
} else if (hl[j] == NORMAL) {
|
||||||
|
bprintf("%s%c", WHITE_BG, c[j]);
|
||||||
} else {
|
} else {
|
||||||
switch (hl[j]) {
|
switch (hl[j]) {
|
||||||
case NUMBER:
|
case NUMBER:
|
||||||
|
@ -1120,6 +1112,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CTRL_KEY('l'):
|
||||||
case '\033':
|
case '\033':
|
||||||
if (cur_editor->mode == INSERT) {
|
if (cur_editor->mode == INSERT) {
|
||||||
move_xy(ARROW_LEFT);
|
move_xy(ARROW_LEFT);
|
||||||
|
|
Loading…
Reference in a new issue