File | Lines added | Lines deleted |
---|---|---|
docs/03-options.md | 6 | 1 |
docs/pipedial.1 | 4 | 1 |
src/Args.cpp | 2 | 0 |
src/Args.hpp | 6 | 1 |
src/PipeDial.cpp | 5 | 1 |
src/PipeDial.hpp | 1 | 1 |
src/main.cpp | 1 | 1 |
File docs/03-options.md changed (mode: 100644) (index 486faab..521e5a2) | |||
... | ... | OPTIONS | |
7 | 7 | Display short usage help. | Display short usage help. |
8 | 8 | ||
9 | 9 | **--version** | **--version** |
10 | ----------------- | ||
10 | ------------- | ||
11 | 11 | ||
12 | 12 | Display version information. | Display version information. |
13 | |||
14 | **--filter, -f** | ||
15 | ---------------- | ||
16 | |||
17 | Start in filtering mode. |
File docs/pipedial.1 changed (mode: 100644) (index 115f2f6..6f1e733) | |||
1 | 1 | .\" Automatically generated by Pandoc 1.17.0.3 | .\" Automatically generated by Pandoc 1.17.0.3 |
2 | 2 | .\" | .\" |
3 | .TH "pipedial" "1" "July 29, 2020" "" "" | ||
3 | .TH "pipedial" "1" "September 20, 2020" "" "" | ||
4 | 4 | .hy | .hy |
5 | 5 | .SH NAME | .SH NAME |
6 | 6 | .PP | .PP |
... | ... | Display short usage help. | |
23 | 23 | .SS \f[B]\-\-version\f[] | .SS \f[B]\-\-version\f[] |
24 | 24 | .PP | .PP |
25 | 25 | Display version information. | Display version information. |
26 | .SS \f[B]\-\-filter, \-f\f[] | ||
27 | .PP | ||
28 | Start in filtering mode. | ||
26 | 29 | .SH SHORTCUTS | .SH SHORTCUTS |
27 | 30 | .PP | .PP |
28 | 31 | \f[B]{Escape}\f[] \-\- abort partially typed shortcut. | \f[B]{Escape}\f[] \-\- abort partially typed shortcut. |
File src/Args.cpp changed (mode: 100644) (index 92ac31c..994f5ad) | |||
... | ... | Args::Args(int argc, const char *argv[]) | |
26 | 26 | TCLAP::CmdLine cmd("Terminal element picker.", ' ', "0.2"); | TCLAP::CmdLine cmd("Terminal element picker.", ' ', "0.2"); |
27 | 27 | TCLAP::ValueArg<std::string> titleArg("t", "title", "Title message", false, | TCLAP::ValueArg<std::string> titleArg("t", "title", "Title message", false, |
28 | 28 | "", "string", cmd); | "", "string", cmd); |
29 | TCLAP::SwitchArg filterArg("f", "filter", "Start in filtering mode", cmd); | ||
29 | 30 | ||
30 | 31 | cmd.parse(argc, argv); | cmd.parse(argc, argv); |
31 | 32 | ||
32 | 33 | title = (titleArg.isSet() ? titleArg.getValue() : "Pick an item:"); | title = (titleArg.isSet() ? titleArg.getValue() : "Pick an item:"); |
34 | filterOnStart = filterArg.isSet(); | ||
33 | 35 | } | } |
File src/Args.hpp changed (mode: 100644) (index 80410d4..67bb1a0) | |||
... | ... | public: | |
32 | 32 | std::string getTitle() const | std::string getTitle() const |
33 | 33 | { return title; } | { return title; } |
34 | 34 | ||
35 | // Retrieves filter-on-start flag. | ||
36 | bool getFilterOnStart() const | ||
37 | { return filterOnStart; } | ||
38 | |||
35 | 39 | public: | public: |
36 | std::string title; // Title of the list. | ||
40 | std::string title; // Title of the list. | ||
41 | bool filterOnStart; // Start in filtering mode. | ||
37 | 42 | }; | }; |
38 | 43 | ||
39 | 44 | #endif // PIPEDIAL__ARGS_HPP__ | #endif // PIPEDIAL__ARGS_HPP__ |
File src/PipeDial.cpp changed (mode: 100644) (index 1f679a4..6ea47bb) | |||
... | ... | PipeDial::buildHelpMode() | |
341 | 341 | } | } |
342 | 342 | ||
343 | 343 | std::wstring | std::wstring |
344 | PipeDial::run() | ||
344 | PipeDial::run(bool filterOnStart) | ||
345 | 345 | { | { |
346 | 346 | // Make sure curses lets go of the screen when this method ends. | // Make sure curses lets go of the screen when this method ends. |
347 | 347 | struct S { | struct S { |
... | ... | PipeDial::run() | |
350 | 350 | } s { screen }; | } s { screen }; |
351 | 351 | ||
352 | 352 | screen.replaceTopWidget(&track); | screen.replaceTopWidget(&track); |
353 | |||
354 | if (filterOnStart) { | ||
355 | filter(); | ||
356 | } | ||
353 | 357 | screen.draw(); | screen.draw(); |
354 | 358 | ||
355 | 359 | vle::KeyDispatcher dispatcher; | vle::KeyDispatcher dispatcher; |
File src/PipeDial.hpp changed (mode: 100644) (index 4ca7cb8..c23c863) | |||
... | ... | public: | |
47 | 47 | public: | public: |
48 | 48 | // Runs the app. Returns user's pick, empty result means "nothing was | // Runs the app. Returns user's pick, empty result means "nothing was |
49 | 49 | // picked". | // picked". |
50 | std::wstring run(); | ||
50 | std::wstring run(bool filterOnStart); | ||
51 | 51 | ||
52 | 52 | private: | private: |
53 | 53 | // Constructs help message. | // Constructs help message. |
File src/main.cpp changed (mode: 100644) (index f4d8c13..08ca77b) | |||
... | ... | main(int argc, const char *argv[]) | |
50 | 50 | ||
51 | 51 | PipeDial app(cursed::toWide(args.getTitle()), std::move(lines)); | PipeDial app(cursed::toWide(args.getTitle()), std::move(lines)); |
52 | 52 | ||
53 | std::string result = cursed::toNarrow(app.run()); | ||
53 | std::string result = cursed::toNarrow(app.run(args.getFilterOnStart())); | ||
54 | 54 | if (result.empty()) { | if (result.empty()) { |
55 | 55 | return EXIT_FAILURE; | return EXIT_FAILURE; |
56 | 56 | } | } |