Coder Social home page Coder Social logo

ranger_keybord's Introduction

Support hotkeys other keyboard layouts

It is plugin for FM ranger ;). It allows to enable support command hotkeys for other keyboard layouts. By default, Russian and Ukrainian are supported enable. You can add or replace support your keyboard layouts for ranger. To do this, replace the following fields: other_keys, en_keys in a file: ~/.config/ranger/plugins/ranger_multiple_keyboard.py You can use merge mode (usually for S-[0-9]): field other_keys_mm. Simple to fill in the other_keys_mm (see examples in plugin). It do not applied for a pager.

Installation plugin for your ranger

multiple_keyboard.py must be copied to ~/.config/ranger/plugins

version 2.0

fix crash on some file names(preview lags input) with translate-keys navigation in list files:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 4: unexpected end of data

How to fill other other_keys, en_keys and other_keys_mm

  1. You can open your favourite text editor (need support utf-8) and input all keys for your native keyboard layout. For example to do it for German witch more intricate than Cyrillic group.
    1. Your En-inputting for all symbols without pressed Shift and below DE-inputting:
      1. de: qwertzuiopü+asdfghjklöäyxcvbnm,.- and up-numerical ^1234567890ß´
      2. en: qwertyuiop[]asdfghjkl;'zxcvbnm,./ and up-numerical ˋ1234567890-= (ˋ is replaced)
    2. Your En-inputting for alphabetic symbols with pressed Shift and below DE-inputting:
      1. DE: QWERTZUIOPÜ*ASDFGHJKLÖÄYXCVBNM;:_ and up-numerical °!"§$%&/()=?ˋ (ˋ is replaced)
      2. EN: QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>? and up-numerical ~!@#$%^&*()_+
  2. You can see equals hotkeys in column inputting. Deleting it...
    1. de: zü+öäy- and up-numerical ^ß´
    2. en: y[];'z/ and up-numerical ˋ-= (ˋ is replaced)
    3. DE: ZÜ*ÖÄY;:_ and up-numerical °"§&/()=?ˋ (ˋ is replaced)
    4. EN: Y{}:"Z<>? and up-numerical ~@#^&*()_+
  3. Union variables and there are next:
    1. de: zü+öäy- + ZÜ*ÖÄY;:_ + ^ß´ + °"§&/()=?ˋ (ˋ is replaced)
    2. en: y[];'z/ + Y{}:"Z<>? + ˋ-= + ~@#^&*()_+ (ˋ is replaced)
  4. Arrange it for plugin:
    1. Grouping:
      de: "üÜä°§" + 'ö;Ö:' + 'Ä"' + 'ß-/&^`+' + '?_' + '´=)(*' + 'zZyY'
      en: "[{'~#" + ';<:>' + '"@' + '-/&^`+]' + '_?' + '=)(*}' + 'yYzZ'
      
    2. Part. Fill variable by symbols and utf-8, it will be translated in ascii:
      other_keys    = "üÜä°§" + "öÖ"  + 'Ä' + 'ß'
      en_keys       = "[{'~#" + ";:"  + '"' + '-'
      other_keys_mm = ''
      
    3. All. Adding merge and handling ascii (fallback):
      other_keys    = "üÜä°§" + "öÖ"  + 'Ä' + 'ß'
      en_keys       = "[{'~#" + ";:"  + '"' + '-' \
                      ';:"------_====zZ'
      other_keys_mm = '<>@/`^&+]?)(*}yY'
      
    4. Optimization:
      other_keys    = "üÜä°§öÖ" + 'Äß'
      en_keys       = "[{'~#;:" + '"-' \
                      ';:"------_====zZ'
      other_keys_mm = '<>@/`^&+]?)(*}yY'
      
  5. Fill variables (copy/paste) in for plugin using text from 4.4.

So, other_keys and en_keys need for translate letters for utf-8 into ascii, where translated char is a pair map other_keys, en_keys. other_keys_mm need for merge keys for two or more keyboards layout (usually for intersection). Too may been used to translate ascii chars (fallback).

