rxi / lite

A lightweight text editor written in Lua
MIT License
7.34k stars 348 forks source link

Numpad alternate functions do not work #58

Open radiantly opened 4 years ago

radiantly commented 4 years ago

When num lock is off, alternate functions do not work (direction keys, end, home, pgup, pgdown).

Also: really nice editor! Blazingly fast!

rxi commented 4 years ago

I unfortunately lack the hardware to test this myself. Would you be able to add print(k) to the top of the keymap.on_key_pressed(k) function in data/core/keymap.lua and report back what values you get for the keys which don't work as expected? Thanks!

radiantly commented 4 years ago

Here it is:

keypad 0
keypad .
keypad 1
keypad 2
keypad 3
keypad 4
keypad 6
keypad 7
keypad 8
keypad 9

Interestingly, the output is the same when num lock is on.

My keyboard numpad has the same mappings as this one here.

Note: keypad enter does not work either, but it looks like this has been reported in #131

uramer commented 3 years ago

I've made this as a temporary workaround https://github.com/rxi/lite-plugins/pull/90

Tmpod commented 3 years ago

In my current machine (Linux Manjaro + Cinnamon), using xev I get different keys depending on whether the NumLock is active or not. How does lite get the keypresses?

uramer commented 3 years ago

@Tmpod I'm running Windows 10. for me numpad doesn't react to numlock. I haven't looked at the code, but I assume lite uses SDL events.

Tmpod commented 3 years ago

Looking at this resource, it seems SDL doesn't aknowledge function keys from the keypad... :/

I guess the workaround it to have lite keep track of the numlock state itself, but that sounds really bad lol

uramer commented 3 years ago

@Tmpod there is an SDL function to get the current numlock state with the current design, it would just mean passing that value into key press events, and mapping some keys (the way I've done) based on it

Tmpod commented 3 years ago

Yep, that sounds about right. We'd have to change system.c I suppose? I have to take a better look at the C part of lite.

uramer commented 3 years ago

Yep, pass that value from system.c to here https://github.com/rxi/lite/blob/7517d0ef552c89cc24e0589a8df8eb9648217e24/data/core/init.lua#L325