[fpc-pascal]The Video unit

Michael.VanCanneyt at Wisa.be Michael.VanCanneyt at Wisa.be
Sat Jan 13 17:40:21 CET 2001


On Sat, 13 Jan 2001, Sergey Ulanov wrote:

> 
> I want to draw box on the screen. Why does following code work well on
> linux console, but does not work in xterm ?

It works well, but the terminal characters you use are wrong. I picked
a new font, and changed the characters to IBM PC character set:

I spawned an x-term with a VGA font:
  xterm -fn vga -fb vga -ls
and ran the modified program in it. It worked perfectly.

I suggest you use normal characters to draw boxes, such as - = + | and so on.

Michael.

Here is the modified program:
-----------------------------------------------------------------------

{$mode objfpc}
uses
  video;

procedure DrawChar(x,y:integer;c:char);
begin
  VideoBuf^[x+y*ScreenWidth] := $0700 + byte(c);
end;

procedure DrawBox(x,y,w,h:integer);
var
  i,j:integer;
begin
    DrawChar(x,y,#201);
    DrawChar(x+w-1 ,y,#187);
    DrawChar(x,y+h-1,#200);
    DrawChar(x+w-1,y+h-1,#188);
    for i:=1 to w-2 do begin
      DrawChar(x+i,y,#205);
      DrawChar(x+i,y+h-1,#205);
    end;
    for i:=1 to h-2 do begin  
      DrawChar(x,y+i,#186);
      DrawChar(x+w-1,y+i,#186);
    end;
end;

begin
  InitVideo;
  DrawBox(5,5,20,10);    
  UpdateScreen(true);
  readln;
  DoneVideo;
end.





More information about the fpc-pascal mailing list