Compare commits
No commits in common. "9d54946b7a7ab4450dd88bebea015324f14bd69e" and "960d322ef97e58c5a833f101f67b754930727f79" have entirely different histories.
9d54946b7a
...
960d322ef9
4 changed files with 40 additions and 38 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 = -Os -march=native -mtune=native -pipe -s -flto -std=c99 -pedantic -Wall -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 $(INCFLAGS)
|
CFLAGS = -O3 -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(int ignore);
|
void handle_sigwinch();
|
||||||
void cleanup(void);
|
void cleanup();
|
||||||
void show_help(void);
|
void show_help();
|
||||||
char *check_trash_dir(void);
|
char *check_trash_dir();
|
||||||
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);
|
void list_files();
|
||||||
void show_file_content(void);
|
void show_file_content();
|
||||||
void edit_file(void);
|
void edit_file();
|
||||||
void toggle_executable(void);
|
void toggle_executable();
|
||||||
char *replace_home(char *str);
|
char *replace_home(char *str);
|
||||||
int write_last_d(void);
|
int write_last_d();
|
||||||
int sort_compare(const void *a, const void *b);
|
int sort_compare(const void *a, const void *b);
|
||||||
void sort_files(void);
|
void sort_files();
|
||||||
char *get_panel_string(char *prompt);
|
char *get_panel_string(char *prompt);
|
||||||
void rename_file(void);
|
void rename_file();
|
||||||
void goto_dir(void);
|
void goto_dir();
|
||||||
void create_dir(void);
|
void create_dir();
|
||||||
void create_file(void);
|
void create_file();
|
||||||
void delete_files(void);
|
void delete_files();
|
||||||
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(void);
|
int read_key();
|
||||||
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(-1);
|
handle_sigwinch();
|
||||||
|
|
||||||
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(int ignore)
|
void handle_sigwinch()
|
||||||
{
|
{
|
||||||
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(int ignore)
|
||||||
list_files();
|
list_files();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup(void)
|
void cleanup()
|
||||||
{
|
{
|
||||||
if (argv_cp != NULL)
|
if (argv_cp != NULL)
|
||||||
free(argv_cp);
|
free(argv_cp);
|
||||||
|
@ -433,7 +433,7 @@ void cleanup(void)
|
||||||
bprintf("\033[2J\033[?1049l\033[?25h");
|
bprintf("\033[2J\033[?1049l\033[?25h");
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_help(void)
|
void show_help()
|
||||||
{
|
{
|
||||||
bprintf("\033[2J");
|
bprintf("\033[2J");
|
||||||
move_cursor(1, 1);
|
move_cursor(1, 1);
|
||||||
|
@ -456,7 +456,7 @@ void show_help(void)
|
||||||
/*
|
/*
|
||||||
* Checks if the trash directory is set and returns it
|
* Checks if the trash directory is set and returns it
|
||||||
*/
|
*/
|
||||||
char *check_trash_dir(void)
|
char *check_trash_dir()
|
||||||
{
|
{
|
||||||
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)
|
void list_files()
|
||||||
{
|
{
|
||||||
long overflow = 0;
|
long overflow = 0;
|
||||||
if (sel_file > rows - 4) {
|
if (sel_file > rows - 4) {
|
||||||
|
@ -779,6 +779,7 @@ void list_files(void)
|
||||||
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) ||
|
||||||
|
@ -807,6 +808,7 @@ void list_files(void)
|
||||||
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 */
|
||||||
|
@ -859,7 +861,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)
|
void show_file_content()
|
||||||
{
|
{
|
||||||
file current_file = files->items[sel_file];
|
file current_file = files->items[sel_file];
|
||||||
|
|
||||||
|
@ -988,7 +990,7 @@ void show_file_content(void)
|
||||||
/*
|
/*
|
||||||
* Opens $EDITOR to edit the file
|
* Opens $EDITOR to edit the file
|
||||||
*/
|
*/
|
||||||
void edit_file(void)
|
void edit_file()
|
||||||
{
|
{
|
||||||
#ifdef EDITOR
|
#ifdef EDITOR
|
||||||
char *editor = EDITOR;
|
char *editor = EDITOR;
|
||||||
|
@ -1011,7 +1013,7 @@ void edit_file(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggle_executable(void)
|
void toggle_executable()
|
||||||
{
|
{
|
||||||
file f = files->items[sel_file];
|
file f = files->items[sel_file];
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
@ -1041,7 +1043,7 @@ char *replace_home(char *str)
|
||||||
return newstr;
|
return newstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_last_d(void)
|
int write_last_d()
|
||||||
{
|
{
|
||||||
#ifdef LAST_D
|
#ifdef LAST_D
|
||||||
char *last_d = estrdup(LAST_D);
|
char *last_d = estrdup(LAST_D);
|
||||||
|
@ -1080,7 +1082,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)
|
void sort_files()
|
||||||
{
|
{
|
||||||
qsort(files->items, files->length, sizeof(file), sort_compare);
|
qsort(files->items, files->length, sizeof(file), sort_compare);
|
||||||
list_files();
|
list_files();
|
||||||
|
@ -1125,7 +1127,7 @@ char *get_panel_string(char *prompt)
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rename_file(void)
|
void rename_file()
|
||||||
{
|
{
|
||||||
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: ");
|
||||||
|
@ -1147,7 +1149,7 @@ void rename_file(void)
|
||||||
free(newfilename);
|
free(newfilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void goto_dir(void)
|
void goto_dir()
|
||||||
{
|
{
|
||||||
char *input = get_panel_string("Goto dir: ");
|
char *input = get_panel_string("Goto dir: ");
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
@ -1165,7 +1167,7 @@ void goto_dir(void)
|
||||||
free(input);
|
free(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_dir(void)
|
void create_dir()
|
||||||
{
|
{
|
||||||
char *input = get_panel_string("New dir: ");
|
char *input = get_panel_string("New dir: ");
|
||||||
char *newfilename = memalloc(PATH_MAX);
|
char *newfilename = memalloc(PATH_MAX);
|
||||||
|
@ -1181,7 +1183,7 @@ void create_dir(void)
|
||||||
free(newfilename);
|
free(newfilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_file(void)
|
void create_file()
|
||||||
{
|
{
|
||||||
char *input = get_panel_string("New file: ");
|
char *input = get_panel_string("New file: ");
|
||||||
FILE *f = fopen(input, "w+");
|
FILE *f = fopen(input, "w+");
|
||||||
|
@ -1191,7 +1193,7 @@ void create_file(void)
|
||||||
free(input);
|
free(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void delete_files(void)
|
void delete_files()
|
||||||
{
|
{
|
||||||
if (marked->length) {
|
if (marked->length) {
|
||||||
char *trash_dir = check_trash_dir();
|
char *trash_dir = check_trash_dir();
|
||||||
|
@ -1236,7 +1238,7 @@ void move_cursor(int row, int col)
|
||||||
bprintf("\033[%d;%dH", row, col);
|
bprintf("\033[%d;%dH", row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_key(void)
|
int read_key()
|
||||||
{
|
{
|
||||||
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)
|
void hashtable_init()
|
||||||
{
|
{
|
||||||
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(void)
|
||||||
hashtable_add(gitignore);
|
hashtable_add(gitignore);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hashtable_print(void)
|
void hashtable_print()
|
||||||
{
|
{
|
||||||
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);
|
void hashtable_init();
|
||||||
void hashtable_print(void);
|
void hashtable_print();
|
||||||
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