-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bindable action for character insert/typing? #1130
Comments
Adding to this on this, |
Hi, Reviewing the open issues with inserting characters, can I suggest a Lua function: function Insert(Current,item)
if type(item)=="string" then
Current.Cursor:DeleteSelection()
Current.Buf:Insert(editor_GetTextLoc(Current), item)
end
end
-- Dependent upon:
function editor_GetTextLoc(Current)
-- Returns Loc-tuple w/ current marked text or whole line (begin, end)
-- From https://github.com/NicolaiSoeborg/manipulator-plugin/blob/master/manipulator.lua
local a, b = nil, nil
if editor.HasSelection(Current) then
if Current.Cursor.CurSelection[1]:GreaterThan(-Current.Cursor.CurSelection[2]) then
a, b = Current.Cursor.CurSelection[2], Current.Cursor.CurSelection[1]
else
a, b = Current.Cursor.CurSelection[1], Current.Cursor.CurSelection[2]
end
else
local eol = string.len(Current.Buf:Line(Current.Cursor.Loc.Y))
a, b = Current.Cursor.Loc, buffer.Loc(eol, Current.Cursor.Y)
end
return buffer.Loc(a.X, a.Y), buffer.Loc(b.X, b.Y)
end This can be used with spaces (" "), tabs ("\t"), newline ("\n") or any string. Lua functions are bound in the usual way - depending upon which file you store them inside. However, Lua functions will not work with multicursor selections, unlike proper Go actions defined in the source - which execute at each cursor. Hope this helps and we can close these issues? Kind Regards Gavin Holt |
There are bindable actions like
but I could not find anything like
InsertCharacter
that would work for typing anything other than space, tabs and newlines? Is there a suitable event I don't see yet or could something like this be added?The text was updated successfully, but these errors were encountered: