aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2019-01-24 08:52:54 +0100
committerache <ache@ache.one>2019-01-24 08:52:54 +0100
commite63da80cd14701d1df6423480dab4b4c7c2c8a23 (patch)
tree379c820b4ba33b55b70306797e7d1522bdff2f58
parentEdit instead of remplace (diff)
Search by filename
-rwxr-xr-xmain.c21
-rw-r--r--readline.obin7384 -> 0 bytes
-rw-r--r--regex.c14
-rw-r--r--regex.h1
-rw-r--r--wind.c4
-rw-r--r--wind.h2
6 files changed, 31 insertions, 11 deletions
diff --git a/main.c b/main.c
index 33dbab8..70c007f 100755
--- a/main.c
+++ b/main.c
@@ -237,13 +237,13 @@ int main(int argc, char* argv[]){
case 0:
switch (c) {
case 'B':
- case 'j':
+ case 'j': // Up
if( menu.hl < menu.nbElem-1 )
menu.hl++;
printTagInfo(&menu);
break;
case 'A':
- case 'k':
+ case 'k': // Down
if( menu.hl > 0)
menu.hl--;
printTagInfo(&menu);
@@ -252,7 +252,7 @@ int main(int argc, char* argv[]){
break;
case KEY_SRIGHT:
break;
- case 'e':
+ case 'e': // Edit mode
if( !status[0] ) {
status[0] = 'e';
comp = 'e';
@@ -260,16 +260,21 @@ int main(int argc, char* argv[]){
status[0] = 0;
}
break;
- case ' ':
+ case ' ': // Select under cursor mode
menu.list[menu.hl].selected = !menu.list[menu.hl].selected;
break;
- case 's':
- prepare("xs");
+ case 's': // Select by regex mode
+ prepare("xs", "");
regexSelection(&menu,msg_win_str);
resizeMain(&menu);
break;
- case 'x':
- prepare("x");
+ case '/': // Search mode
+ prepare("/", "");
+ regexSearch(&menu, msg_win_str);
+ resizeMain(&menu);
+ break;
+ case 'x': // Regex mode
+ prepare("x", "");
regexXtracts(&menu, msg_win_str);
resizeMain(&menu);
break;
diff --git a/readline.o b/readline.o
deleted file mode 100644
index 932a9cc..0000000
--- a/readline.o
+++ /dev/null
Binary files differ
diff --git a/regex.c b/regex.c
index f820eab..3f1cc36 100644
--- a/regex.c
+++ b/regex.c
@@ -117,6 +117,20 @@ void regexSelection(menuC* menu, const char* msg) {
}
}
}
+void regexSearch(menuC* menu, const char* msg) {
+ for(int i = menu->hl + 1 ; i < menu->nbElem ; i++ ) {
+ if( match_regex(msg, menu->list[i].cstr, NULL, -1 ) ) {
+ menu->hl = i;
+ return;
+ }
+ }
+ for(int i = 0 ; i < menu->hl ; i++ ) {
+ if( match_regex(msg, menu->list[i].cstr, NULL, -1 ) ) {
+ menu->hl = i;
+ return;
+ }
+ }
+}
void regexXtracts(menuC* menu, const char* msg) {
int hasSelect = 0;
for(int i = 0 ; i < menu->nbElem ; i++ ) {
diff --git a/regex.h b/regex.h
index f2659df..e295d29 100644
--- a/regex.h
+++ b/regex.h
@@ -13,6 +13,7 @@ static int match_regex (const char* rS, const char * to_match, char* m2[], int n
void regexXtracts(menuC* it, const char* str);
void regexXtract(itemC* it, const char* str);
void regexSelection(menuC* menu, const char* msg);
+void regexSearch(menuC* menu, const char* msg);
#endif
diff --git a/wind.c b/wind.c
index 78b9835..1a46013 100644
--- a/wind.c
+++ b/wind.c
@@ -15,11 +15,11 @@ extern WINDOW *cmd_win;
extern WINDOW *sep_win;
-void prepare(char* s) {
+void prepare(const char* s, const char* placeholder) {
refresh();
strcpy(status, s);
printStatus();
- readline_n("");
+ readline_n(placeholder);
clear();
curs_set(0);
}
diff --git a/wind.h b/wind.h
index 7b7f12a..66531c5 100644
--- a/wind.h
+++ b/wind.h
@@ -19,7 +19,7 @@ void printmenu(menuC* menu);
void printStatus(void);
-void prepare(char* s);
+void prepare(const char* s, const char* placeholder);
void resize(void);
void resizeMain(menuC* menu);