0

我想知道如何实现更多过滤器 - 就像显示文本一样,直到它填满屏幕并用“Enter”移动每一行(就像在 UNIX 中一样)。我知道 ncurses 会很有用,但找不到合适的方法。

谢谢!

4

1 回答 1

0

做一个两个缓冲区的实现

这可以是一个大纲:

Read from file into the 1st buffer.

offset = 0

while `offset != total_lines_in_file`
  [1] show `max_lines_in_a_page` number of lines starting from line number `offset`
  [2] when showing the lines if a buffer end is detected, load the other buffer and switch buffer, and print remaining lines.
  [3] if the specific scroll keypress is detected make `offset = offset + x` (x = 1, 2 etc.)

最好看一下实现的源代码more

于 2012-04-29T14:49:50.643 回答