Page 1 of 1

Desperate to change command window buffer size or alternate

Posted: 06 Jun 2012 12:54
by MKANET
To my horror, I just realized that the text color changing utility (as well as other ones I've tried) have a strange bug in it which requires the command window's vertical buffer size to be large enough in order for colors to be displayed correctly. I didn't notice this bug since I always have my buffer size set to 300 lines or more. When I reset the history back to the default 25 lines, my heart practically stopped. Without the buffer size being large enough, the colors on the screen spill over; making a big mess. My entire batch file uses this color changing utility all over the place. :(

I am hoping someone much smarter than me can figure out the best way to handle this with the least amount of code change to my gigantic batch file.

Where, even the simplest code can trigger this bug in any of the below utilities. I can't find any mention of this bug anywhere.
Image

Test.cmd

Code: Select all

:start
chgcolor.exe 80
echo Test test test test test
chgcolor.exe 07
echo      -Test test test test test
echo      -test test test test test
goto start



chgcolor.exe
http://www.mailsend-online.com/blog/set ... -file.html
CoColor.exe
http:\\www.horstmuc.de/win/cocolor.zip
ColorX.exe
http:\\www.westmesatech.com/files/sst27.zip

Re: Desperate to change command window buffer size or altern

Posted: 06 Jun 2012 13:03
by MKANET
I am able to circumvent this bug by using the below subroutine (without an external utility). However, the current syntax to use it is far too different than what I'm using now. So, maybe there's a way to use this technique; however, still keep very close to the same syntax I currently have in my gigantic batch file; so it would work as close to the below syntax as possible :

Current method in gigantic batch file:

Code: Select all

chgcolor.exe 80
echo Test test test test test
chgcolor.exe 07




Below code doesnt have the bug; probably because there's better control when it reaches end-of-line or carriage return. If there was a way to change this to work similar to the other utilities; without the same problem.

Code: Select all


:start             
call :txtcolor 4f "test test test test test test" /n
ECHO     -TEST test test test test test test
ECHO     -TEST test test test test test test
goto start



goto end
:txtcolor Color  Str  [/n]
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do

rem"') do set "DEL=%%a"
<nul >"%temp%\x" set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%.%DEL%"
setlocal
set "str=%~2"
call :txtcolorvar %1 str %3
if exist "%temp%\x" del /q "%temp%\x" >nul
exit /b
:txtcolorvar  Color  StrVar  [/n]
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do

rem"') do set "DEL=%%a"
<nul >"%temp%\x" set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%.%DEL%"
if not defined %~2 exit /b
setlocal enableDelayedExpansion
set "str=a%DEL%!%~2:\=a%DEL%\..\%DEL%%DEL%%DEL%!"
set "str=!str:/=a%DEL%/..\%DEL%%DEL%%DEL%!"
set "str=!str:"=\"!"
pushd "%temp%"
findstr /p /A:%1 "." "!str!\..\x" nul
if /i "%~3"=="/n" echo(   
if exist "%temp%\x" del /q "%temp%\x" >nul
exit /b

:end

Re: Desperate to change command window buffer size or altern

Posted: 06 Jun 2012 14:45
by MKANET
Simple solution...

AutoIt, again, saved me. It has the ability to change the console buffer without changing the height. Problem resolved!

Re: Desperate to change command window buffer size or altern

Posted: 06 Jun 2012 16:40
by Fawers
Apparetly, AutoIt can do anything. :lol: