%
% 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.3i

GuiAppName=FileManager3
GuiAppBinary=true
GuiAppIcon=fileopen.png
GuiAppType=Custom
GuiAppProtocols=Server
GuiAppDesc=Simple file manager. Browsing directory structure with basic file operations.

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Include($(CfgDir)/Utils/aliases-server-fbrowser-v3i.cfg);\
	Make(var,list_index,by_value,1);

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

(Connect)=\
	Set(parameter,debug,on);\
	Get(model);\
	Set(icons,File manager,\
		1,folder,2,fullscreen,3,default,\
		4,default,5,default,6,default,\
		7,default,8,default,9,default,\
		*,question,0,no,#,default);\
	ExecAndSet(title,sleep 2);\
	Macro(FBROWSER_IC_FILL_LIST);\
	Macro(UpdateMenu);

UpdateMenu=Set(menu,replace,GoTo,File info,Copy,Move,Delete,Make Dir,View,Exec,Go Home);

SetIndex=Set(iconlist,select,$(list_index));
StoreIndex=Make(var,list_index,by_value,$(Index));
Delete($$)=Macro(StoreIndex);\
	ExecAndSet(iconlist,replace,Files,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";rm -rf "$(Param)";echo "folder:..");\
	Macro(FillDir);\
	Macro(FillFile);\
	Macro(SetIndex);
Back($$)=Set(list,close);
Back=Set(text,close);

GoTo($$)   =Macro(FBROWSER_IC_GO_TO);
Go Home($$)=Macro(FBROWSER_IC_GO_HOME);
%Push($$) use from aliases-server-fbrowser-v3i.cfg

Cancel=Exit

0=Exit
1=Macro(FBROWSER_IC_FILL_LIST);Macro(UpdateMenu);
2=Set(fullscreen,toggle);

* *=Set(text,replace,Help, Menu-driven basic\nfile operations.\n1 - enter file manager screen\n2 - toggle fullscreen);

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

Exec($$)=\
	Macro(StoreIndex);\
	Make(var,execdir,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";pwd);\
	Make(var,execfile,by_value,$(Param));\
	Set(editfield,Enter parameters,Parameters,);\
	Make(mode,EXEC);

[Mode]=EXEC

Ok($$)=\
	ExecAndSet(text,replace,Results,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";"$(execdir)"/$(execfile) $(Param));\
	Make(mode,EXECSHOW);

Back($$)=\
	Macro(FBROWSER_IC_FILL_LIST);\
	Macro(SetIndex);\
	Macro(UpdateMenu);\
	Make(mode,default);

[ModeEnd]

[Mode]=EXECSHOW

(ExitMode)=\
	Macro(FBROWSER_IC_FILL_LIST);\
	Macro(SetIndex);\
	Macro(UpdateMenu);

Back=\
	Make(mode,default);

[ModeEnd]


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

Make Dir($$)=\
	Macro(StoreIndex);\
	Set(editfield,Enter name,New Directory,);\
	Make(mode,MKDIR);

[Mode]=MKDIR

Ok($$)=\
	ExecAndSet(iconlist,replace,Files,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";mkdir $(Param);echo "folder:..");\
	Macro(FillDir);\
	Macro(FillFile);\
	Macro(SetIndex);\
	Macro(UpdateMenu);\
	Make(mode,default);
        
Back($$)=\
	Macro(FBROWSER_IC_FILL_LIST);\
	Macro(SetIndex);\
	Macro(UpdateMenu);\
	Make(mode,default);

[ModeEnd]

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

File info($$)=\
	Macro(StoreIndex);\
	Make(var,infodir,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";pwd);\
	Make(var,infofile,by_value,$(Param));\
	Make(mode,FINFO);

[Mode]=FINFO

(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,close);\
	Macro(FBROWSER_IC_FILL_LIST);\
	Macro(SetIndex);\
	Macro(UpdateMenu);

Back=Make(mode,default);

[ModeEnd]

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

View($$)=\
	Macro(StoreIndex);\
	Make(var,viewdir,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";pwd);\
	Make(var,viewfile,by_value,$(Param));\
	Make(mode,VIEW);

[Mode]=VIEW

(EnterMode)=\
	ExecAndSet(text,replace,File View,more "$(viewdir)"/$(viewfile));
	
(ExitMode)=\
	Macro(FBROWSER_IC_FILL_LIST);\
	Macro(SetIndex);\
	Macro(UpdateMenu);

Back=Make(mode,default);

[ModeEnd]

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

Copy($$)=\
	Make(var,copydir,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";pwd);\
	Make(var,copyfile,by_value,$(Param));\
	Make(mode,COPY)

[Mode]=COPY

(EnterMode)=\
	Set(iconlist,replace,Copy To,folder:..);\
	Make(var,copyto,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";pwd);\
	Macro(FillCDir);\
	Macro(FillCFile);\
	Set(menu,replace,GoTo,Copy To);

FillCDir=\
	ExecAndSet(iconlist,add,SAME,cd "$(copyto)";ls -F --quoting-style=shell|sed 's/\*//;s/,/\r/g;s/@//;s/$/,/'|grep '/'| xargs -d '\n' -i echo "folder:" {} );
	
FillCFile=\
	ExecAndSet(iconlist,add,SAME,cd "$(copyto)";ls -F --quoting-style=shell|sed 's/\*//;s/,/\r/g;s/@//;s/$/,/'|grep -v '/'| xargs -d '\n' -i echo "file:"{} );

GoTo($$)=\
	Set(iconlist,replace,Copy To,folder:..);\
	Make(var,copytmp,by_value,$(Param));\
	Make(var,copyto,cd "$(copyto)";echo "if [ -d $(copytmp) ]; then cd $(copytmp);fi;pwd"|bash -f -s);\
	Macro(FillCDir);\
	Macro(FillCFile);

Copy To($$)=\
	Make(var,copytofile,by_value,$(Param));\
	ExecAndSet(iconlist,replace,Copy To,cp "$(copydir)"/$(copyfile) "$(copyto)"/$(copytofile);echo "folder:..");\
	Make(var,copyto,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";pwd);\
	Macro(FillCDir);\
	Macro(FillCFile);\
	Macro(UpdateMenu);\
	Make(mode,default);

Back($$)=\
	Macro(FBROWSER_IC_FILL_LIST);\
	Macro(UpdateMenu);\
	Make(mode,default);

[ModeEnd]

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

Move($$)=\
	Make(var,movedir,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";pwd);\
	Make(var,movefile,by_value,$(Param));\
	Make(mode,MOVE);

[Mode]=MOVE

(EnterMode)=\
	Set(iconlist,replace,Move To,folder:..);\
	Make(var,moveto,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";pwd);\
	Macro(FillMDir);\
	Macro(FillMFile);\
	Set(menu,replace,GoTo,Move To);

FillMDir=\
	ExecAndSet(iconlist,add,SAME,cd "$(moveto)";ls -F --quoting-style=shell|sed 's/\*//;s/,/\r/g;s/@//;s/$/,/'|grep '/'| xargs -d '\n' -i echo "folder:" {} );

FillMFile=\
	ExecAndSet(iconlist,add,SAME,cd "$(moveto)";ls -F --quoting-style=shell|sed 's/\*//;s/,/\r/g;s/@//;s/$/,/'|grep -v '/'| xargs -d '\n' -i echo "file:"{} );

GoTo($$)=\
	Set(iconlist,replace,Move To,folder:..);\
	Make(var,movetmp,by_value,$(Param));\
	Make(var,moveto,cd "$(moveto)";echo "if [ -d $(movetmp) ]; then cd $(movetmp);fi;pwd"|bash -f -s);\
	Macro(FillMDir);\
	Macro(FillMFile)

Move To($$)=\
	Make(var,movetofile,by_value,$(Param));\
	ExecAndSet(iconlist,replace,Move To,mv "$(movedir)"/$(movefile) "$(moveto)"/$(movetofile);echo "folder:..");\
	Make(var,moveto,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";pwd);\
	Macro(FillMDir);\
	Macro(FillMFile);\
	Macro(UpdateMenu);\
	Make(mode,default);

Back($$)=\
	Macro(FBROWSER_IC_FILL_LIST);\
	Macro(UpdateMenu);\
	Make(mode,default);

[ModeEnd]


[End]
