Page 1 of 2

Coloured active line

Posted: Thu Apr 24, 2003 11:17 pm
by CJ
    I would like to optionally have the current line coloured a differnt background colour. This way you can always clearly see where your cursor is.

    Posted: Fri Apr 25, 2003 1:05 pm
    by Bonzo
    I'll second that!... its a little thing, but once you've used this in another editor, you won't understand how you lived without it...

    Posted: Tue May 06, 2003 4:32 pm
    by zridling
    Crimson Editor and UltraEdit allow the active line color/shade to be customized. I shade it light gray or light yellow and it's noticeable, but not obtrusive. It's a good feature.

    Posted: Thu Jun 05, 2003 12:05 pm
    by jeffy

    Posted: Thu Jun 12, 2003 3:53 pm
    by rcoats
    As a minimum it would be nice to be able to set the colour of the cursor (I normally use red in other editors which stands out well).

    Posted: Wed Jul 16, 2003 6:58 pm
    by Tyriel
    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.

    Posted: Wed Jul 16, 2003 7:31 pm
    by MudGuard
    It IS possible to set the color...

    Posted: Mon Jul 21, 2003 1:12 pm
    by b-urn
    Unfortunately.. the color-selecting for this feature doesn't work very well if you try to use darker shades of colour for the background.

    For some reason, it doesn't allow me to select brighter colours for highlighting the cursorline, when I use a darker background-colour (eg. dark-blue, black).

    Posted: Fri Aug 08, 2003 9:27 pm
    by Angantyr
    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.

    Posted: Fri Aug 08, 2003 9:57 pm
    by Angantyr
    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.

    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;
    
    This is the main blending function:

    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;
    
    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.

    Code: Select all

        pntBox.Canvas.Brush.Color := Blend(fcBackground, fcBlend, BlendPct);
    
    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.

    Code: Select all

        pntBox.Canvas.Font.Color := Blend(pntBox.Canvas.Font.Color, fcBlend, BlendPct);
    
    That is the meat of the Active Line Demo program. The rest is just fluff.

    -Angantyr

    Posted: Tue Aug 12, 2003 6:23 pm
    by jeffy
    Because of the adverse comments from users about how this feature was implemented in 4.7, I'm re-adding it to the poll rankings

    Where did the dashed line thing come from?

    Posted: Fri Aug 15, 2003 1:23 pm
    by briankiser
    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.

    Posted: Fri Oct 03, 2003 7:48 pm
    by Angantyr
    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.

    Posted: Fri Nov 07, 2003 11:44 am
    by jom
    How can I change the default active line background/foreground colour so I do not need to set them for every new/opened document?

    Posted: Fri Nov 07, 2003 12:07 pm
    by s_reynisson
    Close all open documents, then goto
    Configure->Preferences->Document Classes->Default->Colors
    and select Current line. HTH