• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H14-Feb-2021-5742

.theia/H14-Feb-2021-76

cargo-crates/H03-May-2022-382,515340,189

ci/H14-Feb-2021-5433

src/H03-May-2022-1,7581,221

syntax.d/H14-Feb-2021-6456

.all-contributorsrcH A D14-Feb-20213.2 KiB121120

.gitignoreH A D14-Feb-202139 54

.gitpod.DockerfileH A D14-Feb-2021118 63

.gitpod.ymlH A D14-Feb-2021443 1512

.markdownlint.jsonH A D14-Feb-2021409 2625

.travis.ymlH A D14-Feb-20213.5 KiB10187

CHANGELOG.mdH A D14-Feb-20214.5 KiB10876

COPYRIGHTH A D14-Feb-20211.8 KiB3728

Cargo.lockH A D14-Feb-20217.5 KiB293259

Cargo.tomlH A D14-Feb-2021871 3125

LICENSE-APACHEH A D14-Feb-2021553 1410

LICENSE-MITH A D14-Feb-20211 KiB84

README.mdH A D14-Feb-202115.4 KiB354261

config_example.iniH A D14-Feb-2021337 139

count_loc.shH A D14-Feb-20211.3 KiB4726

rustfmt.tomlH A D14-Feb-2021316 1211

README.md

