aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2026-04-01 12:50:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2026-04-01 12:50:04 -0700
commit21ac634c5a0ba60c7313bea602dcbd16912894a7 (patch)
tree67384faf3ef4c861a58576815121125545f80b2c
parent9d790df53787b6a66a3ac34a9b07c6235f9a04de (diff)
parent8af1e8364716633c352d02dac897a7852e6aaf51 (diff)
downloadtext.love-main.tar.gz
Merge lines.loveHEADmain
-rw-r--r--README.md3
-rw-r--r--keychord.lua10
-rw-r--r--reference.md8
-rw-r--r--source_text.lua11
-rw-r--r--text.lua11
5 files changed, 22 insertions, 21 deletions
diff --git a/README.md b/README.md
index 0887f4a..21630e6 100644
--- a/README.md
+++ b/README.md
@@ -35,6 +35,9 @@ While editing text:
* `ctrl+z` to undo, `ctrl+y` to redo
* `ctrl+=` to zoom in, `ctrl+-` to zoom out, `ctrl+0` to reset zoom
* `alt+right`/`alt+left` to jump to the next/previous word, respectively
+ Only left alt is supported, because many keyboard layouts use right alt like
+ shift for typing characters, and I don't know how to figure out the current
+ layout.
* mouse drag or `shift` + movement to select text, `ctrl+a` to select all
* `ctrl+e` to modify the sources
diff --git a/keychord.lua b/keychord.lua
index e817405..01ab16f 100644
--- a/keychord.lua
+++ b/keychord.lua
@@ -43,15 +43,21 @@ function App.default_modifier(key)
end
end
-function App.any_modifier_down()
- return App.ctrl_down() or App.alt_down() or App.shift_down() or App.cmd_down()
+-- Many keyboard layouts use a special altGr key to insert additional
+-- printable characters. SDL/LÖVE can't represent altGr distinctly.
+function alt_gr_down()
+ return App.key_down('ralt')
end
+-- altGr is a separate modifier and never considered with alt or ctrl,
+-- regardless of layout.
function App.ctrl_down()
+ if alt_gr_down() then return false end
return App.key_down('lctrl') or App.key_down('rctrl')
end
function App.alt_down()
+ if alt_gr_down() then return false end
return App.key_down('lalt') or App.key_down('ralt')
end
diff --git a/reference.md b/reference.md
index 80309c3..0390048 100644
--- a/reference.md
+++ b/reference.md
@@ -92,7 +92,8 @@ automatically called for you as appropriate.
string representation of the current key combination, consisting of the key
with the following prefixes:
* `C-` if one of the `ctrl` keys is pressed,
- * `M-` if one of the `alt` keys is pressed,
+ * `M-` if the left `alt` key is pressed (right alt has other meanings in
+ some keyboard layouts, so we never check for it),
* `S-` if one of the `shift` keys is pressed, and
* `s-` if the `windows`/`cmd`/`super` key is pressed.
@@ -326,10 +327,7 @@ The following facilities help set these things up:
key (arrow keys, page-up/down, home/end)
* `App.cmd_down()`, `App.ctrl_down`, `App.alt_down()`, `App.shift_down()` --
- predicates for different modifier keys.
-
-* `App.any_modifier_down()` -- returns `true` if any of the modifier keys is
- currently pressed.
+ predicates for different modifier keys. `alt_down` only checks for left alt.
* `App.key_down(key)` -- returns `true` if the given key is currently pressed.
(Based on [LÖVE](https://love2d.org/wiki/love.keyboard.isDown).)
diff --git a/source_text.lua b/source_text.lua
index 3a0a941..e884b4b 100644
--- a/source_text.lua
+++ b/source_text.lua
@@ -220,13 +220,10 @@ end
function Text.text_input(State, t)
if App.mouse_down(1) then return end
- if App.any_modifier_down() then
- if App.key_down(t) then
- -- The modifiers didn't change the key. Handle it in keychord_press.
- return
- else
- -- Key mutated by the keyboard layout. Continue below.
- end
+ -- textinput events can occur on chords with the shift key or AltGr key
+ -- but not for ctrl, alt or cmd/super/gui
+ if App.ctrl_down() or App.alt_down() or App.cmd_down() then
+ return
end
local before = snapshot(State, State.cursor1.line)
--? print(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos)
diff --git a/text.lua b/text.lua
index c8a6cbb..1414f60 100644
--- a/text.lua
+++ b/text.lua
@@ -142,13 +142,10 @@ end
function Text.text_input(State, t)
if App.mouse_down(1) then return end
- if App.any_modifier_down() then
- if App.key_down(t) then
- -- The modifiers didn't change the key. Handle it in keychord_press.
- return
- else
- -- Key mutated by the keyboard layout. Continue below.
- end
+ -- textinput events can occur on chords with the shift key or AltGr key
+ -- but not for ctrl, alt or cmd/super/gui
+ if App.ctrl_down() or App.alt_down() or App.cmd_down() then
+ return
end
local before = snapshot(State, State.cursor1.line)
--? print(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos)