-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.95 - Helper script F4TCIE, DocumentTemplates, New icon
- Loading branch information
hi5
committed
Jul 15, 2017
1 parent
601d420
commit 881bddb
Showing
12 changed files
with
298 additions
and
79 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Document Templates for F4TCIE.ahk | ||
|
||
Note that this is an additional functionality, if you don't place any template.* files | ||
in this folder F4TCIE will not use it. | ||
|
||
## Introduction | ||
|
||
By default you can use the keyboard shortcut <kbd>Shift</kbd>+<kbd>F4</kbd> or the | ||
*cm_EditNewFile* command to create a new text file and open this in your defined text | ||
editor. | ||
|
||
By setting F4TCIE.ahk as editor: | ||
|
||
TC, Configuration, Edit/View, Editor: | ||
drive:\path-to\F4TCIE.ahk "%1" | ||
|
||
you can extend this functionality to the programs you defined in F4MiniMenu. | ||
|
||
Unlike text editors, many program simply don't accept or understand the new empty | ||
file Total Commander creates. They may not start correctly or generate an error message. | ||
Here is where F4TCIE comes in. It checks if there is a "template.ext" file for the new | ||
file you just created, if so it copies that template to your current active panel and | ||
start your preferred program which you defined in F4MiniMenu. | ||
|
||
So instead of opening your text editor when you create a new "MyImageFile.PNG" it | ||
can start your preferred Graphics program for PNG files. | ||
|
||
If it can't find a template, it will simply launch your default editor. | ||
|
||
When you add new templates to this folder you need to Update (scan) the | ||
"Currently Available Document Templates" in the Settings window, or via | ||
"Scan Document Templates" in the Tray or Foreground menu OR restart F4MiniMenu. | ||
|
||
You can find two examples in DocumentTemplatesExamples.zip to illustrate how it | ||
works (RTF, PNG) - you can of course replace these with your own Template files. | ||
|
||
## Limitation(s) | ||
|
||
* It won't work in/with ZIP files (but will copy file to Active panel) | ||
* Shift+F4 doesn't work in FTP panels (default TC behaviour) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
Script : F4TCIE.ahk for Total Commander - AutoHotkey 1.1+ (Ansi and Unicode) | ||
Version : 0.4 | ||
Author : hi5 | ||
Last update : 10 July 2017 | ||
Purpose : Helper script for F4MiniMenu program to allow internal editor to function | ||
now you can edit files from within Archives and FTP (and have TC update/upload them) | ||
Notes : It will always use the "normal" method to open programs, so the "drag & drop", "filelist" | ||
and "cmdline" methods will not be used (TC doesn't see file changes when using these methods) | ||
If you are using INI make sure to rename "F4TCIE" to end with an "i" (same method as F4MiniMenu) | ||
Source : https://github.com/hi5/F4MiniMenu | ||
Setup : TC, Configuration, Edit/View, Editor: | ||
drive:\path-to\F4TCIE.ahk "%1" | ||
Templates : Create a DocumentTemplates\ folder and place files for each template you'd like to use for | ||
the Shift-F4 'enter file name to edit' function of TC. File names are template.ext | ||
This will copy the template.ext to the panel with the new name so you can work on it the | ||
defined editor. Not all programs allow empty files at start up so this will resolve that | ||
problem for say Office applications or Graphics programs. | ||
For testing purposes the variable "templateExt" below needs to be modified, this will | ||
be automatically done when integrating F4TCIE into the F4MM repo. | ||
See DocumentTemplates\readme.md for more info. | ||
*/ | ||
|
||
#NoTrayIcon | ||
#NoEnv | ||
|
||
SetWorkingDir, %A_ScriptDir% | ||
|
||
File=%1% ; cmd line parameter "%1" it receives from TC | ||
SplitPath, File, , , OutExtension | ||
StringUpper, OutExtension, OutExtension | ||
|
||
If !File ; if empty | ||
ExitApp | ||
|
||
; shared with F4MM | ||
#Include %A_ScriptDir%\inc\LoadSettings1.ahk | ||
#Include %A_ScriptDir%\inc\LoadSettings2.ahk | ||
|
||
If Error | ||
{ | ||
MsgBox, 16, F4MiniMenu/F4TCIE, Couldn't load configuration file, closing script and starting default Windows editor.`n`nMay not work if there is no "Edit" defined for this filetype:`n`n%OutExtension% | ||
Try | ||
Run edit %file% ; run Windows editor for this filetype | ||
Catch | ||
Run notepad %file% ; alas no type defined so run notepad as a last resort | ||
ExitApp | ||
} | ||
|
||
templateExt:=MatchList.Settings.templatesExt | ||
|
||
; shared with F4MM | ||
#Include %A_ScriptDir%\inc\TotalCommanderPath.ahk | ||
|
||
for k, v in MatchList | ||
{ | ||
if (k = "settings") | ||
continue | ||
if (v.ext = "") ; reported by Ovg if EXT is empty it would not launch the default editor | ||
continue | ||
If RegExMatch(OutExtension,RegExExtensions(v.ext)) ; Open in defined program - v0.9 allow for wildcards | ||
{ | ||
editor:=GetTCCommander_Path(v.exe) | ||
If OutExtension in %templateExt% | ||
{ | ||
IfExist, %file% ; file is already present, this could be that TC created it just now (0 bytes) or that is already existed. | ||
{ | ||
FileGetSize, NewFileSize, %file% | ||
If (NewFileSize = 0) ; TC created it, so overwrite with our template, otherwise don't. This to avoid overwriting existing documents. | ||
FileCopy, %A_ScriptDir%\DocumentTemplates\template.%OutExtension%, %file%, 1 | ||
} | ||
} | ||
If editor | ||
{ | ||
Sleep % v.delay | ||
Run %editor% %file% | ||
} | ||
ExitApp ; we only have one file to proces so we're done | ||
} | ||
} | ||
|
||
; We couldn't find a defined Editor so launch the default Editor [1] | ||
Run % matchlist[1].exe A_Space file | ||
|
||
; shared with F4MM | ||
#include %A_ScriptDir%\inc\HelperFunctions.ahk | ||
|
||
; just for loading the Matchlist object, we don't need all the rest | ||
#include %A_ScriptDir%\lib\xa.ahk | ||
#include %A_ScriptDir%\lib\iob.ahk | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
; used in F4MiniMenu and F4TCIE | ||
|
||
GetTCCommander_Path(editor) | ||
{ | ||
global MyComSpec | ||
editor:=StrReplace(editor,"%Commander_Path%",Commander_Path) | ||
editor:=StrReplace(editor,"%ComSpec%",MyComSpec) | ||
Return editor | ||
} | ||
|
||
RegExExtensions(in) | ||
{ | ||
out:="iU)\b(" StrReplace(StrReplace(StrReplace(in,",","|"),"?",".?"),"*",".*") ")\b" ; v0.9 allow for wildcards | ||
Return out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
; used in F4MiniMenu and F4TCIE | ||
|
||
SplitPath, A_ScriptName, , , , OutNameNoExt | ||
If (SubStr(OutNameNoExt,0) <> "i") | ||
{ | ||
F4ConfigFile:="F4MiniMenu.xml" | ||
F4Load:="XA_Load" | ||
F4Save:="XA_Save" | ||
} | ||
else | ||
{ | ||
F4ConfigFile:="F4MiniMenu.ini" | ||
F4Load:="iob" | ||
F4Save:="iob_save" | ||
} | ||
|
||
Error:=0 | ||
; http://en.wikipedia.org/wiki/List_of_archive_formats | ||
ArchiveExtentions:="\.(a|ar|cpio|shar|iso|lbr|mar|tar|bz2|F|gz|lz|lzma|lzo|rz|sfark|xz|z|infl|7z|s7z|ace|afa|alz|apk|arc|arj|ba|bh|cab|cfs|cpt|dar|dd|dgc|dmg|gca|ha|hki|ice|j|kgb|lzh|lha|lzx|pak|partimg|paq6|paq7|paq8|pea|pim|pit|qda|rar|rk|sda|sea|sen|sfx|sit|sitx|sqx|tar\.gz|tgz|tar\.Z|tar\.bz2|tbz2|tar\.lzma|tlz|uc|uc0|uc2|ucn|ur2|ue2|uca|uha|wim|xar|xp3|yz1|zip|zipx|zoo|zz)\\" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
; used in F4MiniMenu and F4TCIE | ||
|
||
; Load settings on MatchList Object | ||
Try | ||
{ | ||
%F4Load%(F4ConfigFile) | ||
} | ||
Catch | ||
{ | ||
Error:=1 | ||
} | ||
|
||
If ((MatchList.MaxIndex() = 0) or (MatchList.MaxIndex() = "")) | ||
Error:=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.