|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 03-May-2022 | - |
| tests/ | H | 03-May-2022 | - | 1,828 | 1,357 |
| vendor/ | H | 14-Feb-2020 | - | 33 | 23 |
| .gitignore | H A D | 14-Feb-2020 | 21 | 4 | 3 |
| .gitmodules | H A D | 14-Feb-2020 | 329 | 13 | 12 |
| .travis.yml | H A D | 14-Feb-2020 | 107 | 6 | 5 |
| LICENSE | H A D | 14-Feb-2020 | 11.1 KiB | 203 | 169 |
| Makefile | H A D | 03-May-2022 | 1.7 KiB | 61 | 46 |
| README.md | H A D | 14-Feb-2020 | 5.5 KiB | 175 | 123 |
| aproc.c | H A D | 14-Feb-2020 | 3.7 KiB | 132 | 101 |
| bline.c | H A D | 14-Feb-2020 | 5 KiB | 158 | 128 |
| buffer.c | H A D | 14-Feb-2020 | 57.4 KiB | 1,834 | 1,465 |
| bview.c | H A D | 14-Feb-2020 | 38.5 KiB | 1,171 | 928 |
| cmd.c | H A D | 14-Feb-2020 | 52.4 KiB | 1,713 | 1,378 |
| cursor.c | H A D | 14-Feb-2020 | 13.4 KiB | 387 | 343 |
| editor.c | H A D | 14-Feb-2020 | 88.4 KiB | 2,305 | 1,920 |
| keys.h | H A D | 14-Feb-2020 | 2.7 KiB | 69 | 68 |
| main.c | H A D | 14-Feb-2020 | 935 | 36 | 33 |
| mark.c | H A D | 14-Feb-2020 | 28.7 KiB | 807 | 658 |
| mlbuf.h | H A D | 14-Feb-2020 | 13.9 KiB | 360 | 307 |
| mle.1 | H A D | 14-Feb-2020 | 6.3 KiB | 282 | 279 |
| mle.h | H A D | 03-May-2022 | 23.2 KiB | 712 | 582 |
| uscript.c | H A D | 14-Feb-2020 | 12.2 KiB | 410 | 324 |
| uscript.inc | H A D | 14-Feb-2020 | 78.8 KiB | 2,597 | 2,445 |
| uscript.inc.php | H A D | 14-Feb-2020 | 9.4 KiB | 242 | 229 |
| uscript.lua | H A D | 14-Feb-2020 | 422 | 16 | 12 |
| utf8.c | H A D | 14-Feb-2020 | 2 KiB | 85 | 71 |
| util.c | H A D | 14-Feb-2020 | 17.6 KiB | 618 | 464 |
README.md
1# mle
2
3mle is a small, flexible, terminal-based text editor written in C.
4
5Runs on Linux, Windows (cygwin), FreeBSD, and MacOS.
6
7[![Build Status](https://travis-ci.org/adsr/mle.svg?branch=master)](https://travis-ci.org/adsr/mle)
8
9### Demos
10
11[![asciicast](https://i.imgur.com/PZocaOT.png)](https://asciinema.org/a/162536)
12
13* [Emacs-style jump](https://i.imgur.com/atS11HX.gif)
14* [Large file benchmark](http://i.imgur.com/VGGMmGg.gif)
15* [Older demos](http://imgur.com/a/ZBmmQ)
16
17### Aims
18
19* Keep codebase small and hackable
20* Minimize build-time and run-time dependencies
21* Make extensible and configurable
22* Favor simplicity over portability
23* Use shell commands to enhance functionality (e.g., grep, tree)
24
25### Features
26
27* Small codebase (<10k sloc)
28* Full UTF-8 support
29* Syntax highlighting
30* Stackable key maps (modes)
31* Extensible via [Lua](https://www.lua.org)
32* Scriptable rc file
33* Key macros
34* Multiple splittable windows
35* Regex search and replace
36* Large file support
37* Incremental search
38* Linear undo and redo
39* Multiple cursors
40* Auto indent
41* Headless mode
42* Navigation via [ctags](https://github.com/universal-ctags/ctags)
43* Movement via [less](https://www.gnu.org/software/less/)
44* Fuzzy file search via [fzf](https://github.com/junegunn/fzf)
45* File browsing via [tree](http://mama.indstate.edu/users/ice/tree/)
46* File grep via [grep](https://www.gnu.org/software/grep/)
47* String manip via [perl](https://www.perl.org/)
48
49### Building
50
51 $ sudo apt install git build-essential libtool automake # or equivalent
52 $
53 $ git clone --recursive https://github.com/adsr/mle.git
54 $ cd mle
55 $ make mle_vendor=1
56
57To build a completely static binary, try `make mle_vendor=1 mle_static=1`.
58
59You can also run plain `make` to link against system libraries instead of
60`vendor/`. Note this requires the following packages to be installed:
61
62 uthash-dev
63 liblua5.3-dev
64 libpcre3-dev
65 libtermbox-dev
66
67### Installing
68
69To install to `/usr/local/bin`:
70
71 $ make install
72
73To install to a custom directory, supply `prefix`, e.g.:
74
75 $ make install prefix=/usr # /usr/bin/mle
76
77### Basic usage
78
79 $ mle # Open blank buffer
80 $ mle one.c # Edit one.c
81 $ mle one.c:100 # Edit one.c at line 100
82 $ mle one.c two.c # Edit one.c and two.c
83 $ mle -h # Show command line help
84
85The default key bindings are intuitive. Input text as normal, use directional
86keys to move around, use `Ctrl-S` to save, `Ctrl-O` to open, `Ctrl-X` to exit.
87
88Press `F2` for full help.
89
90### Advanced usage: mlerc
91
92mle is customized via command line options. Run `mle -h` to view all cli
93options.
94
95To set default options, make an rc file named `~/.mlerc` (or `/etc/mlerc`). The
96contents of the rc file are any number of cli options separated by newlines.
97Lines that begin with a semi-colon are interpretted as comments.
98
99If `~/.mlerc` is executable, mle executes it and interprets the resulting stdout
100as described above. For example, consider the following snippet from an
101executable `~/.mlerc` bash(1) script:
102
103 # Define 'test' kmap
104 echo '-Ktest,,1'
105
106 # M-q: replace grep with git grep if `.git` exists
107 if [ -d ".git" ]; then
108 echo '-kcmd_grep,M-q,git grep --color=never -P -i -I -n %s 2>/dev/null'
109 fi
110
111 # Set default kmap
112 echo '-n test'
113
114This overrides the built-in grep command with `git grep` if `.git` exists in
115the current working directory.
116
117### Shell command integration
118
119The following programs will enable or enhance certain features of mle if they
120exist in `PATH`.
121
122* [bash](https://www.gnu.org/software/bash/) (tab completion)
123* [fzf](https://github.com/junegunn/fzf) (fuzzy file search)
124* [grep](https://www.gnu.org/software/grep/) (file grep)
125* [less](https://www.gnu.org/software/less/) (less integration)
126* [perl](https://www.perl.org/) (perl 1-liners)
127* [readtags](https://github.com/universal-ctags/ctags) (ctags integration)
128* [tree](http://mama.indstate.edu/users/ice/tree/) (file browsing)
129
130Arbitrary shell commands can also be run via `cmd_shell` (M-e by default). If
131any text is selected, it is sent to stdin of the command. Any resulting stdout
132is inserted into the text buffer.
133
134### Advanced usage: Headless mode
135
136mle provides support for non-interactive editing which may be useful for using
137the editor as a regular command line tool. In headless mode, mle reads stdin
138into a buffer, applies a startup macro if specified, and then writes the buffer
139contents to stdout. For example:
140
141 $ echo -n hello | mle -M 'test C-e space w o r l d enter' -p test
142 hello world
143
144If stdin is a pipe, mle goes into headless mode automatically. Headless mode can
145be explicitly enabled or disabled with the `-H` option.
146
147If stdin is a pipe and headless mode is disabled via `-H0`, mle reads stdin into
148a new buffer and then runs as normal in interactive mode.
149
150### Advanced usage: Scripting
151
152mle is extensible via the [Lua](https://www.lua.org) programming language.
153Scripts are loaded via the `-x` cli option. Commands registered by scripts can
154be mapped to keys as normal via `-k`. See `uscript.lua` for a simple example.
155
156There is also a `wren` branch with [Wren](http://wren.io) scripting support.
157That work is on pause.
158
159### Known bugs
160
161* Multi-line style rules don't work properly when overlapped/staggered.
162
163### Fork
164
165Also check out [eon](https://github.com/tomas/eon), a fork of mle with some cool
166features.
167
168### Acknowledgments
169
170mle makes extensive use of the following libraries.
171
172* [uthash](https://troydhanson.github.io/uthash) for hash maps and linked lists
173* [termbox](https://github.com/nsf/termbox) for TUI
174* [PCRE](http://www.pcre.org/) for syntax highlighting and search
175