xaizek / libcursedrl (License: GPLv3+) (since 2019-03-24)
libcursed extension for integration with readline.
Commit e40130a8d2a8374195824ee363a6c248d70c7c9d

Add prompt history saving and loading
Having it in a separate class might be useful.
Author: xaizek
Author date (UTC): 2019-03-23 11:56
Committer name: xaizek
Committer date (UTC): 2019-03-24 18:22
Parent(s): f663c5f11e5acb30ced31cee2461018e1d2d5ca8
Signing key: 99DC5E4DB05F6BE2
Tree: c6205c8938a54b11fb5d851abbb7790edaa91f5b
File Lines added Lines deleted
PromptRequest.cpp 12 0
PromptRequest.hpp 6 0
File PromptRequest.cpp changed (mode: 100644) (index f64c351..80efa15)
... ... private:
69 69
70 70 } }
71 71
72 void
73 PromptRequest::loadHistory(const std::string &path)
74 {
75 static_cast<void>(read_history(path.c_str()));
76 }
77
78 void
79 PromptRequest::saveHistory(const std::string &path)
80 {
81 static_cast<void>(write_history(path.c_str()));
82 }
83
72 84 PromptResult::PromptResult() : hasInput(false) PromptResult::PromptResult() : hasInput(false)
73 85 { } { }
74 86
File PromptRequest.hpp changed (mode: 100644) (index aa6dc60..f75531b)
... ... public:
75 75 PromptRequest & operator=(const PromptRequest &rhs) = delete; PromptRequest & operator=(const PromptRequest &rhs) = delete;
76 76 PromptRequest & operator=(PromptRequest &&rhs) = delete; PromptRequest & operator=(PromptRequest &&rhs) = delete;
77 77
78 public:
79 // Loads history from the file.
80 static void loadHistory(const std::string &path);
81 // Stores history to the file.
82 static void saveHistory(const std::string &path);
83
78 84 public: public:
79 85 // Sets callback to be invoked when input is changed. // Sets callback to be invoked when input is changed.
80 86 void setOnInputChanged(inputChangedFunc newOnInputChanged); void setOnInputChanged(inputChangedFunc newOnInputChanged);
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/libcursedrl

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

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