Skip to content

Commit

Permalink
Improve docs + logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jgclark committed Oct 24, 2023
1 parent e783ccd commit df43053
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
12 changes: 8 additions & 4 deletions jgclark.WindowSets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@ The commands are simple:

As monitor dimensions vary widely, a window set layout is specific to the particular macOS computer you've defined it on. If you have more than one then it will only show you the ones for the machine you're currently using.

<!-- (There are currently some other commands for testing. To see the underlying window set definitions, you can use **/log window sets** which writes to the Help > Plugin Console.) -->

_If you want to dig into more detail, and tweak more of what's going on, please read on. But you shouldn't need to for most use of saving and opening window sets._

[<img width="100px" alt="Buy Me A Coffee" src="https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg">](https://www.buymeacoffee.com/revjgc)

<hr />

<!-- (There are currently some other commands for testing. To see the underlying window set definitions, you can use **/log window sets** which writes to the Help > Plugin Console.) -->

## Known limitations
Unfortunately because of limitations in the API that plugins use, WindowSets:
1. can't control the width of split windows within the main NotePlan window.
2. can't control the order of windows that overlap, as the API doesn't supply the z-order of windows when saving a set. (Nor can it control the z-order of windows when opening a set.)

## Configuration
Click the gear button on the **Window Sets** line in the Plugin Preferences panel, and configure the two general settings accordingly:
- Note title for Window Set definitions: defaults to `Window Sets`.
- Folder where Window Set definitions are stored: defaults to `@Window Sets`.

_If you want to dig into more detail, and tweak more of what's going on, please read on. But you shouldn't need to for most use of saving and opening window sets._

## Defining Window Sets
These are defined in a special note; by default this is `@Window Sets/Windows Sets` but can be changed in the plugin Settings. All Window Sets are defined in a code block in JSON format. When first run it will offer to write out some examples for you to use or modify.
Expand Down
4 changes: 2 additions & 2 deletions jgclark.WindowSets/src/WSHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ const exampleWSs: Array<WindowSet> = [
"editorWindows": [
{
"noteType": "Calendar",
"windowType": "split",
"windowType": "main",
"filename": "{-1d}",
"title": "yesterday",
"x": 0,
Expand Down Expand Up @@ -530,7 +530,7 @@ const exampleWSs: Array<WindowSet> = [
"editorWindows": [
{
"noteType": "Calendar",
"windowType": "split",
"windowType": "main",
"filename": "{-1w}",
"title": "last week",
"x": 0,
Expand Down
8 changes: 4 additions & 4 deletions jgclark.WindowSets/src/windowSets.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const pluginID = 'jgclark.WindowSets'
export async function saveWindowSet(): Promise<void> {
try {
if (NotePlan.environment.platform !== 'macOS' || NotePlan.environment.buildVersion < 1100) {
logInfo('saveWindowSet', `Window Sets needs NotePlan v3.9.8 or later on macOS. Stopping.`)
logInfo(pluginJson, `Window Sets needs NotePlan v3.9.8 or later on macOS. Stopping.`)
return
}

Expand All @@ -90,7 +90,6 @@ export async function saveWindowSet(): Promise<void> {
height: winRect.height,
}
})
// logDebug('saveWindowSet', `Found ${String(editorWinDetails.length)} editor windows`)

const htmlWinDetails: Array<wsh.HTMLWinDetails> = NotePlan.htmlWindows.map((win) => {
const winRect = win.windowRect
Expand All @@ -105,7 +104,7 @@ export async function saveWindowSet(): Promise<void> {
height: winRect.height,
}
})
// logDebug('saveWindowSet', `Found ${String(htmlWinDetails.length)} HTML windows`)
logDebug(pluginJson, `saveWindowSet starting with ${String(editorWinDetails.length)} editor + ${String(htmlWinDetails.length)} HTML windows`)

if ((editorWinDetails.length + htmlWinDetails.length) < 2) {
const answer = await showMessageYesNo("There's only 1 open window. Are you sure you want to continue to make a Window Set?")
Expand Down Expand Up @@ -318,9 +317,10 @@ export async function saveWindowSet(): Promise<void> {
export async function openWindowSet(setName: string = ''): Promise<boolean> {
try {
if (NotePlan.environment.platform !== 'macOS' || NotePlan.environment.buildVersion < 1100) {
logInfo('saveWindowSet', `Window Sets needs NotePlan v3.9.8 or later on macOS. Stopping.`)
logInfo(pluginJson, `Window Sets needs NotePlan v3.9.8 or later on macOS. Stopping.`)
return false
}
logDebug(pluginJson, `openWindowSet starting with param setName '${setName}'`)

const config = await wsh.getPluginSettings()
const thisMachineName = NotePlan.environment.machineName
Expand Down

0 comments on commit df43053

Please sign in to comment.