Merge branch 'dev'

This commit is contained in:
Joachim Nilsson 2018-03-22 16:06:13 +01:00
commit 3cf0e89a68
4 changed files with 75 additions and 55 deletions

View File

@ -1,6 +1,6 @@
Editline
========
[![Travis Status]][Travis] [![Coverity Status]][Coverity Scan]
[![License Badge][]][License] [![Travis Status]][Travis] [![Coverity Status]][Coverity Scan]
Table of Contents
@ -20,7 +20,7 @@ This is a small [line editing][] library. It can be linked into almost
any program to provide command line editing and history functions. It
is call compatible with the [FSF readline][] library, but at a fraction
of the size, and as a result fewer features. It is also distributed
under a much more liberal [LICENSE][].
under a much more liberal [License][].
The small size (<30k), lack of dependencies (ncurses not needed!), and
the free license should make this library interesting to many embedded
@ -216,10 +216,10 @@ Origin & References
--------------------
This [line editing][] library was created by [Rich Salz][] and Simmule
Turner and in 1992. It is distributed under a “C News-like” license,
similar to the [BSD license][]. Rich's latest version is however under
Turner and in 1992. It is distributed with a “[C News][]-like” license,
similar to the [BSD license][]. Rich's current version is however under
the Apache license. For details on the licensing terms of this version
of the software, see [LICENSE][].
of the software, see [License][].
This version of the editline library was forked from the [Minix 3][]
source tree and is *not* related to the similarily named NetBSD version
@ -249,7 +249,7 @@ Outstanding issues are listed in the [TODO.md][] file.
[line editing]: https://github.com/troglobit/editline/blob/master/doc/README
[release tarball]: https://github.com/troglobit/editline/releases
[maintainer]: http://troglobit.com
[LICENSE]: https://github.com/troglobit/editline/blob/master/LICENSE
[C News]: https://en.wikipedia.org/wiki/C_News
[TODO.md]: https://github.com/troglobit/editline/blob/master/TODO.md
[ChangeLog.md]: https://github.com/troglobit/editline/blob/master/ChangeLog.md
[FSF readline]: http://www.gnu.org/software/readline/
@ -262,6 +262,8 @@ Outstanding issues are listed in the [TODO.md][] file.
[Heimdal]: http://www.h5l.org
[Festival]: http://festvox.org/festival/
[Steve Tell]: http://www.cs.unc.edu/~tell/dist.html
[License]: https://github.com/troglobit/editline/blob/master/LICENSE
[License Badge]: https://img.shields.io/badge/License-C%20News-orange.svg
[Travis]: https://travis-ci.org/troglobit/editline
[Travis Status]: https://travis-ci.org/troglobit/editline.png?branch=master
[Coverity Scan]: https://scan.coverity.com/projects/2982

1
examples/.gitignore vendored
View File

@ -1,3 +1,4 @@
*.o
cli
testit
excallback

View File

@ -134,6 +134,8 @@ main()
rl_callback_read_char();
}
}
return 0;
}
void
@ -168,7 +170,8 @@ change_prompt(void)
prompt = !prompt;
/* save away the current contents of the line */
strcpy(line_buf, rl_line_buffer);
strncpy(line_buf, rl_line_buffer, sizeof(line_buf));
line_buf[sizeof(line_buf) - 1] = 0;
/* install a new handler which will change the prompt and erase the current line */
rl_callback_handler_install(get_prompt(), process_line);
@ -179,7 +182,7 @@ change_prompt(void)
/* redraw the current line - this is an undocumented function. It invokes the
* redraw-current-line command.
*/
rl_refresh_line(0, 0);
return rl_refresh_line(0, 0);
}
char *

View File

@ -892,6 +892,31 @@ el_status_t el_del_char(void)
return del_char();
}
static el_status_t fd_word(void)
{
return do_forward(CSmove);
}
static el_status_t bk_word(void)
{
int i;
char *p;
i = 0;
do {
for (p = &rl_line_buffer[rl_point]; p > rl_line_buffer && !is_alpha_num(p[-1]); p--)
left(CSmove);
for (; p > rl_line_buffer && !isblank(p[-1]) && is_alpha_num(p[-1]); p--)
left(CSmove);
if (rl_point == 0)
break;
} while (++i < Repeat);
return CSstay;
}
static el_status_t meta(void)
{
int c;
@ -905,6 +930,20 @@ static el_status_t meta(void)
if (c == '[' || c == 'O') {
switch (tty_get()) {
case EOF: return CSeof;
case '1':
{
char seq[4] = { 0 };
for (c = 0; c < 3; c++)
seq[c] = tty_get();
if (!strncmp(seq, ";5C", 3))
return fd_word(); /* Ctrl+Right */
if (!strncmp(seq, ";5D", 3))
return bk_word(); /* Ctrl+Left */
break;
}
case '2': tty_get(); return CSstay; /* Insert */
case '3': tty_get(); return del_char(); /* Delete */
case '5': tty_get(); return CSstay; /* PgUp */
@ -1689,11 +1728,6 @@ static el_status_t move_to_char(void)
return CSstay;
}
static el_status_t fd_word(void)
{
return do_forward(CSmove);
}
static el_status_t fd_kill_word(void)
{
int i;
@ -1708,26 +1742,6 @@ static el_status_t fd_kill_word(void)
return CSstay;
}
static el_status_t bk_word(void)
{
int i;
char *p;
i = 0;
do {
for (p = &rl_line_buffer[rl_point]; p > rl_line_buffer && !is_alpha_num(p[-1]); p--)
left(CSmove);
for (; p > rl_line_buffer && !isblank(p[-1]) && is_alpha_num(p[-1]); p--)
left(CSmove);
if (rl_point == 0)
break;
} while (++i < Repeat);
return CSstay;
}
static el_status_t bk_kill_word(void)
{
bk_word();