Commit Graph

23 Commits

Author SHA1 Message Date
Érico Nogueira a265492706 Add intial query command line option.
It has an existing bug where the filter is only applied after the first
user interaction.
2022-08-13 00:19:05 -03:00
Érico Nogueira 69efce1d95 Add print_prompt funtion. 2022-08-13 00:11:32 -03:00
Érico Nogueira 55ae15eb6f Token length is now limited.
Otherwise it's necessary to be able to propagate back into the token
list the new location of a resized string.
2022-08-13 00:05:50 -03:00
Érico Nogueira a0951f2aa5 Only deal with ASCII printable characters.
At least for now, it's easier than dealing with unicode properly.
2022-08-13 00:05:50 -03:00
Érico Nogueira 8bf7ceef41 Clean up ef.c.
Use do{ /*things*/ }while(0) for macro with code, update comments and remove
unnecessary one.
2022-08-12 23:48:50 -03:00
Érico Nogueira ec6014a0e5 Duplicate stdin fd before reading from it.
Otherwise, stdin will have an error state of EOF, leading to wgetch()
returning -1, which is unexpected, given that we polled the file
descriptor for data.
2022-08-12 23:48:50 -03:00
Érico Nogueira 8f38a81690 Add some command line options.
- delimiter choice
- compatibility with fzf
2022-08-12 23:48:50 -03:00
Érico Nogueira cbb98853d1 Fix bug in entry reading.
- deal with empty lines correctly: single letter options that don't get
  a newline were being missed
- entirely empty lines (empty line without a newline) weren't being used
  correctly
- fix UB from not setting line=NULL
- use the delim parameter instead of hardcoding for newlines
2022-08-12 23:48:50 -03:00
Érico Nogueira b734660c96 Use poll(3) and self pipe for signal handling.
Actually safe to perform the terminal cleanup here. We keep using
exit(3) and quick_exit(3) so that only one of them actually prints the
results to the screen.
2022-08-12 23:48:36 -03:00
Érico Nogueira a0ce797775 Use /dev/tty instead of stderr for interactivity. 2022-08-12 15:03:10 -03:00
Érico Rolim 4e174d9126 Rename executable to ef.
Maybe ef for "érico's finder"?

Also add install target.
2021-01-08 02:02:52 -03:00
Érico Rolim 70a8aba601 Various small fixes.
- make nrows size_t to avoid casting so much
- add fast exit cases for 0 and 1 input values
- don't print anything if entries.ms==0 and RETURN is pressed
- don't match an empty line when reading values from stdin
2021-01-08 01:46:42 -03:00
Érico Rolim 3edddbfc79 Fix display/navigation of results when tokens change.
- always use listsize to calculate listy
  - in init code: for semantic meaning
  - in the code for scroll: to fix an overflow bug
  (listy+nrows >>> entries.ms)

- change WRITELIST macro to support two indexes

- make index_in_matched be set by the search part, so the scroll part
can rely on it; also reset it when entries.ms=0

- leave ifdef'd out a partial implementation for a version that when
updating search results tries to stick to the value instead of on-screen
position
2021-01-08 01:45:07 -03:00
Érico Rolim 7385d08bf1 Rework the list so navigating with arrows fully works.
It's still necessary to fix display after a query, but the current
navigation should just work when that's added.
2021-01-07 20:59:58 -03:00
Érico Rolim 1e42b5527e Add sort_entries, make filter_entries(a, 0) set a.m[i]=true.
- sorting the entries is just better UI
- filter_entries() is used to initialize a.ms to a.n, but it can lead to
weird things if all a.m members aren't also initialized
2021-01-07 20:59:33 -03:00
Érico Rolim 472337a477 Support case insensitive search.
Enabled only if there is an upper string character in the search tokens.

Also call setlocale() in main() to guarantee correct behavior.
2021-01-07 18:44:12 -03:00
Érico Rolim 68226bc337 Support arbitratily sized search tokens. 2021-01-07 18:29:20 -03:00
Érico Rolim dba748f593 Add xmalloc and xrealloc wrappers. 2021-01-07 18:23:36 -03:00
Érico Rolim ef21f16b54 Implement token search.
- only shows results that match all tokens
- tokens are generated by adding a space to the query
2021-01-07 18:17:20 -03:00
Érico Rolim ab99ea260b Switch to using a pad for the list, add working navigation. 2021-01-07 17:36:12 -03:00
Érico Rolim 8f70f6e213 Add basic structure to print only result to stdout.
Also reorganize init sequence a bit, and add KEY_ENTER as a recognized
input.
2021-01-07 16:34:12 -03:00
Érico Rolim 4ae24894e7 Split implementation into multiple files.
Also add comments for improvements.
2021-01-07 16:07:16 -03:00
Érico Rolim d10e9cbc23 Initial commit.
Single file with the whole implementation. Keypad interaction is still
murky; how exactly do I read a backspace or Ctrl+W command?
2021-01-07 16:07:12 -03:00