DirSync — синхронизация каталогов

Здесь можно обсудить ваш любимый плагин.
pepak
Posts: 604
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 17 times
Been thanked: 54 times

DirSync — Synchronize Directories

Post by pepak »

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;

}}
Last edited by pepak on Thu 01 Jan, 1970 01:00, edited 0 times in total.
Reason: moved from http://forum.farmanager.com/viewtopic.php?f=39&t=4479
pepak
Posts: 604
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 17 times
Been thanked: 54 times

Re: DirSync — Synchronize Directories

Post by pepak »

Edited to add quotes around the paths.
ccaid
Posts: 908
Joined: Fri 12 Jun, 2009 16:04
Has thanked: 24 times
Been thanked: 6 times

Re: DirSync — синхронизация каталогов

Post by ccaid »

плагин не срабатывает на строках рапорта с маркером <--> — при нажатии altf3 вместо меню выскакивает сообщение об ошибке, что этот файл — не файл-рапорт
нельзя ли поправить
Фар делают добрые люди
dar3000
Posts: 1
Joined: Fri 01 Jun, 2012 00:25

Re: DirSync — синхронизация каталогов

Post by dar3000 »

Подскажите, имхо, DirSync не может сравнивать локальные папки с папками на фтп. А вообще есть такие плагины для far? Хотелось бы иметь нечто аналогичное "Синхронизации каталогов" в TC.
ccaid
Posts: 908
Joined: Fri 12 Jun, 2009 16:04
Has thanked: 24 times
Been thanked: 6 times

Re: DirSync — синхронизация каталогов

Post by ccaid »

вопрос снят, всем спасибо

а это мой вариант использования плагина

Фар делают добрые люди
User avatar
Wave
Posts: 1887
Joined: Thu 04 Aug, 2005 18:47
Has thanked: 14 times
Been thanked: 26 times

Re: DirSync — синхронизация каталогов

Post by Wave »

Будет ли версия под тройку?
Под враппером выдаётся что-то типа «Incorrect struct size # (516!=528)» и плагин отказывается работать — это к плагину, врапперу или моим рукам?
Пользуюсь ФАРом больше 20 лет © собирательный.
Post Reply

Return to “Обсуждение плагинов”