diff options
author | louie <lshprung@yahoo.com> | 2020-12-23 18:20:46 -0800 |
---|---|---|
committer | louie <lshprung@yahoo.com> | 2020-12-23 18:20:46 -0800 |
commit | f9227cef5bcbe9f3a3fe3487ed1cc358cff37932 (patch) | |
tree | 5a009fd6587f075c5a48a9b8c665347ed151507e | |
parent | fa8e3992ef7060168770ccccabdfe3b2982ea700 (diff) |
Fixed Windows configuration auto-generation, added new setLauncherRaw option
-rw-r--r-- | draw.c | 11 | ||||
-rw-r--r-- | draw.o | bin | 19712 -> 19720 bytes | |||
-rw-r--r-- | group.c | 13 | ||||
-rw-r--r-- | group.h | 4 | ||||
-rw-r--r-- | group.o | bin | 8216 -> 8672 bytes | |||
-rw-r--r-- | history/history.db | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | read_cfg.c | 22 | ||||
-rw-r--r-- | read_cfg.o | bin | 20400 -> 20608 bytes | |||
-rwxr-xr-x | tml | bin | 46960 -> 47080 bytes |
9 files changed, 35 insertions, 15 deletions
@@ -437,7 +437,7 @@ char *get_launch(){ char *program = get_gprog(g[g_hover]); char *flags = get_gflags(g[g_hover]); char *path = get_epath(e[e_hover]); - bool force = get_eforce(e[e_hover]); + bool quotes = get_gquotes(g[g_hover]); char *full_command = malloc(sizeof(char) * BUF_LEN); full_command[0] = '\0'; @@ -450,9 +450,9 @@ char *get_launch(){ } else{ - strcat(full_command, "\""); + if(quotes) strcat(full_command, "\""); strcat(full_command, program); - strcat(full_command, "\""); + if(quotes) strcat(full_command, "\""); if(flags[0] !='\0'){ strcat(full_command, " "); strcat(full_command, flags); @@ -472,6 +472,7 @@ void win_launch(){ char *program = get_gprog(g[g_hover]); char *flags = get_gflags(g[g_hover]); char *path = get_epath(e[e_hover]); + bool quotes = get_gquotes(g[g_hover]); char file[BUF_LEN]; char params[BUF_LEN]; @@ -485,9 +486,9 @@ void win_launch(){ } else{ - strcat(file, "\""); + if(quotes) strcat(file, "\""); strcat(file, program); - strcat(file, "\""); + if(quotes) strcat(file, "\""); params[0] = '\0'; if(flags[0] != '\0'){ Binary files differ@@ -17,6 +17,7 @@ typedef struct group{ struct entry *tail; struct group *next; int entry_count; + bool launcher_quotes; //set by a group option whether or not the launcher should be wrapped by quotes } GROUP; GROUP *create_group(char *new_name); @@ -32,6 +33,8 @@ void set_gflags(GROUP *g, char *p); ENTRY *get_ghead(GROUP *g); int get_ecount(GROUP *g); void set_ecount(GROUP *g, int new_count); //for use in hiding entries +void set_gquotes(GROUP *g, bool b); +bool get_gquotes(GROUP *g); int get_gcount(); void group_debug(); //debug function to output all groups @@ -50,6 +53,7 @@ GROUP *create_group(char *new_name){ new->tail = NULL; new->next = NULL; new->entry_count = 0; + new->launcher_quotes = true; group_count++; return new; @@ -228,6 +232,15 @@ void set_ecount(GROUP *g, int new_count){ g->entry_count = new_count; } +void set_gquotes(GROUP *g, bool b){ + assert(g != NULL); + g->launcher_quotes = b; +} + +bool get_gquotes(GROUP *g){ + return g->launcher_quotes; +} + int get_gcount(){ return group_count; } @@ -29,6 +29,10 @@ int get_ecount(GROUP *g); void set_ecount(GROUP *g, int new_count); +void set_gquotes(GROUP *g, bool b); + +bool get_gquotes(GROUP *g); + int get_gcount(); void group_debug(); Binary files differdiff --git a/history/history.db b/history/history.db Binary files differnew file mode 100644 index 0000000..5398ed4 --- /dev/null +++ b/history/history.db @@ -12,7 +12,7 @@ #include "group.h" #define BUF_LEN 1024 //maybe move this line to the header file #define MAX_ARGS 5 -#define OPTION_CNT 13 +#define OPTION_CNT 14 //public #if defined _WIN32 || defined _WIN64 @@ -135,7 +135,8 @@ void cfg_interp(char *path){ options[9] = "hideFile"; options[10] = "setFlags"; options[11] = "setLauncher"; - options[12] = "sort"; + options[12] = "setLauncherRaw"; + options[13] = "sort"; //Read each line of "config" while(fgets(buffer, BUF_LEN, fp)){ @@ -240,22 +241,19 @@ void mkconfig_wizard(char *path){ exit(1); } - //write to file (in Windows, launch an application with the default launcher by invoking "start") - //FIXME at the moment, this WILL NOT WORK. I need to add an option to set launcher without quotes + //write to file (in Windows, executing a file will open it in its default application) #if defined _WIN32 || defined _WIN64 fprintf(fp, "# This file was auto-generated by tml. See docs/tml-config.md or tml-config(5) for documentation\n" - "# Please note that the launcher \"start\" is a built-in Windows command to launch a file with the default application\n\n" + "# By default, no launcher is specified for any group. When no launcher is specified on the Windows build of tml, media files will be opened with their default application.\n" + "# It is generally recommended to specify a launcher for groups containing media files using the \"setLauncher\" command\n\n" "# Recursively add files from %s%cMusic%c to Music group\n" "addGroup Music\n" - "setLauncher Music start\n" "addR %s%cMusic%c* Music\n\n" "# Recursively add files from %s%cPictures%c to Pictures group\n" "addGroup Pictures\n" - "setLauncher Pictures start\n" "addR %s%cPictures%c* Pictures\n\n" "# Recursively add files from %s%cVideos%c to Videos group\n" "addGroup Videos\n" - "setLauncher Videos start\n" "addR %s%cVideos%c* Videos", home, sep, sep, home, sep, sep, home, sep, sep, home, sep, sep, home, sep, sep, home, sep, sep); #else fprintf(fp, "# This file was auto-generated by tml. See docs/tml-config.md or tml-config(5) for documentation\n" @@ -459,6 +457,7 @@ void check_line(char *buffer, char **options, int ln){ break; case 11: //setLauncher + case 12: //setLauncherRaw //args[1] is referring to a group g = get_groups(); g_count = get_gcount(); @@ -470,7 +469,10 @@ void check_line(char *buffer, char **options, int ln){ //set a group's launcher (this requires pulling down the existing groups and finding the one that args[1] mentions) //assert that a matching group was found - if(i < g_count) set_gprog(g[i], strip_quotes(args[2])); + if(i < g_count){ + set_gprog(g[i], strip_quotes(args[2])); + if(search_res == 12) set_gquotes(g[i], false); //FIXME don't forget to change this line if adding more options!!! + } else{ error_p = malloc(sizeof(char) * 1024); sprintf(error_p, "Group \"%s\" does not exist", args[1]); @@ -479,7 +481,7 @@ void check_line(char *buffer, char **options, int ln){ } break; - case 12: //sort + case 13: //sort if(!(strcmp(args[1], "on"))) sort = true; else if(!(strcmp(args[1], "off"))) sort = false; break; Binary files differBinary files differ |