mirror of
https://gittea.dev/nova/th.git
synced 2026-05-01 05:55:15 -04:00
Compare commits
3 Commits
3d47e0410f
...
da4c90d243
| Author | SHA1 | Date | |
|---|---|---|---|
| da4c90d243 | |||
| ac50d377ca | |||
| a64982857a |
@@ -1,7 +1,7 @@
|
|||||||
CC := gcc
|
CC := gcc
|
||||||
CFLAGS := -Wall -Wextra -O2 -flto=auto
|
CFLAGS := -Wall -Wextra -O3 -flto=auto
|
||||||
CURSES := $(shell pkg-config --libs ncursesw)
|
CURSES := $(shell pkg-config --libs ncursesw)
|
||||||
CFLAGS_DEBUG := $(CFLAGS) -g
|
CFLAGS_DEBUG := $(CFLAGS) -ggdb
|
||||||
CFLAGS_PROFILE := $(CFLAGS) -pg
|
CFLAGS_PROFILE := $(CFLAGS) -pg
|
||||||
GDB := gdb --tui ./th
|
GDB := gdb --tui ./th
|
||||||
VALGRIND := valgrind --leak-check=full --track-origins=yes --show-leak-kinds=all --log-fd=9 9>>valgrind.log ./th
|
VALGRIND := valgrind --leak-check=full --track-origins=yes --show-leak-kinds=all --log-fd=9 9>>valgrind.log ./th
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ static const mimetype mimetype_default_cmd[] = {
|
|||||||
* gives us "image/gif", thusly if we want to open gif in mpv rather than feh,
|
* gives us "image/gif", thusly if we want to open gif in mpv rather than feh,
|
||||||
* we need to define "gif" before "image" */
|
* we need to define "gif" before "image" */
|
||||||
{ "text", "$EDITOR" },
|
{ "text", "$EDITOR" },
|
||||||
|
{ "avif", "nohup mpv % >/dev/null 2>&1 &" },
|
||||||
{ "gif", "nohup mpv --loop-file=\"inf\" % >/dev/null 2>&1 &" },
|
{ "gif", "nohup mpv --loop-file=\"inf\" % >/dev/null 2>&1 &" },
|
||||||
{ "image", "feh % >/dev/null 2>&1 &" },
|
{ "image", "feh % >/dev/null 2>&1 &" },
|
||||||
{ "video", "nohup mpv % >/dev/null 2>&1 &" },
|
{ "video", "nohup mpv % >/dev/null 2>&1 &" },
|
||||||
@@ -37,6 +38,7 @@ static const extension file_extension_default_cmd[] = {
|
|||||||
{ ".cbr", "mcomix % &"},
|
{ ".cbr", "mcomix % &"},
|
||||||
{ ".json", "$EDITOR"},
|
{ ".json", "$EDITOR"},
|
||||||
{ ".csv", "$EDITOR"},
|
{ ".csv", "$EDITOR"},
|
||||||
|
{ ".blend", "blender-bin-5.0.0"}, /* version number in bin in main repo? yea idc */
|
||||||
};
|
};
|
||||||
static const binding key_binding[] = {
|
static const binding key_binding[] = {
|
||||||
/*key action blackmagic comment*/
|
/*key action blackmagic comment*/
|
||||||
|
|||||||
@@ -25,11 +25,6 @@ int (*order_func)() = sort_natural;
|
|||||||
linked_dir *visited_dirs;
|
linked_dir *visited_dirs;
|
||||||
linked_dir *current_dir;
|
linked_dir *current_dir;
|
||||||
|
|
||||||
unsigned long get_dir_size(char *path);
|
|
||||||
void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_content);
|
|
||||||
void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file *dir_content);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long get_dir_size(char *path){
|
unsigned long get_dir_size(char *path){
|
||||||
DIR *dir = opendir(path);
|
DIR *dir = opendir(path);
|
||||||
@@ -236,47 +231,6 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* shortens the printed file name if it is too long
|
|
||||||
* example input: aaaaaaaa.txt
|
|
||||||
* example output: aaa~.txt
|
|
||||||
* example input: aaaaaaaa.longextension
|
|
||||||
* example output: ~.longe~
|
|
||||||
* if no extension is found, the name will truncate */
|
|
||||||
char *file_name = NULL;
|
|
||||||
unsigned long printable_size = offset_back - (is_selected + offset_front);
|
|
||||||
if (strlen(dir_content[i].file_name) >= printable_size) {
|
|
||||||
char *extension = strrchr(dir_content[i].file_name, '.');
|
|
||||||
if (extension && extension != dir_content[i].file_name) {
|
|
||||||
file_name = malloc(printable_size+1);
|
|
||||||
|
|
||||||
/*if the extension is bigger than the filename this is false */
|
|
||||||
if ((&file_name[printable_size - strlen(extension)] - 2) > file_name) {
|
|
||||||
memcpy(file_name, dir_content[i].file_name, (printable_size - strlen(extension)));
|
|
||||||
memcpy(file_name + (printable_size - strlen(extension))-1, extension, strlen(extension)+1);
|
|
||||||
file_name[printable_size - strlen(extension) - 2] = '~';
|
|
||||||
file_name[printable_size] = '\0';
|
|
||||||
} else {
|
|
||||||
memcpy(file_name + 1, extension, printable_size - 1);
|
|
||||||
file_name[0] = '~';
|
|
||||||
file_name[printable_size-2] = '~';
|
|
||||||
file_name[printable_size-1] = '\0';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
file_name = malloc(printable_size);
|
|
||||||
memcpy(file_name, dir_content[i].file_name, printable_size);
|
|
||||||
file_name[printable_size-2] = '~';
|
|
||||||
file_name[printable_size-1] = '\0';
|
|
||||||
file_name[printable_size] = '\0';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
file_name = malloc(strlen(dir_content[i].file_name)+1);
|
|
||||||
memcpy(file_name, dir_content[i].file_name, strlen(dir_content[i].file_name));
|
|
||||||
file_name[strlen(dir_content[i].file_name)] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mvwaddstr(win, i-offset_vertical, 0, bg);
|
mvwaddstr(win, i-offset_vertical, 0, bg);
|
||||||
if(print_info) {
|
if(print_info) {
|
||||||
#if SETTINGS_LINE_NUMBERS == 2
|
#if SETTINGS_LINE_NUMBERS == 2
|
||||||
@@ -309,7 +263,6 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
|||||||
mvwprintw(win, i-offset_vertical, offset_front-offset_index, "%ld", i);
|
mvwprintw(win, i-offset_vertical, offset_front-offset_index, "%ld", i);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mvwaddnstr(win, i-offset_vertical, offset_front+is_selected, file_name, line_width-offset_front-is_selected-2);
|
|
||||||
|
|
||||||
if (dir_content[i].file_type &= FILE_TYPE_DIR) {
|
if (dir_content[i].file_type &= FILE_TYPE_DIR) {
|
||||||
mvwprintw(win, i-offset_vertical, offset_back, "%ld", dir_content[i].file_size);
|
mvwprintw(win, i-offset_vertical, offset_back, "%ld", dir_content[i].file_size);
|
||||||
@@ -318,15 +271,24 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
|||||||
} else {
|
} else {
|
||||||
mvwprintw(win, i-offset_vertical, offset_back, "%0.2lf %c", printed_size, size_char);
|
mvwprintw(win, i-offset_vertical, offset_back, "%0.2lf %c", printed_size, size_char);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
mvwaddnstr(win, i-offset_vertical, 0, file_name, line_width);
|
char *extension = strrchr(dir_content[i].file_name, '.');
|
||||||
|
|
||||||
|
size_t printable_size = offset_back-offset_front-is_selected-2;
|
||||||
|
|
||||||
|
mvwaddnstr(win, i-offset_vertical, offset_front+is_selected, dir_content[i].file_name, printable_size);
|
||||||
|
if (extension && printable_size <= strlen(dir_content[i].file_name)) {
|
||||||
|
mvwaddnstr(win, i-offset_vertical, offset_back-strlen(extension)-1, extension, strlen(extension));
|
||||||
|
mvwaddnstr(win, i-offset_vertical, offset_back-strlen(extension)-2, "~", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (dir_content[i].status & FILE_STATUS_SELECTED) {
|
if (dir_content[i].status & FILE_STATUS_SELECTED) {
|
||||||
wattroff(win, COLOR_PAIR(8));
|
wattroff(win, COLOR_PAIR(8));
|
||||||
} else {
|
} else {
|
||||||
wattroff(win, COLOR_PAIR(dir_content[i].color_pair));
|
wattroff(win, COLOR_PAIR(dir_content[i].color_pair));
|
||||||
}
|
}
|
||||||
free(file_name);
|
/*free(file_name);*/
|
||||||
|
|
||||||
}
|
}
|
||||||
free(bg);
|
free(bg);
|
||||||
|
|||||||
Reference in New Issue
Block a user