EC_EDITLINE(3)
π EC_EDITLINE π
okay bestie, so this one is straight out of the Libecoli Programmer's Manual, and it's literally the function that spins up a whole editline instance for you with all the default behavior already baked in. no cap. let's get into it π«Ά
πΈ NAME πΈ
ec_editline β creates an editline instance with default behavior. that's it, that's the vibe β¨
π SYNOPSIS π
#include <ecoli/editline.h>
struct ec_editline * ec_editline(
/*
* The name of the invoking program, used when reading the editrc(5) file
* to determine which settings to use.
*/
const char *prog,
FILE *f_in, /* The input stream to use. */
FILE *f_out, /* The output stream to use. */
FILE *f_err, /* The error stream to use. */
/*
* Flags to customize initialization. See ec_editline_init_flags.
*/
enum ec_editline_init_flags flags
);
β¨ DESCRIPTION β¨
so what actually happens here? it allocates and initializes an ec_editline structure, calls editline's el_init(), and then does the editline configuration according to whatever flags you handed it. very demure, very mindful. π
and then β and this is the important part, don't skip it β after that, the user must call ec_editline_set_node() to attach the grammar to the editline. like, it's not optional. the grammar does not attach itself. do it. π§
π¦ STRUCTURES π¦
here's the enum in all its raw glory, character for character, exactly as the page has it:
enum ec_editline_init_flags {
/*
* The ctrl-c, ctrl-z will be interpreted as standard
* characters. An action can be associated with these characters with:
static int
* cb(EditLine *editline, int c) {
{
see editline documentation for details
}
if
* (el_set(el, EL_ADDFN, "ed-foobar", "Help string about foobar", cb))
* handle_error;
if (el_set(el, EL_BIND, "^C", "ed-break", NULL))
handle_error;
The
* default behavior (without this flag) is to let the signal pass:
ctrl-c will stop
* program and ctrl-z will suspend it.
*/
EC_EDITLINE_DISABLE_SIGNALS;
/*
* The default behavior creates a history with
* EC_EDITLINE_HISTORY_SIZE entries. To change this value, use
ec_editline_set_history().
*/
EC_EDITLINE_DISABLE_HISTORY;
/*
* The default behavior is to complete when ? or <tab> is hit.
* You can register your own callback with:
if (el_set(el, EL_ADDFN,
* "ed-complete", "Complete buffer", callback))
handle_error;
if (el_set(el, EL_BIND,
* "^I", "ed-complete", NULL))
handle_error;
The default used callback is
* ec_editline_complete().
*/
EC_EDITLINE_DISABLE_COMPLETION;
/*
* Otherwise, the current signal handlers will be used.
*/
EC_EDITLINE_DEFAULT_SIGHANDLER; };
okay now let's break down what each of those flags is actually doing, because the vibe check demands clarity π
EC_EDITLINE_DISABLE_SIGNALSβ with this,ctrl-candctrl-zget interpreted as standard characters instead of signals. you can associate an action with these characters using a callback, like:
static int
cb(EditLine *editline, int c) {
(see editline documentation for details π«)
and then hooking it up like:
if (el_set(el, EL_ADDFN, "ed-foobar", "Help string about foobar", cb))
handle_error;
if (el_set(el, EL_BIND, "^C", "ed-break", NULL))
handle_error;
the default behavior β i.e. without this flag β is to let the signal pass through: ctrl-c will stop the program, and ctrl-z will suspend it. so if you don't set this flag, your program is getting interrupted, periodt. π
EC_EDITLINE_DISABLE_HISTORYβ the default behavior creates a history withEC_EDITLINE_HISTORY_SIZEentries. want to change that number? useec_editline_set_history(). easy. β¨EC_EDITLINE_DISABLE_COMPLETIONβ by default it completes when?or<tab>is hit. you can register your own callback with:
if (el_set(el, EL_ADDFN, "ed-complete", "Complete buffer", callback))
handle_error;
if (el_set(el, EL_BIND, "^I", "ed-complete", NULL))
handle_error;
and the default callback it uses is ec_editline_complete(). she's the main character of completion, lowkey π
EC_EDITLINE_DEFAULT_SIGHANDLERβ otherwise, the current signal handlers will be used. π
π RETURN VALUE π
the allocated ec_editline structure, or NULL on error. if you get NULL, that's your sign bestie, something went wrong π
π SEE ALSO π
ec_editline_get_el(3)ec_editline_set_prompt(3)ec_editline_complete(3)ec_editline_set_prompt_esc(3)ec_editline_parse(3)ec_editline_free(3)ec_editline_term_size(3)ec_editline_gets(3)ec_editline_interact(3)ec_editline_set_node(3)ec_editline_set_history(3)ec_editline_get_node(3)ec_editline_curline(3)
go read those next, they're all part of the same friend group fr fr π«Ά
π COPYRIGHT π
Copyright (C) 2010-2026 Olivier Matz, Robin Jarry.
and that's the whole page bestie!! π this was libecoli, dated 2026-06-11 β go forth and ec_editline responsibly, and don't forget to call ec_editline_set_node() or the grammar will simply not be attached and that's on you πβ¨π¦
π¦ where this page comes from
- fedora 44: libecoli-devel 0.11.7-1.fc44 Β· BSD-3-Clause AND LicenseRef-Fedora-Public-Domain
- fedora 44: libecoli-devel 0.11.7-1.fc44 Β· BSD-3-Clause AND LicenseRef-Fedora-Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms