X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=Ada95%2Fsamples%2Fncurses2-slk_test.adb;h=4971ed64bb2e2060ce86a00907e40c0a07c89bf5;hp=77ca2843fa68a98a13b821ecc0fbe3a50f32ca38;hb=d61c3c6a831d18ef0ed6f797ac97d60fffc2f158;hpb=46722468f47c2b77b3987729b4bcf2321cccfd01 diff --git a/Ada95/samples/ncurses2-slk_test.adb b/Ada95/samples/ncurses2-slk_test.adb index 77ca2843..4971ed64 100644 --- a/Ada95/samples/ncurses2-slk_test.adb +++ b/Ada95/samples/ncurses2-slk_test.adb @@ -7,7 +7,8 @@ -- B O D Y -- -- -- ------------------------------------------------------------------------------ --- Copyright (c) 2000 Free Software Foundation, Inc. -- +-- Copyright 2018,2020 Thomas E. Dickey -- +-- Copyright 2000-2009,2011 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- @@ -35,7 +36,8 @@ ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno 2000 -- Version Control --- $Revision: 1.1 $ +-- $Revision: 1.11 $ +-- $Date: 2020/02/02 23:34:34 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with ncurses2.util; use ncurses2.util; @@ -46,13 +48,13 @@ with Interfaces.C; with Terminal_Interface.Curses.Aux; procedure ncurses2.slk_test is - procedure myGet (Win : in Window := Standard_Window; + procedure myGet (Win : Window := Standard_Window; Str : out Ada.Strings.Unbounded.Unbounded_String; - Len : in Integer := -1); + Len : Integer := -1); - procedure myGet (Win : in Window := Standard_Window; + procedure myGet (Win : Window := Standard_Window; Str : out Ada.Strings.Unbounded.Unbounded_String; - Len : in Integer := -1) + Len : Integer := -1) is use Ada.Strings.Unbounded; use Interfaces.C; @@ -63,18 +65,18 @@ procedure ncurses2.slk_test is Len : int) return int; pragma Import (C, Wgetnstr, "wgetnstr"); - Txt : char_array (0 .. 10); + -- FIXME: how to construct "(Len > 0) ? Len : 80"? + Ask : constant Interfaces.C.size_t := Interfaces.C.size_t'Val (Len + 80); + Txt : char_array (0 .. Ask); + begin Txt (0) := Interfaces.C.char'First; - if Wgetnstr (Win, Txt, 8) = Curses_Err then + if Wgetnstr (Win, Txt, Txt'Length) = Curses_Err then raise Curses_Exception; end if; Str := To_Unbounded_String (To_Ada (Txt, True)); end myGet; - - use Int_IO; - use Ada.Strings.Unbounded; c : Key_Code; @@ -158,7 +160,7 @@ begin when 'x' | 'q' => exit; -- the C version needed a goto, ha ha - -- breaks exit the case not the loop because fall-throuh + -- breaks exit the case not the loop because fall-through -- happens in C! when others => Beep;