Add view history using 'e' and update config h for marked files color

This commit is contained in:
Night Kaly 2024-11-17 22:53:06 +00:00
parent 548572536b
commit ff79dbcd64
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM
4 changed files with 33 additions and 2 deletions

View file

@ -61,6 +61,7 @@ A: show directory disk usage/block size
i: toggle file details i: toggle file details
u: sort files u: sort files
x: view file/dir attributes x: view file/dir attributes
e: show history
y: copy filename to clipboard y: copy filename to clipboard
!: open shell in current dir !: open shell in current dir
@ -83,8 +84,6 @@ O: open file with a GUI program detached from file manager
/: search /: search
e: show history
c: copy c: copy
m: move m: move
s: symbolic link s: symbolic link

1
ccc.1
View file

@ -41,6 +41,7 @@ A: show directory disk usage/block size
i: toggle file details i: toggle file details
u: sort files u: sort files
x: view file/dir attributes x: view file/dir attributes
e: show history
y: copy filename to clipboard y: copy filename to clipboard
!: open shell in current dir !: open shell in current dir

30
ccc.c
View file

@ -70,6 +70,7 @@ void delete_files(void);
void start_shell(void); void start_shell(void);
void yank_clipboard(void); void yank_clipboard(void);
void view_file_attr(void); void view_file_attr(void);
void show_history(void);
void wpprintw(const char *fmt, ...); void wpprintw(const char *fmt, ...);
void move_cursor(int row, int col); void move_cursor(int row, int col);
int readch(void); int readch(void);
@ -367,6 +368,10 @@ int main(int argc, char **argv)
view_file_attr(); view_file_attr();
break; break;
case 'e':
show_history();
break;
/* mark one file */ /* mark one file */
case SPACE: case SPACE:
add_file_stat(files->items[sel_file].name, files->items[sel_file].path, 1); add_file_stat(files->items[sel_file].name, files->items[sel_file].path, 1);
@ -502,6 +507,12 @@ void change_dir(const char *buf, int selection, int ftype)
strcpy(tmp, buf); strcpy(tmp, buf);
strcpy(p_cwd, cwd); strcpy(p_cwd, cwd);
strcpy(cwd, tmp); strcpy(cwd, tmp);
char history_path[PATH_MAX];
strcpy(history_path, "~/.cache/ccc/history");
replace_home(history_path);
FILE *history_file = fopen(history_path, "a");
fprintf(history_file, "%s\n", cwd);
fclose(history_file);
} }
if (ftype == 0) if (ftype == 0)
arraylist_free(files); arraylist_free(files);
@ -1272,6 +1283,25 @@ void view_file_attr(void)
readch(); readch();
} }
void show_history(void)
{
bprintf("\033[2J");
move_cursor(1, 1);
char history_path[PATH_MAX];
strcpy(history_path, "~/.cache/ccc/history");
replace_home(history_path);
FILE *history_file = fopen(history_path, "r");
char buffer[PATH_MAX];
int row = 1;
while (fgets(buffer, sizeof(buffer), history_file) && row <= rows - 1) {
move_cursor(row++, 1);
bprintf(buffer);
}
fclose(history_file);
readch();
}
/* /*
* Print line to the panel * Print line to the panel
*/ */

View file

@ -13,6 +13,7 @@ enum files_colors {
FIF_COLOR = 35, /* FIFO */ FIF_COLOR = 35, /* FIFO */
DEF_COLOR = 37, /* Default */ DEF_COLOR = 37, /* Default */
EXE_COLOR = 32, /* Executable file */ EXE_COLOR = 32, /* Executable file */
MAR_COLOR = 36, /* Marked files */
}; };
/* Set width offset for windows: /* Set width offset for windows: