📄 terminal.texi
字号:
This specifies eight bits per byte.@end deftypevrThe following four bits are BSD extensions; this exist only on BSDsystems and the GNU system.@comment termios.h@comment BSD@deftypevr Macro tcflag_t CCTS_OFLOWIf this bit is set, enable flow control of output based on the CTS wire(RS232 protocol).@end deftypevr@comment termios.h@comment BSD@deftypevr Macro tcflag_t CRTS_IFLOWIf this bit is set, enable flow control of input based on the RTS wire(RS232 protocol).@end deftypevr@comment termios.h@comment BSD@deftypevr Macro tcflag_t MDMBUFIf this bit is set, enable carrier-based flow control of output.@end deftypevr@comment termios.h@comment BSD@deftypevr Macro tcflag_t CIGNOREIf this bit is set, it says to ignore the control modes and line speedvalues entirely. This is only meaningful in a call to @code{tcsetattr}.The @code{c_cflag} member and the line speed values returned by@code{cfgetispeed} and @code{cfgetospeed} will be unaffected by thecall. @code{CIGNORE} is useful if you want to set all the softwaremodes in the other members, but leave the hardware details in@code{c_cflag} unchanged. (This is how the @code{TCSASOFT} flag to@code{tcsettattr} works.)This bit is never set in the structure filled in by @code{tcgetattr}.@end deftypevr@node Local Modes@subsection Local ModesThis section describes the flags for the @code{c_lflag} member of the@code{struct termios} structure. These flags generally controlhigher-level aspects of input processing than the input modes flagsdescribed in @ref{Input Modes}, such as echoing, signals, and the choiceof canonical or noncanonical input.The @code{c_lflag} member itself is an integer, and you change the flagsand fields using the operators @code{&}, @code{|}, and @code{^}. Don'ttry to specify the entire value for @code{c_lflag}---instead, changeonly specific flags and leave the rest untouched (@pxref{SettingModes}).@comment termios.h@comment POSIX.1@deftypevr Macro tcflag_t ICANONThis bit, if set, enables canonical input processing mode. Otherwise,input is processed in noncanonical mode. @xref{Canonical or Not}.@end deftypevr@comment termios.h@comment POSIX.1@deftypevr Macro tcflag_t ECHOIf this bit is set, echoing of input characters back to the terminalis enabled.@cindex echo of terminal input@end deftypevr@comment termios.h@comment POSIX.1@deftypevr Macro tcflag_t ECHOEIf this bit is set, echoing indicates erasure of input with the ERASEcharacter by erasing the last character in the current line from thescreen. Otherwise, the character erased is re-echoed to show what hashappened (suitable for a printing terminal).This bit only controls the display behavior; the @code{ICANON} bit byitself controls actual recognition of the ERASE character and erasure ofinput, without which @code{ECHOE} is simply irrelevant.@end deftypevr@comment termios.h@comment BSD@deftypevr Macro tcflag_t ECHOPRTThis bit is like @code{ECHOE}, enables display of the ERASE character ina way that is geared to a hardcopy terminal. When you type the ERASEcharacter, a @samp{\} character is printed followed by the firstcharacter erased. Typing the ERASE character again just prints the nextcharacter erased. Then, the next time you type a normal character, a@samp{/} character is printed before the character echoes.This is a BSD extension, and exists only in BSD systems and theGNU system.@end deftypevr@comment termios.h@comment POSIX.1@deftypevr Macro tcflag_t ECHOKThis bit enables special display of the KILL character by moving to anew line after echoing the KILL character normally. The behavior of@code{ECHOKE} (below) is nicer to look at.If this bit is not set, the KILL character echoes just as it would if itwere not the KILL character. Then it is up to the user to remember thatthe KILL character has erased the preceding input; there is noindication of this on the screen.This bit only controls the display behavior; the @code{ICANON} bit byitself controls actual recognition of the KILL character and erasure ofinput, without which @code{ECHOK} is simply irrelevant.@end deftypevr@comment termios.h@comment BSD@deftypevr Macro tcflag_t ECHOKEThis bit is similar to @code{ECHOK}. It enables special display of theKILL character by erasing on the screen the entire line that has beenkilled. This is a BSD extension, and exists only in BSD systems and theGNU system.@end deftypevr@comment termios.h@comment POSIX.1@deftypevr Macro tcflag_t ECHONLIf this bit is set and the @code{ICANON} bit is also set, then thenewline (@code{'\n'}) character is echoed even if the @code{ECHO} bitis not set.@end deftypevr@comment termios.h@comment BSD@deftypevr Macro tcflag_t ECHOCTLIf this bit is set and the @code{ECHO} bit is also set, echo controlcharacters with @samp{^} followed by the corresponding text character.Thus, control-A echoes as @samp{^A}. This is usually the preferred modefor interactive input, because echoing a control character back to theterminal could have some undesired effect on the terminal.This is a BSD extension, and exists only in BSD systems and theGNU system.@end deftypevr@comment termios.h@comment POSIX.1@deftypevr Macro tcflag_t ISIGThis bit controls whether the INTR, QUIT, and SUSP characters arerecognized. The functions associated with these characters are performedif and only if this bit is set. Being in canonical or noncanonicalinput mode has no affect on the interpretation of these characters.You should use caution when disabling recognition of these characters.Programs that cannot be interrupted interactively are veryuser-unfriendly. If you clear this bit, your program should providesome alternate interface that allows the user to interactively send thesignals associated with these characters, or to escape from the program.@cindex interactive signals, from terminal@xref{Signal Characters}.@end deftypevr@comment termios.h@comment POSIX.1@deftypevr Macro tcflag_t IEXTENPOSIX.1 gives @code{IEXTEN} implementation-defined meaning,so you cannot rely on this interpretation on all systems.On BSD systems and the GNU system, it enables the LNEXT and DISCARD characters.@xref{Other Special}.@end deftypevr@comment termios.h@comment POSIX.1@deftypevr Macro tcflag_t NOFLSHNormally, the INTR, QUIT, and SUSP characters cause input and outputqueues for the terminal to be cleared. If this bit is set, the queuesare not cleared.@end deftypevr@comment termios.h@comment POSIX.1@deftypevr Macro tcflag_t TOSTOPIf this bit is set and the system supports job control, then@code{SIGTTOU} signals are generated by background processes thatattempt to write to the terminal. @xref{Access to the Terminal}.@end deftypevrThe following bits are BSD extensions; they exist only in BSD systemsand the GNU system. @comment termios.h@comment BSD@deftypevr Macro tcflag_t ALTWERASEThis bit determines how far the WERASE character should erase. TheWERASE character erases back to the beginning of a word; the questionis, where do words begin?If this bit is clear, then the beginning of a word is a nonwhitespacecharacter following a whitespace character. If the bit is set, then thebeginning of a word is an alphanumeric character or underscore followinga character which is none of those.@xref{Editing Characters}, for more information about the WERASE character.@end deftypevr@comment termios.h@comment BSD@deftypevr Macro tcflag_t FLUSHOThis is the bit that toggles when the user types the DISCARD character.While this bit is set, all output is discarded. @xref{Other Special}.@end deftypevr@comment termios.h@comment BSD@deftypevr Macro tcflag_t NOKERNINFOSetting this bit disables handling of the STATUS character.@xref{Other Special}.@end deftypevr@comment termios.h@comment BSD@deftypevr Macro tcflag_t PENDINIf this bit is set, it indicates that there is a line of input thatneeds to be reprinted. Typing the REPRINT character sets this bit; thebit remains set until reprinting is finished. @xref{Editing Characters}.@end deftypevr@c EXTPROC is too obscure to document now. --roland@node Line Speed@subsection Line Speed@cindex line speed@cindex baud rate@cindex terminal line speed@cindex terminal line speedThe terminal line speed tells the computer how fast to read and writedata on the terminal.If the terminal is connected to a real serial line, the terminal speedyou specify actually controls the line---if it doesn't match theterminal's own idea of the speed, communication does not work. Realserial ports accept only certain standard speeds. Also, particularhardware may not support even all the standard speeds. Specifying aspeed of zero hangs up a dialup connection and turns off modem controlsignals.If the terminal is not a real serial line (for example, if it is anetwork connection), then the line speed won't really affect datatransmission speed, but some programs will use it to determine theamount of padding needed. It's best to specify a line speed value thatmatches the actual speed of the actual terminal, but you can safelyexperiment with different values to vary the amount of padding.There are actually two line speeds for each terminal, one for input andone for output. You can set them independently, but most oftenterminals use the same speed for both directions.The speed values are stored in the @code{struct termios} structure, butdon't try to access them in the @code{struct termios} structuredirectly. Instead, you should use the following functions to read andstore them:@comment termios.h@comment POSIX.1@deftypefun speed_t cfgetospeed (const struct termios *@var{termios-p})This function returns the output line speed stored in the structure@code{*@var{termios-p}}.@end deftypefun@comment termios.h@comment POSIX.1@deftypefun speed_t cfgetispeed (const struct termios *@var{termios-p})This function returns the input line speed stored in the structure@code{*@var{termios-p}}.@end deftypefun@comment termios.h@comment POSIX.1@deftypefun int cfsetospeed (struct termios *@var{termios-p}, speed_t @var{speed})This function stores @var{speed} in @code{*@var{termios-p}} as the outputspeed. The normal return value is @code{0}; a value of @code{-1}indicates an error. If @var{speed} is not a speed, @code{cfsetospeed}returns @code{-1}.@end deftypefun@comment termios.h@comment POSIX.1@deftypefun int cfsetispeed (struct termios *@var{termios-p}, speed_t @var{speed})This function stores @var{speed} in @code{*@var{termios-p}} as the inputspeed. The normal return value is @code{0}; a value of @code{-1}indicates an error. If @var{speed} is not a speed, @code{cfsetospeed}returns @code{-1}.@end deftypefun@comment termios.h@comment BSD@deftypefun int cfsetspeed (struct termios *@var{termios-p}, speed_t @var{speed})This function stores @var{speed} in @code{*@var{termios-p}} as both theinput and output speeds. The normal return value is @code{0}; a valueof @code{-1} indicates an error. If @var{speed} is not a speed,@code{cfsetspeed} returns @code{-1}. This function is an extension in4.4 BSD.@end deftypefun@comment termios.h@comment POSIX.1@deftp {Data Type} speed_tThe @code{speed_t} type is an unsigned integer data type used torepresent line speeds.@end deftpThe functions @code{cfsetospeed} and @code{cfsetispeed} report errorsonly for speed values that the system simply cannot handle. If youspecify a speed value that is basically acceptable, then those functionswill succeed. But they do not check that a particular hardware devicecan actually support the specified speeds---in fact, they don't knowwhich device you plan to set the speed for. If you use @code{tcsetattr}to set the speed of a particular device to a value that it cannothandle, @code{tcsetattr} returns @code{-1}.@strong{Portability note:} In the GNU library, the functions aboveaccept speeds measured in bits per second as input, and return speedvalues measured in bits per second. Other libraries require speeds tobe indicated by special codes. For POSIX.1 portability, you must useone of the following symbols to represent the speed; their precisenumeric values are system-dependent, but each name has a fixed meaning:@code{B110} stands for 110 bps, @code{B300} for 300 bps, and so on.There is no portable way to represent any speed but these, but these arethe only speeds that typical serial lines can support.@comment termios.h@comment POSIX.1@vindex B0@comment termios.h@comment POSIX.1@vindex B50@comment termios.h@comment POSIX.1@vindex B75@comment termios.h@comment POSIX.1@vindex B110@comment termios.h@comment POSIX.1@vindex B134@comment termios.h@comment POSIX.1@vindex B150@comment termios.h@comment POSIX.1@vindex B200@comment termios.h@comment POSIX.1@vindex B300
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -