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
5454 return "__keybinding" .. tostring(message_id)
5555 end
5656
57−local function dispatch_key_binding(name, state, key_name)
57+local function dispatch_key_binding(name, state, key_name, key_text)
5858 local fn = dispatch_key_bindings[name]
5959 if fn then
60− fn(name, state, key_name)
60+ fn(name, state, key_name, key_text)
6161 end
6262 end
6363
@@ -176,11 +176,15 @@ local function add_binding(attrs, key, name, fn, rp) · 112 unmodified lines
176176 ["r"] = "repeat",
177177 ["p"] = "press",
178178 }
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
180183 fn({
181184 event = key_states[state:sub(1, 1)] or "unknown",
182185 is_mouse = state:sub(2, 2) == "m",
183186 key_name = key_name,
187+ key_text = key_text,
184188 })
185189 end
186190 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