⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 curses.3

📁 操作系统设计与实现源码
💻 3
字号:
.TH CURSES 3.SH NAMEcurses \- screen/window management library.SH SYNOPSIScc demo.c -lcurses.SH DESCRIPTIONCurses is a library of screen and window management routines.  It is modeledafter the UNIX curses and ncurses libraries. Normally, programs written forcurses should be easily ported to UNIX, and vice versa..PPTo use the routines, the function initscr() must first be called.This creates two 'windows' for the user: stdscr and curscr.  Stdscr is thedefaultwindow for the user to make changes on, and curscr reflects the currentcontents of the physical display screen.  The user writes or edits the stdscrwindow to his liking, then calls the refresh() function to make curscrand the physical screen look like stdscr.  When the user program terminates,it should call the endwin() function to restore things to normal..PPThere are all sorts of window manipulation routines available to theprogrammer: auxiliary windows may be created, edited, moved and deleted.  Theterminal may be set in many different modes, output text may be attributedwith blink, blank, bold and reverse attributes.  Screen colors may also be set, foreground and background.  There are window-specificprintf- and scanf-like routines, routines for scrolling, box-drawing,window overlaying, clearing routines etc..PPFor more and detailed information, see the library source codes.  All cursesfunctions are preceded by a complete description..SH FUNCTIONSBelow is a list over the available functions, together with a briefdescription of what they do.  In general, functions whose names start with 'w'differ from the one without 'w' (like wmove vs. move) signify thata specific window is used. Without a 'w', sdtscr is implied.  The functionsthat start with 'mv' before the 'genereic' function name signify that acursor motion should be made before the actual work.  'mv' and 'w' combineas expected..PPMost routines that return an int will return the manifest constant ERR ifthere is a failure during execution.  Routines that return a char actuallyreturn an int, so that ERR does not conflict with the character code 0xff.All characters from 0 to 0xff are allowed for usage with curses..PPSome routines, like {mv}{w} printw() and {mv}{w}scanw() return a meaningfulpositive value if the operation is successful..PPThe curses package uses some predefined types, variables and manifestconstants that are also available to the programmer.  There are also a fewglobally accessible variables that should not be touched by the applicationprogram.  Those untouchable variables have names starting with anunderscore (_) to avoid conflicts.  The user-accessible types, variablesand constants are (there are a number of other constants defining characterattribute names and function key names - consult <curses.h> for details):.sp.nf.ta 3i(manifest constants).RSTRUE	boolean trueFALSE	boolean falseERR	unsuccessfull operationOK	successfull operation.RE.sp(types).RSWINDOW	a window structure typebool	boolean flag type.RE.sp(variables).RSWINDOW curscr	physical display imageWINDOW stdscr	default user drawing boardint LINES	terminal heightint COLS	terminal widthint NONL	\\n causes CR and LF when TRUE.RE.sp.fiThe following is an alphabetical list of the curses functions, togetherwith their types, parameters and a short comment for each (win is a window,ch, vc, hc are characters, buf is a character buffer, attrs is anattribute bit map, bf is a boolean flag.  Note that `characters' in thiscontext usually can have 16 bits):.nf.spint waddch(win,ch)	put char in stdscrint addch(ch)int mvaddch(y,x,ch)int mvwaddch(win,y,x,ch)int waddstr(win,str)	put string in stdscrint addstr(str)int mvaddstr(y,x,str)int mvwaddstr(win,y,x,str)void wattroff(win,attrs)	clear attribute(s) in windowvoid attroff(attrs)void wattron(win,attrs)	add attribute(s) in windowvoid attron(attrs)void wattrset(win,attrs)	set window char attributesvoid attrset(attrs)int baudrate()	dummy for compatibilityvoid beep()	ring the bell or visible bell if no bell availablevoid flash()	flash terminal screen or rings bell if no visible bell availablevoid wbox(win,miny,minx,maxy,maxx,vc,hc)	box in a window, with given charactersvoid box(win,vc,hc)void cbreak()	set terminal cbreak modevoid wclear(win)	clear stdscrvoid clear()void clearok(win,bf)	marks window for screen clearint wclrtobot(win)	clear from cursor to end of line and all lines down this lineint clrtobot()int mvclrtoeol(y,x)int mvwclrtobot(win,y,x)int wclrtoeol(win)	clear from cursor to end of lineint clrtoeol()int mvclrtoeol(y,x)int mvwclrtoeol(win,y,x)int wdelch(win)	delete a char in a windowint delch()int mvdelch(y,x)int mvwdelch(win,y,x)int wdeleteln(win)	delete a line in a windowint deleteln()int mvdeleteln(y,x)int mvwdeleteln(win,y,x)void delwin(win)	delete a window or a subwindowvoid doupdate()	update physical screenvoid echo()	set terminal echo modeint endwin()	cleanup and curses finitializationvoid werase(win)	erase a windowvoid erase()int erasechar()	return char delete characterint fixterm()	dummy for compatibilityvoid flushinp()	kill pending keyboard inputint wgetch(win)	get char via a windowint getch()int mvgetch(y,x)int mvwgetch(win,y,x)int wgetstr(win,str)	get string via window to a bufferint getstr(str)int mvgetstr(y,x,str)int mvwgetstr(win,y,x,str)void getyx(win,y,x)	get a window's cursor positionint gettmode()	dummy for compatibilityvoid idlok(win,bf)	dummy for compatibilityWINDOW *initscr()	curses initialization (ret stdscr or NULL)int winch(win)	get char at window cursorint inch()int mvinch(y,x)int mvwinch(win,y,x)int winsch(win,ch)	insert character in a windowint insch(ch)int mvinsch(y,x,ch)int mvwinsch(win,y,x,ch)int winsertln(win)	insert new line in a windowint insertln()int mvinsertln(y,x)int mvwinsertln(win,y,x)void keypad(win,bf)	marks a window for keypad usageint killchar()	return line delete characterchar *longname()	returns terminal description stringvoid leaveok(win,bf)	marks window for cursor 'update leave'void meta(win,bf)	marks window for metaint move(y,x)	move cursor in stdscrint mvcur(oldy,oldx,y,x)	move terminal cursor to <y,x>int mvprintw(y,x,fmt,args)	move & print string in stdscrint mvscanw(y,x,fmt,args)	move & get values via stdscrint mvwin(win,y,x)	move window on physical screenint mvwprintw(win,x,y,fmt,args)	move & print string in a windowint mvwscanw(win,y,x,fmt,args)	move & get values via a windowWINDOW *newwin(lines,cols,begy,begx)	create a new windowvoid nl()	set terminal cr-crlf mapping modevoid nocbreak()	unset terminal cbreak modvoid nodelay(win,bf)	marks window for no input waitvoid noecho()	unset terminal echo modevoid nonl()	unset terminal cr-crlf mapping modevoid noraw()	unset raw terminal modevoid overlay(win1,win2)	overlay one window on anothervoid overwrite(win1,win2)	overwrite one window on anotherint printw(fmt,args)	print string in stdscrvoid raw()	set raw terminal modevoid refrbrk(bf)	set screen update break modevoid refresh()	refresh stdscrint resetterm()	dummy for compatibilityint resetty()	restore terminal I/O modesint saveoldterm()	dummy for compatibilityint saveterm()	dummy for compatibilityint savetty()	save terminal I/O modesint scanw(fmt,args)	get values via stdscrvoid scroll(win)	scroll scrolling region of a windowvoid scrollok(win,bf)	marks a window to allow scrollvoid setcolors(A_COLOR(for,back))	sets the forground and background	colors of stdscrvoid set_curs(visibility)	0 for invisible, 1 for visible, 2 for good	visibleint setsrcreg(miny,maxy)	define stdscr's scroll regionint setterm()	dummy for compatibilityint setupterm(term,fd,errret)	set up terminalvoid standend()	start normal chars in stdscrvoid standout()	start standout chars in stdscrWINDOW *subwin(win,lines,cols,begy,begx)	create a sub-window in window winint tabsize(ts)	set/get tabsize of stdscrvoid touchwin(win)	mark a window as totally modifiedchar *unctrl(ch)	char-to-string converterint wmove(win,y,x)	move cursor in a windowvoid wnoutrefresh(win)	create internal screen imageint wprintw(win,fmt,args)	print string in a windowvoid wrefresh(win)	refresh windowint wscanw(win,fmt,args)	get values via a windowvoid wsetcolors(win,A_COLOR(for,back))	sets the forground and	background colors of the specified windowint wsetsrcreg(win,miny,maxy)	define a window's scrolling regionvoid wstandend(win)	start normal chars in windowvoid wstandout(win)	start standout chars in windowint wtabsize(win,ts)	set/get tabsize of a window.SH BUGSFunction keys are not available under the MINIX version.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -