History

input: add text produced by key to script key events

Particularly for "any_unicode" mappings, so they don't have to special-case keys like '#' and ' ', which are normally mapped to symbolic names for input.conf reasons. (Though admittedly, this is a pretty minor thing, since API users could map these manually.)

wm4 committed 6 years ago

Commit 21f24681 parent eab54577 files · +32 −7Browse files

Showing the changes to player/lua/defaults.lua (1 of 7 files). Show all

Unified · Split

player/lua/defaults.lua+7−3
@@ -54,10 +54,10 @@ local function reserve_binding() · 53 unmodified lines
54 return "__keybinding" .. tostring(message_id)54 return "__keybinding" .. tostring(message_id)
55end55end
56 56
57local function dispatch_key_binding(name, state, key_name)57local function dispatch_key_binding(name, state, key_name, key_text)
58 local fn = dispatch_key_bindings[name]58 local fn = dispatch_key_bindings[name]
59 if fn then59 if fn then
60 fn(name, state, key_name)60 fn(name, state, key_name, key_text)
61 end61 end
62end62end
63 63
@@ -176,11 +176,15 @@ local function add_binding(attrs, key, name, fn, rp) · 112 unmodified lines
176 ["r"] = "repeat",176 ["r"] = "repeat",
177 ["p"] = "press",177 ["p"] = "press",
178 }178 }
179 key_cb = function(name, state, key_name)179 key_cb = function(name, state, key_name, key_text)
180 if key_text == "" then
181 key_text = nil
182 end
180 fn({183 fn({
181 event = key_states[state:sub(1, 1)] or "unknown",184 event = key_states[state:sub(1, 1)] or "unknown",
182 is_mouse = state:sub(2, 2) == "m",185 is_mouse = state:sub(2, 2) == "m",
183 key_name = key_name,186 key_name = key_name,
187 key_text = key_text,
184 })188 })
185 end189 end
186 msg_cb = function()190 msg_cb = function()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t