我想知道如何实现更多的过滤器 - 就像在显示文本中一样,直到它填满屏幕并用“Enter”移动每一行(就像在UNIX中一样)。我知道ncurses很有用,但无法找到合适的方法。
谢谢!
答案 0 :(得分: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
实现的源代码。