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.4 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,SUBJ_ALL_CAPS autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f9642664cfbe6417 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!n18g2000vbq.googlegroups.com!not-for-mail From: Emile8 Newsgroups: comp.lang.ada Subject: Re: ACCESS TO SYSTEM VARIABLES Date: Mon, 7 Mar 2011 12:14:47 -0800 (PST) Organization: http://groups.google.com Message-ID: <6ea98f8c-33eb-4f20-a696-eb59a519b80d@n18g2000vbq.googlegroups.com> References: <31c9ef20-db49-4d3e-bafb-0d2a5dca7866@e9g2000vbk.googlegroups.com> <4d74c5c3$0$6878$9b4e6d93@newsspool2.arcor-online.net> NNTP-Posting-Host: 90.28.247.181 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1299528888 30261 127.0.0.1 (7 Mar 2011 20:14:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 7 Mar 2011 20:14:48 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: n18g2000vbq.googlegroups.com; posting-host=90.28.247.181; 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.14) Gecko/20110221 Ubuntu/10.10 (maverick) Firefox/3.6.14,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:17956 Date: 2011-03-07T12:14:47-08:00 List-Id: On 7 mar, 12:47, Georg Bauhaus wrote: > On 07.03.11 10:34, Emile8 wrote: > > > > > with Ada.Environment_Variables; use Ada.Environment_Variables; > > with Ada.Text_Io; use Ada.Text_Io; > > > procedure Print_Env is > > begin > > Put_Line("Columns : " & Value("COLUMNS")); > > Put_Line("Lines : " & Value("LINES")); > > Put_Line("Path : " & Value("PATH")); > > end Print_Env; > > > I would like to understand the reasons of this behavior. Are there > > different kinds of system variables in Linux ? Those as HOME, PATH > > whose values depend only on the user session and those as LINES, > > COLUMNS defined for each used terminal. Is there a way in Ada to > > overcome this limitation ? > > Variables LINES and COLUMNS might not have been marked for export. > Try export -p. > > With the above program, I see constraint errors for LINES and > COLUMNS when these don't exist in the environment (which is > expected behavior). > > $ LINES=$LINES COLUMNS=$COLUMNS ./print_env > Columns : 255 > Lines : 42 > Path : /usr/local/bin:/usr/bin:/bin:/usr/games I tried your suggestion which in fact solves only part of the problem. With this approach the Ada program manages well to get the right initial values for the Lines and Columns of the terminal, but when I use it in a loop to monitor a manual resizing of the terminal, it does not see the changes in LINES and COLUMNS and reports always the same initial values. This behavior persists even if each LINES and COLUMNS variables acquisitions are preceded by an export-p command. I finally found a solution making in the Ada program the bash command "stty size > TermSize.txt" which reports in the dedicated file TermSize.txt the two numbers for LINES and COLUMNS. A reading of this file brings back in the Ada program the two numbers. This approach works well when the terminal is resized. The next best thing would be now to be able to manage the terminal as a protected object in Ada and to have always an exact knowledge of its dimensions when I want tu use it. But it is certainly only a dream... It is not a very elegant solution and I should look also at how the Ada version of ncurses manages to get the same informations.