Coloured active line
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Coloured active line
Last edited by CJ on Fri Apr 25, 2003 4:13 pm, edited 3 times in total.
This seems to have been implemented in 4.7. Yay! Of course, being able to choose the color would be cool.
On a related note, Is a moderator going to remove the threads which request a feature that was later implemented? Heck, maybe I should make a new thread about that =) I realize Keith's time is spread out over a bunch of forums, but we've got to keep this forum pared down so the developers can quickly figure out what they'd like to work on.
On a related note, Is a moderator going to remove the threads which request a feature that was later implemented? Heck, maybe I should make a new thread about that =) I realize Keith's time is spread out over a bunch of forums, but we've got to keep this forum pared down so the developers can quickly figure out what they'd like to work on.
~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~
-Steve Estes (Tyriel)
AIM: EnderW271
ICQ: 6854118
Email: destes[at]ix.netcom.com
-Steve Estes (Tyriel)
AIM: EnderW271
ICQ: 6854118
Email: destes[at]ix.netcom.com
Note: I started writing this post, then realized that I might have a really cool way to do highlighting of the active line without a lot of extra work. I whipped up a program to show how I would like active highlighting to work (since it is much easier to show than to explain). So, what follows in dark blue is my original thoughts, with all text in black being new thoughts.
I think I can see why the develpers implemented the active line highlighting the way they did (i.e. they didn't have to have a second set of forground/background color properties for syntax highlighting on the active line). Think about it. If you had a color scheme that used a black background with lighter text, and then had a yellow highlight color for the active line, your text on the active line would be nearly invisible.
However, it would sure be nice if this was implemented as a solid, colored line.
Here are what I think are some of the possible solutions to the problem, accompanied by my personal feelings on the solution:
1. Creating a duplicate set of colors for the active line would be the best solution visually, but would require (I suspect) major additions to the color scheme...changes which would effectively double the items requiring color settings. I expect that such a change would require a major development effort. I think I would like the flexibility that this would offer, but it seems overly complex to me...almost like overkill.
2. Going the simpler route and just using the existing foreground colors for the text with the active line highlight color as the background could work well...but only if the active line highlight color was close to the normal background color. I would like this solution, mainly because I the color I would select would be similar to my background so as to keep the active line visible, but not glaring. However, this solution may not be desireable for others who prefer to have a light colored active line on a dark background or vice-versa.
3. An even simpler route would involve stripping out syntax highlighting for the active line and just using the background/foreground colors of the "Current Line" item to render the line. I don't think I would like sacrificing the syntax highlighting on the active line in exchange for having it highlighted.
4. Do it like Textpad did it, but slightly better, i.e. make it work better with dark backgrounds. This is probably the simplest solution, especially since it is already implemented for the most part. I would actually use the active line highlighting as it is implemented in 4.7.0 if it only worked better with dark backgrounds. It isn't my first choice, but it seems to be a well-balanced choice from both a user and developer perspective.
5. Use a mathematical formula for determining the colors on the active line.
While writing option #5 I had an epiphany. This "formula" I was looking for was basically a form of alpha blending, or transparency. So, I made a test program using Delphi 7 that basically shows what I am talking about. If Textpad were to implement this for the active line feature, I think it would be a big improvement over the existing implementation.
It is much easier to show you how it works than to explain it, so I am making my demo program available for download.
http://members.cox.net/angantyr/ActiveLine.zip
(Note: As this is just a "proof of concept" app, I should give some basic instructions. Text in the top memo box is processed and echoed in paintbox below it. Any editing has to be done in the top box. The bottom box is just to show how the text appears after syntax and active line highlighting is applied. The bottom box doesn't scroll either. All color swatches can be changed, as well as the "transparency" of the highlight color.)
The concept works with both dark and light backgrounds and maintains syntax highlighting. If Textpad were to implement this, it would not require a new set of color settings for the active line.
I'll post the relevant source code that does the blending in another post. You will see that it doesn't require overly complex calculations and could probably be implemented fairly easily.
P.S. This method could also be used for normal highlighting as well!
EDIT: Just added the note on how to use the Active Line Demo program.
I think I can see why the develpers implemented the active line highlighting the way they did (i.e. they didn't have to have a second set of forground/background color properties for syntax highlighting on the active line). Think about it. If you had a color scheme that used a black background with lighter text, and then had a yellow highlight color for the active line, your text on the active line would be nearly invisible.
However, it would sure be nice if this was implemented as a solid, colored line.
Here are what I think are some of the possible solutions to the problem, accompanied by my personal feelings on the solution:
1. Creating a duplicate set of colors for the active line would be the best solution visually, but would require (I suspect) major additions to the color scheme...changes which would effectively double the items requiring color settings. I expect that such a change would require a major development effort. I think I would like the flexibility that this would offer, but it seems overly complex to me...almost like overkill.
2. Going the simpler route and just using the existing foreground colors for the text with the active line highlight color as the background could work well...but only if the active line highlight color was close to the normal background color. I would like this solution, mainly because I the color I would select would be similar to my background so as to keep the active line visible, but not glaring. However, this solution may not be desireable for others who prefer to have a light colored active line on a dark background or vice-versa.
3. An even simpler route would involve stripping out syntax highlighting for the active line and just using the background/foreground colors of the "Current Line" item to render the line. I don't think I would like sacrificing the syntax highlighting on the active line in exchange for having it highlighted.
4. Do it like Textpad did it, but slightly better, i.e. make it work better with dark backgrounds. This is probably the simplest solution, especially since it is already implemented for the most part. I would actually use the active line highlighting as it is implemented in 4.7.0 if it only worked better with dark backgrounds. It isn't my first choice, but it seems to be a well-balanced choice from both a user and developer perspective.
5. Use a mathematical formula for determining the colors on the active line.
While writing option #5 I had an epiphany. This "formula" I was looking for was basically a form of alpha blending, or transparency. So, I made a test program using Delphi 7 that basically shows what I am talking about. If Textpad were to implement this for the active line feature, I think it would be a big improvement over the existing implementation.
It is much easier to show you how it works than to explain it, so I am making my demo program available for download.
http://members.cox.net/angantyr/ActiveLine.zip
(Note: As this is just a "proof of concept" app, I should give some basic instructions. Text in the top memo box is processed and echoed in paintbox below it. Any editing has to be done in the top box. The bottom box is just to show how the text appears after syntax and active line highlighting is applied. The bottom box doesn't scroll either. All color swatches can be changed, as well as the "transparency" of the highlight color.)
The concept works with both dark and light backgrounds and maintains syntax highlighting. If Textpad were to implement this, it would not require a new set of color settings for the active line.
I'll post the relevant source code that does the blending in another post. You will see that it doesn't require overly complex calculations and could probably be implemented fairly easily.
P.S. This method could also be used for normal highlighting as well!
EDIT: Just added the note on how to use the Active Line Demo program.
Last edited by Angantyr on Fri Aug 08, 2003 10:03 pm, edited 1 time in total.
Here is the blending code in Delphi Pascal. It should be very easy to translate into C++. (I am assuming that this is the language Textpad is written in.)
Here are some basic TColor to RGB and vice-versa conversion functions. Note that TColor in Delphi is basically defined (in hex) as BBGGRR.
This is the main blending function:
This is the code that is used when the background color needs to be determined (for the active line). The normal background color for the text is blended with the blend color according to the blend percent.
This is the code that is used when a forground color needs to be blended. fcBlend is the blend color selected by the user. So basically, it just takes whatever color the text should be (based on syntax highlighting) and blends it with the blend color before painting it to the canvas.
That is the meat of the Active Line Demo program. The rest is just fluff.
-Angantyr
Here are some basic TColor to RGB and vice-versa conversion functions. Note that TColor in Delphi is basically defined (in hex) as BBGGRR.
Code: Select all
{------------------------------------------------------------------------------}
{ Converts TColor to TRGB }
{------------------------------------------------------------------------------}
function ColorToRGB(Color: TColor): TRGB;
begin
Result.R := Color mod $100;
Result.G := (Color div $100) mod $100;
Result.B := (Color div $10000) mod $100;
end;
{------------------------------------------------------------------------------}
{ Converts TRGB to TColor }
{------------------------------------------------------------------------------}
function RGBToColor(RGB: TRGB): TColor;
begin
Result := (RGB.B * $10000) + (RGB.G * $100) + RGB.R;
end;
Code: Select all
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
function TForm1.Blend(SourceColor, BlendColor: TColor; BlendPct: Byte): TColor;
var
SourceRGB: TRGB;
BlendRGB: TRGB;
ResultRGB: TRGB;
begin
SourceRGB := ColorToRGB(SourceColor);
BlendRGB := ColorToRGB(BlendColor);
ResultRGB.R := Round(((BlendPct * BlendRGB.R) + ((100 - BlendPct) * SourceRGB.R)) / 100);
ResultRGB.G := Round(((BlendPct * BlendRGB.G) + ((100 - BlendPct) * SourceRGB.G)) / 100);
ResultRGB.B := Round(((BlendPct * BlendRGB.B) + ((100 - BlendPct) * SourceRGB.B)) / 100);
Result := RGBToColor(ResultRGB);
end;
Code: Select all
pntBox.Canvas.Brush.Color := Blend(fcBackground, fcBlend, BlendPct);
Code: Select all
pntBox.Canvas.Font.Color := Blend(pntBox.Canvas.Font.Color, fcBlend, BlendPct);
-Angantyr
-
- Posts: 11
- Joined: Thu Aug 14, 2003 6:11 pm
- Location: Frankfort, Kentucky
- Contact:
Where did the dashed line thing come from?
Who came up with this idea? A simple colored line has been implemented in many packages before, to a positive response. Why in the world would someone want to change something so common and successful?
Guys, from a fellow software designer, please use the best of what's out there. That's the way to build a better product.
Guys, from a fellow software designer, please use the best of what's out there. That's the way to build a better product.
That dashed line thing bugs me too. Fortunately, the latest release of TextPad (4.7.1) allows you to specify the background color of the active line. Now, the dashed line is actually still there, but you can get rid of it by setting the foreground color of the "Current Line" to the same color as the background for "Text".
Thanks to this, I will be using the current line feature.
Thanks to this, I will be using the current line feature.
- s_reynisson
- Posts: 939
- Joined: Tue May 06, 2003 1:59 pm