如何让rxconsole 找不到层映射到resources

7.5.&Configuring the Linux Console
配置 Linux 控制台
本节讨论如何配置 console 和 consolelog 启动脚本, 设置键盘映射, 控制台字体和控制台内核日志级别。 如果您不使用非 ASCII 字符 (如版本符号, 英镑和欧元符号)
并且是美式键盘, 可以跳过这一节。
没有配置文件, console 初始化脚本不会做任何事情。
console 和
consolelog 脚本读取 /etc/sysconfig/console文件作为配置信息, 决定使用哪种键盘映射和屏幕字体。 各种特定语言的 HOWTOs 也能帮助您完成配置,请参考 .
如果您还有疑问, 请查看 /lib/kbd目录中的可用键盘映射和屏幕字体。 阅读 loadkeys(1) 和 setfont(8)手册页来确定这些程序的正确参数。
/etc/sysconfig/console 文件中应该包含这样格式的行: VARIABLE="value"。 下列变量是公认的:
该变量指定内核信息日志级别,这些信息发送到由dmesg
设置的控制台。可用的级别是从 &1& (没有信息) 到 &8&。默认级别是 &7&。
这个变量指定 loadkeys
程序的参数。典型的像键盘映射的名字
&es&。 如果不设定参数,bootscript 就不会运行 loadkeys
程序, 而是使用默认的内核键盘映射。
KEYMAP_CORRECTIONS
这个变量 (很少用到) 是被用来指定再次调用loadkeys 程序的。
如果提供的键盘映射不是很领人满意,并要做一些小的调整时,这个参数很有用。例如, 我们要把一些正常情况下不会出现的欧洲字符包含到在键盘映射中,
那我们就需要把这个参数设为 &euro2&。
这个变量是为 setfont 程序设定的。通常情况下它要包括font的名字, &-m&,
以及需要载入的应用字符映射名。例如,为了加载 &lat1-16& 字体和 &8859-1& 应用字符映射 (因为它适用于USA), 就把这个变量设置为 &lat1-16 -m 8859-1&。在 UTF-8 模式,内核使用应用字符映射将键盘映射中ĭ键组成的代码转变成
UTF-8,因而,使用 &-m& 参数是为了设置键盘映射中的组合键码编码。
为了把控制台改为UTF-8模式,要把此变量设置成 &1&, &yes& 或 &true&。在 UTF-8 的 locale下比较有用,其他情况都是有害的。
LEGACY_CHARSET
对于很多键盘布局,在Kbd软件包中不存在Unicode键盘映射。 如果这个变量被设置 为一个有效的非 UTF-8 编码的键盘映射,console 启动脚本会把它转换成 UTF-8 编码。
一些例子:
对于一个非 Unicode 的安装,只有 KEYMAP 和 FONT 变量是必需的。 例如, 在波兰语安装中,
应当使用:
cat & /etc/sysconfig/console && "EOF"
# Begin /etc/sysconfig/console
KEYMAP="pl2"
FONT="lat2a-16 -m 8859-2"
# End /etc/sysconfig/console
正如上面的方法, 有时需要对提供的键盘映射进行稍微的调整。 下面的例子在德国键盘映射中添加欧元符号 :
cat & /etc/sysconfig/console && "EOF"
# Begin /etc/sysconfig/console
KEYMAP="de-latin1"
KEYMAP_CORRECTIONS="euro2"
FONT="lat0-16 -m 8859-15"
# End /etc/sysconfig/console
下面是一个保加利亚的 Unicode 例子,存在一个 UTF-8 键盘映射:
cat & /etc/sysconfig/console && "EOF"
# Begin /etc/sysconfig/console
UNICODE="1"
KEYMAP="bg_bds-utf8"
FONT="LatArCyrHeb-16"
# End /etc/sysconfig/console
由于在前面的例子中使用&#2 字符 的 LatArCyrHeb-16 字体, 在 Linux 控制台上不能再显示明亮的颜色, 除非使用
framebuffer。如果你想不利用 framebuffer 来显示明亮的颜色,并使用本语种字符,像下面的说明,通过使用相应语言&#3-字符字体, 这仍然是可能实现的:
cat & /etc/sysconfig/console && "EOF"
# Begin /etc/sysconfig/console
UNICODE="1"
KEYMAP="bg_bds-utf8"
FONT="cyr-sun16"
# End /etc/sysconfig/console
下面的例子解释了键盘映射从 ISO-8859-15 到 UTF-8 的自动转变和在 Unicode 模式下打开无效键:
cat & /etc/sysconfig/console && "EOF"
# Begin /etc/sysconfig/console
UNICODE="1"
KEYMAP="de-latin1"
KEYMAP_CORRECTIONS="euro2"
LEGACY_CHARSET="iso-8859-15"
FONT="LatArCyrHeb-16 -m 8859-15"
# End /etc/sysconfig/console
一些键盘映射有无效键 (也就是说, 这些键自己不产生字符, 但是会在下面一个键产生的字符上加上重音符号) 或定义组成规则 (例如:在默认的键盘映射中
&按 Ctrl+. A E 会得到 &AE& )。 Linux-2.6.32.8
解释的键盘映射中的无效键和组成规则只有在源字符组成的并不是字节时才是正确的。 这个缺陷不影响对欧洲语言的键盘映射,
因为那里的重音符号被加入到无重音的ASCII码, 或把两个 ASCII 码组合在一起。然而,在 UTF-8
模式, 这是个问题, 例如,对于希腊语,有时需要把重音符号加到字母 &alpha&上。 解决办法是,或者不使用
UTF-8, 或者安装 X window 系统,它在输入处理中没有这个限制。
对于中文,日文,韩文和其他一些语言,控制台不能被配置成显示所需的字符。 需要这些语言的用户, 应该安装 X
Window System, 它包含所需字符集的字体, 以及合适的输入法 (例如,SCIM 支持很多语言)。
注意
/etc/sysconfig/console 文件只能控制 Linux 文本控制台定位。在 X Windows、 SSH 会话以及串口控制台中,设置键盘布局和终端字体是没有用的。
在这种情况下,上面列出的最后两项中提到的限制是没用的。中国领先的IT技术网站
51CTO旗下网站
console_codes 中文man页面
Linux控制台实现了VT102和ECMA-48/ISO 6429/ANSI X3.64终端控制的子集, 这个子集很庞大,当然还有Linux自己私有的控制序列,以改变颜色配置,字符集映像,等等.在下面将要给出的表格中,第二列为指定的功能给出了ECMA-48 或者DEC助记符(如果是后者会在前面加有DEC前缀).没有给出助记符的序列既不是ECMA-48也不是VT102字符.
作者:佚名来源:CMPP.net| 10:28
控制终端代码 - Linux 控制终端转义和控制序列
DESCRIPTION 描述
Linux控制台实现了VT102和ECMA-48/ISO 6429/ANSI X3.64终端控制的子集, 这个子集很庞大,当然还有Linux自己私有的控制序列,以改变颜色配置,字符集映像,等等.在下面将要给出的表格中,第二列为指定的功能给出了ECMA-48 或者DEC助记符(如果是后者会在前面加有DEC前缀).没有给出助记符的序列既不是ECMA-48也不是VT102字符.
在所有标准输出进程执行完毕,并且一个字符流被送到控制台驱动程序准备显示出来的时候,所发生的第一件事就是将进程使用的代码转换成显示使用的代码.
如果控制台工作于 UTF-8 模式,那么输入的字节会首先编码成16位的 Unicode 代码.如果不是UTF-8模式,那么每个字节会按照当前的字符映射表完成转换(转换成Unicode编码的值). 参看下面将要讨论的 CHARACTER SETS 一章. 在一般情况下,Unicode 代码被转换成为存储在视频存储器中的字体索引,这样对应的具体字符(字符存储在视频ROM中)就显示在屏幕上了. 注意使用 Unicode 编码允许我们同时使用 512 种不同的字体(和计算机硬件有关).
如果当前的 Unicode 代码是一个控制字符,或者系统目前正在处理一个转义序列,处理的方式有些特别.它不会被转换成字体索引,也不会直接显示在屏幕上.它可能控制光标的移动,或者实现其它控制功能.参看下面的 LINUX CONSOLE CONTROLS 一节所进行的讨论.
一般来说直接在程序中插入终端控制字符并不是很好.Linux 支持终端兼容的 terminfo(5) 数据库. 除了直接插入控制和转义序列,也可以使用象 ncurses(3), tput(1), 或者 reset(1). 这样的显示库或者工具.
LINUX CONSOLE CONTROLS Linux终端控制
这一段描述了所有在Linux控制台下使用的调用特殊功能的控制字符和转义序列(例如.任何不在当前光标处插入可见字符的序列).
Control characters 控制字符
当一个字符在通过字符映射表转换之前含有以下14个代码之一的时候表明它是一个控制字符. 00(NUL),07(BEL),08(BS),09(HT),0a(LF),0b(VT), 0c(FF),0d(CR),0e(SO),0f(SI),18(CAN),1a(SUB), 1b(ESC),7f(DEL). 我们可以通过设置 `显示控制字符' 模式(见下文)以允许07,09,0b, 18,1a,7f 像普通字符一样显示在屏幕上.另一方面,在UTF-8模式下所有位于 00-1f之间的代码都被认为是控制字符,而不管是否处于 `显示控制字符'模式.
一个控制字符会立刻生效,然后被丢弃(即使是在转义序列中间), 之后转义序列才继续处理下一个字符. (在任何情况下,ESC都表示一个新的转义序列的开始,可能导致 前一个序列的非正常终止,CAN和SUB 终止任何转义序列.) 可识别的控制字符是BEL,BS,HT,LF,VT,FF,CR,SO,SI,CAN, SUB,ESC,DEL,CSI.他们的功能如下.:
BEL(0x07,^G)铃声; BS(0x08,^H)后退一格(在行首不起作用); HT(0x09,^I)跳至下一个制表位.如果后面已没有制表位则跳至行尾; LF(0x0A,^J),VT(0x0B,^K),FF(0x0C,^L)三者都表示换行; CR(0x0D,^M)回车并换行; SO(0x0E,^N)激活 G1 字符集, 如果设置了 LF/NL(新行模式)还要加上回车换行; SI(0x0F,^O)激活 G0 字符集; CAN(0x18,^X),SUB(0x1A,^Z)两者都表示中断转义序列; ESC(0x1B,^[)开始一个新的转义序列; DEL(0x7F)忽略; CSI(0x9B)等同于 ESC [;
ESC- but not CSI-sequences 非控制转义序列
设置当前列为制表位.
翻转换行(Reverse linefeed).
DEC 私有定义.内核将其解释为
VT102字符,返回字符ESC [ ? 6 c.
存储当前状态(光标坐标,
属性,字符集).
恢复上一次储存的设置
控制序列介绍
开始一个字符集选择序列
&&&选择默认字符集(ISO 646 / ISO 8859-1)
&&&选择 UTF-8
&&&选择 UTF-8(已不用)
DEC 屏幕校准测试 - 以E's填充屏幕.
开始一个 G0 字符集定义序列
&&&选择默认字符集(ISO 8859-1 mapping)
&&&选择 vt100 图形映射
&&&选择空映射 - 直接访问字符ROM
&&&选择用户映射 - 由程序mapscrn(8)
开始一个 G1 字符集定义
(后面跟 B,0,U,K,同上).
设置数字小键盘模式
设置程序键盘模式
(是perating system command的缩写)
ESC ] P nrrggbb: 设置调色板,后面紧跟7个
十六进制数,再跟一个 P :-(.
这里 n 是颜色(0-16),而 rrggbb 表示
红/绿/蓝 值(0-255).
ESC ] R: 重置调色板
ECMA-48 CSI sequence ECMA-48 CSI 序列
CSI(或者 ESC [)后面跟的参数序列大部分是NPAR(16), 就是由分号隔开的十进制数.空参数或缺少的参数以0处理. 可以用一个问号代替参数序列.
在任何情况下,系统读取 CSI [(或者 ESC [ [)后的单个字符, 而忽略整个序列.(用于忽略回显功能键.)
CSI 序列的动作由其最后一个字符决定.
用#符号指示空格.
光标上移到#标识的行.
光标下移到#标识的行.
光标右移到#标识的列.
光标左移到#标识的列.
将光标下移到#指示的行的第一列.
将光标上移到#指示的行的第一列.
光标移动到当前行的指定列.
光标移动到指定行和列(以1行1列为参照).
删除(默认从当前光标处到行尾的)内容.
ESC [ 1 J: 删除从开始到光标处的内容.
ESC [ 2 J: 清空整个屏幕.
删除行(默认从当前光标处到结尾).
ESC [ 1 K: 删除从行首到当前光标处的内容.
ESC [ 2 K: 删除整行.
在空行插入#.
删除#标记的行.
删除当前行中#标记的字符.
删除当前行中#标记的单词.
光标移动到#标记的右边.
以`I am a VT102'应答 ESC [ ? 6 c:
光标移动到当前列指定行
光标移动到#标记的下一行.
光标移动到指定的行和列.
没有参数: 清除当前位置的制表站.
ESC [ 3 g: 删除所有制表站.
设置模式(见下文).
重置模式(见下文).
设置属性(见下文).
状态报告(见下文).
设置键盘指示灯.
ESC [ 0 q: 熄灭所有指示灯
ESC [ 1 q: 点亮 Scroll Lock 灯
ESC [ 2 q: 点亮 Num Lock 灯
ESC [ 3 q: 点亮 Caps Lock 灯
设置滚动范围; 参数为首行和末行.
存储光标位置.
恢复光标位置.
光标移动到当前行指定列.
ECMA-48 Set Graphics Rendition 设置图形属性
ECMA-48 SGR 序列 ESC [ &parameters& m 设置显示属性. 同样的序列可以设置一个或多个属性.
所有属性重设为默认值
设置亮度减半(用一种颜色模拟另一种颜色)
设置底纹(用一种颜色模拟另一种颜色)
(用于模拟的颜色由using ESC ] ...设置)
设置反转视频(reverse video)
重设选定映像,显示控制标记,
反转元素标记.
选择空映像,设置显示控制标记,
重设反转标记.
选择空映像,设置显示控制标记,
重设反转标记.(在完成映像表转
换之前反转标记引起每一字节的
高位反转.)
设置正常亮度(和 ECMA-48 不兼容)
设置正常亮度
关闭下划线
反转视频关闭
孔雀蓝前景
打开下划线,设置默认前景色
关闭下划线,设置默认前景色
孔雀蓝背景
设置默认背景色
ECMA-48 Mode Switches ECMA-48模式选择
ESC [ 3 h DECCRM(默认关闭): 显示控制字符. ESC [ 4 h DECIM(默认关闭): 设置插入模式. ESC [ 20 h LF/NL(默认关闭): 自动在CR后加上 LF,VT 或者 FF.
ECMA-48 状态报告命令.
ESC [ 5 n 设备状态报告(DSR): 以 ESC [ 0 n 应答(终端准备好). ESC [ 6 n 光标位置报告(CPR): 以ESC [ y ; x R 应答, 这里 x,y 指光标位置.
DEC Private Mode(DECSET/DECRST)sequences DEC私有模式序列.
这里给出的序列在 ECMA-48中没有描述.我们列出了设置模式序列; 用l替换最后一个h就是重设模式序列.
ESC [ ? 1 h DECCKM(默认关闭): 打开时光标键送出 ESC O 前缀, 而不是 ESC [. ESC [ ? 3 h DECCOLM(默认 = 80 行): 交替选择 80/132 行模式.当原显示模式不足以满足要求的时候,象 resizecons(8) 这样的用户程序会改变终端显示卡的硬件注册. ESC [ ? 5 h DECSCNM(默认关闭): 设置视频反转模式. ESC [ ? 6 h DECOM(默认关闭): 打开时,光标位置用相对于滚动条左上角的位置表示. ESC [ ? 7 h DECAWM(默认关闭): 打开自动换行.在这种模式下,一行中超过80列的字符将自动换行(在DECCOLM打开时是132列). ESC [ ? 8 h DECARM(默认关闭): 打开键盘自动重复. ESC [ ? 9 h X10 鼠标报告(默认关闭): 设置报告模式 1(或者重设为 0)- 见下文. ESC [ ? 25 h DECCM(默认打开): 设置光标可见. ESC [ ? 1000 h X11 鼠标报告(默认关闭): 设置报告模式 2(或者重设为 0)- 见下文.
Linux Console Private CSI Sequences Linux控制台私有控制序列
下面的序列既不属于 ECMA-48 字符也不属于 VT102.它们只在 Linux控制台上使用.颜色采用 SGR 参数: 0 = 黑色,1 = 红色,2 = 绿色,3 =褐色 ,4 = 蓝色,5 = 洋红,6 = 孔雀蓝,7 = 白色.
ESC [ 1 ; n ]
设置下划线颜色为 n
ESC [ 2 ; n ]
设置暗色为 n
设置当前颜色对为默认属性.
ESC [ 9 ; n ]
设置屏幕空白超时为 n 分钟.
ESC [ 10 ; n ]
设置机箱喇叭鸣叫频率,单位: Hz.
ESC [ 11 ; n ]
设置机箱喇叭鸣叫持续时间,单位:微秒.
ESC [ 12 ; n ]
设置指定控制台前台运行.
ESC [ 13 ]
设置指定控制台黑色
ESC [ 14 ; n ]
设置 VESA 关闭间隔,单位: 分钟.
CHARACTER SETS 字符集
内核可以完成以下四种字符转换,使字符能在屏幕上显示. a)Latin1 -& PC,b)VT100 graphics -& PC,c)PC -& PC, d)user-defined(用户自定义).
有两种字符集设置,以 G0 和 G1定义,当前字符集必定是其中之一.(初始化为G0.)键入 ^N 使 G1 成为当前字符集,键入 ^O 使 G0 成为当前设置.
变量 G0 and G1 指向字符映射关系表,并且这种指向关系可以由用户改变. 系统初始化时它们分别指向表 a)and b). 序列 ESC( B ,ESC( 0 ,ESC( U 和 ESC( K 分别使 G0 指向字符映射表
&a),b),c)和&d). 序列 ESC )B ,ESC )0 ,ESC )U 和 ESC )K 分别使 G1 指向字符映射表 a),b),c)和 d).
序列 ESC c 重置一个终端,当屏幕显示出现混乱时可以使用这个序列. 另一个序列 &echo ^V^O& 仅仅将G0设为当前字符集,但并不保证 G0 指向映射表 a). 有的Linux发行版中提供一个叫做 reset(1) 的程序用来送出序列 &echo ^[c&. 如果你的系统终端变量没有错误( rs1=\Ec), 那么使用&tput reset&也可以达到同样效果.
用户自定义映射表可以用程序 mapscrn(8). 定义.这个程序工作时会将送入的字符c通过关系式s=map[c]映射到字符s然后送入显存.字符s所对应的位图放在字符ROM里面,可以使用程序 setfont(8).
MOUSE TRACKING 鼠标轨迹
鼠标轨迹工具可以返回与 xterm 兼容的鼠标状态报告.因为控制台驱动没有办法知道鼠标类型,只有当虚拟终端驱动接收到鼠标输入输出消息更新时才会将这些报告返回给控制台输入流..这些鼠标输入输出消息由 gpm(8) 守护进程产生.
所有鼠标轨迹转义序列参数由xterm 编码成象value+040 这样的单一字符形式的数字参数.比如,`!' 编码成 1.屏幕坐标系统以'1'为基准.
X10 兼容模式在鼠标键按下时将按下的键和鼠标位置编码后送出. ESC [ ? 9 h 允许这一动作,ESC [ ? 9 l禁止这一动作. 有键按下时,xterm 送出ESC [ M bxy(6 个字符).这里 b 代表 键-1,而 x 和 y 是鼠标的 x 和 y 坐标.这和内核产生的序列相同.
常规的轨迹模式(Linux 2.0.24不再支持)在左右两键同时按下然后释放时送出转义序列.组合键编码也被送出.ESC [ ? 1000 h 允许这个动作而ESC [ 1000 l 禁止这个动作.当有键按下或者释放时, xterm 送出 ESC [ M bxy.b 的低两位对按键信息编码: 0=鼠标键1按下,1=鼠标键2 按下,2=鼠标键3 按下,3=释放. 高位编码代表组合键,和上述编码一起送出: 4=Shift,8=Meta(Alt),16=Control(Ctrl).x 和y为发生鼠标事件的x和y坐标.以左上角为(1,1).
和其它终端的比较
我们已经讨论了几种终端类型,比如Linux 控制台.这类终端称为 &VT100兼容&的终端.这里我们再介绍其他两种重要的终端类型: DEC VT102 和 xterm(1) 以及他们和Linux控制终端的区别.
Control-character handling 控制字符处理
vt102 也使用以下控制序列:
NUL(0x00)忽略; ENQ(0x05)触发应答消息; DC1(0x11,^Q,XON)继续传送; DC3(0x13,^S,XOFF)使 vt100 忽略(并停止传送) 除 XOFF and XON 以外的一切字符.
VT100-like DC1/DC3 进程可以由 tty 驱动激活.
程序 xterm (在 vt100 模式 中)使用控制序列 BEL,BS,HT,LF,VT,FF,CR,SO,SI,ESC.
Escape sequences 转义序列
VT100 控制台序列不完全支持Linux控制台序列:
仅仅为下一个字符选择 G2 字符集
(Single shift 2).
仅仅为下一个字符选择 G2 字符集
(Single shift 2).
设备控制字符,由ESC \ 终止
(Device control string).
字符串开始.
(Start of string)
私有消息,由 ESC \ 终结
(Privacy message)
字符串终结
(String terminator)
指定 G2 字符集
指定 G3 字符集
程序 xterm (vt100 模式)承认 ESC c,ESC # 8,ESC &,ESC =, ESC D,ESC E,ESC H,ESC M,ESC N,ESC O,ESC P ...ESC , ESC Z(以 [ ? 1 ; 2 c,`I am a vt100 with advanced video option'回应) 以及 ESC ^ ...ESC ,意义同上. 接受 ESC(,ESC ),ESC *,ESC + 后跟 0,A,B 的字符序列,分别代表的DEC 特殊字符,画线设置,UK 和 US ASCII码. 接受 ESC ] 作为特定资源设置:
ESC ] 0 ; txt BEL
将图标名和窗口标题设为文本.
ESC ] 1 ; txt BEL
将图标名设为文本.
ESC ] 2 ; txt BEL
将窗口名设为文本.
ESC ] 4 6 ; name BEL
改变日志文件名(一般
由编译时选项禁止)
ESC ] 5 0 ; fn BEL
字体设置为 fn.
以下字符的含义略有不同::
ESC 7 DECSC
存储光标位置
ESC 8 DECRC
恢复光标位置
它还接受以下序列:
光标移动到屏幕左下角(由
hpLowerleftBugCompat 打开这项设置)
内存锁定(对于 HP 终端).
锁定光标以上的内存.
内存解锁(对于 HP 终端).
调用 G2 字符集.
调用 G3 字符集.
以GR调用 G3 字符集.
在xterm上看不到效果.
以GR调用 G3 字符集.
在xterm上看不到效果.
以GR调用 G3 字符集.
在xterm上看不到效果.
它不识别 ESC % ...
CSI Sequences CSI 序列
程序 xterm (直到 XFree86 3.1.2G)不能识别闪烁或者不可见模式的 SGR值.X11R6 也不能识别以 SGRs 为参数设置的色彩. xterm 可以识别其他的 ECMA-48 CSI 序列,只要Linux可以识别. 反之亦然.
xterm 可以识别以上列出的所有 DEC 私有序列,但是不包括 Linux 私有模式序列. 在 Xterm Control Sequences 中有关于 xterm 的私有模式序列的讨论.
document by Edward Moy and Stephen Gildea,available with the X distribution.
在版本为 2.0.23 的内核中,CSI 序列的识别有些问题: 不能识别转义序列中的NUL.
console(4), console_ioctl(4), charsets(7)
console_codes - Linux console escape and control sequences
DESCRIPTION
The Linux console implements a large subset of the VT102 and ECMA-48/ISO 6429/ANSI X3.64 terminal controls, plus certain private-mode sequences for changing the color palette, character-set mapping, etc. In the tabular descriptions below, the second column gives ECMA-48 or DEC mnemonics (the latter if prefixed with DEC) for the given function. Sequences without a mnemonic are neither ECMA-48 nor VT102.
After all the normal output processing has been done, and a stream of characters arrives at the console driver for actual printing, the first thing that happens is a translation from the code used for processing to the code used for printing.
If the console is in UTF-8 mode, then the incoming bytes are first assembled into 16-bit Unicode codes. Otherwise each byte is transformed according to the current mapping table (which translates it to a Unicode value). See the CHARACTER SETS section below for discussion.
In the normal case, the Unicode value is converted to a font index, and this is stored in video memory, so that the corresponding glyph (as found in video ROM) appears on the screen. Note that the use of Unicode (and the design of the PC hardware) allows us to use 512 different glyphs simultaneously.
If the current Unicode value is a control character, or we are currently processing an escape sequence, the value will treated specially. Instead of being turned into a font index and rendered as a glyph, it may trigger cursor movement or other control functions. See the LINUX CONSOLE CONTROLS section below for discussion.
It is generally not good practice to hard-wire terminal controls into programs. Linux supports a terminfo(5) database of terminal capabilities. Rather than emitting console escape sequences by hand, you will almost always want to use a terminfo-aware screen library or utility such as ncurses(3), tput(1), or reset(1).
LINUX CONSOLE CONTROLS
This section describes all the control characters and escape sequences that invoke special functions (i.e. anything other than writing a glyph at the current cursor location) on the Linux console.
Control characters
A character is a control character if (before transformation according to the mapping table) it has one of the 14 codes 00 (NUL), 07 (BEL), 08 (BS), 09 (HT), 0a (LF), 0b (VT), 0c (FF), 0d (CR), 0e (SO), 0f (SI), 18 (CAN), 1a (SUB), 1b (ESC), 7f (DEL). One can set a `display control characters' mode (see below), and allow 07, 09, 0b, 18, 1a, 7f to be displayed as glyphs. On the other hand, in UTF-8 mode all codes 00-1f are regarded as control characters, regardless of any `display control characters' mode.
If we have a control character, it is acted upon immediately and then discarded (even in the middle of an escape sequence) and the escape sequence continues with the next character. (However, ESC starts a new escape sequence, possibly aborting a previous unfinished one, and CAN and SUB abort any escape sequence.) The recognized control characters are BEL, BS, HT, LF, VT, FF, CR, SO, SI, CAN, SUB, ESC, DEL, CSI. They do what one would expect:
BEL (0x07, ^G) BS (0x08, ^H) backspaces one column (but not past the beginning of the line); HT (0x09, ^I) goes to the next tab stop or to the end of the line if there is LF (0x0A, ^J), VT (0x0B, ^K) and FF (0x0C, ^L) CR (0x0D, ^M) giv SO (0x0E, ^N) activates the G1 character set, and if LF/NL (new line mode) is set al SI (0x0F, ^O) activates the G0 CAN (0x18, ^X) and SUB (0x1A, ^Z) interr ESC (0x1B, ^[) start DEL (0x7F) CSI (0x9B) is equivalent to ESC [.
ESC- but not CSI-sequences
Set tab stop at current column.
Reverse linefeed.
DEC private identification. The kernel
returns the string ESC [ ? 6 c, claiming
that it is a VT102.
Save current state (cursor coordinates,
attributes, character sets pointed at by G0, G1).
Restore state most recently saved by ESC 7.
Control sequence introducer
Start sequence selecting character set
&&&Select default (ISO 646 / ISO 8859-1)
&&&Select UTF-8
&&&Select UTF-8 (obsolete)
DEC screen alignment test - fill screen with E's.
Start sequence defining G0 character set
&&&Select default (ISO 8859-1 mapping)
&&&Select vt100 graphics mapping
&&&Select null mapping - straight to character ROM
&&&Select user mapping - the map that is loaded by
&&&the utility mapscrn(8).
Start sequence defining G1
(followed by one of B, 0, U, K, as above).
Set numeric keypad mode
Set application keypad mode
(Should be: Operating system command)
ESC ] P nrrggbb: set palette, with parameter
given in 7 hexadecimal digits after the final P :-(.
Here n is the color (0-15), and rrggbb indicates
the red/green/blue values (0-255).
ESC ] R: reset palette
ECMA-48 CSI sequences
CSI (or ESC [) is followed by a sequence of parameters, at most NPAR (16), that are decimal numbers separated by semicolons. An empty or absent parameter is taken to be 0. The sequence of parameters may be preceded by a single question mark.
However, after CSI [ (or ESC [ [) a single character is read and this entire sequence is ignored. (The idea is to ignore an echoed function key.)
The action of a CSI sequence is determined by its final character.
Insert the indicated # of blank characters.
Move cursor up the indicated # of rows.
Move cursor down the indicated # of rows.
Move cursor right the indicated # of columns.
Move cursor left the indicated # of columns.
Move cursor down the indicated # of rows, to column 1.
Move cursor up the indicated # of rows, to column 1.
Move cursor to indicated column in current row.
Move cursor to the indicated row, column (origin at 1,1).
Erase display (default: from cursor to end of display).
ESC [ 1 J: erase from start to cursor.
ESC [ 2 J: erase whole display.
Erase line (default: from cursor to end of line).
ESC [ 1 K: erase from start of line to cursor.
ESC [ 2 K: erase whole line.
Insert the indicated # of blank lines.
Delete the indicated # of lines.
Delete the indicated # of characters on the current line.
Erase the indicated # of characters on the current line.
Move cursor right the indicated # of columns.
Answer ESC [ ? 6 c: `I am a VT102'.
Move cursor to the indicated row, current column.
Move cursor down the indicated # of rows.
Move cursor to the indicated row, column.
Without parameter: clear tab stop at the current position.
ESC [ 3 g: delete all tab stops.
Set Mode (see below).
Reset Mode (see below).
Set attributes (see below).
Status report (see below).
Set keyboard LEDs.
ESC [ 0 q: clear all LEDs
ESC [ 1 q: set Scroll Lock LED
ESC [ 2 q: set Num Lock LED
ESC [ 3 q: set Caps Lock LED
S parameters are top and bottom row.
Save cursor location.
Restore cursor location.
Move cursor to indicated column in current row.
ECMA-48 Set Graphics Rendition
The ECMA-48 SGR sequence ESC [ &parameters& m sets display attributes. Several attributes can be set in the same sequence.
reset all attributes to their defaults
set half-bright (simulated with color on a color display)
set underscore (simulated with color on a color display)
(the colors used to simulate dim or underline are set
using ESC ] ...)
set reverse video
reset selected mapping, display control flag,
and toggle meta flag.
select null mapping, set display control flag,
reset toggle meta flag.
select null mapping, set display control flag,
set toggle meta flag. (The toggle meta flag
causes the high bit of a byte to be toggled
before the mapping table translation is done.)
set normal intensity (this is not compatible with ECMA-48)
set normal intensity
underline off
reverse video off
set black foreground
set red foreground
set green foreground
set brown foreground
set blue foreground
set magenta foreground
set cyan foreground
set white foreground
set underscore on, set default foreground color
set underscore off, set default foreground color
set black background
set red background
set green background
set brown background
set blue background
set magenta background
set cyan background
set white background
set default background color
ECMA-48 Mode Switches
ESC [ 3 h DECCRM (default off): Display control chars. ESC [ 4 h DECIM (default off): Set insert mode. ESC [ 20 h LF/NL (default off): Automatically follow echo of LF, VT or FF with CR.
ECMA-48 Status Report Commands
ESC [ 5 n Device status report (DSR): Answer is ESC [ 0 n (Terminal OK). ESC [ 6 n Cursor position report (CPR): Answer is ESC [ y ; x R, where x,y is the cursor location.
DEC Private Mode (DECSET/DECRST) sequences.
These are not described in ECMA-48. We list the Set M the Reset Mode sequences are obtained by replacing the final `h' by `l'.
ESC [ ? 1 h DECCKM (default off): When set, the cursor keys send an ESC O prefix, rather than ESC [. ESC [ ? 3 h DECCOLM (default off = 80 columns): 80/132 col mode switch. The driver sources note that this al some user-mode utility such as resizecons(8) has to change the hardware registers on the console video card. ESC [ ? 5 h DECSCNM (default off): Set reverse-video mode. ESC [ ? 6 h DECOM (default off): When set, cursor addressing is relative to the upper left corner of the scrolling region. ESC [ ? 7 h DECAWM (default on): Set autowrap on. In this mode, a graphic character emitted after column 80 (or column 132 of DECCOLM is on) forces a wrap to the beginning of the following line first. ESC [ ? 8 h DECARM (default on): Set keyboard autorepreat on. ESC [ ? 9 h X10 Mouse Reporting (default off): Set reporting mode to 1 (or reset to 0) - see below. ESC [ ? 25 h DECCM (default on): Make cursor visible. ESC [ ? 1000 h X11 Mouse Reporting (default off): Set reporting mode to 2 (or reset to 0) - see below.
Linux Console Private CSI Sequences
The following sequences are neither ECMA-48 nor native VT102. They are native to the Linux console driver. Colors are in SGR parameters: 0 = black, 1 = red, 2 = green, 3 = brown, 4 = blue, 5 = magenta, 6 = cyan, 7 = white.
ESC [ 1 ; n ]
Set color n as the underline color
ESC [ 2 ; n ]
Set color n as the dim color
Make the current color pair the default attributes.
ESC [ 9 ; n ]
Set screen blank timeout to n minutes.
ESC [ 10 ; n ]
Set bell frequency in Hz.
ESC [ 11 ; n ]
Set bell duration in msec.
ESC [ 12 ; n ]
Bring specified console to the front.
ESC [ 13 ]
Unblank the screen.
ESC [ 14 ; n ]
Set the VESA powerdown interval in minutes.
CHARACTER SETS
The kernel knows about 4 translations of bytes into console-screen symbols. The four tables are: a) Latin1 -& PC, b) VT100 graphics -& PC, c) PC -& PC, d) user-defined.
There are two character sets, called G0 and G1, and one of them is the current character set. (Initially G0.) Typing ^N causes G1 to become current, ^O causes G0 to become current.
These variables G0 and G1 point at a translation table, and can be changed by the user. Initially they point at tables a) and b), respectively. The sequences ESC ( B and ESC ( 0 and ESC ( U and ESC ( K cause G0 to point at translation table a), b), c) and d), respectively. The sequences ESC ) B and ESC ) 0 and ESC ) U and ESC ) K cause G1 to point at translation table a), b), c) and d), respectively.
The sequence ESC c causes a terminal reset, which is what you want if the screen is all garbled. The oft-advised &echo ^V^O& will only make G0 current, but there is no guarantee that G0 points at table a). In some distributions there is a program reset(1) that just does &echo ^[c&. If your terminfo entry for the console is correct (and has an entry rs1=\Ec), then &tput reset& will also work.
The user-defined mapping table can be set using mapscrn(8). The result of the mapping is that if a symbol c is printed, the symbol s = map[c] is sent to the video memory. The bitmap that corresponds to s is found in the character ROM, and can be changed using setfont(8).
MOUSE TRACKING
The mouse tracking facility is intended to return xterm-compatible mouse status reports. Because the console driver has no way to know the device or type of the mouse, these reports are returned in the console input stream only when the virtual terminal driver receives a mouse update ioctl. These ioctls must be generated by a mouse-aware user-mode application such as the gpm(8) daemon.
Parameters for all mouse tracking escape sequences generated by xterm encode numeric parameters in a single character as value+040. For example, `!' is 1. The screen coordinate system is 1-based.
The X10 compatibility mode sends an escape sequence on button press encoding the location and the mouse button pressed. It is enabled by sending ESC [ ? 9 h and disabled with ESC [ ? 9 l. On button press, xterm sends ESC [ M bxy (6 characters). Here b is button-1, and x and y are the x and y coordinates of the mouse when the button was pressed. This is the same code the kernel also produces.
Normal tracking mode (not implemented in Linux 2.0.24) sends an escape sequence on both button press and release. Modifier information is also sent. It is enabled by sending ESC [ ? 1000 h and disabled with ESC [ 1000 l. On button press or release, xterm sends ESC [ M bxy. The low two bits of b encode button information: 0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release. The upper bits encode what modifiers were down when the button was pressed and are added together: 4=Shift, 8=Meta, 16=Control. Again x and y are the x and y coordinates of the mouse event. The upper left corner is (1,1).
COMPARISONS WITH OTHER TERMINALS
Many different terminal types are described, like the Linux console, as being `VT100-compatible'. Here we discuss differences vbetween the Linux console an the two most important others, the DEC VT102 and xterm(1).
Control-character handling
The vt102 also recognized the following control characters:
NUL (0x00) ENQ (0x05) triggered a DC1 (0x11, ^Q, XON)
DC3 (0x13, ^S, XOFF) caused vt100 to ignore (and stop transmitting) all codes except XOFF and XON.
VT100-like DC1/DC3 processing may be enabled by the tty driver.
The xterm program (in vt100 mode) recognizes the control characters BEL, BS, HT, LF, VT, FF, CR, SO, SI, ESC.
Escape sequences
VT100 console sequences not implemented on the Linux console:
Single shift 2. (Select G2 character set for the next
character only.)
Single shift 3. (Select G3 character set for the next
character only.)
Device control string (ended by ESC \)
Start of string.
Privacy message (ended by ESC \)
String terminator
Designate G2 character set
Designate G3 character set
The program xterm (in vt100 mode) recognizes ESC c, ESC # 8, ESC &, ESC =, ESC D, ESC E, ESC H, ESC M, ESC N, ESC O, ESC P ... ESC , ESC Z (it answers ESC [ ? 1 ; 2 c, `I am a vt100 with advanced video option') and ESC ^ ... ESC &with the same meanings as indicated above. It accepts ESC (, ESC ), ESC *, ESC + followed by 0, A, B for the DEC special character and line drawing set, UK, and USASCII, respectively. It accepts ESC ] for the setting of certain resources:
ESC ] 0 ; txt BEL
Set icon name and window title to txt.
ESC ] 1 ; txt BEL
Set icon name to txt.
ESC ] 2 ; txt BEL
Set window title to txt.
ESC ] 4 6 ; name BEL
Change log file to name (normally disabled
by a compile-time option)
ESC ] 5 0 ; fn BEL
Set font to fn.
It recognizes the following with slightly modified meaning:
ESC 7 DECSC
Save cursor
ESC 8 DECRC
Restore cursor
It also recognizes
Cursor to lower left corner of screen (if enabled by
the hpLowerleftBugCompat resource)
Memory lock (per HP terminals).
Locks memory above the cursor.
Memory unlock (per HP terminals).
Invoke the G2 character set.
Invoke the G3 character set.
Invoke the G3 character set as GR.
Has no visible effect in xterm.
Invoke the G2 character set as GR.
Has no visible effect in xterm.
Invoke the G1 character set as GR.
Has no visible effect in xterm.
It does not recognize ESC % ...
CSI Sequences
The xterm program (as of XFree86 3.1.2G) does not recognize the blink or invisible-mode SGRs. Stock X11R6 versions do not recognize the color-setting SGRs. All other ECMA-48 CSI sequences recognized by Linux are also recognized by xterm, and vice-versa.
The xterm program will recognize all of the DEC Private Mode sequences listed above, but none of the Linux private-mode sequences. For discussion of xterm's own private-mode sequences, refer to the Xterm Control Sequences document by Edward Moy and Stephen Gildea, available with the X distribution.
In 2.0.23, CSI is broken, and NUL is not ignored inside escape sequences.
console(4), console_ioctl(4), charsets(7)【责任编辑: TEL:(010)】
大家都在看猜你喜欢
头条热点热点头条热点
24H热文一周话题本月最赞
讲师:132823人学习过
讲师:270250人学习过
讲师:160376人学习过
精选博文论坛热帖下载排行
本书是为那些对Web开发感兴趣的读者而编写的。ASP(Active Server Pages)是微软公司在Web领域的又一次突破,它打破了以往只能由专业人员来...
订阅51CTO邮刊

我要回帖

更多关于 eclipse找不到console 的文章

 

随机推荐