O
ozbear
I have been writing a Telnet client control with various terminal type
emulations available such as ANSI, VT100, Linux/XTERM, etc. While my
control works, the actual console portion of it derives from the old
workhorse richeditbox.
Richedit supplies useful functionality such as a cursor, ability to
copy the text to the clipboard, colours/highlighting and so forth,
but is relatively clumsy when updating when new information is sent
from the Telnet host.
For example, when connected to a Linux host, the "aptitude" program
sends back an extremely "busy" panel of information. There are
many, many, cursor positioning and highlighting commands in the
datastream and the information to be displayed is not in a simple
top-to-bottom sequence.
Since the ANSI highlighting commands only specify the current high-
light to be applied from the current cursor position on, you cannot
really start doing highlighting via the various richtextbox
Selectionxxxx method calls since you do not yet know how long the
selection is until another highlighting sequence arrives.
I have solved that issue by maintaining a backing array of row x
columns characters and row x columns attributes (underline,
reverse video, forecolor, backcolor, "blink"). As characters arrive
from the host, the backing array is updated with the display data and
the associated highlighting attributes. When required, the backing
array is transferred to the richtextbox's Text property and then I
run through the attributes deriving a "map" of character positions,
attributes to be applied, and lengths derived from when the attribute
at position r/c differs from r'/c'. The Selection length, start,
colours, fond attributes (unlerline, etc) are then applied.
This minimises the number of Selectxxxx calls and the associated
Windows messaging overheads, flicker, etc.
As I said, this all works, but I am interested in opinions as to
whether this was the best approach. In particular, whether the
richtextbox was the best base class. If I didn't need the abilty to
copy text from the screen via mouse select+control-C, as you would do
in, say, Notepad, I could have just used a Panel with DrawString
outputing the characters + highlights.
For copyings it seems I am stuck with the edit-control classes and of
them only richtextbox has the colour and highlighting functionality.
Does anyone have another suggest on the whole approach?
Regards, Oz
emulations available such as ANSI, VT100, Linux/XTERM, etc. While my
control works, the actual console portion of it derives from the old
workhorse richeditbox.
Richedit supplies useful functionality such as a cursor, ability to
copy the text to the clipboard, colours/highlighting and so forth,
but is relatively clumsy when updating when new information is sent
from the Telnet host.
For example, when connected to a Linux host, the "aptitude" program
sends back an extremely "busy" panel of information. There are
many, many, cursor positioning and highlighting commands in the
datastream and the information to be displayed is not in a simple
top-to-bottom sequence.
Since the ANSI highlighting commands only specify the current high-
light to be applied from the current cursor position on, you cannot
really start doing highlighting via the various richtextbox
Selectionxxxx method calls since you do not yet know how long the
selection is until another highlighting sequence arrives.
I have solved that issue by maintaining a backing array of row x
columns characters and row x columns attributes (underline,
reverse video, forecolor, backcolor, "blink"). As characters arrive
from the host, the backing array is updated with the display data and
the associated highlighting attributes. When required, the backing
array is transferred to the richtextbox's Text property and then I
run through the attributes deriving a "map" of character positions,
attributes to be applied, and lengths derived from when the attribute
at position r/c differs from r'/c'. The Selection length, start,
colours, fond attributes (unlerline, etc) are then applied.
This minimises the number of Selectxxxx calls and the associated
Windows messaging overheads, flicker, etc.
As I said, this all works, but I am interested in opinions as to
whether this was the best approach. In particular, whether the
richtextbox was the best base class. If I didn't need the abilty to
copy text from the screen via mouse select+control-C, as you would do
in, say, Notepad, I could have just used a Panel with DrawString
outputing the characters + highlights.
For copyings it seems I am stuck with the edit-control classes and of
them only richtextbox has the colour and highlighting functionality.
Does anyone have another suggest on the whole approach?
Regards, Oz