very basic and no good file hover implemented
This commit is contained in:
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);
|
||||
|
Reference in New Issue
Block a user