From 6ee92025a0b666e606ca646eac655f4efb4a8427 Mon Sep 17 00:00:00 2001 From: night0721 Date: Wed, 20 Mar 2024 12:28:08 +0000 Subject: [PATCH] refactor --- ccc.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ccc.c b/ccc.c index 0a4ad66..3d9a3cf 100644 --- a/ccc.c +++ b/ccc.c @@ -16,6 +16,7 @@ #include "config.h" /* functions' definitions */ +void start_ccc(); void change_dir(const char *buf, int selection); int mkdir_p(const char *destdir); void populate_files(const char *path, int ftype); @@ -80,15 +81,9 @@ int main(int argc, char** argv) init_pair(7, COLOR_CYAN, -1); /* MARKED FILES */ init_pair(8, COLOR_WHITE, -1); /* REG */ - half_width = COLS / 2; - init_windows(); - refresh(); - cwd = memalloc(PATH_MAX * sizeof(char)); getcwd(cwd, PATH_MAX); - - populate_files(cwd, 0); - highlight_current_line(); + start_ccc(); int ch, ch2; while (1) { @@ -298,11 +293,7 @@ int main(int argc, char** argv) delwin(preview_content); delwin(panel); endwin(); - half_width = COLS / 2; - init_windows(); - refresh(); - populate_files(cwd, 0); - highlight_current_line(); + start_ccc(); break; default: break; @@ -314,6 +305,15 @@ int main(int argc, char** argv) return 0; } +void start_ccc() +{ + half_width = COLS / 2; + init_windows(); + refresh(); + populate_files(cwd, 0); + highlight_current_line(); +} + /* * Change directory in window with selection */