示例#1
0
int	crt_scroll (int iline, int numlines, void (*func)(int))
{
	register
	int	dif, j;
	int	close	= end_margin - top_margin - 1;

	iline = min(numlines-1, max(0, iline));

	if (func == 0)	func = crt__null;

	if (iline < top_line)
	{
		if ((dif = (top_line - iline)) < close)
		{
			while (dif-- > 0)
			{
				crt_move (top_margin, 1);
				top_line--;
				end_line = min(top_line+lpp2, end_line);
				scr$down_scroll ();
				for (j = end_margin-1; j >= top_margin; j--)
					strcpy (crtvec[j], crtvec[j-1]);
				*crtvec[0]    = EOS;
				(*func)(top_line);
			}
		}
		else
		{
			top_line -= dif;
			end_line = min(top_line+lpp2, numlines-1);
			for (j = top_margin-1; j < end_margin; j++)
				(*func)(top_line+j);
		}
	}
	else if (iline > end_line)
	{
		if ((dif = (iline - end_line)) < close)
		{
			while (dif-- > 0)
			{
				top_line++, end_line++;
				crt_move (end_margin, 1);
				scr$up_scroll ();
				for (j = top_margin-1; j < end_margin-1; j++)
					strcpy (crtvec[j], crtvec[j+1]);
				*crtvec[end_margin-1] = EOS;
				(*func)(end_line);
			}
		}
		else
		{
			top_line += dif;
			end_line += dif;
			for (j = top_margin-1; j < end_margin; j++)
				(*func)(top_line+j);
		}
	}
	return (iline-top_line+1);
}
示例#2
0
void up_lcdputc(char ch)
{
  /* Check for new line */

  if (ch == '\n')
    {
      up_scroll();
    }

  /* Should we wrap to truncate at the end of line???  Let's truncate.  In either
   * case, let's ignore all other non-printable characters.
   */

  else if (g_nchars < LCD_NCHARS && isprint(ch))
    {
      up_lcdwrite(true, ch);
      g_line[g_nchars] = ch;
      g_nchars++;
    }
}