我正在使用库ncurses,当我尝试拨打wprintw()
,然后在右侧窗口执行wrefresh
时,它不会打印任何内容。
#include <stdio.h>
#include <stdlib.h>
#include <ncurses.h>
int main()
{
WINDOW *winTest; //The window
int rows, cols; //Rows and colums in the terminal
initscr(); //Starting NCurses
raw(); //Calling 'getch()' doesn't wait for '\n'
noecho(); //Doesn't print what's written by user
curs_set(0); //Doesn't display the cursor
getmaxyx(stdscr, rows, cols); //How many rows and colums in stdscr (the terminal)
winTest = newwin(10, 10, rows/2, cols/2); //Creates a square WINDOW at the center of the terminal
mvwprintw(winTest, 0, 0, "Test"); //Prints "Test" on the created window
wrefresh(winTest); //Refreshes so what's done is displayed
getch(); //Pause
delwin(winTest); //Free the memory for winTest
endwin(); //Ends NCurses
return 0;
}
执行此操作时,不会显示任何内容。
我在Ubuntu 14.04 LTS上,用gcc编译:
gcc -g -Wall -Werror -Wpedantic -Wextra -Wformat -o test.exe test.c -lncurses
我在gnome-terminal中执行。
答案 0 :(得分:2)
正如here所述,您应该替换:
protected function setIsCommentingEnabledAttribute($enabled) {
$this->setVariable(UserVariable::IS_COMMENTING_ENABLED, $enabled);
}
protected function getIsCommentingEnabledAttribute($enabled) {
$this->getVariable(UserVariable::IS_COMMENTING_ENABLED);
}
}
由:
$user = User::find(123);
$user->is_commenting_enabled; // Calls the getter, no DB calls
$user->is_commenting_enabled = 1; // Calls the setter, no DB calls
$user->push(); // Saves the user and any variables which have been added or changed.
答案 1 :(得分:0)
我用自己的暂停功能替换了第二次暂停,getch():scanf(“%* s”);然后它在中间显示测试,就像它应该的那样。我认为发生的事情是它一次性地经历了两次停顿,因此您从未看过“测试”,因为它被删除的速度与创建速度一样快。 - 托尼露丝
感谢Tony Ruth,他回答了我的问题。即使我仍然不明白为什么getch()
删除了所写的内容,将其替换为scanf("%*s")
也能正常工作!