?
Solved

ANSI Color and TRichEdit

Posted on 2000-03-10
4
Medium Priority
?
440 Views
Last Modified: 2010-04-04

I'm trying to use a RichEdit box to create a custom terminal emulation
program that supports ANSI color codes (no other ANSI Escape codes are
needed currently), however, I've run into a slight problem with the
RichEdit control.  If I try to set the text on the control via
RichEdit1.Text := RichEdit1.Text + 'Blah blah'; or
RichEdit1.Lines.Text := RichEdit1.Lines.Text + 'Blah blah'; it strips
all my color and style changes.  However, if I use
RichEdit1.Lines.Add() or RichEdit1.Lines.Append(), it automatically
inserts a line break, which I don't want.

So far, any simple processes I've thought of to eliminate this haven't
worked.  I store the raw text with ANSI codes in a separate text file
and reparse the entire RichEdit control with an array of positions and
style/color definitions, but that would be extremely slow once I have
1000 lines or so.

Is there any simpler way to do this?  Or perhaps any alternate
components I could use which would parse this for me automatically?
0
Comment
Question by:DirewolfX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Expert Comment

by:TheNeil
ID: 2604300
You could try this:

iStart := RichEdit1.Text.Length;
RichEdit1.Text.Add('Blah, blah, blah');
RichEdit1.SelStart := iStart;
RichEdit1.SelLength := Length(RichEdit1.Text) - iStart;
RichEdit1.SelAttributes.Font.Color := clRed;

This will set the text attributes for each bit of text as you add it. If you want to speed things up then only use the above code when you need to change the text style/colour

The Neil
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 150 total points
ID: 2604313
just use
the seltext-property for inserting text like

richedit1.seltext := 'Blah Blah Blah';
0
 

Author Comment

by:DirewolfX
ID: 2606571
Kretzchmar's solution was correct.  Thanks!
0
 

Author Comment

by:DirewolfX
ID: 2606573
The solution worked, but it wasn't well explained.

However, if anyone knows any good third party ANSI text controls, I'm still interested...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question