commit 9f6d1cfb334d7268608e04379400ce8bbe0429c9
parent d909de605c133037b72b4cfbcd34e83b130aa55c
Author: sin <sin@2f30.org>
Date: Mon, 8 Feb 2016 16:52:07 +0000
Remove filter as you type mode
Nobody uses it and adds additional complexity.
Diffstat:
3 files changed, 2 insertions(+), 100 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -32,8 +32,6 @@ struct key bindings[] = {
/* Filter */
{ '/', SEL_FLTR },
{ '&', SEL_FLTR },
- /* Filter as you type */
- { '?', SEL_TYPE },
/* Next */
{ 'j', SEL_NEXT },
{ KEY_DOWN, SEL_NEXT },
diff --git a/noice.1 b/noice.1
@@ -47,8 +47,6 @@ Open file or enter directory.
Back up one directory level.
.It Ic / or &
Change filter (see below for more information).
-.It Ic \&?
-Enter filter-as-you-type mode.
.It Ic c
Change into the given directory.
.It Ic t
diff --git a/noice.c b/noice.c
@@ -50,7 +50,6 @@ enum action {
SEL_BACK,
SEL_GOIN,
SEL_FLTR,
- SEL_TYPE,
SEL_NEXT,
SEL_PREV,
SEL_PGDN,
@@ -355,58 +354,6 @@ readln(void)
return ln[0] ? strdup(ln) : NULL;
}
-/*
- * Read one key and modify the provided string accordingly.
- * Returns 0 when more input is expected and 1 on completion.
- */
-int
-readmore(char **str)
-{
- int c, ret = 0;
- int i;
- char *ln = *str;
-
- timeout(-1);
- if (ln != NULL)
- i = strlen(ln);
- else
- i = 0;
- DPRINTF_D(i);
-
- curs_set(TRUE);
-
- c = getch();
- switch (c) {
- case KEY_ENTER:
- case '\r':
- ret = 1;
- break;
- case KEY_BACKSPACE:
- case CONTROL('H'):
- i--;
- if (i > 0) {
- ln = xrealloc(ln, (i + 1) * sizeof(*ln));
- ln[i] = '\0';
- } else {
- free(ln);
- ln = NULL;
- }
- break;
- default:
- i++;
- ln = xrealloc(ln, (i + 1) * sizeof(*ln));
- ln[i - 1] = c;
- ln[i] = '\0';
- }
-
- curs_set(FALSE);
-
- *str = ln;
- timeout(1000);
-
- return ret;
-}
-
int
canopendir(char *path)
{
@@ -627,25 +574,18 @@ browse(const char *ipath, const char *ifilter)
struct stat sb;
regex_t re;
int r, fd;
- int nowtyping = 0;
strlcpy(path, ipath, sizeof(path));
strlcpy(fltr, ifilter, sizeof(fltr));
begin:
r = populate();
if (r == -1) {
- if (!nowtyping) {
- printwarn();
- goto nochange;
- }
+ printwarn();
+ goto nochange;
}
for (;;) {
redraw();
-
- /* Handle filter-as-you-type mode */
- if (nowtyping)
- goto moretyping;
nochange:
switch (nextsel(&run, &env)) {
case SEL_QUIT:
@@ -734,40 +674,6 @@ nochange:
if (n > 0)
mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
goto begin;
- case SEL_TYPE:
- nowtyping = 1;
- tmp = NULL;
-moretyping:
- printprompt("type: ");
- if (tmp != NULL)
- printw("%s", tmp);
- r = readmore(&tmp);
- DPRINTF_D(r);
- DPRINTF_S(tmp);
- if (r == 1)
- nowtyping = 0;
- /* Check regex errors */
- if (tmp != NULL) {
- r = setfilter(&re, tmp);
- if (r != 0)
- if (nowtyping) {
- goto moretyping;
- } else {
- free(tmp);
- goto nochange;
- }
- }
- /* Copy or reset filter */
- if (tmp != NULL)
- strlcpy(fltr, tmp, sizeof(fltr));
- else
- strlcpy(fltr, ifilter, sizeof(fltr));
- /* Save current */
- if (n > 0)
- mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
- if (!nowtyping)
- free(tmp);
- goto begin;
case SEL_NEXT:
if (cur < n - 1)
cur++;