LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-28-2008, 10:01 AM   #1
mintzyuval
LQ Newbie
 
Registered: Dec 2008
Location: Tel-Aviv, Israel
Posts: 14

Rep: Reputation: 0
Which text editor supports ANSI escape sequences?


Hey,

I have logs produced by programs that print to the terminal with colors using escape sequences.

I usually use VIM (or gvim) to open logs, but seeing all those escape sequences instead of colors really bother me.

Is there a way to set VIM to use esacape-sequences (as opposed of showing them on screen)? if not, do you happen to know a solid text-editor that can do that?

Thanks,
Mintz Yuval
 
Old 12-28-2008, 10:47 AM   #2
mk27
Member
 
Registered: Sep 2008
Distribution: fedora, gentoo, ubuntu
Posts: 148

Rep: Reputation: 23
Well, the point of a text editor is to edit text files, not process them, so I'm going to guess that you're out of luck on this (on the other hand, vim can make toast and do dishes if you configure it right and want to deal with the somewhat painful documentation, so you never know).

Google around. What you want is some kind of VIEWER, not editor. This is like: you view web pages in a browser, you edit them in a text editor. They look very different in these two places for good reason -- the purpose of the text editor is for editing the html code.

I do GUI programming and it would be a simple task to write something to do what you want, so perhaps someone has done it already -- you just have to find where they put it.
 
Old 12-28-2008, 11:55 AM   #3
mintzyuval
LQ Newbie
 
Registered: Dec 2008
Location: Tel-Aviv, Israel
Posts: 14

Original Poster
Rep: Reputation: 0
I guess you're right and I've mis-pronounced my purpose.

I'll google for it; if someone can point me to such a viewer, I'd be grateful.

Thanks,
Mintz Yuval
 
Old 12-29-2008, 04:16 AM   #4
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Given that a number of text editors can be set to do colouring of text dependant upon input language (C, C++, perl, bash script...) if you find a tutorial on how to set up one of those for a new language, you may be able to modify things so that it highlights dependant on escape sequences. Don't underestimate the work in this approach, though.
 
Old 08-05-2009, 07:17 PM   #5
DaveQB
Member
 
Registered: Oct 2003
Location: Sydney, Australia.
Distribution: Debian, Ubuntu
Posts: 400

Rep: Reputation: 39
Best I could find on this...

http://blog.hartwork.org/?p=88
 
Old 08-05-2009, 08:22 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You might want to look at the Text Terminal HOWTO at the www.tldp.org website.

http://tldp.org/HOWTO/Text-Terminal-HOWTO.html#toc22

Also look at the setting of the console program you are using. You may be able to simply change the terminal emulation settings, allowing the colors to be displayed properly when viewing a log in the less program.

Last edited by jschiwal; 08-05-2009 at 08:27 PM.
 
Old 08-05-2009, 08:40 PM   #7
DaveQB
Member
 
Registered: Oct 2003
Location: Sydney, Australia.
Distribution: Debian, Ubuntu
Posts: 400

Rep: Reputation: 39
Thanks. Yeah I read the less manual,but not thoroughly enough.

http://www.linuxquestions.org/questi...uences-511166/

less -R <file with escape characters>
 
Old 08-08-2009, 01:57 PM   #8
mintzyuval
LQ Newbie
 
Registered: Dec 2008
Location: Tel-Aviv, Israel
Posts: 14

Original Poster
Rep: Reputation: 0
Well, "less -R" obviously work - but my original intention was to find an editor that can show colored ANSI qoutes, not a viewer; and unless I'm terribly misinformed, less does not qualify as one.
 
Old 11-17-2017, 06:00 PM   #9
miriam-e
LQ Newbie
 
Registered: Nov 2011
Location: QLD, Australia
Distribution: Puppy Linux
Posts: 29

Rep: Reputation: Disabled
ANSI text editors

I was searching for the same thing: an ANSI text editor that could show ANSI (color, bold, underline, etc) directly and edit it.

When I searched for "ANSI" on the amazing site http://texteditors.org (they list 1,879 text editors there) it listed 83 results. It's going to take me a while to narrow the list down to good Linux ANSI editors. I'll try to remember to post back here when I find a winner.

Here are some initial contenders:

Linux ANSI Draw - Drawing program for creating ANSI screens
Author: choc
Download: http://www.ibiblio.org/pub/Linux/app....0.0.7a.tar.gz
Family: SpecializedFamily
License: Freeware
Availability: yes
Platform: Linux
Linux ANSI package similar to DOS based ANSI packages and is designed for use on linux console.

