LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   print the degree symbol in kwrite via the keyboard (http://www.linuxquestions.org/questions/slackware-14/print-the-degree-symbol-%B0-in-kwrite-via-the-keyboard-588356/)

tramni1980 09-30-2007 05:23 AM

print the degree symbol in kwrite via the keyboard
 
Hello!
I need to enable kwrite and openoffice to print the "degree" symbol when I press, say F4. I have checked the degreee symbol that I need is coded like: U+00B0 (176). How can I achieve that?

Any suggestions will be appreciated.

Su-Shee 09-30-2007 06:22 AM

If it's ANY Gtk-based application, you just press Ctrl-Shift u<00b0>, if you're running a Unicode environment.

This should work in OpenOffice as well.

In kwrite, I don't know.

tramni1980 09-30-2007 06:57 AM

Quote:

Originally Posted by Su-Shee (Post 2908172)
If it's ANY Gtk-based application, you just press Ctrl-Shift u<00b0>, if you're running a Unicode environment.

This should work in OpenOffice as well.

In kwrite, I don't know.

I do not quite understand how I could press u<00b0> ? ctrl-shift ok, but how do I press u<00b0> ? I tried typing that sequence in openoffice but nothing happened.

Su-Shee 09-30-2007 12:40 PM

Hold Ctrl and Shift and press u00b0 in sequence.

I just tried in Firefox, there it works. (I don't have an OpenOffice here right now.)

Otherwise, check your X-keyboard setup in /etc/X11/xkb/symbols/pc/; usally signs/chars like "degree" are a simple combined shortcuts. Which keys to type exactly depends on your keyboard setting.

osor 09-30-2007 12:45 PM

I think there is something much easier than remembering Unicode code points for various symbols. What Im talking about of course is the Compose Key. For example, on my computer (which uses en_US.UTF-8), the degree symbol is obtained in any program with:
Code:

<Multi_key> <o> <o>
You can customize compose key mappings using the file $HOME/.XCompose (there is a system-wide file named /usr/share/X11/locale/$LC_LOCALE/Compose). To get the various toolkits (e.g., gtk and qt) to use X for Compose Key processing (the so-called X input method), you might need to define a few environment variables:
Code:

export QT_IM_MODULE=xim
export GTK_IM_MODULE=xim


tramni1980 10-01-2007 04:29 AM

Thank you very much for you responsiveness. I read some literature on xfree86, keycodes, keyboardmaps,etc, but it seems to be a whole bit of a science to me. I would be very thankful if someone can provide an easy step-by-step guide on how to make the degree symbol possible to type via the keyboard.
I found out that it is the so called Multi_key that has to be set, but I could neither find out which is the Multi_key on my keyboard and how can I set it to print the degree symbol.

tramni1980 10-01-2007 06:00 AM

Sorry for posting again. I managed to set the compose key to be left win by means of the kde Control Center.
Here is an excerpt of my /etc/X11/xkb/symbols/us file:

partial alphanumeric_keys
xkb_symbols "intl" {

name[Group1]= "U.S. English - International (with dead keys)";

include "us(basic)"

// Alphanumeric section

key <AC10> { [ semicolon, colon, paragraph, degree ] };

include "level3(ralt_switch)"
};

And here is an excerpt of my /usr/share/X11/locale/en_US.UTF-8/Compose file:
# UTF-8 (Unicode) compose sequence
# David.Monniaux@ens.fr
#
# $XFree86: xc/nls/Compose/en_US.UTF-8,v 1.11 2004/01/06 13:14:04 pascal Exp $

# Part 1 - Manual definitions

# Spacing versions of dead accents

<dead_abovering> <space> : "В" degree # DEGREE SIGN
<dead_abovering> <dead_abovering> : "В" degree # DEGREE SIGN
# Spaces
<Multi_key> <o> <o> : "В" degree # DEGREE SIGN


Any ideas? What must I do to be able to type the degree symbol from the keyboard?

osor 10-01-2007 01:11 PM

Quote:

Originally Posted by tramni1980 (Post 2909154)
Any ideas? What must I do to be able to type the degree symbol from the keyboard?

If you want to go the Compose Key route, use this entry:
Code:

<Multi_key> <o> <o>                    : ""  degree # DEGREE SIGN
What it says is this:
  1. Press and release the Multi-Key (lwin or whatever).
  2. Press and release the o key.
  3. Press and release the o key again.
And the result will be the degree sign. See, watch:

I would suggest you first try this in a plain X application (i.e., not gtk or qt). For example an xterm (provided you have appropriate fonts). Then, export those environment variables (QT_IM_MODULE and GTK_IM_MODULE) so they are in effect upon booting your computer. With the environment variables set, you should be able to use all the combos within gtk apps (e.g., firefox) and qt/kde apps (e.g., kwrite).


P.S., a few caveats regarding compose key usage:
  • Pay close attention to the case of keys specified. In this example, the keys specified are lowercase o, which means to type as if you are typing a lowercase o (i.e., just press and release the key). If you wanted, for example, the pilcrow sign (), you need two upper-case P presses (which means use the shift modifier while pressing and releasing the key).
  • If you create a file called $HOME/.XCompose, it will replace (not augment) your system-wide combos. Therefore, it is recommended to copy the system wide file to your home directory and edit it there (so you dont lose the established combos).

tramni1980 10-01-2007 02:42 PM

I tried in xterm as well but in vain. For example <Multi_key> <a> <e> does work , but <Multi_key> <o> <o> does not :(. Anyway, what I by chance found out, is that pressing left alt+0 produces the degree symbol. Unfortunately this only works in xterm and in no other application. What can I do?

I am very thankful for your responsiveness.

bogzab 10-01-2007 03:38 PM

Hi
I have had a similar problem, trying to get a number of foreign characters to display from keyboard combinations. I have got nearly everything I got working and used as my main source of information the following link : http://www.in-ulm.de/~mascheck/X11/xmodmap.html
which (together with further links therein) explains a lot about how X keyboard mapping works. Including the nice quotation : If you're thinking that this is all senselessly complicated... you're right."

Incidently, if you have the same default keyboard mappping as I have (works on both my Slackware Box and on a Suse installation) you can generate the degree symbol with the following key combination : AltGr-Shift-0 (thats the zero on the line of numeric characters, not the 0 on the numeric keypad). If that does not work for you, the link above will show you how to make it work.

Bogus

osor 10-01-2007 04:00 PM

Quote:

Originally Posted by tramni1980 (Post 2909600)
I tried in xterm as well but in vain. For example <Multi_key> <a> <e> does work , but <Multi_key> <o> <o> does not

This sounds to me like a font problem (you have to be using a fixed width xterm font that supports many unicode code points, specifically the degree symbol). What is displayed on the screen? Two os? A box (i.e., filler) character? Nothing at all?

In any case, it seems your multi-key works (at least for the glyphs supported by your font). Now try a gtk app. For example, try launching firefox like this:
Code:

$ GTK_IM_MODULE=xim firefox
and now try your multi-key combo (e.g., in a text box).

tramni1980 10-02-2007 02:29 AM

Quote:

Originally Posted by osor (Post 2909666)
This sounds to me like a font problem (you have to be using a fixed width xterm font that supports many unicode code points, specifically the degree symbol). What is displayed on the screen? Two os? A box (i.e., filler) character? Nothing at all?

In any case, it seems your multi-key works (at least for the glyphs supported by your font). Now try a gtk app. For example, try launching firefox like this:
Code:

$ GTK_IM_MODULE=xim firefox
and now try your multi-key combo (e.g., in a text box).

I started firefox the way you suggested and again works, but degree does not. Nothing gets printed at all. Anyway, I followed the link that bogzab gave and I issued:
xmodmap -e "keycode 116 = 176"
Now with that key I can print the degree symbol in any application. The only problem is that any time I change the keyboard layout,e.g from "us" to "bg", I have to issue the command:
xmodmap -e "keycode 116 = 176"
Is there a way to get that command executed automatically at keyboard layout change ?

osor 10-02-2007 12:20 PM

Quote:

Originally Posted by tramni1980 (Post 2910093)
Is there a way to get that command executed automatically at keyboard layout change ?

That depends on how you change your keyboard layout. The hackiest way would be to write a wrapper script for the program called. The wrapper script would first call the actual utility then call xmodmap. There is probably a more elegant way using the file ~/.Xresources or something like that.



P.S.:
If you still want to try using the Multi-key (and its understandable if you dont), it seems you might have a case of mistaken locality. Specifically, what is the output of the locale command? If you want to use the Compose combos for en_US.UTF-8 (which on my system is the most complete), just copy /usr/share/X11/locale/en_US.UTF-8/Compose to ~/.XCompose. If after all that, it still doesnt work, then I think it would be better to go the other route after all.

tramni1980 10-02-2007 02:31 PM

Quote:

Originally Posted by osor (Post 2910640)
That depends on how you change your keyboard layout. The hackiest way would be to write a wrapper script for the program called. The wrapper script would first call the actual utility then call xmodmap. There is probably a more elegant way using the file ~/.Xresources or something like that.

I change my keyboard layout pressing ctrl+tab. On my computer at work the keyboard layout is changed by pressing shift+ctrl. Where do I have to write the command "xmodmap -e "keycode 116 = 176" so that at pressing the key combination that changes the keyboard layout, the degree symbol is assigned to key number 176? If I need to write a wrapper script, what should it contain and where should it be located? How do I specify that this script must be executed at pressing ctrl+tab for instance?

the output of "locale" is:
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE=C
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=

I tried copying the file you suggested, but there was no difference.

phi11ip 10-04-2007 05:00 AM

Quote:

Originally Posted by tramni1980 (Post 2909154)
Sorry for posting again. I managed to set the compose key to be left win by means of the kde Control Center.
Here is an excerpt of my /etc/X11/xkb/symbols/us file:

partial alphanumeric_keys
xkb_symbols "intl" {

name[Group1]= "U.S. English - International (with dead keys)";

include "us(basic)"

// Alphanumeric section

key <AC10> { [ semicolon, colon, paragraph, degree ] };

include "level3(ralt_switch)"
};

<AC10> corresponds to the tenth alphanumeric key on row C of the keyboard. Ie the semicolon key.
no modifier - semicolon
<SHIFT> + <;> - colon
<ALT GR> + <;> - paragraph
<SHIFT> + <ALT GR> + <;> - degree

Hence for the degree symbol press and hold <ALT GR> then press and hold <SHIFT>, then press <;>.
On my UK keyboard it's <AE10>, the number 0 key. It doesn't seem to work if you press all 3 keys at the same time.
Hope this helps
Phil


All times are GMT -5. The time now is 01:16 AM.