Schim
vim.h
Go to the documentation of this file.
1 #ifndef VIM_H
3 #define VIM_H
4 
5 #include <QKeyEvent>
6 
19 #define vimdo(N) for (int Intentionally_Long_Unlikely_Name = 0;\
20  Intentionally_Long_Unlikely_Name < N; ++Intentionally_Long_Unlikely_Name)
21 
25 namespace Vim
26 {
27 
48 class Count
49 {
50  int count;
51 public:
56  Count(int count);
57 
62  operator int() const;
64  int raw() const;
65 };
66 
68 typedef Count N;
69 
81 class Action
82 {
83  // A count of 0 means that no count was specified
84  int count = 0;
85  // in_reg = -1 means that the stroke takes no input register
86  char in_reg = -1;
87  QString command;
88  //TODO motion;
89 
90 public:
92  explicit Action(const QString &command, int count = 0);
93 
95  QString getCommand() const;
97  Count getCount() const;
98 
100  bool operator==(const QString &cmd) const;
101 };
102 
104 void enable(bool enable);
106 bool enabled();
108 Count n();
109 
115 void addBinding(const QString &sequence, const QString &action);
120 void addBindings(const QMap<QString, QString> &map);
151 void registerKeyPress(QKeyEvent *event,
152  std::function<bool(const Action &action)> callback,
153  bool allowCount = true);
157 void resetStroke();
158 
160 QString getStatusText();
161 
162 } // namespace Vim
163 
164 #endif // VIM_H
void registerKeyPress(QKeyEvent *event, std::function< bool(const Action &action)> callback, bool allowCount=true)
Process a key press in vim-mode.
Count(int count)
Construct a vim-count.
int raw() const
Get the raw count from this Count.
Count n()
The vim-count from the current key sequence.
An action in vim-mode.
Definition: vim.h:81
void addBindings(const QMap< QString, QString > &map)
Convenient alternative to multiple calls of Vim::addBinding.
void resetStroke()
Discard the current key sequence and reset vim status indicator.
void enable(bool enable)
Enable/Disable vim-mode throughout the application instance.
bool enabled()
Is vim-mode enabled?
void addBinding(const QString &sequence, const QString &action)
Register a keybinding with Vim-mode.
Everything related to vim-mode inside schim.
Definition: vim.h:25
QString getStatusText()
Get the vim status text for the current key sequence.
Count N
Convenience typedef.
Definition: vim.h:68
Representation of a vim-count.
Definition: vim.h:48