From kirt.fitzpatrick at gmail.com Fri Mar 28 17:55:55 2008 From: kirt.fitzpatrick at gmail.com (Kirt Fitzpatrick) Date: Fri, 28 Mar 2008 10:55:55 -0700 Subject: [TxMt Plugins] Text Buffer, Word Characters, Undo, Find, and Macro questions Message-ID: <6928C7B1-8051-4A17-AE1C-30C9D6A3463B@gmail.com> Several months ago I decided that I was going to hold off further development of ViMate until version two of TextMate came out and a documented plugin API was made available. Since version two is being compared to Duke Nukem Forever I probably shouldn't wait. I apologize if any of these are noob Cocoa questions. I use vi on OS X, I'm either a die-hard or a Cocoa-noob. Probably both. ;-) Word Movement: I believe that I need to get access to the text buffer and some list of word and non-word characters so that I can move by word properly. Right now I am using the moveWordForward, moveWordBackwardAndModifySelection... methods to accomplish this but they are inadequate especially near boundaries such as the end of line or end of file. Moving by word will switch from jumping to the beginning of words to jumping to the end of words and back. It's a crap-shoot and is the cause of most of the bugs in the ViMate plugin. Is there a way for me to get access to a list of known word/non-word characters known by TextMate as well as the text buffer and current position so I can implement my own movement and selection commands? Undo: I reworked the ViMate plugin a while back to perform complex edits in a manner that would look to TextMate like one edit and therefore would undo easily without any hacking on the undo manager. Now I need to hook the 'u' command to the built in Undo functionality. How would I do that? Find: vi has the * command that will search and highlight all occurrences of the current word in a file. This is incredibly useful when tracing through code and checking for typographical errors. How do I hook into the Find functionality programatically? Is there a built in way for me to highlight each occurrence of a word at the same time without bringing up the find dialog? Macros: I would like to hook 'q' up to the built in macro recording. Again, where can I find that? kirt From throw-away-2 at macromates.com Sat Mar 29 14:36:50 2008 From: throw-away-2 at macromates.com (Allan Odgaard) Date: Sat, 29 Mar 2008 15:36:50 +0100 Subject: [TxMt Plugins] Text Buffer, Word Characters, Undo, Find, and Macro questions In-Reply-To: <6928C7B1-8051-4A17-AE1C-30C9D6A3463B@gmail.com> References: <6928C7B1-8051-4A17-AE1C-30C9D6A3463B@gmail.com> Message-ID: <3FF5C4A8-8E29-4585-B725-19BE55BDD9CF@macromates.com> On 28 Mar 2008, at 18:55, Kirt Fitzpatrick wrote: > Several months ago I decided that I was going to hold off further > development of ViMate until version two of TextMate came out and a > documented plugin API was made available. Since version two is > being compared to Duke Nukem Forever I probably shouldn't wait. While I still want to downplay any potential release, I am using TM 2 myself now for most stuff. So chances for a beta before summer are good. When a beta is out, I will gladly work a little closer with you to make a functional ViMate plug-in. And anyone who writes me in N months to ask on status for the above can be certain to be excluded from any potential beta program :p > Word Movement: > [...] There really isn’t much more than the NSTextInput protocol to work with here and the string/selection methods (which return the contents as a string). Personally not overly optimistic about the feasibility of this for 1.x. > Undo: > I reworked the ViMate plugin a while back to perform complex edits > in a manner that would look to TextMate like one edit and therefore > would undo easily without any hacking on the undo manager. Now I > need to hook the 'u' command to the built in Undo functionality. > How would I do that? Not sure what you have done to achieve this. Calling undo: doesn’t work? > Find: > vi has the * command that will search and highlight all occurrences > of the current word in a file. This is incredibly useful when > tracing through code and checking for typographical errors. How do > I hook into the Find functionality programatically? Is there a > built in way for me to highlight each occurrence of a word at the > same time without bringing up the find dialog? You can use findNext: to find next occurrence on the find pasteboard (see NSPPasteboard), but highlighting multiple segments is not possible. > Macros: > I would like to hook 'q' up to the built in macro recording. Again, > where can I find that? There are action methods for toggling macro recording and replaying the scratch macro. Probably the easiest way is to open the MainMenu.nib file and look at what the menus are setup to call (I can’t remember off hand).