1# Kibi: A text editor in ≤1024 lines of code, written in Rust
2
3[![Build Status](https://img.shields.io/travis/com/ilai-deutel/kibi/master?logo=travis)](https://travis-ci.com/ilai-deutel/kibi)
4[![Crate](https://img.shields.io/crates/v/kibi.svg)](https://crates.io/crates/kibi)
5[![Minimum rustc version](https://img.shields.io/badge/rustc-1.41+-blue.svg?logo=rust)](https://www.rust-lang.org/)
6[![Platform](https://img.shields.io/badge/platform-Linux%20%7C%20macOS%20%7C%20Windows%2010-blue)](#)
7[![Packaging status](https://repology.org/badge/tiny-repos/kibi.svg)](https://repology.org/project/kibi/versions)
8[![License](https://img.shields.io/crates/l/kibi?color=blue)](#license)
9[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ilai-deutel/kibi
10)<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
11[![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg)](#contributors)
12<!-- ALL-CONTRIBUTORS-BADGE:END -->
13
14[![asciicast](https://gist.githubusercontent.com/ilai-deutel/39670157dd008d9932b2f2fd3c885cca/raw/bfdbfc96181c4f6e3ce2663c25c6e97bf57c8684/kibi.gif)](https://asciinema.org/a/KY7tKPlxHXqRdJiv5KaTJbPj5)
15
16A configurable text editor with UTF-8 support, incremental search, syntax
17highlighting, line numbers and more, written in less than 1024
18lines<sup>[1](#counted-with)</sup> of Rust with minimal dependencies.
19
20Kibi is compatible with Linux, macOS, and Windows
2110<sup>[2](#windows-version)</sup>.
22
23This project is inspired by [`kilo`](https://github.com/antirez/kilo), a text
24editor written in C.
25See [comparison](#comparison-with-kilo) below for a list of additional features.
26
27Contributions are welcome! Be careful to stay below the 1024-line limit...
28
29<!-- markdownlint-disable MD033 -->
30<sub><a name="counted-with">1.</a>: Counted with
31[`count_loc.sh`](count_loc.sh)</sub> \
32<sub><a name="windows-version">2.</a>: Kibi requires the terminal to support
33ANSI escape sequences. Windows 10 version 1703 ([Creators Update](https://devblogs.microsoft.com/commandline/windows-10-creators-update-whats-new-in-bashwsl-windows-console),
34April 2017) and above are supported.</sub>
35<!-- markdownlint-enable MD033 -->
36
37## Table of contents
38
39* [Installation](#installation)
40  * [With cargo](#with-cargo)
41  * [Arch User Repository (Arch Linux)](#arch-user-repository-arch-linux)
42  * [Android (with Termux)](#android-with-termux)
43  * [Fedora/CentOS](#fedoracentos)
44  * [NetBSD](#netbsd)
45* [Usage](#usage)
46  * [Keyboard shortcuts](#keyboard-shortcuts)
47  * [Configuration](#configuration)
48    * [Global configuration](#global-configuration)
49    * [Syntax highlighting](#syntax-highlighting)
50* [Comparison with kilo](#comparison-with-kilo)
51* [Dependencies](#dependencies)
52* [Why Kibi?](#why-kibi)
53* [Contributors](#contributors)
54* [License](#license)
55
56## Installation
57
58<!-- markdownlint-disable MD033 -->
59<a href="https://repology.org/project/kibi/versions">
60    <img src="https://repology.org/badge/vertical-allrepos/kibi.svg"
61    alt="Packaging status" align="right">
62</a>
63<!-- markdownlint-enable MD033 -->
64
65### With `cargo`
66
67You can install Kibi with [`cargo`](https://github.com/rust-lang/cargo/):
68
69```bash
70cargo install kibi
71```
72
73Syntax highlighting configuration files are available in the
74[`syntax.d`](syntax.d) directory of this repository. They need to be placed in
75one of the configuration directories mentioned in the
76[Configuration/Syntax Highlighting](#syntax-highlighting) section.
77
78For instance:
79
80```bash
81cd ~/repos
82git clone https://github.com/ilai-deutel/kibi.git
83mkdir -p ~/.local/share/kibi/
84ln -sr ./kibi/syntax.d ~/.local/share/kibi/syntax.d
85```
86
87### Arch User Repository (Arch Linux)
88
892 packages are available on the AUR:
90[`kibi`](https://aur.archlinux.org/packages/kibi) and
91[`kibi-git`](https://aur.archlinux.org/packages/kibi-git).
92
93<details><summary>Installation instructions</summary>
94
951. Installation with an AUR helper, for instance using `yay`:
96
97   ```bash
98   yay -Syu kibi  # or yay -Syu kibi-git
99   ```
100
1012. Install manually with `makepkg`:
102
103   ```bash
104   git clone https://aur.archlinux.org/kibi.git  # or git clone https://aur.archlinux.org/kibi-git.git
105   cd kibi
106   makepkg -si
107   ```
108
109</details>
110
111### Android (with Termux)
112
113Kibi is available as [a Termux package](https://github.com/termux/termux-packages/tree/master/packages/kibi).
114
115<details><summary>Installation instructions</summary>
116
1171. Install Termux:
118
119   [![Get it on F-Droid"](https://user-images.githubusercontent.com/10098207/80576418-fe805600-89b9-11ea-82a5-7dc00c0ccc50.png)](https://f-droid.org/repository/browse/?fdid=com.termux)
120   [![Get it on Google Play"](https://user-images.githubusercontent.com/10098207/80576344-e27cb480-89b9-11ea-9fa6-08ec94af10cb.png)](https://play.google.com/store/apps/details?id=com.termux)
121
1222. Install Kibi within Termux: `pkg install kibi`
123
124</details>
125
126### Fedora/CentOS
127
128The package is available in COPR as [`atim/kibi`](https://copr.fedorainfracloud.org/coprs/atim/kibi).
129
130<details><summary>Installation instructions</summary>
131
132```bash
133sudo dnf copr enable atim/kibi -y
134sudo dnf install kibi
135```
136
137</details>
138
139### NetBSD
140
141Kibi is available from [the official repos](https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc/editors/kibi/README.html).
142
143
144<details><summary>Installation instructions</summary>
145
146Install using:
147
148```bash
149pkgin install kibi
150```
151
152or build from source:
153
154```bash
155cd /usr/pkgsrc/editors/kibi
156make install
157```
158
159</details>
160
161## Usage
162
163```bash
164kibi              # Start an new text buffer
165kibi <file path>  # Open a file
166kibi --version    # Print version information and exit
167```
168
169### Keyboard shortcuts
170
171| Keyboard shortcut | Description                                                   |
172| ----------------- | ------------------------------------------------------------- |
173| Ctrl-F            | Incremental search; use arrows to navigate                    |
174| Ctrl-S            | Save the buffer to the current file, or specify the file path |
175| Ctrl-G            | Go to `<line number>[:<column number>]` position              |
176| Ctrl-Q            | Quit                                                          |
177| Ctrl-D            | Duplicate the current row                                     |
178| Ctrl-E            | Execute an external command and paste its output              |
179
180### Configuration
181
182#### Global configuration
183
184Kibi can be configured using a configuration file. It must follow this format:
185
186```ini
187# The size of a tab. Must be > 0.
188tab_stop=4
189# The number of confirmations needed before quitting, when changes have been
190# made since the file was last changed.
191quit_times=2
192# The duration for which messages are shown in the status bar, in seconds.
193message_duration=3
194# Whether to show line numbers.
195show_line_numbers=true
196```
197
198The location of these files is described below.
199
200##### Linux / macOS
201
202kibi follows the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html):
203
204* A user-level configuration file can be located at
205  `$XDG_CONFIG_HOME/kibi/config.ini` if environment variable `$XDG_CONFIG_HOME`
206  is defined, `~/.config/kibi/config.ini` otherwise.
207* A system-wide configuration file can be located at
208  `$XDG_CONFIG_DIRS/kibi/config.ini` if environment variable
209  `$XDG_CONFIG_DIRS` is defined, `/etc/kibi/config.ini` or
210  `/etc/xdg/kibi/config.ini` otherwise.
211
212##### Windows
213
214A configuration file can be located at `%APPDATA%\Kibi\config.ini`.
215
216#### Syntax highlighting
217
218Syntax highlighting can be configured using INI files which follow this format:
219
220<!-- markdownlint-disable MD013 -->
221```ini
222### /usr/share/kibi/syntax.d/rust.ini ###
223# Kibi syntax highlighting configuration for Rust
224
225name=Rust
226extensions=rs
227highlight_numbers=true
228singleline_string_quotes="
229singleline_comment_start=//
230multiline_comment_delims=/*, */
231; In Rust, the multi-line string delimiter is the same as the single-line string
232; delimiter
233multiline_string_delim="
234; https://doc.rust-lang.org/book/appendix-01-keywords.html
235keywords_1=abstract, as, async, await, become, box, break, const, continue, crate, do, dyn, else, enum, extern, false, final, fn, for, if, impl, in, let, loop, macro, match, mod, move, mut, override, priv, pub, ref, return, self, Self, static, struct, super, trait, true, try, type, typeof, unsafe, unsized, use, virtual, where, while, yield
236keywords_2=i8, i16, i32, i64, i128, isize, u8, u16, u32, u36, u128, usize, f32, f64, bool, char, str
237```
238<!-- markdownlint-enable MD013 -->
239
240The location of these files is described below.
241
242##### Linux / macOS
243
244kibi follows the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html):
245
246* User-level syntax highlighting configuration files can be located at `$XDG_DATA_HOME/kibi/syntax.d/<file_name>.ini`
247  if environment variable `$XDG_DATA_HOME` is defined,
248  `~/.local/share/kibi/syntax.d/<file_name>.ini` otherwise.
249* System-wide syntax highlighting configuration files can be located at `$XDG_DATA_DIRS/kibi/syntax.d/<file_name>.ini`
250  if environment variable `$XDG_DATA_DIRS` is defined,
251  `/usr/local/share/kibi/syntax.d/<file_name>.ini` or
252  `/usr/share/kibi/syntax.d/<file_name>.ini` otherwise.
253
254##### Windows
255
256Syntax highlighting configuration files can be located at `%APPDATA%\Kibi\syntax.d\<file_name>.ini`.
257
258## Comparison with `kilo`
259
260This project is inspired by [`kilo`](https://github.com/antirez/kilo), a text
261editor written by Salvatore Sanfilippo (antirez) in C, and
262[this tutorial](https://viewsourcecode.org/snaptoken/kilo/) (also in C).
263
264`kibi` provides additional features:
265
266* Support for UTF-8 characters
267* Compatibility with Windows
268* Command to jump to a given row/column
269* Handle window resize (UNIX only)
270* Parsing configuration files: global editor configuration, language-specific
271  syntax highlighting configuration
272* Display line numbers on the left of the screen; display file size in the status
273  bar
274* Syntax highlighting: multi-line strings
275* *Save as* prompt when no file name has been provided
276* Command to duplicate the current row
277* Ability to execute an external command from the editor and paste its output
278* Memory safety, thanks to Rust!
279* Many bug fixes
280
281## Dependencies
282
283This project must remain tiny, so using advanced dependencies such as [`ncurses`](https://crates.io/crates/ncurses),
284[`toml`](https://crates.io/crates/toml) or
285[`ansi-escapes`](https://crates.io/crates/ansi-escapes) would be cheating.
286
287The following dependencies provide wrappers around system calls.
288
289* On UNIX systems (Linux, macOS):
290  * `libc`
291* On Windows:
292  * `winapi`
293  * `winapi-util`
294
295In addition, `unicode-width` is used to determine the displayed width of Unicode
296characters. Unfortunately, there is no way around it: the
297[unicode character width table](https://github.com/unicode-rs/unicode-width/blob/3033826f8bf05e82724140a981d5941e48fce393/src/tables.rs#L52)
298is 230 lines long.
299
300## Why Kibi?
301
3021. Porting the `kilo` source code from C to Rust and trying to make it idiomatic
303   was interesting
3042. Implementing new features while under the 1024-line constraint is a good challenge
3053. Most importantly, I wanted to learn Rust and this was a great project to
306   start (thanks Reddit for the idea)
307
308## Contributors
309
310This project follows the [all-contributors](https://allcontributors.org/) specification
311([emoji key](https://allcontributors.org/docs/en/emoji-key)). Contributions of
312any kind welcome!
313
314<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
315<!-- prettier-ignore-start -->
316<!-- markdownlint-disable -->
317<table>
318  <tr>
319    <td align="center"><a href="https://github.com/ilai-deutel"><img src="https://avatars0.githubusercontent.com/u/10098207?v=4" width="100px;" alt=""/><br /><sub><b>Ilaï Deutel</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=ilai-deutel" title="Code">��</a> <a href="#ideas-ilai-deutel" title="Ideas, Planning, & Feedback">��</a> <a href="#infra-ilai-deutel" title="Infrastructure (Hosting, Build-Tools, etc)">��</a> <a href="#platform-ilai-deutel" title="Packaging/porting to new platform">��</a> <a href="#syntax-highlighting-ilai-deutel" title="Contributing to syntax highlighting configuration files">��</a></td>
320    <td align="center"><a href="https://github.com/codingonHP"><img src="https://avatars3.githubusercontent.com/u/7105293?v=4" width="100px;" alt=""/><br /><sub><b>Vishal Anand</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/issues?q=author%3AcodingonHP" title="Bug reports">��</a></td>
321    <td align="center"><a href="https://github.com/gsbhasin123"><img src="https://avatars2.githubusercontent.com/u/48339289?v=4" width="100px;" alt=""/><br /><sub><b>Gurjus Bhasin</b></sub></a><br /><a href="#ideas-gsbhasin123" title="Ideas, Planning, & Feedback">��</a></td>
322    <td align="center"><a href="https://github.com/ldang0"><img src="https://avatars1.githubusercontent.com/u/1281722?v=4" width="100px;" alt=""/><br /><sub><b>Libin Dang</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=ldang0" title="Code">��</a> <a href="https://github.com/ilai-deutel/kibi/issues?q=author%3Aldang0" title="Bug reports">��</a></td>
323    <td align="center"><a href="https://github.com/andradei"><img src="https://avatars0.githubusercontent.com/u/2653546?v=4" width="100px;" alt=""/><br /><sub><b>Isaac Andrade</b></sub></a><br /><a href="#ideas-andradei" title="Ideas, Planning, & Feedback">��</a></td>
324    <td align="center"><a href="https://github.com/frjol"><img src="https://avatars2.githubusercontent.com/u/4422813?v=4" width="100px;" alt=""/><br /><sub><b>frjol</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/issues?q=author%3Afrjol" title="Bug reports">��</a></td>
325    <td align="center"><a href="https://github.com/tim77"><img src="https://avatars0.githubusercontent.com/u/5614476?v=4" width="100px;" alt=""/><br /><sub><b>Artem Polishchuk</b></sub></a><br /><a href="#platform-tim77" title="Packaging/porting to new platform">��</a></td>
326  </tr>
327  <tr>
328    <td align="center"><a href="https://github.com/malbarbo"><img src="https://avatars3.githubusercontent.com/u/1678126?v=4" width="100px;" alt=""/><br /><sub><b>Marco A L Barbosa</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=malbarbo" title="Code">��</a></td>
329    <td align="center"><a href="https://github.com/voidpin"><img src="https://avatars3.githubusercontent.com/u/35956139?v=4" width="100px;" alt=""/><br /><sub><b>pin</b></sub></a><br /><a href="#platform-voidpin" title="Packaging/porting to new platform">��</a></td>
330    <td align="center"><a href="https://github.com/Uniminin"><img src="https://avatars3.githubusercontent.com/u/42061747?v=4" width="100px;" alt=""/><br /><sub><b>Uniminin</b></sub></a><br /><a href="#syntax-highlighting-Uniminin" title="Contributing to syntax highlighting configuration files">��</a></td>
331    <td align="center"><a href="https://github.com/Woomy4680-exe"><img src="https://avatars.githubusercontent.com/u/57042741?v=4" width="100px;" alt=""/><br /><sub><b>Woomy4680-exe</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/issues?q=author%3AWoomy4680-exe" title="Bug reports">��</a></td>
332  </tr>
333</table>
334
335<!-- markdownlint-restore -->
336<!-- prettier-ignore-end -->
337
338<!-- ALL-CONTRIBUTORS-LIST:END -->
339
340## License
341
342This project is licensed under either of
343
344* [Apache License, Version 2.0](LICENSE-APACHE)
345* [MIT License](LICENSE-MIT)
346
347at your option.
348
349### Contribution
350
351Unless you explicitly state otherwise, any contribution intentionally submitted
352for inclusion in Kibi by you shall be dual licensed as above, without any
353additional terms or conditions.
354