LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   FULL LIST of Entering Special Characters with Compose Key? (http://www.linuxquestions.org/questions/linux-newbie-8/full-list-of-entering-special-characters-with-compose-key-922021/)

Geremia 01-04-2012 12:23 PM

FULL LIST of Entering Special Characters with Compose Key?
 
I have found many lists of compose key sequences for entering special characters, e.g.:
  1. This one
    1. It is lacking, though. E.g., it lacks ← and → ( compose + -> or compose + -< ).
  2. a fuller list: http://fsymbols.com/keyboard/linux/compose/
  3. the most comprehensive I've seen yet: https://help.ubuntu.com/community/GtkComposeTable
Yet none of them are complete. The interrobang ‽, e.g., is not on those lists; its sequence is: comp. + ? + !


Is there a complete list? Why does KCharSelect not say how to enter special characters with the compose key? Or does it? Thanks

David the H. 01-04-2012 03:14 PM

I don't know if there is a "complete" list outside of the configuration files themselves, due to the sheer number of them. On most systems (I believe) you'll find them at one of these locations:

/usr/share/X11/locale/<locale>/Compose
/usr/X11R6/lib/X11/locale/<locale>/Compose

This page offers a short script that will search your locale's Compose file for you (only utf-8 locales supported).

http://www.pixelbeat.org/docs/xkeyboard/

Just hand it the actual character you want to find the mappings for and you'll get a list of the compose sequences defined for it.

If you're interested, I've rewritten it into a more solid bash-based script that can handle multiple input characters at once. I recommend it over the original, of course. :cool:

Code:

#!/bin/bash

# List the X compose sequences available to generate the specified character.
# I.E. the keyboard key sequence to enter after the compose (multi) key or
# a dead key is pressed.
#
# This version has been heavily modified by me (David the H.).  It is now
# bash-specific, reduces the need for external tools (only grep is needed),
# and can handle multiple inputs.
#
# Original script info follows.  For the original version, go here:
# http://www.pixelbeat.org/docs/xkeyboard/
#
# Author:
#    P@draigBrady.com
# Notes:
#    GTK+ apps use a different but broadly similar input method
#    to X by default. Personally I tell GTK+ to use the X one by
#    adding `export GTK_IM_MODULE=xim` to /etc/profile
# Changes:
#    V0.1, 09 Sep 2005, Initial release
#    V0.2, 04 May 2007, Added support for ubuntu
#

if [[ -z $* ]]; then
        echo "Usage: ${0##*/} 'character(s)'" >&2
        echo "Multiple characters are supported." >&2
        echo "They don't need to be space-separated." >&2
        exit 1
fi

if [[ $LANG =~ (.*)[.]UTF.*8 ]]; then

        lang="${BASH_REMATCH[1]}"
        codeset=UTF-8

else

        echo "Sorry, only UTF-8 is supported at present" >&2
        exit 1
        #could try and normalise codeset, and get char with printf %q
        #but would not be general enough I think.

fi

dir=/usr/share/X11/locale #ubuntu

if [[ ! -d "$dir" ]]; then

        dir=/usr/X11R6/lib/X11/locale #redhat/debian

fi

if [[ ! -f "$dir/locale.dir" ]]; then

        echo "Sorry, couldn't find your X windows locale data" >&2
        exit 1

fi

page="$( grep -m1 "${lang}.${codeset}$" <$dir/locale.dir )"
page=${page%%/*}

file="$dir/$page/Compose"

while read -n 1 character; do

        [[ -z $character ]] && continue
        echo "combinations found for [$character]"
        grep -F "\"$character\"" "$file"
        echo

done <<<"$@"

exit 0

Example usage (I have it aliased to "ximkeys"):
Code:

$ ximkeys ←→‽
combinations found for [←]
<Multi_key> <less> <minus>      : "←" U2190 # LEFTWARDS ARROW

combinations found for [→]
<Multi_key> <minus> <greater>  : "→" U2192 # RIGHTWARDS ARROW

combinations found for [‽]
<Multi_key> <exclam> <question>        : "‽"  U203D # INTERROBANG

Be aware though, as the original script header says, that GTK uses its own internal mapping system by default, ignoring the X compose table, so some compositions may be handled differently in GTK apps.

Geremia 01-05-2012 01:11 AM

Quote:

Originally Posted by David the H. (Post 4566084)
I've rewritten it into a more solid bash-based script that can handle multiple input characters at once. I recommend it over the original, of course. :cool:

Code:

#!/bin/bash

# List the X compose sequences available to generate the specified character.
# I.E. the keyboard key sequence to enter after the compose (multi) key or
# a dead key is pressed.
#
# This version has been heavily modified by me (David the H.).  It is now
# bash-specific, reduces the need for external tools (only grep is needed),
# and can handle multiple inputs.
#
# Original script info follows.  For the original version, go here:
# http://www.pixelbeat.org/docs/xkeyboard/
#
# Author:
#    P@draigBrady.com
# Notes:
#    GTK+ apps use a different but broadly similar input method
#    to X by default. Personally I tell GTK+ to use the X one by
#    adding `export GTK_IM_MODULE=xim` to /etc/profile
# Changes:
#    V0.1, 09 Sep 2005, Initial release
#    V0.2, 04 May 2007, Added support for ubuntu
#

if [[ -z $* ]]; then
        echo "Usage: ${0##*/} 'character(s)'" >&2
        echo "Multiple characters are supported." >&2
        echo "They don't need to be space-separated." >&2
        exit 1
fi

if [[ $LANG =~ (.*)[.]UTF.*8 ]]; then

        lang="${BASH_REMATCH[1]}"
        codeset=UTF-8

else

        echo "Sorry, only UTF-8 is supported at present" >&2
        exit 1
        #could try and normalise codeset, and get char with printf %q
        #but would not be general enough I think.

fi

dir=/usr/share/X11/locale #ubuntu

if [[ ! -d "$dir" ]]; then

        dir=/usr/X11R6/lib/X11/locale #redhat/debian

fi

if [[ ! -f "$dir/locale.dir" ]]; then

        echo "Sorry, couldn't find your X windows locale data" >&2
        exit 1

fi

page="$( grep -m1 "${lang}.${codeset}$" <$dir/locale.dir )"
page=${page%%/*}

file="$dir/$page/Compose"

while read -n 1 character; do

        [[ -z $character ]] && continue
        echo "combinations found for [$character]"
        grep -F "\"$character\"" "$file"
        echo

done <<<"$@"

exit 0


Thanks for the excellent script

SecretCode 01-05-2012 03:21 AM

Quote:

Originally Posted by David the H. (Post 4566084)
I don't know if there is a "complete" list outside of the configuration files themselves, due to the sheer number of them. On most systems (I believe) you'll find them at one of these locations:

/usr/share/X11/locale/<locale>/Compose
/usr/X11R6/lib/X11/locale/<locale>/Compose

Or at ~/.XCompose - if you or somebody or some utility has created this file. (This is the best way to add user customisations - it can include the full locale file.)

Geremia 02-01-2012 01:16 AM

No ∞ symbol?
 
I can't find the infinity ∞ symbol. I wonder why.

SecretCode 02-01-2012 05:26 AM

Quote:

Originally Posted by Geremia (Post 4590065)
I can't find the infinity ∞ symbol. I wonder why.

Not enough googling? :p

In your ~./XCompose file, a line like this
Code:

<Multi_key> <8> <8>            : "∞"  U221E # INFINITY
will do the trick
(or whatever other sequences of keys you want to use - some people like <0> <0> - one guy likes <1> <slash> <0> ;))

Geremia 02-02-2012 05:46 PM

Quote:

Originally Posted by SecretCode (Post 4590252)
<1> <slash> <0>

Haha thanks


All times are GMT -5. The time now is 01:46 PM.