Compare commits
2 commits
960d322ef9
...
9d54946b7a
Author | SHA1 | Date | |
---|---|---|---|
9d54946b7a | |||
295997322d |
4 changed files with 38 additions and 40 deletions
2
Makefile
2
Makefile
|
@ -11,7 +11,7 @@ MANDIR = $(PREFIX)/share/man/man1
|
||||||
|
|
||||||
LDFLAGS != pkg-config --libs libsixel
|
LDFLAGS != pkg-config --libs libsixel
|
||||||
INCFLAGS != pkg-config --cflags libsixel
|
INCFLAGS != pkg-config --cflags libsixel
|
||||||
CFLAGS = -O3 -march=native -mtune=native -pipe -s -flto -std=c99 -pedantic -Wall -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 $(INCFLAGS)
|
CFLAGS = -Os -march=native -mtune=native -pipe -s -flto -std=c99 -pedantic -Wall -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 $(INCFLAGS)
|
||||||
|
|
||||||
SRC = ccc.c util.c file.c icons.c
|
SRC = ccc.c util.c file.c icons.c
|
||||||
|
|
||||||
|
|
68
ccc.c
68
ccc.c
|
@ -21,33 +21,33 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
/* functions' definitions */
|
/* functions' definitions */
|
||||||
void handle_sigwinch();
|
void handle_sigwinch(int ignore);
|
||||||
void cleanup();
|
void cleanup(void);
|
||||||
void show_help();
|
void show_help(void);
|
||||||
char *check_trash_dir();
|
char *check_trash_dir(void);
|
||||||
void change_dir(const char *buf, int selection, int ftype);
|
void change_dir(const char *buf, int selection, int ftype);
|
||||||
void mkdir_p(const char *destdir);
|
void mkdir_p(const char *destdir);
|
||||||
void populate_files(const char *path, int ftype, ArrayList **list);
|
void populate_files(const char *path, int ftype, ArrayList **list);
|
||||||
int get_directory_size(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf);
|
int get_directory_size(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf);
|
||||||
void add_file_stat(char *filename, char *path, int ftype);
|
void add_file_stat(char *filename, char *path, int ftype);
|
||||||
char *get_file_mode(mode_t mode);
|
char *get_file_mode(mode_t mode);
|
||||||
void list_files();
|
void list_files(void);
|
||||||
void show_file_content();
|
void show_file_content(void);
|
||||||
void edit_file();
|
void edit_file(void);
|
||||||
void toggle_executable();
|
void toggle_executable(void);
|
||||||
char *replace_home(char *str);
|
char *replace_home(char *str);
|
||||||
int write_last_d();
|
int write_last_d(void);
|
||||||
int sort_compare(const void *a, const void *b);
|
int sort_compare(const void *a, const void *b);
|
||||||
void sort_files();
|
void sort_files(void);
|
||||||
char *get_panel_string(char *prompt);
|
char *get_panel_string(char *prompt);
|
||||||
void rename_file();
|
void rename_file(void);
|
||||||
void goto_dir();
|
void goto_dir(void);
|
||||||
void create_dir();
|
void create_dir(void);
|
||||||
void create_file();
|
void create_file(void);
|
||||||
void delete_files();
|
void delete_files(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 read_key();
|
int read_key(void);
|
||||||
int get_window_size(int *row, int *col);
|
int get_window_size(int *row, int *col);
|
||||||
void bprintf(const char *fmt, ...);
|
void bprintf(const char *fmt, ...);
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ int main(int argc, char **argv)
|
||||||
p_cwd = memalloc(PATH_MAX);
|
p_cwd = memalloc(PATH_MAX);
|
||||||
p_cwd[0] = '\0';
|
p_cwd[0] = '\0';
|
||||||
populate_files(cwd, 0, &files);
|
populate_files(cwd, 0, &files);
|
||||||
handle_sigwinch();
|
handle_sigwinch(-1);
|
||||||
|
|
||||||
if (to_open_file) {
|
if (to_open_file) {
|
||||||
sel_file = arraylist_search(files, argv_cp, true);
|
sel_file = arraylist_search(files, argv_cp, true);
|
||||||
|
@ -407,7 +407,7 @@ int main(int argc, char **argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_sigwinch()
|
void handle_sigwinch(int ignore)
|
||||||
{
|
{
|
||||||
get_window_size(&rows, &cols);
|
get_window_size(&rows, &cols);
|
||||||
if (cols < 80 || rows < 24) {
|
if (cols < 80 || rows < 24) {
|
||||||
|
@ -418,7 +418,7 @@ void handle_sigwinch()
|
||||||
list_files();
|
list_files();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup()
|
void cleanup(void)
|
||||||
{
|
{
|
||||||
if (argv_cp != NULL)
|
if (argv_cp != NULL)
|
||||||
free(argv_cp);
|
free(argv_cp);
|
||||||
|
@ -433,7 +433,7 @@ void cleanup()
|
||||||
bprintf("\033[2J\033[?1049l\033[?25h");
|
bprintf("\033[2J\033[?1049l\033[?25h");
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_help()
|
void show_help(void)
|
||||||
{
|
{
|
||||||
bprintf("\033[2J");
|
bprintf("\033[2J");
|
||||||
move_cursor(1, 1);
|
move_cursor(1, 1);
|
||||||
|
@ -456,7 +456,7 @@ void show_help()
|
||||||
/*
|
/*
|
||||||
* Checks if the trash directory is set and returns it
|
* Checks if the trash directory is set and returns it
|
||||||
*/
|
*/
|
||||||
char *check_trash_dir()
|
char *check_trash_dir(void)
|
||||||
{
|
{
|
||||||
char *path = memalloc(PATH_MAX);
|
char *path = memalloc(PATH_MAX);
|
||||||
|
|
||||||
|
@ -752,7 +752,7 @@ char *get_file_mode(mode_t mode)
|
||||||
/*
|
/*
|
||||||
* Print files in directory window
|
* Print files in directory window
|
||||||
*/
|
*/
|
||||||
void list_files()
|
void list_files(void)
|
||||||
{
|
{
|
||||||
long overflow = 0;
|
long overflow = 0;
|
||||||
if (sel_file > rows - 4) {
|
if (sel_file > rows - 4) {
|
||||||
|
@ -779,7 +779,6 @@ void list_files()
|
||||||
move_cursor(1, 1);
|
move_cursor(1, 1);
|
||||||
bprintf("\033[2J");
|
bprintf("\033[2J");
|
||||||
|
|
||||||
long line_count = 0;
|
|
||||||
for (long i = overflow; i < range; i++) {
|
for (long i = overflow; i < range; i++) {
|
||||||
int is_selected = 0;
|
int is_selected = 0;
|
||||||
if ((overflow == 0 && i == sel_file) ||
|
if ((overflow == 0 && i == sel_file) ||
|
||||||
|
@ -808,7 +807,6 @@ void list_files()
|
||||||
is_selected ? "48" : "38", is_marked ? GREEN : color, line);
|
is_selected ? "48" : "38", is_marked ? GREEN : color, line);
|
||||||
|
|
||||||
free(line);
|
free(line);
|
||||||
line_count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* show file content every time cursor changes */
|
/* show file content every time cursor changes */
|
||||||
|
@ -861,7 +859,7 @@ void print_chunk(const char *str, size_t start, size_t end)
|
||||||
/*
|
/*
|
||||||
* Get file content into buffer and show it to preview window
|
* Get file content into buffer and show it to preview window
|
||||||
*/
|
*/
|
||||||
void show_file_content()
|
void show_file_content(void)
|
||||||
{
|
{
|
||||||
file current_file = files->items[sel_file];
|
file current_file = files->items[sel_file];
|
||||||
|
|
||||||
|
@ -990,7 +988,7 @@ void show_file_content()
|
||||||
/*
|
/*
|
||||||
* Opens $EDITOR to edit the file
|
* Opens $EDITOR to edit the file
|
||||||
*/
|
*/
|
||||||
void edit_file()
|
void edit_file(void)
|
||||||
{
|
{
|
||||||
#ifdef EDITOR
|
#ifdef EDITOR
|
||||||
char *editor = EDITOR;
|
char *editor = EDITOR;
|
||||||
|
@ -1013,7 +1011,7 @@ void edit_file()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggle_executable()
|
void toggle_executable(void)
|
||||||
{
|
{
|
||||||
file f = files->items[sel_file];
|
file f = files->items[sel_file];
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
@ -1043,7 +1041,7 @@ char *replace_home(char *str)
|
||||||
return newstr;
|
return newstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_last_d()
|
int write_last_d(void)
|
||||||
{
|
{
|
||||||
#ifdef LAST_D
|
#ifdef LAST_D
|
||||||
char *last_d = estrdup(LAST_D);
|
char *last_d = estrdup(LAST_D);
|
||||||
|
@ -1082,7 +1080,7 @@ int sort_compare(const void *a, const void *b)
|
||||||
return strcmp(((file *) a)->name, ((file *) b)->name);
|
return strcmp(((file *) a)->name, ((file *) b)->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sort_files()
|
void sort_files(void)
|
||||||
{
|
{
|
||||||
qsort(files->items, files->length, sizeof(file), sort_compare);
|
qsort(files->items, files->length, sizeof(file), sort_compare);
|
||||||
list_files();
|
list_files();
|
||||||
|
@ -1127,7 +1125,7 @@ char *get_panel_string(char *prompt)
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rename_file()
|
void rename_file(void)
|
||||||
{
|
{
|
||||||
char *filename = files->items[sel_file].path;
|
char *filename = files->items[sel_file].path;
|
||||||
char *input = get_panel_string("Rename file: ");
|
char *input = get_panel_string("Rename file: ");
|
||||||
|
@ -1149,7 +1147,7 @@ void rename_file()
|
||||||
free(newfilename);
|
free(newfilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void goto_dir()
|
void goto_dir(void)
|
||||||
{
|
{
|
||||||
char *input = get_panel_string("Goto dir: ");
|
char *input = get_panel_string("Goto dir: ");
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
@ -1167,7 +1165,7 @@ void goto_dir()
|
||||||
free(input);
|
free(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_dir()
|
void create_dir(void)
|
||||||
{
|
{
|
||||||
char *input = get_panel_string("New dir: ");
|
char *input = get_panel_string("New dir: ");
|
||||||
char *newfilename = memalloc(PATH_MAX);
|
char *newfilename = memalloc(PATH_MAX);
|
||||||
|
@ -1183,7 +1181,7 @@ void create_dir()
|
||||||
free(newfilename);
|
free(newfilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_file()
|
void create_file(void)
|
||||||
{
|
{
|
||||||
char *input = get_panel_string("New file: ");
|
char *input = get_panel_string("New file: ");
|
||||||
FILE *f = fopen(input, "w+");
|
FILE *f = fopen(input, "w+");
|
||||||
|
@ -1193,7 +1191,7 @@ void create_file()
|
||||||
free(input);
|
free(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void delete_files()
|
void delete_files(void)
|
||||||
{
|
{
|
||||||
if (marked->length) {
|
if (marked->length) {
|
||||||
char *trash_dir = check_trash_dir();
|
char *trash_dir = check_trash_dir();
|
||||||
|
@ -1238,7 +1236,7 @@ void move_cursor(int row, int col)
|
||||||
bprintf("\033[%d;%dH", row, col);
|
bprintf("\033[%d;%dH", row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_key()
|
int read_key(void)
|
||||||
{
|
{
|
||||||
int nread;
|
int nread;
|
||||||
char c;
|
char c;
|
||||||
|
|
4
icons.c
4
icons.c
|
@ -22,7 +22,7 @@ unsigned int hash(char *name)
|
||||||
return hash_value;
|
return hash_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hashtable_init()
|
void hashtable_init(void)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < TABLE_SIZE; i++)
|
for (int i = 0; i < TABLE_SIZE; i++)
|
||||||
hash_table[i] = NULL;
|
hash_table[i] = NULL;
|
||||||
|
@ -139,7 +139,7 @@ void hashtable_init()
|
||||||
hashtable_add(gitignore);
|
hashtable_add(gitignore);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hashtable_print()
|
void hashtable_print(void)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
|
4
icons.h
4
icons.h
|
@ -12,8 +12,8 @@ typedef struct {
|
||||||
} icon;
|
} icon;
|
||||||
|
|
||||||
unsigned int hash(char *name);
|
unsigned int hash(char *name);
|
||||||
void hashtable_init();
|
void hashtable_init(void);
|
||||||
void hashtable_print();
|
void hashtable_print(void);
|
||||||
bool hashtable_add(icon *p);
|
bool hashtable_add(icon *p);
|
||||||
icon *hashtable_search(char *name);
|
icon *hashtable_search(char *name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue