name : ConEmu.Editor.fml
// This is sample macro-file for MacroLib plugin for Far Manager 2.x
// You can download plugin here:
// http://code.google.com/p/far-plugins/wiki/MacroLib


//include "Consts.fmi"
const ConEmu   = 0x43454D55

macro Descr="ConEmu: Auto switch to Editor Tab"
  Key="F3 F4"
  Area="Shell Search"
  Cond="PanelType:0"
{{
  %k = Key(#AKey);
  $if (!APanel.Empty && (APanel.Current!=".."))
    %s=APanel.Path;
    %s=%s+iif(substr(%s,len(%s)-1)=="\\","","\\")+APanel.Current;
    //MsgBox("Current item", %s)
    %c = substr(%k,len(%k)-1,1);
    %cmd = iif(%c=="4","FindEditor:","FindViewer:")+%s;
    %iRc=callplugin(#%ConEmu,%cmd);
    //MsgBox("EditOpen result", "callplugin="+%iRc+"\n<"+env("ConEmuMacroResult")+">")
    $if (%iRc!=0)
      %r = env("ConEmuMacroResult");
      $if (substr(%r,0,5)=="Found")
        $Exit // Ok
      $else $if (substr(%r,0,6)=="Active")
        F12 eval(substr(%r,7))
        $Exit // Ok
      $else $if (%r=="Blocked")
        // MsgBox("ConEmu macro","Tab can't be activated now\n"+%s);
      $end $end $end
    $end
  $end

  //history.enable(0xF)
  $if (%k=="F4") F4 $else F3 $end

  // As we get here, Far will try to open viewer or editor window.
  // But, it may be already opened in the current Far instance.
  // When it's exists, Far show messagebox with confirmation and buttons:
  // { Current } [ New instance ] [ Reload ]
  // Next macro line depress { Current } button
  $if (Dialog && Title=="Editor" && Dlg.ItemCount==7 && Dlg.CurPos==5 && Dlg.ItemType==7) Enter $end
}}

© 2026 UnknownSec