A Tool Parameter Macro to select/access open documents

Ideas for new features

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
User avatar
inghamc
Posts: 4
Joined: Thu Jan 27, 2005 5:31 pm
Location: Fort Collins, Colorado

A Tool Parameter Macro to select/access open documents

Post by inghamc »

You have a lot of useful Tool Parameter Macros that all act on the currently open document. It'd be nice to easily access the other documents as well, with a construct like

$Document(n), where $Document(0) was the currently open document, $Document(1) the 1st most recent displayed document, etc.

$Document(0) would remain the default argument to macros such as $File, UNIXFile, etc.

It would then be nice to prompt for one or more of the currently open documents. For example, I'd like to add WinMerge to my list of tools, which takes two filename arguments. I'd like to prompt for the left and right filenames, and have the prompt be a list of TextPad's currently open documents that I could select from.

A sugestion for this syntax would be:

$PromptDocument(Left file: [0])
$PromptDocument(Right file: [1])


Or if someone wanted to select multiple documents for a command:

Select multiple files: $PromptDocuments(Choose files:)

It would then be nice to pass the result of these to other macros, such as $UNIXFile:

$File($PromptDocument(Left file: [0]))
cbono
Posts: 1
Joined: Thu Jan 29, 2004 2:52 pm

I second that motion!

Post by cbono »

I've been looking for a way to set up a visual diff utility as a TextPad tool, too.

What I'd like to see is the ability to select multiple documents in the Document Selector pane and have a macro that inserts those filenames into a command.

This is similar to how TextPad's built-in compare tool works.

Unless there's some spiffy visual difference tool coming with TextPad 5...
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Post by kengrubb »

I'll bump this one into the new decade.

Tool Parameter Macros has, among other Macros, $File - The fully qualified filename of the current document.

I'd like to see the addition of a $PreviousFile - The fully qualified filename of the previously selected document.

When one does a Compare Files in TextPad, the currently selected and previously selected docs are the ones placed in First File and Second File for the compare.

Having this additional Macro would allow one to integrate with an external compare tool, and Beyond Compare is what I use.
(2[Bb]|[^2].|.[^Bb])

That is the question.
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Post by kengrubb »

Using AutoIt (.au3), I created a script to do an external compare. I've had funky behavior using AutoIt Scripts as External Tools, so I use a .cmd file as the middleman between TP and AutoIt. Besides, who doesn't love a good Rube Goldberg solution?

I pointed CTRL-F9 to the new External Tool, so it's fairly quick and easy to:
- Select File1
- CTRL-F9
- Select File2
- CTRL-F9
- External compare of File1 and File2

The .cmd file

Code: Select all

"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "C:\Scripts\BeyondCompareQueue.au3" %1
The AutoIt script

Code: Select all

; ------------------------------------------------------------------------------
; Name     : BeyondCompareQueue.au3
; Version  : 1.0
; Type     : AutoIt 3.x
; Author   : Ken Grubb
; Written  : 02 Jul 2013
; Built    : Windows7 SP1 (AutoIt 3.3.8.1)
; Tested   : Windows7 SP1 (AutoIt 3.3.8.1)
; Keywords : file, compare
; Purpose  : Takes the command line input ($CmdLine[1]) of a file and compares it to the contents of the Clipboard
;            If the command line input and the contents of the Clipboard are the same, then a message is shown
;            If the contents of the Clipboard are a file, then the command line input and the contents of the Clipboard are compared using Beyond Compare
;            If the contents of the Clipboard are not a file, then the command line input is written to the Clipboard
; Usage    : autoit3.exe BeyondCompareQueue.au3 %1
; ------------------------------------------------------------------------------

#include <File.au3>

Opt("MustDeclareVars", 1)	;0 = no, 1 = require pre-declare

Local $Quote = chr(34)
Local $InputFile = $CmdLine[1]

Local $ClipboardContents = ClipGet()
If FileExists($ClipboardContents) Then
	If $InputFile = $ClipboardContents Then
		Local $szDrive, $szDir, $szFName, $szExt
		Local $TestPath = _PathSplit($ClipboardContents, $szDrive, $szDir, $szFName, $szExt)
		MsgBox(4096, @ScriptName, "Attempt to compare " & $szFName & $szExt & " to itself")
	Else
		Local $Command = $Quote & "C:\Program Files (x86)\Beyond Compare 3\BCompare.exe" & $Quote & " " & $Quote & $ClipboardContents & $Quote & " " & $Quote & $InputFile & $Quote
		Run($Command)
	EndIf
Else
	ClipPut($InputFile)
EndIf
(2[Bb]|[^2].|.[^Bb])

That is the question.
Post Reply