[GRASS5] OUT OF CONTEXT: QUERY ON NCURSES

Vidya Kotamraju vidyakr at darya.nio.org
Fri Jun 20 07:22:36 EDT 2003


Hi all,
Sorry for the out-of-context question but cudnt locate a more 
appropriate mailin list.
I am developing a C code to be integrated with GRASS that makes use of 
ncurses.
The program needs to open a text file and scroll down if the
number of lines in the file exceeds the screen size.
Though I am able to scroll up and down succesfully ( by making use of 
scrl() function) I lose the text below and above the cursor respectively.
How do i maintain continuity while displaying the file ?

Following is the code that i use.

if(ch == KEY_F(9)) //To display file contents and scroll
             {
	      werase(stdscr);
               max_i=0;
               file_read=fopen("session.txt","r");
               printw("\n");
               do{
		c = fgets(oneline,300,file_read);
                 max_i++;
		if (c != NULL)
		  printw("%s",oneline);
	      }while (c != NULL);
	      max_ch= getch();
	      while(max_ch == KEY_UP || max_ch == KEY_DOWN)
		{
		  switch(max_ch)
		    {
		    case KEY_DOWN:
		      scrl(1); //scroll down by one line
		      refresh();
		      break;

		    case KEY_UP:
		      scrl(-1); //scroll up by one line
		      refresh();
		      break;

		    default:
		      break;
		    }
		  max_ch =getch();
		  }
               fclose(file_read);

             }


I have also initialised the necessary curses functions for scrolling. 
they are :

   idlok (stdscr, TRUE);
   scrollok(stdscr,TRUE);
   scroll(stdscr);



Any pointers ?????



Vidya Kotamraju.

--
-----------------------------------------------------------------------
Maybe this world is another planet's Hell.
                                      -Aldous Huxley
-----------------------------------------------------------------------
Kotamraju Vidya
Marine HydroDynamics Lab,
Physical Oceanography Division,
National Institute of Oceanography,
Dona Paula, Goa 403 004, India.
Ph.: +91-832-2456700 *4400 (O)
       +91-832-2541756 (R)
e-mail: vidyakr at darya.nio.org




More information about the grass-dev mailing list