"curs_set()" 未能 return 先前的游标状态
"curs_set()" failed to return the previous cursor state
根据 curs_set
手册页:
The curs_set
routine sets the cursor state to invisible, normal, or very visible for visibility
equal to 0
, 1
, or 2
respectively. If the terminal supports the
visibility requested, the previous cursor state is returned; otherwise, ERR
is returned.
但是下面的简单程序并没有return之前的状态:
[STEP 107] # cat curs_set.c
#include <stdio.h>
#include <curses.h>
int main()
{
int ret;
initscr();
ret = curs_set(1);
endwin();
printf("curs_set() returned %d\n", ret);
return 0;
}
[STEP 108] # gcc curs_set.c -lncurses
[STEP 109] # setterm -cursor off
[STEP 110] # ./a.out <-- cursor invisible
curs_set() returned 1 <-- why not 0?
[STEP 111] # tput civis <-- cursor visible
[STEP 112] # ./a.out <-- cursor invisible
curs_set() returned 1 <-- why not 0?
[STEP 113] # <-- cursor visible
我是不是漏掉了什么?
正如评论中 @vonaka 所提醒的那样,手册页还说(在单独的 NOTES 部分):
Both ncurses
and SVr4
will call curs_set()
in endwin()
if curs_set()
has been called to make the cursor other than normal, i.e., either invisible or very visible. There is no way for ncurses to determine the initial cursor state to restore that.
根据 curs_set
手册页:
The
curs_set
routine sets the cursor state to invisible, normal, or very visible forvisibility
equal to0
,1
, or2
respectively. If the terminal supports the visibility requested, the previous cursor state is returned; otherwise,ERR
is returned.
但是下面的简单程序并没有return之前的状态:
[STEP 107] # cat curs_set.c
#include <stdio.h>
#include <curses.h>
int main()
{
int ret;
initscr();
ret = curs_set(1);
endwin();
printf("curs_set() returned %d\n", ret);
return 0;
}
[STEP 108] # gcc curs_set.c -lncurses
[STEP 109] # setterm -cursor off
[STEP 110] # ./a.out <-- cursor invisible
curs_set() returned 1 <-- why not 0?
[STEP 111] # tput civis <-- cursor visible
[STEP 112] # ./a.out <-- cursor invisible
curs_set() returned 1 <-- why not 0?
[STEP 113] # <-- cursor visible
我是不是漏掉了什么?
正如评论中 @vonaka 所提醒的那样,手册页还说(在单独的 NOTES 部分):
Both
ncurses
andSVr4
will callcurs_set()
inendwin()
ifcurs_set()
has been called to make the cursor other than normal, i.e., either invisible or very visible. There is no way for ncurses to determine the initial cursor state to restore that.