stdin.readln() works fine until I, out of habit, use the up arrow to recall an earlier input and the left/right to move around and change a character. How do I get that to work?
Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
February 25, 2023 stdin.readln line editing and recall with up arrow | ||||
---|---|---|---|---|
| ||||
February 25, 2023 Re: stdin.readln line editing and recall with up arrow | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daren Scot Wilson | On 25/02/2023 6:36 PM, Daren Scot Wilson wrote:
> stdin.readln() works fine until I, out of habit, use the up arrow to recall an earlier input and the left/right to move around and change a character. How do I get that to work?
Not with that module.
You can either use GNU readline itself, or Adam's version within arsd.
|
February 25, 2023 Re: stdin.readln line editing and recall with up arrow | ||||
---|---|---|---|---|
| ||||
Posted in reply to Richard (Rikki) Andrew Cattermole | On Saturday, 25 February 2023 at 05:41:48 UTC, Richard (Rikki) Andrew Cattermole wrote:
> On 25/02/2023 6:36 PM, Daren Scot Wilson wrote:
>> stdin.readln() works fine until I, out of habit, use the up arrow to recall an earlier input and the left/right to move around and change a character. How do I get that to work?
>
> Not with that module.
>
> You can either use GNU readline itself, or Adam's version within arsd.
I went with readline. Left/right arrows work, but up arrow still does not recall earlier commands. Maybe I need also a separate input history thing?
|
February 25, 2023 Re: stdin.readln line editing and recall with up arrow | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daren Scot Wilson | On 25/02/2023 9:45 PM, Daren Scot Wilson wrote: > I went with readline. Left/right arrows work, but up arrow still does not recall earlier commands. Maybe I need also a separate input history thing? https://tiswww.case.edu/php/chet/readline/readline.html#Basic-Behavior |
February 25, 2023 Re: stdin.readln line editing and recall with up arrow | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daren Scot Wilson | On Saturday, 25 February 2023 at 08:45:27 UTC, Daren Scot Wilson wrote: >On Saturday, 25 February 2023 at 05:41:48 UTC, Richard (Rikki) Andrew Cattermole wrote: >On 25/02/2023 6:36 PM, Daren Scot Wilson wrote: >stdin.readln() works fine until I, out of habit, use the up arrow to recall an earlier input and the left/right to move around and change a character. How do I get that to work? Not with that module. You can either use GNU readline itself, or Adam's version within arsd. I went with readline. Left/right arrows work, but up arrow still does not recall earlier commands. Maybe I need also a separate input history thing? If you start your program with rlwrap, for example |
March 01, 2023 Re: stdin.readln line editing and recall with up arrow | ||||
---|---|---|---|---|
| ||||
Posted in reply to Richard (Rikki) Andrew Cattermole | On Saturday, 25 February 2023 at 08:47:42 UTC, Richard (Rikki) Andrew Cattermole wrote: > On 25/02/2023 9:45 PM, Daren Scot Wilson wrote: >> I went with readline. Left/right arrows work, but up arrow still does not recall earlier commands. Maybe I need also a separate input history thing? > > https://tiswww.case.edu/php/chet/readline/readline.html#Basic-Behavior Hmm... the add_history(), or maybe it's rl_add_history(), function seems to have been in ancient readline versions but at some point all line history code was taken out to be its own library. https://tiswww.case.edu/php/chet/readline/rltop.html https://tiswww.case.edu/php/chet/readline/history.html Arch Linux drags in both readline.so and history.so in its readline package. No one notices! Trying import gnu.history; fails since there's no distinct 'history' package (yet) and Dub doesn't drag it in along with readline. D can call C and link to anything in /usr/lib easily. Done. It works! How does D know to link to the libhistory.so library? I didn't say "history" anywhere. But it works. extern (C) { void add_history(const char*); } I'm tempted to make a history package and submit it to DUB. Maybe. After dinner... |
Copyright © 1999-2021 by the D Language Foundation