Text Files - Coloured Characters

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
POSAM-Ron
Posts: 3
Joined: 29 May 2019 12:14

Text Files - Coloured Characters

#1 Post by POSAM-Ron » 29 May 2019 12:36

In the good old days of DOS , a text file contained individual characters preceded by a color code byte (background color and text/character color) for EACH character. Has that ability been lost? Is there a feature in DOS or some software that can still do that coloring? If so , how do you display the character-colored file in Windows (like my XP)?

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Text Files - Coloured Characters

#2 Post by penpen » 29 May 2019 17:10

You could use vt100 codes which are virtual terminal sequences:
https://docs.microsoft.com/en-us/window ... -sequences

Example:
viewtopic.php?f=3&t=8044

You might also want to read the folowing:
viewtopic.php?f=3&t=9144


penpen

IcarusLives
Posts: 175
Joined: 17 Jan 2016 23:55

Re: Text Files - Coloured Characters

#3 Post by IcarusLives » 29 May 2019 22:02

penpen wrote:
29 May 2019 17:10
-snip-
I very much appreciate you using MY code as an example! How exciting :)

OP,

Here are some examples of coloring with VT100. Mind you, this is a WIN10 feature.

The method below is using string substitution. You will notice VT100 colors very quickly.

Code: Select all

@echo off & setlocal enableDelayedExpansion
rem DEFINE ESC
for /f %%a in ('echo prompt $E^| cmd') do set "esc=%%a"

set "background=%esc%[48;5;cm"
set "textColor=%esc%[38;5;cm"
set "RGB=%esc%[38;2;r;g;bm"
set "resetAttribute=%esc%[0m"

echo %background:c=9%Hello World%resetAttribute%
echo %textColor:c=10%Hello World%resetAttribute%
echo %RGB:r;g;b=190;80;170%Hello World%resetAttribute%

pause>nul

POSAM-Ron
Posts: 3
Joined: 29 May 2019 12:14

Re: Text Files - Coloured Characters

#4 Post by POSAM-Ron » 31 May 2019 10:49

Hi > IcarusLives

* Thank you for your quick reply * I created a batch file with your code * It ran in XP but I only got the result > see attached image *

* It seems like nobody has written a text editor that will do this ancient form of text * It must have been possible back in the days . . . * Possibly ASCII art can do it but I just wanted to edit and display simple text * I downloaded > Personal Editor - pe32.zip < from > http://www.pe32.com/index.html < but that didn't do it either unless I don't know how to use that program well enough yet *

* Your batch programs seems to want to operate properly but it doesn't do the "sets" correctly *

* Thank you for your help *

POSAM

[img]file:E:\Colors.gif[/img]

POSAM-Ron
Posts: 3
Joined: 29 May 2019 12:14

Re: Text Files - Coloured Characters

#5 Post by POSAM-Ron » 03 Jun 2019 10:22

* I do appreciate your efforts to get me going on editing and displaying colored text the old fashioned DOS text way * Obviously , this capability has been lost to the history books * So , having spent many hours finding and downloading ASCII text editors and even using your batch solution , nothing seems to work * And , so , I will now move on to something much more productive in my life * Thanks again *
* BTW - it would be nice if one could attach a file , like an image file or text file * This website seems to be limited to URL protocols and not everyone has a website for you to access files *
POSAM

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Text Files - Coloured Characters

#6 Post by aGerman » 03 Jun 2019 12:28

As long as you still stick with XP you're out of luck. ANSI escape sequences are supported on Windows 10 version 10.0.10586 onwards.
If you don't want to use 3rd party tools on older Windows versions then check out FINDSTR /A workarounds like these
viewtopic.php?p=41155#p41155
viewtopic.php?p=22243#p22243

Steffen

elzooilogico
Posts: 128
Joined: 23 May 2016 15:39
Location: Spain

Re: Text Files - Coloured Characters

#7 Post by elzooilogico » 04 Jun 2019 00:06

or you may try ansicon

Post Reply