I'm seeking a little aid in getting started on some features I'm looking to add into Mori. I don't expect anyone to do the work for me, but I would love some aid in getting started.
Firstly, let me say that I am quite new to Cocoa (though not to programming) so I apologize if I miss basic things I should know. Also let me say that I adore the simplicity of the Hog Bay software I've just started using.
Let me explain my goals for these features, as they are very simple:
1) Wiki style formatting on the fly
I will be using Mori for taking notes in meetings and classes primarily, and I wish to be able to format a header on my notes simply by adding specific characters to the beginning of a line. For instance, any line beginning with '=' would be made into a pre-defined font and size when the return key is pressed.
2) Entry Dating (less important)
I also want to change the behavior of a new entry to have its name set to the current date by default (instead of 'untitled') for my ease of use.
My focus is primarily #1, as it will save me the most time when taking notes, and provide me with the rich text presentation to aid my review of the notes while still editing.
Now, onto my plans for implementing this. I recently wrote an applescript for TextEdit which parses the open document for these format characters, but I failed miserably at attempting the same thing via applescript in Mori. This also was not a real time solution, as I would need to run the script manually on a regular basis, thus failing at the entire point of the project (to keep from needing to format using the mouse and menus).
I've come to the realization that the best solution probably involves writing a plugin to do these things. I will obviously need to become acquainted with the Blocks plugin framework, but the real reason for this post is a plausibility check and perhaps some starting points / suggestions.
Let me know if you have any suggestions or see any major flaws that could mean a brick wall for me.
I'm pretty sure that what
I'm pretty sure that what you want to do is possible with Mori/Blocks plugins
#2 is going to be the easier of the two. You could get started by looking at the MIEntryDelegateProtocol. By implementing an object with this protocol you can watch for changes in Mori entries (this is what the mGTD plugin does.) You could wait until an entry is created (maybe watching for a creation date to be set.) and if the title is nil, then set the title to the date. (The Date Time plugin I wrote can give you some pointers for working with the dates in Cocoa.)
#1 is going to be harder because you want to do it "on the fly," meaning that your plugin is going to have to continually monitor what's going on in the text field to catch when it should format something. If you don't mind using a keyboard shortcut to 'activate' the formatting, you should take a look at Gordon's Mori Math plugin, which does a good job of this. Otherwise, I would suggest that some hints to what you want to do might be found in how Mori recognizes URLs automatically. Search the Mori project code for the 'FindLink' method. Maybe what you're planning won't be as difficult because you only have to check when the return key is pressed--that should cut down on overhead.
Do you know of other programs that are able to format text on the fly based on Wiki syntax? Most I've seen, have two separate modes: display and edit.
Another option would be to use a given markup syntax (markdown, multimarkdown, textile) and then have your plugin feed the current note through one of their structured text -> formatted text processors. You could batch process each note as you finish writing it. (You could try this out kind of workflow by adding a keyboard shortcut to your applescript, so that it runs on the current note's contents. That would at least keep your hands off the mouse and menus. If you post your script, I'm sure Jesse or others could help you get it working with Mori.)