%
% anyremote configuration file for to make basic file operations with help of
% GUI of Java client. (Server-mode)
%

% STATUS stable
% TODO handle braces/brackets in file names
% XTEST no
% SOUND no
% ENV no
% FBROWSER v.2++
% ALL_IN_ONE 

GuiAppName=FileManager2
GuiAppBinary=true
GuiAppIcon=fileopen.png
GuiAppType=Custom
GuiAppProtocols=Server
GuiAppDesc=Simple file manager which looks like Midnight Commander. Browsing directory structure with basic file operations.

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Make(var,list_index_l,by_value,1);\
	Make(var,list_index_r,by_value,1);
	
(Connect)=\
	Set(parameter,debug,on);\
	ExecAndSet(title,sleep 2);\
	Make(mode,fileManager2);

(InCall)=Make(remote,off);
(EndCall)=Make(remote,on);

All-in-1L($$)=Macro(FM2_ALLIN1);
All-in-1R($$)=Macro(FM2_ALLIN1);
BackL($$)=Macro(FM2_ALLIN1);
BackR($$)=Macro(FM2_ALLIN1);
Back=Set(text,close);
Cancel=Exit

FM2_ALLIN1=Set(filemanager,close);Macro(All-in-1);

0=Exit
1=Make(mode,fileManager2);
2=Set(fullscreen,toggle);

* *=Set(text,replace,Help, Basic file operations.\n1 - enter file manager screen\n 2 - toggle fullscreen)

