xaizek / libvle (License: GPLv3+) (since 2019-04-21)
Library for building Vim-like applications.
Commit 32bc9c91577dc939193d80455d5413838783e262

Add README file
Author: xaizek
Author date (UTC): 2019-04-21 14:20
Committer name: xaizek
Committer date (UTC): 2019-04-21 14:24
Parent(s): e0626da2657b18fd7ef3b38b4a7e70113a1993d4
Signing key: 99DC5E4DB05F6BE2
Tree: 47b252aaa71ae02ca7448605efb9ae63250cc622
File Lines added Lines deleted
README.md 108 0
File README.md added (mode: 100644) (index 0000000..ac0a57f)
1 **libvle**, _2019_
2
3 _This file last updated on 21 April, 2019_
4
5 ### Brief Description ###
6
7 This is a C++11 library that provides basic classes for implementing Vim-like
8 behaviour. Although the interface is in C++, core of the implementation is in
9 C.
10
11 VLE stands for Vim-Like Engine.
12
13 #### Goals ####
14
15 The obvious purpose is to avoid reimplementing Vim-like functionality over and
16 over again and instead do it once in a reusable manner.
17
18 #### Implementation state ####
19
20 It was extracted out of [vifm][vifm] for a couple of projects, has minimally
21 necessary functionality and can change quite a bit in the future. The
22 implementations might diverge as there is currently no synchronization process
23 in place.
24
25 #### Throw-in library state ####
26
27 There is no build system and nothing is getting built for the client. To use
28 it clone the repository (possibly as a submodule) and handle the building with
29 the build system that's used by the main project. Compile C++ files with C++11
30 enabled.
31
32 ### Prerequisites ###
33
34 * C++11 capable compiler
35
36 ### Structure ###
37
38 #### API ####
39
40 The API consists of classes in the `vle` namespace.
41
42 #### What's available ####
43
44 As noted above, API is extended to accomodate use cases and currently includes
45 only:
46
47 * `Modes` -- handles initialization, deinitialization and switching modes
48 * `Mode` -- contains mode configuration
49 * `Shortcut` -- shortcuts with optional support of count
50 * `KeyDispatcher` -- input processor
51
52 #### How to use ####
53
54 1. Create `Mode` objects and populate them with `Shortcut` objects.
55 2. Put `Mode` objects into `Modes`.
56 3. Feed input to `KeyDispatcher`, which will trigger shortcut handlers.
57
58 ### Sample ###
59
60 Very minimal application:
61
62 ```cxx
63 #include <cstdlib>
64
65 #include <iostream>
66 #include <string>
67
68 #include "vle/KeyDispatcher.hpp"
69 #include "vle/Mode.hpp"
70 #include "vle/Modes.hpp"
71
72 int
73 main()
74 {
75 vle::Mode normalMode("normal");
76 normalMode.setUsesCount(true);
77 normalMode.addShortcut({ L"gg", [&]() {
78 std::wcout << L"go to the top\n";
79 }, "go to the top" });
80 normalMode.addShortcut({ L"j", [&](int i) {
81 std::wcout << L"go down " << (i == -1 ? 1 : i) << L" item(s)\n";
82 }, "go down" });
83
84 std::vector<vle::Mode> allModes;
85 allModes.emplace_back(std::move(normalMode));
86
87 vle::Modes modes;
88 modes.setModes(std::move(allModes));
89 modes.switchTo("normal");
90
91 vle::KeyDispatcher dispatcher;
92
93 for (std::wstring ws; std::wcout << L" User input: ",
94 std::getline(std::wcin, ws); ) {
95 for (wchar_t wc : ws) {
96 std::wcout << L" > Sending in: " << wc << L'\n';
97 dispatcher.dispatch(wc);
98 std::wcout << L" > Buffered: " << dispatcher.getPendingInput()
99 << L'\n';
100 }
101 std::wcout << L"\n";
102 }
103
104 return EXIT_SUCCESS;
105 }
106 ```
107
108 [vifm]: https://vifm.info/
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/libvle

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

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