Skip to content
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

File browser doesn't handle non-latin input #5

Open
suhr opened this issue Jun 10, 2013 · 5 comments
Open

File browser doesn't handle non-latin input #5

suhr opened this issue Jun 10, 2013 · 5 comments

Comments

@suhr
Copy link

suhr commented Jun 10, 2013

File browser filters list by latin input, but doesn't ever respond on non-latin (e.g russian) one.

@rgieseke
Copy link
Owner

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.

@ioplker
Copy link
Contributor

ioplker commented Mar 8, 2021

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).
image
image
image

@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 😺

ioplker added a commit to ioplker/textredux that referenced this issue Mar 8, 2021
If char is not registered in Textadept (e.g. russian by default aren't rgieseke#5) the error breaks the workflow - especially when you work in several views (it changes focus to other view).
@rgieseke
Copy link
Owner

rgieseke commented Mar 8, 2021

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'}
}

@ioplker
Copy link
Contributor

ioplker commented Mar 10, 2021

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.

@rgieseke
Copy link
Owner

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants