My Quest to Add My Own Features

Tags ( )

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.)

Thanks

Thanks for the reply BMEguy!

Yes, I don't expect #2 will give me much trouble once I've found my way around in the source. Thanks for the pointers as to where I should start on that.

As for #1, let me clarify a little bit: No program that I know of does this sort of formatting, this is just me attempting to create my own standard for quick formatting. The goal here is to have the ease of entry of never needing to stop the flow of typing to format but with the benefits of having formatted headers. I planned on having it process the format changes when return was pressed because it does make the most sense to cut down on overhead, and there is no real reason to do it before that.

I had also been working on my own very basic text editor with this feature using the starting point of this example code from apple:
http://developer.apple.com/samplecode/TextViewDelegate/index.html

As far as messing with the script goes, I figure it is worth my while to slowly work on this project to reach the ideal situation for editing I envision. Currently I still just take notes in plaintext with no formatting, and I will be fine with that until I make this work well. I've also been slowly digging into creating a service that could provide such features in any rich text editor on OS X, but I figure I'll work this part of it out first so I can actually use it for course notes.

-Ho0ber

Do you have access to Mori's

Do you have access to Mori's source yet? Even though Mori has a plugin architecture it doesn't have much documentation, so in general plugin writers will want to be looking at Mori's sources to see how (and debug) things work as they write their plugin.

If you don't have access to Mori's sources email me.

For number #2 yes I think it should be fairly strait forward if you use the MIEntryDelegateProtocol. But I think you might actually need to add anther callback to that protocol (something like entryJustCreated) and have your plugin set the title their. Once you get a basic plugin working that extends from the MIEntryDelegateProtocol I can help you add that callback.

For #1 I think the easiest way to do things is to add your changes directly to the core Mori user interface plugin. Ie edit mori's code directly and don't create your own plugin. The place to do this would be in MITextStorageSyntaxtHighlightingController. I think I have some wiki syntax highlighting code hanging around from Hog Bay Notebook so that might get you started. But you still might run into some tricky issues... I can't remember why I haven't added that feature myself, except that I think I ran into a problem when I tried to just copy paste the Hog Bay Notebook code into Mori.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.