{"id":13438469,"url":"https://github.com/troglobit/editline","last_synced_at":"2025-04-05T09:08:50.863Z","repository":{"id":989915,"uuid":"797112","full_name":"troglobit/editline","owner":"troglobit","description":"A small replacement for GNU readline() for UNIX","archived":false,"fork":false,"pushed_at":"2024-09-07T09:02:46.000Z","size":1317,"stargazers_count":279,"open_issues_count":14,"forks_count":57,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-10-11T02:45:49.478Z","etag":null,"topics":["editline","readline","unix"],"latest_commit_sha":null,"homepage":"https://troglobit.com/projects/editline/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/troglobit.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-07-25T21:06:05.000Z","updated_at":"2024-10-07T10:59:06.000Z","dependencies_parsed_at":"2024-09-07T10:24:50.271Z","dependency_job_id":"f3218439-4489-4045-ab83-91f5d0bf55c5","html_url":"https://github.com/troglobit/editline","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troglobit%2Feditline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troglobit%2Feditline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troglobit%2Feditline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troglobit%2Feditline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/troglobit","download_url":"https://codeload.github.com/troglobit/editline/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312081,"owners_count":20918344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["editline","readline","unix"],"created_at":"2024-07-31T03:01:05.781Z","updated_at":"2025-04-05T09:08:50.829Z","avatar_url":"https://github.com/troglobit.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"Editline\n========\n[![License Badge][]][License] [![Travis Status]][Travis] [![Coverity Status]][Coverity Scan]\n\n\nTable of Contents\n-----------------\n\n* [Introduction](#introduction)\n* [API](#api)\n* [Example](#example)\n* [Build \u0026 Install](#build--install)\n* [Origin \u0026 References](#origin--references)\n\n\nIntroduction\n------------\n\nThis is a small [line editing][]  library.  It can be linked into almost\nany program to  provide command line editing and  history functions.  It\nis call compatible with the [FSF readline][] library, but at a fraction\nof the  size, and as  a result fewer  features.  It is  also distributed\nunder a much more liberal [License][].\n\nThe small size  (\u003c30k), lack of dependencies (ncurses  not needed!), and\nthe free license  should make this library interesting  to many embedded\ndevelopers.\n\nEditline has several optional build-time features that can be enabled by\nsupplying different options to the GNU configure script.  See the output\nfrom \u003ckbd\u003econfigure --help\u003c/kbd\u003e for details.  Some useful hints on how\nto use the library is available in the `examples/` directory.\n\nEditline is maintained collaboratively at [GitHub][].\n\n\u003e **Note:** Windows is not a supported target for editline.\n\n\nExample\n-------\n\nBelow is a very brief example to illustrate how one can use Editline to\ncreate a simple CLI, Ctrl-D exits the program.  A slightly more advanced\nexample is Jush, \u003chttps://github.com/troglobit/jush/\u003e, a small and very\nsimplistic UNIX shell.  The Editline sources also include an `examples/`\nsub-directory.\n\n1. Build and install the library, preferably using a [release tarball][]\n   The configure script defaults to a `/usr/local` prefix.\n\n        tar xf editline-1.15.3.tar.xz\n        cd editline-1.15.3/\n        ./configure --prefix=/usr\n        make all\n        sudo make install\n\n2. Place the below source code in a separate project directory,\n   e.g. `~/src/example.c`\n\n```C\n    #include \u003cstdio.h\u003e\n    #include \u003cstdlib.h\u003e\n    #include \u003ceditline.h\u003e\n\n    int main(void)\n    {\n        char *p;\n\n        while ((p = readline(\"CLI\u003e \")) != NULL) {\n            puts(p);\n            free(p);\n        }\n\n        return 0;\n    }\n```\n\n3. Compile the example:\n\n        cd ~/src/\n        make LDLIBS=-leditline example\n\nHere I use `make` and rely on its implicit (built-in) rules to handle\nall the compiler magic, but you may want to create your own Makefile for\nthe project.  In particular if you don't change the default prefix\n(above), because then you need to specify the search path for the\ninclude file(s) and the library manually.\n\nA simple `~/src/Makefile` could look like this:\n\n    CFLAGS    = -I/usr/local/include\n    LDFLAGS   = -L/usr/local/lib\n    LDLIBS    = -leditline\n    EXEC      = example\n    OBJS      = example.o\n    \n    all: $(EXEC)\n    \n    $(EXEC): $(OBJS)\n    \n    clean:\n            $(RM) $(OBJS) $(EXEC)\n    \n    distclean: clean\n            $(RM) *.o *~ *.bak\n\nThen simply type `make` from your `~/src/` directory.  You can also use\n`pkg-config` for your `~/src/Makefile`, replace the following lines:\n\n    CFLAGS    = $(shell pkg-config --cflags libeditline)\n    LDFLAGS   = $(shell pkg-config --libs-only-L libeditline)\n    LDLIBS    = $(shell pkg-config --libs-only-l libeditline)\n    \nThen simply type \u003ckbd\u003emake\u003c/kbd\u003e, like above.\n\nHowever, most `.rpm` based distributions `pkg-config` doesn't search in\n`/usr/local` anymore, so you need to call make like this:\n\n    PKG_CONFIG_LIBDIR=/usr/local/lib/pkgconfig make\n\nDebian/Ubuntu based systems do not have this problem.\n\n\nAPI\n---\n\nHere is the libeditline interfaces.  It has a small compatibility layer\nto [FSF readline][], which may not be entirely up-to-date.\n\n```C\n    /* Editline specific global variables. */\n    int         el_no_echo;   /* Do not echo input characters */\n    int         el_no_hist;   /* Disable auto-save of and access to history,\n                               * e.g. for password prompts or wizards */\n    int         el_hist_size; /* Size of history scrollback buffer, default: 15 */\n    \n    /* Editline specific functions. */\n    char *      el_find_word     (void);\n    void        el_print_columns (int ac, char **av);\n    el_status_t el_ring_bell     (void);\n    el_status_t el_del_char      (void);\n    \n    /* Callback function for key binding */\n    typedef el_status_t el_keymap_func_t(void);\n    \n    /* Bind key to a callback, use CTL('f') to change Ctrl-F, for example */\n    el_status_t el_bind_key            (int key, el_keymap_func_t function);\n    el_status_t el_bind_key_in_metamap (int key, el_keymap_func_t function);\n    \n    /* For compatibility with FSF readline. */\n    int         rl_point;\n    int         rl_mark;\n    int         rl_end;\n    int         rl_inhibit_complete;\n    char       *rl_line_buffer;\n    const char *rl_readline_name;\n    \n    void (*rl_deprep_term_function)(void);\n    void rl_deprep_terminal (void);\n    void rl_reset_terminal  (const char *terminal_name);\n\n    void rl_initialize   (void);\n    void rl_uninitialize (void);                         /* Free all internal memory */\n\n    void rl_save_prompt    (void);\n    void rl_restore_prompt (void);\n    void rl_set_prompt     (const char *prompt);\n    \n    void rl_clear_message         (void);\n    void rl_forced_update_display (void);\n\n    /* Main function to use, saves history by default */\n    char *readline    (const char *prompt);\n\n    /* Use to save a read line to history, when el_no_hist is set */\n    void add_history  (const char *line);\n    \n    /* Load and save editline history from/to a file. */\n    int read_history  (const char *filename);\n    int write_history (const char *filename);\n    \n    /* Magic completion API, see examples/cli.c for more info */\n    rl_complete_func_t    *rl_set_complete_func    (rl_complete_func_t *func);\n    rl_list_possib_func_t *rl_set_list_possib_func (rl_list_possib_func_t *func);\n    \n    /* Alternate interface to plain readline(), for event loops */\n    void rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *lhandler);\n    void rl_callback_read_char       (void);\n    void rl_callback_handler_remove  (void);\n```\n\n\nBuild \u0026 Install\n---------------\n\nEditline was originally designed for older UNIX systems and Plan 9.  The\ncurrent maintainer works exclusively on GNU/Linux systems, so it may use\nGCC and  GNU Make specific  extensions here and  there.  This is  not on\npurpose and patches or pull requests to correct this are most welcome!\n\n0. Call \u003ckbd\u003e./autogen.sh\u003c/kbd\u003e if you build from git\n1. Configure editline with default features: \u003ckbd\u003e./configure\u003c/kbd\u003e\n2. Build the library and examples: \u003ckbd\u003emake all\u003c/kbd\u003e\n3. Install using \u003ckbd\u003emake install\u003c/kbd\u003e\n\nThe `$DESTDIR` environment variable is honored at install.  For more\noptions, see \u003ckbd\u003e./configure --help\u003c/kbd\u003e\n\nRemember to run `ldconfig` after install to update the linker cache.  If\nyou've installed to a non-standard location (`--prefix`) you may also\nhave to update your `/etc/ld.so.conf`, or use `pkg-confg` to build your\napplication (above).\n\n**NOTE:** RedHat/Fedora/CentOS and other `.rpm`-based distributions do\n  not consider `/usr/local` as standard path anymore.  So make sure to\n  `./configure --prefix=/usr`, otherwise the build system use the GNU\n  default, which is `/usr/local`.  The Debian based distributions, like\n  Ubuntu, do not have this problem.\n\n\nOrigin \u0026 References\n--------------------\n\nThis [line editing][]  library was created by [Rich  Salz][] and Simmule\nTurner and in 1992.  It is distributed with a “[C News][]-like” license,\nsimilar to the [BSD license][].  Rich's current version is however under\nthe Apache license.  For details on  the licensing terms of this version\nof the software, see [License][].\n\nThis version  of the editline  library was  forked from the  [Minix 2][]\nsource tree and is *not* related  to the similarily named NetBSD version\nthat [Jess Thrysøe][jess]  disitributes to the world  outside *BSD.  The\nlibraries have much in common, but  the latter is heavily refactored and\nalso relies  on libtermcap (usually  supplied by ncurses),  whereas this\nlibrary only uses termios from the standard C library.\n\nPatches and  bug fixes from the  following forks, based on  the original\n[comp.sources.unix][] posting, have been merged:\n\n* Debian [libeditline][]\n* [Heimdal][]\n* [Festival][] speech-tools\n* [Steve Tell][]'s editline patches\n\nThe version numbering  scheme today follows that of  the Debian version,\ndetails available  in the [ChangeLog.md][].  The  current [maintainer][]\nwas unaware  of the Debian version  for quite some time,  so a different\nname and versioning  scheme was used.  In June 2009  this was changed to\nline up  alongside Debian, with  the intent  is to eventually  merge the\nefforts.\n\nOutstanding issues are listed in the [TODO.md][] file.\n\n[GitHub]:          https://github.com/troglobit/editline\n[line editing]:    https://github.com/troglobit/editline/blob/master/docs/README\n[release tarball]: https://github.com/troglobit/editline/releases\n[maintainer]:      http://troglobit.com\n[C News]:          https://en.wikipedia.org/wiki/C_News\n[TODO.md]:         https://github.com/troglobit/editline/blob/master/docs/TODO.md\n[ChangeLog.md]:    https://github.com/troglobit/editline/blob/master/ChangeLog.md\n[FSF readline]:    http://www.gnu.org/software/readline/\n[Rich Salz]:       https://github.com/richsalz/editline/\n[comp.sources.unix]: http://ftp.cs.toronto.edu/pub/white/pub/rc/editline.shar\n[Minix 2]:         http://www.cise.ufl.edu/~cop4600/cgi-bin/lxr/http/source.cgi/lib/editline/\n[jess]:            http://thrysoee.dk/editline/\n[BSD license]:     http://en.wikipedia.org/wiki/BSD_licenses\n[libeditline]:     http://packages.qa.debian.org/e/editline.html\n[Heimdal]:         http://www.h5l.org\n[Festival]:        http://festvox.org/festival/\n[Steve Tell]:      http://www.cs.unc.edu/~tell/dist.html\n[License]:         https://github.com/troglobit/editline/blob/master/LICENSE\n[License Badge]:   https://img.shields.io/badge/License-C%20News-orange.svg\n[Travis]:          https://travis-ci.org/troglobit/editline\n[Travis Status]:   https://travis-ci.org/troglobit/editline.png?branch=master\n[Coverity Scan]:   https://scan.coverity.com/projects/2982\n[Coverity Status]: https://scan.coverity.com/projects/2982/badge.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftroglobit%2Feditline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftroglobit%2Feditline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftroglobit%2Feditline/lists"}