Пример #1
0
/* The given window has its properties set so that it is selected */
static void 
select_win(struct Window *w ){
	w->font = BIGFONT;
	w->height = WL_HIGH_HEIGHT;
	w->border = 1;
	win_scroll(w);		// enable horizontal scrolling
};
Пример #2
0
INT32 win_internal_putchar(UINT32 idx, UINT8 ch)
{
	struct sWindow *pwin = &p_windows[idx];
	INT32 rel = 0;
	UINT32 x0, y0;
	UINT8 color;

	if( NULL == pwin->text )
		return 0;

	color = pwin->co_text;

    switch( ch )
	{
	case '\b':  /* Backspace? */
		if( pwin->cx )
		{
			pwin->cx--;
			rel--;
		}
		break;

	case '\r':  /* Carriage return */
		rel = - pwin->cx;
		pwin->cx = 0;
		break;

	case '\n':  /* Newline or linefeed? */
#if NEWLINE_ERASE_EOL
		win_erase_eol( idx, ' ' );
#endif
		rel = - pwin->cx;
		pwin->cx = 0;
		pwin->cy++;
		if( pwin->cy >= pwin->h )
		{
			pwin->cy--;
			win_scroll(idx);
		}
		break;

	case '\t':  /* Tab? */
		do
		{
			rel += win_internal_putchar( idx, ' ');
		} while( pwin->cx % TAB_STOP );
		break;

    default:
        x0 = pwin->x + pwin->cx;
		y0 = pwin->y + pwin->cy;

		if( pwin->flags & BORDER_LEFT )
			++x0;
		if( pwin->flags & BORDER_TOP )
			++y0;

		/* Sanity check */
        if( x0 < screen_w && y0 < screen_h )
		{
			pwin->text[pwin->cy * screen_w + pwin->cx] = ch;
            pwin->attr[pwin->cy * screen_w + pwin->cx] = color;
			if( pwin->cx < pwin->w )
			{
				if( p_prio_map[y0 * screen_w + x0] >= pwin->prio && !(pwin->flags & HIDDEN) )
					win_out(ch, color, x0, y0, idx);
			}
		}

		rel++;
		pwin->cx++;
		if( pwin->cx >= pwin->w )
		{
			/* If we do not wrap at the right side, just exit */
            if( pwin->flags & NO_WRAP )
				return rel;
            pwin->cx = 0;
			pwin->cy++;
			if( pwin->cy >= pwin->h )
			{
				win_scroll(idx);
                pwin->cy--;
			}
		}
    }
	return rel;
}
Пример #3
0
END_TEST

START_TEST (test_win_handler_scroll)
{
  int ret;
  Win *w;
  win_properties props = { 0, 0 };

  w = win_create (0, 0, 40, 80, &props);
  fail_unless (w != NULL);
  ret = win_load_file (w, CONFDIR "text_test_long.txt");

  fail_unless (ret == 0);
  ret = win_scroll (w, -1);
  fail_unless (ret < 0);	/* at the first line already. */

  ret = win_scroll (w, 130);
  fail_unless (ret < 0);	/* scroll to far down. */

  ret = win_scroll (w, -15);
  fail_unless (ret == 0);

  ret = win_scroll (w, -1);
  fail_unless (ret == 0);

  ret = win_scroll (w, 5);
  fail_unless (ret == 0);

  ret = win_scroll (w, 1);
  fail_unless (ret == 0);

  win_to_top (w);

  ret = win_go_to_line (w, -2);
  fail_unless (ret < 0);
  ret = win_go_to_line (w, 180);
  fail_unless (ret < 0);

  ret = win_go_to_line (w, 15);
  fail_unless (ret == 0);

  ret = win_move (w, -1);
  fail_unless (ret == 0);
  ret = win_move (w, -4);
  fail_unless (ret == 0);
  ret = win_move (w, 1);
  fail_unless (ret == 0);
  ret = win_move (w, 4);
  fail_unless (ret == 0);

  win_clear (w);

  win_free (w);

  props.properties = WIN_PROP_CURSOR;
  w = win_create (0, 0, 40, 80, &props);
  fail_unless (w != NULL);
  ret = win_load_file (w, CONFDIR "text_test_long.txt");
  ret = win_go_to_line (w, 15);
  fail_unless (ret == 0);
  ret = win_move (w, -1);
  fail_unless (ret == 0);
  ret = win_move (w, -4);
  fail_unless (ret == 0);
  ret = win_move (w, 1);
  fail_unless (ret == 0);
  ret = win_move (w, 4);
  fail_unless (ret == 0);

  win_clear (w);

  win_free (w);
}