1
0
mirror of https://gittea.dev/nova/th.git synced 2026-01-30 08:40:10 -05:00

small changes

This commit is contained in:
nova
2026-01-17 17:53:52 +01:00
parent 8734fa6ae4
commit f3a39b0df0
4 changed files with 16 additions and 21 deletions

View File

@@ -39,7 +39,7 @@ static const extension file_extension_default_cmd[] = {
{ ".csv", "$EDITOR"}, { ".csv", "$EDITOR"},
}; };
static const binding key_binding[] = { static const binding key_binding[] = {
/*key action blackmagic comment*/ /*key action blackmagic comment*/
/*you cannot add bindings that include other bindings in its entirety /*you cannot add bindings that include other bindings in its entirety
* possible: mk, mf * possible: mk, mf
* not possible: gg, ggg * not possible: gg, ggg

3
dir.c
View File

@@ -254,7 +254,7 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
file_name[printable_size + strlen(extension)-1] = '\0'; file_name[printable_size + strlen(extension)-1] = '\0';
file_name[printable_size - 2] = '~'; file_name[printable_size - 2] = '~';
} else { } else {
file_name = malloc(printable_size-1); file_name = malloc(printable_size);
memcpy(file_name, dir_content[i].file_name, printable_size); memcpy(file_name, dir_content[i].file_name, printable_size);
file_name[printable_size-2] = '~'; file_name[printable_size-2] = '~';
file_name[printable_size-1] = '\0'; file_name[printable_size-1] = '\0';
@@ -323,6 +323,7 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
char update_selected_file(){ char update_selected_file(){
char ret = -1; /* -1 on empty or inaccessible file, 0 on unchanged file, 1 on changed file */ char ret = -1; /* -1 on empty or inaccessible file, 0 on unchanged file, 1 on changed file */
if (selected_file_current >= mid_file_count) { if (selected_file_current >= mid_file_count) {
selected_file_current = mid_file_count-1; selected_file_current = mid_file_count-1;
} }

View File

@@ -201,7 +201,7 @@ void move_up(unsigned long passes){
current_dir->selected_file_current = selected_file_current; current_dir->selected_file_current = selected_file_current;
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK); status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_0);
pthread_mutex_unlock(&mutex_selection); pthread_mutex_unlock(&mutex_selection);
} }
void move_left(unsigned long passes){ void move_left(unsigned long passes){
@@ -217,7 +217,9 @@ void move_left(unsigned long passes){
selected_file_current = dir_get_selected_file_current(); selected_file_current = dir_get_selected_file_current();
} }
} }
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY); update_selected_file();
current_dir->selected_file_current = selected_file_current;
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY);
} }
void move_right(){ void move_right(){
if (mid_content->file_name[0] == '\0') { if (mid_content->file_name[0] == '\0') {
@@ -248,7 +250,7 @@ void move_right(){
} }
curs_set(1); /*for some reason, 1 here turns it invisible once again */ curs_set(1); /*for some reason, 1 here turns it invisible once again */
match = 1; match = 1;
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL); status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY);
break; break;
} }
} }
@@ -262,7 +264,7 @@ void move_right(){
/*do nothing*/ /*do nothing*/
} }
curs_set(1); /*for some reason, 1 here turns it invisible once again */ curs_set(1); /*for some reason, 1 here turns it invisible once again */
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL); status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY);
break; break;
} }
@@ -271,11 +273,11 @@ void move_right(){
free(mime); free(mime);
} }
update_selected_file(); update_selected_file();
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY); status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY);
} }
void toggle_hidden_files(){ 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_RELOAD_FULL | STATUS_RELOAD_DIRECTORY);
} }
void toggle_selection(){ void toggle_selection(){
pthread_mutex_lock(&mutex_selection); pthread_mutex_lock(&mutex_selection);
@@ -291,7 +293,7 @@ void jump_bottom(){
selected_file_current = 0 - 1; selected_file_current = 0 - 1;
update_selected_file(); update_selected_file();
current_dir->selected_file_current = selected_file_current; current_dir->selected_file_current = selected_file_current;
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK); status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_0);
pthread_mutex_unlock(&mutex_selection); pthread_mutex_unlock(&mutex_selection);
} }
void jump_top(){ void jump_top(){

View File

@@ -93,9 +93,7 @@ void *thread_mid(){
mid_file_count = 0; mid_file_count = 0;
} }
pthread_mutex_lock(&mutex_selection);
update_selected_file(); update_selected_file();
pthread_mutex_unlock(&mutex_selection);
} }
btm_status = local_status; btm_status = local_status;
@@ -157,18 +155,11 @@ void *thread_rgt(){
pthread_mutex_lock(&mutex_mid); pthread_mutex_lock(&mutex_mid);
char *path; char *path = mid_content[selected_file_current].file_name;
if (mid_file_count != 0) {
path = malloc(strlen(mid_content[selected_file_current].file_name) + 1);
memcpy(path, mid_content[selected_file_current].file_name, strlen(mid_content[selected_file_current].file_name)+1);
} else {
path = malloc(sizeof(char));
path[0] = '\0';
}
memcpy(&file_current, &mid_content[selected_file_current], sizeof(file)); memcpy(&file_current, &mid_content[selected_file_current], sizeof(file));
pthread_mutex_unlock(&mutex_mid); pthread_mutex_unlock(&mutex_mid);
if (mid_content[selected_file_current].permissions & S_IRUSR) { if (file_current.permissions & S_IRUSR) {
if (file_current.file_type &= FILE_TYPE_DIR) { if (file_current.file_type &= FILE_TYPE_DIR) {
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0 #if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
images_clear(); images_clear();
@@ -229,8 +220,9 @@ void *thread_rgt(){
rgt_buffer = malloc(sizeof(char)); rgt_buffer = malloc(sizeof(char));
rgt_buffer[0] = '\0'; rgt_buffer[0] = '\0';
} }
/*
free(path); free(path);
*/
pthread_mutex_unlock(&mutex_rgt); pthread_mutex_unlock(&mutex_rgt);
} }