mirror of
https://gittea.dev/nova/th.git
synced 2026-03-16 15:27:25 -04:00
Compare commits
6 Commits
1f1de78283
...
f53fd66d88
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f53fd66d88 | ||
|
|
7e4ae9bb84 | ||
|
|
36c8524a70 | ||
|
|
99ac76162f | ||
|
|
1d3b71b00f | ||
|
|
84b1c17dd8 |
1
config.h
1
config.h
@@ -93,6 +93,7 @@ static const binding key_binding[] = {
|
||||
{ "ut", cmd_on_selected, "tar -xvf", "unzip tar" },
|
||||
{ "ut", cmd_on_selected, "gzip -d", "unzip gzip" },
|
||||
{ "uz", cmd_on_selected, "unzip ", "unzip zip" },
|
||||
{ "uj", cmd_on_selected, "unzip -O shift-jis", "unzip zip shift-jis" },
|
||||
|
||||
{ "on", order_by, sort_natural, "order natural" },
|
||||
{ "oe", order_by, sort_extension, "order extension" },
|
||||
|
||||
31
dir.c
31
dir.c
@@ -238,30 +238,41 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
||||
|
||||
|
||||
/* shortens the printed file name if it is too long
|
||||
* example input: aaaaaaaa.txt
|
||||
* example input: aaaaaaaa.txt
|
||||
* example output: aaa~.txt
|
||||
* example input: aaaaaaaa.longextension
|
||||
* example output: ~.longe~
|
||||
* if no extension is found, the name will truncate */
|
||||
char *file_name = NULL;
|
||||
unsigned long printable_size = (offset_back - is_selected - offset_front);
|
||||
if (strlen(dir_content[i].file_name) > printable_size) {
|
||||
unsigned long printable_size = offset_back - (is_selected + offset_front);
|
||||
if (strlen(dir_content[i].file_name) >= printable_size) {
|
||||
char *extension = strrchr(dir_content[i].file_name, '.');
|
||||
if (extension && extension != dir_content[i].file_name) {
|
||||
file_name = malloc(printable_size);
|
||||
printable_size -= strlen(extension);
|
||||
file_name = malloc(printable_size+1);
|
||||
|
||||
memcpy(file_name, dir_content[i].file_name, printable_size);
|
||||
memcpy(file_name + printable_size-1, extension, strlen(extension));
|
||||
file_name[printable_size + strlen(extension)-1] = '\0';
|
||||
file_name[printable_size - 2] = '~';
|
||||
/*if the extension is bigger than the filename this is false */
|
||||
if ((&file_name[printable_size - strlen(extension)] - 2) > file_name) {
|
||||
memcpy(file_name, dir_content[i].file_name, (printable_size - strlen(extension)));
|
||||
memcpy(file_name + (printable_size - strlen(extension))-1, extension, strlen(extension)+1);
|
||||
file_name[printable_size - strlen(extension) - 2] = '~';
|
||||
file_name[printable_size] = '\0';
|
||||
} else {
|
||||
memcpy(file_name + 1, extension, printable_size - 1);
|
||||
file_name[0] = '~';
|
||||
file_name[printable_size-2] = '~';
|
||||
file_name[printable_size-1] = '\0';
|
||||
}
|
||||
} else {
|
||||
file_name = malloc(printable_size);
|
||||
memcpy(file_name, dir_content[i].file_name, printable_size);
|
||||
file_name[printable_size-2] = '~';
|
||||
file_name[printable_size-1] = '\0';
|
||||
file_name[printable_size] = '\0';
|
||||
}
|
||||
} else {
|
||||
file_name = malloc(strlen(dir_content[i].file_name)+1);
|
||||
memcpy(file_name, dir_content[i].file_name, strlen(dir_content[i].file_name)+1);
|
||||
memcpy(file_name, dir_content[i].file_name, strlen(dir_content[i].file_name));
|
||||
file_name[strlen(dir_content[i].file_name)] = '\0';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <curses.h>
|
||||
#include <dirent.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
|
||||
@@ -188,7 +188,7 @@ void *thread_rgt(){
|
||||
rgt_content->file_type = 0;
|
||||
rgt_content->permissions = mid_content[selected_file_current].permissions;
|
||||
}
|
||||
} else if ((status & STATUS_DELTA_TIME) != STATUS_DELTA_TIME) {
|
||||
} else if ((status & STATUS_DELTA_TIME) != STATUS_DELTA_TIME && mid_file_count > 0) {
|
||||
|
||||
unsigned long i = 0;
|
||||
for (i = 0; i < rgt_file_count; i++) {
|
||||
@@ -246,6 +246,7 @@ void *thread_top(){
|
||||
top_buffer = malloc(strlen(global_path)+1);
|
||||
memcpy(top_buffer, global_path, strlen(global_path)+1);
|
||||
top_width = strlen(top_buffer);
|
||||
/*printing of mid_content[selected_file_current].file_name is done directly in window.c window_top()*/
|
||||
|
||||
pthread_mutex_unlock(&mutex_top);
|
||||
}
|
||||
|
||||
6
window.c
6
window.c
@@ -37,11 +37,13 @@ void window_top(WINDOW *win){
|
||||
werase(win);
|
||||
|
||||
if (pthread_mutex_trylock(&mutex_top) == 0) {
|
||||
wattron(win, COLOR_PAIR(COLOR_PATH));
|
||||
if (*top_buffer != ' ') { /*printing ' ' (standard initialized value, see threading_init) makes valgrind throw a fuss*/
|
||||
wattron(win, COLOR_PAIR(COLOR_PATH));
|
||||
mvwaddstr(win, 0, 0, top_buffer);
|
||||
mvwaddch(win, 0, strlen(top_buffer), '/');
|
||||
wattroff(win, COLOR_PAIR(COLOR_PATH));
|
||||
mvwaddstr(win, 0, strlen(top_buffer)+1, mid_content[selected_file_current].file_name);
|
||||
}
|
||||
wattroff(win, COLOR_PAIR(COLOR_PATH));
|
||||
pthread_mutex_unlock(&mutex_top);
|
||||
} else {
|
||||
mvwaddstr(win, 0, terminal_width/2, "LOADING");
|
||||
|
||||
Reference in New Issue
Block a user