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

📄 intro.3cur

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 3CUR
📖 第 1 页 / 共 2 页
字号:
.TH intro 3cur.SH Nameintro \- introduction to the X/Open Curses Package, which optimizes terminal screen handling and updating .SH Syntax.B #include <cursesX.h>.br.B cc[ .I options].I files.B \-lcursesX[ .I libraries ].SH Description.NXR "intro(3cur) keyword".NXR "curses package".NXR "cursor" "optimizing movement".NXR "curses library".NXR "curses package" "main routines".NXR "screen" "updating".NXR "window" "defined".NXR "terminal" "updating screen".PPThe.PN curses (cursor optimization) package is the X/Open set of library routines used for writing screen-management programs.Cursor optimization minimizes the amount the cursor has to be movedaround the screen in order to update it.Screen-management programs are used for tasks such as moving the cursor, printing a menu, dividing a terminalscreen into windows or drawing a display on a screen for data entry andretrieval..PPThe .PN curses package is split into three parts: screen updating,screen updating with user input, andcursor motion optimization.Screen-updating routines are used when parts of the screen need to bechanged but the overall image remains the same.The cursor motion part of the package can be used separately for tasks suchas defining how the cursor moves in response to tabs and newline characters.PPThe.PN cursesroutines do not write directly to the terminal screen (the physical screen):instead, they write to awindow,a two-dimensional array of characters which represents all or part ofthe terminal screen. A window can be as big as the terminal screen or any smaller size down toa single character..PPThe .PN <cursesX.h> header file supplies two default windows,  .PN stdscr(standard screen) and.PN curscr(current screen) for all programs using.PN cursesroutines.The.PN stdscr window is the size of the current terminal screen. The.PN curscrwindow is not normally accessed directly by the screen-management program;changes are made to the appropriate window and thenthe.PN refresh routine is called.The screen program keeps track of what is on the physical screenand what is on.PN stdscr .When .PN refresh is called,it compares the two screen images and then sends a streamof characters to the terminal to make the physical screen look like.PN stdscr ..PPThe header file.PN <cursesX.h>defines.PN stdscrto be of the type.PN WINDOW* . This is a pointer to a C structurewhich includes the starting position of the window on the screen and the windowsize..PPSome .PN cursesroutines are designed to work with a .PN pad .A pad is a type of window whose size is not restricted by thesize of the screen. Use a pad when you only need part of a window on the screen at any one time, for example when running a spreadsheet application..PPOther windows can be created with.PN newwin and used instead of.PN stdscrfor maintaining several different screen images, for example,one window can control input/output andanother can display error messages.The routine .PN subwin creates subwindows within windows.When windows overlap, the contents of the current screen show the mostrecently refreshed window..PPAmong the most basic routines are.PN move and.PN addch .These routines are used to move the cursor aroundand to add characters to the default window,.PN stdscr. .PPAll.PN cursesdata is manipulated using the routines provided by the .PN curseslibrary.You should not use routines or system calls from other libraries in a .PN curses program as they may cause undesirable results when you run the program..PP.B Using Curses.PP    The .PN curses library has three types of routines; Main routines, TERMINFO routines and TERMCAP compatibility routines.PPThe .PN terminforoutines are a group of routines within the.PN curseslibrary which provide a database containing descriptions of many terminals thatcan be used with.PN cursesprograms.The termcap compatibility routines are provided asa conversion aid for programs using termcap..PPMost screen handling can be achieved using the Mainroutines.  The following hints should help you make the most of the screen-handling routines..PPThe .PN <cursesX.h>header file must always be included whenever.PN cursesfunctions are used in a program. Note that the header file includes.PN <sgtty.h>to enable the terminal to use the features provided by ULTRIX.All the manual definitions assume that.PN <cursesX.h>has been included in the code..PPThe header file defines global variables and data structures, and defines severalof the routines as macros.The integer variables .PN LINESand .PN COLSare definedso that when a .PN curses program is run on a particular terminal, .PN initscr assignsthe vertical and horizontal dimensionsof the terminal screen to these variables..PPA.PN curses program must start by calling the routine.PN initscr to allocate memory space for the windows.It should only be called once in a program,as it can overflowcore memory if it is called repeatedly.The routine .PN endwin is used to exit from the screen-handling routines..PPMost interactive screen-oriented programs need character-at-a-timeinput without echoing.To achieve this, you should call:.EXnonl();cbreak();noecho();.EEimmediately after calling .PN initscr .All .PN cursesroutines that move the cursor, move it relative to the home position in theupper left corner of the screen. The .PN (LINES ,.PN COLS )coordinate at this position is (1,1). Note that the vertical coordinate.PN yis given first and the horizontal coordinate.PN xis given second.The \-1 in the example program takes the home position into accountto place the cursor on the centre line of the terminal screen.The example program displays .B MIDSCREENin the centre of the screen.Usethe.PN refresh routine after changing a screen to make the terminal screen look like.PN stdscr ..PP.BExample Program.R.EX 0#include <cursesX.h>main (){.EE.EXinitscr();     /*initialize terminal settings, data		 ** structures and variables*/move(LINES/2 \-1, COLS/2 \-4);addstr("MID");refresh();     /* send output to update terminal                 **  screen */addstr("SCREEN");refresh();     /* send more output to terminal                 **  screen */endwin();      /*restore all terminal settings */.EE.EX 0}.EE.SH Main Routines.PPRoutines listed here can be called when using the .PN curseslibrary.Routines that are preceded by a .B waffect a specified window,those preceded by a .B paffect a specified pad.All other routines affect the default window .PN stdscr .Windows are specified by a numeric argument, for example: .PN winch(\fIwin\fR)where.I win is the specified window..PP.ds w \fIwin\fR.ds s \fHstdscr\fR.TStab (#);l l.addch(ch)#T{Add a character to \*s (like \fHputchar\fP wraps to nextline at end of line)T}addstr(str)#Call addch with each character in \fIstr\fPattroff(attrs)#Turn off named attributesattron(attrs)#Turn on named attributesattrset(attrs)#Set current attributes to \fIattrs\fPbaudrate(\|)#Display current terminal speedbeep(\|)#Sound beep on terminalbox(win, vert, hor)#Draw a box around edges of \*w,#\fIvert\fP and \fIhor\fP are characters to use for vertical#and horizontal edges of boxclear(\|)#Clear \*sclearok(win, bf)#Clear screen before next redraw of \*wclrtobot(\|)#Clear to bottom of \*sclrtoeol(\|)#Clear to end of line on \*scbreak(\|)#Set cbreak modedelay_output(ms)#Insert \fIms\fP millisecond pause in outputdelch(\|)#Delete a characterdeleteln(\|)#Delete a linedelwin(win)#Delete \*wdoupdate(\|)#Update screen from all wnoutrefreshecho(\|)#Set echo modeendwin(\|)#End window modeserase(\|)#Erase \*serasechar(\|)#Return user's erase characterfixterm(\|)#Restore tty to in ``curses'' stateflash(\|)#Flash screen or beepflushinp(\|)#Throw away any typeaheadgetch(\|)#Get a character from ttygetstr(str)#Get a string through \*s

⌨️ 快捷键说明

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