Page 1 of 1

scrolling region test

Posted: 03 Sep 2024 04:16
by miskox
Here is a scrolling region test.

Code: Select all

@echo off
mode con cols=80 lines=24
cls

REM Aacini's solution (see below for more info regarding this correction)
for /f %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"

echo                  S C R O L L I N G      T E S T

echo %esc%[21;0H======================================================================
echo                  S C R O L L I N G      T E S T 

REM set scrolling region lines 10-20
echo %esc%[10;20r

echo %esc%[9;0H======================================================================

for /L %%f in (100,1,120) do echo %%f&timeout /T 1 >nul

echo %esc%[22;0H

Output (shortened to fit):

Code: Select all

                 S C R O L L I N G      T E S T
======================================================================
100
101
102
103
104
105
106
107



======================================================================
                 S C R O L L I N G      T E S T
and when finished:

Code: Select all

                 S C R O L L I N G      T E S T
======================================================================
111
112
113
114
115
116
117
118
119
120

======================================================================
                 S C R O L L I N G      T E S T
Saso

Updated: Aacini is the author of the way how ESC gets into a variable. Source updated. See below. Aacini: I am very sorry. This was not intentional.

Re: scrolling region test

Posted: 05 Sep 2024 21:49
by Aacini
Interesting! :) I translated your code to printf.exe (version 2.81 with \e as ESC and enabled Virtual Terminal Processing). Here it is:

Code: Select all

@echo off
mode con cols=80 lines=24
cls

printf "%%s\n"		/* format to show strings */			^
   "                 S C R O L L I N G      T E S T"  OUT ^<		^
   "\e[21;0H======================================================================"  OUT ^<	^
   "                 S C R O L L I N G      T E S T"  OUT ^<		^
   "\e[10;20r"  OUT ^<		/* set scrolling region lines 10-20 */	^
   "\e[9;0H======================================================================"   OUT ^<	^
   1000 ]0 ^<			/* milliseconds to wait in GETK? */	^
   FMT{ "%%i\n" 100 ( OUT ++ 120 ^<=x? ^< ( GETK?:0 ) : ) FMT}		^
   "\e[22;0H" OUT

Antonio

PS - I wonder why you called the method to get the ESC character "Jeb's solution"...

Re: scrolling region test

Posted: 05 Sep 2024 23:07
by miskox
Aacini wrote:
05 Sep 2024 21:49
PS - I wonder why you called the method to get the ESC character "Jeb's solution"...
Because: https://ss64.com/nt/syntax-ansi.html

where it says:
A batch file to save the ESC character in a variable %ESC% (via Jeb on the forum)
Did I miss something?

Saso

Re: scrolling region test

Posted: 09 Sep 2024 14:02
by Aacini
miskox wrote:
05 Sep 2024 23:07

Did I miss something?

Saso
Mmm... Maybe you missed this reply where I posted such a method for the first time more than 7 years ago...

Such topic, posted on 2017/Aug/22, is particularly interesting. At the beginning, IcarusLives shows an example where he inserts a hardcoded ESC character into the program. Then, penpen suggests using the strange method to get an ESC based on a for %%b in (1) do rem command that was commonly used at the time. After that, I present the method that everyone is using now:

Code: Select all

for /F %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"
The funny thing is that a couple of replies below my post there is a reply from yourself addressed to me!

Yes, I think you did miss several things...

Antonio

Re: scrolling region test

Posted: 10 Sep 2024 00:19
by miskox
Antonio, I am very sorry. I really did not read that topic again - I just assumed that SS64's information is correct. Please accept my sincere apology. I didn't want to give credit to a wrong person. Then I guess Simon (SS64) should correct that info.

Saso

Re: scrolling region test

Posted: 10 Sep 2024 14:34
by Aacini
miskox wrote:
10 Sep 2024 00:19
Then I guess Simon (SS64) should correct that info.

Saso
Yes, he already did...

Thanks a lot!

Antonio

Re: scrolling region test

Posted: 11 Sep 2024 14:36
by Sponge Belly
Hi All,

Ed Dyreen and Dave Benham discussed capturing the backspace character in the Send Backspace Key in Batch topic as far back as 2012.

HTH! :)

- SB

Re: scrolling region test

Posted: 11 Sep 2024 15:35
by Aacini
Yes, you are right Sponge Belly.

Ed Dyrenn first proposed this method:

Code: Select all

   for /f "delims=#" %%a in (
      '"prompt #$H# &echo on &for %%b in (1) do rem"'
   ) do (
      set "%$Defines%=%%a"
      set "%$Defines%=!$BS:~0,1!"
   )
... and then dbenham suggested this simplification:

Code: Select all

for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
This last code was widely used until I posted my method in 2017:

Code: Select all

for /F %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"
... that was the point we are talking about in the replies above...

Antonio

Re: scrolling region test

Posted: 12 Sep 2024 11:10
by jeb
Hi,

a bit nitpicking :D

new functions: :chr, :asc, :asciiMap (Fri Apr 01, 2011 10:34 pm)

I probably developed the ESC, DEL and CR (buffer overflow) technique, but the rest was just a copy and paste.

jeb