Hi, build 5485 does not end the path with '\' when I inserting path and filename. In previous version I use hot key CTRL+[ and then CTRL+Enter for inserting full filename (e.g. when I comparing two files - fc somefile.txt X:\Example\somefile.txt), but now if filename bad (fc somefile.txt X:\Examplesomefile.txt).
Backslash with CTRL+[
Posted: Thu 10 Oct, 2019 13:41
by DrKnS
Hi, there were reports that paths like "c:\something\" (note the quotes) don't work properly when passed to other programs (due to weird escaping rules), so we put the backslash outside the quotes, e.g. "c:\something"\. And then there were other reports that this doesn't work as well in some other stupid programs that can't unquote properly. So we were like "A plague o' both your houses!" and removed the backslash completely. You can write a simple macro to put a trailing backslash wherever you prefer.
Backslash with CTRL+[
Posted: Fri 11 Oct, 2019 05:05
by pepak
Personally, I find the original behavior (before 5472) the best suited for my needs and recompile FAR with that commit removed. And would urge to recommend the return to the original functionality for the official FAR itself - after all, if someone finds the terminating backslash interfering with their "some other stupid programs", they can always write a macro to remove it, there's no need to force a change onto those who don't have this problem.
Backslash with CTRL+[
Posted: Fri 11 Oct, 2019 07:30
by Yegor
Here is a simple macro to add a backslash (silly):
Macro {
area="Shell";
key="Ctrl[ Ctrl]";
description="Backslash with Ctrl+[ ]";
action = function()
key = mf.key(akey(1));
if (key == "Ctrl[" and APanel.Left) or (key == "Ctrl]" and not APanel.Left) then
mf.print("\""..APanel.Path.."\\\"");
else
mf.print("\""..PPanel.Path.."\\\"");
end
end;
}
Yegor wrote: ↑Fri 11 Oct, 2019 07:30
Here is a simple macro to add a backslash
C:\\
Backslash with CTRL+[
Posted: Fri 11 Oct, 2019 10:00
by 2useven10
Also missed keys Ctrl+ShiftCtrl+AltAlt+Shift + [ ]
Would be nice if both variants possible: before 5472 and before 4521.
If macros can handle all mentioned cases add it in Addons will cover all wishes.
Backslash with CTRL+[
Posted: Fri 11 Oct, 2019 10:14
by DrKnS
I'm pondering about reverting to the original behaviour (pre-4521, backslash-within-quotes, "path\").
After all, it was there for 20 years and didn't cause much trouble.
I remember only 1 (one) report when it wasn't desirable - https://bugs.farmanager.com/view.php?id=3011.
Changing it literally opened a can of worms.
Backslash with CTRL+[
Posted: Fri 11 Oct, 2019 12:05
by pepak
Seems like a value in far:config might be in order...
Myself, I don't really care where the backslash is, as long as it is somewhere. Both pre-5472 and pre-4521 work fine for me. Post-5472 is unusable as far as I am concerned, even with a macro (which seems to be growing to absurd proportions if it needs to recover all the functionality). But as I re-build FAR from the sources anyway, to facilitate my improvements which are not being accepted to the main source, it makes little difference to me whether there is an option or not.
Looking at the report, I would say that it actually reported something which is an error in the user's application rather than FAR: A quote belongs to the set of characters prohibited from appearing in filenames (source) and as such the application should not allow a quote to become a part of a filename. If escaping is required by the application (to facilitate passing an argument to another application, for example), it should be done consistently and not by interpreting \" as an escaped " but \C as unescaped \C. I am all for reverting the change completely.
Backslash with CTRL+[
Posted: Fri 11 Oct, 2019 13:48
by DrKnS
So be it.
Backslash with CTRL+[
Posted: Fri 11 Oct, 2019 16:09
by 2useven10
A bit more complex macros.
Choose your preference. It should not depends on DrKnS next move(s) or far3 version.
local BackSlashIn, BackSlashOut, NoBackSlash = 1, 2, 3
-- Ctrl + [] -- Left/Right path
-- Ctrl + Alt + [] -- Left/Right unc path
-- Ctrl + Shift + [] -- Active/Passive path
-- Alt + Shift + [] -- Active/Passive unc path
local AllKeys = "Ctrl[ Ctrl] CtrlAlt[ CtrlAlt] CtrlShift[ CtrlShift] AltShift[ AltShift]"
local function is_active_panel_key(key)
if (key:len() >= 10 or key:sub(1,1) == "A") then -- CtrlShift[ ] or AltShift[ ]
return key:sub(-1) == "["
else
return (key:sub(-1) == "[") == APanel.Left
end
end
local function correction_keys(last2, pref)
local last = last2:sub(-1)
if pref == NoBackSlash then
if last == "\\" then
return "BS" -- Path\ or "Path"\ --> Path or "Path"
elseif last2 == "\\\"" then
return "BS BS \"" -- "Path\" --> "Path"
end
elseif pref == BackSlashOut then
if last ~= "\\" then
if last2 ~= "\\\"" then
return "BackSlash" -- Path or "Path" --> Path\ or "Path"\
else
return "BS BS \" BackSlash" -- "Path\" --> "Path"\
end
end
else -- BackSlashIn
if last == "\"" then
if last2 ~= "\\\"" then
return "BS BackSlash \"" -- "Path" --> "Path\"
end
elseif last == "\\" then
if last2 == "\"\\" then
return "BS BS BackSlash \"" -- "Path"\ --> "Path\"
end
else
return "BackSlash" -- Path --> Path\
end
end
return nil
end
Macro {
area="Shell"; key=AllKeys; description="Backslash with Ctrl+[]";
action = function()
local akey = mf.key(akey(1))
Keys("AKey")
local path0
if is_active_panel_key(akey) then path0 = APanel.Path0 else path0 = PPanel.Path0 end
if path0:sub(-1) == "\\" then return end -- root path ends with "\" in any mode - do nothing
local cmd = CmdLine.Value
if cmd:len() < 2 then return end -- something goes wrong - do nothing
local modify = correction_keys(cmd:sub(-2), BackSlashOut) -- EDIT mode!
if modify then
Keys(modify)
end
end;
}
Macro {
area="Shell"; key="CtrlEnter"; description="Ctrl+Enter on ..";
condition = APanel.Current == "..";
action = function()
Keys "CtrlEnter"
local cmd = CmdLine.Value
if cmd:len() < 3 or cmd:sub(-1) ~= " " then return end -- something goes wrong
local modify = correction_keys(cmd:sub(-3, cmd:len()-1), NoBackSlash) -- EDIT mode!
if modify then
Keys("BS") Keys(modify) Keys("Space")
end
end;
}