very basic and no good file hover implemented
This commit is contained in:
parent
2b52329904
commit
0574732a69
@ -1,10 +1,14 @@
|
||||
#include <curses.h>
|
||||
#include <pthread.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include "defines.h"
|
||||
|
||||
|
||||
extern unsigned int file_modifiers;
|
||||
unsigned long selected_file_current;
|
||||
unsigned long selected_file_last;
|
||||
extern pthread_mutex_t mutex_selection;
|
||||
|
||||
void user_interactions(char *input, unsigned int *status, unsigned int *settings) {
|
||||
if (*input == 'q') {
|
||||
@ -23,7 +27,19 @@ void user_interactions(char *input, unsigned int *status, unsigned int *settings
|
||||
} else if (*input == 'h') {
|
||||
chdir("..");
|
||||
*status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK);
|
||||
|
||||
} else if (*input == 'n') {
|
||||
pthread_mutex_lock(&mutex_selection);
|
||||
/* capping the maximum file is done inside thread_mid */
|
||||
selected_file_current++;
|
||||
*status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK);
|
||||
pthread_mutex_unlock(&mutex_selection);
|
||||
} else if (*input == 't') {
|
||||
pthread_mutex_lock(&mutex_selection);
|
||||
if (selected_file_current != 0) {
|
||||
selected_file_current--;
|
||||
}
|
||||
*status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK);
|
||||
pthread_mutex_unlock(&mutex_selection);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
25
threading.c
25
threading.c
@ -12,22 +12,24 @@ pthread_mutex_t mutex_btm;
|
||||
pthread_mutex_t mutex_lft;
|
||||
pthread_mutex_t mutex_mid;
|
||||
pthread_mutex_t mutex_rgt;
|
||||
pthread_mutex_t mutex_selection;
|
||||
|
||||
/* contains entire directory as 2d array
|
||||
* may be changed in future to only include parts of the dir (currently includes entire dir) */
|
||||
file *rgt_content;
|
||||
file *mid_content;
|
||||
file *lft_content;
|
||||
|
||||
char *top_content; /* current path */
|
||||
|
||||
unsigned long rgt_file_count;
|
||||
unsigned long mid_file_count;
|
||||
unsigned long lft_file_count;
|
||||
unsigned long top_width;
|
||||
|
||||
|
||||
|
||||
|
||||
extern unsigned int status;
|
||||
extern unsigned long selected_file_current;
|
||||
extern unsigned long selected_file_last;
|
||||
|
||||
void *thread_mid(void *data){
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
@ -48,6 +50,18 @@ void *thread_mid(void *data){
|
||||
memset(mid_content, ' ', mid_file_count * sizeof(file));
|
||||
get_dir_content(path, &mid_file_count, mid_content);
|
||||
|
||||
|
||||
pthread_mutex_lock(&mutex_selection);
|
||||
if (selected_file_current >= mid_file_count) {
|
||||
selected_file_current = mid_file_count-1;
|
||||
}
|
||||
mid_content[selected_file_current].status = FILE_STATUS_HOVER;
|
||||
if (selected_file_current != selected_file_last) {
|
||||
mid_content[selected_file_last].status &= ~FILE_STATUS_HOVER;
|
||||
}
|
||||
selected_file_last = selected_file_current;
|
||||
pthread_mutex_unlock(&mutex_selection);
|
||||
|
||||
}
|
||||
free(path);
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
@ -117,11 +131,12 @@ void threading_init(){
|
||||
|
||||
top_content = malloc(sizeof(char));
|
||||
|
||||
|
||||
|
||||
pthread_mutex_init(&mutex_top, NULL);
|
||||
pthread_mutex_init(&mutex_mid, NULL);
|
||||
pthread_mutex_init(&mutex_lft, NULL);
|
||||
pthread_mutex_init(&mutex_selection, NULL);
|
||||
selected_file_current = 0;
|
||||
selected_file_last = 0;
|
||||
}
|
||||
void threading_free(){
|
||||
free(rgt_content);
|
||||
|
Loading…
x
Reference in New Issue
Block a user