Duh DRAW - Graphic ANSI Editor for linux similar to TheDraw
Author: Ben Fowler
Download: http://www.ibiblio.org/pub/Linux/app...-2.6.96.tar.gz
Family: SpecializedFamily
License: GPL
Availability: yes
Platform: Linux
Graphic ANSI Editor. Features the ability to translate one colorshading scheme into another, Block Flip and Mirror, SAUCE support, 1000 line maximum ANSI size, IBM high ascii character support. Includes utilities to convert created ANSI's to C data statements for inclusion in programs and a fullscreen scrolling ANSI Viewer.

SyncDraw is a multi-platform ANSI drawing program
Author: Stephen Hurd
Homepage: http://syncdraw.bbsdev.net/
Family: MsDosEditors, SpecializedFamily
License: Open source
Availability: yes
Platform: Windows, Apple OSX, Linux, OpenBSD, NetBSD, and FreeBSD
SyncDraw is an ANSI drawing program which supports:
- Windows 95/98/ME/NT/2000/XP, Apple OSX, Linux, OpenBSD, NetBSD, and FreeBSD
- Runs in full-screen mode under Windows
- *nix versions will run using X or using curses
- Support for IBM low and high ASCII including the face graphics (☺ and ☻) and card symbols (♠, ♣, ♥, and ♦) which so many other programs have problems with (may not work in curses mode... depends on the terminal being used).
- Up to 1000 lines
- Mouse-driven menus
- Copy/Paste
- Can use TheDraw fonts
- Can save/load ANSI, Avatar, PCBoard, ASCII, Binary, C and Synchronet formats
- Supports Sauce
- Line drawing mode
Seems similar or follow up/fork of Mystic Draw by Mike Krueger http://sourceforge.net/projects/mysticdraw/

Tetradraw is a fully featured ANSI art editor for *nix operating systems
Author: John McCutchan
Homepage: http://tetradraw.sourceforge.net/
Family: MsDosEditors, SpecializedFamily
License: Freeware|Shareware|Open source|GPL
Availability: yes
Platform: Unix, Linux
Tetradraw is a fully featured ANSI art editor for *nix operating systems by John McCutchan. ANSI art is only made of the ASCII characters with 16 colours. ANSI art is mainly used in text mode interfaces. Tetradraw is the first completly usable ANSI art editor for *nix operating systems. However Tetradraw does not only emulate the ansi editors for DOS. Tetradraw is revolutionary in the way ANSI art can be drawn, for the first time ever two artists can draw together over the internet on the exact same image (MultiDraw). This has been a long awaited feature and should provide a new level of art.
On top of the ground breaking MultiDraw here are some of Tetradraw's features:
- ANSI art is not limited to a certain amount of lines. Your art can be an unlimited length.
- Informative status bar.
- Built in ASCII character table.
- Built in Chat interface for MultiDraw.
- A powerful block command. Featuring character and colour replacement and fill. Flipping on the X and Y axes. Transparent Layer mode.
- 20 configurable character sets.
- A powerful interface.
- Supports the ANSI, ASCII and BIN file formats.
- You get complete access to the source code to make any improvements or changes you want.
- Many configurable options that can be changed from internal options screen.
- A separate ANSI viewer: Tetraview.
- Fully compatible with all DOS based ANSI editors and the linux console.
- Auto backup of the image you are working on.
- Built in quick help screen.

I know these are draw programs, but I think they can probably be used as just ANSI text editors too.

Last edited by miriam-e; 11-17-2017 at 06:22 PM.
 
Old 11-17-2017, 07:43 PM   #10
miriam-e
LQ Newbie
 
Registered: Nov 2011
Location: QLD, Australia
Distribution: Puppy Linux
Posts: 29

Rep: Reputation: Disabled
ANSI text editors

The winners so far are TetraDraw and SyncDraw.

TetraDraw comes with source that you can compile (a major advantage), but is really weird to use. Reading the documentation is an absolute necessity.
http://tetradraw.sourceforge.net/docs.html

