mirror of
https://gittea.dev/nova/th.git
synced 2026-01-30 16:50:10 -05:00
better string handling
This commit is contained in:
@@ -238,9 +238,9 @@ void move_right(){
|
||||
for (i = 0; i < file_extension_default_count; i++) {
|
||||
if (strstr(extension, file_extension_default_cmd[i].file_extension)) {
|
||||
char *cmd;
|
||||
concat(cmd, file_extension_default_cmd[i].command, " ./\"", 0);
|
||||
concat(cmd, file_extension_default_cmd[i].command, " ./\'", 0);
|
||||
concat(cmd, cmd, mid_content[selected_file_current].file_name, 1);
|
||||
concat(cmd, cmd, "\"", 1);
|
||||
concat(cmd, cmd, "\'", 1);
|
||||
|
||||
|
||||
if (system(cmd) == -1) {
|
||||
@@ -257,12 +257,7 @@ void move_right(){
|
||||
for (i = 0; i < mimetype_default_count; i++) {
|
||||
if (strstr(mime, mimetype_default_cmd[i].mimetype)) {
|
||||
|
||||
char *cmd;
|
||||
concat(cmd, mimetype_default_cmd[i].command, " ./\"", 0);
|
||||
concat(cmd, cmd, mid_content[selected_file_current].file_name, 1);
|
||||
concat(cmd, cmd, "\"", 1);
|
||||
|
||||
|
||||
char *cmd = parse_cmd_char(mimetype_default_cmd[i].command, mid_content[selected_file_current].file_name);
|
||||
if (system(cmd) == -1) {
|
||||
/*do nothing*/
|
||||
}
|
||||
@@ -317,9 +312,9 @@ void open_with(){
|
||||
mvwin(win_b, terminal_height-6, 0);
|
||||
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width/3); /*the div3 just looks cool*/
|
||||
|
||||
concat(btm_buffer, ui_open_with_text_0, " \"", 0);
|
||||
concat(btm_buffer, ui_open_with_text_0, " \'", 0);
|
||||
concat(btm_buffer, btm_buffer, mid_content[selected_file_current].file_name, 1);
|
||||
concat(btm_buffer, btm_buffer, "\" ", 1);
|
||||
concat(btm_buffer, btm_buffer, "\' ", 1);
|
||||
concat(btm_buffer, btm_buffer, ui_open_with_text_1, 1);
|
||||
|
||||
|
||||
@@ -334,9 +329,9 @@ void open_with(){
|
||||
|
||||
if (err == 0) {
|
||||
char *cmd;
|
||||
concat(cmd, str, " ./\"", 0);
|
||||
concat(cmd, str, " ./\'", 0);
|
||||
concat(cmd, cmd, mid_content[selected_file_current].file_name, 1);
|
||||
concat(cmd, cmd, "\"", 1);
|
||||
concat(cmd, cmd, "\'", 1);
|
||||
|
||||
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||
images_clear();
|
||||
@@ -366,9 +361,9 @@ void rename_hovered(){
|
||||
mvwin(win_b, terminal_height-6, 0);
|
||||
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width/3); /*the div3 just looks cool*/
|
||||
|
||||
concat(btm_buffer, ui_rename_text_0, " \"", 0);
|
||||
concat(btm_buffer, ui_rename_text_0, " \'", 0);
|
||||
concat(btm_buffer, btm_buffer, mid_content[selected_file_current].file_name, 1);
|
||||
concat(btm_buffer, btm_buffer, "\" ", 1);
|
||||
concat(btm_buffer, btm_buffer, "\' ", 1);
|
||||
concat(btm_buffer, btm_buffer, ui_rename_text_1, 1);
|
||||
|
||||
window_btm(win_b, 1);
|
||||
@@ -381,10 +376,10 @@ void rename_hovered(){
|
||||
|
||||
if (!err) {
|
||||
char *cmd;
|
||||
concat(cmd, "mv ./\"", mid_content[selected_file_current].file_name, 0);
|
||||
concat(cmd, cmd, "\" ./\"", 1);
|
||||
concat(cmd, "mv ./\'", mid_content[selected_file_current].file_name, 0);
|
||||
concat(cmd, cmd, "\' ./\'", 1);
|
||||
concat(cmd, cmd, str, 1);
|
||||
concat(cmd, cmd, "\"", 1);
|
||||
concat(cmd, cmd, "\'", 1);
|
||||
|
||||
if (system(cmd) == -1) {
|
||||
FAIL("rename_hovered", "mv or creating subcommand failed");
|
||||
@@ -411,9 +406,9 @@ void delete(){
|
||||
char *file_str = "";
|
||||
for (i = 0; i < mid_file_count; i++) {
|
||||
if (mid_content[i].status & FILE_STATUS_SELECTED) {
|
||||
concat(file_str, file_str, "\"", 0);
|
||||
concat(file_str, file_str, "\'", 0);
|
||||
concat(file_str, file_str, mid_content[i].file_name, 1);
|
||||
concat(file_str, file_str, "\" ", 1);
|
||||
concat(file_str, file_str, "\' ", 1);
|
||||
hits++;
|
||||
}
|
||||
}
|
||||
@@ -653,9 +648,9 @@ void cmd_on_selected(unsigned long passes, int index){
|
||||
char *file_str = "";
|
||||
for (i = 0; i < mid_file_count; i++) {
|
||||
if (mid_content[i].status & FILE_STATUS_SELECTED) {
|
||||
concat(file_str, file_str, "\"", 0);
|
||||
concat(file_str, file_str, "\'", 0);
|
||||
concat(file_str, file_str, mid_content[i].file_name, 1);
|
||||
concat(file_str, file_str, "\" ", 1);
|
||||
concat(file_str, file_str, "\' ", 1);
|
||||
hits++;
|
||||
}
|
||||
}
|
||||
@@ -663,9 +658,9 @@ void cmd_on_selected(unsigned long passes, int index){
|
||||
if (hits) {
|
||||
concat(btm_buffer, key_binding[index].black_magic, file_str, 2);
|
||||
} else {
|
||||
concat(btm_buffer, key_binding[index].black_magic, "\"", 0);
|
||||
concat(btm_buffer, key_binding[index].black_magic, "\'", 0);
|
||||
concat(btm_buffer, btm_buffer, mid_content[selected_file_current].file_name, 1);
|
||||
concat(btm_buffer, btm_buffer, "\"", 1);
|
||||
concat(btm_buffer, btm_buffer, "\'", 1);
|
||||
}
|
||||
|
||||
concat(btm_buffer, btm_buffer, "?", 1);
|
||||
@@ -691,9 +686,9 @@ void cmd_on_selected(unsigned long passes, int index){
|
||||
for (i = 0; i < mid_file_count; i++) {
|
||||
if (mid_content[i].status & FILE_STATUS_SELECTED) {
|
||||
free(cmd);
|
||||
concat(cmd, (char*)key_binding[index].black_magic, " \"", 0);
|
||||
concat(cmd, (char*)key_binding[index].black_magic, " \'", 0);
|
||||
concat(cmd, cmd, mid_content[i].file_name, 1);
|
||||
concat(cmd, cmd, "\"", 1);
|
||||
concat(cmd, cmd, "\'", 1);
|
||||
if (system(cmd) != 0) {
|
||||
/*do nothing*/
|
||||
}
|
||||
@@ -701,9 +696,9 @@ void cmd_on_selected(unsigned long passes, int index){
|
||||
}
|
||||
} else {
|
||||
free(cmd);
|
||||
concat(cmd, (char*)key_binding[index].black_magic, " \"", 0);
|
||||
concat(cmd, (char*)key_binding[index].black_magic, " \'", 0);
|
||||
concat(cmd, cmd, mid_content[selected_file_current].file_name, 1);
|
||||
concat(cmd, cmd, "\"", 1);
|
||||
concat(cmd, cmd, "\'", 1);
|
||||
if (system(cmd) != 0) {
|
||||
/*do nothing*/
|
||||
}
|
||||
@@ -727,15 +722,15 @@ void yank_text(unsigned long passes, int index){
|
||||
char *cmd;
|
||||
if (strncmp((char*)key_binding[index].black_magic, "path", 4) == 0) {
|
||||
char *path=getcwd(NULL, 0);
|
||||
concat(cmd, "echo \"", path, 0);
|
||||
concat(cmd, "echo \'", path, 0);
|
||||
concat(cmd, cmd, "/", 1);
|
||||
concat(cmd, cmd, mid_content[selected_file_current].file_name, 1);
|
||||
concat(cmd, cmd, "\" | ", 1);
|
||||
concat(cmd, cmd, "\' | ", 1);
|
||||
concat(cmd, cmd, clipboard_cmd, 1);
|
||||
free(path);
|
||||
} else {
|
||||
concat(cmd, "echo \"", mid_content[selected_file_current].file_name, 0);
|
||||
concat(cmd, cmd, "\" | ", 1);
|
||||
concat(cmd, "echo \'", mid_content[selected_file_current].file_name, 0);
|
||||
concat(cmd, cmd, "\' | ", 1);
|
||||
concat(cmd, cmd, clipboard_cmd, 1);
|
||||
}
|
||||
if (system(cmd) == -1) {
|
||||
@@ -792,17 +787,15 @@ void yank_file(unsigned long passes, int index){
|
||||
void paste(){
|
||||
unsigned long i;
|
||||
for (i = 0; i < yank_files.count; i++) {
|
||||
/*TODO(2025-08-14T22:10:44) escape path*/
|
||||
char *cmd;
|
||||
if (yank_files.status & YANK_COPY) {
|
||||
concat(cmd, "false | cp -ri ", yank_files.path, 0);
|
||||
concat(cmd, "false | cp -ri \'", yank_files.path, 0);
|
||||
} else {
|
||||
concat(cmd, "mv ", yank_files.path, 0);
|
||||
concat(cmd, "mv \'", yank_files.path, 0);
|
||||
}
|
||||
concat(cmd, cmd, "/", 1);
|
||||
concat(cmd, cmd, *yank_files.list, 1);
|
||||
concat(cmd, cmd, " ./", 1);
|
||||
concat(cmd, cmd, *yank_files.list, 1);
|
||||
concat(cmd, cmd, "\' ./", 1);
|
||||
concat(cmd, cmd, " 2>&1", 1);
|
||||
char *line = malloc(INPUT_BUFFER_SIZE);
|
||||
FILE *cmd_open;
|
||||
|
||||
Reference in New Issue
Block a user