how to support line editing/history in C++ console program?2019 Community Moderator ElectionHow do you declare an interface in C++?How can I profile C++ code running on Linux?How can I get the application's path in a .NET console application?Win32 Console — Backspace to Last LineWhy is this program erroneously rejected by three C++ compilers?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Read file line by line using ifstream in C++Why is reading lines from stdin much slower in C++ than Python?Simple and portable method for managing console cursors action in C++Gracefully shut-down command-line application on console window closure (on windows)

What approach do we need to follow for projects without a test environment?

Is it possible to upcast ritual spells?

Employee lack of ownership

Do I need to be arrogant to get ahead?

Gantt Chart like rectangles with log scale

Official degrees of earth’s rotation per day

Life insurance that covers only simultaneous/dual deaths

Interplanetary conflict, some disease destroys the ability to understand or appreciate music

Why Choose Less Effective Armour Types?

Did Ender ever learn that he killed Stilson and/or Bonzo?

Hacking a Safe Lock after 3 tries

Time travel from stationary position?

What exactly is this small puffer fish doing and how did it manage to accomplish such a feat?

What do Xenomorphs eat in the Alien series?

Look at your watch and tell me what time is it. vs Look at your watch and tell me what time it is

How to change two letters closest to a string and one letter immediately after a string using notepad++

What is the significance behind "40 days" that often appears in the Bible?

PTIJ: Who should I vote for? (21st Knesset Edition)

What has been your most complicated TikZ drawing?

My Graph Theory Students

How to use deus ex machina safely?

Who is flying the vertibirds?

How to create the Curved texte?

Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?



how to support line editing/history in C++ console program?



2019 Community Moderator ElectionHow do you declare an interface in C++?How can I profile C++ code running on Linux?How can I get the application's path in a .NET console application?Win32 Console — Backspace to Last LineWhy is this program erroneously rejected by three C++ compilers?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Read file line by line using ifstream in C++Why is reading lines from stdin much slower in C++ than Python?Simple and portable method for managing console cursors action in C++Gracefully shut-down command-line application on console window closure (on windows)










0















I'm writing an interactive command-driven console program... think of something like Python, Matlab, etc. if that helps. User types a command, gets a result, and repeats until done.



This works OK, but the only editing users can do is typing and Backspace. I'd like to let them use standard line editing: arrow keys, ctrl-A/E, option-arrow to go by word, etc. And (really asking a lot now), I'd also like them to be able to use up/down arrow to cycle through previous inputs, to edit/reenter those.



I'm aware of ncurses, but that seems like overkill; it's designed for making GUI-like interfaces, while what I want is a simple command-based interface.



I'm coding on a Mac, but I will soon want this to work on Linux and Windows too. I'm willing to roll up my sleeves and do it myself if necessary, but surely there's something out there that either does this, or at least abstracts away the differences between Unix and Windows consoles, without dragging all of ncurses into the picture?










share|improve this question



















  • 4





    en.wikipedia.org/wiki/GNU_Readline

    – Neil Butterworth
    Mar 6 at 19:19






  • 2





    In Windows, if you get the input from stdin the previous inputs are available from the up/down arrow keys. It works the same way as the console command line, but it only presents the inputs that were taken by the program running.

    – Weather Vane
    Mar 6 at 19:25







  • 2





    github.com/troglobit/editline is a BSD-like licensed version.

    – Botje
    Mar 6 at 19:45











  • @Weather Vane, that sounds like exactly the behavior I want — so I just need to pick or develop a solution to get the same behavior on the Unix/Linux.

    – Joe Strout
    Mar 6 at 23:25











  • Sounds like GNU Readline/editline is ideal — with editline possibly being preferable due to the license. @Botje, if you want to post that as an answer I'll be happy to accept it.

    – Joe Strout
    Mar 6 at 23:26















0















I'm writing an interactive command-driven console program... think of something like Python, Matlab, etc. if that helps. User types a command, gets a result, and repeats until done.



This works OK, but the only editing users can do is typing and Backspace. I'd like to let them use standard line editing: arrow keys, ctrl-A/E, option-arrow to go by word, etc. And (really asking a lot now), I'd also like them to be able to use up/down arrow to cycle through previous inputs, to edit/reenter those.



I'm aware of ncurses, but that seems like overkill; it's designed for making GUI-like interfaces, while what I want is a simple command-based interface.



I'm coding on a Mac, but I will soon want this to work on Linux and Windows too. I'm willing to roll up my sleeves and do it myself if necessary, but surely there's something out there that either does this, or at least abstracts away the differences between Unix and Windows consoles, without dragging all of ncurses into the picture?










share|improve this question



















  • 4





    en.wikipedia.org/wiki/GNU_Readline

    – Neil Butterworth
    Mar 6 at 19:19






  • 2





    In Windows, if you get the input from stdin the previous inputs are available from the up/down arrow keys. It works the same way as the console command line, but it only presents the inputs that were taken by the program running.

    – Weather Vane
    Mar 6 at 19:25







  • 2





    github.com/troglobit/editline is a BSD-like licensed version.

    – Botje
    Mar 6 at 19:45











  • @Weather Vane, that sounds like exactly the behavior I want — so I just need to pick or develop a solution to get the same behavior on the Unix/Linux.

    – Joe Strout
    Mar 6 at 23:25











  • Sounds like GNU Readline/editline is ideal — with editline possibly being preferable due to the license. @Botje, if you want to post that as an answer I'll be happy to accept it.

    – Joe Strout
    Mar 6 at 23:26













