[fpc-pascal]Direct writes to console buffer

Michael.VanCanneyt at Wisa.be Michael.VanCanneyt at Wisa.be
Sun Aug 3 21:07:13 CEST 2003

On Sun, 3 Aug 2003, Michalis Kamburelis wrote:

> Rich Pasco wrote:
> > Michalis Kamburelis wrote:
> >
> >
> >>Unit Video is exactly what you are looking for - it lets you write/read
> >>characters and their attributes (text color + background + blink
> >>attribute) directly to/from a buffer in memory and then use simple
> >>UpdateScreen procedure to "flush" contents of this memory buffer to the
> >>console. This way you can write console programs using the same approach
> >>as under DOS (with these ptr(SegB800,0) / ptr(SegB000,0)) BUT it works
> >>under many platforms - in particular, it works under Win32.
> >>
> >>For more information, look at the FPC documentation for this unit.
> >
> >
> > This unit looks most like what I want to do, except that the document
> > says that it should not be used together with the CRT unit, and that
> > doing so will result in very strange behaviour, possibly program
> > crashes.  Since the rest of my code uses the CRT unit (probably even
> > more than I use the direct video stuff), I am stuck.
> >
> >      - Rich
> That's true, unit Video can't be used together with Crt unit because
> they both use the system console and using them both at the same time
> could make one of them not "synchronized" with the current console state
> (and maybe there are also others, possibly some platform-specific issues
> that I'm not aware of).
> One solution is to implement the Crt functionality using the Video unit
> - in most cases it should be pretty simple, e.g. you can implement
> GotoXY by calling Video.SetCursorPos, you can implement WhereX / WhereY
> to return the values of Video.CursorX / CursorY etc. Functions dealing
> with keyboard (ReadKey and KeyPressed) may be implemented using the
> Keyboard unit.

The idea is that in future the CRT unit will be 100% based on the video and
keyboard units. The only reason it is not yet so is that none of the core
team has had time to do it. It should be a pretty simple job, but it just
takes time.


More information about the fpc-pascal mailing list