summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouie <lshprung@yahoo.com>2020-08-18 18:24:59 -0700
committerlouie <lshprung@yahoo.com>2020-08-18 18:24:59 -0700
commitb35606d04316b3ba2c9c7a5fcdaf12a3ac3e6ccc (patch)
tree133838484047a5d123dcf3ee7ea3456e4f8d5de9
parent73ba31618b28d72e241ff066080ed1a407a82aa3 (diff)
Added hideFile option to read_cfg
-rw-r--r--docs/README.md10
-rw-r--r--docs/tml-config.md7
-rw-r--r--read_cfg.c19
3 files changed, 25 insertions, 11 deletions
diff --git a/docs/README.md b/docs/README.md
index 7e01ebd..a3b3842 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -4,7 +4,7 @@
## Compiling and Running
-tml can be installed on any system with gcc and the ncurses library installed. It has been tested to work on Ubuntu and Windows 10. To compile and run tml:
+tml can be compiled on any system with gcc and the ncurses library installed. It has been tested to work on Ubuntu and Windows 10. To compile and run tml:
1. Clone the repository
2. Run `make` in the directory the repository was cloned into. This will create a file called `tml`
@@ -20,4 +20,10 @@ By default, tml searches in the following order for a config file:
2. `$HOME/.tml/config`
3. `config` (in the current directory)
-A different config file location can also be specified with the `-c` flag. For Documentation of the config file, see [tml-config](tml-config.md)
+A different config file location can also be specified with the `-c` flag:
+
+```
+tml -c /path/to/config
+```
+
+For Documentation of the config file, see [tml-config](tml-config.md)
diff --git a/docs/tml-config.md b/docs/tml-config.md
index 3b843e1..e0c782b 100644
--- a/docs/tml-config.md
+++ b/docs/tml-config.md
@@ -15,6 +15,7 @@
- [addNameF](#addNameF)
- [addR](#addR)
- [hide](#hide)
+ - [hideFile](#hideFile)
- [Settings](#Settings)
- [autoAlias](#autoAlias)
- [compMode](#compMode)
@@ -84,6 +85,12 @@ tml will hide empty groups, so you will need to know how to add entries to a gro
`hide` will remove a specified entry from a specified group. The entry argument should refer to the entry's name, rather than the entry's path. This option may be useful to hide certain files after adding entries with the '\*' operator. *At the moment, hide can only hide a single entry*.
+### hideFile
+
+- **hideFile** *path* *group*
+
+`hideFile` has the exact same functionality as `hide`, but takes the absolute path of the entry to hide as the first argument, instead of the name.
+
## Settings
If any of the following settings are specified, they should be at the top of the config file.
diff --git a/read_cfg.c b/read_cfg.c
index b9f90ff..d692fcd 100644
--- a/read_cfg.c
+++ b/read_cfg.c
@@ -10,7 +10,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
char *find_config();
@@ -99,9 +99,10 @@ void cfg_interp(char *path){
options[7] = "compMode";
options[8] = "foldCase";
options[9] = "hide";
- options[10] = "setFlags";
- options[11] = "setLauncher";
- options[12] = "sort";
+ options[10] = "hideFile";
+ options[11] = "setFlags";
+ options[12] = "setLauncher";
+ options[13] = "sort";
//Read each line of "config"
while(fgets(buffer, BUF_LEN, fp)){
@@ -262,6 +263,7 @@ void check_line(char *buffer, char **options){
//TODO consider having this call handle_fname instead so that '*' can be used
case 9: //hide
+ case 10: //hideFile
//args[2] is referring to a group
g = get_groups();
g_count = get_gcount();
@@ -276,7 +278,7 @@ void check_line(char *buffer, char **options){
e = get_entries(get_ghead(g[i]), e_count);
for(j = 0; j < e_count; j++){
- if(!strcmp(get_ename(e[j]), strip_quotes(args[1]))) break;
+ if(!strcmp((search_res == 9 ? get_ename(e[j]) : get_epath(e[j])), strip_quotes(args[1]))) break;
}
if(j < e_count){
@@ -289,7 +291,7 @@ void check_line(char *buffer, char **options){
else printf("Error: Group \"%s\" does not exist\n", args[2]);
break;
- case 10: //setFlags
+ case 11: //setFlags
//args[1] is referring to a group
g = get_groups();
g_count = get_gcount();
@@ -305,7 +307,7 @@ void check_line(char *buffer, char **options){
else printf("Error: Group \"%s\" does not exist\n", args[1]);
break;
- case 11: //setLauncher
+ case 12: //setLauncher
//args[1] is referring to a group
g = get_groups();
g_count = get_gcount();
@@ -321,7 +323,7 @@ void check_line(char *buffer, char **options){
else printf("Error: Group \"%s\" does not exist\n", args[1]);
break;
- case 12: //sort
+ case 13: //sort
if(!(strcmp(args[1], "on"))) sort = true;
else if(!(strcmp(args[1], "off"))) sort = false;
break;
@@ -466,7 +468,6 @@ void addme(char *path, char *group, bool force, char *name){
}
-//TODO figure out how to trim the extensions of files off
char *autoAlias(char *path){
char *hr_name = malloc(sizeof(char) * BUF_LEN);
char *p = hr_name;