mirror of
https://gittea.dev/nova/th.git
synced 2025-10-24 20:00:16 -04:00
Compare commits
37 Commits
e0a5871bc2
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4229ebe1d5 | ||
|
|
3da05ce27f | ||
|
|
d5a816ae38 | ||
|
|
cbd479ff4f | ||
|
|
7450280c43 | ||
|
|
326d3f7e52 | ||
|
|
df726e2f32 | ||
|
|
140457e4b7 | ||
|
|
23654741bc | ||
|
|
fa544204ba | ||
|
|
61023ce42e | ||
|
|
3fa16fd8b2 | ||
|
|
ac6d0e8408 | ||
|
|
731bfe722a | ||
|
|
3082fed378 | ||
|
|
23ff0b07ec | ||
|
|
c2d88f4909 | ||
|
|
0b98e8eb68 | ||
|
|
87ae2a5e8f | ||
|
|
f0ad6295f7 | ||
|
|
e979209de3 | ||
|
|
8fade0c4a8 | ||
|
|
333d4d1df6 | ||
|
|
c6763233bf | ||
|
|
7ee16c8f4a | ||
|
|
b32848ad3d | ||
|
|
4d9dc46691 | ||
|
|
8dcf88baea | ||
|
|
8839f737c5 | ||
|
|
36012b1a71 | ||
|
|
4784ec3f64 | ||
|
|
d3e46846cd | ||
|
|
21a11d8be1 | ||
|
|
b46d2da308 | ||
|
|
fe781c2d3c | ||
|
|
fb1af6d2d2 | ||
|
|
14948ba573 |
4
Makefile
4
Makefile
@@ -3,6 +3,7 @@ CFLAGS := -Wall -Wextra -O2 -flto=auto
|
|||||||
CURSES := -lncursesw -ltinfow #utf8 support
|
CURSES := -lncursesw -ltinfow #utf8 support
|
||||||
#CURSES := -lncurses -tinfo #no utf8
|
#CURSES := -lncurses -tinfo #no utf8
|
||||||
CFLAGS_DEBUG := $(CFLAGS) -g
|
CFLAGS_DEBUG := $(CFLAGS) -g
|
||||||
|
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
|
||||||
HELGRIND := valgrind --tool=helgrind --log-fd=9 9>>helgrind.log ./th
|
HELGRIND := valgrind --tool=helgrind --log-fd=9 9>>helgrind.log ./th
|
||||||
@@ -15,6 +16,9 @@ d:
|
|||||||
$(CC) ./main.c -o th -std=c89 $(CFLAGS_DEBUG) $(CURSES)
|
$(CC) ./main.c -o th -std=c89 $(CFLAGS_DEBUG) $(CURSES)
|
||||||
$(GDB)
|
$(GDB)
|
||||||
|
|
||||||
|
p:
|
||||||
|
$(CC) ./main.c -o th -std=c89 $(CFLAGS_PROFILE) $(CURSES)
|
||||||
|
|
||||||
v:
|
v:
|
||||||
$(CC) ./main.c -o th -std=c89 $(CFLAGS_DEBUG) $(CURSES)
|
$(CC) ./main.c -o th -std=c89 $(CFLAGS_DEBUG) $(CURSES)
|
||||||
$(VALGRIND)
|
$(VALGRIND)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ char* concat(const char *s1, const char *s2){
|
|||||||
memcpy(result + len1, s2, len2 + 1);
|
memcpy(result + len1, s2, len2 + 1);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
char* smartstrcasestr(char *haystack, const char *needle){
|
char* smartstrcasestr(const char *haystack, const char *needle){
|
||||||
char smart = 0;
|
char smart = 0;
|
||||||
char *ret;
|
char *ret;
|
||||||
char passes = 0;
|
char passes = 0;
|
||||||
@@ -24,7 +24,7 @@ char* smartstrcasestr(char *haystack, const char *needle){
|
|||||||
needle -= passes;
|
needle -= passes;
|
||||||
if (smart == 0) {
|
if (smart == 0) {
|
||||||
char *needle_case = malloc(strlen(needle)+1);
|
char *needle_case = malloc(strlen(needle)+1);
|
||||||
strcpy(needle_case, needle);
|
memcpy(needle_case, needle, strlen(needle)+1);
|
||||||
passes = 0;
|
passes = 0;
|
||||||
while (*needle_case) {
|
while (*needle_case) {
|
||||||
*needle_case = *needle_case | ' ';
|
*needle_case = *needle_case | ' ';
|
||||||
@@ -34,7 +34,7 @@ char* smartstrcasestr(char *haystack, const char *needle){
|
|||||||
needle_case -= passes;
|
needle_case -= passes;
|
||||||
|
|
||||||
char *haystack_case = malloc(strlen(haystack)+1);
|
char *haystack_case = malloc(strlen(haystack)+1);
|
||||||
strcpy(haystack_case, haystack);
|
memcpy(haystack_case, haystack, strlen(haystack)+1);
|
||||||
passes = 0;
|
passes = 0;
|
||||||
while (*haystack_case) {
|
while (*haystack_case) {
|
||||||
*haystack_case = *haystack_case | ' ';
|
*haystack_case = *haystack_case | ' ';
|
||||||
|
|||||||
@@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
|
|
||||||
char* concat(const char *s1, const char *s2);
|
char* concat(const char *s1, const char *s2);
|
||||||
char* smartstrcasestr(char *haystack, const char *needle);
|
char* smartstrcasestr(const char *haystack, const char *needle);
|
||||||
|
|||||||
2
colors.c
2
colors.c
@@ -108,7 +108,7 @@ void colors_init() {
|
|||||||
if (line[0] == '.') {
|
if (line[0] == '.') {
|
||||||
extension = strtok(line, " ");
|
extension = strtok(line, " ");
|
||||||
colors[i].file_extension = malloc(strlen(extension)+1);
|
colors[i].file_extension = malloc(strlen(extension)+1);
|
||||||
strcpy(colors[i].file_extension, extension);
|
memcpy(colors[i].file_extension, extension, strlen(extension)+1);
|
||||||
|
|
||||||
colors[i].color_pair = i+11;
|
colors[i].color_pair = i+11;
|
||||||
parse_colors(line, &fg, &bg);
|
parse_colors(line, &fg, &bg);
|
||||||
|
|||||||
36
config.h
36
config.h
@@ -1,10 +1,14 @@
|
|||||||
|
#define SETTINGS_LINE_NUMBERS 2 /* 0 is disabled, 1 is enabled, 2 is relative */
|
||||||
|
#define SETTINGS_UEBERZUG_IMAGE_PREVIEW 1 /* 0 is disabled, 1 is enabled, 2 is with caching */
|
||||||
|
#define SETTINGS_RELOAD_DIR_DELTA 10 /* 0 is disabled, time in seconds of how often the directory should be reload */
|
||||||
|
|
||||||
|
/* {{{ */
|
||||||
#ifndef CONFIG_GUARD
|
#ifndef CONFIG_GUARD
|
||||||
#define CONFIG_GUARD
|
#define CONFIG_GUARD
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "sorting.h"
|
#include "sorting.h"
|
||||||
#include "interactions.h"
|
#include "interactions.h"
|
||||||
|
/* }}} */
|
||||||
#define SETTINGS_LINE_NUMBERS 2 /* 0 is disabled, 1 is enabled, 2 is relative */
|
|
||||||
|
|
||||||
static const mimetype mimetype_default_cmd[] = {
|
static const mimetype mimetype_default_cmd[] = {
|
||||||
/* mimetype shell command
|
/* mimetype shell command
|
||||||
@@ -40,9 +44,11 @@ static const binding key_binding[] = {
|
|||||||
/* blackmagic holds a modifier of an action, either as string or as function pointer depending on the action */
|
/* blackmagic holds a modifier of an action, either as string or as function pointer depending on the action */
|
||||||
{ "q", quit_program, NULL, "quit" },
|
{ "q", quit_program, NULL, "quit" },
|
||||||
{ " ", toggle_selection, NULL, "toggle file selection" }, /* on hovered file/directory */
|
{ " ", toggle_selection, NULL, "toggle file selection" }, /* on hovered file/directory */
|
||||||
|
{ "v", select_all, NULL, "select all files in dir" },
|
||||||
{ "e", update, NULL, "rerun all backend" }, /* executes the entire backend and redrawing of the screen */
|
{ "e", update, NULL, "rerun all backend" }, /* executes the entire backend and redrawing of the screen */
|
||||||
{ "B", enter_shell, "$SHELL", "enter $SHELL shell" },
|
{ "B", enter_shell, "$SHELL", "enter $SHELL shell" },
|
||||||
{ "/", search, NULL, "search" },
|
{ "/", search, NULL, "search" },
|
||||||
|
{ ":", jmp_file_index, NULL, "jump to file on input number" },
|
||||||
{ "l", search_next, NULL, "search next" },
|
{ "l", search_next, NULL, "search next" },
|
||||||
{ "L", search_previous, NULL, "search previous" },
|
{ "L", search_previous, NULL, "search previous" },
|
||||||
|
|
||||||
@@ -55,6 +61,8 @@ static const binding key_binding[] = {
|
|||||||
{ "r", rename_hovered, NULL, "rename hovered file" }, /* renames currently hovered file/directory */
|
{ "r", rename_hovered, NULL, "rename hovered file" }, /* renames currently hovered file/directory */
|
||||||
{ "dD", delete, NULL, "delete file" }, /* deletes currently hovered OR selected file/directory
|
{ "dD", delete, NULL, "delete file" }, /* deletes currently hovered OR selected file/directory
|
||||||
* this means that it does not delete the hovered files if files are already selected */
|
* this means that it does not delete the hovered files if files are already selected */
|
||||||
|
{ "yn", yank_text, "name", "yank filename of hovered file" },
|
||||||
|
{ "yp", yank_text, "path", "yank path of hovered file" },
|
||||||
{ "yy", yank_file, "copy", "copy/yank file/directory" },
|
{ "yy", yank_file, "copy", "copy/yank file/directory" },
|
||||||
{ "dd", yank_file, "cut", "cut file/directory" },
|
{ "dd", yank_file, "cut", "cut file/directory" },
|
||||||
{ "pp", paste, NULL, "paste" },
|
{ "pp", paste, NULL, "paste" },
|
||||||
@@ -62,8 +70,11 @@ static const binding key_binding[] = {
|
|||||||
{ "G", jump_bottom, NULL, "jump to last file in dir" },
|
{ "G", jump_bottom, NULL, "jump to last file in dir" },
|
||||||
{ "gg", jump_top, NULL, "jump to first file in dir" },
|
{ "gg", jump_top, NULL, "jump to first file in dir" },
|
||||||
{ "gh", jump_to_dir, "$HOME", "jump to $HOME" },
|
{ "gh", jump_to_dir, "$HOME", "jump to $HOME" },
|
||||||
{ "gs", jump_to_dir, "$START_PATH", "jump to $START_PATH" },
|
{ "gs", jump_to_dir, "$START_PATH", "jump to $START_PATH" }, /* the path you started th in */
|
||||||
{ "gD", jump_to_dir, "$HOME/Downloads", "jump to $HOME/Downloads" },
|
{ "gD", jump_to_dir, "$HOME/Downloads", "jump to $HOME/Downloads" },
|
||||||
|
{ "gC", jump_to_dir, "$HOME/Documents", "jump to $HOME/Documents" },
|
||||||
|
{ "gP", jump_to_dir, "$HOME/Pictures", "jump to $HOME/Pictures" },
|
||||||
|
{ "gM", jump_to_dir, "$HOME/Music", "jump to $HOME/Music" },
|
||||||
{ "gd", jump_to_dir, "/dev", "jump to /dev" },
|
{ "gd", jump_to_dir, "/dev", "jump to /dev" },
|
||||||
{ "ge", jump_to_dir, "/etc", "jump to /etc" },
|
{ "ge", jump_to_dir, "/etc", "jump to /etc" },
|
||||||
{ "gp", jump_to_dir, "/etc/portage", "jump to /etc/portage" },
|
{ "gp", jump_to_dir, "/etc/portage", "jump to /etc/portage" },
|
||||||
@@ -80,11 +91,10 @@ static const binding key_binding[] = {
|
|||||||
{ "uz", cmd_on_selected, "unzip ", "unzip zip" },
|
{ "uz", cmd_on_selected, "unzip ", "unzip zip" },
|
||||||
|
|
||||||
{ "on", order_by, sort_natural, "order natural" },
|
{ "on", order_by, sort_natural, "order natural" },
|
||||||
{ "or", not_implemented, "", "order reverse" },
|
{ "oe", order_by, sort_extension, "order extension" },
|
||||||
{ "oe", not_implemented, "", "order extension" },
|
|
||||||
{ "os", order_by, sort_size, "order size" },
|
{ "os", order_by, sort_size, "order size" },
|
||||||
{ "ot", order_by, sort_type, "order type" },
|
{ "ot", order_by, sort_type, "order type" },
|
||||||
{ "oz", order_by, sort_random, "order random" },
|
{ "or", order_by, sort_random, "order random" },
|
||||||
{ "oa", order_by, sort_alpha, "order alphabetically" },
|
{ "oa", order_by, sort_alpha, "order alphabetically" },
|
||||||
|
|
||||||
{ "mk", makedir, NULL, "create directory" },
|
{ "mk", makedir, NULL, "create directory" },
|
||||||
@@ -93,15 +103,27 @@ static const binding key_binding[] = {
|
|||||||
{ "a", toggle_hidden_files, NULL, "toggle hidden files" },
|
{ "a", toggle_hidden_files, NULL, "toggle hidden files" },
|
||||||
{ "\x7F", toggle_hidden_files, NULL, "toggle hidden files" }, /* backspace key */
|
{ "\x7F", toggle_hidden_files, NULL, "toggle hidden files" }, /* backspace key */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char size_unit[] = { 'B', 'K', 'M', 'G', 'T', 'P' }; /* this defines the maximum size unit, deleting everything except B results in all sizes being displayed in byte */
|
||||||
|
|
||||||
|
static const char clipboard_cmd[] = "xsel -ib --trim"; /* assembles the following shell cmd: echo "hovered_file" | clipboard_cmd */
|
||||||
|
static const char ui_btm_text_storage_left[] = "total free";
|
||||||
|
static const char ui_btm_current_dir_size[] = "sum of dir,";
|
||||||
|
|
||||||
|
/* {{{ */
|
||||||
static const unsigned long binding_count = sizeof(key_binding) / sizeof(binding);
|
static const unsigned long binding_count = sizeof(key_binding) / sizeof(binding);
|
||||||
static const unsigned long mimetype_default_count = sizeof(mimetype_default_cmd) / sizeof(mimetype);
|
static const unsigned long mimetype_default_count = sizeof(mimetype_default_cmd) / sizeof(mimetype);
|
||||||
static const unsigned long file_extension_default_count = sizeof(file_extension_default_cmd) / sizeof(extension);
|
static const unsigned long file_extension_default_count = sizeof(file_extension_default_cmd) / sizeof(extension);
|
||||||
|
static const char size_unit_count = (sizeof(size_unit) / sizeof(size_unit[0])) - 1;
|
||||||
#else
|
#else
|
||||||
|
static const char clipboard_cmd[];
|
||||||
static const mimetype mimetype_default_cmd[];
|
static const mimetype mimetype_default_cmd[];
|
||||||
static const extension file_extension_default_cmd[];
|
static const extension file_extension_default_cmd[];
|
||||||
static const binding key_binding[];
|
static const binding key_binding[];
|
||||||
static const unsigned long binding_count;
|
static const unsigned long binding_count;
|
||||||
static const unsigned long mimetype_default_count;
|
static const unsigned long mimetype_default_count;
|
||||||
static const unsigned long file_extension_default_count;
|
static const unsigned long file_extension_default_count;
|
||||||
|
static const char size_unit[];
|
||||||
|
static const char size_unit_count;
|
||||||
#endif
|
#endif
|
||||||
|
/* }}} */
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#define STATUS_UPDATE_SCREEN_RELOAD_FULL 32
|
#define STATUS_UPDATE_SCREEN_RELOAD_FULL 32
|
||||||
#define STATUS_USER_ROOT 64
|
#define STATUS_USER_ROOT 64
|
||||||
#define STATUS_INPUT_MATCH 128
|
#define STATUS_INPUT_MATCH 128
|
||||||
|
#define STATUS_DELTA_TIME 256
|
||||||
|
|
||||||
#define SETTINGS_HAS_COLOR 1
|
#define SETTINGS_HAS_COLOR 1
|
||||||
|
|
||||||
@@ -55,6 +56,9 @@
|
|||||||
#define YANK_CUT 2
|
#define YANK_CUT 2
|
||||||
#define YANK_COPY 4
|
#define YANK_COPY 4
|
||||||
|
|
||||||
|
#define BTM_WINDOW_HEIGHT_ON_STR_INTERACTION 5
|
||||||
|
#define INPUT_BUFFER_SIZE 255
|
||||||
|
|
||||||
#ifndef STRUCT_GUARD
|
#ifndef STRUCT_GUARD
|
||||||
#define STRUCT_GUARD
|
#define STRUCT_GUARD
|
||||||
/* complex types are good actually */
|
/* complex types are good actually */
|
||||||
|
|||||||
185
dir.c
185
dir.c
@@ -12,6 +12,8 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern file *mid_content;
|
||||||
|
extern unsigned long mid_file_count;
|
||||||
extern unsigned int settings;
|
extern unsigned int settings;
|
||||||
extern unsigned int file_modifiers;
|
extern unsigned int file_modifiers;
|
||||||
extern unsigned int color_count;
|
extern unsigned int color_count;
|
||||||
@@ -26,32 +28,33 @@ linked_dir *current_dir;
|
|||||||
unsigned long get_dir_size(char *path);
|
unsigned long get_dir_size(char *path);
|
||||||
void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_content);
|
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);
|
void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file *dir_content);
|
||||||
char recursive_delete(file current_file);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long get_dir_size(char *path){
|
unsigned long get_dir_size(char *path){
|
||||||
DIR *dir = opendir(path);
|
DIR *dir = opendir(path);
|
||||||
unsigned long entry_count = 0;
|
unsigned long entry_count = 0;
|
||||||
if (dir) {
|
struct dirent *entry;
|
||||||
struct dirent *entry;
|
if (dir && file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) {
|
||||||
while ((entry=readdir(dir))) {
|
while ((entry=readdir(dir))) {
|
||||||
if (entry->d_name[0] != '.' || (file_modifiers & FILE_MODIFIERS_HIDDEN_FILES)) {
|
entry_count++;
|
||||||
|
}
|
||||||
|
/* removes files "." and ".." */
|
||||||
|
entry_count -= 2;
|
||||||
|
} else if (dir) {
|
||||||
|
while ((entry=readdir(dir))) {
|
||||||
|
if (entry->d_name[0] != '.') {
|
||||||
entry_count++;
|
entry_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
if (file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) {
|
|
||||||
/* removes files "." and ".." */
|
|
||||||
entry_count -= 2;
|
|
||||||
}
|
|
||||||
return entry_count;
|
return entry_count;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_content){
|
void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_content){
|
||||||
struct dirent **entry;
|
struct dirent **entry = NULL;
|
||||||
if (file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) { /* print hidden files */
|
if (file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) { /* print hidden files */
|
||||||
scandir(path, &entry, skip_dot, NULL);
|
scandir(path, &entry, skip_dot, NULL);
|
||||||
} else {
|
} else {
|
||||||
@@ -63,25 +66,21 @@ void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_conten
|
|||||||
if (entry[i]->d_name[0] == '.' && !(file_modifiers & FILE_MODIFIERS_HIDDEN_FILES)) {
|
if (entry[i]->d_name[0] == '.' && !(file_modifiers & FILE_MODIFIERS_HIDDEN_FILES)) {
|
||||||
} else {
|
} else {
|
||||||
dir_content[i].file_name = malloc(strlen(entry[i]->d_name)+1);
|
dir_content[i].file_name = malloc(strlen(entry[i]->d_name)+1);
|
||||||
strcpy(dir_content[i].file_name, entry[i]->d_name);
|
memcpy(dir_content[i].file_name, entry[i]->d_name, strlen(entry[i]->d_name) + 1);
|
||||||
dir_content[i].file_name[strlen(entry[i]->d_name)] = '\0';
|
|
||||||
|
|
||||||
|
|
||||||
struct stat *file;
|
struct stat *file;
|
||||||
file = malloc(sizeof(struct stat));
|
file = malloc(sizeof(struct stat));
|
||||||
memset(file, ' ', sizeof(struct stat));
|
|
||||||
|
|
||||||
/* using the full path allows using the same function for all windows */
|
/* using the full path allows using the same function for all windows */
|
||||||
unsigned long path_len = strlen(path);
|
|
||||||
char *full_path = malloc(strlen(path) + strlen(entry[i]->d_name) + 1 + sizeof("/"));
|
char *full_path = malloc(strlen(path) + strlen(entry[i]->d_name) + 1 + sizeof("/"));
|
||||||
memcpy(full_path, path, strlen(path));
|
memcpy(full_path, path, strlen(path));
|
||||||
memcpy(full_path + path_len, "/", sizeof("/"));
|
memcpy(full_path + strlen(path) + sizeof("/") - 1, entry[i]->d_name, strlen(entry[i]->d_name) + 1);
|
||||||
memcpy(full_path + path_len + sizeof("/") - 1, entry[i]->d_name, strlen(entry[i]->d_name) + 1);
|
full_path[strlen(path)] = '/';
|
||||||
|
|
||||||
lstat(full_path, file);
|
lstat(full_path, file);
|
||||||
|
|
||||||
dir_content[i].file_size = file->st_size;
|
dir_content[i].file_size = file->st_size;
|
||||||
dir_content[i].permissions = 1;
|
|
||||||
dir_content[i].permissions = file->st_mode;
|
dir_content[i].permissions = file->st_mode;
|
||||||
|
|
||||||
if (S_ISDIR(file->st_mode)) {
|
if (S_ISDIR(file->st_mode)) {
|
||||||
@@ -89,12 +88,30 @@ void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_conten
|
|||||||
dir_content[i].color_pair = COLOR_DIR;
|
dir_content[i].color_pair = COLOR_DIR;
|
||||||
dir_content[i].file_size = get_dir_size(full_path);
|
dir_content[i].file_size = get_dir_size(full_path);
|
||||||
} else if (S_ISLNK(file->st_mode)) {
|
} else if (S_ISLNK(file->st_mode)) {
|
||||||
dir_content[i].file_type = FILE_TYPE_SYMLINK;
|
stat(full_path, file);
|
||||||
dir_content[i].color_pair = COLOR_SYMLINK;
|
if (S_ISDIR(file->st_mode)) {
|
||||||
dir_content[i].file_size = get_dir_size(full_path);
|
dir_content[i].file_type = FILE_TYPE_DIR | FILE_TYPE_SYMLINK;
|
||||||
|
dir_content[i].color_pair = COLOR_SYMLINK;
|
||||||
|
dir_content[i].file_size = get_dir_size(full_path);
|
||||||
|
} else {
|
||||||
|
dir_content[i].file_type = FILE_TYPE_REGULAR | FILE_TYPE_SYMLINK;
|
||||||
|
dir_content[i].color_pair = COLOR_SYMLINK;
|
||||||
|
}
|
||||||
} else if (file->st_mode & S_IXUSR) {
|
} else if (file->st_mode & S_IXUSR) {
|
||||||
dir_content[i].file_type = FILE_TYPE_EXEC;
|
dir_content[i].file_type = FILE_TYPE_EXEC;
|
||||||
dir_content[i].color_pair = COLOR_EXEC;
|
dir_content[i].color_pair = COLOR_EXEC;
|
||||||
|
} else if (S_ISREG(file->st_mode)) {
|
||||||
|
dir_content[i].file_type = FILE_TYPE_REGULAR;
|
||||||
|
dir_content[i].color_pair = COLOR_REGULAR;
|
||||||
|
unsigned long j = 0;
|
||||||
|
char *extension = strrchr(entry[i]->d_name, '.');
|
||||||
|
if (extension) {
|
||||||
|
for (j = 0; j < color_count; j++) {
|
||||||
|
if (!strncmp(colors[j].file_extension, extension, strlen(colors[j].file_extension))) {
|
||||||
|
dir_content[i].color_pair = colors[j].color_pair;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (S_ISBLK(file->st_mode)) {
|
} else if (S_ISBLK(file->st_mode)) {
|
||||||
dir_content[i].file_type = FILE_TYPE_BLOCK;
|
dir_content[i].file_type = FILE_TYPE_BLOCK;
|
||||||
dir_content[i].color_pair = COLOR_BLOCK;
|
dir_content[i].color_pair = COLOR_BLOCK;
|
||||||
@@ -106,19 +123,6 @@ void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_conten
|
|||||||
} else if (S_ISSOCK(file->st_mode)) {
|
} else if (S_ISSOCK(file->st_mode)) {
|
||||||
dir_content[i].file_type = FILE_TYPE_SOCK;
|
dir_content[i].file_type = FILE_TYPE_SOCK;
|
||||||
dir_content[i].color_pair = COLOR_SOCK;
|
dir_content[i].color_pair = COLOR_SOCK;
|
||||||
} else if (S_ISREG(file->st_mode)) {
|
|
||||||
dir_content[i].file_type = FILE_TYPE_REGULAR;
|
|
||||||
dir_content[i].color_pair = COLOR_REGULAR;
|
|
||||||
unsigned long j = 0;
|
|
||||||
char *extension = strrchr(entry[i]->d_name, '.');
|
|
||||||
if (extension) {
|
|
||||||
for (j = 0; j < color_count; j++) {
|
|
||||||
if (!strcmp(colors[j].file_extension, extension)) {
|
|
||||||
dir_content[i].color_pair = colors[j].color_pair;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
dir_content[i].file_type = COLOR_REGULAR;
|
dir_content[i].file_type = COLOR_REGULAR;
|
||||||
dir_content[i].color_pair = COLOR_REGULAR;
|
dir_content[i].color_pair = COLOR_REGULAR;
|
||||||
@@ -126,7 +130,7 @@ void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_conten
|
|||||||
char *extension = strrchr(entry[i]->d_name, '.');
|
char *extension = strrchr(entry[i]->d_name, '.');
|
||||||
if (extension) {
|
if (extension) {
|
||||||
for (j = 0; j < color_count; j++) {
|
for (j = 0; j < color_count; j++) {
|
||||||
if (!strcmp(colors[j].file_extension, extension)) {
|
if (!strncmp(colors[j].file_extension, extension, strlen(colors[j].file_extension))) {
|
||||||
dir_content[i].color_pair = colors[j].color_pair;
|
dir_content[i].color_pair = colors[j].color_pair;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +147,10 @@ void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_conten
|
|||||||
for (i = 0; i < *dir_file_count; i++) {
|
for (i = 0; i < *dir_file_count; i++) {
|
||||||
free(entry[i]);
|
free(entry[i]);
|
||||||
}
|
}
|
||||||
free(entry);
|
if (entry != NULL) {
|
||||||
|
free(entry);
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +167,6 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
|||||||
float printed_size = 0;
|
float printed_size = 0;
|
||||||
char size_char = ' ';
|
char size_char = ' ';
|
||||||
char is_selected = 0;
|
char is_selected = 0;
|
||||||
static const char sizes[6] = { 'B', 'K', 'M', 'G', 'T', 'P' };
|
|
||||||
|
|
||||||
unsigned long offset_vertical = 0;
|
unsigned long offset_vertical = 0;
|
||||||
unsigned long offset_back = 0;
|
unsigned long offset_back = 0;
|
||||||
@@ -189,64 +195,33 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
|||||||
offset_vertical = selected_file_current - (terminal_height/3)*2;
|
offset_vertical = selected_file_current - (terminal_height/3)*2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
offset_front = 0;
|
||||||
}
|
}
|
||||||
for (i = offset_vertical; i < *dir_file_count && i < (terminal_height + offset_vertical); i++) {
|
for (i = offset_vertical; i < *dir_file_count && i < (terminal_height + offset_vertical); i++) {
|
||||||
|
|
||||||
/* shortens the printed file name if it is too long
|
|
||||||
* example input: aaaaaaaa.txt
|
|
||||||
* example output: aaa~.txt
|
|
||||||
* if no extension is found, the name will truncate */
|
|
||||||
char *file_name;
|
|
||||||
unsigned long file_name_width = strlen(dir_content[i].file_name);
|
|
||||||
if ((file_name_width + offset_front + is_selected) > offset_back - 1) {
|
|
||||||
char *extension = strrchr(dir_content[i].file_name, '.');
|
|
||||||
if (extension) {
|
|
||||||
int char_offset = (file_name_width + offset_front + is_selected) - (offset_back - 1) ;
|
|
||||||
if ((file_name_width - char_offset - strlen(extension) - 1) > 1) {
|
|
||||||
file_name = malloc(file_name_width - char_offset + 1);
|
|
||||||
memcpy(file_name, dir_content[i].file_name, file_name_width - char_offset);
|
|
||||||
memcpy(file_name + (file_name_width - char_offset - strlen(extension)), extension, strlen(extension));
|
|
||||||
file_name[file_name_width - char_offset - strlen(extension) - 1] = '~';
|
|
||||||
file_name[file_name_width - char_offset] = '\0';
|
|
||||||
} else {
|
|
||||||
file_name = malloc(strlen(extension)+1);
|
|
||||||
file_name[0] = '~';
|
|
||||||
memcpy(file_name+1, extension, strlen(extension));
|
|
||||||
file_name[strlen(extension)] = '\0';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
file_name = malloc(file_name_width+1);
|
|
||||||
memcpy(file_name, dir_content[i].file_name, file_name_width);
|
|
||||||
file_name[file_name_width] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
file_name = malloc(file_name_width+1);
|
|
||||||
memcpy(file_name, dir_content[i].file_name, file_name_width);
|
|
||||||
file_name[file_name_width] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (print_info) {
|
if (print_info) {
|
||||||
file_size = dir_content[i].file_size;
|
file_size = dir_content[i].file_size;
|
||||||
char size_index = 0;
|
char size_index = -1;
|
||||||
while (file_size > 1) {
|
|
||||||
|
do {
|
||||||
printed_size=file_size;
|
printed_size=file_size;
|
||||||
file_size /= 1024;
|
file_size /= 1024;
|
||||||
size_index++;
|
size_index++;
|
||||||
if (size_index >= 6) {
|
} while (file_size > 1 && size_index < size_unit_count);
|
||||||
break;
|
size_char = size_unit[(unsigned)size_index];
|
||||||
}
|
|
||||||
}
|
if (dir_content[i].file_type &= FILE_TYPE_DIR) {
|
||||||
size_char = sizes[size_index-1];
|
|
||||||
if (dir_content[i].file_type == FILE_TYPE_DIR || dir_content[i].file_type == FILE_TYPE_SYMLINK) {
|
|
||||||
offset_back = line_width - (snprintf(NULL,0,"%ld", dir_content[i].file_size) + 1);
|
offset_back = line_width - (snprintf(NULL,0,"%ld", dir_content[i].file_size) + 1);
|
||||||
} else if (size_char =='B') {
|
} else if (size_char =='B') {
|
||||||
offset_back = line_width - (snprintf(NULL,0,"%0.0lf %c", printed_size, size_char) + 1);
|
offset_back = line_width - (snprintf(NULL,0,"%0.0lf %c", printed_size, size_char) + 1);
|
||||||
} else {
|
} else {
|
||||||
offset_back = line_width - (snprintf(NULL,0,"%0.2lf %c", printed_size, size_char) + 1);
|
offset_back = line_width - (snprintf(NULL,0,"%0.2lf %c", printed_size, size_char) + 1);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
offset_back = line_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dir_content[i].status & FILE_STATUS_SELECTED) {
|
if (dir_content[i].status & FILE_STATUS_SELECTED) {
|
||||||
@@ -265,6 +240,37 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
|||||||
wattroff(win, A_REVERSE);
|
wattroff(win, A_REVERSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* shortens the printed file name if it is too long
|
||||||
|
* example input: aaaaaaaa.txt
|
||||||
|
* example output: aaa~.txt
|
||||||
|
* 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);
|
||||||
|
printable_size -= strlen(extension);
|
||||||
|
|
||||||
|
memcpy(file_name, dir_content[i].file_name, printable_size);
|
||||||
|
memcpy(file_name + printable_size-1, extension, strlen(extension));
|
||||||
|
file_name[printable_size + strlen(extension)-1] = '\0';
|
||||||
|
file_name[printable_size - 2] = '~';
|
||||||
|
} else {
|
||||||
|
file_name = malloc(printable_size-1);
|
||||||
|
memcpy(file_name, dir_content[i].file_name, printable_size);
|
||||||
|
file_name[printable_size-2] = '~';
|
||||||
|
file_name[printable_size-1] = '\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)+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
@@ -298,9 +304,8 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
mvwaddnstr(win, i-offset_vertical, offset_front+is_selected, file_name, line_width-offset_front-is_selected-2);
|
mvwaddnstr(win, i-offset_vertical, offset_front+is_selected, file_name, line_width-offset_front-is_selected-2);
|
||||||
free(file_name);
|
|
||||||
|
|
||||||
if (dir_content[i].file_type == FILE_TYPE_DIR || dir_content[i].file_type == FILE_TYPE_SYMLINK) {
|
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);
|
||||||
}else if (size_char =='B') {
|
}else if (size_char =='B') {
|
||||||
mvwprintw(win, i-offset_vertical, offset_back, "%0.0lf %c", printed_size, size_char);
|
mvwprintw(win, i-offset_vertical, offset_back, "%0.0lf %c", printed_size, size_char);
|
||||||
@@ -309,9 +314,15 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mvwaddnstr(win, i-offset_vertical, 0, file_name, line_width);
|
mvwaddnstr(win, i-offset_vertical, 0, file_name, line_width);
|
||||||
free(file_name);
|
|
||||||
}
|
}
|
||||||
|
if (file_name != NULL) {
|
||||||
|
/* sometimes NULL remains, need to do deeper analysis soon */
|
||||||
|
free(file_name);
|
||||||
|
} else {
|
||||||
|
printf("file_name remains NULL on %s, if this happens consistent on the same file, please inform me", dir_content[i].file_name);
|
||||||
|
volatile static int debug_print_dir;
|
||||||
|
debug_print_dir++;
|
||||||
|
}
|
||||||
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 {
|
||||||
@@ -380,8 +391,8 @@ void dir_init(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char recursive_delete(file current_file){
|
void recursive_delete(file current_file){
|
||||||
if (current_file.file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR)) {
|
if (current_file.file_type & FILE_TYPE_DIR) {
|
||||||
unsigned int file_modifiers_tmp = file_modifiers;
|
unsigned int file_modifiers_tmp = file_modifiers;
|
||||||
file_modifiers |= FILE_MODIFIERS_HIDDEN_FILES;
|
file_modifiers |= FILE_MODIFIERS_HIDDEN_FILES;
|
||||||
unsigned long current_file_count = get_dir_size(current_file.file_name);
|
unsigned long current_file_count = get_dir_size(current_file.file_name);
|
||||||
@@ -389,14 +400,18 @@ char recursive_delete(file current_file){
|
|||||||
file *current_dir = malloc(current_file_count * sizeof(file));
|
file *current_dir = malloc(current_file_count * sizeof(file));
|
||||||
memset(current_dir, '\0', current_file_count * sizeof(file));
|
memset(current_dir, '\0', current_file_count * sizeof(file));
|
||||||
get_dir_content(current_file.file_name, ¤t_file_count, current_dir);
|
get_dir_content(current_file.file_name, ¤t_file_count, current_dir);
|
||||||
chdir(current_file.file_name);
|
if (chdir(current_file.file_name) != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
for (i = 0; i < current_file_count; i++) {
|
for (i = 0; i < current_file_count; i++) {
|
||||||
recursive_delete(current_dir[i]);
|
recursive_delete(current_dir[i]);
|
||||||
free(current_dir[i].file_name);
|
free(current_dir[i].file_name);
|
||||||
}
|
}
|
||||||
free(current_dir);
|
free(current_dir);
|
||||||
chdir("..");
|
if (chdir("..") != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
remove(current_file.file_name);
|
remove(current_file.file_name);
|
||||||
file_modifiers = file_modifiers_tmp;
|
file_modifiers = file_modifiers_tmp;
|
||||||
|
|||||||
2
dir.h
2
dir.h
@@ -10,4 +10,4 @@ char update_selected_file();
|
|||||||
void dir_set_selected_file_current(unsigned long selected_file_current);
|
void dir_set_selected_file_current(unsigned long selected_file_current);
|
||||||
unsigned long dir_get_selected_file_current();
|
unsigned long dir_get_selected_file_current();
|
||||||
void dir_init();
|
void dir_init();
|
||||||
char recursive_delete(file current_file);
|
void recursive_delete(file current_file);
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "backend.h"
|
|
||||||
|
|
||||||
|
#include "backend.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||||
static FILE *ueberzug = NULL;
|
static FILE *ueberzug = NULL;
|
||||||
|
#endif
|
||||||
extern unsigned int terminal_height;
|
extern unsigned int terminal_height;
|
||||||
extern unsigned int terminal_width;
|
extern unsigned int terminal_width;
|
||||||
char previewd;
|
char previewd;
|
||||||
@@ -43,14 +48,19 @@ char* preview_file(char *file_name, unsigned long file_size){
|
|||||||
|
|
||||||
|
|
||||||
char *mime = get_mimetype(file_name);
|
char *mime = get_mimetype(file_name);
|
||||||
|
|
||||||
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||||
images_clear();
|
images_clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (strstr(mime, "text")) {
|
if (strstr(mime, "text")) {
|
||||||
file_buffer = text(file_name, &file_size);
|
file_buffer = text(file_name, &file_size);
|
||||||
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||||
} else if (strstr(mime, "image")) {
|
} else if (strstr(mime, "image")) {
|
||||||
file_buffer = generic(file_name);
|
file_buffer = generic(file_name);
|
||||||
images_print(file_name);
|
images_print(file_name);
|
||||||
previewd = 1;
|
previewd = 1;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
file_buffer = generic(file_name);
|
file_buffer = generic(file_name);
|
||||||
}
|
}
|
||||||
@@ -74,28 +84,6 @@ char* text(char *path, unsigned long *file_size){
|
|||||||
return "failed reading file";
|
return "failed reading file";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void images_clear() {
|
|
||||||
if (previewd == 1) {
|
|
||||||
fprintf(ueberzug, "{\"action\": \"remove\", \
|
|
||||||
\"identifier\": \"preview\"}\n");
|
|
||||||
fflush(ueberzug);
|
|
||||||
previewd = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void images_print(char *file_name) {
|
|
||||||
char *path=getcwd(NULL, 0);
|
|
||||||
fprintf(ueberzug, "{\"action\": \"remove\", \
|
|
||||||
\"identifier\": \"preview\"}\n");
|
|
||||||
fprintf(ueberzug, "{\"action\":\"add\", \
|
|
||||||
\"identifier\":\"preview\", \
|
|
||||||
\"max_height\":%d, \
|
|
||||||
\"max_width\":%d, \
|
|
||||||
\"y\":0, \
|
|
||||||
\"x\":%d, \
|
|
||||||
\"path\":\"%s/%s\"}\n", terminal_height, terminal_width/2, terminal_width/2, path, file_name);
|
|
||||||
fflush(ueberzug);
|
|
||||||
free(path);
|
|
||||||
}
|
|
||||||
char* generic(char *path){
|
char* generic(char *path){
|
||||||
char *cmd = concat("file ./\"", path);
|
char *cmd = concat("file ./\"", path);
|
||||||
cmd = concat(cmd, "\"");
|
cmd = concat(cmd, "\"");
|
||||||
@@ -111,6 +99,38 @@ char* generic(char *path){
|
|||||||
return "failed executing shell command \"file\"";
|
return "failed executing shell command \"file\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ueberzug_init(){
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||||
ueberzug = popen("ueberzug layer -s ", "w");
|
void images_clear(){
|
||||||
|
if (previewd == 1) {
|
||||||
|
fprintf(ueberzug, "{\"action\": \"remove\", \
|
||||||
|
\"identifier\": \"preview\"}\n");
|
||||||
|
fflush(ueberzug);
|
||||||
|
previewd = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
void images_print(char *file_name){
|
||||||
|
char *path=getcwd(NULL, 0);
|
||||||
|
|
||||||
|
fprintf(ueberzug, "{\"action\":\"add\", \
|
||||||
|
\"identifier\":\"preview\", \
|
||||||
|
\"max_height\":%d, \
|
||||||
|
\"max_width\":%d, \
|
||||||
|
\"y\":0, \
|
||||||
|
\"x\":%d, \
|
||||||
|
\"path\":\"%s/%s\"}\n", terminal_height, terminal_width/2, terminal_width/2, path, file_name);
|
||||||
|
fflush(ueberzug);
|
||||||
|
free(path);
|
||||||
|
}
|
||||||
|
void ueberzug_init(){
|
||||||
|
|
||||||
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW == 2
|
||||||
|
ueberzug = popen("ueberzug layer -s ", "w");
|
||||||
|
#elif SETTINGS_UEBERZUG_IMAGE_PREVIEW == 1
|
||||||
|
ueberzug = popen("ueberzug layer -s --no-cache ", "w");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void ueberzug_close(){
|
||||||
|
images_clear();
|
||||||
|
pclose(ueberzug);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
#ifndef PREVIEW_GUARD
|
#ifndef PREVIEW_GUARD
|
||||||
#define PREVIEW_GUARD
|
#define PREVIEW_GUARD
|
||||||
#include "file_previews.c"
|
#include "file_previews.c"
|
||||||
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char* preview_file(char *file_name, unsigned long file_size);
|
char* preview_file(char *file_name, unsigned long file_size);
|
||||||
char* get_mimetype(char *path);
|
char* get_mimetype(char *path);
|
||||||
void images_clear();
|
void images_clear();
|
||||||
void ueberzug_init();
|
void ueberzug_init();
|
||||||
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||||
|
void ueberzug_close();
|
||||||
|
#endif
|
||||||
|
|||||||
422
interactions.c
422
interactions.c
@@ -1,7 +1,9 @@
|
|||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "file_previews.h"
|
#include "file_previews.h"
|
||||||
#include "backend.h"
|
#include "backend.h"
|
||||||
@@ -17,6 +19,7 @@ extern unsigned int file_modifiers;
|
|||||||
extern pthread_mutex_t mutex_selection;
|
extern pthread_mutex_t mutex_selection;
|
||||||
extern pthread_mutex_t mutex_rgt;
|
extern pthread_mutex_t mutex_rgt;
|
||||||
extern pthread_mutex_t mutex_mid;
|
extern pthread_mutex_t mutex_mid;
|
||||||
|
extern pthread_mutex_t mutex_btm;
|
||||||
extern pthread_cond_t cond_rgt;
|
extern pthread_cond_t cond_rgt;
|
||||||
extern file *mid_content;
|
extern file *mid_content;
|
||||||
extern file *lft_content;
|
extern file *lft_content;
|
||||||
@@ -35,15 +38,16 @@ extern unsigned int status;
|
|||||||
extern char *start_path;
|
extern char *start_path;
|
||||||
extern char *input;
|
extern char *input;
|
||||||
|
|
||||||
char search_buffer[255];
|
extern time_t *seed;
|
||||||
|
|
||||||
|
char search_buffer[INPUT_BUFFER_SIZE];
|
||||||
unsigned int timeout_time = 0;
|
unsigned int timeout_time = 0;
|
||||||
unsigned int input_pass;
|
unsigned int input_pass;
|
||||||
int parsed_input_number;
|
unsigned long parsed_input_number;
|
||||||
yank yank_files = { 0 };
|
yank yank_files = { 0 };
|
||||||
|
|
||||||
int read_string(WINDOW *win, int y, int x, char *str);
|
|
||||||
int strcmp_offset(char *in0, char *in1, char offset);
|
|
||||||
extern void render_pass();
|
extern void render_pass();
|
||||||
|
extern void window_btm(WINDOW *win, char force_render);
|
||||||
extern int (*order_func)();
|
extern int (*order_func)();
|
||||||
|
|
||||||
|
|
||||||
@@ -66,19 +70,21 @@ void user_interactions() {
|
|||||||
|
|
||||||
ch = getch();
|
ch = getch();
|
||||||
if(ch != ERR) {
|
if(ch != ERR) {
|
||||||
timeout(1); /* blocking timeout of getch() */
|
timeout(10); /* blocking timeout of getch() */
|
||||||
input[input_pass] = ch;
|
input[input_pass] = ch;
|
||||||
mvaddstr(terminal_height-1, (terminal_width/3)*2, input);
|
mvaddstr(terminal_height-1, (terminal_width/3)*2, input);
|
||||||
input_pass++;
|
input_pass++;
|
||||||
if (ch == 27) { /* esc key */
|
if (ch == 27) { /* esc key */
|
||||||
memset(input, ' ', terminal_width);
|
memset(input, ' ', terminal_width);
|
||||||
mvaddstr(terminal_height-1, (terminal_width/3)*2, input);
|
mvaddstr(terminal_height-1, (terminal_width/3)*2, input);
|
||||||
memset(input, 0, 255);
|
memset(input, 0, INPUT_BUFFER_SIZE);
|
||||||
input_pass = 0;
|
input_pass = 0;
|
||||||
timeout(100); /* blocking timeout of getch() */
|
timeout(100); /* blocking timeout of getch() */
|
||||||
}
|
}
|
||||||
binding_pass = 0;
|
binding_pass = 0;
|
||||||
status |= STATUS_UPDATE_SCREEN_0;
|
status |= STATUS_UPDATE_SCREEN_0;
|
||||||
|
} else {
|
||||||
|
timeout(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -115,11 +121,11 @@ void user_interactions() {
|
|||||||
}
|
}
|
||||||
if (status & STATUS_INPUT_MATCH) {
|
if (status & STATUS_INPUT_MATCH) {
|
||||||
attron(A_UNDERLINE);
|
attron(A_UNDERLINE);
|
||||||
mvaddstr(terminal_height-binding_matches-2, 0, "input\tcommand\t\t");
|
mvwprintw(stdscr, terminal_height-binding_matches-2, 0, "input\tcommand\t\t");
|
||||||
attroff(A_UNDERLINE);
|
attroff(A_UNDERLINE);
|
||||||
status &= ~STATUS_INPUT_MATCH;
|
status &= ~STATUS_INPUT_MATCH;
|
||||||
} else if (number_length != strlen(input)) {
|
} else if (number_length != strlen(input)) {
|
||||||
memset(input, 0, 255);
|
memset(input, 0, INPUT_BUFFER_SIZE);
|
||||||
input_pass = 0;
|
input_pass = 0;
|
||||||
binding_pass = 0;
|
binding_pass = 0;
|
||||||
number_length = 0;
|
number_length = 0;
|
||||||
@@ -163,36 +169,25 @@ int read_string(WINDOW *win, int y, int x, char *str){
|
|||||||
}
|
}
|
||||||
str[pass] = '\0';
|
str[pass] = '\0';
|
||||||
|
|
||||||
timeout(10);
|
timeout(100);
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
int strcmp_offset(char *in0, char *in1, char offset){
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
while (in0[i] != '\0' && in1[i] != '\0') {
|
|
||||||
if (in0[i+offset] != in1[i]) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
in1++;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
void quit_program(){
|
void quit_program(){
|
||||||
status = STATUS_QUIT_PROGRAM;
|
status = STATUS_QUIT_PROGRAM;
|
||||||
}
|
}
|
||||||
void toggle_selection(){
|
void select_all(){
|
||||||
pthread_mutex_lock(&mutex_selection);
|
pthread_mutex_lock(&mutex_selection);
|
||||||
pthread_mutex_lock(&mutex_mid);
|
pthread_mutex_lock(&mutex_mid);
|
||||||
mid_content[selected_file_current].status ^= FILE_STATUS_SELECTED;
|
unsigned long i;
|
||||||
status |= (STATUS_UPDATE_SCREEN_MASK);
|
for(i = 0; i < mid_file_count; i++) {
|
||||||
|
mid_content[i].status ^= FILE_STATUS_SELECTED;
|
||||||
|
}
|
||||||
pthread_mutex_unlock(&mutex_mid);
|
pthread_mutex_unlock(&mutex_mid);
|
||||||
pthread_mutex_unlock(&mutex_selection);
|
pthread_mutex_unlock(&mutex_selection);
|
||||||
}
|
}
|
||||||
void move_down(int passes){
|
void move_down(unsigned long passes){
|
||||||
pthread_mutex_lock(&mutex_selection);
|
pthread_mutex_lock(&mutex_selection);
|
||||||
if (passes == 0) {
|
if (passes == 0) {
|
||||||
passes++;
|
passes++;
|
||||||
@@ -205,7 +200,7 @@ void move_down(int passes){
|
|||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_0);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_0);
|
||||||
pthread_mutex_unlock(&mutex_selection);
|
pthread_mutex_unlock(&mutex_selection);
|
||||||
}
|
}
|
||||||
void move_up(int passes){
|
void move_up(unsigned long passes){
|
||||||
pthread_mutex_lock(&mutex_selection);
|
pthread_mutex_lock(&mutex_selection);
|
||||||
if (passes == 0) {
|
if (passes == 0) {
|
||||||
passes++;
|
passes++;
|
||||||
@@ -222,11 +217,11 @@ void move_up(int passes){
|
|||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK);
|
||||||
pthread_mutex_unlock(&mutex_selection);
|
pthread_mutex_unlock(&mutex_selection);
|
||||||
}
|
}
|
||||||
void move_left(int passes){
|
void move_left(unsigned long passes){
|
||||||
if (passes == 0) {
|
if (passes == 0) {
|
||||||
passes++;
|
passes++;
|
||||||
}
|
}
|
||||||
int i;
|
unsigned long i;
|
||||||
for (i = 0; i < passes; i++) {
|
for (i = 0; i < passes; i++) {
|
||||||
if (chdir("..") != 0) {
|
if (chdir("..") != 0) {
|
||||||
/* TODO(2025-07-09T00:30:05) fix */
|
/* TODO(2025-07-09T00:30:05) fix */
|
||||||
@@ -241,7 +236,7 @@ void move_right(){
|
|||||||
if (mid_content->file_name[0] == '\0') {
|
if (mid_content->file_name[0] == '\0') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mid_content[selected_file_current].file_type == FILE_TYPE_DIR || mid_content[selected_file_current].file_type == FILE_TYPE_SYMLINK) {
|
if ((mid_content[selected_file_current].file_type & FILE_TYPE_DIR) == FILE_TYPE_DIR) {
|
||||||
if (chdir(mid_content[selected_file_current].file_name) != 0) {
|
if (chdir(mid_content[selected_file_current].file_name) != 0) {
|
||||||
FAIL("move_right", "unhandled error of chdir");
|
FAIL("move_right", "unhandled error of chdir");
|
||||||
} else {
|
} else {
|
||||||
@@ -252,20 +247,22 @@ void move_right(){
|
|||||||
char match = 0;
|
char match = 0;
|
||||||
char *mime = get_mimetype(mid_content[selected_file_current].file_name);
|
char *mime = get_mimetype(mid_content[selected_file_current].file_name);
|
||||||
char *extension = strrchr(mid_content[selected_file_current].file_name, '.');
|
char *extension = strrchr(mid_content[selected_file_current].file_name, '.');
|
||||||
for (i = 0; i < file_extension_default_count; i++) {
|
if (extension != NULL) {
|
||||||
if (strstr(extension, file_extension_default_cmd[i].file_extension)) {
|
for (i = 0; i < file_extension_default_count; i++) {
|
||||||
char *cmd = concat(file_extension_default_cmd[i].command, " ./\"");
|
if (strstr(extension, file_extension_default_cmd[i].file_extension)) {
|
||||||
cmd = concat(cmd, mid_content[selected_file_current].file_name);
|
char *cmd = concat(file_extension_default_cmd[i].command, " ./\"");
|
||||||
cmd = concat(cmd, "\"");
|
cmd = concat(cmd, mid_content[selected_file_current].file_name);
|
||||||
|
cmd = concat(cmd, "\"");
|
||||||
|
|
||||||
|
|
||||||
if (system(cmd) == -1) {
|
if (system(cmd) == -1) {
|
||||||
/*do nothing*/
|
/*do nothing*/
|
||||||
|
}
|
||||||
|
curs_set(1); /*for some reason, 1 here turns it invisible once again */
|
||||||
|
match = 1;
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
curs_set(1); /*for some reason, 1 here turns it invisible once again */
|
|
||||||
match = 1;
|
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (match == 0) {
|
if (match == 0) {
|
||||||
@@ -275,9 +272,7 @@ void move_right(){
|
|||||||
char *cmd = concat(mimetype_default_cmd[i].command, " ./\"");
|
char *cmd = concat(mimetype_default_cmd[i].command, " ./\"");
|
||||||
cmd = concat(cmd, mid_content[selected_file_current].file_name);
|
cmd = concat(cmd, mid_content[selected_file_current].file_name);
|
||||||
cmd = concat(cmd, "\"");
|
cmd = concat(cmd, "\"");
|
||||||
btm_buffer = malloc(strlen(cmd));
|
|
||||||
|
|
||||||
strcpy(btm_buffer, cmd-1);
|
|
||||||
|
|
||||||
|
|
||||||
if (system(cmd) == -1) {
|
if (system(cmd) == -1) {
|
||||||
@@ -299,6 +294,15 @@ void toggle_hidden_files(){
|
|||||||
file_modifiers ^= FILE_MODIFIERS_HIDDEN_FILES;
|
file_modifiers ^= FILE_MODIFIERS_HIDDEN_FILES;
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
||||||
}
|
}
|
||||||
|
void toggle_selection(){
|
||||||
|
pthread_mutex_lock(&mutex_selection);
|
||||||
|
pthread_mutex_lock(&mutex_mid);
|
||||||
|
mid_content[selected_file_current].status ^= FILE_STATUS_SELECTED;
|
||||||
|
status |= (STATUS_UPDATE_SCREEN_MASK);
|
||||||
|
pthread_mutex_unlock(&mutex_mid);
|
||||||
|
pthread_mutex_unlock(&mutex_selection);
|
||||||
|
move_down(1);
|
||||||
|
}
|
||||||
void jump_bottom(){
|
void jump_bottom(){
|
||||||
pthread_mutex_lock(&mutex_selection);
|
pthread_mutex_lock(&mutex_selection);
|
||||||
selected_file_current = 0 - 1;
|
selected_file_current = 0 - 1;
|
||||||
@@ -317,63 +321,66 @@ void jump_top(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void open_with(){
|
void open_with(){
|
||||||
|
pthread_mutex_lock(&mutex_btm);
|
||||||
|
|
||||||
|
|
||||||
|
char *btm_buffer_tmp = btm_buffer;
|
||||||
|
werase(win_b);
|
||||||
|
mvwin(win_b, terminal_height-6, 0);
|
||||||
|
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width/3); /*the div3 just looks cool*/
|
||||||
|
|
||||||
btm_buffer = concat("open \"", mid_content[selected_file_current].file_name);
|
btm_buffer = concat("open \"", mid_content[selected_file_current].file_name);
|
||||||
btm_buffer = concat(btm_buffer, "\" with:");
|
btm_buffer = concat(btm_buffer, "\" with:");
|
||||||
|
|
||||||
status |= STATUS_UPDATE_SCREEN_0;
|
window_btm(win_b, 1);
|
||||||
werase(win_b);
|
|
||||||
mvwin(win_b, terminal_height-6, 0);
|
|
||||||
wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/
|
|
||||||
|
|
||||||
render_pass();
|
|
||||||
unsigned long local_height;
|
|
||||||
local_height = getmaxy(win_b);
|
|
||||||
|
|
||||||
|
|
||||||
/* TODO(2025-06-22T01:24:36) fix fixed buffer size */
|
char *str = malloc(INPUT_BUFFER_SIZE);
|
||||||
char *str = malloc(255);
|
memset(str, ' ', INPUT_BUFFER_SIZE);
|
||||||
memset(str, ' ', 255);
|
str[INPUT_BUFFER_SIZE-1] = '\0';
|
||||||
int err = read_string(win_b, local_height - 1, 0 , str);
|
int err = read_string(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION - 1, 0 , str);
|
||||||
|
|
||||||
|
|
||||||
if (!err) {
|
if (err == 0) {
|
||||||
char *cmd = concat(str, " ./\"");
|
char *cmd = concat(str, " ./\"");
|
||||||
cmd = concat(cmd, mid_content[selected_file_current].file_name);
|
cmd = concat(cmd, mid_content[selected_file_current].file_name);
|
||||||
cmd = concat(cmd, "\"");
|
cmd = concat(cmd, "\"");
|
||||||
|
|
||||||
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||||
|
images_clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (system(cmd) == -1) {
|
if (system(cmd) == -1) {
|
||||||
FAIL("open_with", "creating subcommand failed unhandled");
|
FAIL("open_with", "creating subcommand failed unhandled");
|
||||||
}
|
}
|
||||||
|
|
||||||
free(btm_buffer);
|
|
||||||
btm_buffer = cmd;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||||
|
|
||||||
|
free(btm_buffer);
|
||||||
|
btm_buffer = btm_buffer_tmp;
|
||||||
|
pthread_mutex_unlock(&mutex_btm);
|
||||||
|
|
||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rename_hovered(){
|
void rename_hovered(){
|
||||||
|
pthread_mutex_lock(&mutex_btm);
|
||||||
|
|
||||||
|
char *btm_buffer_tmp = btm_buffer;
|
||||||
|
werase(win_b);
|
||||||
|
mvwin(win_b, terminal_height-6, 0);
|
||||||
|
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width/3); /*the div3 just looks cool*/
|
||||||
|
|
||||||
btm_buffer = concat("rename \"", mid_content[selected_file_current].file_name);
|
btm_buffer = concat("rename \"", mid_content[selected_file_current].file_name);
|
||||||
btm_buffer = concat(btm_buffer, "\" to:");
|
btm_buffer = concat(btm_buffer, "\" to:");
|
||||||
|
|
||||||
status |= STATUS_UPDATE_SCREEN_0;
|
window_btm(win_b, 1);
|
||||||
werase(win_b);
|
|
||||||
mvwin(win_b, terminal_height-6, 0);
|
|
||||||
wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/
|
|
||||||
|
|
||||||
render_pass();
|
char *str = malloc(INPUT_BUFFER_SIZE);
|
||||||
|
memset(str, ' ', INPUT_BUFFER_SIZE);
|
||||||
unsigned long local_height;
|
str[INPUT_BUFFER_SIZE-1] = '\0';
|
||||||
local_height = getmaxy(win_b);
|
int err = read_string(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION - 1, 0, str);
|
||||||
|
|
||||||
/* TODO(2025-06-22T01:24:30) fix fixed buffer size */
|
|
||||||
char *str = malloc(255);
|
|
||||||
memset(str, ' ', 255);
|
|
||||||
int err = read_string(win_b, local_height - 1, 0, str);
|
|
||||||
|
|
||||||
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
@@ -387,14 +394,20 @@ void rename_hovered(){
|
|||||||
};
|
};
|
||||||
btm_buffer = cmd;
|
btm_buffer = cmd;
|
||||||
}
|
}
|
||||||
|
free(str);
|
||||||
|
free(btm_buffer);
|
||||||
|
btm_buffer = btm_buffer_tmp;
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&mutex_btm);
|
||||||
|
|
||||||
free(str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void delete(){
|
void delete(){
|
||||||
|
pthread_mutex_lock(&mutex_btm);
|
||||||
|
|
||||||
|
char *btm_buffer_tmp = btm_buffer;
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
unsigned int hits = 0;
|
unsigned int hits = 0;
|
||||||
@@ -408,31 +421,52 @@ void delete(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hits) {
|
|
||||||
btm_buffer = concat("delete:", file_str);
|
|
||||||
} else {
|
|
||||||
btm_buffer = concat("delete: \"", mid_content[selected_file_current].file_name);
|
|
||||||
btm_buffer = concat(btm_buffer, "\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
btm_buffer = concat(btm_buffer, "?");
|
|
||||||
btm_buffer = concat(btm_buffer, "\n\n");
|
|
||||||
btm_buffer = concat(btm_buffer, "(y/N)");
|
|
||||||
|
|
||||||
status |= STATUS_UPDATE_SCREEN_0;
|
|
||||||
werase(win_b);
|
werase(win_b);
|
||||||
mvwin(win_b, terminal_height-6, 0);
|
mvwin(win_b, terminal_height-6, 0);
|
||||||
wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/
|
if (strlen(file_str) < (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION-1) * (terminal_width/3)) {
|
||||||
|
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width/3); /*the div3 just looks cool*/
|
||||||
|
btm_buffer = malloc(BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3));
|
||||||
|
memset(btm_buffer, ' ', (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3)));
|
||||||
|
|
||||||
render_pass();
|
memcpy(btm_buffer, "delete: ",strlen("delete: "));
|
||||||
|
if (hits) {
|
||||||
|
memcpy(btm_buffer + strlen("delete: "), file_str, strlen(file_str));
|
||||||
|
} else {
|
||||||
|
btm_buffer[strlen("delete: ")] = '"';
|
||||||
|
memcpy(btm_buffer + strlen("delete: ") + sizeof(char), mid_content[selected_file_current].file_name, strlen(mid_content[selected_file_current].file_name)-1);
|
||||||
|
btm_buffer[strlen("delete: ") + sizeof(char) + strlen(mid_content[selected_file_current].file_name)] = '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(btm_buffer + (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3) - (terminal_width/3)) , "(y/N)", strlen("(y/N)"));
|
||||||
|
btm_buffer[BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3)] = '\0';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/*since more data is present than can be represented using div3, we do the uncool thing*/
|
||||||
|
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width);
|
||||||
|
btm_buffer = malloc(BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width);
|
||||||
|
memset(btm_buffer, ' ', BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width);
|
||||||
|
|
||||||
|
memcpy(btm_buffer, "delete: ",strlen("delete: "));
|
||||||
|
|
||||||
|
/*this horrendous check tries to copy everything until the last line, while keeping said last line unwritten*/
|
||||||
|
/*lets hope im never gonna need to format something like this ever again*/
|
||||||
|
memcpy(btm_buffer + strlen("delete: "), file_str,
|
||||||
|
(strlen(file_str) > ((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) ?
|
||||||
|
((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) :
|
||||||
|
strlen(file_str)));
|
||||||
|
|
||||||
|
memcpy(btm_buffer + (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width - terminal_width) , "(y/N)", strlen("(y/N)"));
|
||||||
|
btm_buffer[BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
window_btm(win_b, 1);
|
||||||
|
|
||||||
timeout(-1); /* negative numbers block until enter is pressed */
|
timeout(-1); /* negative numbers block until enter is pressed */
|
||||||
/* TODO(2025-06-22T01:24:30) fix fixed buffer size */
|
|
||||||
char ch = wgetch(win_b);
|
char ch = wgetch(win_b);
|
||||||
|
|
||||||
if (ch == 'y' || ch == 'Y') {
|
if (ch == 'y' || ch == 'Y') {
|
||||||
/* TODO(2025-06-30T02:27:06) IMPORTANT: this really fucks up when the file has a quotation mark in its name */
|
|
||||||
if (hits) {
|
if (hits) {
|
||||||
for (i = 0; i < mid_file_count; i++) {
|
for (i = 0; i < mid_file_count; i++) {
|
||||||
if (mid_content[i].status & FILE_STATUS_SELECTED) {
|
if (mid_content[i].status & FILE_STATUS_SELECTED) {
|
||||||
@@ -440,47 +474,45 @@ void delete(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(btm_buffer);
|
free(btm_buffer);
|
||||||
btm_buffer = concat("deleted: ", file_str);
|
|
||||||
} else {
|
} else {
|
||||||
free(btm_buffer);
|
free(btm_buffer);
|
||||||
if (mid_content[selected_file_current].file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR)) {
|
if (mid_content[selected_file_current].file_type & FILE_TYPE_DIR) {
|
||||||
recursive_delete(mid_content[selected_file_current]);
|
recursive_delete(mid_content[selected_file_current]);
|
||||||
}
|
}
|
||||||
remove(mid_content[selected_file_current].file_name);
|
remove(mid_content[selected_file_current].file_name);
|
||||||
btm_buffer = concat("deleted: \"", mid_content[selected_file_current].file_name);
|
|
||||||
btm_buffer = concat(btm_buffer, "\"");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*system(cmd);*/
|
}
|
||||||
|
free(btm_buffer);
|
||||||
} else {
|
btm_buffer = btm_buffer_tmp;
|
||||||
free(btm_buffer);
|
if (hits) {
|
||||||
btm_buffer = "cancled deletion";
|
free(file_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout(10);
|
timeout(10);
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||||
|
|
||||||
if (hits) {
|
pthread_mutex_unlock(&mutex_btm);
|
||||||
free(file_str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void makedir(){
|
void makedir(){
|
||||||
btm_buffer = "create dir: ";
|
pthread_mutex_lock(&mutex_btm);
|
||||||
status |= STATUS_UPDATE_SCREEN_0;
|
|
||||||
|
|
||||||
|
char *btm_buffer_tmp = btm_buffer;
|
||||||
werase(win_b);
|
werase(win_b);
|
||||||
mvwin(win_b, terminal_height-6, 0);
|
mvwin(win_b, terminal_height-6, 0);
|
||||||
wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/
|
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width/3); /*the div3 just looks cool*/
|
||||||
render_pass();
|
|
||||||
|
|
||||||
unsigned long local_height;
|
btm_buffer = "create dir: ";
|
||||||
local_height = getmaxy(win_b);
|
|
||||||
|
window_btm(win_b, 1);
|
||||||
|
|
||||||
|
char *str = malloc(INPUT_BUFFER_SIZE);
|
||||||
|
memset(str, ' ', INPUT_BUFFER_SIZE);
|
||||||
|
str[INPUT_BUFFER_SIZE-1] = '\0';
|
||||||
|
int err = read_string(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION - 1, 0, str);
|
||||||
|
|
||||||
/* TODO(2025-07-03T01:19:55) fix fixed buffer size */
|
|
||||||
char *str = malloc(255);
|
|
||||||
memset(str, ' ', 255);
|
|
||||||
int err = read_string(win_b, local_height - 1, 0, str);
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
btm_buffer = concat(btm_buffer, str);
|
btm_buffer = concat(btm_buffer, str);
|
||||||
mode_t mask = umask(0);
|
mode_t mask = umask(0);
|
||||||
@@ -488,23 +520,29 @@ void makedir(){
|
|||||||
umask(mask);
|
umask(mask);
|
||||||
}
|
}
|
||||||
free(str);
|
free(str);
|
||||||
|
free(btm_buffer);
|
||||||
|
btm_buffer = btm_buffer_tmp;
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||||
|
pthread_mutex_unlock(&mutex_btm);
|
||||||
}
|
}
|
||||||
void makefile(){
|
void makefile(){
|
||||||
btm_buffer = "create file: ";
|
pthread_mutex_lock(&mutex_btm);
|
||||||
status |= STATUS_UPDATE_SCREEN_0;
|
|
||||||
|
char *btm_buffer_tmp = btm_buffer;
|
||||||
werase(win_b);
|
werase(win_b);
|
||||||
mvwin(win_b, terminal_height-6, 0);
|
mvwin(win_b, terminal_height-6, 0);
|
||||||
wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/
|
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width/3); /*the div3 just looks cool*/
|
||||||
render_pass();
|
|
||||||
|
|
||||||
unsigned long local_height;
|
btm_buffer = "create file: ";
|
||||||
local_height = getmaxy(win_b);
|
|
||||||
|
window_btm(win_b, 1);
|
||||||
|
|
||||||
|
char *str = malloc(INPUT_BUFFER_SIZE);
|
||||||
|
memset(str, ' ', INPUT_BUFFER_SIZE);
|
||||||
|
str[INPUT_BUFFER_SIZE-1] = '\0';
|
||||||
|
int err = read_string(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION - 1, 0, str);
|
||||||
|
|
||||||
/* TODO(2025-07-03T01:19:49) fix fixed buffer size */
|
|
||||||
char *str = malloc(255);
|
|
||||||
memset(str, ' ', 255);
|
|
||||||
int err = read_string(win_b, local_height - 1, 0, str);
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
btm_buffer = concat(btm_buffer, str);
|
btm_buffer = concat(btm_buffer, str);
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@@ -512,15 +550,22 @@ void makefile(){
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
free(str);
|
free(str);
|
||||||
|
free(btm_buffer);
|
||||||
|
btm_buffer = btm_buffer_tmp;
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||||
|
pthread_mutex_unlock(&mutex_btm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(){
|
void update(){
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||||
}
|
}
|
||||||
void enter_shell(int passes, int index){
|
void enter_shell(unsigned long passes, int index){
|
||||||
(void)passes;
|
(void)passes;
|
||||||
|
|
||||||
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||||
|
images_clear();
|
||||||
|
#endif
|
||||||
endwin();
|
endwin();
|
||||||
if (system(key_binding[index].black_magic) != 0) {
|
if (system(key_binding[index].black_magic) != 0) {
|
||||||
/*do nothing*/
|
/*do nothing*/
|
||||||
@@ -528,14 +573,14 @@ void enter_shell(int passes, int index){
|
|||||||
initscr();
|
initscr();
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||||
}
|
}
|
||||||
void not_implemented(int passes, int index){
|
void not_implemented(unsigned long passes, int index){
|
||||||
(void)passes;
|
(void)passes;
|
||||||
|
|
||||||
mvaddstr(terminal_height-1, 0, key_binding[index].comment);
|
mvaddstr(terminal_height-1, 0, key_binding[index].comment);
|
||||||
mvaddstr(terminal_height-1, strlen(key_binding[index].comment), "\t");
|
mvaddstr(terminal_height-1, strlen(key_binding[index].comment), "\t");
|
||||||
mvaddstr(terminal_height-1, strlen(key_binding[index].comment) + strlen("\t"), "is not yet implemented");
|
mvaddstr(terminal_height-1, strlen(key_binding[index].comment) + strlen("\t"), "is not yet implemented");
|
||||||
}
|
}
|
||||||
void jump_to_dir(int passes, int index){
|
void jump_to_dir(unsigned long passes, int index){
|
||||||
(void)passes;
|
(void)passes;
|
||||||
|
|
||||||
char *ch = (char*)key_binding[index].black_magic;
|
char *ch = (char*)key_binding[index].black_magic;
|
||||||
@@ -555,7 +600,7 @@ void jump_to_dir(int passes, int index){
|
|||||||
ch = (char*)key_binding[index].black_magic;
|
ch = (char*)key_binding[index].black_magic;
|
||||||
if (*ch == '/') {
|
if (*ch == '/') {
|
||||||
path = malloc(strlen((char*)key_binding[index].black_magic));
|
path = malloc(strlen((char*)key_binding[index].black_magic));
|
||||||
strcpy(path, (char*)key_binding[index].black_magic);
|
memcpy(path, (char*)key_binding[index].black_magic, strlen((char*)key_binding[index].black_magic)+1);
|
||||||
} else if (slash) {
|
} else if (slash) {
|
||||||
env_str = malloc(env_len * sizeof(char));
|
env_str = malloc(env_len * sizeof(char));
|
||||||
memcpy(env_str, (char*)key_binding[index].black_magic +1, env_len);
|
memcpy(env_str, (char*)key_binding[index].black_magic +1, env_len);
|
||||||
@@ -565,16 +610,16 @@ void jump_to_dir(int passes, int index){
|
|||||||
path = concat(env_parsed, (char*)key_binding[index].black_magic + env_len);
|
path = concat(env_parsed, (char*)key_binding[index].black_magic + env_len);
|
||||||
} else {
|
} else {
|
||||||
path = malloc(strlen((char*)key_binding[index].black_magic));
|
path = malloc(strlen((char*)key_binding[index].black_magic));
|
||||||
strcpy(path, (char*)key_binding[index].black_magic);
|
memcpy(path, (char*)key_binding[index].black_magic, strlen((char*)key_binding[index].black_magic)+1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
env_parsed = getenv((char*)key_binding[index].black_magic +1);
|
env_parsed = getenv((char*)key_binding[index].black_magic +1);
|
||||||
if (env_parsed) {
|
if (env_parsed) {
|
||||||
path = malloc(strlen(env_parsed)+1);
|
path = malloc(strlen(env_parsed)+1);
|
||||||
strcpy(path, env_parsed);
|
memcpy(path, env_parsed, strlen(env_parsed)+1);
|
||||||
} else {
|
} else {
|
||||||
path = malloc(strlen((char*)key_binding[index].black_magic));
|
path = malloc(strlen((char*)key_binding[index].black_magic));
|
||||||
strcpy(path, (char*)key_binding[index].black_magic);
|
memcpy(path, (char*)key_binding[index].black_magic, strlen((char*)key_binding[index].black_magic)+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (chdir(path) != 0) {
|
if (chdir(path) != 0) {
|
||||||
@@ -592,15 +637,22 @@ void jump_to_dir(int passes, int index){
|
|||||||
}
|
}
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
||||||
}
|
}
|
||||||
void order_by(int passes, int index){
|
void order_by(unsigned long passes, int index){
|
||||||
(void)passes;
|
(void)passes;
|
||||||
|
|
||||||
|
free(seed);
|
||||||
|
seed = NULL;
|
||||||
|
seed = malloc(sizeof(time_t));
|
||||||
|
*seed = time(NULL);
|
||||||
|
|
||||||
order_func = key_binding[index].black_magic;
|
order_func = key_binding[index].black_magic;
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
||||||
}
|
}
|
||||||
void cmd_on_selected(int passes, int index){
|
void cmd_on_selected(unsigned long passes, int index){
|
||||||
(void)passes;
|
(void)passes;
|
||||||
|
pthread_mutex_lock(&mutex_btm);
|
||||||
|
|
||||||
|
char *btm_buffer_tmp = btm_buffer;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
unsigned int hits = 0;
|
unsigned int hits = 0;
|
||||||
char *file_str = " ";
|
char *file_str = " ";
|
||||||
@@ -625,13 +677,11 @@ void cmd_on_selected(int passes, int index){
|
|||||||
btm_buffer = concat(btm_buffer, "\n\n");
|
btm_buffer = concat(btm_buffer, "\n\n");
|
||||||
btm_buffer = concat(btm_buffer, "(y/N)");
|
btm_buffer = concat(btm_buffer, "(y/N)");
|
||||||
|
|
||||||
status |= STATUS_UPDATE_SCREEN_0;
|
|
||||||
werase(win_b);
|
werase(win_b);
|
||||||
mvwin(win_b, terminal_height-6, 0);
|
mvwin(win_b, terminal_height-6, 0);
|
||||||
wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/
|
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width/3); /*the div3 just looks cool*/
|
||||||
|
|
||||||
render_pass();
|
|
||||||
|
|
||||||
|
window_btm(win_b, 1);
|
||||||
|
|
||||||
timeout(-1); /* negative numbers block until enter is pressed */
|
timeout(-1); /* negative numbers block until enter is pressed */
|
||||||
/* TODO(2025-07-06T07:22:49) fix fixed buffer size */
|
/* TODO(2025-07-06T07:22:49) fix fixed buffer size */
|
||||||
@@ -654,7 +704,7 @@ void cmd_on_selected(int passes, int index){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(btm_buffer);
|
free(btm_buffer);
|
||||||
btm_buffer = concat("completed: ", key_binding[index].black_magic);
|
memcpy(btm_buffer, "completed: ", strlen("completed: "));
|
||||||
} else {
|
} else {
|
||||||
free(btm_buffer);
|
free(btm_buffer);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
@@ -672,8 +722,10 @@ void cmd_on_selected(int passes, int index){
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
free(btm_buffer);
|
free(btm_buffer);
|
||||||
btm_buffer = "cancled deletion";
|
memcpy(btm_buffer, "cancled deletion", strlen("cancled deletion"));
|
||||||
}
|
}
|
||||||
|
free(btm_buffer);
|
||||||
|
btm_buffer = btm_buffer_tmp;
|
||||||
|
|
||||||
timeout(10);
|
timeout(10);
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||||
@@ -681,18 +733,41 @@ void cmd_on_selected(int passes, int index){
|
|||||||
if (hits) {
|
if (hits) {
|
||||||
free(file_str);
|
free(file_str);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex_btm);
|
||||||
}
|
}
|
||||||
void yank_file(int passes, int index){
|
void yank_text(unsigned long passes, int index){
|
||||||
|
(void)passes;
|
||||||
|
char *cmd;
|
||||||
|
if (strncmp((char*)key_binding[index].black_magic, "path", 4) == 0) {
|
||||||
|
char *path=getcwd(NULL, 0);
|
||||||
|
cmd = concat("echo \"", path);
|
||||||
|
cmd = concat(cmd, "/");
|
||||||
|
cmd = concat(cmd, mid_content[selected_file_current].file_name);
|
||||||
|
cmd = concat(cmd, "\" | ");
|
||||||
|
cmd = concat(cmd, clipboard_cmd);
|
||||||
|
free(path);
|
||||||
|
} else {
|
||||||
|
cmd = concat("echo \"", mid_content[selected_file_current].file_name);
|
||||||
|
cmd = concat(cmd, "\" | ");
|
||||||
|
cmd = concat(cmd, clipboard_cmd);
|
||||||
|
}
|
||||||
|
if (system(cmd) == -1) {
|
||||||
|
/*do nothing*/
|
||||||
|
}
|
||||||
|
free(cmd);
|
||||||
|
}
|
||||||
|
void yank_file(unsigned long passes, int index){
|
||||||
(void)passes;
|
(void)passes;
|
||||||
|
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
if (yank_files.status & YANK_IS_USED) {
|
if (yank_files.status & YANK_IS_USED) {
|
||||||
free(yank_files.path);
|
|
||||||
for (i = 0; i < yank_files.count; i++) {
|
for (i = 0; i < yank_files.count; i++) {
|
||||||
free(yank_files.list[i]);
|
free(yank_files.list[i]);
|
||||||
}
|
}
|
||||||
free(yank_files.list);
|
free(yank_files.list);
|
||||||
|
free(yank_files.path);
|
||||||
yank_files.count = 0;
|
yank_files.count = 0;
|
||||||
|
yank_files.status = 0;
|
||||||
}
|
}
|
||||||
yank_files.path=getcwd(NULL, 0);
|
yank_files.path=getcwd(NULL, 0);
|
||||||
yank_files.count = 0;
|
yank_files.count = 0;
|
||||||
@@ -706,13 +781,13 @@ void yank_file(int passes, int index){
|
|||||||
yank_files.count = 1;
|
yank_files.count = 1;
|
||||||
yank_files.list = (char**)malloc(yank_files.count * sizeof(char*));
|
yank_files.list = (char**)malloc(yank_files.count * sizeof(char*));
|
||||||
*yank_files.list = malloc(strlen(mid_content[selected_file_current].file_name)+1);
|
*yank_files.list = malloc(strlen(mid_content[selected_file_current].file_name)+1);
|
||||||
strcpy(*yank_files.list, mid_content[selected_file_current].file_name);
|
memcpy(*yank_files.list, mid_content[selected_file_current].file_name, strlen(mid_content[selected_file_current].file_name));
|
||||||
} else {
|
} else {
|
||||||
yank_files.list = malloc(yank_files.count * sizeof(char*));
|
yank_files.list = malloc(yank_files.count * sizeof(char*));
|
||||||
for (i = 0; i < mid_file_count && i < yank_files.count; i++) {
|
for (i = 0; i < mid_file_count; i++) {
|
||||||
if (mid_content[i].status & FILE_STATUS_SELECTED) {
|
if (mid_content[i].status & FILE_STATUS_SELECTED) {
|
||||||
*yank_files.list = malloc(strlen(mid_content[i].file_name)+1);
|
*yank_files.list = malloc(strlen(mid_content[i].file_name)+1);
|
||||||
strcpy(*yank_files.list, mid_content[i].file_name);
|
memcpy(*yank_files.list, mid_content[i].file_name, strlen(mid_content[i].file_name));
|
||||||
yank_files.list += 1;
|
yank_files.list += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -733,34 +808,54 @@ void paste(){
|
|||||||
/*TODO(2025-08-14T22:10:44) escape path*/
|
/*TODO(2025-08-14T22:10:44) escape path*/
|
||||||
char *cmd;
|
char *cmd;
|
||||||
if (yank_files.status & YANK_COPY) {
|
if (yank_files.status & YANK_COPY) {
|
||||||
cmd = concat("false | cp -r -i ", yank_files.path);
|
cmd = concat("false | cp -riv ", yank_files.path);
|
||||||
} else {
|
} else {
|
||||||
cmd = concat("mv ", yank_files.path);
|
cmd = concat("mv ", yank_files.path);
|
||||||
}
|
}
|
||||||
cmd = concat(cmd, "/");
|
cmd = concat(cmd, "/");
|
||||||
cmd = concat(cmd, *yank_files.list);
|
cmd = concat(cmd, *yank_files.list);
|
||||||
cmd = concat(cmd, " ./");
|
cmd = concat(cmd, " ./");
|
||||||
mvprintw(i, 0, cmd);
|
cmd = concat(cmd, *yank_files.list);
|
||||||
if (system(cmd) != 0) {
|
cmd = concat(cmd, " 2>&1");
|
||||||
cmd = concat(cmd, *yank_files.list);
|
char *line = malloc(INPUT_BUFFER_SIZE);
|
||||||
while (1) {
|
FILE *cmd_open;
|
||||||
|
while (1) {
|
||||||
|
cmd_open = popen(cmd, "r");
|
||||||
|
if (fgets(line, INPUT_BUFFER_SIZE, cmd_open) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (strstr(line, "are the same file")) {
|
||||||
|
cmd[strlen(cmd)-strlen(" 2>&1")] = '\0';
|
||||||
cmd = concat(cmd, "_");
|
cmd = concat(cmd, "_");
|
||||||
if (system(cmd) == 0) {
|
cmd = concat(cmd, " 2>&1");
|
||||||
break;
|
} else if ((strstr(line, "overwrite"))) {
|
||||||
} }
|
cmd[strlen(cmd)-strlen(" 2>&1")] = '\0';
|
||||||
|
cmd = concat(cmd, "_");
|
||||||
|
cmd = concat(cmd, " 2>&1");
|
||||||
|
} else if ((strstr(line, "No such file or directory"))) {
|
||||||
|
pclose(cmd_open);
|
||||||
|
break;
|
||||||
|
} else if (pclose(cmd_open) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pclose(cmd_open);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(cmd);
|
||||||
|
|
||||||
yank_files.list++;
|
yank_files.list++;
|
||||||
}
|
}
|
||||||
yank_files.list -= yank_files.count;
|
yank_files.list -= yank_files.count;
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||||
}
|
}
|
||||||
void search(){
|
void search(){
|
||||||
|
pthread_mutex_lock(&mutex_btm);
|
||||||
|
|
||||||
unsigned long local_height;
|
unsigned long local_height;
|
||||||
local_height = getmaxy(win_b);
|
local_height = getmaxy(win_b);
|
||||||
|
memset(search_buffer, '\0', INPUT_BUFFER_SIZE);
|
||||||
|
|
||||||
memset(search_buffer, '\0', 255);
|
window_btm(win_b, 1);
|
||||||
render_pass();
|
|
||||||
|
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
|
|
||||||
@@ -818,6 +913,7 @@ void search(){
|
|||||||
update_selected_file();
|
update_selected_file();
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_0);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_0);
|
||||||
|
pthread_mutex_unlock(&mutex_btm);
|
||||||
}
|
}
|
||||||
void search_next(){
|
void search_next(){
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
@@ -846,3 +942,25 @@ void search_previous(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void jmp_file_index(){
|
||||||
|
char *index = malloc(INPUT_BUFFER_SIZE);
|
||||||
|
memset(index, ' ', INPUT_BUFFER_SIZE);
|
||||||
|
index[INPUT_BUFFER_SIZE-1] = '\0';
|
||||||
|
unsigned long local_height;
|
||||||
|
local_height = getmaxy(win_b);
|
||||||
|
read_string(win_b, local_height - 1, 0, index);
|
||||||
|
|
||||||
|
unsigned long new_index = 0;
|
||||||
|
while((*index >= '0') && (*index <= '9')) {
|
||||||
|
new_index = (new_index * 10) + (*index - '0');
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
if (new_index > mid_file_count) {
|
||||||
|
selected_file_current = mid_file_count;
|
||||||
|
} else {
|
||||||
|
selected_file_current = new_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_0);
|
||||||
|
update_selected_file();
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,10 +7,11 @@
|
|||||||
void user_interactions();
|
void user_interactions();
|
||||||
void quit_program();
|
void quit_program();
|
||||||
void toggle_selection();
|
void toggle_selection();
|
||||||
|
void select_all();
|
||||||
void move_right();
|
void move_right();
|
||||||
void move_up(int passes);
|
void move_up(unsigned long passes);
|
||||||
void move_down(int passes);
|
void move_down(unsigned long passes);
|
||||||
void move_left(int passes);
|
void move_left(unsigned long passes);
|
||||||
void jump_bottom();
|
void jump_bottom();
|
||||||
void jump_top();
|
void jump_top();
|
||||||
void toggle_hidden_files();
|
void toggle_hidden_files();
|
||||||
@@ -20,13 +21,15 @@ void delete();
|
|||||||
void makedir();
|
void makedir();
|
||||||
void makefile();
|
void makefile();
|
||||||
void update();
|
void update();
|
||||||
void enter_shell(int passes, int index);
|
void enter_shell(unsigned long passes, int index);
|
||||||
void not_implemented(int passes, int index);
|
void not_implemented(unsigned long passes, int index);
|
||||||
void jump_to_dir(int passes, int index);
|
void jump_to_dir(unsigned long passes, int index);
|
||||||
void order_by(int passes, int index);
|
void order_by(unsigned long passes, int index);
|
||||||
void cmd_on_selected(int passes, int index);
|
void cmd_on_selected(unsigned long passes, int index);
|
||||||
void yank_file(int passes, int index);
|
void yank_text(unsigned long passes, int index);
|
||||||
|
void yank_file(unsigned long passes, int index);
|
||||||
void paste();
|
void paste();
|
||||||
void search();
|
void search();
|
||||||
void search_next();
|
void search_next();
|
||||||
void search_previous();
|
void search_previous();
|
||||||
|
void jmp_file_index();
|
||||||
|
|||||||
46
main.c
46
main.c
@@ -21,7 +21,7 @@ unsigned int settings;
|
|||||||
unsigned int file_modifiers;
|
unsigned int file_modifiers;
|
||||||
unsigned int status = (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
unsigned int status = (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
||||||
char *start_path;
|
char *start_path;
|
||||||
time_t seed;
|
time_t *seed;
|
||||||
|
|
||||||
WINDOW *win_t;
|
WINDOW *win_t;
|
||||||
WINDOW *win_b;
|
WINDOW *win_b;
|
||||||
@@ -60,6 +60,11 @@ int main(){
|
|||||||
|
|
||||||
char threading = 0;
|
char threading = 0;
|
||||||
terminal_width_empty_line = malloc(terminal_width);
|
terminal_width_empty_line = malloc(terminal_width);
|
||||||
|
#if SETTINGS_RELOAD_DIR_DELTA != 0
|
||||||
|
time_t t;
|
||||||
|
time_t dt;
|
||||||
|
time(&t);
|
||||||
|
#endif
|
||||||
|
|
||||||
pthread_create(&thread_t, NULL, thread_top, &status); /*top bar*/
|
pthread_create(&thread_t, NULL, thread_top, &status); /*top bar*/
|
||||||
pthread_create(&thread_l, NULL, thread_lft, &status); /*parent_content slash win_l*/
|
pthread_create(&thread_l, NULL, thread_lft, &status); /*parent_content slash win_l*/
|
||||||
@@ -76,13 +81,13 @@ int main(){
|
|||||||
temp_heigth = terminal_height;
|
temp_heigth = terminal_height;
|
||||||
}
|
}
|
||||||
if (threading) {
|
if (threading) {
|
||||||
status &= ~(STATUS_RELOAD_DIRECTORY);
|
status &= ~(STATUS_RELOAD_DIRECTORY | STATUS_DELTA_TIME);
|
||||||
threading = 0;
|
threading = 0;
|
||||||
}
|
}
|
||||||
if (status & STATUS_RUN_BACKEND) {
|
if (status & STATUS_RUN_BACKEND) {
|
||||||
pthread_cond_signal(&cond_top);
|
pthread_cond_signal(&cond_top);
|
||||||
pthread_cond_signal(&cond_mid);
|
pthread_cond_signal(&cond_mid);
|
||||||
pthread_cond_signal(&cond_btm);
|
pthread_cond_signal(&cond_lft);
|
||||||
status &= ~(STATUS_RUN_BACKEND);
|
status &= ~(STATUS_RUN_BACKEND);
|
||||||
status |= STATUS_UPDATE_SCREEN_0;
|
status |= STATUS_UPDATE_SCREEN_0;
|
||||||
threading = 1;
|
threading = 1;
|
||||||
@@ -92,17 +97,30 @@ int main(){
|
|||||||
|
|
||||||
render_pass();
|
render_pass();
|
||||||
|
|
||||||
|
#if SETTINGS_RELOAD_DIR_DELTA != 0
|
||||||
|
time(&dt);
|
||||||
|
if (dt - t >= SETTINGS_RELOAD_DIR_DELTA) {
|
||||||
|
time(&t);
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY | STATUS_DELTA_TIME);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||||
|
ueberzug_close();
|
||||||
|
#endif
|
||||||
threading_free();
|
threading_free();
|
||||||
free(start_path);
|
free(start_path);
|
||||||
|
|
||||||
if (threading) {
|
/*
|
||||||
|
if (threading) {
|
||||||
pthread_join(thread_l, NULL);
|
pthread_join(thread_l, NULL);
|
||||||
pthread_join(thread_r, NULL);
|
pthread_join(thread_r, NULL);
|
||||||
pthread_join(thread_m, NULL);
|
pthread_join(thread_m, NULL);
|
||||||
pthread_join(thread_t, NULL);
|
pthread_join(thread_t, NULL);
|
||||||
pthread_join(thread_b, NULL);
|
pthread_join(thread_b, NULL);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
delwin(win_l);
|
delwin(win_l);
|
||||||
delwin(win_m);
|
delwin(win_m);
|
||||||
@@ -127,11 +145,6 @@ void render_pass(){
|
|||||||
|
|
||||||
/*TODO: check if deallocation of window and reallocation is faster than this or not */
|
/*TODO: check if deallocation of window and reallocation is faster than this or not */
|
||||||
|
|
||||||
wclear(win_t);
|
|
||||||
wclear(win_b);
|
|
||||||
wclear(win_l);
|
|
||||||
wclear(win_m);
|
|
||||||
wclear(win_r);
|
|
||||||
|
|
||||||
wresize(win_t, 1, terminal_width);
|
wresize(win_t, 1, terminal_width);
|
||||||
wresize(win_l, terminal_height-2, terminal_width/8);
|
wresize(win_l, terminal_height-2, terminal_width/8);
|
||||||
@@ -156,7 +169,7 @@ void render_pass(){
|
|||||||
window_lft(win_l);
|
window_lft(win_l);
|
||||||
window_mid(win_m);
|
window_mid(win_m);
|
||||||
window_rgt(win_r);
|
window_rgt(win_r);
|
||||||
window_btm(win_b);
|
window_btm(win_b, 0);
|
||||||
wrefresh(win_t);
|
wrefresh(win_t);
|
||||||
wrefresh(win_l);
|
wrefresh(win_l);
|
||||||
wrefresh(win_m);
|
wrefresh(win_m);
|
||||||
@@ -174,8 +187,8 @@ void init() {
|
|||||||
curs_set(0);
|
curs_set(0);
|
||||||
|
|
||||||
/*file_modifiers = (FILE_MODIFIERS_HIDDEN_FILES | FILE_MODIFIERS_SORT_BITMASK);*/
|
/*file_modifiers = (FILE_MODIFIERS_HIDDEN_FILES | FILE_MODIFIERS_SORT_BITMASK);*/
|
||||||
input = malloc(sizeof(char)*255); /* size of input buffer, out of bounds access will not be accounted for */
|
input = malloc(INPUT_BUFFER_SIZE); /* size of input buffer, out of bounds access will not be accounted for */
|
||||||
memset(input, 0, 255);
|
memset(input, 0, INPUT_BUFFER_SIZE);
|
||||||
status = (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
status = (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
||||||
if (getuid() == 0) {
|
if (getuid() == 0) {
|
||||||
status |= STATUS_USER_ROOT;
|
status |= STATUS_USER_ROOT;
|
||||||
@@ -183,14 +196,17 @@ void init() {
|
|||||||
|
|
||||||
threading_init(); /* found in threading.c */
|
threading_init(); /* found in threading.c */
|
||||||
colors_init(); /* in colors.c */
|
colors_init(); /* in colors.c */
|
||||||
ueberzug_init(); /* in file_previews.c */
|
|
||||||
dir_init(); /*in dir.c */
|
dir_init(); /*in dir.c */
|
||||||
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||||
|
ueberzug_init(); /* in file_previews.c */
|
||||||
|
#endif
|
||||||
|
|
||||||
ESCDELAY = 10;
|
ESCDELAY = 10;
|
||||||
char *start_path = getcwd(NULL, 0);
|
char *start_path = getcwd(NULL, 0);
|
||||||
setenv("START_PATH", start_path, 0);
|
setenv("START_PATH", start_path, 0);
|
||||||
free(start_path);
|
free(start_path);
|
||||||
time(&seed);
|
|
||||||
srand(seed);
|
seed = malloc(sizeof(time_t));
|
||||||
|
*seed = time(NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
173
sorting.c
173
sorting.c
@@ -4,20 +4,21 @@
|
|||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
extern time_t seed;
|
extern time_t *seed;
|
||||||
extern unsigned int settings;
|
|
||||||
extern unsigned int file_modifiers;
|
|
||||||
|
|
||||||
int skip_hidden_files(const struct dirent *entry){
|
int skip_hidden_files(const struct dirent *entry){
|
||||||
|
|
||||||
if (entry->d_name[0] == '.') {
|
if (entry->d_name[0] == '.') {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int skip_dot(const struct dirent *entry){
|
int skip_dot(const struct dirent *entry){
|
||||||
|
|
||||||
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
|
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -26,10 +27,10 @@ int skip_dot(const struct dirent *entry){
|
|||||||
|
|
||||||
int sort_natural(const void *file0, const void *file1){
|
int sort_natural(const void *file0, const void *file1){
|
||||||
|
|
||||||
if (((file*)file0)->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR) && !(((file*)file1)->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR))) {
|
if ((((file*)file0)->file_type & FILE_TYPE_DIR) && !(((file*)file1)->file_type & FILE_TYPE_DIR)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!(((file*)file0)->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR)) && ((file*)file1)->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR)) {
|
if (!(((file*)file0)->file_type & FILE_TYPE_DIR) && (((file*)file1)->file_type & FILE_TYPE_DIR)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
const unsigned char *a = (unsigned char*)((file*)file0)->file_name;
|
const unsigned char *a = (unsigned char*)((file*)file0)->file_name;
|
||||||
@@ -41,38 +42,37 @@ int sort_natural(const void *file0, const void *file1){
|
|||||||
char result = 0;
|
char result = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
is_num = 0;
|
|
||||||
|
|
||||||
if ((*a >= '0') && (*a <= '9')) {
|
if ((*a <= '9') && (*a >= '0')) {
|
||||||
parsed_number0 = 0;
|
parsed_number0 = 0;
|
||||||
while((*a >= '0') && (*a <= '9')) {
|
do {
|
||||||
parsed_number0 = (parsed_number0 * 10) + (*a - '0');
|
parsed_number0 = (parsed_number0 * 10) + (*a - '0');
|
||||||
a++;
|
a++;
|
||||||
}
|
} while((*a <= '9') && (*a >= '0'));
|
||||||
is_num |= 1;
|
is_num |= 1;
|
||||||
}
|
}
|
||||||
if ((*b >= '0') && (*b <= '9')) {
|
if ((*b <= '9') && (*b >= '0')) {
|
||||||
parsed_number1 = 0;
|
parsed_number1 = 0;
|
||||||
while((*b >= '0') && (*b <= '9')) {
|
do {
|
||||||
parsed_number1 = (parsed_number1 * 10) + (*b - '0');
|
parsed_number1 = (parsed_number1 * 10) + (*b - '0');
|
||||||
b++;
|
b++;
|
||||||
}
|
} while((*b <= '9') && (*b >= '0'));
|
||||||
is_num |= 2;
|
is_num |= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_num) {
|
if (is_num) {
|
||||||
if (is_num == 1) {
|
if (is_num == 1) {
|
||||||
if (*b < '0') {
|
if (*b > '9') {
|
||||||
result = 1;
|
|
||||||
} else {
|
|
||||||
result = -1;
|
result = -1;
|
||||||
|
} else {
|
||||||
|
result = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else if (is_num == 2) {
|
} else if (is_num == 2) {
|
||||||
if (*a < '0') {
|
if (*a > '9') {
|
||||||
result = -1;
|
|
||||||
} else {
|
|
||||||
result = 1;
|
result = 1;
|
||||||
|
} else {
|
||||||
|
result = -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@@ -86,6 +86,7 @@ int sort_natural(const void *file0, const void *file1){
|
|||||||
}
|
}
|
||||||
/* those breaks are not set here, due to the possibillity that both numbers are equal
|
/* those breaks are not set here, due to the possibillity that both numbers are equal
|
||||||
* in which case the comparison should continue */
|
* in which case the comparison should continue */
|
||||||
|
is_num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char aa = ((*a >= 'A') && (*a <= 'Z')) ? (*a | ' ') : *a;
|
unsigned char aa = ((*a >= 'A') && (*a <= 'Z')) ? (*a | ' ') : *a;
|
||||||
@@ -99,76 +100,104 @@ int sort_natural(const void *file0, const void *file1){
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
int sort_alpha(const void *file0, const void *file1){
|
int sort_alpha(const void *file0, const void *file1){
|
||||||
char *file_name0 = ((file*)file0)->file_name;
|
|
||||||
char *file_name1 = ((file*)file1)->file_name;
|
if ((((file*)file0)->file_type & FILE_TYPE_DIR) && !(((file*)file1)->file_type & FILE_TYPE_DIR)) {
|
||||||
return strcmp(file_name0, file_name1);
|
|
||||||
}
|
|
||||||
int sort_random(const void *file0_, const void *file1_){
|
|
||||||
file *file0 = (file*)file0_;
|
|
||||||
file *file1 = (file*)file1_;
|
|
||||||
if (file0->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR) && !(file1->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR))) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!(file0->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR)) && file1->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR)) {
|
if (!(((file*)file0)->file_type & FILE_TYPE_DIR) && (((file*)file1)->file_type & FILE_TYPE_DIR)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int random = rand();
|
|
||||||
if (random & 1) {
|
return strcmp(((file*)file0)->file_name, ((file*)file1)->file_name);
|
||||||
return 1;
|
}
|
||||||
} else {
|
int sort_random(const void *file0, const void *file1){
|
||||||
return -1;
|
|
||||||
|
if ((((file*)file0)->file_type & FILE_TYPE_DIR) && !(((file*)file1)->file_type & FILE_TYPE_DIR)) {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (!(((file*)file0)->file_type & FILE_TYPE_DIR) && (((file*)file1)->file_type & FILE_TYPE_DIR)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
time_t num = (time_t)&seed;
|
||||||
|
time_t i;
|
||||||
|
for (i = num%2; i < 6+(((time_t)&seed)%2); i++){
|
||||||
|
num ^= *seed;
|
||||||
|
if (num%2) {
|
||||||
|
num ^= (time_t)#
|
||||||
|
num ^= num << (i + (((time_t)&seed)%5));
|
||||||
|
} else {
|
||||||
|
num ^= (time_t)&seed;
|
||||||
|
num ^= num >> (i + (((time_t)&num)%5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
num ^= getpid();
|
||||||
|
|
||||||
|
return ((num%3) - 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
int sort_type(const void *file0, const void *file1){
|
int sort_type(const void *file0, const void *file1){
|
||||||
unsigned char file_type0 = ((file*)file0)->file_type;
|
|
||||||
unsigned char file_type1 = ((file*)file1)->file_type;
|
if ((((file*)file0)->file_type & FILE_TYPE_DIR) && !(((file*)file1)->file_type & FILE_TYPE_DIR)) {
|
||||||
char *file_name0 = ((file*)file0)->file_name;
|
return -1;
|
||||||
char *file_name1 = ((file*)file1)->file_name;
|
}
|
||||||
if (file_type0 == file_type1) {
|
if (!(((file*)file0)->file_type & FILE_TYPE_DIR) && (((file*)file1)->file_type & FILE_TYPE_DIR)) {
|
||||||
return strcasecmp(file_name0, file_name1);
|
return 1;
|
||||||
} else if (file_type0 == FILE_TYPE_DIR || file_type0 == FILE_TYPE_SYMLINK) {
|
}
|
||||||
|
|
||||||
|
if (((file*)file0)->file_type > ((file*)file1)->file_type) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (file_type1 == FILE_TYPE_DIR || file_type1 == FILE_TYPE_SYMLINK) {
|
} else if (((file*)file0)->file_type < ((file*)file1)->file_type) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
if (file_type0 > file_type1) {
|
return sort_natural(file0, file1);
|
||||||
return -1;
|
|
||||||
} else if (file_type0 < file_type1) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return strcasecmp(file_name0, file_name1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int sort_size(const void *file0, const void *file1){
|
int sort_size(const void *file0, const void *file1){
|
||||||
unsigned char file_type0 = ((file*)file0)->file_type;
|
|
||||||
unsigned char file_type1 = ((file*)file1)->file_type;
|
if ((((file*)file0)->file_type & FILE_TYPE_DIR) && !(((file*)file1)->file_type & FILE_TYPE_DIR)) {
|
||||||
unsigned long file_size0 = ((file*)file0)->file_size;
|
|
||||||
unsigned long file_size1 = ((file*)file1)->file_size;
|
|
||||||
char *file_name0 = ((file*)file0)->file_name;
|
|
||||||
char *file_name1 = ((file*)file1)->file_name;
|
|
||||||
if (file_type0 == file_type1) {
|
|
||||||
if (file_size0 > file_size1) {
|
|
||||||
return -1;
|
return -1;
|
||||||
} else if (file_size0 < file_size1) {
|
}
|
||||||
|
if (!(((file*)file0)->file_type & FILE_TYPE_DIR) && (((file*)file1)->file_type & FILE_TYPE_DIR)) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
}
|
||||||
return strcasecmp(file_name0, file_name1);
|
|
||||||
}
|
if (((file*)file0)->file_size > ((file*)file1)->file_size) {
|
||||||
|
return -1;
|
||||||
|
} else if (((file*)file0)->file_size < ((file*)file1)->file_size) {
|
||||||
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
if (file_type0 == FILE_TYPE_DIR || file_type0 == FILE_TYPE_SYMLINK) {
|
return sort_natural(file0, file1);
|
||||||
return -1;
|
}
|
||||||
} else if (file_type1 == FILE_TYPE_DIR || file_type1 == FILE_TYPE_SYMLINK) {
|
}
|
||||||
return 1;
|
int sort_extension(const void *file0, const void *file1){
|
||||||
} else {
|
|
||||||
if (file_size0 > file_size1) {
|
if ((((file*)file0)->file_type & FILE_TYPE_DIR) && !(((file*)file1)->file_type & FILE_TYPE_DIR)) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (file_size0 < file_size1) {
|
}
|
||||||
return 1;
|
if (!(((file*)file0)->file_type & FILE_TYPE_DIR) && (((file*)file1)->file_type & FILE_TYPE_DIR)) {
|
||||||
} else {
|
return 1;
|
||||||
return strcasecmp(file_name0, file_name1);
|
}
|
||||||
}
|
|
||||||
}
|
char *extension0 = strrchr(((file*)file0)->file_name, '.');
|
||||||
|
char *extension1 = strrchr(((file*)file1)->file_name, '.');
|
||||||
|
|
||||||
|
if (extension0 && extension1) {
|
||||||
|
if ((strcmp(extension0, extension1)) == 0) {
|
||||||
|
return sort_natural(file0, file1);
|
||||||
|
} else {
|
||||||
|
file f0;
|
||||||
|
file f1;
|
||||||
|
memcpy(&f0, file0, sizeof(file));
|
||||||
|
memcpy(&f1, file1, sizeof(file));
|
||||||
|
f0.file_name = extension0;
|
||||||
|
f1.file_name = extension1;
|
||||||
|
return sort_natural(&f0, &f1);
|
||||||
|
}
|
||||||
|
} else if (extension0 != NULL && extension1 == NULL) {
|
||||||
|
return 1;
|
||||||
|
} else if (extension0 == NULL && extension1 != NULL) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return sort_natural(file0, file1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
121
threading.c
121
threading.c
@@ -6,7 +6,9 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/statvfs.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
#include "file_previews.h"
|
#include "file_previews.h"
|
||||||
|
|
||||||
@@ -46,12 +48,15 @@ volatile unsigned long selected_file_last = 0;
|
|||||||
extern unsigned int terminal_width;
|
extern unsigned int terminal_width;
|
||||||
extern unsigned int status;
|
extern unsigned int status;
|
||||||
|
|
||||||
|
unsigned int btm_status;
|
||||||
|
|
||||||
|
|
||||||
void *thread_mid(){
|
void *thread_mid(){
|
||||||
|
|
||||||
while(!(status & STATUS_QUIT_PROGRAM)){
|
while(!(status & STATUS_QUIT_PROGRAM)){
|
||||||
pthread_mutex_lock(&mutex_mid);
|
pthread_mutex_lock(&mutex_mid);
|
||||||
pthread_cond_wait(&cond_mid, &mutex_mid);
|
pthread_cond_wait(&cond_mid, &mutex_mid);
|
||||||
|
unsigned int local_status = status;
|
||||||
|
|
||||||
char *path;
|
char *path;
|
||||||
if((path=getcwd(NULL, 0)) == NULL) {
|
if((path=getcwd(NULL, 0)) == NULL) {
|
||||||
@@ -61,7 +66,7 @@ void *thread_mid(){
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
if (status & STATUS_RELOAD_DIRECTORY) {
|
if (local_status & STATUS_RELOAD_DIRECTORY) {
|
||||||
unsigned long i = 0;
|
unsigned long i = 0;
|
||||||
for (i = 0; i < mid_file_count; i++) {
|
for (i = 0; i < mid_file_count; i++) {
|
||||||
free(mid_content[i].file_name);
|
free(mid_content[i].file_name);
|
||||||
@@ -90,8 +95,9 @@ void *thread_mid(){
|
|||||||
pthread_mutex_unlock(&mutex_selection);
|
pthread_mutex_unlock(&mutex_selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btm_status = local_status;
|
||||||
pthread_cond_signal(&cond_rgt);
|
pthread_cond_signal(&cond_rgt);
|
||||||
pthread_cond_signal(&cond_lft);
|
pthread_cond_signal(&cond_btm);
|
||||||
|
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
@@ -104,6 +110,7 @@ void *thread_lft(){
|
|||||||
while(!(status & STATUS_QUIT_PROGRAM)){
|
while(!(status & STATUS_QUIT_PROGRAM)){
|
||||||
pthread_mutex_lock(&mutex_lft);
|
pthread_mutex_lock(&mutex_lft);
|
||||||
pthread_cond_wait(&cond_lft, &mutex_lft);
|
pthread_cond_wait(&cond_lft, &mutex_lft);
|
||||||
|
unsigned int local_status = status;
|
||||||
|
|
||||||
char *path;
|
char *path;
|
||||||
if((path=getcwd(NULL, 0)) == NULL) {
|
if((path=getcwd(NULL, 0)) == NULL) {
|
||||||
@@ -115,7 +122,7 @@ void *thread_lft(){
|
|||||||
path[strrchr(path, '/')-path] = '\0';
|
path[strrchr(path, '/')-path] = '\0';
|
||||||
path[0] = '/';
|
path[0] = '/';
|
||||||
|
|
||||||
if (status & STATUS_RELOAD_DIRECTORY) {
|
if (local_status & STATUS_RELOAD_DIRECTORY) {
|
||||||
lft_file_count = get_dir_size(path);
|
lft_file_count = get_dir_size(path);
|
||||||
free(lft_content);
|
free(lft_content);
|
||||||
lft_content = malloc(lft_file_count * sizeof(file));
|
lft_content = malloc(lft_file_count * sizeof(file));
|
||||||
@@ -143,7 +150,7 @@ void *thread_rgt(){
|
|||||||
char *path;
|
char *path;
|
||||||
if (mid_file_count != 0) {
|
if (mid_file_count != 0) {
|
||||||
path = malloc(strlen(mid_content[selected_file_current].file_name) + 1);
|
path = malloc(strlen(mid_content[selected_file_current].file_name) + 1);
|
||||||
strcpy(path, mid_content[selected_file_current].file_name);
|
memcpy(path, mid_content[selected_file_current].file_name, strlen(mid_content[selected_file_current].file_name)+1);
|
||||||
} else {
|
} else {
|
||||||
path = malloc(sizeof(char));
|
path = malloc(sizeof(char));
|
||||||
path[0] = '\0';
|
path[0] = '\0';
|
||||||
@@ -154,8 +161,10 @@ void *thread_rgt(){
|
|||||||
pthread_mutex_unlock(&mutex_mid);
|
pthread_mutex_unlock(&mutex_mid);
|
||||||
|
|
||||||
if (mid_content[selected_file_current].permissions & S_IRUSR) {
|
if (mid_content[selected_file_current].permissions & S_IRUSR) {
|
||||||
if (file_current.file_type == FILE_TYPE_DIR || file_current.file_type == FILE_TYPE_SYMLINK) {
|
if (file_current.file_type &= FILE_TYPE_DIR) {
|
||||||
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||||
images_clear();
|
images_clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
unsigned long i = 0;
|
unsigned long i = 0;
|
||||||
for (i = 0; i < rgt_file_count; i++) {
|
for (i = 0; i < rgt_file_count; i++) {
|
||||||
@@ -174,7 +183,7 @@ void *thread_rgt(){
|
|||||||
free(rgt_buffer);
|
free(rgt_buffer);
|
||||||
rgt_buffer = malloc(sizeof(char));
|
rgt_buffer = malloc(sizeof(char));
|
||||||
rgt_buffer[0] = '\0';
|
rgt_buffer[0] = '\0';
|
||||||
} else {
|
} else if ((status & STATUS_DELTA_TIME) != STATUS_DELTA_TIME) {
|
||||||
|
|
||||||
unsigned long i = 0;
|
unsigned long i = 0;
|
||||||
for (i = 0; i < rgt_file_count; i++) {
|
for (i = 0; i < rgt_file_count; i++) {
|
||||||
@@ -227,7 +236,8 @@ void *thread_top(){
|
|||||||
top_width = sizeof("cannot open directory");
|
top_width = sizeof("cannot open directory");
|
||||||
top_buffer = "cannot open directory";
|
top_buffer = "cannot open directory";
|
||||||
} else {
|
} else {
|
||||||
top_buffer = getcwd(NULL, 0);
|
top_buffer = malloc(strlen(path)+1);
|
||||||
|
memcpy(top_buffer, path, strlen(path)+1);
|
||||||
top_width = strlen(top_buffer);
|
top_width = strlen(top_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,16 +247,104 @@ void *thread_top(){
|
|||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
}
|
}
|
||||||
void *thread_btm(){
|
void *thread_btm(){
|
||||||
|
char *path = NULL;
|
||||||
|
char *ui_btm_right_block = malloc(sizeof(char));
|
||||||
|
unsigned int ui_btm_right_block_size = 0;
|
||||||
|
unsigned int buffer_width = 0;
|
||||||
|
|
||||||
while(!(status & STATUS_QUIT_PROGRAM)){
|
while(!(status & STATUS_QUIT_PROGRAM)){
|
||||||
pthread_mutex_lock(&mutex_btm);
|
pthread_mutex_lock(&mutex_btm);
|
||||||
pthread_cond_wait(&cond_btm, &mutex_btm);
|
pthread_cond_wait(&cond_btm, &mutex_btm);
|
||||||
|
unsigned int local_status = btm_status;
|
||||||
|
|
||||||
|
|
||||||
free(btm_buffer);
|
if (local_status & (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY)) {
|
||||||
int buffer_width = terminal_width;
|
/*{{{ parse storage info; the fold of shame*/
|
||||||
btm_buffer = malloc(buffer_width);
|
pthread_mutex_lock(&mutex_mid);
|
||||||
memset(btm_buffer, 0, buffer_width);
|
unsigned long i;
|
||||||
|
float total_dir_size = 0;
|
||||||
|
for(i = 0; i < mid_file_count; i++) {
|
||||||
|
if ((mid_content[i].file_type & (FILE_TYPE_DIR)) != FILE_TYPE_DIR) {
|
||||||
|
total_dir_size += mid_content[i].file_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&mutex_mid);
|
||||||
|
|
||||||
|
|
||||||
|
if (path != NULL) {
|
||||||
|
/* sometimes NULL remains, need to do deeper analysis soon */
|
||||||
|
free(path);
|
||||||
|
path = NULL;
|
||||||
|
} else {
|
||||||
|
volatile static int debug_thread_btm;
|
||||||
|
debug_thread_btm++;
|
||||||
|
}
|
||||||
|
free(ui_btm_right_block);
|
||||||
|
|
||||||
|
path = getcwd(NULL, 0);
|
||||||
|
struct statvfs fs;
|
||||||
|
statvfs(path, &fs);
|
||||||
|
|
||||||
|
float disk_size_free = fs.f_bsize * fs.f_bavail;
|
||||||
|
|
||||||
|
float parsed_number[2] = { 0 };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char size_index[2] = { 0 };
|
||||||
|
if (total_dir_size > 1) {
|
||||||
|
size_index[0] = -1;
|
||||||
|
while (total_dir_size > 1 && size_index[0] < size_unit_count) {
|
||||||
|
parsed_number[0]=total_dir_size;
|
||||||
|
size_index[0]++;
|
||||||
|
total_dir_size /= 1024;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
size_index[0] = 0;
|
||||||
|
parsed_number[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disk_size_free > 1) {
|
||||||
|
size_index[1] = -1;
|
||||||
|
while (disk_size_free > 1 && size_index[1] < size_unit_count) {
|
||||||
|
parsed_number[1]=disk_size_free;
|
||||||
|
size_index[1]++;
|
||||||
|
disk_size_free /= 1024;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
size_index[1] = 0;
|
||||||
|
}
|
||||||
|
if (size_index[0] > 0 && size_index[1] > 0) {
|
||||||
|
ui_btm_right_block_size = snprintf(NULL, 0, "%0.2lf%c %s %0.2lf%c %s", parsed_number[0], size_unit[(unsigned)size_index[0]], ui_btm_current_dir_size, parsed_number[1], size_unit[(unsigned)size_index[1]], ui_btm_text_storage_left)+1;
|
||||||
|
ui_btm_right_block = malloc(ui_btm_right_block_size);
|
||||||
|
sprintf(ui_btm_right_block, "%0.2lf%c %s %0.2lf%c %s", parsed_number[0], size_unit[(unsigned)size_index[0]], ui_btm_current_dir_size, parsed_number[1], size_unit[(unsigned)size_index[1]], ui_btm_text_storage_left);
|
||||||
|
} else if (size_index[0] <= 0 && size_index[1] > 0) {
|
||||||
|
ui_btm_right_block_size = snprintf(NULL, 0, "%0.0lf%c %s %0.2lf%c %s", parsed_number[0], size_unit[(unsigned)size_index[0]], ui_btm_current_dir_size, parsed_number[1], size_unit[(unsigned)size_index[1]], ui_btm_text_storage_left)+1;
|
||||||
|
ui_btm_right_block = malloc(ui_btm_right_block_size);
|
||||||
|
sprintf(ui_btm_right_block, "%0.0lf%c %s %0.2lf%c %s", parsed_number[0], size_unit[(unsigned)size_index[0]], ui_btm_current_dir_size, parsed_number[1], size_unit[(unsigned)size_index[1]], ui_btm_text_storage_left);
|
||||||
|
} else if (size_index[0] > 0 && size_index[1] <= 0) {
|
||||||
|
ui_btm_right_block_size = snprintf(NULL, 0, "%0.2lf%c %s %0.0lf%c %s", parsed_number[0], size_unit[(unsigned)size_index[0]], ui_btm_current_dir_size, parsed_number[1], size_unit[(unsigned)size_index[1]], ui_btm_text_storage_left)+1;
|
||||||
|
ui_btm_right_block = malloc(ui_btm_right_block_size);
|
||||||
|
sprintf(ui_btm_right_block, "%0.2lf%c %s %0.0lf%c %s", parsed_number[0], size_unit[(unsigned)size_index[0]], ui_btm_current_dir_size, parsed_number[1], size_unit[(unsigned)size_index[1]], ui_btm_text_storage_left);
|
||||||
|
} else {
|
||||||
|
ui_btm_right_block_size = snprintf(NULL, 0, "%0.0lf%c %s %0.0lf%c %s", parsed_number[0], size_unit[(unsigned)size_index[0]], ui_btm_current_dir_size, parsed_number[1], size_unit[(unsigned)size_index[1]], ui_btm_text_storage_left)+1;
|
||||||
|
ui_btm_right_block = malloc(ui_btm_right_block_size);
|
||||||
|
sprintf(ui_btm_right_block, "%0.0lf%c %s %0.0lf%c %s", parsed_number[0], size_unit[(unsigned)size_index[0]], ui_btm_current_dir_size, parsed_number[1], size_unit[(unsigned)size_index[1]], ui_btm_text_storage_left);
|
||||||
|
}
|
||||||
|
/*}}}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buffer_width != terminal_width) {
|
||||||
|
buffer_width = terminal_width;
|
||||||
|
free(btm_buffer);
|
||||||
|
btm_buffer = malloc(buffer_width);
|
||||||
|
memset(btm_buffer, ' ', buffer_width/2);
|
||||||
|
}
|
||||||
|
memset(btm_buffer + (buffer_width/2), ' ', buffer_width/2);
|
||||||
|
btm_buffer[buffer_width] = '\0';
|
||||||
|
|
||||||
|
memcpy(btm_buffer + buffer_width - ui_btm_right_block_size, ui_btm_right_block, ui_btm_right_block_size);
|
||||||
|
|
||||||
btm_buffer[0] = (S_ISDIR(mid_content[selected_file_current].permissions)) ? 'd' : '-';
|
btm_buffer[0] = (S_ISDIR(mid_content[selected_file_current].permissions)) ? 'd' : '-';
|
||||||
btm_buffer[1] = (mid_content[selected_file_current].permissions & S_IRUSR) ? 'r' : '-';
|
btm_buffer[1] = (mid_content[selected_file_current].permissions & S_IRUSR) ? 'r' : '-';
|
||||||
btm_buffer[2] = (mid_content[selected_file_current].permissions & S_IWUSR) ? 'w' : '-';
|
btm_buffer[2] = (mid_content[selected_file_current].permissions & S_IWUSR) ? 'w' : '-';
|
||||||
@@ -259,6 +357,7 @@ void *thread_btm(){
|
|||||||
btm_buffer[9] = (mid_content[selected_file_current].permissions & S_IXOTH) ? 'x' : '-';
|
btm_buffer[9] = (mid_content[selected_file_current].permissions & S_IXOTH) ? 'x' : '-';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&mutex_btm);
|
pthread_mutex_unlock(&mutex_btm);
|
||||||
}
|
}
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
|
|||||||
6
window.c
6
window.c
@@ -48,7 +48,7 @@ void window_top(WINDOW *win){
|
|||||||
status |= STATUS_UPDATE_SCREEN_0;
|
status |= STATUS_UPDATE_SCREEN_0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void window_btm(WINDOW *win){
|
void window_btm(WINDOW *win, char force_render){
|
||||||
werase(win);
|
werase(win);
|
||||||
|
|
||||||
if (pthread_mutex_trylock(&mutex_btm) == 0) {
|
if (pthread_mutex_trylock(&mutex_btm) == 0) {
|
||||||
@@ -58,6 +58,10 @@ void window_btm(WINDOW *win){
|
|||||||
pthread_mutex_unlock(&mutex_btm);
|
pthread_mutex_unlock(&mutex_btm);
|
||||||
/*the printing of the input char is done in user_interactions*/
|
/*the printing of the input char is done in user_interactions*/
|
||||||
/*the printing of all possible inputs are done in user_interactions */
|
/*the printing of all possible inputs are done in user_interactions */
|
||||||
|
} else if (force_render) {
|
||||||
|
/*force_render is used in stuff like open_with, search, and other functions that take over win_b,
|
||||||
|
* while needing to avoid possible conflicts like thread_btm itself*/
|
||||||
|
mvwprintw(win, 0, 0, "%s", btm_buffer);
|
||||||
} else {
|
} else {
|
||||||
mvwaddstr(win, 0, terminal_width/2, "LOADING");
|
mvwaddstr(win, 0, terminal_width/2, "LOADING");
|
||||||
status |= STATUS_UPDATE_SCREEN_0;
|
status |= STATUS_UPDATE_SCREEN_0;
|
||||||
|
|||||||
2
window.h
2
window.h
@@ -1,7 +1,7 @@
|
|||||||
#include "window.c"
|
#include "window.c"
|
||||||
|
|
||||||
void window_top(WINDOW *win);
|
void window_top(WINDOW *win);
|
||||||
void window_btm(WINDOW *win);
|
void window_btm(WINDOW *win, char force_render);
|
||||||
void window_lft(WINDOW *win);
|
void window_lft(WINDOW *win);
|
||||||
void window_mid(WINDOW *win);
|
void window_mid(WINDOW *win);
|
||||||
void window_rgt(WINDOW *win);
|
void window_rgt(WINDOW *win);
|
||||||
|
|||||||
Reference in New Issue
Block a user