0












0








0








I'm writing an interactive command-driven console program... think of something like Python, Matlab, etc. if that helps. User types a command, gets a result, and repeats until done.



This works OK, but the only editing users can do is typing and Backspace. I'd like to let them use standard line editing: arrow keys, ctrl-A/E, option-arrow to go by word, etc. And (really asking a lot now), I'd also like them to be able to use up/down arrow to cycle through previous inputs, to edit/reenter those.



I'm aware of ncurses, but that seems like overkill; it's designed for making GUI-like interfaces, while what I want is a simple command-based interface.



I'm coding on a Mac, but I will soon want this to work on Linux and Windows too. I'm willing to roll up my sleeves and do it myself if necessary, but surely there's something out there that either does this, or at least abstracts away the differences between Unix and Windows consoles, without dragging all of ncurses into the picture?










share|improve this question
















I'm writing an interactive command-driven console program... think of something like Python, Matlab, etc. if that helps. User types a command, gets a result, and repeats until done.



This works OK, but the only editing users can do is typing and Backspace. I'd like to let them use standard line editing: arrow keys, ctrl-A/E, option-arrow to go by word, etc. And (really asking a lot now), I'd also like them to be able to use up/down arrow to cycle through previous inputs, to edit/reenter those.



I'm aware of ncurses, but that seems like overkill; it's designed for making GUI-like interfaces, while what I want is a simple command-based interface.



I'm coding on a Mac, but I will soon want this to work on Linux and Windows too. I'm willing to roll up my sleeves and do it myself if necessary, but surely there's something out there that either does this, or at least abstracts away the differences between Unix and Windows consoles, without dragging all of ncurses into the picture?







c++ console-application






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 6 at 19:50









Barmar

432k36255356




432k36255356










asked Mar 6 at 19:17









Joe StroutJoe Strout

1,83611729




1,83611729







  • 4





    en.wikipedia.org/wiki/GNU_Readline

    – Neil Butterworth
    Mar 6 at 19:19






  • 2





    In Windows, if you get the input from stdin the previous inputs are available from the up/down arrow keys. It works the same way as the console command line, but it only presents the inputs that were taken by the program running.

    – Weather Vane
    Mar 6 at 19:25







  • 2





    github.com/troglobit/editline is a BSD-like licensed version.

    – Botje
    Mar 6 at 19:45











  • @Weather Vane, that sounds like exactly the behavior I want — so I just need to pick or develop a solution to get the same behavior on the Unix/Linux.

    – Joe Strout
    Mar 6 at 23:25











  • Sounds like GNU Readline/editline is ideal — with editline possibly being preferable due to the license. @Botje, if you want to post that as an answer I'll be happy to accept it.

    – Joe Strout
    Mar 6 at 23:26












  • 4





    en.wikipedia.org/wiki/GNU_Readline

    – Neil Butterworth
    Mar 6 at 19:19






  • 2





    In Windows, if you get the input from stdin the previous inputs are available from the up/down arrow keys. It works the same way as the console command line, but it only presents the inputs that were taken by the program running.

    – Weather Vane
    Mar 6 at 19:25







  • 2





    github.com/troglobit/editline is a BSD-like licensed version.

    – Botje
    Mar 6 at 19:45











  • @Weather Vane, that sounds like exactly the behavior I want — so I just need to pick or develop a solution to get the same behavior on the Unix/Linux.

    – Joe Strout
    Mar 6 at 23:25











  • Sounds like GNU Readline/editline is ideal — with editline possibly being preferable due to the license. @Botje, if you want to post that as an answer I'll be happy to accept it.

    – Joe Strout
    Mar 6 at 23:26







4




4





en.wikipedia.org/wiki/GNU_Readline

– Neil Butterworth
Mar 6 at 19:19





en.wikipedia.org/wiki/GNU_Readline

– Neil Butterworth
Mar 6 at 19:19




2




2





In Windows, if you get the input from stdin the previous inputs are available from the up/down arrow keys. It works the same way as the console command line, but it only presents the inputs that were taken by the program running.

– Weather Vane
Mar 6 at 19:25






In Windows, if you get the input from stdin the previous inputs are available from the up/down arrow keys. It works the same way as the console command line, but it only presents the inputs that were taken by the program running.

– Weather Vane
Mar 6 at 19:25





2




2





github.com/troglobit/editline is a BSD-like licensed version.

– Botje
Mar 6 at 19:45





github.com/troglobit/editline is a BSD-like licensed version.

– Botje
Mar 6 at 19:45













@Weather Vane, that sounds like exactly the behavior I want — so I just need to pick or develop a solution to get the same behavior on the Unix/Linux.

– Joe Strout
Mar 6 at 23:25





@Weather Vane, that sounds like exactly the behavior I want — so I just need to pick or develop a solution to get the same behavior on the Unix/Linux.

– Joe Strout
Mar 6 at 23:25













Sounds like GNU Readline/editline is ideal — with editline possibly being preferable due to the license. @Botje, if you want to post that as an answer I'll be happy to accept it.

– Joe Strout
Mar 6 at 23:26





Sounds like GNU Readline/editline is ideal — with editline possibly being preferable due to the license. @Botje, if you want to post that as an answer I'll be happy to accept it.

– Joe Strout
Mar 6 at 23:26












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55030620%2fhow-to-support-line-editing-history-in-c-console-program%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55030620%2fhow-to-support-line-editing-history-in-c-console-program%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved