Fix arrow keys, comments and indentation

This commit is contained in:
Night Kaly 2024-11-05 20:00:50 +00:00
parent 9d54946b7a
commit ece4178645
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM
2 changed files with 143 additions and 148 deletions

34
ccc.c
View file

@ -165,14 +165,14 @@ int main(int argc, char **argv)
run = 0;
break;
/* reload using z */
/* reload */
case 'z':
change_dir(cwd, 0, 0);
break;
/* go back by backspace or h or left arrow */
case BACKSPACE: /* PASSTHROUGH */
case LEFT: /* PASSTHROUGH */
/* go back */
case BACKSPACE:
case ARROW_LEFT:
case 'h':;
/* get parent directory */
strcpy(p_cwd, cwd);
@ -187,9 +187,9 @@ int main(int argc, char **argv)
}
break;
/* enter directory/open a file using enter or l or right arrow */
case ENTER: /* PASSTHROUGH */
case RIGHT: /* PASSTHROUGH */
/* enter directory/open a file */
case ENTER:
case ARROW_RIGHT:
case 'l':
strcpy(p_cwd, cwd);
file c_file = files->items[sel_file];
@ -215,7 +215,7 @@ int main(int argc, char **argv)
}
break;
/* jump up (ctrl u) */
/* jump up */
case CTRLU:
if ((sel_file - JUMP_NUM) > 0)
sel_file -= JUMP_NUM;
@ -225,8 +225,8 @@ int main(int argc, char **argv)
list_files();
break;
/* go up by k or up arrow */
case UP: /* PASSTHROUGH */
/* go up */
case ARROW_UP:
case 'k':
if (sel_file > 0)
sel_file--;
@ -234,7 +234,7 @@ int main(int argc, char **argv)
list_files();
break;
/* jump down (ctrl d) */
/* jump down */
case CTRLD:
if ((sel_file + JUMP_NUM) < (files->length - 1))
sel_file += JUMP_NUM;
@ -244,8 +244,8 @@ int main(int argc, char **argv)
list_files();
break;
/* go down by j or down arrow */
case DOWN: /* PASSTHROUGH */
/* go down */
case ARROW_DOWN:
case 'j':
if (sel_file < (files->length - 1))
sel_file++;
@ -395,10 +395,6 @@ int main(int argc, char **argv)
}
break;
/* escape */
case ESC:
break;
default:
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') {
char seq[3];

View file

@ -42,15 +42,10 @@ In COLS:
/* Keybindings */
#define CTRLD 0x04
#define ENTER 0xA
#define ENTER 0xD
#define CTRLU 0x15
#define ESC 0x1B
#define SPACE 0x20
#define TILDE 0x7E
#define DOWN 0x102
#define UP 0x103
#define LEFT 0x104
#define RIGHT 0x105
/* Colros */
#define GREEN "166;227;161"