diff options
author | Přemysl Janouch <p@janouch.name> | 2018-11-02 22:12:34 +0100 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2018-11-02 22:12:34 +0100 |
commit | 579e4c9a34b98059530f08133b77f4ab44a60e91 (patch) | |
tree | b0553cf6d50bdfc68b2a57236b5b9f93ab7a8e54 /sdn.cpp | |
parent | 3c056dde9138d3c575cde8acb9fa9c8851e1072e (diff) | |
download | sdn-579e4c9a34b98059530f08133b77f4ab44a60e91.tar.gz sdn-579e4c9a34b98059530f08133b77f4ab44a60e91.tar.xz sdn-579e4c9a34b98059530f08133b77f4ab44a60e91.zip |
Make confirming a search choose the item
Diffstat (limited to 'sdn.cpp')
-rw-r--r-- | sdn.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -478,6 +478,7 @@ static struct { string chosen; ///< Chosen item for the command line bool no_chdir; ///< Do not tell the shell to chdir + bool quitting; ///< Whether we should quit already int inotify_fd, inotify_wd = -1; ///< File watch bool out_of_date; ///< Entries may be out of date @@ -924,15 +925,15 @@ fun change_dir (const string &path) { } } -fun choose (const entry &entry) -> bool { +fun choose (const entry &entry) { // Dive into directories and accessible symlinks to them if (!S_ISDIR (entry.info.st_mode) && !S_ISDIR (entry.target_info.st_mode)) { g.chosen = entry.filename; - return false; + g.quitting = true; + } else { + change_dir (entry.filename); } - change_dir (entry.filename); - return true; } fun handle_editor (wint_t c) { @@ -976,19 +977,20 @@ fun handle (wint_t c) -> bool { case ACTION_CHOOSE_FULL: g.chosen = g.cwd + "/" + current.filename; g.no_chdir = true; - return false; + g.quitting = true; + break; case ACTION_CHOOSE: - if (choose (current)) - break; - return false; + choose (current); + break; case ACTION_HELP: show_help (); - return true; + break; case ACTION_QUIT_NO_CHDIR: g.no_chdir = true; - return false; + // Fall-through case ACTION_QUIT: - return false; + g.quitting = true; + break; case ACTION_SORT_LEFT: g.sort_column = (g.sort_column + entry::COLUMNS - 1) % entry::COLUMNS; @@ -1048,6 +1050,9 @@ fun handle (wint_t c) -> bool { g.editor_on_change = [] { search (g.editor_line); }; + g.editor_on_confirm = [] { + choose (g.entries[g.cursor]); + }; break; case ACTION_RENAME_PREFILL: g.editor_line = to_wide (current.filename); @@ -1084,7 +1089,7 @@ fun handle (wint_t c) -> bool { } fix_cursor_and_offset (); update (); - return true; + return !g.quitting; } fun inotify_check () { |