I have started to implement a function that is inspired at the cmdmenusel found on the Judago's site.
It is the skeleton or a proof of concept.
I have used native dos command!
I stopped this a long time. If someone wants to improve it ...
Code: Select all
@echo off & setlocal EnableDelayedExpansion & Goto :Init_system
:Main
cls & mode %cols%,%lines% & color
rem default color E2F4
rem exitcode return the position selected
set /a sel=2, oldsel=2
set Num=9
For /L %%O in (1,1,%num%) do set "opt%%O=Option %%O"
:menu
mode %cols%,%lines%
echo Menu %sel%
echo ----
For /L %%O in (1,1,%num%) do (
<nul set /p "=%DEL% "
if !sel! equ %%O (call :colorText E8 "-!opt%%O!-" & call :ColorText_bg_BS E %cols%-13 /n
) else (
if !oldsel! equ %%O (
call :colorText 8E " !opt%%O!" & call :ColorText_bg_BS 8 %cols%-12 /n
) else call :colorText 8E " !opt%%O!" /n
)
)
pause>nul
set /a "oldsel=sel, sel=(sel %% num)+1"
goto :menu
goto :End_Main
:ColorText
<nul set /p ".=%BS%"> "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
rem del "%~2" > nul 2>&1
if /i "%~3"=="/n" echo(
goto :eof
:ColorText_bg_BS bg_color len [/n]
(
set /a "len=%2-1"
if !len! geq 1 for %%. in (!len!) do findstr /v /a:%1%1 /R "^$" "!str_findstr:~0,%%.!" nul
if /i "%~3"=="/n" echo(
goto :eof
)
:init_system
rem change to temp dir
pushd "%temp%"
for /f %%a in ('copy /Z "%~dpf0" nul') do set "CR=%%a"
rem make DEL
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
:: Define BS to contain a backspace
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
rem screen widht
set /a cols=78, lines=43
rem make a string with len %cols% cars
set "str_findstr="
For /L %%c in (1,1,%cols%) do set "str_findstr=!str_findstr!L"
rem male all lenght possibles, for speedup findstr
For /L %%l in (1,1,%cols%) do <nul set /p .=%BS%> "!str_findstr:~0,%%l!"
goto :Main
:End_Main
rem remove the temporary files... TODO!
popd
Goto :eof
einstein1969