开发者

Is it Possible to Display Editable Text In A Shell Via The Standard C++ IOStream?

Is it possible to display interactive and editable text in a console via a standard C++ iostream?

In other words, would it be possible to have basic Vim-esque text editing abilities using only the standard C++ iostream within a shell?

For example, suppose a simple string exampleTe开发者_C百科xt containing the text "Example text." was displayed in a shell window using the code:

std::string exampleText = "Example text.";
std::string editedText;
std::cout << exampleText;

would it be possible to edit the string stored in exampleText while it is displayed in a shell and then save the edited version of that string into editedText?

I have doubts about this being possible, but if anyone could help to clarify whether or not this would be possible I would greatly appreciate it.

Thanks in advance!


Of course it is possible. Just output the correct terminal escapes. For each escape make sure you cover for all the popular terminals.

Or save yourself the trouble and use readline or ncurses.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