Tutorials/ComposeKey/zh-cn: Difference between revisions

From KDE UserBase Wiki
m (Created page with "== 使用/设置 Compose 键 ==")
(Updating to match new version of source page)
 
(32 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages />
<languages />
== 使用/设置 Compose 键 ==


=== Introduction ===
<span id="Introduction"></span>
== 介绍 ==


The ''compose key'' is used to enter characters on the keyboard that are usually not available on the key caps. Such letters could be an "umlaut", a "macron" or accents on letters:
<div class="mw-translate-fuzzy">
''compose ''是键盘用来输入不在键帽上的字符。这样的字母可能是"元音字母变音符号(umlaut)""长音符号(macron)"或是字母标音(accents on letters):
* http://en.wikipedia.org/wiki/Umlaut_(diacritic)
* http://en.wikipedia.org/wiki/Umlaut_(diacritic)
* http://en.wikipedia.org/wiki/Macron
* http://zh.wikipedia.org/wiki/長音符號
</div>


These descriptions were tested on several ''Kubuntu Hardy Heron 8.04.1'' systems. Further information may be found in the ''[[Special:myLanguage/ComposeKey#Links and Further Information|Links and Further Information]]'' section below.
<div class="mw-translate-fuzzy">
教程已经在多个''Kubuntu Hardy Heron 8.04.1''系统上测试过了。进一步的信息可以在下列的''[[Special:myLanguage/ComposeKey#Links and Further Information|链接和进一步信息]]''小节找到。
</div>


The modifications will work with (almost) all applications, including the desktop environment, browsers, OpenOffice.org, as well as many console/text only applications.
<div class="mw-translate-fuzzy">
修改对(几乎)所有程序,包括桌面环境、浏览器、OpenOffice.org和众多终端/字符程序(console/text only applications)有效。
</div>


The following instructions will configure a ''compose'' key, which will be mapped to the ''right logo key'' (on most keyboards this logo is the ''Windows'' logo).
如下的教程会设定一个''<compose>键,'',同时映射到''<right logo>''键(多数键盘上这个logo 是''Windows'' logo)。


=== Console Configuration ===
== Plasma Workspace ==
 
[[Image:system-settings-compose.png|center|frameless|800px]]
 
* Start [[Special:myLanguage/System Settings|System Settings]]
 
* Select <menuchoice>Input Devices</menuchoice> then <menuchoice>Keyboard</menuchoice>
 
* Click the <menuchoice>Advanced</menuchoice> tab
 
* Click the box next to <menuchoice>Configure Keyboard Options</menuchoice> to enable changing keyboard options
 
* Click the {{Icon|breeze-go-next}} icon next to '''Position of Compose key'''
 
* Click the box next to the desired key to enable it
 
<span id="Console_Configuration"></span>
<div class="mw-translate-fuzzy">
=== 终端设置 ===
</div>
 
̣{{Note|This instruction are old and only works in Debian based system. If you know a better way, feel free to edit this wiki page.}}


To do this properly I'm trying to go the "holistic way" starting with the console:
To do this properly I'm trying to go the "holistic way" starting with the console:
Line 30: Line 57:
** A new ''initial RAM disk'' for the next boot will be created now.
** A new ''initial RAM disk'' for the next boot will be created now.


=== KDE 3.x Configuration ===
<span id="Configuration_for_GTK_Applications_(Gnome,_Firefox,_etc.)"></span>
 
<div class="mw-translate-fuzzy">
Now we can go on and configure our windowing environment. This description uses either ''Kcontrol'' or the Kubuntu configuration tool, which exposes the same option dialogue.
=== 设置 Gtk 程序(Gnome,FireFox 等等) ===
 
</div>
* Start the '''System Settings''' or the '''KDE Control Center'''
* <menuchoice>Regional & Language</menuchoice> (for System Settings) or <menuchoice>Regional & Accessibility</menuchoice> (for Control Centre) -> <menuchoice>Keyboard Layout</menuchoice>
* Choose your keyboard layout
* Modify the <menuchioce>Xkb Options</menuchioce> to select/enable the ''compose key''
 
 
[[Image:ControlKeyKDE3.png|500px|center]]
 
 
=== KDE SC 4.x configuration ===


Now we can go on and configure our windowing environment (Plasma). This description uses the '''System Settings''' as they're available in the K-Menu of the Kubuntu install:
{{Note|This instruction are probably obsolete. If GTK applications don't work ''out-of-the-box'', please go to the [[Special:myLanguage/Tutorials/ComposeKey#Troubleshooting|Troubleshooting section]].}}
 
* Start the '''System Settings'''
* <menuchoice>Regional & Language</menuchioce>
* Select the <menuchoice>Keyboard Layout</menuchoice> configuration
* Under the ''Layout'' tab, select <menuchoice>Enable keyboard layouts</menuchoice>
* Modify ''Advanced'' options to select/enable the ''compose key''


<div class="mw-translate-fuzzy">
Gtk(例如 Firefox)和 Gnome 程序(Ubuntu 系统上)通常使用''SCIM''作为输入法,而非那种依赖(X)Compose 配置的''XIM'' (X Input Method)。Therefore, you will often find that the "a" and "o" macron characters can yield the female/male ordinals "ª" and "º". 为了使其能同样有效,需要"告诉" GTK 程序使用 XIM。
</div>


[[Image:ControlKeyKDE4.png|500px|center]]
=== "One Off" Configuration ===


 
对于单个程序,你可以这样做:只要设定程序的环境变量'''GTK_IM_MODULE'''值为'''xim'''
=== Configuration for Gtk Applications (Gnome, FireFox, etc.) ===
 
Gtk (such as also FireFox) and Gnome applications use (on an Ubuntu system) usually ''SCIM'' as the input method, not ''XIM'' (X Input Method) that relies on the configurations from (X)Compose. Therefore, you will often find that the "a" and "o" macron characters can yield the female/male ordinals "ª" and "º". To still make it work, Gtk applications need to be "told" to use XIM instead.
 
==== "One Off" Configuration ====
 
For a single application you can do it by just setting the environment variable ''GTK_IM_MODULE'' for the application to be launched to '''xim''':


{{Input|1= $ GTK_IM_MODULE=xim firefox}}
{{Input|1= $ GTK_IM_MODULE=xim firefox}}


More permanently that can be done for a single shell session like this:
对于单个 shell 会话永久的设置可以这样:


{{Input|1= $ export GTK_IM_MODULE=xim}}
{{Input|1= $ export GTK_IM_MODULE=xim}}


This can, of course, also be persisted for a single user in your ''~/.bash_profile'', or for all users in ''/etc/environment''. This is, however, the less elegant way, the more elegant way follows below.
这条变量设置可以放到'''~/.bash_profile'''来设定单个用户下的G系程序都是如此,或是放到'''/etc/environment'''来设定全部用户都是如此。这种做法并怎么好,更好的方法在下面。


==== Persistent Configuration ====
=== Persistent Configuration ===


* Copy the setup file ''/etc/X11/xinit/xinput.d/default'' to ''/etc/X11/xinit/xinput.d/xim''
* Copy the setup file ''/etc/X11/xinit/xinput.d/default'' to ''/etc/X11/xinit/xinput.d/xim''
Line 97: Line 104:
* After a restart of the X server everything should work.
* After a restart of the X server everything should work.


==== Optional Tweaking of XCompose Map ====
<span id="Optional_Tweaking_of_XCompose_Map"></span>
<div class="mw-translate-fuzzy">
==== 可选的 XCompose Map 调整 ====
</div>


Now that you're using XIM, you can further tweak the XCompose input map for further characters, or for characters in more convenient locations, etc.
既然你当前用 XIM,你可以进一步调整 XCompose 输入映射便于输入更多字符,或是调整键位安排方便输入等等。


To do that follow these steps:
照下面这样做:
* Create a ''~/.XCompose'' file, and put the following lines into it:
* 创建一个'''~/.XCompose'''文件,复制下列字段进去:


{{Input|1=
{{Input|1=
Line 118: Line 128:
* Just log out and in again (no restart necessary), and you can use your new "multi key short strokes" using the compose key to your desire. As you see this even works for creating longer character sequences.
* Just log out and in again (no restart necessary), and you can use your new "multi key short strokes" using the compose key to your desire. As you see this even works for creating longer character sequences.


=== Typing Macrons, Umlauts, Accents, ... ===
== Typing Macrons, Umlauts, Accents, ... ==


The <keycap>compose</keycap> key will be now whatever you have configured it to be, e. g. <keycap>right logo</keycap>.
The <keycap>compose</keycap> key will be now whatever you have configured it to be, e. g. <keycap>right logo</keycap>.
Line 125: Line 135:
{{Input|1=<keycap>compose + shift + hyphen</keycap> then ''<vowel >''}}or {{Input|1=<keycap>compose + underscore</keycap> then ''<vowel >''}}
{{Input|1=<keycap>compose + shift + hyphen</keycap> then ''<vowel >''}}or {{Input|1=<keycap>compose + underscore</keycap> then ''<vowel >''}}


--> {{Output|1=āēīōū ĀĒĪŌŪ}}
&rarr; {{Output|1=āēīōū ĀĒĪŌŪ}}




Line 131: Line 141:
{{Input|1=<keycap>compose + shift + <single quote></keycap> then ''<vowel >''}}or {{Input|1=<keycap>compose + <double quotes></keycap> then ''<vowel >''}}  
{{Input|1=<keycap>compose + shift + <single quote></keycap> then ''<vowel >''}}or {{Input|1=<keycap>compose + <double quotes></keycap> then ''<vowel >''}}  


--> {{Output|1=äëïöü ÄËÏÖÜ}}
&rarr; {{Output|1=äëïöü ÄËÏÖÜ}}




Line 137: Line 147:
{{Input|1=<keycap>compose</keycap> then <keycap>s</keycap> and <keycap>s</keycap> (twice the "s")}}
{{Input|1=<keycap>compose</keycap> then <keycap>s</keycap> and <keycap>s</keycap> (twice the "s")}}


--> {{Output|1=ß }}
&rarr; {{Output|1=ß }}




* More bindings can be found in ''/usr/share/X11/locale/en_US.UTF-8/Compose''
* More bindings can be found in ''/usr/share/X11/locale/en_US.UTF-8/Compose''
<span id="Links and Further Information"></span>
<span id="Links and Further Information"></span>
=== Links and Further Information ===
== Troubleshooting ==
 
=== Compose key does not work in GTK applications ===
 
In {{Path|.xinputrc}}, delete the line with the following content: <code>run_im ibus</code>. Then reboot your computer, or restart the X server.
 
== More Information ==


* http://cyberborean.wordpress.com/2008/01/06/compose-key-magic/
* http://cyberborean.wordpress.com/2008/01/06/compose-key-magic/
Line 151: Line 167:
* http://hdante.blogspot.com/2007/05/kiel-oni-skribas-typing-esperanto.html
* http://hdante.blogspot.com/2007/05/kiel-oni-skribas-typing-esperanto.html


[[Category:Tutorials]]
[[Category:教程/zh-cn]]
[[Category:Advanced Users]]
[[Category:高级用户/zh-cn]]

Latest revision as of 08:32, 25 May 2024

Other languages:

介绍

compose 键是键盘用来输入不在键帽上的字符。这样的字母可能是"元音字母变音符号(umlaut)","长音符号(macron)"或是字母标音(accents on letters):

教程已经在多个Kubuntu Hardy Heron 8.04.1系统上测试过了。进一步的信息可以在下列的链接和进一步信息小节找到。

修改对(几乎)所有程序,包括桌面环境、浏览器、OpenOffice.org和众多终端/字符程序(console/text only applications)有效。

如下的教程会设定一个<compose>键,,同时映射到<right logo>键(多数键盘上这个logo 是Windows logo)。

Plasma Workspace

  • Select Input Devices then Keyboard
  • Click the Advanced tab
  • Click the box next to Configure Keyboard Options to enable changing keyboard options
  • Click the icon next to Position of Compose key
  • Click the box next to the desired key to enable it

终端设置

̣

Note

This instruction are old and only works in Debian based system. If you know a better way, feel free to edit this wiki page.


To do this properly I'm trying to go the "holistic way" starting with the console:

  • Reconfigure the console for the used keyboard, and the character encoding. Do this in a text terminal or the console.
$ sudo dpkg-reconfigure console-setup
  • Follow these steps in the configuration:
    • Choose your keyboard (here a default 104 US keyboard)
    • If you want the !AltGr key replacement, choose one
    • Choose which key you would like your compose key to be mapped to. I use the right logo key.

      I'd much rather like to use the left logo key, but that's not available in the console setting. But in the graphical window environment (KDE Plasma) that is possible.

    • Choose the console's encoding, set it to UTF-8
    • Choose what character set should be available on the console. I use Combined - Latin; Slavic Cyrillic; Hebrew; basic Arabic

      I guess that selection should give me the wanted characters.

    • Choose what type of console output you'd like (do whatever you like, to be safe you can go with the given current defaults)
    • A new initial RAM disk for the next boot will be created now.

设置 Gtk 程序(Gnome,FireFox 等等)

Note

This instruction are probably obsolete. If GTK applications don't work out-of-the-box, please go to the Troubleshooting section.


Gtk(例如 Firefox)和 Gnome 程序(Ubuntu 系统上)通常使用SCIM作为输入法,而非那种依赖(X)Compose 配置的XIM (X Input Method)。Therefore, you will often find that the "a" and "o" macron characters can yield the female/male ordinals "ª" and "º". 为了使其能同样有效,需要"告诉" GTK 程序使用 XIM。

"One Off" Configuration

对于单个程序,你可以这样做:只要设定程序的环境变量GTK_IM_MODULE值为xim

$ GTK_IM_MODULE=xim firefox

对于单个 shell 会话永久的设置可以这样:

$ export GTK_IM_MODULE=xim

这条变量设置可以放到~/.bash_profile来设定单个用户下的G系程序都是如此,或是放到/etc/environment来设定全部用户都是如此。这种做法并怎么好,更好的方法在下面。

Persistent Configuration

  • Copy the setup file /etc/X11/xinit/xinput.d/default to /etc/X11/xinit/xinput.d/xim
$ sudo cp /etc/X11/xinit/xinput.d/default /etc/X11/xinit/xinput.d/xim
  • Edit the file /etc/X11/xinit/xinput.d/xim and set the input method for GNOME and KDE to xim
...
 GTK_IM_MODULE=xim
 QT_IM_MODULE=xim
 ...
  • Create a link for the locale all_ALL (or the desired locale only):
$ sudo ln -sf /etc/X11/xinit/xinput.d/xim /etc/X11/xinit/xinput.d/all_ALL

If you are using a Debian-derived distribution use following instead

$ sudo update-alternatives --verbose --install /etc/X11/xinit/xinput.d/all_ALL xinput-all_ALL /etc/X11/xinit/xinput.d/xim 20
  • After a restart of the X server everything should work.

可选的 XCompose Map 调整

既然你当前用 XIM,你可以进一步调整 XCompose 输入映射便于输入更多字符,或是调整键位安排方便输入等等。

照下面这样做:

  • 创建一个~/.XCompose文件,复制下列字段进去:
# ~/.XCompose
 # This file defines custom Compose sequences for Unicode characters
# Import default rules from the system Compose file: include "/usr/share/X11/locale/en_US.UTF-8/Compose"
# To put some stuff onto compose key strokes: <Multi_key> <minus> <greater> : "→" U2192 # Compose - > <Multi_key> <colon> <parenright> : "☺" U263A # Compose : ) <Multi_key> <h> <n> <k> : "hugs and kisses" # Compose h n k <Multi_key> <less> < p> : "< p>

" # Compose < p
  • Just log out and in again (no restart necessary), and you can use your new "multi key short strokes" using the compose key to your desire. As you see this even works for creating longer character sequences.

Typing Macrons, Umlauts, Accents, ...

The compose key will be now whatever you have configured it to be, e. g. right logo.

  • Macrons
compose + shift + hyphen then <vowel >

or

compose + underscore then <vowel >

āēīōū ĀĒĪŌŪ


  • Umlauts
compose + shift + <single quote> then <vowel >

or

compose + <double quotes> then <vowel >

äëïöü ÄËÏÖÜ


  • The German Ess-Zet ligature
compose then s and s (twice the "s")

ß


  • More bindings can be found in /usr/share/X11/locale/en_US.UTF-8/Compose

Troubleshooting

Compose key does not work in GTK applications

In .xinputrc, delete the line with the following content: run_im ibus. Then reboot your computer, or restart the X server.

More Information