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

..03-May-2022-

include/H25-Nov-2015-6825

src/H03-May-2022-4,1883,086

tst/H25-Nov-2015-5138

.gitignoreH A D25-Nov-2015149 1413

LICENSEH A D25-Nov-20152.6 KiB6749

README.mdH A D25-Nov-20154 KiB10179

README.md

1# Linenoise Next Generation
2
3A small, portable GNU readline replacement for Linux, Windows and
4MacOS which is capable of handling UTF-8 characters. Unlike GNU
5readline, which is GPL, this library uses a BSD license and can be
6used in any kind of program.
7
8## Origin
9
10This linenoise implementation based on the work by
11[Salvatore Sanfilippo](https://github.com/antirez/linenoise) and
1210gen Inc.  They goal is to create a zero-config, BSD
13licensed, readline replacement usable in Apache2 or BSD licensed
14programs.
15
16* single and multi line editing mode with the usual key bindings implemented
17* history handling
18* completion
19* BSD license source code
20* Only uses a subset of VT100 escapes (ANSI.SYS compatible)
21* UTF8 aware
22* support for linux, MacOS and Windows
23
24It deviates from Salvatore's original goal to have a minimal readline
25replacement for the sake of supporting UTF8 and Windows. It deviates
26from 10gen Inc. goal to create a C++ interface, we stick to a pure
27C interface. However, the library itself uses C++11 unicode strings
28internally.
29
30## Can a line editing library be 20k lines of code?
31
32Line editing with some support for history is a really important
33feature for command line utilities. Instead of retyping almost the
34same stuff again and again it's just much better to hit the up arrow
35and edit on syntax errors, or in order to try a slightly different
36command. But apparently code dealing with terminals is some sort of
37Black Magic: readline is 30k lines of code, libedit 20k. Is it
38reasonable to link small utilities to huge libraries just to get a
39minimal support for line editing?
40
41So what usually happens is either:
42
43 * Large programs with configure scripts disabling line editing if
44   readline is not present in the system, or not supporting it at all
45   since readline is GPL licensed and libedit (the BSD clone) is not
46   as known and available as readline is (Real world example of this
47   problem: Tclsh).
48
49 * Smaller programs not using a configure script not supporting line
50   editing at all (A problem we had with Redis-cli for instance).
51
52The result is a pollution of binaries without line editing support.
53
54So Salvatore spent more or less two hours doing a reality check
55resulting in this little library: is it *really* needed for a line
56editing library to be 20k lines of code? Apparently not, it is possibe
57to get a very small, zero configuration, trivial to embed library,
58that solves the problem. Smaller programs will just include this,
59supporing line editing out of the box. Larger programs may use this
60little library or just checking with configure if readline/libedit is
61available and resorting to linenoise if not.
62
63## Terminals, in 2010.
64
65Apparently almost every terminal you can happen to use today has some
66kind of support for basic VT100 escape sequences. So Salvatore tried
67to write a lib using just very basic VT100 features. The resulting
68library appears to work everywhere Salvatore tried to use it, and now
69can work even on ANSI.SYS compatible terminals, since no VT220
70specific sequences are used anymore.
71
72The original library has currently about 1100 lines of code. In order
73to use it in your project just look at the *example.c* file in the
74source distribution, it is trivial. Linenoise is BSD code, so you can
75use both in free software and commercial software.
76
77## Tested with...
78
79 * Linux text only console ($TERM = linux)
80 * Linux KDE terminal application ($TERM = xterm)
81 * Linux xterm ($TERM = xterm)
82 * Linux Buildroot ($TERM = vt100)
83 * Mac OS X iTerm ($TERM = xterm)
84 * Mac OS X default Terminal.app ($TERM = xterm)
85 * OpenBSD 4.5 through an OSX Terminal.app ($TERM = screen)
86 * IBM AIX 6.1
87 * FreeBSD xterm ($TERM = xterm)
88 * ANSI.SYS
89 * Emacs comint mode ($TERM = dumb)
90 * Windows
91
92Please test it everywhere you can and report back!
93
94## Let's push this forward!
95
96Patches should be provided in the respect of linenoise sensibility for
97small and easy to understand code that and the license
98restrictions. Extensions must be submitted under a BSD license-style.
99A contributor license is required for contributions.
100
101