Open suhr opened 11 years ago
Probably adding the character codes of these letters to Textadept's KEYSYMS
table could work.
E.g., in your ~/.textadept/init.lua
:
_G.keys.KEYSYMS[number] = char
http://foicica.com/textadept/api/keys.html#KEYSYMS
KEYSYMS Lookup table for string representations of key codes higher than 255. Key codes can be identified by temporarily uncommenting the print() statements in core/keys.lua.
Probably adding the character codes of these letters to Textadept's
KEYSYMS
table could work.E.g., in your
~/.textadept/init.lua
:_G.keys.KEYSYMS[number] = char
http://foicica.com/textadept/api/keys.html#KEYSYMS
KEYSYMS Lookup table for string representations of key codes higher than 255. Key codes can be identified by temporarily uncommenting the print() statements in core/keys.lua.
Can confirm it works. With a minor glitch though - you should delete russian letters twice (cause of letter size, I guess).
@suhr, you are welcome to checkout my gist for russian layout - second part is for textredux.
P.S. I hope this helps someone even 8 years later... it helped me though :smiley_cat:
Many thanks for sharing your gist, this topic has come up (also in Textadept) a couple of times over the years.
Maybe there is a better solution possible (Lua's utf8
gives some UTF-8 capabilities) in general. Having to handle this differently for Textadept and Textredux is certainly not optimal.
As for the the back-deleting, there should be a way to check if it's a UTF-8 2-byte character
In core/list.lua
:
listbuffer.keys['\b'] = function()
local search = self.get_current_search(self)
if search then self.set_current_search(self, search:sub(1, #search - 1)) end
end
Maybe using utf8.len
http://www.lua.org/manual/5.4/manual.html#6.5
And maybe there is a better solution in genreal using the utf8
module from Lua.
It's used in a couple of places in Textadept: https://github.com/search?q=utf8+path%3Amodules%2Ftextadept+repo%3Aorbitalquark%2Ftextadept+language%3ALua+language%3ALua&type=Code&ref=advsearch&l=Lua&l=Lua
Does the Command Entry work with your keyboard layout? If yes, this could be a direction to use with Textredux.
Textadept's modules/textadept/keys.lua
:
-- Other.
-- UTF-8 input.
[function()
ui.command_entry.run(
function(code) buffer:add_text(utf8.char(tonumber(code, 16))) end)
end] = {nil, 'cmd+U', 'meta+u'}
}
Yes, the Command Entry works in russian (I mean, it handles the input). So I see we can use this utf8
library in Textredux too, but can't promise anything right now. Anyway, thanks for possible direction to fix this properly.
So a quick test seemed to work for me, in buffer.lua
:
events.connect(events.CHAR_ADDED, function(code)
local _textredux = buffer._textredux
if not _textredux then return end
if _textredux.on_char_added then
local char = utf8.char(code)
if char ~= nil then
_textredux.on_char_added(char)
end
end
end)
This will probably require some more testing ... but if you can give it a try that would be good (if you have the time).
File browser filters list by latin input, but doesn't ever respond on non-latin (e.g russian) one.