瀏覽代碼

Use / to toggle string and regex

master
Arun Prakash Jana 5 年之前
父節點
當前提交
0222b75c2e
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: A75979F35C080412
共有 3 個檔案被更改,包括 12 行新增23 行删除
  1. +1
    -3
      nnn.1
  2. +8
    -17
      src/nnn.c
  3. +3
    -3
      src/nnn.h

+ 1
- 3
nnn.1 查看文件

@@ -142,9 +142,7 @@ Filters are strings to find matching entries in the current directory instantly
.Pp .Pp
To modify match criteria at runtime: To modify match criteria at runtime:
.br .br
- string to regex: press '\\' at empty filter prompt - toggle between string and regex: press '/' at empty filter prompt
.br
- regex to string: press '/' at empty filter prompt
.br .br
- toggle case sensitivity: press ':' at empty filter prompt - toggle case sensitivity: press ':' at empty filter prompt
.Pp .Pp


+ 8
- 17
src/nnn.c 查看文件

@@ -2072,7 +2072,7 @@ static void showfilterinfo(void)


i = getorderstr(info); i = getorderstr(info);


snprintf(info + i, REGEX_MAX - i - 1, " %s [keys /\\], %s [key :]", snprintf(info + i, REGEX_MAX - i - 1, " %s [/], %s [:]",
(cfg.regex ? "regex" : "str"), (cfg.regex ? "regex" : "str"),
((fnstrstr == &strcasestr) ? "ic" : "noic")); ((fnstrstr == &strcasestr) ? "ic" : "noic"));
printinfoln(info); printinfoln(info);
@@ -2238,20 +2238,11 @@ static int filterentries(char *path, char *lastname)
continue; continue;
} }


/* string to regex */ /* toggle string or regex filter */
if (*ch == RFILTER && ln[0] == FILTER) { if (*ch == FILTER) {
wln[0] = ln[0] = RFILTER; wln[0] = ln[0] = (ln[0] == FILTER) ? RFILTER : FILTER;
cfg.regex = TRUE; cfg.regex ^= 1;
filterfn = &visible_re; filterfn = (filterfn == &visible_str) ? &visible_re : &visible_str;
showfilter(ln);
continue;
}

/* regex to string */
if (*ch == FILTER && ln[0] == RFILTER) {
wln[0] = ln[0] = FILTER;
cfg.regex = FALSE;
filterfn = &visible_str;
showfilter(ln); showfilter(ln);
continue; continue;
} }
@@ -4994,7 +4985,7 @@ nochange:
case SEL_MFLTR: // fallthrough case SEL_MFLTR: // fallthrough
case SEL_TOGGLEDOT: // fallthrough case SEL_TOGGLEDOT: // fallthrough
case SEL_DETAIL: // fallthrough case SEL_DETAIL: // fallthrough
case SEL_ORDER: case SEL_SORT:
switch (sel) { switch (sel) {
case SEL_MFLTR: case SEL_MFLTR:
cfg.filtermode ^= 1; cfg.filtermode ^= 1;
@@ -5020,7 +5011,7 @@ nochange:
cfg.showdetail ? (printptr = &printent_long) : (printptr = &printent); cfg.showdetail ? (printptr = &printent_long) : (printptr = &printent);
cfg.blkorder = 0; cfg.blkorder = 0;
continue; continue;
default: /* SEL_ORDER */ default: /* SEL_SORT */
r = get_input(messages[MSG_ORDER]); r = get_input(messages[MSG_ORDER]);


if ((r == 'a' || r == 'd' || r == 'e' || r == 's' || r == 't') if ((r == 'a' || r == 'd' || r == 'e' || r == 's' || r == 't')


+ 3
- 3
src/nnn.h 查看文件

@@ -67,7 +67,7 @@ enum action {
SEL_STATS, SEL_STATS,
SEL_CHMODX, SEL_CHMODX,
SEL_ARCHIVE, SEL_ARCHIVE,
SEL_ORDER, SEL_SORT,
SEL_REDRAW, SEL_REDRAW,
SEL_SEL, SEL_SEL,
SEL_SELMUL, SEL_SELMUL,
@@ -174,8 +174,8 @@ static struct key bindings[] = {
/* Create archive */ /* Create archive */
{ 'z', SEL_ARCHIVE }, { 'z', SEL_ARCHIVE },
/* Sort toggles */ /* Sort toggles */
{ 't', SEL_ORDER }, { 't', SEL_SORT },
{ CONTROL('T'), SEL_ORDER }, { CONTROL('T'), SEL_SORT },
/* Redraw window */ /* Redraw window */
{ CONTROL('L'), SEL_REDRAW }, { CONTROL('L'), SEL_REDRAW },
/* Select current file path */ /* Select current file path */


||||||
x
 
000:0
Loading…
取消
儲存