From bec432f0db0c13753550dcaa1dc51c1a973c4c4e Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 17 Jul 2017 18:50:04 +0200 Subject: Regex on selection --- main.c | 2 +- regex.c | 13 +++++++++++++ regex.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 7cc60d5..f39d0e7 100755 --- a/main.c +++ b/main.c @@ -261,7 +261,7 @@ int main(int argc, char* argv[]){ break; case 'x': prepare("x"); - regexXtract(&menu.list[menu.hl], msg_win_str); + regexXtracts(&menu, msg_win_str); resizeMain(&menu); break; case 'q': diff --git a/regex.c b/regex.c index 0b01347..a96fe5e 100644 --- a/regex.c +++ b/regex.c @@ -101,6 +101,19 @@ void regexSelection(menuC* menu, const char* msg) { } } } +void regexXtracts(menuC* menu, const char* msg) { + int hasSelect = 0; + for(int i = 0 ; i < menu->nbElem ; i++ ) { + if( menu->list[i].selected == 1 ) { + regexXtract(&(menu->list[i]), msg); + hasSelect = 1; + } + } + if( !hasSelect ) { + regexXtract(&menu->list[menu->hl], msg); + } + +} /* * Example regex : * diff --git a/regex.h b/regex.h index 752f17b..f2659df 100644 --- a/regex.h +++ b/regex.h @@ -10,6 +10,7 @@ static int compile_regex (regex_t * r, const char * regex_text); static int match_regex (const char* rS, const char * to_match, char* m2[], int nbR); +void regexXtracts(menuC* it, const char* str); void regexXtract(itemC* it, const char* str); void regexSelection(menuC* menu, const char* msg); -- cgit v1.2.3