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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c4e4e40240a86624 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!s18g2000prg.googlegroups.com!not-for-mail From: Emile8 Newsgroups: comp.lang.ada Subject: Re: Anyone see a problem in 5.7 ncurses Ada? Date: Wed, 9 Mar 2011 12:28:53 -0800 (PST) Organization: http://groups.google.com Message-ID: <431bc7ac-07d3-4ccc-abb6-18091cb5a0db@s18g2000prg.googlegroups.com> References: NNTP-Posting-Host: 90.27.116.165 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1299702533 14236 127.0.0.1 (9 Mar 2011 20:28:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 9 Mar 2011 20:28:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s18g2000prg.googlegroups.com; posting-host=90.27.116.165; posting-account=u9P-fgoAAAB1qVhsrmxVpcdi-eIb_an8 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; fr; rv:1.9.2.15) Gecko/20110303 Ubuntu/10.10 (maverick) Firefox/3.6.15,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:18009 Date: 2011-03-09T12:28:53-08:00 List-Id: 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;