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

From: Mitchell <m.att.foicica.com>
Date: Wed, 27 Mar 2019 09:12:06 -0400 (EDT)

Hi Julien,

On Wed, 27 Mar 2019, Julien L. wrote:

> Hello Mitchell,
>
> I thank you for your answer.
>
> > 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.
>
> This is a good point.
>
> Here is my proposed version of the workaround :
> local problematicKeys = {
> [string.byte(",")] = ",",
> [string.byte("/")] = "/"
> }
>
> events.connect(events.KEYPRESS, function(code, shift, control, alt, meta)
> local char = problematicKeys[code]
> if char and not shift and not control and not alt and not meta then
> if buffer.selection_empty then
> buffer:add_text(char)
> else
> buffer:replace_sel(char)
> end
> return true -- do not propagate this key further
> end
> end)
>
> I have been tested it for a couple of days and it seems to work fine, except for multiple and rectangular selections. I looked in the API on how to do that but I did not see how. Unless there is an easy solution, the current solution is enough for me.

There is no easy solution to multiple and rectangular selection. Multiple selection would involve iterating through each selection, inserting or replacing text, and then restoring all selections. There'd be some math involved with selection positions for each subsequent selection. It's doable, but tricky. As for rectangular selection, I'm not quite sure how that would be done.

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 Wed 27 Mar 2019 - 09:12:06 EDT

This archive was generated by hypermail 2.2.0 : Thu 28 Mar 2019 - 06:37:37 EDT