comp.lang.ada
 help / color / mirror / Atom feed
From: wjr17@attbi.com (Bill)
Subject: Line and Column size
Date: 9 Feb 2004 10:27:44 -0800
Date: 2004-02-09T10:27:44-08:00	[thread overview]
Message-ID: <ef0e5520.0402091027.32c24f0b@posting.google.com> (raw)

I'm working on a project for school and I have created a very nice
looking TUI window library in ADA95. I thought as an added extra it
would be nice to be able to scale the TUI window to the size of the
current users terminal window. I have looked into using the $LINES and
$COLUMNS term variables, be they wont work since they need to be
exported. Therefore this would not be a safe method of getting the
lines/columns, since not all systems have the variables exported.
Another thing I have tried is to use the curses library. I wrote a
small C library using curses. It goes as follows:



code:--------------------------------------------------------------------------------
#include <curses.h>

struct scr
{
  int LINES;
  int COLUMNS;
};

struct scr GetScreen(void)
{
  struct scr Scr = {0,0};
  initscr();
  Scr.LINES = LINES;
  Scr.COLUMNS = COLS;
  endwin();
  return Scr;
}
--------------------------------------------------------------------------------


I can import the function fine into ADA95 by doing on of these:

code:--------------------------------------------------------------------------------
  TYPE scrsize IS RECORD
    LINES       : INTEGER := 0;
    COLUMNS : INTEGER := 0;
  END RECORD;

  FUNCTION GetSize Return scrsize IS
    Function GetScreen Return scrsize;
    pragma Import(C,GetScreen,"GetScreen");
  BEGIN -- GetSize
    RETURN GetScreen;
  END GetSize;
--------------------------------------------------------------------------------


Then to compile the code you do a
gcc -c myc_Lib.c
gnatmake main_prog.adb -largs -lcurses myc_lib.o

Now the C code returns the line and column numbers perfectly. However
it seems that when curses runs, it changes the screen, or does
something, because my TUI code no longer displays properly. The
terminal window seems to act wierd after my program exits.
So I was wondering if anyone knew what might be wrong or I'm not doing
that I should be in the C code, or if there is a better way to go
about doing what I'm doing. Maybe there is a library package for ADA95
that already does what I want it to, but I have just not found it yet.
Thanks for the help.

- Bill



             reply	other threads:[~2004-02-09 18:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-09 18:27 Bill [this message]
2004-02-09 19:08 ` Line and Column size Ludovic Brenta
replies disabled

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