restart: with(StringTools): with(Maplets): with(Maplets[Elements]): ScreenHeight:=20: HelpText:= " You can use the commands:\n\ 1) help\n\ 2) dir\n\ 3) cls\n\ 4) exit\n\ 5) date\n\ 6) time": Page:="": SearchCommand:=proc(str) substring(str,searchtext(">",str)+1..-1); end proc: PrepareText:=proc(s) local numbers,n: numbers:=[SearchAll("\n",s)]: n:=nops(numbers)+1: if n > ScreenHeight then substring(s,numbers[n-ScreenHeight]+1..-1) else cat("\n"$(ScreenHeight-n),s); end if: end proc: Show:=proc(s) global Page: Maplets:-Tools:-Get(TF_Command): Page:=cat(Page,"\n",%,"\n",s): Maplets:-Tools:-Set(TB_Screen=PrepareText(Page)) end proc: Prompt:=proc() global CursorPosition, prigl: prigl:=cat(currentdir(),">"): CursorPosition:=length(prigl): return prigl end proc: SetPrompt:=proc() Maplets:-Tools:-Set(TF_Command(focus)=true): Maplets:-Tools:-Set(TF_Command=Prompt()): Maplets:-Tools:-Set(TF_Command(cursor)=CursorPosition) end proc: Execute:=proc() local cmd,path,spl: use Maplets:-Tools in cmd:=SearchCommand(Get(TF_Command)): spl:=Split(cmd," "): if (nops(spl)=2 and spl[1]="cd") then cmd:=spl[1]: path:=spl[2] end if: if (cmd="exit") then SHUTDOWN(): elif (cmd="cls") then CLS() elif (cmd="dir") then DIR() elif (cmd="help") then HELP() elif (cmd="date") then DATE() elif (cmd="time") then TIME() elif (cmd="cd")then CD(path) elif (cmd="") then : else Show(cat(" Error command: ",cmd,"\n Execute command: help")) end if end use end proc: SHUTDOWN:=proc() ClearTF(): Maplets:-Tools:-Set(A_Sd(run)=true) end proc: CLS:=proc() global Page: Page:="": Maplets:-Tools:-Set(TB_Screen=Page): end proc: DIR:=proc() local l: l:=listdir(currentdir()); cat(op(map(f->cat(" ",f,"\n"),l[1..nops(l)])))[1..-2]: Show(%) end proc: HELP:=proc() Show(HelpText) end proc: DATE:=proc() Show(FormatTime(" The current day is: %d.%m.%Y")) end proc: TIME:=proc() Show(FormatTime(" The current time is: %X")) end proc: CD:=proc(path) currentdir(path): #Show(cat(" ",currentdir())): end proc: M:=Maplet( onstartup=Action(RunWindow(W),Evaluate(function=SetPrompt)), Window[W](resizable=false,title="Maplet Commander", layout=GridLayout(inset=0, GridRow( GridCell( TextBox[TB_Screen](width=91,height=ScreenHeight,editable=false,font=F_Courier, background=black,foreground=white,wrapped=false) ) ), GridRow( GridCell( TextField[TF_Command]( width=90,font=F_Courier, background="#202020",foreground="#FFFFFF") ), GridCell( Button("",visible=false,onclick=A_Execute) ) ) ) ), Action[A_Execute](Evaluate(function=Execute),Evaluate(function=SetPrompt)), Action[A_Sd](Shutdown()), Font[F_Courier]("courier",14) ): Display(M):