Introducing Clipboarder (UPDATED)

Get help using and writing Nisus Writer Pro macros.
Post Reply
User avatar
loulesko
Posts: 124
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Introducing Clipboarder (UPDATED)

Post by loulesko »

You know how you're writing along, you come up with a good paragraph but it just doesn't fit where you're working. You ever wish you could place it on a scratch pad to use later? If this is you, you're going to love this set of tools.

This set of macros will cut and copy your text selections to the next available Nisus Writer clipboard numbered two and above. It also saves the selected text to a folder given the same name as the title of your file in a folder of your choosing.

This was significantly improved thanks to the help from people on the forum. The latest version uploaded 7 June, 2023

Huge thanks to:

@adryan Adrian—took your advice and now the paste window only shows available clipboards rather than EMPTY CLIPBOARD.
@xiamenese Mark your testing was super helpful.
@martin Martin tanks for the registry code and the choose folder code.

Clipboarder>Paste gives you the option choose the text snippet to paste.

Clipboarder>Paste with no file open offers the choice to reset your clipboards to factory default or navigate to the Save Clipboards folder for housekeeping.

Clipboarder>Restore looks for the folder with the same name as the title of your file to import the saved clipboards so you can paste them as need.
clipboarder-pic.jpg
clipboarder-pic.jpg (293.52 KiB) Viewed 2128 times
Clipboarder Macro + Manual.zip
(42.45 KiB) Downloaded 126 times
Last edited by loulesko on 2023-06-07 12:42:49, edited 2 times in total.
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Introducing Clipboarder

Post by adryan »

G'day, Lou et al

I like the way this is heading, as it makes the contents of multiple Clipboards more readily explicit than the inbuilt Clipboards Palette.

However, it failed to create a Save Clipboards folder for me. I couldn't find one, and the Restore Macro says there are no Clipboards to restore.

Also, the Copy command skips over an "EMPTY CLIPBOARD" and writes to the next one if it can.

I guess ideally there would also be a Clear Macro that would offer the option to clear a selected Clipboard or the whole lot.

Thanks for creating a nice addition to Nisus Writer's toolbox.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
User avatar
loulesko
Posts: 124
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Re: Introducing Clipboarder

Post by loulesko »

Hi Adryan,

Thanks for the feedback.

Wonder if there is a permissions issue. My thought is wherever the Macros folder lives, Nisus should have write permissions to it.

Try creating the Saved Clipboards folder manually and let me know if that works. I may have to explicitly set permissions.

If anyone else is having this problem, let me know. TIA!

Not sure what you mean by the skipping the EMPTY CLIPBOARD but this may clear things up: The first clipboard is left untouched because it's used system wide. I didn't want to trample on a user's text if they copied from another app. As such, the macro uses clipboard 2 and above. The words EMPTY CLIPBOARD are put in at the time of building the list. If the primary clipboard is empty, it's indicated as such. Let me know if that makes sense. Thanks!

I've updated the zip file with a PDF manual.

Lou
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Introducing Clipboarder

Post by adryan »

G'day, Lou et al

I'm afraid this is not working well for me at present.

The Copy Macro fails to create a Saved Clipboards folder. If one is created manually, it remains empty on execution of the Macro.

Also, the Copy Macro sometimes sets the contents of one of the Clipboards to "EMPTY CLIPBOARD" and fails to set the contents of any Clipboard to the selected text.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
User avatar
xiamenese
Posts: 543
Joined: 2006-12-08 00:46:44
Location: London or Exeter, UK

Re: Introducing Clipboarder

Post by xiamenese »

Hi,

Testing it out quickly, I concur with Adrian on Saved Clipboards folder issues. I had a folder of that name already in the right place, which it did not access; I trashed that folder but it didn't create a new one; I created a new one manually but it didn't access it. Pressing "Restore" gave thew alert "There are no clipboards to restore".

On the other hand, on repeatedly pressing Copy and then Paste, it offered the right number of populated clipboards preceded and followed by Empty clipboards.

Cheers.
Mark
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Introducing Clipboarder

Post by martin »

Thanks for sharing your macro Lou! This looks very nicely done and certainly handy 8)

As for the troubles with permissions, it's best not to assume Nisus Writer will have access to any folder on disk. I'd amend your macro(s) to explicitly establish access to the desired clipboard storage folder. I'd also let the user choose where to save these snippets. Here's some code that does that:

Code: Select all

# the first time the macro runs: ask the user where to save clipboards
$registry = Registry.userRegistry
$registryKey = 'org.‪loulesko.clipboards.storageFolderPath'
$folderPath = $registry.loadValueWithName($registryKey)
If ! $folderPath
	$folderPath = Choose Folder @undefined, "Choose Clipboard Storage Folder"
	If ! $folderPath
		Exit # user cancelled
	End
	# if the chosen folder is not empty, create a subfolder
	$folderFiles = File.namesInFolderAtPath($folderPath)
	If $folderFiles.count > 0
		$folderPath = $folderPath.filePathByAppendingComponent("Saved Clipboards")
		File.createFolderWithPath($folderPath)
	End
	# save access to folder
	File.learnAccessAtPath $folderPath
	$registry.saveValueWithName($folderPath, $registryKey)
Else
	# restore access to the desired folder
	File.requireAccessAtPath $folderPath
End
The code was written so you can swap it in above your existing "# variables" section. Probably you'd want to make it a separate function/command, so you can use the same logic elsewhere in your macros, e.g. amend your variables to use the declared $folderPath instead of relying upon "macros folder path".
User avatar
loulesko
Posts: 124
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Re: Introducing Clipboarder

Post by loulesko »

Martin

Thank you for the code. You are correct, this is a better option. I'll incorporate and repost the update.

Lou
Post Reply