will8211 / unimatrix

Python script to simulate the display from "The Matrix" in terminal. Uses half-width katakana unicode characters by default, but can use custom character sets. Accepts keyboard controls while running. Based on CMatrix.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting background colors using non-QWERTY keyboard

pylipp opened this issue · comments

commented

The keys for switching background color are based on the QWERTY-layout:

unimatrix/unimatrix.py

Lines 508 to 525 in cd04928

elif kp == ord('!'):
self.set_bg_color('Green')
elif kp == ord('@'):
self.set_bg_color('Red')
elif kp == ord('#'):
self.set_bg_color('Blue')
elif kp == ord('$'):
self.set_bg_color('White')
elif kp == ord('%'):
self.set_bg_color('Yellow')
elif kp == ord('^'):
self.set_bg_color('Cyan')
elif kp == ord('&'):
self.set_bg_color('Magenta')
elif kp == ord('*'):
self.set_bg_color('Black')
elif kp == ord('('):
self.set_bg_color('default')

For me (QWERTZ-user), the corresponding row is !"§$%&/(). Is it easy to detect the actual ID of the key being pressed rather than the symbol mapped to it? Expanding the current mapping does not make sense because f.i. ( is on the German 8 but on the English 9.

Anyways, not a big deal because I probably won't be switching colors all day long.

Interesting, hadn't thought about that. Let me look into it!

Well, looks like an easy fix would be to add the three characters " § / as alternatives, since they're not used anyway. This would help for French Canadian keyboards as well!
Looking at the differences more closely, this won't work. Also, it seems that curses can only see the final output of SHIFT combinations. How about 'g' to cycle though background colors (and 'f' for foreground colors.) Then people around the word can switch background colors all day long!

OR... the ALT key would work.

For example, Alt-1 and Alt-2 look like '1[' and '2[' to the curses 'get character' function. These would map correctly on any keyboard. The only problem is that people might have these combinations already set to do something in their window manager or terminal...

commented

These are some valuable thoughts! I like the g/f cycling option very much (I think few remember what key maps to whichever color anyways). And using the Alt key might indeed interfer with some peoples workflow (I think gnome-terminal uses Alt-; people could have it as their WM modifier etc...)

Maybe use c/C key for cycling however, because f toggles flashers? Do you want me to do a PR?