SyncDraw comes pre-compiled (major drawback), but is very easy to use, even if it takes a few minutes of exploring to get the hang of it. The ESC key brings up menus (there's even a help screen accessible from the menu) and you can use the mouse to select colour and character set. Also you can position the cursor anywhere using the mouse. The webpage is at http://syncdraw.bbsdev.net/ and there does seem to be source available from http://cvs.synchro.net/cgi-bin/viewcvs.cgi/ but it is very slow to download and may be an entire BBS system, with SyncDraw just one small part of it.

"Linux ANSI Draw" and "Duh DRAW" are only available precompiled and don't work on my computer. You may have better luck.

I'll keep looking for more later when I have more time.
 
Old 11-18-2017, 01:01 PM   #11
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
I don't think I fully understand the problem, but take a look at SciTE -- GUI text editor that does syntax highlighting. If it doesn't do what you want out of the box, it can probably be configured.
 
Old 11-18-2017, 06:31 PM   #12
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
I haven't looked into ANSI editors since I was using TheDraw to make BBS menus, but Google got me a guide to setting up Joe for this:

https://stackoverflow.com/a/2303758

Last edited by dugan; 11-18-2017 at 07:37 PM.
 
Old 11-18-2017, 06:59 PM   #13
miriam-e
LQ Newbie
 
Registered: Nov 2011
Location: QLD, Australia
Distribution: Puppy Linux
Posts: 29

Rep: Reputation: Disabled
scasey, syntax highlighting isn't the same thing. ANSI escape sequences mean that you can, for instance, display the text:
The quick brown fox jumps over the lazy dog.
But do it using the same old ANSI escape sequences that are commonly used to display text in the commandline console of your computer. If I was to represent the escape character as \e then the previous line would be written as:
The \e[1mquick\e[0m \e[3mbrown\e[0m \e[4mfox\e[0m \e[32;1mjumps\e[0m over the \e[1;4mlazy\e[0m \e[31mdog\e[0m.

To prove to you that it works, copy the command below into your console:
Code:
echo -e "The \e[1mquick\e[0m \e[3mbrown\e[0m \e[4mfox\e[0m \e[32;1mjumps\e[0m over the \e[1;4mlazy\e[0m \e[31mdog\e[0m."
The "-e" option in the echo command enables the use of escaped characters, in this case the "\e" which is the actual escape character itself -- character 27.

You might think, what's the point? I mean I can type in the actual escape sequences by hand (\e[1m sets bold text for instance) but in practice it is a major hassle. Much better if I can let the computer take care of that because it's the kind of thing computers do really well, and leave myself to working on the creative part -- the things we humans do really well.

Well, you wonder, why not just use a wordprocessor or an HTML editor? Using a wordprocessor to do simple writing tasks is often like using a steamroller to crack a peanut. They are big and slow, and have a gazillion options that are unneeded for 99% of ordinary text, and their outputs are largely incompatible with each other. This is the beauty of ordinary text. Anything can read flat text, and even with ANSI sequences it can be displayed with or without the codes almost anywhere.

And an HTML editor? Well, yes. I often resort to that when I want to write simple stuff with a little bit of markup, but often that feels like overkill, especially if I'm using a lower-powered computer or my main computer is currently heavily loaded with lots of stuff (for example rendering complex scenes in Blender3D). The last thing I want to do is invite a crash or a glitch by pushing it to load another moderately big program. And even though there are simple, fast, low-footprint HTML viewers now, like Dillo, it often seems too much for a simple piece of text.

If I can use something on the level of Leafpad to write simple ANSI styled text then it makes my life a lot simpler.

Last edited by miriam-e; 11-18-2017 at 07:01 PM.
 
Old 11-18-2017, 11:23 PM   #14
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
miriam-e:
I said I didn't understand the problem/question...'tho I get the ANSI stuff: My root prompt, in blue:
Code:
export PS1="\[\e[2;34m\][\u@\h:\w]# \[\e[0m\]"
so I remember when I'm root.
 
Old 11-19-2017, 01:53 AM   #15
miriam-e
LQ Newbie
 
Registered: Nov 2011
Location: QLD, Australia
Distribution: Puppy Linux
Posts: 29

Rep: Reputation: Disabled
scasey, no worries.

Interesting prompt.

Mine is:
PS1="\[\e]2;\w\a\e[32m\]$USER\\$ \[\e[0m\]"

The sequence "\e]2;" puts the next bit of text up to the "\a" on the terminal's titlebar. As the text it puts there is the sequence "\w" which represents the current working directory this lets me keeps the commandline prompt short without sacrificing information.

I notice you color your prompt blue. I color mine green. It makes sense to have a colored prompt as it stands out nicely looking back over many lines of output trying to find the previous prompt. I use a different way to give my username (I can't remember why I didn't use the simpler "\u"), and I don't bother with the hostname.

I can't remember why the "\$" needed to be double-escaped. It shows as "$" when I'm a lower-privileged user and "#" when I'm root. It's probably overkill. I think I originally used it by itself, but forgot about it and was surprised when it changed (when switching root/lower-privilege), so added the "$USER" to make it explicit.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Less outputs ANSI escape sequences sprocketboy Mandriva 2 08-05-2009 08:22 PM
escape sequences in enscript lanco Linux - Newbie 1 03-01-2009 02:32 PM
LXer: CLI Magic: Use ANSI escape sequences to display a clock in your terminal LXer Syndicated Linux News 0 01-22-2008 10:20 PM
How to stop terminal escape sequences ? Mike Davies Linux - Newbie 1 08-08-2004 11:37 AM
Xterm escape sequences GrayGh0st Linux - Software 3 07-19-2003 12:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration