comp.lang.ada
 help / color / mirror / Atom feed
From: Emile8 <pocchiola.yves@gmail.com>
Subject: Re: Anyone see a problem in 5.7 ncurses Ada?
Date: Wed, 9 Mar 2011 12:28:53 -0800 (PST)
Date: 2011-03-09T12:28:53-08:00	[thread overview]
Message-ID: <431bc7ac-07d3-4ccc-abb6-18091cb5a0db@s18g2000prg.googlegroups.com> (raw)
In-Reply-To: slrninfj90.kmk.localhost@example.org

On 9 mar, 19:55, localh...@example.org wrote:
> I had built some programs against an earlier version of ncurses, I can't
> remember whether it was 5.5 or later and they were working fine. When I
> rebuilt them against 5.7 a few of them broke. I have tracked it down to
> incorrect values being returned by get_size. For a 24x80 xterm get_size is
> returning 25 columns and 81 lines. This makes the values actually 2 higher
> than they should be, because the numbers are supposed to be
> zero-relative. That is the lines should be 23 and the columns 79. Has anyone
> else noticed this? I don't know whether it's in the Ada binding or in
> ncurses itself. I would think if ncurses itself was broken people would have
> noted and fixed it but then again I don't think the Ada binding has been
> touched in years (and wow, it's good).

I confirm your observation on the Ada binding of the version 5.7 of
ncurses. The numbers of lines and columns are 1 higher than the actual
ones. I don't know if this is relevant but Get_Size gives the number
of lines and columns of a window in the terminal. It seems so that the
standard_window is a bit greater than its terminal.

with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with ncurses2.util;             use ncurses2.util;
with ada.text_io; use ada.text_io;
with Ada.integer_Text_IO; use Ada.integer_Text_IO;

procedure test1 is
   NL : Line_count;
   NC : Column_count;
begin
   init_screen;
   Get_size (number_of_columns => NC, number_of_lines => NL);
   put(integer(NL));
   put_line("");
   put(integer(NC));
   delay 10.0;
end test1;


Here after is the source code of Get_Size. It could be that the
problem comes from the value of Offset_XY.

procedure Get_Size
     (Win               : in Window := Standard_Window;
      Number_Of_Lines   : out Line_Count;
      Number_Of_Columns : out Column_Count)
   is
      function GetMaxY (W : Window) return C_Int;
      pragma Import (C, GetMaxY, "getmaxy");

      function GetMaxX (W : Window) return C_Int;
      pragma Import (C, GetMaxX, "getmaxx");

      Y : constant C_Int := GetMaxY (Win)
                          + C_Int (Offset_XY);
      X : constant C_Int := GetMaxX (Win)
                          + C_Int (Offset_XY);
   begin
      Number_Of_Lines   := Line_Count (Y);
      Number_Of_Columns := Column_Count (X);
   end Get_Size;



  parent reply	other threads:[~2011-03-09 20:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-09 18:55 Anyone see a problem in 5.7 ncurses Ada? localhost
2011-03-09 19:45 ` Anh Vo
2011-03-09 19:52   ` localhost
2011-03-09 20:00     ` Anh Vo
2011-03-09 20:02       ` localhost
2011-03-09 22:12     ` Emile8
2011-03-09 20:28 ` Emile8 [this message]
2011-03-09 20:53   ` Jeffrey Carter
2011-03-09 21:42     ` Emile8
2011-03-10 14:43       ` Niklas Holsti
2011-03-10 21:38         ` Jeffrey Carter
2011-03-10  6:14   ` localhost
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox