我试图在 ncurses 中获取一个窗口,在其中写入 mysql 查询的结果。但查询返回的行数比我终端中的行数多。所以我尝试创建一个垫子,以便我可以滚动浏览结果。
但问题是,我的终端上没有可见的键盘。
我只是简化了代码,但它仍然不适合我:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <ncurses.h>
#include <mysql.h>
#include <my_global.h>
WINDOW *pad;
MYSQL *con;
static int mrow, mcol;
static char *host, *user, *pass;
void quit(void)
{
// close MySQL connection
mysql_close(con);
// end curses
endwin();
}
int main(int argc, char **argv)
{
// initialize curses
initscr();
atexit(quit);
clear();
cbreak();
keypad(stdscr, TRUE);
start_color();
// get terminal size
getmaxyx(stdscr, mrow, mcol);
// open MySQL connection
host = "localhost";
user = "root"; …Run Code Online (Sandbox Code Playgroud) 我最近被介绍过ncurses用于异步键盘按键监听,并且与它相处得很好.我面临的一个问题是你只能在可见屏幕上显示文字,没有滚动条.我想知道它是否可以继续使用,ncurses因为它是如此可爱,但让程序仍然保持滚动条而不是到达最后一行并留在那里.