简体   繁体   English

Ncurses:刷新不重叠的窗口将刷新整个屏幕。 如何避免这种情况?

[英]Ncurses: Refreshing a non-overlapping window refreshes the whole screen. How to avoid this?

I am hacking together a ncurses application which uses 5 windows: 我正在一起黑客入侵使用5个窗口的ncurses应用程序:

  • statusbar window - 1 X COLS right at the bottom of the screen. 状态栏窗口-屏幕底部右侧为1 X COLS。
  • titlebar window - 1 X COLS right at the top of the screen. 标题栏窗口-屏幕顶部正好有1 X COLS。
  • 3 content windows - LINES - 2 X COLS, inbetween the statusbar and titlebar. 3个内容窗口-线-2 X COLS,位于状态栏和标题栏之间。

Note that there are 3 content windows, which entirely overlap each other. 请注意,有3个内容窗口,它们彼此完全重叠。 I am manually deciding which is to be redrawn. 我正在手动确定要重绘的内容。 The titlebar and statusbar windows do not overlap any other window. 标题栏和状态栏窗口不与任何其他窗口重叠。

One use case is for the user to choose a file to upload to a network daemon using a menu in one of the content windows. 一个用例是用户使用内容窗口之一中的菜单选择要上传到网络守护程序的文件。 Upon selecting a file, the statusbar acts as a crude progressbar, drawing some hashes to indicate how far the file has been uploaded. 选择文件后,状态栏将充当粗略的进度栏,并绘制一些哈希值以指示文件已上传的距离。

What this boils down to is using: 这归结为正在使用:

  • wclear(status); wclear(状态);
  • mvwprintw(status, ...); mvwprintw(状态,...);
  • wrefresh(status); wrefresh(状态);

This works, but for some reason causes the entire screen to be redrawn, causing a horrible flickery mess. 这是可行的,但是由于某种原因导致整个屏幕被重绘,从而导致可怕的闪烁混乱。 Having read the manual, I can not see why this should be the case; 阅读了手册后,我看不到为什么会这样。 as long as the statusbar does not overlap any other windows, redrawing the statusbar should not cause a whole screen redraw? 只要状态栏不与任何其他窗口重叠,重绘状态栏是否应不会导致整个屏幕重绘?

Am I correct, or have I misunderstood? 我是正确的,还是我误会了? Is there a way to prevent this? 有办法防止这种情况吗?

The code is here: https://github.com/vext01/hgd/blob/master/nchgdc.c#L812 代码在这里: https : //github.com/vext01/hgd/blob/master/nchgdc.c#L812

Note, the code is vastly unfinished and lacks polish =) 请注意,该代码尚未完成,并且缺少修饰=)

My ncurses implementation is that of OpenBSD. 我的ncurses实现是OpenBSD的实现。

From the wclear man page: 在清晰的手册页中:

The clear and wclear routines are like erase and werase, but they also call clearok, so that the screen is cleared completely on the next call to wrefresh for that window and repainted from scratch. 清除和清除例程类似于“擦除”和“擦除”程序,但是它们也调用clearok,以便在下次调用该窗口的wrefresh时完全清除屏幕并从头开始重新绘制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM