使用GNU Readline;如何在同一程序中添加ncurses? [英] Using GNU Readline; how can I add ncurses in the same program?

查看:112
本文介绍了使用GNU Readline;如何在同一程序中添加ncurses?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题比我的实际目标更具体:

The title is a bit more specific than my actual goal:

我有一个命令行程序,该程序使用GNU Readline,主要用于命令历史记录(即,使用向上箭头检索以前的命令)和其他一些优点.现在,程序的输出似乎散布在用户的输入中,这有时可以,但是输出是异步的(通过网络连接响应输入命令),有时会很烦人(例如,当用户输入时输出行)输入新的输入内容.

I have a command-line program which uses GNU Readline, primarily for command history (i.e. retrieving previous commands using up-arrow) and some other niceties. Right now the program's output appears interspersed with the user's input, which sometimes is OK but the output is asynchronous (it comes via a network connection in response to the input commands), and that gets annoying sometimes (e.g. if lines are output when the user is typing new input).

我想为该程序添加一个功能:输出的单独窗口".我考虑过为此使用ncurses.但是从 ncurses常见问题解答中看来,这两个库都不容易一起使用.

I'd like to add a feature to this program: a separate "window" for the output. I thought about using ncurses for this. But it appears from the ncurses FAQ that the two libraries are not easy to use together.

我可能会考虑使用 Editline

I might consider using Editline or tecla instead of Readline, but it's not clear to me if either of those will solve my problem. I'd also consider using something other than ncurses, including a library which provides both kinds of functionality (text-mode windows and command history), but I don't know what might be best.

哦,支持彩色文本可能会获得加分.我怀疑我可以使用Readline做到这一点,所以也许这是一个单独的问题,但是如果解决我的问题也可以轻松地在输出中添加一些颜色,那就更好了.

Oh, and support for colored text might get bonus points. I suspect I may be able to do that with Readline, so maybe it's a separate concern, but if a solution to my problem also makes it easy to add a bit of color to the output, so much the better.

我正在使用Ubuntu Hardy(Linux 2.6).

I'm using Ubuntu Hardy (Linux 2.6).

推荐答案

我已经做了一些搜索,看来您不走运.

I have done some searching, and it seems like you are out of luck.

对于ncurses替代品,有 SLang Turbo 视觉. lang语不仅限于屏幕处理,因此还有更多 复杂,但也许可以用于您的目的?纽特使用屏幕 且处理起来要简单得多,但是太简单了,单线程模式 我认为是出于您的目的.

For ncurses alternatives there are SLang, Newt and Turbo Vision. Slang is much more than just screen handling and thus more complex, but maybe it can be used for your purpose?. Newt uses the screen handling and is much simpler, but too simple and single-threaded-mode for your purpose I think.

Turbo vision是Borland的文本模式图形库,由 他们在80年代末90年代初的所有工具. Borland发布了源代码 当这种事情的市场减少时,就会有代码 现在是Linux的端口(旁注,此项目似乎已经写好了 自己的涡轮增压视觉实现).那个端口还没死(有 是今年的一些cvs更新,并且编译良好(旧版本 没有)),但是我发现的电视示例都不是最新的,我 在放弃其余部分之前,只让其中一些进行了编译. 这有点可耻,因为电视是一个可爱的使用环境. 电视是C ++(我假设您使用的是C?).

Turbo vision is the text mode graphics library from Borland, used by all their tools in the late 80s/early 90s. Borland released the source code when the market for that kind of thing diminished, and there is now a port for linux (side note, this project seems to have written its own turbo vision implementation). That port is not dead (there have been some cvs updates this year which compiled fine (the older releases did not)), but none of the TV examples I found were up to date and I did only got a few of them to compile before giving up on the rest. This is a bit of a shame, because TV was a lovely environment to use. TV is btw C++ (and I assume you are using C?).

作为readline的替代方法,可以使用 libkinput 与ncurses一起使用(它说它可以使用ncurses的terminfo.但是我 不知道这是否意味着它可以与ncurses用法一起共存)?

For an alternative to readline, there is libkinput, which maybe works together with ncurses (it says it can use ncurses' terminfo. but I am not sure if that means that it can co-exists together with ncurses usage)?

也许一种选择是在ncurses程序中外部"运行readline 使用 rlwrap ?

Maybe one option is to run readline "externally" to your ncurses program using rlwrap?

这篇关于使用GNU Readline;如何在同一程序中添加ncurses?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