在Ncurses上添加滚动条,或使其类似于“更多". [英] Add a scrollbar on Ncurses or make it like "more"

查看:64
本文介绍了在Ncurses上添加滚动条,或使其类似于“更多".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我正在编写一个客户端程序,该程序从服务器接收响应和日志,该客户端还能够向服务器发送请求以获取不同的信息.我使用了诅咒,输出看起来还不错.看起来像VI,顶部输出,客户端用户输入底部命令.唯一的事情是我无法向后滚动..我的老板告诉我将其设置为"Linux中的更多命令",我想坚持我的解决方案,并在输出窗口的侧面添加滚动条...我以为Server是随机发送日志的,几乎不可能(或太难了)以使其看起来更多...

Basically I am writing a client program which receives response and logs from server, the client is also able to send request to server for different information. I used curses and output looks pretty good. It looks like VI, output at the top and user on Client end enter command at the bottom. Only thing is I am not able to scroll back.. My boss told me to make it like "more command in linux" and I want to stick with my solution and add a scroll bar on the side for output window... I was thinking Server sends logs randomly and it's nearly impossible (or too hard) to make it look like more...

推荐答案

我不确定您是否正在询问如何实现回滚或如何使用ncurses绘制滚动条.我的猜测是第二个.

I'm not entirely sure if you are asking about how to implement scrollback or how to draw a scrollbar with ncurses. My guess is the second.

假设您的ncurses是在Unicode支持下编译的(记住初始化ncurses时要正确设置环境,请查看"setlang"),您可以使用以下字符:

Assuming your ncurses is compiled with Unicode support (remember to set the environment correctly when initializing ncurses, look into "setlang"), you can use following characters:

Unicode:
▲ - U+25B2 BLACK UP-POINTING TRIANGLE
▼ - U+25BC BLACK DOWN-POINTING TRIANGLE
▮ - U+25AE BLACK VERTICAL RECTANGLE

ASCII:
176 - ░ Light shaded block
177 - ▒ Medium shaded block
178 - ▓ Dark shaded block
219 - █ Block block

编写代码以将暗块显示在正确的位置应该很简单.

Writing the code to display the dark block at the right place should be quite straightforward.

如果我对你的问题理解不对,请原谅.

If I understood your question wrong, my excuses.

这篇关于在Ncurses上添加滚动条,或使其类似于“更多".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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