如何使用 ncurses 添加到终端的回滚?

发布于 2024-08-11 01:36:37 字数 249 浏览 4 评论 0原文

我正在使用 ncurses 编写一个应用程序,它显示在多台计算机上运行的测试的状态。它在屏幕底部显示几个进度条,并在其上方显示失败日志。但是,日志可能很容易比终端的其余部分长。

我希望多余的日志从顶部滚下来,这样如果用户向上滚动终端,他们就会看到日志的其余部分。这就是当您使用 less 滚动浏览文件时会发生的情况;它将用下一页替换当前视图,但您传递的文本最终会出现在终端的回滚中。

我怎样才能让 ncurses 做到这一点?

I'm writing an app using ncurses which displays the status of tests running on multiple machines. It displays several progress bars at the bottom of the screen, and a failure log above them. However, the log may easily be longer than the rest of the terminal.

I'd like to have excess log roll off the top in such a way that if the user scrolls their terminal up they'll see the rest of the log. This is what happens when you scroll through a file using less; it replaces the current view with the next page, but the text you've passed ends up in the terminal's scrollback.

How can I get ncurses to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

So要识趣 2024-08-18 01:36:37

事实证明这很容易。我只是在屏幕顶部放置一个窗口,使其可滚动 (scrollok),并向其添加文本,直至其滚动。文本毫无问题地立即滚动到回滚中。

Turns out this is easy. I just put a window at the top of the screen, made it scrollable (scrollok), and addstr'd text to it until it scrolled. The text scrolled right off into the scrollback without trouble.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文