From: jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk)
Subject: Re: Interrupt Calls
Date: 1997/11/12
Date: 1997-11-12T00:00:00+00:00 [thread overview]
Message-ID: <879299115.77snx@jvdsys.nextjk.stuyts.nl> (raw)
In-Reply-To: 3467a0ef.0@silver.truman.edu
In article <3467a0ef.0@silver.truman.edu> v025@academic.truman.edu writes:
>I am trying to write a package similar to your conio package. So there would
>be a text screen manipulation package for the NT complier. I figured since NT
>supports text-base dos programs all I would need to do is call the dos
>interrupt, but all I really need is a move cursor cursor function for my text
>graphics routines.
Unfortunately, there is no such thing as a 'dos interrupt' in a Win95/NT
program. To do this you need to use the Win32 API.
I will release AdaConio (a console package simular to conio for DOS) for
Win95/NT after the next upgrade of AdaGraph.
In the meantime, if you just need cursor control, the following might be
of some help:
-- ****************************************
-- * cursor.ads - Win95/NT cursor control *
-- ****************************************
package Cursor is
procedure Console_Size (X, Y: out Integer);
function Where_X return Integer;
function Where_Y return Integer;
procedure Goto_XY (X, Y: Integer);
end Cursor;
-- ****************************************
-- * cursor.adb - Win95/NT cursor control *
-- ****************************************
pragma C_Pass_By_Copy (128);
package body Cursor is
-----------------
-- WIN32 stuff --
-----------------
type SHORT is mod 2 ** 16;
for SHORT'Size use 16;
subtype WORD is SHORT;
subtype BOOL is Integer;
subtype DWORD is Integer;
subtype HANDLE is Integer;
type COORD is
record
X : SHORT;
Y : SHORT;
end record;
pragma Convention (C, COORD);
type SMALL_RECT is
record
Left : SHORT;
Top : SHORT;
Right : SHORT;
Bottom : SHORT;
end record;
pragma Convention (C, SMALL_RECT);
type CONSOLE_SCREEN_BUFFER_INFO is
record
Size : COORD;
Cursor_Pos : COORD;
Attrib : WORD;
Window : SMALL_RECT;
Max_Size : COORD;
end record;
pragma Convention (C, CONSOLE_SCREEN_BUFFER_INFO);
type PCONSOLE_SCREEN_BUFFER_INFO is access all CONSOLE_SCREEN_BUFFER_INFO;
pragma Convention (C, PCONSOLE_SCREEN_BUFFER_INFO);
function GetStdHandle (Value : DWORD) return HANDLE;
pragma Import (StdCall, GetStdHandle, "GetStdHandle");
function SetConsoleCursorPosition (Buffer : HANDLE;
Pos : COORD)
return BOOL;
pragma Import (StdCall, SetConsoleCursorPosition,
"SetConsoleCursorPosition");
function GetConsoleScreenBufferInfo (Buffer : HANDLE;
Info : PCONSOLE_SCREEN_BUFFER_INFO)
return BOOL;
pragma Import (StdCall, GetConsoleScreenBufferInfo,
"GetConsoleScreenBufferInfo");
FALSE : constant BOOL := 0;
STD_OUTPUT_HANDLE : constant DWORD := -11;
INVALID_HANDLE_VALUE : constant HANDLE := -1;
Output_Buffer : HANDLE;
Buffer_Info_Rec : aliased CONSOLE_SCREEN_BUFFER_INFO;
Buffer_Info : PCONSOLE_SCREEN_BUFFER_INFO := Buffer_Info_Rec'Access;
Cursor_Pos_Error : Exception;
Buffer_Info_Error : Exception;
Invalid_Handle_Error : Exception;
----------------------
-- Supporting stuff --
----------------------
procedure Get_Buffer_Info is
begin
if GetConsoleScreenBufferInfo (Output_Buffer, Buffer_Info) = FALSE then
raise Buffer_Info_Error;
end if;
end Get_Buffer_Info;
---------------------
-- Implementations --
---------------------
procedure Console_Size (X, Y: out Integer) is
begin
Get_Buffer_Info;
X := Integer (Buffer_Info_Rec.Size.X);
Y := Integer (Buffer_Info_Rec.Size.Y);
end Console_Size;
function Where_X return Integer is
begin
Get_Buffer_Info;
return Integer (Buffer_Info_Rec.Cursor_Pos.X);
end Where_X;
function Where_Y return Integer is
begin
Get_Buffer_Info;
return Integer (Buffer_Info_Rec.Cursor_Pos.Y);
end Where_Y;
procedure Goto_XY (X, Y: in Integer) is
New_Pos : COORD := (SHORT (X), SHORT (Y));
begin
Get_Buffer_Info;
if New_Pos.X > Buffer_Info_Rec.Size.X then
New_Pos.X := Buffer_Info_Rec.Size.X;
end if;
if New_Pos.Y > Buffer_Info_Rec.Size.Y then
New_Pos.Y := Buffer_Info_Rec.Size.Y;
end if;
if SetConsoleCursorPosition (Output_Buffer, New_Pos) = FALSE then
raise Cursor_Pos_Error;
end if;
end Goto_XY;
--------------------
-- Initialization --
--------------------
begin
Output_Buffer := GetStdHandle (STD_OUTPUT_HANDLE);
if Output_Buffer = INVALID_HANDLE_VALUE then
raise Invalid_Handle_Error;
end if;
end Cursor;
--
-- Jerry van Dijk | Leiden, Holland
-- Consultant | Team Ada
-- Ordina Finance | jdijk@acm.org
prev parent reply other threads:[~1997-11-12 0:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-11-08 0:00 Interrupt Calls Chad R. Meiners
1997-11-10 0:00 ` Laura & Mike Palmer
1997-11-11 0:00 ` Jerry van Dijk
1997-11-12 0:00 ` Jerry van Dijk
[not found] ` <01bcf06a$ba1d1900$933e63c3@default>
1997-11-21 0:00 ` Chad R. Meiners
1997-11-21 0:00 ` Larry Coon
1997-11-22 0:00 ` Jerry van Dijk
1997-11-10 0:00 ` Jerry van Dijk
1997-11-11 0:00 ` Chad R. Meiners
1997-11-12 0:00 ` Jerry van Dijk [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox