Fix arrow keys, comments and indentation
This commit is contained in:
parent
9d54946b7a
commit
ece4178645
2 changed files with 143 additions and 148 deletions
34
ccc.c
34
ccc.c
|
@ -165,14 +165,14 @@ int main(int argc, char **argv)
|
||||||
run = 0;
|
run = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* reload using z */
|
/* reload */
|
||||||
case 'z':
|
case 'z':
|
||||||
change_dir(cwd, 0, 0);
|
change_dir(cwd, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* go back by backspace or h or left arrow */
|
/* go back */
|
||||||
case BACKSPACE: /* PASSTHROUGH */
|
case BACKSPACE:
|
||||||
case LEFT: /* PASSTHROUGH */
|
case ARROW_LEFT:
|
||||||
case 'h':;
|
case 'h':;
|
||||||
/* get parent directory */
|
/* get parent directory */
|
||||||
strcpy(p_cwd, cwd);
|
strcpy(p_cwd, cwd);
|
||||||
|
@ -187,9 +187,9 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* enter directory/open a file using enter or l or right arrow */
|
/* enter directory/open a file */
|
||||||
case ENTER: /* PASSTHROUGH */
|
case ENTER:
|
||||||
case RIGHT: /* PASSTHROUGH */
|
case ARROW_RIGHT:
|
||||||
case 'l':
|
case 'l':
|
||||||
strcpy(p_cwd, cwd);
|
strcpy(p_cwd, cwd);
|
||||||
file c_file = files->items[sel_file];
|
file c_file = files->items[sel_file];
|
||||||
|
@ -215,7 +215,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* jump up (ctrl u) */
|
/* jump up */
|
||||||
case CTRLU:
|
case CTRLU:
|
||||||
if ((sel_file - JUMP_NUM) > 0)
|
if ((sel_file - JUMP_NUM) > 0)
|
||||||
sel_file -= JUMP_NUM;
|
sel_file -= JUMP_NUM;
|
||||||
|
@ -225,8 +225,8 @@ int main(int argc, char **argv)
|
||||||
list_files();
|
list_files();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* go up by k or up arrow */
|
/* go up */
|
||||||
case UP: /* PASSTHROUGH */
|
case ARROW_UP:
|
||||||
case 'k':
|
case 'k':
|
||||||
if (sel_file > 0)
|
if (sel_file > 0)
|
||||||
sel_file--;
|
sel_file--;
|
||||||
|
@ -234,7 +234,7 @@ int main(int argc, char **argv)
|
||||||
list_files();
|
list_files();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* jump down (ctrl d) */
|
/* jump down */
|
||||||
case CTRLD:
|
case CTRLD:
|
||||||
if ((sel_file + JUMP_NUM) < (files->length - 1))
|
if ((sel_file + JUMP_NUM) < (files->length - 1))
|
||||||
sel_file += JUMP_NUM;
|
sel_file += JUMP_NUM;
|
||||||
|
@ -244,8 +244,8 @@ int main(int argc, char **argv)
|
||||||
list_files();
|
list_files();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* go down by j or down arrow */
|
/* go down */
|
||||||
case DOWN: /* PASSTHROUGH */
|
case ARROW_DOWN:
|
||||||
case 'j':
|
case 'j':
|
||||||
if (sel_file < (files->length - 1))
|
if (sel_file < (files->length - 1))
|
||||||
sel_file++;
|
sel_file++;
|
||||||
|
@ -395,10 +395,6 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* escape */
|
|
||||||
case ESC:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1246,6 +1242,10 @@ int read_key(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FILE *f = fopen("/home/night/a", "a");
|
||||||
|
fprintf(f, "c: %d\n", c);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
if (c == '\033') {
|
if (c == '\033') {
|
||||||
char seq[3];
|
char seq[3];
|
||||||
|
|
||||||
|
|
7
config.h
7
config.h
|
@ -42,15 +42,10 @@ In COLS:
|
||||||
|
|
||||||
/* Keybindings */
|
/* Keybindings */
|
||||||
#define CTRLD 0x04
|
#define CTRLD 0x04
|
||||||
#define ENTER 0xA
|
#define ENTER 0xD
|
||||||
#define CTRLU 0x15
|
#define CTRLU 0x15
|
||||||
#define ESC 0x1B
|
|
||||||
#define SPACE 0x20
|
#define SPACE 0x20
|
||||||
#define TILDE 0x7E
|
#define TILDE 0x7E
|
||||||
#define DOWN 0x102
|
|
||||||
#define UP 0x103
|
|
||||||
#define LEFT 0x104
|
|
||||||
#define RIGHT 0x105
|
|
||||||
|
|
||||||
/* Colros */
|
/* Colros */
|
||||||
#define GREEN "166;227;161"
|
#define GREEN "166;227;161"
|
||||||
|
|
Loading…
Reference in a new issue