improvenments to rendering and start of thread_btm
This commit is contained in:
40
threading.c
40
threading.c
@@ -36,12 +36,15 @@ unsigned long top_width;
|
||||
|
||||
unsigned long selected_file_current=0;
|
||||
unsigned long selected_file_last=0;
|
||||
unsigned int status_mid;
|
||||
extern unsigned int status;
|
||||
extern unsigned int terminal_width;
|
||||
|
||||
void *thread_rgt(void *data);
|
||||
|
||||
void *thread_mid(void *data){
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
status_mid = 0;
|
||||
|
||||
|
||||
char *path;
|
||||
@@ -77,6 +80,7 @@ void *thread_mid(void *data){
|
||||
file_current->file_name_width = mid_content[selected_file_current].file_name_width;
|
||||
file_current->file_size = mid_content[selected_file_current].file_size;
|
||||
file_current->file_type = mid_content[selected_file_current].file_type;
|
||||
file_current->permissions = mid_content[selected_file_current].permissions;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -84,6 +88,7 @@ void *thread_mid(void *data){
|
||||
|
||||
}
|
||||
free(path);
|
||||
status_mid=1;
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
@@ -119,7 +124,14 @@ void *thread_lft(void *data){
|
||||
void *thread_rgt(void *data){
|
||||
pthread_mutex_lock(&mutex_rgt);
|
||||
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
while(1) {
|
||||
if (!pthread_mutex_trylock(&mutex_mid)) {
|
||||
if (status_mid == 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(rgt_content);
|
||||
rgt_content = malloc(sizeof(file));
|
||||
rgt_content[0].file_name = malloc(file_current->file_name_width + 1);
|
||||
@@ -173,7 +185,33 @@ void *thread_top(void *data){
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
void *thread_btm(void *data){
|
||||
pthread_mutex_lock(&mutex_btm);
|
||||
|
||||
while(1) {
|
||||
if (!pthread_mutex_trylock(&mutex_mid)) {
|
||||
if (status_mid == 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
|
||||
free(btm_buffer);
|
||||
int buffer_width = terminal_width;
|
||||
btm_buffer = malloc(buffer_width);
|
||||
memset(btm_buffer, 0, buffer_width);
|
||||
btm_buffer[0] = (file_current->permissions & S_IRUSR) ? 'r' : '-';
|
||||
btm_buffer[1] = (file_current->permissions & S_IWUSR) ? 'w' : '-';
|
||||
btm_buffer[2] = (file_current->permissions & S_IXUSR) ? 'x' : '-';
|
||||
btm_buffer[3] = (file_current->permissions & S_IRGRP) ? 'r' : '-';
|
||||
btm_buffer[4] = (file_current->permissions & S_IWGRP) ? 'w' : '-';
|
||||
btm_buffer[5] = (file_current->permissions & S_IXGRP) ? 'x' : '-';
|
||||
btm_buffer[6] = (file_current->permissions & S_IROTH) ? 'r' : '-';
|
||||
btm_buffer[7] = (file_current->permissions & S_IWOTH) ? 'w' : '-';
|
||||
btm_buffer[8] = (file_current->permissions & S_IXOTH) ? 'x' : '-';
|
||||
|
||||
|
||||
pthread_mutex_unlock(&mutex_btm);
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user