RE: [code] [textadept] Issue with BÉPO keyboard layout on Win32

From: Mitchell <m.att.foicica.com>
Date: Mon, 11 Mar 2019 11:13:07 -0400 (EDT)

Hi Julien,

On Mon, 11 Mar 2019, Julien L. wrote:

> Hello Mitchell,
>
> Le 08/03/19 à 06:46, Mitchell a écrit :
>> It is unfortunate that it's a GTK issue. Thank you for taking the time
>> to identify it though. I wonder if you could work around this by
>> trying to put the following in your *~/.textadept/init.lua*:
>>
>> events.connect(events.KEYPRESS, function(code, shift, control, alt,
>> meta)
>> if code == string.char(',') and not shift and not control and not
>> alt and not meta then
>> buffer:add_text(',')
>> return true -- do not propagate this key further
>> end
>> end)
> The workaround seems to work fine! Thank you very much for it!
> Though it provoked an error. I had to replace “code == string.char(',')”
> by “code == string.byte(',')” (unless you wanted to write
> “string.char(code) == ','”).

I always get `string.char()` and `string.byte()` confused. Thanks for catching that.

>> If this works, I can help you come up with a more robust handler for
>> this key. Hopefully it's the only one and you wouldn't have to add a
>> similar handler for more keys.
> The issue also occurs for the slash key ('/'). I think that I will be
> able to adapt the workaround for this key as well.
>
> I posted a message to the creators of the BÉPO layout in order to
> understand what special these two keys are.
>
> What do you mean by “a more robust handler”?

The example handler I gave was very basic. It only adds characters. If you have text selected, the expected behavior when typing a key is to replace the selection with the typed character. Similarly, when multiple selections are active, the handler I gave you would only add a character at the current selection instead of all of them.

A starting point might be:

   events.connect(events.KEYPRESS, function(code, shift, control, alt, meta)
     if code == string.char(',') and not shift and not control and not alt and not meta then
       if buffer.selection_empty then
         buffer:add_text(',')
       else
         buffer:replace_sel(',')
       end
       return true -- do not propagate this key further
     end
   end)

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Mon 11 Mar 2019 - 11:13:07 EDT

This archive was generated by hypermail 2.2.0 : Tue 12 Mar 2019 - 06:45:24 EDT