From: Jeroen v. d. Z. <jv...@cf...> - 2000-11-21 19:16:18
|
On Tue, 21 Nov 2000, you wrote: > > > I am confused now. Your original announcement stated *brace* > > > matching had been added (with an implication that block begin/end > > > were delimited with braces), but now you are referring to > > > *parenthesis* matching. Which did you really mean: brace or parenthesis? > > > > Its the same algorithm. Internally, the character to be matched is simply > > plugged in as a parameter, so the same chunk of code can be used to match > > braces {}, brackets [], parenthese (), and angle brackets < >. > > More specifically, he's just added a new message that FXText understands > (FXText::ID_GOTO_MATCHING) and supporting functions to change the cursor > position to the matching position. For example, if the cursor is currently > sitting at an open brace "{" and you send the FXText object the > ID_GOTO_MATCHING message, it should jump to the matching close brace "}". It > inspects the character at the current position and tries to find its match, > so it actually works for several kinds of characters -- see the > FXText::findMatching() function for the whole story. > > If you never send this message to FXText, the code never gets invoked. [A > C++ editor application would therefore hook up some menu command or hotkey > to send this message to the text.] Yes, often, Lyle says it better. Basically, the idea is that you create some accelerators [or pulldown menus] which simply send FXText the right message. You can therefore take advantage of these new features quite simply: new FXMenuCommand(searchmenu,"Goto matching",NULL,editor,FXText::ID_GOTO_MATCHING); The above was excerpted from FOX TextEdit. Note, and this is cool (it really is), you get to decide what accelerator invokes the behaviour, and whether it makes sense in your particular application to have this function. I have not discussed this before, but TextEdit also has (unlimited, but limitable) undo/redo capabilities. If you need such behavior in your own app, feel free to grab TextCommand.{h,cpp} out of the textedit directory. There is an underlying philosophy behind FOX's Undo System: 1) There should be *one* single undo/redo list for the entire application. This means we will not build in the undo / redo list into all the FOX widgets themselves, but we try to make it fairly easy to hook up a widget to your central undo/redo list by having the widgets send the appropriate messages. If your app is a multiple-document app, of course you would want to keep one undo list for each document. 2) The class FXUndoList can directly receive messages, so you can simply hook up a button to the undo list object as follows: new FXMenuCommand(editmenu,"Undo",undoicon,&undolist,FXUndoList::ID_UNDO); new FXMenuCommand(editmenu,"Redo",redoicon,&undolist,FXUndoList::ID_REDO); This is in keeping with FOX's "no glue code" philosophy. 3) Widgets send messages like SEL_INSERTED, SEL_REPLACED, and SEL_DELETED. For FXText, for example, you can catch SEL_DELETED to grab the about-to-be deleted text and store it into an undo record. 4) The List widgets (FXList, FXTreeList, FXIconList also send SEL_INSERTED and SEL_DELETED messages. It should be fairly straightforward to hook actions on these widgets into your undo system (e.g. obtain the user data pointer from the list item and store it in your undo record). 5) Since we have only recently developed this as "the way things are done" I still have to implement this for FXTable, but it is my intention to do it there too. Hopefully, this gives people a lot of ideas. Should you have some great suggestions to make it even better, feel free to vent your opinion on the mailing list. Regards, Jeroen -- +-------------------------------+--------------------------------------------+ | E-Mail : jv...@cf... | The FOX Platform Independent GUI Toolkit: | | USMail : 215 Wynn Drive, | | | Huntsville, AL 35805 | Official Site: | | Phone : (256) 726-4820 | http://www.cfdrc.com/FOX/fox.html | | Fax : (256) 726-4806 | ftp://ftp.cfdrc.com/pub/FOX | | WWW : http://www.cfdrc.com | | +-------------------------------+--------------------------------------------+ | Copyright (C) 11:20 11/21/2000 Jeroen van der Zijp. All Rights Reserved. | +----------------------------------------------------------------------------+ |