1
0
mirror of https://gittea.dev/nova/th.git synced 2025-10-21 10:20:15 -04:00

refractoring, fixed enter_shell

This commit is contained in:
nova
2025-08-18 22:01:16 +02:00
parent f25768d522
commit 3f90802663
6 changed files with 31 additions and 7 deletions

View File

@@ -66,6 +66,7 @@ static const binding key_binding[] = {
{ "gD", jump_to_dir, "$HOME/Downloads", "jump to $HOME/Downloads" },
{ "gd", jump_to_dir, "/dev", "jump to /dev" },
{ "ge", jump_to_dir, "/etc", "jump to /etc" },
{ "gp", jump_to_dir, "/etc/portage", "jump to /etc/portage" },
{ "gm", jump_to_dir, "/mnt", "jump to /mnt" },
{ "go", jump_to_dir, "/opt", "jump to /opt" },
{ "gt", jump_to_dir, "/tmp", "jump to /tmp" },

1
dir.c
View File

@@ -336,7 +336,6 @@ void update_selected_file(){
}
void dir_set_selected_file_current(unsigned long selected_file_current){
current_dir->selected_file_current = selected_file_current;
mvwaddch(stdscr, 0,0, selected_file_current + '0');
}
unsigned long dir_get_selected_file_current(){

View File

@@ -523,16 +523,25 @@ void update(){
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
}
void enter_shell(int passes, int index){
(void)passes;
endwin();
if (system(key_binding[index].black_magic) != 0) {
/*do nothing*/
}
initscr();
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
}
void not_implemented(int passes, int index){
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) + strlen("\t"), "is not yet implemented");
(void)passes;
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) + strlen("\t"), "is not yet implemented");
}
void jump_to_dir(int passes, int index){
(void)passes;
char *ch = (char*)key_binding[index].black_magic;
char slash = 0;
unsigned int env_len = 0;
@@ -588,11 +597,14 @@ void jump_to_dir(int passes, int index){
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
}
void order_by(int passes, int index){
(void)passes;
order_func = key_binding[index].black_magic;
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
}
void cmd_on_selected(int passes, int index){
(void)passes;
unsigned int i = 0;
unsigned int hits = 0;
char *file_str = " ";
@@ -675,6 +687,8 @@ void cmd_on_selected(int passes, int index){
}
}
void yank_file(int passes, int index){
(void)passes;
unsigned long i;
if (yank_files.status & YANK_IS_USED) {
free(yank_files.path);

4
main.c
View File

@@ -117,9 +117,9 @@ int main(){
delwin(win_t);
delwin(win_b);
noraw();
endwin();
curs_set(1);
echo();
curs_set(1);
endwin();
return 0;
}

View File

@@ -146,6 +146,8 @@ void *thread_lft(void *data){
}
void *thread_rgt(void *data){
unsigned int status = *(unsigned int*)data;
(void)status;
pthread_mutex_lock(&mutex_rgt);
pthread_mutex_lock(&mutex_wait);
wait_count++;
@@ -206,6 +208,8 @@ void *thread_rgt(void *data){
}
void *thread_top(void *data){
unsigned int status = *(unsigned int*)data;
(void)status;
pthread_mutex_lock(&mutex_top);
free(top_buffer);
@@ -225,6 +229,8 @@ void *thread_top(void *data){
}
void *thread_btm(void *data){
unsigned int status = *(unsigned int*)data;
(void)status;
pthread_mutex_lock(&mutex_btm);
pthread_mutex_lock(&mutex_wait);
wait_count++;

View File

@@ -1,5 +1,9 @@
#include <curses.h>
#ifndef THREADING_GUARD
#define THREADING_GUARD
#include "threading.c"
#endif
void *thread_lft(void *data);
void *thread_mid(void *data);