Restore saved TaskPaper window tiling arrangement


#1

A pair of Keyboard Maestro macros,

  1. Restore a TaskPaper windows tiling arrangement
  2. Record a window tiling arrangement

using Matthew McVickar’s notes and templates as an example


#2

Thank you for this. By any chance, do you have a script that accomplishes the same as Matthew’s month generator on his system?


#3

month generator

Not off-hand (I tend to generate calendars further downstream, at the report stage), but here’s a JavaScript sketch which you may be able to adapt. The standardAdditions() function for the clipboard is JavaScript for Automation, but the rest is vanilla (ES6), JS.

For ES5, you can recompile it in the Babel REPL online, or at:
https://closure-compiler.appspot.com/home

(() => {
    'use strict';

    // Rob Trew 2017

    // GENERIC ---------------------------------------------------------------

    // enumFromTo :: Int -> Int -> [Int]
    const enumFromTo = (m, n) =>
        Array.from({
            length: Math.floor(n - m) + 1
        }, (_, i) => m + i);

    // show :: Int -> a -> Indented String
    // show :: a -> String
    const show = (...x) =>
        JSON.stringify.apply(
            null, x.length > 1 ? [x[1], null, x[0]] : x
        );

    // CALENDAR --------------------------------------------------------------

    // Year -> 1-based Month -> Number of days :: Int
    // daysInMonth :: Int -> Int -> Int
    const daysInMonth = (intYear, intMonth1To12) =>
        Math.round((new Date(intYear, intMonth1To12, 1) -
            new Date(intYear, intMonth1To12 - 1, 1)
        ) / (24 * 3600000));

    // Year -> 1-based Month -> List of days :: [(day of month, day of week)]
    // weekDaysOfMonth :: Int -> Int -> [Int]
    const weekDaysOfMonth = (intYear, intMonth1To12) =>
        enumFromTo(1, daysInMonth(intYear, intMonth1To12))
        .map(d => [
            d,
            (new Date(intYear, intMonth1To12 - 1, d))
            .getDay()
        ]);

    // monthPaper :: Int -> Int -> Int -> String
    const monthPaper = (dayNames, intYear, intMonth) =>
        dayNames.length === 7 ? (
            weekDaysOfMonth(intYear, intMonth)
            .map(([d, wd]) => `${d} ${dayNames[wd]}:`) // Adjust format here
            .join('\n\n') + '\n'
        ) : 'Expected names for 7 days, saw: ' + dayNames.join('-');

    // JXA -------------------------------------------------------------------

    // standardAdditions :: () -> Application
    const standardAdditions = () =>
        Object.assign(Application.currentApplication(), {
            includeStandardAdditions: true
        });

    // TASKPAPER CALENDAR FOR DAY AND MONTH  ---------------------------------

    // dayNames :: (String, String, String, String, String, String, String)
    const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];

    const strMonth = (
        monthPaper(
            dayNames,
            2017, 12 // Year and (1-based) index of Month
        )
    );

    return (
        // Effect
        standardAdditions()
        .setTheClipboardTo(strMonth),
        // Value
        strMonth
    );
})();


#4

Hi Victor and complexpoint. I wanted to let you know that I built a tool for this a while back:

https://matthewmcvickar.github.io/taskpaper-month-generator/

Hope you find that handy—I do!