Page 1 of 1

Template support for "Create new file"

Posted: 2022-10-18, 19:54 UTC
by funkymonk
With default TC settings in TC10.52rc4, SHIFT+F4
  1. opens a dialog that asks for a file name;
  2. if the file does not exist, an empty (0 byte) file with this name is created;
  3. the file is opened with the program that is associated to the file name extension.
This is fine for, e.g., text files. However, many applications cannot directly deal with empty files.

Example:
If you pass a 0 byte file with extension .docx to MS Word, Word opens the file without complaint. Upon save (Ctrl+S), it silently turns the file into a real .docx file with the corresponding header, etc.
If you try the same with .xlsx files, Excel will reject the empty .xlsx file.

My suggestion ist to have template support for "Create new file" (Shift+F4):
  1. opens a dialog that asks for a file name (--> as before);
  2. if the file does not exist, a new file with this name is created;

    NEW: Depending on the extension, a default template file will be copied – OR – a template can be selected from a dropdown list.
    E.g., for “test.xlsx” a (default) Excel template file will be copied to test.xlsx in the current folder.
    To support several templates for the same extension, a dropdown list could provide the options.
  3. the file is opened with the program that is associated to the file name extension. (--> as before)
Of course, docx/xlsx are just examples.
Even though it means some implementation work for the TC author to provide template configuration, I would consider is this feature very useful.

((
Yes, one could create button that copies a template file and then rename and edit it manually.
And also yes, an AHK script could be used.
Actually, I would consider is this feature very useful when directly implemented in TC.
))

Re: Template support for "Create new file"

Posted: 2022-10-18, 20:24 UTC
by hi5

Re: Template support for "Create new file"

Posted: 2022-10-19, 07:56 UTC
by ghisler(Author)
Shift+F4 doesn't open the empty file with the associated program. It always opens it with the text editor configured for F4. It is really only meant for text files. For other file types, use the right click context menu of the directory. It has a "New" sub-menu which uses the registry entries for new file creation. This can also use templates from the templates folder, or from registry keys, or even open a special Windows dialog (e.g. for new .lnk file).

Re: Template support for "Create new file"

Posted: 2022-10-19, 09:17 UTC
by petermad
use the right click context menu of the directory. It has a "New" sub-menu which uses the registry entries for new file creation.
This can also be opened with the cm_EditFileMenu command.

Re: Template support for "Create new file"

Posted: 2022-10-19, 13:20 UTC
by funkymonk
ghisler(Author) wrote: 2022-10-19, 07:56 UTC Shift+F4 doesn't open the empty file with the associated program. It always opens it with the text editor configured for F4.
Yes, right. As I am using OpenFileTC as default editor, I got the impression that TC calls the associated program -- but it's OpenFileTC.
Sorry.

Since I don't find the New Menu (cm_EditFileMenu) very helpful for a portable TC, I will find another solution...

Re: Template support for "Create new file"

Posted: 2022-10-19, 15:26 UTC
by petermad

Re: Template support for "Create new file"

Posted: 2022-10-19, 17:43 UTC
by funkymonk
petermad wrote: 2022-10-19, 15:26 UTC F4Menu works fine for me: http://totalcmd.net/plugring/F4Menu.html
Thank you. I'll give it a try. :)