Latest post of the previous page:
It's my first attempt at FAR's macro language, so please bear with me and point out any errors I made. The code is heavily based on the original Maximus5's code, except that I opted to remove dependency on menu, and use a number of keys instead:- ALT+F1 = copy to left
- ALT+F2 = copy to right
- ALT+F3 = compare using WinMerge (or any other external utility)
- CTRL+F1 = edit left
- CTRL+F2 = edit right
The code for ALT+F3 seems especially cumbersome to me, surely there is a better way to do it?
Code: Select all
// Far2
const DirSyncID = 0x44725363
// Far3
//const DirSyncID = "F5AE7C40-F8D0-443E-82A4-285DBFB4FF69"
macro Descr="DirSync - edit left" Area="Editor" Key="CtrlF1"
{{
$if (callplugin(#%DirSyncID,1)==0) $Exit $end
$if (env("DirSyncFileInfo")=="")
MsgBox("DirSync info","Current editor is not DirSync report\nor current line is not difference info",1)
$Exit
$end
$if (!fexist(env("DirSyncFileLeft")))
MsgBox("DirSync info","File on the left does not exist",1)
$Exit
$end
ShiftF4 print(env("DirSyncFileLeft")) Enter
}}
macro Descr="DirSync - edit right" Area="Editor" Key="CtrlF2"
{{
$if (callplugin(#%DirSyncID,1)==0) $Exit $end
$if (env("DirSyncFileInfo")=="")
MsgBox("DirSync info","Current editor is not DirSync report\nor current line is not difference info",1)
$Exit
$end
$if (!fexist(env("DirSyncFileRight")))
MsgBox("DirSync info","File on the right does not exist",1)
$Exit
$end
ShiftF4 print(env("DirSyncFileRight")) Enter
}}
macro Descr="DirSync - copy to left" Area="Editor" Key="AltF1"
{{
$if (callplugin(#%DirSyncID,1)==0) $Exit $end
$if (env("DirSyncFileInfo")=="")
MsgBox("DirSync info","Current editor is not DirSync report\nor current line is not difference info",1)
$Exit
$end
$if (!fexist(env("DirSyncFileRight")))
MsgBox("DirSync info","File on the right does not exist",1)
$Exit
$end
Home Del Del Del Del print("<---") Right
}}
macro Descr="DirSync - copy to right" Area="Editor" Key="AltF2"
{{
$if (callplugin(#%DirSyncID,1)==0) $Exit $end
$if (env("DirSyncFileInfo")=="")
MsgBox("DirSync info","Current editor is not DirSync report\nor current line is not difference info",1)
$Exit
$end
$if (!fexist(env("DirSyncFileLeft")))
MsgBox("DirSync info","File on the left does not exist",1)
$Exit
$end
Home Del Del Del Del print("--->") Right
}}
macro Descr="DirSync - compare" Area="Editor" Key="AltF3"
{{
$if (callplugin(#%DirSyncID,1)==0) $Exit $end
$if (env("DirSyncFileInfo")=="")
MsgBox("DirSync info","Current editor is not DirSync report\nor current line is not difference info",1)
$Exit
$end
$if (!fexist(env("DirSyncFileLeft")))
MsgBox("DirSync info","File on the left does not exist",1)
$Exit
$end
$if (!fexist(env("DirSyncFileRight")))
MsgBox("DirSync info","File on the right does not exist",1)
$Exit
$end
// Switch to panels
%PanelCount=0;
$While (!Shell)
%PanelCount=%PanelCount+1;
CtrlTab
$End
// Save command line
$If (!CmdLine.Empty)
%Flg_Cmd=1;
%CmdCurPos=CmdLine.ItemCount-CmdLine.CurPos+1;
%CmdVal=CmdLine.Value;
Esc
$End
// Run the compare
print("winmerge \"")
print(env("DirSyncFileLeft"))
print("\" \"")
print(env("DirSyncFileRight"))
print("\"")
Enter
sleep(100)
// Restore command line
$If (%Flg_Cmd==1)
$Text %CmdVal
%Flg_Cmd=0;
%Num=%CmdCurPos;
$While (%Num!=0)
%Num=%Num-1;
CtrlS
$End
$End
// Return back
$While (%PanelCount > 0)
%PanelCount=%PanelCount-1;
CtrlShiftTab
$End
$Exit;
}}