diff --git a/README.md b/README.md index 447c659..b0e5c7b 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ A: show directory disk usage/block size i: toggle file details u: sort files x: view file/dir attributes +e: show history y: copy filename to clipboard !: open shell in current dir @@ -83,8 +84,6 @@ O: open file with a GUI program detached from file manager /: search -e: show history - c: copy m: move s: symbolic link diff --git a/ccc.1 b/ccc.1 index a477a12..9b2aac1 100644 --- a/ccc.1 +++ b/ccc.1 @@ -41,6 +41,7 @@ A: show directory disk usage/block size i: toggle file details u: sort files x: view file/dir attributes +e: show history y: copy filename to clipboard !: open shell in current dir diff --git a/ccc.c b/ccc.c index 4e58371..fd20f10 100644 --- a/ccc.c +++ b/ccc.c @@ -70,6 +70,7 @@ void delete_files(void); void start_shell(void); void yank_clipboard(void); void view_file_attr(void); +void show_history(void); void wpprintw(const char *fmt, ...); void move_cursor(int row, int col); int readch(void); @@ -367,6 +368,10 @@ int main(int argc, char **argv) view_file_attr(); break; + case 'e': + show_history(); + break; + /* mark one file */ case SPACE: 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(p_cwd, cwd); 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) arraylist_free(files); @@ -1272,6 +1283,25 @@ void view_file_attr(void) 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 */ diff --git a/config.h b/config.h index 0e3c549..5be3215 100644 --- a/config.h +++ b/config.h @@ -13,6 +13,7 @@ enum files_colors { FIF_COLOR = 35, /* FIFO */ DEF_COLOR = 37, /* Default */ EXE_COLOR = 32, /* Executable file */ + MAR_COLOR = 36, /* Marked files */ }; /* Set width offset for windows: