Wiki copymirror

This is a mirror of the wiki at pascal.chat. Editing, history and sign-in are there.

KVM API and Crt future

Recently, several people have shown interest in the working of the KVM API (Keyboard/Video/Mouse) units and fixing the problems of the Crt implementation for Unix and other platforms. I'm writing here some parts of the bigger picture, and how I see the future of these units.

Since most of the problems lie in the Unix side of the spectrum, mostly due to the multitude of terminals, libraries and variants, so this topic mostly focuses on unix. However, as long as KVM units are supposedly available for other platforms, implementation based on those units might become completely platform independent.

The original purpose of KVM

The original purpose of the KVM units was simply to be the OS dependent part of Free Vision (FV), the Turbo Vision (TV) clone that is used by the textmode IDE (from here on simply IDE). The interface is reasonably clean though, and there is potential for use without Free Vision or the IDE. Since DOS applications can read from the screen, video keeps track of a virtual screen that can be read.

The base principle of FV is being event driven, and this also had its effect on the KVM API. The system allows for non-blocking polling of events. Also the requirements of the IDE/FV can be seen in the feature set offered by KVM: it tries to cater for all features that were used by Turbo Vision programs, including harder to port properties like being able to use nearly all keys on the keyboard, keyboard shift state and reading the screen. These properties in particular make the KVM API hard to port on Unix, but also give the FPC textmode apps a fairly rich textmode user experience.

On Unix, the KVM units use the "terminfo" library (part of ncurses) for some basic terminal database access, but not ncurses itself. For mouse support, only GPM is supported, with some xterm tweaks.

The origins of Crt

The Crt unit is a standard Turbo Pascal unit to random access write to the screen using direct memory mapped access. A lot of Turbo Pascal programs use it. The non Unix systems (DOS, OS/2, Win32) have a reasonable implementation already, except that they are based on completely standalone codebases and partly duplicate functionality already provided in KVM, but the Unix version has always been a problem. In the FPC subversion repository there are currently two variants, and a third version is proposed.

The problems

The current setup has several problems:

What needs to be done

console detection you say, what do you mean by that?

The behaviour of the terminal is governed by a lot of factors, here are some:

The different ways of console mouse is a bit of a problem, since if the mouse data isn't somehow multiplexed on stdin, one can't do one blocking call to get both kbd+mouse events.

References

This part is reserved for reference information:

text
 Links:
 http://www.bluesock.org/~willg/dev/ansi.html
 http://www.dee.ufcg.edu.br/~rrbrandt/tools/ansi.html
 <s>http://www.linuxgazette.com/issue65/padala.html</s>
 http://vt100.net/docs/vt100-ug/chapter3.html#DECID
 http://invisible-island.net/xterm/xterm.faq.html#bug_ansi_xterm
 http://www.kitebird.com/csh-tcsh-book/ctlseqs.pdf
 http://vt100.net/docs/vt220-rm/chapter4.html#S4.4
 <s>http://www.fh-jena.de/~gmueller/Kurs_halle/esc_vt100.html</s>
 http://vt100.net/docs/vt100-ug/contents.html
 <s>http://krtkg1.rug.ac.be/~colle/C/vt102.codes</s>
 <s>http://www.icewalkers.com/Linux/ManPages/console_codes-4.html</s>
 http://www.kostis.net/charsets/cp850.htm
 http://www.kostis.net/charsets/cp437.htm
 <s>http://www.calsky.com/lexikon/en/txt/c/co/codepage_437.php</s>
 <s>http://www.unet.univie.ac.at/aix/cmds/aixcmds6/xterm.htm</s>

From the Free Pascal wiki, page "KVM API and Crt future", as it stood on 2014-06-30 after a change by BigChimp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 3, last changed by WikiArchive .