Example support Ukrainian and Russian keyboard layouts

other_keys    = "фисвуапршолдьтщзйкыіегмцчнябюхъїжэєё'" + 'ФИСВУАПРШОЛДЬТЩЗЙКЫІЕГМЦЧНЯБЮХЪЇЖЭЄЁʼ' + '№'
en_keys       = "abcdefghijklmnopqrsstuvwxyz,.[]];''``" + 'ABCDEFGHIJKLMNOPQRSSTUVWXYZ<>{}}:""~ʼ' + '#' \
                '@$^&/&'
other_keys_mm = '";:?.,'

Example support for German keyboard layouts

other_keys    = "üÜä°§öÖ" + 'Äß'
en_keys       = "[{'~#;:" + '"-' \
                ';:"------_====zZ'
other_keys_mm = '<>@/`^&+]?)(*}yY'

Example support German, Ukrainian and Russian keyboard layouts

other_keys    = "фисвуапршолдьтщзйкыіегмцчнябюхъїжэєё'" + 'ФИСВУАПРШОЛДЬТЩЗЙКЫІЕГМЦЧНЯБЮХЪЇЖЭЄЁʼ' + '№' + "üÜä°§öÖ" + 'Äß'
en_keys       = "abcdefghijklmnopqrsstuvwxyz,.[]];''``" + 'ABCDEFGHIJKLMNOPQRSSTUVWXYZ<>{}}:""~ʼ' + '#' + "[{'~#;:" + '"-' \
                '@$-&/&' + '$-"------&====zZ'
other_keys_mm = '";:?.,' + '<>@/`^&+]_)(*}yY'

Example way to swap keys

other_keys    = ""
en_keys       = "" \
                "uj"
other_keys_mm = "ju"

Merge mode

Unfortunately, in order to completely abandon the merge mode, we need to know the name of the keyboard layout when a key is pressed in a message for the program. It is assumed that this requires a modification of the Linux kernel and keyboard modules. But this would forever solve the input issue for all future console applications in any languages.

ranger_keybord's People

Contributors

mrgoodvin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ranger_keybord's Issues

Crash in Fedora 32, Xterm

Operating system and version: Fedora 32 x86_64
Terminal emulator and version: xterm
ranger version: ranger 1.9.2
Python version: 3.8.2 (default, Feb 28 2020, 00:00:00) [GCC 10.0.1 20200216 (Red Hat 10.0.1-0.8)]
Locale: ru_RU.UTF-8
Current file: '/home/f32/.xsession-errors'

Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/ranger/core/main.py", line 195, in main
fm.loop()
File "/usr/lib/python3.8/site-packages/ranger/core/fm.py", line 400, in loop
ui.handle_input()
File "/home/f32/.config/ranger/plugins/multiple_keyboard.py", line 99, in handle_input
tkeys = key_translate(keys)
File "/home/f32/.config/ranger/plugins/multiple_keyboard.py", line 69, in key_translate
ch = b''.join([bytes.fromhex('{0:X}'.format(i)) for i in keys]).decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 4: unexpected end of data

Crash on Ubuntu 21.10

Honestly, I don't know if I followed the instructions properly as I barely understood them.
I just wanted to remap the number row by adding:

other_keys = '&é"' + "'(-è_çà"
en_keys = '123' + "4567890"

Here is what I got

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/ranger/core/main.py", line 201, in main
fm.loop()
File "/usr/lib/python3/dist-packages/ranger/core/fm.py", line 383, in loop
ui.handle_input()
File "/home/ileca/.config/ranger/plugins/multiple_keyboard.py", line 99, in handle_input
simple_key(keys)
File "/home/ileca/.config/ranger/plugins/multiple_keyboard.py", line 66, in simple_key
if chr(key) in other_keys_mm and not self.console.visible:
NameError: name 'other_keys_mm' is not defined

Ubuntu 21.10
Gnome 40.4.0
Wayland

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.