inputtext: add access methods for internal character list

This allows for InputText wrappers (namely the Japanese keyboard which
needs to be able to apply modifiers to the character before the cursor)
to nicely access the character list.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
reviewable/pr8432/r1
Aleksa Sarai 3 years ago committed by poire-z
parent ac907df634
commit cb702fb062

@ -707,6 +707,20 @@ function InputText:searchString(str, case_sensitive, start_pos)
return char_pos
end
--- Return the character at the given offset. If is_absolute is truthy then the
-- offset is the absolute position, otherwise the offset is added to the current
-- cursor position (negative offsets are allowed).
function InputText:getChar(offset, is_absolute)
local idx
if is_absolute then
idx = offset
else
idx = self.charpos + offset
end
if idx < 1 or idx > #self.charlist then return end
return self.charlist[idx]
end
function InputText:addChars(chars)
if not chars then
-- VirtualKeyboard:addChar(key) gave us 'nil' once (?!)

Loading…
Cancel
Save