Remove defines to use static *
This commit is contained in:
parent
600dc69dd6
commit
fc83b825e9
2 changed files with 22 additions and 29 deletions
24
ccc.c
24
ccc.c
|
@ -55,10 +55,6 @@ unsigned int focus = 0;
|
||||||
long sel_file = 0;
|
long sel_file = 0;
|
||||||
bool file_picker = false;
|
bool file_picker = false;
|
||||||
bool to_open_file = false;
|
bool to_open_file = false;
|
||||||
bool dirs_size = DIRS_SIZE;
|
|
||||||
bool show_hidden = SHOW_HIDDEN;
|
|
||||||
bool file_details = SHOW_DETAILS;
|
|
||||||
bool show_icons = SHOW_ICONS;
|
|
||||||
char *argv_cp;
|
char *argv_cp;
|
||||||
char *cwd;
|
char *cwd;
|
||||||
char *p_cwd; /* previous cwd */
|
char *p_cwd; /* previous cwd */
|
||||||
|
@ -215,8 +211,8 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* jump up */
|
/* 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;
|
||||||
else
|
else
|
||||||
sel_file = 0;
|
sel_file = 0;
|
||||||
|
|
||||||
|
@ -234,8 +230,8 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* jump down */
|
/* 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;
|
||||||
else
|
else
|
||||||
sel_file = (files->length - 1);
|
sel_file = (files->length - 1);
|
||||||
|
|
||||||
|
@ -319,7 +315,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* toggle file details */
|
/* toggle file details */
|
||||||
case 'i':
|
case 'i':
|
||||||
file_details = !file_details;
|
show_details = !show_details;
|
||||||
change_dir(cwd, 0, 0);
|
change_dir(cwd, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -408,7 +404,7 @@ void handle_sigwinch(int ignore)
|
||||||
cleanup();
|
cleanup();
|
||||||
die("ccc: Terminal size needs to be at least 80x24");
|
die("ccc: Terminal size needs to be at least 80x24");
|
||||||
}
|
}
|
||||||
half_width = cols / 2 + WINDOW_OFFSET;
|
half_width = cols / 2 + window_offset;
|
||||||
list_files();
|
list_files();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,10 +673,10 @@ void add_file_stat(char *filename, char *path, int ftype)
|
||||||
bytes = total_dir_size;
|
bytes = total_dir_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* 4 before decimal + 1 dot + DECIMAL_PLACES (after decimal) +
|
/* 4 before decimal + 1 dot + decimal_place (after decimal) +
|
||||||
unit length (1 for K, 3 for KiB, taking units[1] as B never changes) + 1 space + 1 null */
|
unit length (1 for K, 3 for KiB, taking units[1] as B never changes) + 1 space + 1 null */
|
||||||
static const char* units[] = {"B", "K", "M", "G", "T", "P"};
|
static const char* units[] = {"B", "K", "M", "G", "T", "P"};
|
||||||
int size_size = 4 + 1 + DECIMAL_PLACES + strlen(units[1]) + 1 + 1;
|
int size_size = 4 + 1 + decimal_place + strlen(units[1]) + 1 + 1;
|
||||||
char *size = memalloc(size_size);
|
char *size = memalloc(size_size);
|
||||||
int unit = 0;
|
int unit = 0;
|
||||||
while (bytes > 1024) {
|
while (bytes > 1024) {
|
||||||
|
@ -691,7 +687,7 @@ void add_file_stat(char *filename, char *path, int ftype)
|
||||||
if (bytes == (unsigned int) bytes) {
|
if (bytes == (unsigned int) bytes) {
|
||||||
sprintf(size, "%d%s", (unsigned int) bytes, units[unit]);
|
sprintf(size, "%d%s", (unsigned int) bytes, units[unit]);
|
||||||
} else {
|
} else {
|
||||||
sprintf(size, "%.*f%s", DECIMAL_PLACES, bytes, units[unit]);
|
sprintf(size, "%.*f%s", decimal_place, bytes, units[unit]);
|
||||||
}
|
}
|
||||||
/* get file mode string */
|
/* get file mode string */
|
||||||
char *mode_str = get_file_mode(file_stat.st_mode);
|
char *mode_str = get_file_mode(file_stat.st_mode);
|
||||||
|
@ -789,7 +785,7 @@ void list_files(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* print the actual filename and stats */
|
/* print the actual filename and stats */
|
||||||
char *line = get_line(files, i, file_details, show_icons);
|
char *line = get_line(files, i, show_details, show_icons);
|
||||||
int color = files->items[i].color;
|
int color = files->items[i].color;
|
||||||
/* check is file marked for action */
|
/* check is file marked for action */
|
||||||
bool is_marked = arraylist_search(marked, files->items[i].path, false) != -1;
|
bool is_marked = arraylist_search(marked, files->items[i].path, false) != -1;
|
||||||
|
|
27
config.h
27
config.h
|
@ -1,11 +1,8 @@
|
||||||
|
#define PATH_MAX 4096 /* Max length of path */
|
||||||
/* Settings */
|
/* Settings */
|
||||||
#define PH 1 /* panel height */
|
static int panel_height = 1; /* panel height */
|
||||||
#define JUMP_NUM 14 /* how long ctrl + u/d jump are */
|
static int jump_num = 14; /* Length of ctrl + u/d jump */
|
||||||
#define PATH_MAX 4096 /* max length of the path */
|
static int decimal_place = 1; /* Number of decimal places size can be shown */
|
||||||
#define DECIMAL_PLACES 1 /* how many decimal places show size with */
|
|
||||||
|
|
||||||
/* Size units */
|
|
||||||
static const char* units[] = {"B", "K", "M", "G", "T", "P"};
|
|
||||||
|
|
||||||
/* Set width offset for windows:
|
/* Set width offset for windows:
|
||||||
+-------------%-------------+
|
+-------------%-------------+
|
||||||
|
@ -19,26 +16,26 @@ In COLS:
|
||||||
0 will make them equal (at the center),
|
0 will make them equal (at the center),
|
||||||
15 will make files bigger
|
15 will make files bigger
|
||||||
-15 will make preview bigger */
|
-15 will make preview bigger */
|
||||||
#define WINDOW_OFFSET -30
|
static int window_offset = -30;
|
||||||
|
|
||||||
/* Options */
|
/* Options */
|
||||||
#define SHOW_HIDDEN true /* show hidden files/dotfiles at startup */
|
static int show_hidden = 1; /* Show hidden files/dotfiles at startup */
|
||||||
#define SHOW_DETAILS false /* show file details at startup */
|
static int show_details = 0; /* Show file details at startup */
|
||||||
#define SHOW_ICONS true /* show file icons at startup */
|
static int show_icons = 1; /* Show file icons at startup */
|
||||||
|
|
||||||
/* Calculate directories' sizes RECURSIVELY upon entering
|
/* Calculate directories' sizes RECURSIVELY upon entering
|
||||||
`A` keybind at the startup
|
`A` keybind at the startup
|
||||||
**VERY EXPENSIVE**, **CAN TAKE UP TO A MINUTE IN ROOT** */
|
**VERY EXPENSIVE**, **CAN TAKE UP TO A MINUTE IN ROOT** */
|
||||||
#define DIRS_SIZE false
|
static int dirs_size = 0;
|
||||||
|
|
||||||
/* Default text editor */
|
/* Default text editor */
|
||||||
#define EDITOR "nvim"
|
static const char *editor = "nvim";
|
||||||
|
|
||||||
/* File location to write last directory */
|
/* File location to write last directory */
|
||||||
#define LAST_D "~/.cache/ccc/.ccc_d"
|
static char last_d[PATH_MAX] = "~/.cache/ccc/.ccc_d";
|
||||||
|
|
||||||
/* Will create this directory if doesn't exist! */
|
/* Will create this directory if doesn't exist! */
|
||||||
#define TRASH_DIR "~/.cache/ccc/trash/"
|
static char trash_dir[PATH_MAX] = "~/.cache/ccc/trash/";
|
||||||
|
|
||||||
/* Keybindings */
|
/* Keybindings */
|
||||||
#define CTRLD 0x04
|
#define CTRLD 0x04
|
||||||
|
|
Loading…
Reference in a new issue