mirror of
https://gittea.dev/nova/th.git
synced 2025-10-22 02:40:15 -04:00
Compare commits
5 Commits
3fa16fd8b2
...
main
Author | SHA1 | Date | |
---|---|---|---|
![]() |
df726e2f32 | ||
![]() |
140457e4b7 | ||
![]() |
23654741bc | ||
![]() |
fa544204ba | ||
![]() |
61023ce42e |
3
config.h
3
config.h
@@ -48,6 +48,7 @@ static const binding key_binding[] = {
|
|||||||
{ "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" },
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ 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" },
|
||||||
{ "oe", not_implemented, NULL, "order extension" },
|
{ "oe", order_by, sort_extension, "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" },
|
||||||
{ "or", order_by, sort_random, "order random" },
|
{ "or", order_by, sort_random, "order random" },
|
||||||
|
@@ -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
|
||||||
|
|
||||||
|
19
dir.c
19
dir.c
@@ -54,7 +54,7 @@ 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){
|
||||||
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 {
|
||||||
@@ -147,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 {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +246,7 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
|||||||
* example input: aaaaaaaa.txt
|
* example input: aaaaaaaa.txt
|
||||||
* example output: aaa~.txt
|
* example output: aaa~.txt
|
||||||
* if no extension is found, the name will truncate */
|
* if no extension is found, the name will truncate */
|
||||||
char *file_name;
|
char *file_name = NULL;
|
||||||
unsigned long printable_size = (offset_back - is_selected - offset_front);
|
unsigned long printable_size = (offset_back - is_selected - offset_front);
|
||||||
if (strlen(dir_content[i].file_name) > printable_size) {
|
if (strlen(dir_content[i].file_name) > printable_size) {
|
||||||
char *extension = strrchr(dir_content[i].file_name, '.');
|
char *extension = strrchr(dir_content[i].file_name, '.');
|
||||||
@@ -312,8 +315,14 @@ 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 {
|
||||||
|
119
interactions.c
119
interactions.c
@@ -1,6 +1,7 @@
|
|||||||
#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 <unistd.h>
|
||||||
|
|
||||||
@@ -42,11 +43,10 @@ extern time_t *seed;
|
|||||||
char search_buffer[255];
|
char search_buffer[255];
|
||||||
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 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 int (*order_func)();
|
extern int (*order_func)();
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ 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++;
|
||||||
@@ -83,6 +83,8 @@ void user_interactions() {
|
|||||||
}
|
}
|
||||||
binding_pass = 0;
|
binding_pass = 0;
|
||||||
status |= STATUS_UPDATE_SCREEN_0;
|
status |= STATUS_UPDATE_SCREEN_0;
|
||||||
|
} else {
|
||||||
|
timeout(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,7 +121,7 @@ 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)) {
|
||||||
@@ -167,24 +169,11 @@ 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;
|
||||||
}
|
}
|
||||||
@@ -198,7 +187,7 @@ void select_all(){
|
|||||||
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++;
|
||||||
@@ -211,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++;
|
||||||
@@ -228,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 */
|
||||||
@@ -561,7 +550,7 @@ void makefile(){
|
|||||||
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
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||||
@@ -574,14 +563,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;
|
||||||
@@ -638,7 +627,7 @@ 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);
|
free(seed);
|
||||||
@@ -649,7 +638,7 @@ void order_by(int passes, int index){
|
|||||||
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);
|
pthread_mutex_lock(&mutex_btm);
|
||||||
|
|
||||||
@@ -737,7 +726,7 @@ void cmd_on_selected(int passes, int index){
|
|||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mutex_btm);
|
pthread_mutex_unlock(&mutex_btm);
|
||||||
}
|
}
|
||||||
void yank_text(int passes, int index){
|
void yank_text(unsigned long passes, int index){
|
||||||
(void)passes;
|
(void)passes;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
if (strncmp((char*)key_binding[index].black_magic, "path", 4) == 0) {
|
if (strncmp((char*)key_binding[index].black_magic, "path", 4) == 0) {
|
||||||
@@ -758,17 +747,18 @@ void yank_text(int passes, int index){
|
|||||||
}
|
}
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
void yank_file(int passes, int index){
|
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;
|
||||||
@@ -785,7 +775,7 @@ void yank_file(int passes, int index){
|
|||||||
strcpy(*yank_files.list, mid_content[selected_file_current].file_name);
|
strcpy(*yank_files.list, 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);
|
strcpy(*yank_files.list, mid_content[i].file_name);
|
||||||
@@ -809,32 +799,41 @@ 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(255);
|
||||||
char *line = NULL;
|
FILE *cmd_open;
|
||||||
size_t size = 0;
|
while (1) {
|
||||||
FILE *cmd_open;
|
cmd_open = popen(cmd, "r");
|
||||||
while (1) {
|
if (fgets(line, 255, cmd_open) == 0) {
|
||||||
cmd_open = popen(cmd, "r");
|
break;
|
||||||
int val = getline(&line, &size, cmd_open);
|
|
||||||
|
|
||||||
if (pclose(cmd_open) == 0) {
|
|
||||||
break;
|
|
||||||
} else if (val == 0 || val == -1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cmd = concat(cmd, "_");
|
|
||||||
}
|
}
|
||||||
|
if (strstr(line, "are the same file")) {
|
||||||
|
cmd[strlen(cmd)-strlen(" 2>&1")] = '\0';
|
||||||
|
cmd = concat(cmd, "_");
|
||||||
|
cmd = concat(cmd, " 2>&1");
|
||||||
|
} 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;
|
||||||
@@ -936,3 +935,25 @@ void search_previous(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void jmp_file_index(){
|
||||||
|
char *index = malloc(255);
|
||||||
|
memset(index, ' ', 255);
|
||||||
|
index[254] = '\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();
|
||||||
|
}
|
||||||
|
@@ -9,9 +9,9 @@ void quit_program();
|
|||||||
void toggle_selection();
|
void toggle_selection();
|
||||||
void select_all();
|
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();
|
||||||
@@ -21,14 +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_text(int passes, int index);
|
void yank_text(unsigned long passes, int index);
|
||||||
void yank_file(int 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();
|
||||||
|
4
main.c
4
main.c
@@ -81,7 +81,7 @@ 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) {
|
||||||
@@ -101,7 +101,7 @@ int main(){
|
|||||||
time(&dt);
|
time(&dt);
|
||||||
if (dt - t >= SETTINGS_RELOAD_DIR_DELTA) {
|
if (dt - t >= SETTINGS_RELOAD_DIR_DELTA) {
|
||||||
time(&t);
|
time(&t);
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY | STATUS_DELTA_TIME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
55
sorting.c
55
sorting.c
@@ -144,13 +144,13 @@ int sort_type(const void *file0, const void *file1){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((file*)file0)->file_type == ((file*)file1)->file_type) {
|
if (((file*)file0)->file_type > ((file*)file1)->file_type) {
|
||||||
/*somehow relying on the else below, occasionaly trips either one of the checked for conditions*/
|
|
||||||
return strcasecmp(((file*)file0)->file_name, ((file*)file1)->file_name);
|
|
||||||
} else if (((file*)file0)->file_type > ((file*)file1)->file_type) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
} else if (((file*)file0)->file_type < ((file*)file1)->file_type) {
|
||||||
return 1;
|
return 1;
|
||||||
|
} else {
|
||||||
|
return sort_natural(file0, file1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int sort_size(const void *file0, const void *file1){
|
int sort_size(const void *file0, const void *file1){
|
||||||
|
|
||||||
@@ -161,10 +161,43 @@ int sort_size(const void *file0, const void *file1){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((file*)file0)->file_size == ((file*)file1)->file_size) {
|
if (((file*)file0)->file_size > ((file*)file1)->file_size) {
|
||||||
return strcasecmp(((file*)file0)->file_name, ((file*)file1)->file_name);
|
|
||||||
} else if (((file*)file0)->file_size > ((file*)file1)->file_size) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
} else if (((file*)file0)->file_size < ((file*)file1)->file_size) {
|
||||||
return 1;
|
return 1;
|
||||||
|
} else {
|
||||||
|
return sort_natural(file0, file1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int sort_extension(const void *file0, const void *file1){
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
13
threading.c
13
threading.c
@@ -183,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++) {
|
||||||
@@ -247,7 +247,7 @@ void *thread_top(){
|
|||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
}
|
}
|
||||||
void *thread_btm(){
|
void *thread_btm(){
|
||||||
char *path = malloc(sizeof(char));
|
char *path = NULL;
|
||||||
char *ui_btm_right_block = malloc(sizeof(char));
|
char *ui_btm_right_block = malloc(sizeof(char));
|
||||||
unsigned int ui_btm_right_block_size = 0;
|
unsigned int ui_btm_right_block_size = 0;
|
||||||
unsigned int buffer_width = 0;
|
unsigned int buffer_width = 0;
|
||||||
@@ -271,7 +271,14 @@ void *thread_btm(){
|
|||||||
pthread_mutex_unlock(&mutex_mid);
|
pthread_mutex_unlock(&mutex_mid);
|
||||||
|
|
||||||
|
|
||||||
free(path);
|
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);
|
free(ui_btm_right_block);
|
||||||
|
|
||||||
path = getcwd(NULL, 0);
|
path = getcwd(NULL, 0);
|
||||||
|
Reference in New Issue
Block a user