From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e9b3af563ee9322a X-Google-Attributes: gid103376,public From: jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk) Subject: Re: Interrupt Calls Date: 1997/11/12 Message-ID: <879299115.77snx@jvdsys.nextjk.stuyts.nl>#1/1 X-Deja-AN: 288727780 References: <3467a0ef.0@silver.truman.edu> Distribution: world Organization: *JerryWare HQ*, Leiden, Holland Newsgroups: comp.lang.ada Date: 1997-11-12T00:00:00+00:00 List-Id: 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