MacArachnophilia

MacArachnophilia: Using Arachnophilia on Mac OS X

Arachnophilia is a configurable programming editor with special HTML editing features. Written by Paul Lutus in Java, the program is highly portable but not extensively tested on Mac OS X. At the same time, like his well-regarded AppleWriter II, Arachnophilia is extremely flexible. Here are some suggestions on adapting the program to the Mac.

Don't quit:

Don't quit the program from the application's menu or type ⌘-Q, Arachnophilia won't have a chance to save any changes to the configuration file(s). They will be lost. Instead use the [ExitApp] macro. There's even a nice icon named Exit.gif.

Modifiers ⌘ & ^:

The default keyboard modifier for many commands is ^ (control). Any shortcut key can include ⌘ (command on the Mac; meta on the JVM), but the unmodified key replaces the current selection in the editor pane. This precludes using printable keys with the command modifier, but function keys work fine. Use the Define button to change the shortcut in the macro editor or in the macro configuration file: ~/.Arachnophilia/Macros/Macros.xml. In the latter, the first parameter is the JVM KeyEvent code; the second is the modifier (InputEvent.META_MASK + InputEvent.META_DOWN_MASK). Thus ⌘-Q would be <keyboardhook>81,260</keyboardhook>.

Line numbers:

The [DisplayLineNumberColumn] macro toggles line numbers. It makes a simple addition to the standard programming menu.

Line wrap:

The documentation is clear that the right-click context menu changes the line wrap. With a one-button mouse, right-click is control-click. Oddly, this brings up the control-right-click context menu. Use [DisplaySyntaxColors] and [DisplayPlainText] to switch display mode. In plain text mode, the macro [DisplayLineWrap] toggles line wrap. For convenience, add the desired macros to the ToolBar or the control-right-click configuration file, ~/.Arachnophilia/ArachConf/CtrlRightClickList.txt.

Browser issues:

Opening a file or link in a browser fails, as the program inexplicably prefixes the URL with the application's path. This produces such novelties as "/Applications/file:/Users/…" The program also tries to launch multiple instances of an application from the About dialog, despite settings to the contrary. As an alternative, open the document in the default browser with [SystemExec:open [FullPath]], or a named application with [SystemExec:open -a firefox [FullPath]]. The browser will scroll to the last position, but the document must have been saved to see the current version. Prepending a [Save] macro is optional.

Similarly, opening the help index is easy: [SystemExec:open [UserHomeDirectory]/.Arachnophilia/Documentation/index.html] Another, more elaborate approach is shown in Listing 1, a custom class named LaunchBrowser. More details on custom classes may be found in the documentation.

Base Calculator:

The [LaunchBaseCalculator] macro opens a handy base conversion tool. Sadly, the text fields are left justified and only 10 pixels high. Instead, the Mac's Calculator has a delightful Programmer's view: [SystemExec:open -a Calculator].

Application bundle:

It's perfectly possible to launch Arachnophilia from the command-line with java -jar Arachnophilia.jar, but adding the jar to a Mac application bundle makes it easier to manage. The essential element of a bundle is the xml property list, Info.plist. A typical one is shown in Listing 2. It puts the menu bar in the familiar location and specifies the dock name and version details.

More details on bundling a jar may be found in the article Java Deployment Options for Mac OS X.

Listing 1: LaunchBrowser.

/**
 * LaunchBrowser: an Arachnophilia custom class for Mac OS X.
 *
 * Macro form: open with the default application
 * [RunCustomClassArg:CustomClasses/LaunchBrowser.open,[FullPath]]
 *
 * Macro form: open with the named application
 * [RunCustomClassArg:CustomClasses/LaunchBrowser.open,[FullPath]:application]
 *
 * Macro form: open help with the default browser
 * [RunCustomClassArg:CustomClasses/LaunchBrowser.help,[UserHomeDirectory]]
 *
 * @author John B. Matthews
 */

import java.io.*;

public class LaunchBrowser {

    private static final String DOCPATH =
        "/.Arachnophilia/Documentation/index.html";
    
    /**
     * Open a file in the default or specified application.
     * @param s the result of [FullPath]; application name is optional
     */
    public String open(String s) {
        String result = "";
        String command = null;
        String error;
        String[] args;
        Process p;
        try {
            args = s.split(":");
            if (args.length == 1) {
                command = "open " + args[0];
            } else if (args.length == 2) {
                command = "open -a " + args[1] + " " + args[0];
            }
            p = Runtime.getRuntime().exec(command);
            BufferedReader in = new BufferedReader (
                new InputStreamReader(p.getErrorStream()));
            if ( (error = in.readLine()) != null) {
                result = command + "\n" + error + "\n";
            }
        } catch (Exception e) {
            result = e.getMessage();
        }
        return result;
    }
      
    /**
     * Open the Documentation index in the default browser.
     * @param s the result of [UserHomeDirectory]
     */
    public String help(String s) {
        try {
            Process p = Runtime.getRuntime().exec(
                "open " + s + DOCPATH);
        } catch (Exception e) {
            return e.getMessage();
        }
        return "";
    }
}

Listing 2: Info.plist.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

<dict>

    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>

    <key>CFBundleExecutable</key>
    <string>JavaApplicationStub</string>

    <key>CFBundleGetInfoString</key>
    <string>5.4, build 2461 (03/31/2011) arachnoid.com</string>

    <key>CFBundleIconFile</key>
    <string>Arachnophilia.icns</string>

    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>

    <key>CFBundleName</key>
    <string>Arachnophilia</string>

    <key>CFBundlePackageType</key>
    <string>APPL</string>

    <key>CFBundleSignature</key>
    <string>????</string>

    <key>CFBundleShortVersionString</key>
    <string>5.4</string>

    <key>CFBundleVersion</key>
    <string>5.4, build 2461 (03/31/2011)</string>

    <key>Java</key>
    <dict>

        <key>JVMVersion</key>
        <string>1.6*</string>

        <key>MainClass</key>
        <string>Arachnophilia.Arachnophilia</string>

        <key>ClassPath</key>
        <string>$JAVAROOT/Arachnophilia.jar</string>

        <key>Properties</key>
        <dict>

            <key>java.library.path</key>
            <string>$JAVAROOT/</string>

            <key>apple.laf.useScreenMenuBar</key>
            <string>true</string>

        </dict>

        <key>VMOptions</key>
        <string>-Xdock:name=Arachnophilia</string>

    </dict>

    <key>LSHasLocalizedDisplayName</key>
    <true/>

    <key>NSHumanReadableCopyright</key>
    <string>Copyright 2000-2011, P. Lutus. All rights reserved.</string>

</dict>
</plist>

Acknowledgements:

Thanks to Arachnophilia for nicely formatted listings.

Disclaimer:

Sorry, I cannot accept liability arising out of use of this program including (but not limited to) the time you waste playing with it. Happy editing!

Copyright:

©2008, John B. Matthews. Distribution permitted without warranty under the terms of the LGPL.

Last updated 28-Apr-11