The Marked 2 URL Handler
There’s an update to Marked 2 almost ready for release which has an in-app purchase option for full spelling and grammar checking. It also includes completely rewritten memory management and background processing which improves speed and stability (that part will be free to all users). Look for that soon! In the meantime…
Recent versions of Marked 2 have included a URL handler. Rather than expanding the AppleScript library immediately, I’ve focused on allowing more inclusive inter-app operability with url commands that can easily be used with launchers such as LaunchBar and Alfred, called from the command line or any script with the open command, or used as links.
The url handler can load files, send text to temporary previews, force refreshes on a single window or all windows, change the preview style, and even reposition windows.
The initial documentation is on the Marked 2 site (and in the internal help). The protocol for the handler is
marked://, followed by the command you want to call. For example, to refresh every open window from the command line or a script, you can use:
If you pass a
?file= parameter with that url, you can target a specific window. While the
open command requires a full path, commands that target a window (refresh, style, etc.) only need a partial match; Marked will refresh whichever window’s filename best matches the path given.
Points of interest:
opencommand can accept an additional
x-successparameter, which can call any other app that has a url handler upon completion of the command
?file=parameter, but calling it with just a path works as well:
marked://open/~/nvALT2.2(also note that because that path is a directory, Marked will open it as a folder watcher and show the most recent file, updating as that changes)
previewcommands can be used to create temporary preview windows using text from the clipboard or passed in the
- Most commands can include a
frameparameter (not documented yet) which accepts 4 numbers separated by commas (or
NSStringFromRect()), defining top left corner distance from left of display, top left corner distance from top of display, window width, and window height for the target preview window
displayparameter can be used to force multi-display setups to target a specific monitor, numbered beginning at 0
- If the parameters also include
&framePosition=right, the window will be positioned to the left or right of the given frame (if possible within screen dimensions), allowing you to pass the frame of another window and have Marked move its preview based on that window’s position
As an example of the url handler in action, I’ve created two simple System Services you can download below. One for previewing the clipboard in Marked, and one for selected text. Both open a temporary preview window (which you can chose to save as a permanent file if needed), and if you set up keyboard shortcuts for them, they demonstrate the usefulness and flexibility of the handler.
There are additional handlers that will be documented soon. The
Check out Marked 2 at marked2app.com!
Marked Selection Services v1
Download Marked Selection Services v1
Services for opening selections and clipboard contents in Marked
Updated 05/29/15. Changelog