[Lazarus] Xterm, konsole etc.
Mark Morgan Lloyd
markMLl.lazarus at telemetry.co.uk
Mon Jun 17 23:23:35 CEST 2013
Martin wrote:
> On 17/06/2013 17:13, Mattias Gaertner wrote:
>> On Sat, 15 Jun 2013 13:46:57 +0000
>> Mark Morgan Lloyd <markMLl.lazarus at telemetry.co.uk> wrote:
>>
>>> What's the easiest way to implement something like xterm or konsole,
>>> that has minimal escape decoding for e.g. cursor control but under
>>> normal circumstances buffers output lines in scrollable form?
>>>
>>> What I'm trying to do is implement some special 8-bit codepage mapping
>>> for programs run inside a window, but it would be desirable to be able
>>> to run a (unix) shell and a standard editor such as vi.
>> I'm interested in a terminal LCL control as well.
>>
> Count me in (for wanting to have), would be nice for the debugger
> (linux) (and Mac, if someone knows how to simulate a tty)
I don't claim to have anything like the expertise to do all of the work
(I've never tackled a component in either Delphi or Lazarus), but it
might be worthwhile kicking ideas around.
Almost everything I do ends up having at least one terminal pane, at the
very least for status/debugging output. This needs to be scrollable,
with a limit on the number of history lines, and (optionally) for the
insertion point to be forced visible when there's fresh output. Copy to
clipboard, save as text etc. are desirable, paste etc. not.
I've hooked into TSynEdit.KeyDown to get full control of the keyboard,
and injected Unicode characters using IntfUTF8KeyPress(). This allowed
me to put APL characters etc. into text I was editing, there was nothing
from a tty line etc. in this case and I didn't need colour.
For an actual terminal emulator (emulating an old IBM electromechanical
terminal), I've experimented with TMemo and TListBox, with the option of
using TRichMemo if available; I also tried basing something on TCmdBox
but it didn't really suit. In all cases I hooked the KeyDown event
translating it to 8-bit ASCII rather than Unicode, I found a few detail
differences between Qt and GTK keycodes. Output was done by rather
painfully tacking onto the stringlist etc. that underlay the control,
with colour (black/red) handling in some cases- this used custom escape
sequences, since the thing I was emulating long preceded ANSI/VT100.
Something else I've done displays terminal output from a protocol
analyzer, this includes serial control line transitions, graphical
control characters and possibly things like Prestel/Minitel which I
don't think are in Unicode.
The current thing I'm looking at is a number of programs (APL systems)
which require custom 8-bit keyboard and screen handling which would
"correctly" by done by tweaking the X configuration. Unfortunately this
is system-wide so I'm wondering whether it could be done by a Lazarus
(and/or text-mode FPC) wrapper around the program.
A twist in this case is that one of these systems wants to shell out to
an editor. One approach- the one I'm using at the moment- would be to
simply run vi (or whatever) in a shell, but it would be nicer to be able
to pass full control back to the terminal and have it save just the
edited lines.
As Marc says, some tweak to Synedit might be viable provided that it was
able to handle colours etc. properly. The basic control would probably
have two modes (cell-addressable and extensible) with provision for
attaching keyboard and escape-sequence handlers.
--
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