Bike Outliner :: Jump to next or previous empty line

A pair of macros for Jesse Grosjean's new Bike Outliner:

Hog Bay Software – Bike: Tool for thought

bike outliner


BikeJumpToNextOrPrevEmptyLine.kmmacros (10.0 KB)

  • ⌥⌘ ↓ – jump to NEXT empty line
  • ⌥⌘ ↑ – jump to PREVIOUS empty line


Expand disclosure triangle to view JS Source
(() => {
    "use strict";

    // BIKE – Select next (or previous) empty line.
    // Rob Trew @2022
    // Ver 0.03

    // JavaScript for Automation
    // Test in Script Editor with language selector at
    // top left set to JavaScript

    // ---------------- DIRECTION OPTION -----------------

    // To jump to PREVIOUS blank line,
    // edit the value of `directionDown` to false.
    const directionDown = true;

    // main :: IO ()

    // eslint-disable-next-line max-lines-per-function
    const main = () => {
        const
            bike = Application("Bike"),
            doc = bike.documents.at(0);

        return doc.exists() ? (() => {
            const
                // IDs paired with names
                rows = doc.rows.where({
                    visible: true
                }),
                idNames = zip(
                    rows.id()
                )(
                    rows.name()
                ),

                // Position of selected line
                selectedID = doc.selectionRow.id(),
                selnIndex = idNames.findIndex(
                    ab => selectedID === ab[0]
                ),

                // Offset of first blank in remaining or
                // preceding lines.
                nextIndex = (
                    directionDown ? (
                        idNames.slice(1 + selnIndex)
                    ) : (
                        idNames.slice(0, selnIndex)
                        .reverse()
                    )
                )
                .findIndex(ab => "" === ab[1]);

            bike.activate();

            // First following blank line selected (if any)
            return -1 !== nextIndex ? (
                doc.select({
                    at: rows.at(
                        (
                            (x, y) => directionDown ? (
                                x + y
                            ) : x - y
                        )(selnIndex, 1 + nextIndex)
                    )
                }),
                "Selected"
            ) : (
                Object.assign(
                    Application.currentApplication(), {
                        includeStandardAdditions: true
                    }
                ).beep(),
                `No more blank rows visible in ${doc.name()}`
            );
        })() : "No document open in Bike.";
    };


    // --------------------- GENERIC ---------------------
    // https://github.com/RobTrew/prelude-jxa


    // zip :: [a] -> [b] -> [(a, b)]
    const zip = xs =>
        // The paired members of xs and ys, up to
        // the length of the shorter of the two lists.
        ys => Array.from({
            length: Math.min(xs.length, ys.length)
        }, (_, i) => [xs[i], ys[i]]);


    // MAIN ---
    return main();
})();

Other Keyboard Maestro macros for BIKE Outliner

Hello there, i've tried this macro and it failed to work properly. The macro itself must be pretty useful consider empty rows in outliner often appear between rows and navigating through them is a pretty brilliant idea.
Is it possible for this macro to get some update?

Could you expand ?

  • What are you expecting ?
  • What are you seeing ?

Which macOS and Bike versions ?

( Working as designed here, once assigned to chosen keystrokes )


(Probably worth switching off the Display results briefly setting on the Execute JavaScript action, for less distraction and faster performance on successive uses)

thx! it worked!

1 Like