FM2_FILLL=ExecAndSet(filemanager,replace,left, cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";echo `pwd`>$HOME/.anyRemote/ar_storedir_l.tmp;ls -F --quoting-style=shell|sed 's/\*//;s/@//;s/,/\r/g;s/$/,/');
FM2_FILLR=ExecAndSet(filemanager,replace,right,cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";echo `pwd`>$HOME/.anyRemote/ar_storedir_r.tmp;ls -F --quoting-style=shell|sed 's/\*//;s/@//;s/,/\r/g;s/$/,/');

FM2_SetIndexL=Set(filemanager,select,left, $(list_index_l));
FM2_SetIndexR=Set(filemanager,select,right,$(list_index_r));
FM2_StoreIndexL=Make(var,list_index_l,by_value,$(Index));
FM2_StoreIndexR=Make(var,list_index_r,by_value,$(Index));

FM2_UPDATEL=Macro(FM2_FILLL);Macro(FM2_SetIndexL);Macro(FM2_FILLR);
FM2_UPDATER=Macro(FM2_FILLR);Macro(FM2_SetIndexR);Macro(FM2_FILLL);

[Mode]=fileManager2
(EnterMode)=\
	Set(icons,File Manager,1,folder,2,fullscreen,3,default,4,default,5,default,6,default,7,default,8,default,9,default,0,no,#,default,*,question);\
	Set(layout,default);\
	Macro(FM2_FILLL);\
	Macro(FM2_FILLR);\
	Make(mode,fileManager2_work);
[ModeEnd]

[Mode]=fileManager2_work

(EnterMode)=Macro(ALLIN1MENU);
Back=Set(text,close);Macro(ALLIN1MENU)

GoToL($$)=\
	ExecAndSet(filemanager,replace,left, cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";if [ -d $(Param) ]; then cd $(Param);fi;pwd>$HOME/.anyRemote/ar_storedir_l.tmp;ls -F --quoting-style=shell|sed 's/\*//;s/@//;s/,/\r/g;s/$/,/');

GoToR($$)=\
	ExecAndSet(filemanager,replace,right,cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";if [ -d $(Param) ]; then cd $(Param);fi;pwd>$HOME/.anyRemote/ar_storedir_r.tmp;ls -F --quoting-style=shell|sed 's/\*//;s/@//;s/,/\r/g;s/$/,/');

ViewL($$)=\
	Macro(FM2_StoreIndexL);\
	Make(var,viewdir,cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";pwd);\
	Make(var,viewfile,by_value,$(Param));\
	Make(mode,fileManager2_view_l);
	
ViewR($$)=\
	Macro(FM2_StoreIndexR);\
	Make(var,viewdir,cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";pwd);\
	Make(var,viewfile,by_value,$(Param));\
	Make(mode,fileManager2_view_r);

MkDirL($$)=\
	Macro(FM2_StoreIndexL);\
	Set(editfield,Enter name,New Directory,);\
	Make(mode,fileManager2_mkdir_l);
	
MkDirR($$)=\
	Macro(FM2_StoreIndexR);\
	Set(editfield,Enter name,New Directory,);\
	Make(mode,fileManager2_mkdir_r);

File infoL($$)=\
	Macro(FM2_StoreIndexL);\
	Make(var,infodir,cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";pwd);\
	Make(var,infofile,by_value,$(Param));\
	Make(mode,fileManager2_finfo_l);
	
File infoR($$)=\
	Macro(FM2_StoreIndexR);\
	Make(var,infodir,cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";pwd);\
	Make(var,infofile,by_value,$(Param));\
	Make(mode,fileManager2_finfo_r);

ExecuteL($$)=\
	Macro(FM2_StoreIndexL);\
	Make(var,execdir_l,cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";pwd);\
	Make(var,execfile_l,by_value,$(Param));\
	Set(editfield,Enter parameters,Parameters,);\
	Make(mode,fileManager2_exec_l);
	
ExecuteR($$)=\
	Macro(FM2_StoreIndexR);\
	Make(var,execdir_r,cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";pwd);\
	Make(var,execfile_r,by_value,$(Param));\
	Set(editfield,Enter parameters,Parameters,);\
	Make(mode,fileManager2_exec_r);

% -----------------------------------------------------------------------

% linked (intermediate) replay for multi-file operation

M_CopyL($$)=\
	Make(var,cpfile_l,by_value,$(Param));\
	Exec(cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";cp -r $(cpfile_l) "`cat $HOME/.anyRemote/ar_storedir_r.tmp`");

M_CopyR($$)=\
	Make(var,cpfile_r,by_value,$(Param));\
	Exec(cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";cp -r $(cpfile_r) "`cat $HOME/.anyRemote/ar_storedir_l.tmp`");

CopyL($$)=\
	Make(var,cpfile_l,by_value,$(Param));\
	ExecAndSet(filemanager,replace,right,cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";cp -r $(cpfile_l) "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";ls -F --quoting-style=shell|sed 's/\*//;s/@//;s/$/,/');

CopyR($$)=\
	Make(var,cpfile_r,by_value,$(Param));\
	ExecAndSet(filemanager,replace,left, cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";cp -r $(cpfile_r) "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";ls -F --quoting-style=shell|sed 's/\*//;s/@//;s/$/,/');

% -----------------------------------------------------------------------

% linked (intermediate) replay for multi-file operation
M_MoveL($$)=\
	Make(var,mvfile_l,by_value,$(Param));\
	Exec(cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";mv $(mvfile_l) "`cat $HOME/.anyRemote/ar_storedir_r.tmp`"/);

M_MoveR($$)=\
	Make(var,mvfile_r,by_value,$(Param));\
	Exec(cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";mv $(Param) "`cat $HOME/.anyRemote/ar_storedir_l.tmp`"/);

MoveL($$)=\
	Make(var,mvfile_l,by_value,$(Param));\
	ExecAndSet(filemanager,replace,left ,cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";mv $(mvfile_l) "`cat $HOME/.anyRemote/ar_storedir_r.tmp`"/;cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";ls -F --quoting-style=shell|sed 's/\*//;s/@//;s/$/,/');\
	Macro(FM2_FILLR);

MoveR($$)=\
	Make(var,mvfile_r,by_value,$(Param));\
	ExecAndSet(filemanager,replace,right,cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";mv $(mvfile_r) "`cat $HOME/.anyRemote/ar_storedir_l.tmp`"/;cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";ls -F --quoting-style=shell|sed 's/\*//;s/@//;s/$/,/');\
	Macro(FM2_FILLL);

% -----------------------------------------------------------------------

% linked (intermediate) replay for multi-file operation
M_DeleteL($$)=\
	Make(var,rmfile_l,by_value,$(Param));\
	Exec(cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";rm -rf $(rmfile_l));

M_DeleteR($$)=\
	Make(var,rmfile_r,by_value,$(Param));\
	Exec(cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";rm -rf $(rmfile_r));

DeleteL($$)=\
	Make(var,rmfile_l,by_value,$(Param));\
	ExecAndSet(filemanager,replace,left, cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";rm -rf $(rmfile_l);echo 'cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";ls -F --quoting-style=shell|sed "s/\*//;s/@//;s/$/,/"'|bash -f -s);

DeleteR($$)=\
	Make(var,rmfile_r,by_value,$(Param));\
	ExecAndSet(filemanager,replace,right,cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";rm -rf $(rmfile_r);echo 'cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";ls -F --quoting-style=shell|sed "s/\*//;s/@//;s/$/,/"'|bash -f -s);
% -----------------------------------------------------------------------

[ModeEnd]

% -----------------------------------------------------------------------

[Mode]=fileManager2_mkdir_l
(EnterMode)=Make(none)
(ExitMode)=Macro(FM2_FILLR);Macro(FM2_SetIndexL);
Ok($$)=ExecAndSet(filemanager,replace,left,cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`";mkdir "$(Param)";ls -F --quoting-style=shell|sed 's/\*//;s/@//;s/$/,/');Make(mode,fileManager2_work);
Back($$)=Make(mode,fileManager2_work);
[ModeEnd]

[Mode]=fileManager2_mkdir_r
(EnterMode)=Make(none)
(ExitMode)=Macro(FM2_FILLL);Macro(FM2_SetIndexR);
Ok($$)=ExecAndSet(filemanager,replace,right,cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`";mkdir "$(Param)";ls -F --quoting-style=shell|sed 's/\*//';s/@//;s/$/,/');Make(mode,fileManager2_work);
Back($$)=Make(mode,fileManager2_work);
[ModeEnd]

% -----------------------------------------------------------------------

[Mode]=fileManager2_view_l
(EnterMode)=ExecAndSet(text,replace,File View,more "$(viewdir)"/$(viewfile));
(ExitMode)=Set(text,clear);Macro(FM2_UPDATEL)
Back=Make(mode,fileManager2_work);
[ModeEnd]

[Mode]=fileManager2_view_r
(EnterMode)=ExecAndSet(text,replace,File View,more "$(viewdir)"/$(viewfile));
(ExitMode)=Set(text,clear);Macro(FM2_UPDATER);
Back=Make(mode,fileManager2_work);
[ModeEnd]

% -----------------------------------------------------------------------

[Mode]=fileManager2_finfo_l
(EnterMode)=ExecAndSet(text,replace,File info,file "$(infodir)"/$(infofile)>$HOME/.anyRemote/ar_infodata.tmp;ls -l "$(infodir)"/$(infofile)>>$HOME/.anyRemote/ar_infodata.tmp;cat $HOME/.anyRemote/ar_infodata.tmp);
(ExitMode)=Set(text,clear);\
	Macro(FM2_FILLL);\
	Macro(FM2_SetIndexL);\
	Macro(FM2_FILLR);
Back=Make(mode,fileManager2_work);
[ModeEnd]

[Mode]=fileManager2_finfo_r
(EnterMode)=ExecAndSet(text,replace,File info,file "$(infodir)"/$(infofile)>$HOME/.anyRemote/ar_infodata.tmp;ls -l "$(infodir)"/$(infofile)>>$HOME/.anyRemote/ar_infodata.tmp;cat $HOME/.anyRemote/ar_infodata.tmp);
(ExitMode)=Set(text,clear);\
	Macro(FM2_FILLR);\
	Macro(FM2_SetIndexR);\
	Macro(FM2_FILLL);
Back=Make(mode,fileManager2_work);
[ModeEnd]

% -----------------------------------------------------------------------

[Mode]=fileManager2_exec_l
(EnterMode)=Make(none)
(ExitMode)=Macro(FM2_UPDATEL)
Ok($$)=ExecAndSet(text,replace,Results,echo 'cd "`cat $HOME/.anyRemote/ar_storedir_l.tmp`"; "$(execdir_l)"/$(execfile_l) $(Param)'|bash -f -s);\
	Make(mode,fileManager2_showres_l);
Back($$)=Make(mode,fileManager2_work);
[ModeEnd]

[Mode]=fileManager2_exec_r
(EnterMode)=Make(none)
(ExitMode)=Macro(FM2_UPDATER);
Ok($$)=ExecAndSet(text,replace,Results,echo 'cd "`cat $HOME/.anyRemote/ar_storedir_r.tmp`"; "$(execdir_r)"/$(execfile_r) $(Param)'|bash -f -s);\
	Make(mode,fileManager2_showres_r);
Back($$)=Make(mode,fileManager2_work);
[ModeEnd]

[Mode]=fileManager2_showres_l
(EnterMode)=Make(none)
(ExitMode)=Set(text,clear);Macro(FM2_UPDATEL)
Back=Make(mode,fileManager2_work);
[ModeEnd]

[Mode]=fileManager2_showres_r
(EnterMode)=Make(none)
(ExitMode)=Set(text,clear);Macro(FM2_UPDATER);
Back=Make(mode,fileManager2_work);
[ModeEnd]

[End]
