Improve help about the L1 option of cm_Edit

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Improve help about the L1 option of cm_Edit

Post by *white »

Current help about the L options of the cm_Edit command:
[Help - Dialog box: Choose command] wrote: L: Launch type: L0=do not launch, L1=open with default editor, L2=open with associated program (including internal associations), L3=open with associated program (no internal associations)
I think the explanation of L1 is not very clear. I suggest to change it to:
L: Launch type: L0=do not launch, L1=open with default program for text files, L2=open with associated program (including internal associations), L3=open with associated program (no internal associations)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Improve help about the L1 option of cm_Edit

Post by *ghisler(Author) »

No, L1 uses the editor configured under Configuration - Options - Edit/View.
L2 uses the default associated program.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Improve help about the L1 option of cm_Edit

Post by *white »

ghisler(Author) wrote: 2023-09-10, 10:51 UTC No, L1 uses the editor configured under Configuration - Options - Edit/View.
I see. That leaves me still confused, what's the difference between L1 and L0 or leaving L out ?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Improve help about the L1 option of cm_Edit

Post by *ghisler(Author) »

L0 is not launching the file at all.
Leaving L out depends on what you open:
It's the same as L1 when entering a single file name.
It's the sames as L0 when creating a group of files via counter or multiple names.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Improve help about the L1 option of cm_Edit

Post by *white »

Ah, multiple files... I was testing the cm_Edit command with the file under the cursor.

The current help is this:
[Help - Dialog box: Choose command] wrote: cm_Edit

The following parameters can be passed to the function behind a slash:
C: Create files which do not already exist
T: Instead of creating an empty file, copy a template file to the new name. By default, the user's template directory will be used. The first file in it with the same extension will be copied to the new file. If no file is found, an empty file will be created
T="c:\path": Sames as T but use the specified template directory
N="name": The name(s) of the file(s) to be created - separate multiple file names with the | character. Alternatively, use templates from the "+" button to create multiple files.
Use the following syntax to pass multiple names in double quotes:
N=<"name1" "name2" "name3">
G: Go, create new files immediately (has no effect when not using C)
L: Launch type: L0=do not launch, L1=open with default editor, L2=open with associated program (including internal associations), L3=open with associated program (no internal associations)
V="verb": Combined with L2 or L3, set the verb to open the file, e.g. "open" or "edit". Leave out or use V="" for default verb. With L1, WinExec will be used when not using V, otherwise ShellExecuteEx (which is always used for L2 and L3).
It doesn't say L0 only works with C:

 cm_Edit  Opens file under cursor in editor 
 cm_Edit /L0  Opens file under cursor in editor 
 cm_Edit /CGL0  Doesn't open file under cursor in editor 
 cm_Edit /N="1.TXT"  Opens "1.TXT" in editor 
 cm_Edit /L0N="1.TXT"  Opens "1.TXT" in editor 
 cm_Edit /CGL0N="1.TXT"  Doesn't open "1.TXT" in editor 


Perhaps it should also work without C.


The Help says
N="name": The name(s) of the file(s) to be created
It doesn't say it also works when not creating file(s). As shown in the examples above, N also works without C. Which is als suggested by this line in HISTORY.TXT:
03.07.23 Added: Internal command cm_edit now supports optional parameters to set edit options: name, create when missing, edit or open, verb for open, use template; see Help - Dialog box: Choose command
But without C, multiple filenames are not supported and multiple filenames will be considered to be 1 filename.

 cm_Edit /N="1.TXT|2.TXT"L1  Tries to open the file "1.TXT|2.TXT" in editor 
 cm_Edit /CGN="1.TXT|2.TXT"L1  Opens "1.TXT" in editor and opens "2.TXT" in editor 


This doesn't seem like an intuitive implementation.


The help says:
Use the following syntax to pass multiple names in double quotes:
N=<"name1" "name2" "name3">
It's not intuitive that passing 1 filename using this notation isn't accepted.

 cm_Edit /CGN=<"1.TXT">  Plays beep sound and prompts for filename 
 cm_Edit /CN=<"1.TXT">  Prompts for filename 
 cm_Edit /CN=<"1.TXT" "2.TXT">   Click OK -> 1.TXT and 2.TXT are created 
 cm_Edit /CN=<"1.TXT" "2.TXT">   Remove "2.TXT" and click OK -> beep sound and prompts for filename again 


The last example above very much feels like a bug.
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Improve help about the L1 option of cm_Edit

Post by *white »

The help says:
V="verb": Combined with L2 or L3, set the verb to open the file, e.g. "open" or "edit". Leave out or use V="" for default verb. With L1, WinExec will be used when not using V, otherwise ShellExecuteEx (which is always used for L2 and L3).
If I have Notepad as the default program for .txt files in Windows and TC configured to use the same Notepad as editor:

 cm_Edit /CGN="1.TXT"L1V="Open"  Opens Notepad 
 cm_Edit /CGN="1.TXT"L3V="Open"  Opens Notepad 
 cm_Edit /CGN="1.TXT"L1V="Edit"  Error 
 cm_Edit /CGN="1.TXT"L3V="Edit"  Opens Notepad 
 cm_Edit /CGN="1.TXT"L1V="Print"  Error 
 cm_Edit /CGN="1.TXT"L3V="Print"  Prints via Notepad 


When using L1, are only the verbs "Open", "runas" and "runasuser" allowed?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Improve help about the L1 option of cm_Edit

Post by *ghisler(Author) »

cm_Edit /L0 would do nothing at all, so L0 is ignored.

Verbs only make sense with file associations, so combining them with L1 is pointless.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Improve help about the L1 option of cm_Edit

Post by *white »

ghisler(Author) wrote: 2023-09-11, 10:03 UTC cm_Edit /L0 would do nothing at all, so L0 is ignored.
Doing nothing would be consistent and consistent with the help text.
cm_Edit /L0 doing nothing would give the user feedback that L0 indeed means: do not start the editor or associated program.
Ignoring it may cause confusion. And it isn't clear from the help.
ghisler(Author) wrote: 2023-09-11, 10:03 UTC Verbs only make sense with file associations, so combining them with L1 is pointless.
I think you mean something other than "runas" and "runasuser", because you mention combining verbs with L1 in the help:
With L1, WinExec will be used when not using V, otherwise ShellExecuteEx (which is always used for L2 and L3).
It could be made clear that only "runas" and "runasuser" are useful with L1. And "open" as well if it causes TC to use ShellExecuteEx instead of WinExec. Does it?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Improve help about the L1 option of cm_Edit

Post by *ghisler(Author) »

The reason why "Edit" doesn't work with L1 is that ShellExecuteEx is called with the program name (e.g. notepad.exe) and the file just as a parameter. But that would use the verb for .exe and not for .txt. That's why only "runas" and "runasuser" work with L1, because that's the extra verbs supported for the extension .exe.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Improve help about the L1 option of cm_Edit

Post by *white »

ghisler(Author) wrote: 2023-09-12, 10:38 UTC The reason why "Edit" doesn't work with L1 is that ShellExecuteEx is called with the program name (e.g. notepad.exe) and the file just as a parameter. But that would use the verb for .exe and not for .txt. That's why only "runas" and "runasuser" work with L1, because that's the extra verbs supported for the extension .exe.
Thanks for the explanation, that makes sense.
Post Reply