Re: [code] ` Follow up

From: Alberto González Palomo <alberto.att.matracas.org>
Date: Wed, 4 Oct 2017 14:50:18 +0200

   Yes, the keypress event should produce two codes, because in the
Spanish keyboard we get the backtick by combining the dead key for the
grave accent with the space.

   The issue here is that the auto_pair insertion uses event.CHAR_ADDED
but typeover_chars uses event.KEYPRESS.
   CHAR_ADDED gets the actual character produced by the input method in
use, while KEYPRESS gets the individual key presses.

   You can see this at "modules/textadept/editing.lua":
https://foicica.com/hg/textadept/file/9c812b9ce0ab/modules/textadept/editing.lua#l124
https://foicica.com/hg/textadept/file/9c812b9ce0ab/modules/textadept/editing.lua#l160

   The solution I'd propose is to use CHAR_ADDED for both cases so that
we always get the actual character.
   Since this event fires after the character has been already inserted
in the document, for typeover_chars instead of cancelling the event we
need to remove the character.
   Additionally, since both actions will be triggered by the same event,
we can unify them to make sure that they run in the right order.

   I attach the corresponding patch.
   I've tested it with a Spanish keyboard, on Ubuntu Linux with TA 9.5.

   It still needs some improvement: the character insertion gets into
the undo history so it behaves a bit different from the original.
   If instead of deleting the inserted char we undid its insertion it
would be perfect, but calling "buffer:undo()" instead of
"buffer:delete_back()" undoes too much.

   I'm now taking a look at SC_MOD_INSERTCHECK [1] from Scintilla which
allows modifying the text about to be inserted, but so far it seems not
to be accessible from Textadept.
[1] http://www.scintilla.org/ScintillaDoc.html#SC_MOD_INSERTCHECK

   Cheers,

-- 
     Alberto González Palomo
     Toledo, España / Saarbrücken, Deutschland
     https://www.matracas.org

-- 
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 04 Oct 2017 - 08:50:18 EDT

This archive was generated by hypermail 2.2.0 : Thu 05 Oct 2017 - 06:47:56 EDT