Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3.  
  4. # Meta Keys:
  5. # The ECMA-35 standard prefixes control sequences containing a high
  6. # eighth-bit with <Esc> to disambiguate from unicode input, which also
  7. # utilizes a high eigth-bit (overlapping ranges). This necessitates
  8. # the use of timings to differentiate and <Esc>-prefixes control
  9. # sequence and <Esc> preceding unrelated keys. Unfortunately the
  10. # timing mechanism is unable to differentiate between macros and
  11. # bindings from actual control sequences as in all cases timing is
  12. # near-zero. Furthermore programs without accurate timers break
  13. # unexpectedly and often randomly, such as vim. Neovim can be
  14. # configured without any breakage, as can tmux. However it is simpler
  15. # - if willing to forego working unicode input - to simply disble
  16. # ECMA-35 and send meta-sequences as eight-bit high.
  17. # Unfortunately URxvt simply passes eight-bit high control-sequences
  18. # untouched, letting higher layers assume they are the beginning of
  19. # unicode byte-sequences. This breaks these sequences. XTerm avoids
  20. # this ambiguity by automatically converting the eight-bit high
  21. # control sequence to appropriate byte sequences using the current
  22. # locale. URxvt can be harcoded to mimic this behaviour, but not in a
  23. # locale-independent fashion. If locales change, the following
  24. # bindings will be broken.
  25. # Summary:
  26. # * Specific to the current locale
  27. # * Breaks UTF-8 input
  28.  
  29. read -r -d '' PyURxvtMeta8 <<-'EOF'
  30. #!/usr/bin/env python3
  31.  
  32. import locale
  33.  
  34. locale.setlocale(locale.LC_ALL, "")
  35. encoding = locale.getlocale()[1]
  36.  
  37. # ASCII range
  38. for i in range(32, 128):
  39. seq = "".join("\{:o}".format(j) for j in chr(i + (1<<7)).encode(encoding))
  40. key = "{:#06X}".format(i)
  41. print("urxvt*keysym.Meta-{}: {}".format(key, seq))
  42. EOF
  43.  
  44. xrdb -merge <(python3 <<<"$PyURxvtMeta8")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement