[Lazarus] Displaying text with colour and insertion point
Mark Morgan Lloyd
markMLl.lazarus at telemetry.co.uk
Wed May 16 17:32:43 CEST 2012
Martin wrote:
> On 16/05/2012 14:13, Mark Morgan Lloyd wrote:
>> Martin wrote:
>>>
>>> The normal way (see example):
>>> // Line 0, from start of line to pos 3 (3 chars) highlighted as
>>> Attr1
>>> Highlighter.AddToken(0,3,Attr1);
>>>
>>> but this will do a single char
>>> Highlighter.AddToken(0,3,Attr1); // Attr1 from col 3
>>> Highlighter.AddToken(0,4,tkText); // text from col 4
>>>
>>
>> I don't think any sort of pre-existing custom highlighter will work.
>> The requirement here is that anything- completely context-free- that
>> the user enters is red, anything that the host supplies (over telnet,
>> serial line etc.) is black. Either of those can be complete garbage,
>> but should still show up in the correct colour (and should stay
>> correct, irrespective of scrolling etc.).
>
> The position highlighter refers to position in text. Scrolling via
> scrollbar is no problem.
>
> But if you add/remove lines; or add/remove chars in a line, you must
> update the positions.
>
> I assume you have a fixed amount of lines and columns? If so it should
> be very simple to write a pos-highlighter (part of your project, does
> not need to be registerred in IDE), that has
>
> CharAttributes: Array[1..maxLine] of array [ 1..MaxColumn] of TAttribute
>
> Of course that is not practical if you have thousands of lines, as it
> would require a lot of storage....
Since it's emulating a mechanical terminal that printed to roll paper,
the number of lines is indeterminate and increasing. I suppose that I
could limit it to (say) 1000, but if other people started using it
there'd be bound to be somebody complain.
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the Lazarus
mailing list