8

When the language layout is changed to a right to left language; in some standard editing places (e.g. the address bar of Google Chrome), characters like <, { and [ automatically become >, } and ] just by changing language layout.

Is there a way to prevent this and make these characters stable?

  • Could you add a showcase with screenshot. – user.dz Mar 22 '14 at 18:01
  • 1
    @Sneetsher: needs a film. add arabic to the languages in Chromium address bar type the charater < alone. Then change layout to English. – user126106 Mar 24 '14 at 15:42
8

I didn't get what you mean for the first time, because I got familiar with that. I think it will be OK, if you can expect results.

That behavior is a standard from Unicode Bidirectional Algorithm. So the dominant BiDi direction is taken from first strong character in the paragraph.

  • So what I think it happens in this case:

    1. First direction with empty textbox is taken from locale/language configuration. As you said Arabic is an RTL language. So cursor on the right.

      initial empty textbox, RTL direction

    2. Input < but it showed as >. It is a neutral char so no affects on direction. Why it is flipped? Short answer: Unicode standard, :) accept that anyway. Well its name is Less-than sign, So ... In RTL/Arabic, formula's start from right side, it should be flipped. What do you think...no?!!!

      textbox with bidi neutral character

    3. Input a Latin char g. It's a strong L (left) char, so this paragraph is detected as LTR.

      textbox with strong left character

    4. Backspace to delete g. But notice where the cursor.

      textbox with bidi neutral character after removing a strong left character

    Now, example [, it was wrongly named Left square bracket. It should be some thing like Open square bracket (It is BiDi neutral and flipped in RTL)

All developers try to follow standards. So noway they will force textbox to be RTL or LTR, Auto is the best for most users.

  • So for you, the best thing I can offer is to use Unicode BiDi Control Char's.

    U+200F right-to-left mark (RLM)
    
    1. In empty address bar, Ctrl+Shift+u, small underlined u shows up, enter 200f then Enter

      GTK/Gnome Unicode input

    2. See < did not flip as LTR.

      GTK/Gnome force RTL direction

    Ctrl+Shift+u is GTK/Gnome specific. KDE misses for such option and it seems not to be fixed, as this bug report mention the conflict between KDE/Qt/Xorg Need way to insert arbitrary Unicode characters in Kubuntu.

  • As it is just a matter of few characters, you could remap non needed keys or map non used ones. For example, I'm using US English (international AltGr dead keys)

    1. Open its xkb layout file for editing:

      sudo nano /usr/share/X11/xkb/symbols/us
      
    2. Look for the group definition that with same name:

      xkb_symbols "altgr-intl" {
      
          name[Group1]= "English (international AltGr dead keys)";
      
    3. Let's look as example for r (easy to remember),: AltGr+r → RLM, Shift+AltGr+r → LRM. Instead of ë & Ë. Replace:

      key <AD04> { [        r, R,           ediaeresis,   Ediaeresis      ] };
      

      With:

      key <AD04> { [        r, R,           U200F,        U200E           ] };
      
    4. Update xkb

      sudo dpkg-reconfigure xkb-data
      
    5. Switch to another layout then back, it will be active immediately.

    Notes:

    • Use same method to add them to Arabic layout, if you want to be able to use it from both layouts.

    • You may use U+061C ؜ ‭arabic letter mark (ALM) instead of RLM as you are an Arabic user.

    • xkb supports other Unicode code entry format, 0x100200f eq. U200F (ie 0x100 as prefix)

    • To avoid overwriting of the modified key map by xkb-data updates, the best is to create a new custom XKB map. See How to add a new keyboard layout (Custom keyboard layout definition) or What are the steps needed to create new keyboard layout on ubuntu?

    • It's possible add all other Unicode control characters. Some application has already an option in Popup Menu of the Multi-line Input Text Box. Example Poedit:

      poedit, bidi control characters menu

Nice to read for further understanding:

References:

  • thanks. for me ctrl+shift + u does not work in KDE. probably it's unity or gnome specific. It'd fantastic if some characters, e.g. ',[]{}' can opt out from direction specific treatments (and always are regraded as ltr), so that they are more compatible with keyboard symbols and less confusing. – user126106 Mar 24 '14 at 22:28
  • 1
    You are right, It seems not to be fixed in KDE, as this bug report mention the conflict between KDE/Qt/Xorg Need way to insert arbitrary unicode characters in Kubuntu. I will search if there is any workaround. – user.dz Mar 24 '14 at 22:51
  • @MinimusHeximus, I updated my answer with Unicode input workaround using xkb. I have only Gnome/Unity. Please, let me know if it doesn't work in KDE. – user.dz Mar 25 '14 at 12:51
  • 1
    Seems I have to use something like 0x100200F instead, I don't know if it is the same as U200F. – user126106 Mar 25 '14 at 13:43
  • 1
    @MinimusHeximus, yes, it is the same "(In fact, this may be a more effective way for adding new keysyms.) The Unicode value must be prefixed with "0x100" to describe the keysym for a single character." , Ref: Wikibooks: FOSS Localization/Annex B: Technical Aspects. Thank you I learned new things from you. – user.dz Mar 25 '14 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.