xaizek / pipedial (License: GPLv3 only) (since 2019-01-08)
One more tool for selecting something in console.
Commit 8bcdb2de69e697aee2fbf18d31994d194f27e188

Extract PipeDial::editAndAccept() method
To shorten PipeDial::buildNormalMode().
Author: xaizek
Author date (UTC): 2020-07-29 16:55
Committer name: xaizek
Committer date (UTC): 2020-07-29 16:55
Parent(s): a9884d86dfb4b54b28d2fbf85f70ac4e87e52421
Signing key: 99DC5E4DB05F6BE2
Tree: a3c3c1498930d0d08fa3de5f83f95f9f71115291
File Lines added Lines deleted
src/PipeDial.cpp 22 17
src/PipeDial.hpp 2 0
File src/PipeDial.cpp changed (mode: 100644) (index 517ed1c..1f679a4)
... ... PipeDial::buildNormalMode()
201 201 modes.switchTo("help"); modes.switchTo("help");
202 202 screen.replaceTopWidget(&help); screen.replaceTopWidget(&help);
203 203 }, "display help" }); }, "display help" });
204 normalMode.addShortcut({ L"e", [&]() {
205 cursed::Prompt prompt;
206 cursed::Track tmpTrack;
207 tmpTrack.addItem(&title);
208 tmpTrack.addItem(&list);
209 tmpTrack.addItem(&prompt);
210
211 cursedrl::PromptRequest request(screen, prompt);
212 screen.replaceTopWidget(&tmpTrack);
213 if (cursedrl::PromptResult r = request.prompt(L"Edit and accept: ",
214 list.getCurrent())) {
215 result = r.getResult();
216 quit = true;
217 } else {
218 screen.replaceTopWidget(&track);
219 }
220 }, "edit and accept" });
204 normalMode.addShortcut({ L"e", [this]() { editAndAccept(); },
205 "edit and accept" });
221 206 normalMode.addShortcut({ vle::Key(L'e').ctrl(), [&]() { normalMode.addShortcut({ vle::Key(L'e').ctrl(), [&]() {
222 207 list.scrollDown(); list.scrollDown();
223 208 }, "scroll one line down" }); }, "scroll one line down" });
 
... ... PipeDial::buildNormalMode()
230 215 return normalMode; return normalMode;
231 216 } }
232 217
218 void
219 PipeDial::editAndAccept()
220 {
221 cursed::Prompt prompt;
222 cursed::Track tmpTrack;
223 tmpTrack.addItem(&title);
224 tmpTrack.addItem(&list);
225 tmpTrack.addItem(&prompt);
226
227 cursedrl::PromptRequest request(screen, prompt);
228 screen.replaceTopWidget(&tmpTrack);
229 if (cursedrl::PromptResult r = request.prompt(L"Edit and accept: ",
230 list.getCurrent())) {
231 result = r.getResult();
232 quit = true;
233 } else {
234 screen.replaceTopWidget(&track);
235 }
236 }
237
233 238 void void
234 239 PipeDial::filter() PipeDial::filter()
235 240 { {
File src/PipeDial.hpp changed (mode: 100644) (index 63e1125..4ca7cb8)
... ... private:
57 57 // Constructs help mode. // Constructs help mode.
58 58 vle::Mode buildHelpMode(); vle::Mode buildHelpMode();
59 59
60 // Accepts current item after editing it.
61 void editAndAccept();
60 62 // Handles line filtering. // Handles line filtering.
61 63 void filter(); void filter();
62 64
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/pipedial

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/pipedial

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master