Re: [Geany-devel] (no subject)

2011-12-02 Thread Frank Lanitz
Am 02.12.2011 01:20, schrieb Lex Trotman:
 On Fri, Dec 2, 2011 at 10:54 AM, Meyer 3m.me...@gmail.com wrote:
 Sure.  I want to be able to select text, and then insert a character (e.g.
 an apostrophe) before and after the selection just by pressing the
 apostrophe key.  Since the normal behavior when a character is pressed while
 text is selected is to delete the text and insert a character, I need to
 know when that happens - then I could undo the delete and insert my
 characters.  If it was two separate events though - delete then insert - I
 won't want to do anything.

 I have it working now, but it seems awfully hackish:  when one of the
 characters I might insert is pressed, I store the current position of the
 cursor and undo the last event.  If the new cursor position is the same
 place as the old one, then it was a overwrite event.  Otherwise, it was
 delete then insert.

 So, any ideas for how I could do this would be much appreciated!
 
 I assume you are writing a plugin.
 
 You should use the keybinding system to capture the apostrophe before
 it goes to scintilla so you can detect and do anything you want.

You could also use editor_nodify signal [1]. E.g. used in GeanyLaTeX
plugin for doing something similar.

Cheers,
Frank

[1]
http://www.geany.org/manual/reference/pluginsignals_8c.html#af601d8beb39bf8082ddd1c09c74ce892

___
Geany-devel mailing list
Geany-devel@uvena.de
https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel


Re: [Geany-devel] (no subject)

2011-12-02 Thread Dimitar Zhekov
On Thu, 1 Dec 2011 14:57:25 -0500
Meyer 3m.me...@gmail.com wrote:

 I have two possible situations that I need to differentiate between
 [...] The first situation is the user deletes selected text by
 overwriting it with a new character.  The second is the user deletes
 selected text by pressing backspace/delete, and then enters a new
 character. [...] how I could accomplish this?

You can't. The underlying scintilla events are identical.

 I want to be able to select text, and then insert a character (e.g.
 an apostrophe) before and after the selection just by pressing the
 apostrophe key.  Since the normal behavior when a character is
 pressed while text is selected is to delete the text and insert a
 character [...]

Ignore keybindings and see extrasel key-press-event.
Remember to check scintilla_get_current() against the widget.

Somebody (nathan@gmail.com Nathan Broadbent?) recently asked
the exactly same question, and probably works on the same thing.
Check the mailing list archive.

-- 
E-gards: Jimmy
___
Geany-devel mailing list
Geany-devel@uvena.de
https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel