May 10, 2012

Set compose key on Linux | Input character directly by Unicode code.

  1. Compose key:
  2. Sometime during your working time, you wanna/have to input some special, useful and widely used characters such as ©, ® or ó, ⁶, and §ô øñ ...
    It isn't easilly to input those above characters with the default input method or keymap.
    You have to change your own IM (Input Method), keymap or copy&paste those characters from another location to your current input area. Or at least, you also have to set some speacial shorcut in concurrent IM/IE (Input Engineer).
    I think there are many tools, tips to resolve this issue out there. And one of the most easy way is that using Compose Key
    How to setup compose key? I'm working on a Gentoo Linux system. So I will give you some guidelines to setting up and using Compose Key.
    1. Setting up:
    2. Now I will demostrate a simplest way to set compose key on most Linux system which has a running X Window system. If your Linux system has a(n) DE(s) such as KDE or GNOME, you're freely to choose another method using GUI, maybe. I'll cover it later.
      Tool and Command: X Window is come with many tool to modify/customize IM, and keyboard layout. One of them that is setxkbmap. And we'll use this tool to set the compose key. The command is:
      $ setxkbmap -option compose:ralt
      
      • setxkbmap: Tool command.
      • option: setxkbmap Commandline option indicates that the another option is Options :3
      • compose: Indicates that the option is setting Compose Key
      • : <-- Don't miss it!
      • ralt: That means the Compose Key is Righ Alt on your keyboard.
      • You're free to choose another key that you wanna such as rwin means it's the Right Windows key on keyboard.
    3. Usage:
    4. How to use the Compose Key?
      |Compose Key| + |First Char| + |Second Char|
      
      You input those keys sequencially.
      • Compose Key: The Compose Key.
      • First Char: The first character to composing. It's usually a symbol such as ", ', ~, `,... And sometime that is a normal character on the keyboard.
      • Second Char: It's mostly is a normal character. Sometime it's a symbol.
    5. Examples:
    6. Following examples will demostrate how to use Compose Key to input speacial character such as: ®, ©¸ õ, ū, ⁶, ₁.
      ralt o c => © 
      
      ralt o r => ® 
      
      ralt ~ o => õ 
      
      ralt - u => ū 
      
      ralt ^ 6 => ⁶ 
      
      ralt _ 1 => ₁
      
    7. Reference:
    8. Linux Compose Key Sequences

  3. Input directly using Unicode code:
  4. ♥, ♚, ♪, ... Interesting huh? You're surely sometime wanna use these special characters. Example: in some lovely post for your friend on her/his facebook's wall.
    How to input it? Compose Key?
    I think unless use some tips/trick, else, the only/first method to input those special characters is copy&paste
    Yes, we should been copy&paste before, but now, we'll input those characters directly by using Unicode code. Interesting huh?
    1. Requirement:
      • You have to know exactly the Unicode code of the character that you wanna.
      • But, "where could I get it?" I dunno exactly. Err, on Internet, or wherever.
        Recommend: GnuCharMap and KCharSelect are two powerful tool to view, select, ... Unicode character.
      • The font that you're using support the Unicode character that you wanna.
      • I'm write these line with GVim, using unifont, and test on Firefox with Linux Biolinum font. Both of them display those above special character nicely!
    2. Input them:
    3.     Ctrl + Shift + u + Unicode Code
          
      • Description:
      • Hold on both Ctrl and Shift keys, then press the u key on keyboard. Lastly input the Unicode Code exactly, as fast as possible. Then left out Ctrl and Shift keys.
      • Note:
      • Do not left out any of two Ctrl and Shift keys until you're done.
    4. Examples:
    5.     Ctrl + Shift + u + 2665 => ♥
          Ctrl + Shift + u + 266a => ♪
              

March 10, 2012

Add more colorscheme for IDLE | Thêm lược đồ màu tô sáng cho IDLE


- IDLE là IDE cho ngôn ngữ Python. Được tích hợp sẵn vào bản cài đặt Python dành cho Windows.

- Bài viết này không đề cập đến vấn đề cài đặt và sử dụng IDLE, mà chỉ nói đến một khía cạnh nhỏ trong quá trình sử dụng IDLE. Đó là vấn đề về bảng chế độ màu tô sáng cú pháp trong IDLE.

- IDLE, cũng như nhiều IDE (Integrated Development Enviroment) khác, đi kèm cùng với chức năng tô sáng cú pháp ngôn ngữ (Syntax highlighting) sử dụng một lược đồ màu sắc (Color Scheme) nào đó, nhằm tạo nên sự tiện lợi và hiệu quả hơn trong quá trình sử dụng chương trình.

- Mỗi IDE thường đi kèm với một hoặc vài Color Scheme đã được tích hợp sẵn. Riêng với IDLE thì chỉ có một hoặc hai colorscheme đó là IDLE Classic và IDLE New.

Trong quá trình sử dụng IDLE, nếu chúng ta không hài lòng với 2 colorscheme sẵn có, chúng ta có thể thêm vào cho IDLE các colorschem khác bằng nhiều cách:

  • Chỉnh sửa ngay trong phần Configure của IDLE:
     Options +> Configure IDLE +> Hilighting
    
  • Chỉnh sửa file config-highilight của IDLE:
    • Đối với Linux, file này ở tại:
      ~/.idlerc/config-main.cfg
    • Đối với Windows:
      C:\Python27\Lib\idlelib\config-highlight.def
      hoặc:
      C:\Users\your-username\.idlerc\config-highlight.cfg
    Để thêm một colorscheme mới vào file trên, chúng ta thêm một đoạn text định nghĩa colorscheme đó vào file, có thể là cuối file.
  • Ví dụ:
    • Để thêm một colorschemedesert, chúng ta thêm đoạn sau vào file config-highlight
    • [desert]
      definition-foreground = #98fb98
      error-foreground = #ff0000
      string-background = #333333
      keyword-foreground = #cc6600
      normal-foreground = #f0e68c
      comment-background = #333333
      hit-foreground = #ffffff
      break-foreground = black
      builtin-background = #333333
      stdout-foreground = #eeeeee
      cursor-foreground = #ffcc00
      hit-background = #333333
      comment-foreground = #87ceeb
      hilite-background = gray
      definition-background = #333333
      stderr-background = #333333
      break-background = #ffff55
      console-foreground = #87ceeb
      normal-background = #333333
      builtin-foreground = #519e51
      stdout-background = #333333
      console-background = #333333
      stderr-foreground = #ff3e40
      keyword-background = #333333
      string-foreground = #ffa0a0
      hilite-foreground = #000000
      error-background = #000000
      

- Để chọn desert làm colorscheme cho IDLE:
 +-> Highlighting +> a Built-in ... +> desert
hoặc
+-> Highlighting +> a Custom ... +> desert


- Tham khảo: