summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/tml-config.md7
-rw-r--r--draw.c10
-rw-r--r--read_cfg.c34
-rw-r--r--read_cfg.h2
4 files changed, 42 insertions, 11 deletions
diff --git a/docs/tml-config.md b/docs/tml-config.md
index f4a1faa..3b843e1 100644
--- a/docs/tml-config.md
+++ b/docs/tml-config.md
@@ -18,6 +18,7 @@
- [Settings](#Settings)
- [autoAlias](#autoAlias)
- [compMode](#compMode)
+ - [foldCase](#foldCase)
- [sort](#sort)
- [Example](#Example)
@@ -106,6 +107,12 @@ If any of the following settings are specified, they should be at the top of the
At the moment, `compMode` can be turned on for using tml in Windows Subsystem for Linux. By default, `compMode` is turned off. *compMode may be removed in the future due to redundancy, as tml works natively in Windows*.
+### foldCase
+
+- **foldCase** *on/off*
+
+Entering any non-traversal input in tml can be used to jump to a group or entry. For instance, hitting 'f' on the keyboard will jump the cursor to the next group or entry that starts with an 'f'. *foldCase* determines whether or not this functionality is **case insensitive (on)** or **case sensitive (off)**. *foldCase* is turned on by default.
+
### sort
- **sort** *on/off*
diff --git a/draw.c b/draw.c
index 13b125a..05ebb2d 100644
--- a/draw.c
+++ b/draw.c
@@ -398,11 +398,17 @@ void trav_col(int new_i){
int locateChar(char input){
int location = (true_hover ? e_hover : g_hover);
+ bool fold_case = get_case_sensitivity();
+ char first_char;
int i;
+ if(fold_case && input >= 97 && input <= 122) input -= 32;
+
if(true_hover){ //hovering on entries
for(i = location+1; i < e_count; i++){
- if(input == get_ename(e[i])[0]){
+ first_char = get_ename(e[i])[0];
+ if(fold_case && first_char >= 97 && first_char <= 122) first_char -= 32;
+ if(input == first_char){
location = i;
break;
}
@@ -411,6 +417,8 @@ int locateChar(char input){
else{ //hovering on groups
for(i = location+1; i < g_count; i++){
+ first_char = get_gname(g[i])[0];
+ if(fold_case && first_char >= 97 && first_char <= 122) first_char -= 32;
if(input == get_gname(g[i])[0]){
location = i;
break;
diff --git a/read_cfg.c b/read_cfg.c
index 3d3a6a6..b9f90ff 100644
--- a/read_cfg.c
+++ b/read_cfg.c
@@ -10,13 +10,14 @@
#include "group.h"
#define BUF_LEN 1024 //maybe move this line to the header file
#define MAX_ARGS 5
-#define OPTION_CNT 12
+#define OPTION_CNT 13
//public
char *find_config();
void cfg_interp(char *path);
int get_compmode();
bool get_sort();
+bool get_case_sensitivity();
//private
void check_line(char *buffer, char **options);
@@ -35,11 +36,14 @@ int compmode = 0;
//maybe more later?
//turn on or off sorting (A-Z); On by default
-bool sort = 1;
+bool sort = true;
//set to true to automatically try to create a human readable name for an entry
bool hr = false;
+//turn foldCase (insensitive case searching) on or off; On by default
+bool fold_case = true;
+
#if defined _WIN32 || defined _WIN64
//for Windows Compatability, this will be '\\' (otherwise '/')
char sep = '\\';
@@ -93,10 +97,11 @@ void cfg_interp(char *path){
options[5] = "addR";
options[6] = "autoAlias";
options[7] = "compMode";
- options[8] = "hide";
- options[9] = "setFlags";
- options[10] = "setLauncher";
- options[11] = "sort";
+ options[8] = "foldCase";
+ options[9] = "hide";
+ options[10] = "setFlags";
+ options[11] = "setLauncher";
+ options[12] = "sort";
//Read each line of "config"
while(fgets(buffer, BUF_LEN, fp)){
@@ -133,6 +138,10 @@ bool get_sort(){
return sort;
}
+bool get_case_sensitivity(){
+ return fold_case;
+}
+
//TODO add support for "addR" recursive adding (still needs work...)
//TODO add support for "alias" option
//TODO add support for "hide" option
@@ -246,8 +255,13 @@ void check_line(char *buffer, char **options){
else printf("Error: Unknown Compatability Mode Argument \"%s\"\n", strip_quotes(args[1]));
break;
+ case 8: //foldCase (case insensitive)
+ if(!(strcmp(args[1], "on"))) fold_case = true;
+ else if(!(strcmp(args[1], "off"))) fold_case = false;
+ break;
+
//TODO consider having this call handle_fname instead so that '*' can be used
- case 8: //hide
+ case 9: //hide
//args[2] is referring to a group
g = get_groups();
g_count = get_gcount();
@@ -275,7 +289,7 @@ void check_line(char *buffer, char **options){
else printf("Error: Group \"%s\" does not exist\n", args[2]);
break;
- case 9: //setFlags
+ case 10: //setFlags
//args[1] is referring to a group
g = get_groups();
g_count = get_gcount();
@@ -291,7 +305,7 @@ void check_line(char *buffer, char **options){
else printf("Error: Group \"%s\" does not exist\n", args[1]);
break;
- case 10: //setLauncher
+ case 11: //setLauncher
//args[1] is referring to a group
g = get_groups();
g_count = get_gcount();
@@ -307,7 +321,7 @@ void check_line(char *buffer, char **options){
else printf("Error: Group \"%s\" does not exist\n", args[1]);
break;
- case 11: //sort
+ case 12: //sort
if(!(strcmp(args[1], "on"))) sort = true;
else if(!(strcmp(args[1], "off"))) sort = false;
break;
diff --git a/read_cfg.h b/read_cfg.h
index a88dfa6..5c2e77b 100644
--- a/read_cfg.h
+++ b/read_cfg.h
@@ -9,4 +9,6 @@ int get_compmode();
bool get_sort();
+bool get_case_sensitivity();
+
#endif