bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU readline 8.2 question (setting the default buffer)


From: Chet Ramey
Subject: Re: GNU readline 8.2 question (setting the default buffer)
Date: Sun, 13 Oct 2024 14:38:20 -0400
User-agent: Mozilla Thunderbird

On 10/13/24 8:25 AM, Basile STARYNKEVITCH wrote:
Hello from France.

This is related to the RefPerSys <http://refpersys.org/> open source inference engine (GPLv3+) project on github <https://github.com/RefPerSys/ RefPerSys/> developed on Linux/Debian/x86-64/trixie.

Is there some GNU readline-8.2 API to preset the buffer?

Yes. You set the variable

rl_startup_hook

to the address of a function that inserts the desired text into the
line using rl_insert_text().

You could potentially use the same startup hook throughout your program,
keep the preset text in a global or file-scope variable, and have the
function insert it whenever it's called (or, if it's a null string, don't
insert anything). Then you can modify the text whenever you like.

This is how the bash read builtin's -i option works. Look at
builtins/read.def:set_itext().

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]