:SetColor <nul SET /P "= [%~1;%~2m" needs a little more cosmetic update
Moderator: DosItHelp
:SetColor <nul SET /P "= [%~1;%~2m" needs a little more cosmetic update
CALL :SetColor 1 33
ECHO ============================================
ECHO Clipboard
CALL :SetColor 0 33
ECHO *once selected, the string will be in CTRL-V
CALL :SetColor 1 33
ECHO ============================================
:SetColor
<nul SET /P "= [%~1;%~2m"
EXIT /B
this :SetColor was one of the best i learned from dostips
is there a different way to change this <nul SET /P "= [%~1;%~2m" to be more readable? giving a variable with 0 size SET name is odd to me
********************
ECHO ============================================
ECHO Clipboard
CALL :SetColor 0 33
ECHO *once selected, the string will be in CTRL-V
CALL :SetColor 1 33
ECHO ============================================
:SetColor
<nul SET /P "= [%~1;%~2m"
EXIT /B
this :SetColor was one of the best i learned from dostips
is there a different way to change this <nul SET /P "= [%~1;%~2m" to be more readable? giving a variable with 0 size SET name is odd to me
********************
-
- Posts: 178
- Joined: 17 Jan 2016 23:55
Re: :SetColor <nul SET /P "= [%~1;%~2m" needs a little more cosmetic update
Code: Select all
@echo off
for /f %%a in ('echo prompt $E^| cmd') do set "\e=%%a" %= \e =%
set "text=%\e%[38;5;xm"
set "back=%\e%[48;5;xm"
set "noColor=%\e%[0m"
rem red background/white text
echo %back:x=196%%text:x=15%Hello World%noColor%
rem yellow background/red text
echo %back:x=226%%text:x=196%Hello World%noColor%
pause
Re: :SetColor <nul SET /P "= [%~1;%~2m" needs a little more cosmetic update
@ECHO off
CALL :SetColor_Title "A ! 1"
ECHO done
pause
GOTO :END
REM ********************************************
:SetColor_Title
FOR /F %%V IN ('ECHO prompt $E^| cmd') DO SET "\e=%%V" %= \e =%
SET "text=%\e%[38;5;xm"
SET "back=%\e%[48;5;xm"
SET "noColor=%\e%[0m"
REM red background/white text
ECHO %back:x=196%%text:x=15%%~1%noColor%
@EXIT /B
REM yellow background/red text
ECHO %back:x=226%%text:x=196%Hello World%noColor%
:END
REM 38 white
REM 48 red
REM 196 red
REM 15 white
REM 226 yellow
REM
REM
REM
REM
REM
**********************************************
you dont need a untypeable <esc> in front of [ in this batch, this part is interesting
i have used ...prompt $p$g...things in DOS's ansi.sys for a color change back in the day
i have no idea what SET "\e=%%V" %= \e =% does, i will just leave it as it is
there are too many different numbers going for the same color, so i may need a color data list. if you could point me where i could get, i'd be appreciated
possible to write a subroutine for me the way below? because at the moment too many numbers are going for the same color
CALL :SetColor_Title color1Num color2Num backgroundNum "Hello World"
color1Num = bright color/normal color switch ( color1Num isnt needed if bright color= normal color + 16)
color2Num = color number
thanks for this
CALL :SetColor_Title "A ! 1"
ECHO done
pause
GOTO :END
REM ********************************************
:SetColor_Title
FOR /F %%V IN ('ECHO prompt $E^| cmd') DO SET "\e=%%V" %= \e =%
SET "text=%\e%[38;5;xm"
SET "back=%\e%[48;5;xm"
SET "noColor=%\e%[0m"
REM red background/white text
ECHO %back:x=196%%text:x=15%%~1%noColor%
@EXIT /B
REM yellow background/red text
ECHO %back:x=226%%text:x=196%Hello World%noColor%
:END
REM 38 white
REM 48 red
REM 196 red
REM 15 white
REM 226 yellow
REM
REM
REM
REM
REM
**********************************************
you dont need a untypeable <esc> in front of [ in this batch, this part is interesting
i have used ...prompt $p$g...things in DOS's ansi.sys for a color change back in the day
i have no idea what SET "\e=%%V" %= \e =% does, i will just leave it as it is
there are too many different numbers going for the same color, so i may need a color data list. if you could point me where i could get, i'd be appreciated
possible to write a subroutine for me the way below? because at the moment too many numbers are going for the same color
CALL :SetColor_Title color1Num color2Num backgroundNum "Hello World"
color1Num = bright color/normal color switch ( color1Num isnt needed if bright color= normal color + 16)
color2Num = color number
thanks for this
-
- Posts: 178
- Joined: 17 Jan 2016 23:55
Re: :SetColor <nul SET /P "= [%~1;%~2m" needs a little more cosmetic update
This line of code gives you the ESC character. The character necessary for VT100.
Code: Select all
for /f %%a in ('echo prompt $E^| cmd') do set "\e=%%a" %= \e =%
Code: Select all
@echo off
for /f %%a in ('echo prompt $E^| cmd') do set "\e=%%a" %= \e =%
call :subroutine 196 15 "Hello World"
call :subroutine 226 196 "Hello World"
call :subroutine 46 202 "Hello World"
pause & exit
:subroutine
echo %\e%[38;5;%~1m%\e%[48;5;%~2m%~3%\e%[0m
goto :eof
Re: :SetColor <nul SET /P "= [%~1;%~2m" needs a little more cosmetic update
@echo off
for /f %%a in ('echo prompt $E^| cmd') do set "\e=%%a" %= \e =%
SetLocal EnableExtensions EnableDelayedExpansion
SET CC=14
SET /A C1=40+CC
:BEGIN
SET /A CC=!CC!+1
call :subroutine !CC! 15 "!CC! Hello World"
IF !CC!==%C1% GOTO :END
GOTO :BEGIN
pause & exit
:subroutine
echo %\e%[38;5;%~1m%\e%[48;5;%~2m%~3%\e%[0m
goto :eof
:END
****************************************
i thought 1st maybe 100 colors from VT100 in websites, it aint it, the batch gave me what lt looked like a spectrum of millions of colors
cool, i will make a personal palette
for /f %%a in ('echo prompt $E^| cmd') do set "\e=%%a" %= \e =%
SetLocal EnableExtensions EnableDelayedExpansion
SET CC=14
SET /A C1=40+CC
:BEGIN
SET /A CC=!CC!+1
call :subroutine !CC! 15 "!CC! Hello World"
IF !CC!==%C1% GOTO :END
GOTO :BEGIN
pause & exit
:subroutine
echo %\e%[38;5;%~1m%\e%[48;5;%~2m%~3%\e%[0m
goto :eof
:END
****************************************
i thought 1st maybe 100 colors from VT100 in websites, it aint it, the batch gave me what lt looked like a spectrum of millions of colors
cool, i will make a personal palette
-
- Posts: 178
- Joined: 17 Jan 2016 23:55
Re: :SetColor <nul SET /P "= [%~1;%~2m" needs a little more cosmetic update
With the one you're using now, just give it a value from 0-255
If you want full 24bit rgb, you can do that, too.
Code: Select all
call :subroutine 0-255 0-255 "TEXT"
Code: Select all
@echo off
for /f %%a in ('echo prompt $E^| cmd') do set "\e=%%a" %= \e =%
call :subroutine_text 255 0 0 "Hello World"
call :subroutine_text 0 255 0 "Hello World"
call :subroutine_text 0 0 255 "Hello World"
call :subroutine_back 255 0 0 "Hello World"
call :subroutine_back 0 255 0 "Hello World"
call :subroutine_back 0 0 255 "Hello World"
pause & exit
:subroutine_text
echo %\e%[38;2;%~1;%~2;%~3m%~4%\e%[0m
goto :eof
:subroutine_back
echo %\e%[48;2;%~1;%~2;%~3m%~4%\e%[0m
goto :eof
Re: :SetColor <nul SET /P "= [%~1;%~2m" needs a little more cosmetic update
REM 1 red
REM 2 green
REM 3 yellow
REM 4 blue
REM 5 magenta
REM 6 cyan
REM 7 gray
REM 8 dark gray
REM 9 bright red
REM 10 bright green
REM 11 bright yellow
REM 12 bright blue
REM 13 bright magenta
REM 14 bright cyan
REM 15 white
REM 16 black
i got it 1st 16 of them has the basic... then it goes to gradient
ok 255, thanks
REM 2 green
REM 3 yellow
REM 4 blue
REM 5 magenta
REM 6 cyan
REM 7 gray
REM 8 dark gray
REM 9 bright red
REM 10 bright green
REM 11 bright yellow
REM 12 bright blue
REM 13 bright magenta
REM 14 bright cyan
REM 15 white
REM 16 black
i got it 1st 16 of them has the basic... then it goes to gradient
ok 255, thanks
Re: :SetColor <nul SET /P "= [%~1;%~2m" needs a little more cosmetic update
@ECHO OFF
FOR /F %%V IN ('ECHO prompt $E^| cmd') DO SET "\e=%%V" %= \e =%
CALL :SetColor-RGB 255 0 0 0 255 0 "Hello World"
CALL :SetColor-RGB 0 255 0 0 0 255 "Hello World"
CALL :SetColor-RGB 0 0 255 255 0 0 "Hello World"
GOTO :END
:SetColor-RGB
ECHO %\e%[38;2;%~1;%~2;%~3m%\e%[48;2;%~4;%~5;%~6m%~7%\e%[0m
@EXIT /B
:END
apparently i have a manipulation skill even though i do not understand most operators
FOR /F %%V IN ('ECHO prompt $E^| cmd') DO SET "\e=%%V" %= \e =%
CALL :SetColor-RGB 255 0 0 0 255 0 "Hello World"
CALL :SetColor-RGB 0 255 0 0 0 255 "Hello World"
CALL :SetColor-RGB 0 0 255 255 0 0 "Hello World"
GOTO :END
:SetColor-RGB
ECHO %\e%[38;2;%~1;%~2;%~3m%\e%[48;2;%~4;%~5;%~6m%~7%\e%[0m
@EXIT /B
:END
apparently i have a manipulation skill even though i do not understand most operators
Re: :SetColor <nul SET /P "= [%~1;%~2m" needs a little more cosmetic update
Code: Select all
@ECHO OFF
FOR /F %%V IN ('ECHO prompt $E^| cmd') DO SET "\e=%%V" %= \e =%
SetLocal EnableExtensions EnableDelayedExpansion
SET CC=0
SET /A C1=40+CC
:BEGIN
SET /A CC=!CC!+1
IF !CC! GEQ 1 IF !CC! LEQ 9 SET DD= !CC!
IF !CC! GTR 9 SET DD=!CC!
CALL :SetColorVT100 !CC! 16
ECHO !DD!. Hello World
IF !CC!==%C1% GOTO :END
GOTO :BEGIN
:SetColorVT100
<nul SET /P "= %\e%[38;5;%~1m%\e%[48;5;%~2m"
@EXIT /B
:END
Code: Select all
@ECHO OFF
FOR /F %%V IN ('ECHO prompt $E^| cmd') DO SET "\e=%%V" %= \e =%
SetLocal EnableExtensions EnableDelayedExpansion
SET CC=0
SET /A C1=40+CC
:BEGIN
SET /A CC=!CC!+1
IF !CC! GEQ 1 IF !CC! LEQ 9 SET "DD= !CC!"
IF !CC! GTR 9 SET "DD=!CC!"
CALL :SetColorRGB-BG16 !CC!
ECHO !DD!. Hello World
IF !CC!==%C1% GOTO :END
GOTO :BEGIN
GOTO :END
:SetColorRGB-BG16
IF "%~1"=="1" SET "R=255" &SET "G=0" &SET "B=0"
IF "%~1"=="2" SET "R=0" &SET "G=180" &SET "B=0"
IF "%~1"=="3" SET "R=192" &SET "G=153" &SET "B=50"
IF "%~1"=="4" SET "R=0" &SET "G=0" &SET "B=255"
IF "%~1"=="5" SET "R=192" &SET "G=0" &SET "B=192"
IF "%~1"=="6" SET "R=51" &SET "G=153" &SET "B=255"
IF "%~1"=="7" SET "R=192" &SET "G=192" &SET "B=192"
IF "%~1"=="8" SET "R=128" &SET "G=128" &SET "B=128"
IF "%~1"=="9" SET "R=255" &SET "G=53" &SET "B=0"
IF "%~1"=="10" SET "R=0" &SET "G=255" &SET "B=0"
IF "%~1"=="11" SET "R=255" &SET "G=255" &SET "B=0"
IF "%~1"=="12" SET "R=0" &SET "G=100" &SET "B=255"
IF "%~1"=="13" SET "R=255" &SET "G=51" &SET "B=255"
IF "%~1"=="14" SET "R=0" &SET "G=255" &SET "B=255"
IF "%~1"=="15" SET "R=255" &SET "G=255" &SET "B=255"
IF "%~1"=="16" SET "R=0" &SET "G=0" &SET "B=0"
<nul SET /P "= %\e%[38;2;%R%;%G%;%B%m"
@EXIT /B
:END
what would you name this sub(:SetColorVT100) which can make itself distinguish from SetColorRGB?
SetColorVT100 or SetColor-mode16 or SetColor-textmode, because i havent heard of VT100 till now
:SetColorVT100
<nul SET /P "= %\e%[38;5;%~1m%\e%[48;5;%~2m"
@EXIT /B
i hope you to run the SetColorRGB batch and see how rich ad clear and bright the colors are compared to the SetColorVT100. because i can see RED in RGB, but still not so much with BLUE
Re: :SetColor <nul SET /P "= [%~1;%~2m" needs a little more cosmetic update
https://mega.nz/file/rQoXRKTL#UkSPi4hW- ... 0ughPzFcuw
the link has the comparison image shot VT100 vs RGB
the link has the comparison image shot VT100 vs RGB