Author Topic: event in codeblocks being sent on a "undo" or "redo" command  (Read 5513 times)

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Hi everybody,

is there an event in c::b which is emitted when the user calls the "undo" or "redo" functionality either by tool button or menu? I looked around in the forum and in the source code of c::b and didn't find anything ( which doesn't mean that there may be none  :) ). Such an event would come in handy for instance for a plugin to notice that there was a change in the active editor and adapt accordingly.

Regards

frithjofh
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5917
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: event in codeblocks being sent on a "undo" or "redo" command
« Reply #1 on: May 27, 2010, 01:33:31 am »
I think the cbEVT_EDITOR_UPDATE_UI event is the right event you want.
see the posts around Re: A feature request about CC and BrowseTracker
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Re: event in codeblocks being sent on a "undo" or "redo" command
« Reply #2 on: May 27, 2010, 10:09:06 am »
HI, and thank you for the answer.

Isn't the cbEVT_EDITOR_UPDATE fired everytime any change happens in the editor, even if somebody adds a whitespace? If some body writes a word, it gets fired for every char written, right? Doesn't that mean really a lot of traffic if I use it in a plugin? I mean additional traffic to the c::b app if the plugin does some calculating, checking or parsing of the editors contents on every cbEVT_EDITOR_UPDATE. Scares me a bit ...

But I'll give it a try  :D and see what happens. If this is the way to do it ...

Regards

frithjofh
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5917
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: event in codeblocks being sent on a "undo" or "redo" command
« Reply #3 on: May 27, 2010, 10:14:16 am »
Quote
Isn't the cbEVT_EDITOR_UPDATE fired everytime any change happens in the editor, even if somebody adds a whitespace?

I think it is. But you can check the scintilla document(this message is send from the scintilla control, cb just do a wrapper) for more information. Currently, this event is used to record the "edit position" in the browser tracker plugin. :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: event in codeblocks being sent on a "undo" or "redo" command
« Reply #4 on: May 27, 2010, 12:19:35 pm »
wxScintilla sends the wxEVT_SCI_MODIFIED.
This event should be send with notification-type wxSCI_PERFORMED_UNDO or wxSCI_PERFORMED_REDO if an undo or redo is done.

See wxScintilla.h for the notification-types and cbEditor::OnEditorModified(wxScintillaEvent& event) for an example how to filter the notification-type.

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Re: event in codeblocks being sent on a "undo" or "redo" command
« Reply #5 on: May 27, 2010, 12:37:51 pm »
Thank you very much for these hints. I remember looking over these files but I guess I got lost in code ... :?

By the way: that new release of c::b, does it already have some schedule for shipping?

regards

frithjofh
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100