fengsunping 发表于 2011-6-10 18:12:03

linux终端的一些问题

1 tcgetattr(STDIN_FILENO, &term)
这是将获得的终端信息保存到term结构中,这些终端信息是什么呢?
2 saveterm.c_cc='\b';
删除上一个还没有删掉的字符。这是删除'\b'转义字符码?
3 看这些终端信息,linux哪本书籍介绍了这一点,如果有PDF文档,请给一下链接,不甚感谢!

root 发表于 2011-6-10 18:50:34

Please see tcgetattr man page using "man tcgetattr". Or you can visit following url if you are not a *nix user.
http://www.kernel.org/doc/man-pages/online/pages/man3/termios.3.html

And if that stuffs is not enough yet, please see
0.Low-Level Terminal Interface part of "GNU C Library Reference Manual" (Section 17, especially 17.4)
   http://www.gnu.org/software/libc/manual/html_node/Low_002dLevel-Terminal-Interface.html#Low_002dLevel-Terminal-Interface
   
1.http://tldp.org/HOWTO/Text-Terminal-HOWTO.html

2.http://tldp.org/HOWTO/Serial-Programming-HOWTO/

3.http://tldp.org/HOWTO/Serial-HOWTO.html

According your post, I guest you are not a *nix user. Install Linux and use it if you want to be a real *nix programmer.

root 发表于 2011-6-10 19:21:20

From termios man page, you can get the information as follow:
================================This is a little piecefrom the termios.3 manual page=====================================================
The termios structure

       Many of the functions described here have a termios_p argument that is a
       pointer to a termios structure.This structure contains at least the
       following members:

         tcflag_t c_iflag;      /* input modes */
         tcflag_t c_oflag;      /* output modes */
         tcflag_t c_cflag;      /* control modes */
         tcflag_t c_lflag;      /* local modes */
         cc_t   c_cc;   /* control chars */

----------------------------------------------------------------------
       The c_cc array defines the special control characters.The symbolic indices
       (initial values) and meaning are:

       VERASE (0177, DEL, rubout, or 010, BS, Ctrl-H, or also #) Erase character.
            This erases the previous not-yet-erased character, but does not erase
            past EOF or beginning-of-line.Recognized when ICANON is set, and then
            not passed as input.
===================================================   End      ==========================================

'\b' is Character Escape Codes in C programming language. It actually is ASCII code BS (Backspace, numeric 0x08), and works as a
control sequences in VT100 series terminal device. When terminal received BS, it moves cursor to the left one character position,
unless it is at the left margin, in which case no action occurs.


http://en.wikipedia.org/wiki/ASCII
http://vt100.net/docs/tp83/appendixb.html

lusson 发表于 2011-6-10 19:25:37

\b是退格符。退一格

fengsunping 发表于 2011-6-17 10:59:24

谢谢各位。

root 发表于 2011-6-17 12:24:55

回复【4楼】fengsunping
谢谢各位。
-----------------------------------------------------------------------
       ./emotion/em021.gif       ./emotion/em021.gif           ./emotion/em021.gif
页: [1]
查看完整版本: linux终端的一些问题