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

% STATUS stable
% XTEST no
% SOUND no
% ENV no
% FBROWSER v.3

GuiAppName=FileManager
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-v3.cfg);\
	Macro(FBROWSER_INIT);\
	Make(var,list_index,by_value,1);

(Exit)=\
	Macro(FBROWSER_EXIT);

(Connect)=\
	Set(parameter,debug,on);\
	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_FILL_LIST);\
	Macro(UPDATE_MENU);


FMAN_FILL_LIST2=\
	ExecAndSet(list,add,SAME,cd "$(fbrowser_dir2)";ls -F --quoting-style=shell|sed 's/\*//;s/,/\r/g;s/@//;s/$/,/'|grep '/');\
	ExecAndSet(list,add,SAME,cd "$(fbrowser_dir2)";ls -F --quoting-style=shell|sed 's/\*//;s/,/\r/g;s/@//;s/$/,/'|grep -v '/');

%InCall($$)=\
%	Make(remote,off);

%EndCall($$)=\
%	Make(remote,on);

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

SET_INDEX=\
	Set(list,select,$(list_index));

STORE_INDEX=\
	Make(var,list_index,by_value,$(Index));

Delete($$)=\
	Macro(STORE_INDEX);\
	Set(list,replace,SAME,..);\
	Make(var,dummy,cd "$(fbrowser_dir)";rm -rf "$(Param)";echo DONE;);\
	Macro(FBROWSER_FILL_LIST);\
	Macro(SET_INDEX);

Back($$)=\
	Set(list,close);

Back=\
	Set(text,close);

GoTo($$)=\
	Macro(FBROWSER_GO_TO);

Go Home($$)=\
	Macro(FBROWSER_GO_HOME);

%Push($$) use from aliases-server-fbrowser-v3i.cfg

Cancel=\
    Make(exit);

0=Make(exit);
1=Macro(FBROWSER_FILL_LIST);\
	Macro(UPDATE_MENU);
2=Set(fullscreen,toggle);

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

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

Exec($$)=\
	Macro(STORE_INDEX);\
	Make(var,execfile,by_value,$(Param));\
        Set(editfield,Enter parameters,Parameters,);\
        Make(mode,EXEC);

[Mode]=EXEC

Ok($$)=\
	ExecAndSet(text,replace,Results,cd "$(fbrowser_dir)";./$(execfile) $(Param));
	
Back=\
	Make(mode,default);

Back($$)=\
	Make(mode,default);

(ExitMode)=\
	Macro(FBROWSER_FILL_LIST);\
	Macro(SET_INDEX);\
	Macro(UPDATE_MENU);

[ModeEnd]

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

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

[Mode]=MKDIR

Ok($$)=\
	Make(var,dummy,cd "$(fbrowser_dir)";mkdir $(Param);echo DONE;);\
	Macro(MKDIR_DONE);
	
Back($$)=\
	Macro(MKDIR_DONE);

MKDIR_DONE=\
	Macro(FBROWSER_FILL_LIST);\
	Macro(SET_INDEX);\
	Macro(UPDATE_MENU);\
	Make(mode,default);

[ModeEnd]

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

File info($$)=\
	Macro(STORE_INDEX);\
	Make(var,infofile,by_value,$(Param));\
	Make(mode,FINFO);

[Mode]=FINFO

(EnterMode)=\
	ExecAndSet(text,replace,File info,file "$(fbrowser_dir)"/$(infofile)>$(TmpDir)/ar_infodata.tmp);\
	ExecAndSet(text,add,SAME,ls -l "$(fbrowser_dir)"/$(infofile));

Back=\
	Make(mode,default);

(ExitMode)=\
	Macro(FBROWSER_FILL_LIST);\
	Macro(SET_INDEX);\
	Macro(UPDATE_MENU);

[ModeEnd]

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

View($$)=\
	Macro(STORE_INDEX);\
	Make(var,viewfile,by_value,$(Param));\
	Make(mode,VIEW);

[Mode]=VIEW

(EnterMode)=\
	ExecAndSet(text,replace,File View,cat "$(fbrowser_dir)"/$(viewfile));

Back=\
	Make(mode,default);

(ExitMode)=\
	Macro(FBROWSER_FILL_LIST);\
	Macro(SET_INDEX);\
	Macro(UPDATE_MENU);

[ModeEnd]

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

Copy($$)=\
	Macro(STORE_INDEX);\
	Make(var,copyfile,by_value,$(Param));\
	Make(mode,COPY)

[Mode]=COPY

(EnterMode)=\
	Make(var,fbrowser_dir2,by_value,$(fbrowser_dir));\
	Set(list,replace,Copy To,..);\
	Macro(FMAN_FILL_LIST2);\
	Set(menu,replace,GoTo,Copy To);

GoTo($$)=\
	Make(var,tmpdir,by_value,$(Param));\
	Make(var,fbrowser_dir2,cd "$(fbrowser_dir2)";if [ -d $(tmpdir) ]; then cd $(tmpdir);fi;pwd;);\
	Set(list,replace,SAME,..);\
	Macro(FMAN_FILL_LIST2);

Copy To($$)=\
	Make(var,copytmp,by_value,$(Param));\
	Make(var,dummy,cp "$(fbrowser_dir)"/$(copyfile) "$(fbrowser_dir2)"/$(copytmp);echo DONE;);\
	Make(mode,default);

Back($$)=\
	Make(mode,default);

(ExitMode)=\
	Macro(FBROWSER_FILL_LIST);\
	Macro(SET_INDEX);\
	Macro(UPDATE_MENU);

[ModeEnd]

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

Move($$)=\
	Macro(STORE_INDEX);\
	Make(var,movefile,by_value,$(Param));\
	Make(mode,MOVE);

[Mode]=MOVE

(EnterMode)=\
	Make(var,fbrowser_dir2,by_value,$(fbrowser_dir));\
	Set(list,replace,Move To,..);\
	Macro(FMAN_FILL_LIST2);\
	Set(menu,replace,GoTo,Move To);

GoTo($$)=\
	Make(var,tmpdir,by_value,$(Param));\
	Make(var,fbrowser_dir2,cd "$(fbrowser_dir2)";if [ -d $(tmpdir) ]; then cd $(tmpdir);fi;pwd;);\
	Set(list,replace,SAME,..);\
	Macro(FMAN_FILL_LIST2);

Move To($$)=\
	Make(var,movetmp,by_value,$(Param));\
	Make(var,dummy,mv "$(fbrowser_dir)"/$(movefile) "$(fbrowser_dir2)"/$(movetmp);echo DONE;);\
	Make(mode,default);

Back($$)=\
	Make(mode,default);

(ExitMode)=\
	Macro(FBROWSER_FILL_LIST);\
	Macro(SET_INDEX);\
	Macro(UPDATE_MENU);

[ModeEnd]

[End]
