slang-users mailing list

[2001 Date Index] [2001 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: need help with s-lang


manuel b <ghaider@xxxxxxxxxxx> wrote:
>Hello
>
>I print some characters at the end of the screen so :
>  (SLsmg_gotorc(SLtt_Screen_Cols-1, 0)).

I assume that this is a typo and that you actually mean to use
SLtt_Screen_Rows and not SLtt_Screen_Cols.

[...]
>what i want to to:
>
>printing x characters (rand()) each line (scrolling up).

Try using:

   SLsmg_Newline_Behavior = SLSMG_NEWLINE_SCROLLS.
   
Here is a simple example:

#include <stdio.h>
#include <slang.h>

int main (int argc, char **argv)
{
   FILE *fp;
   char buf[1024];

   if (argc != 2)
     {
	fprintf (stderr, "Usage: %s FILENAME\n", argv[0]);
	return 1;
     }
   
   fp = fopen (argv[1], "r");
   if (fp == NULL)
     {
	fprintf (stderr, "Failed to open %s\n", argv[1]);
	return 0;
     }
   
   (void) SLtt_get_terminfo ();
   (void) SLsmg_init_smg ();
   SLsmg_Newline_Behavior = SLSMG_NEWLINE_SCROLLS;

   SLsmg_gotorc (0,0);
   while (NULL != fgets (buf, sizeof(buf), fp))
     {
	SLsmg_write_string (buf);
	SLsmg_refresh ();
     }
   fclose (fp);
   SLsmg_reset_smg ();
   return 0;
}


[2001 date index] [2001 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]