Beispiel #1
0
/*
 * Move the cursor up/down the specified number of lines, scrolling
 * to a new screen if necessary.
 */
void
upLINE(RING * gbl, unsigned n)
{
    if (gbl->curfile < n)
	gbl->curfile = 0;
    else
	gbl->curfile -= n;

    if (gbl->curfile < vue->base_file) {
	unsigned savebase = vue->base_file;
	while (gbl->curfile < vue->base_file
	       && vue->base_file > 0) {
	    vue->base_file -= 1;
	    setup_view(gbl);
	}
#if defined(HAVE_WSCRL) && defined(HAVE_WSETSCRREG)
	if (vue->base_file < savebase
	    && setscrreg((int) vue->base_row + 1,
			 (int) vue->last_row - 1) != ERR) {
	    scrl((int) (vue->base_file - savebase));
	    setscrreg(0, LINES - 1);
	}
#endif
	showFILES(gbl, FALSE);
    } else {
	showC(gbl);
    }
}
Beispiel #2
0
void
downLINE(RING * gbl, unsigned n)
{
    gbl->curfile += n;

    if (gbl->curfile >= gbl->numfiles)
	gbl->curfile = gbl->numfiles - 1;

    if (gbl->curfile > vue->last_file) {
	unsigned savebase = vue->base_file;
	while (gbl->curfile > vue->last_file
	       && (vue->last_file + 1) < gbl->numfiles) {
	    vue->base_file += 1;
	    setup_view(gbl);
	}
#if defined(HAVE_WSCRL) && defined(HAVE_WSETSCRREG)
	if (vue->base_file > savebase
	    && setscrreg((int) vue->base_row + 1,
			 (int) vue->last_row - 1) != ERR) {
	    scrl((int) (vue->base_file - savebase));
	    setscrreg(0, LINES - 1);
	}
#endif
	showFILES(gbl, FALSE);
    } else
	showC(gbl);
}
Beispiel #3
0
/*
 * Reposition by a given number of lines
 */
static int
JumpBackwards(int *infile, int jump)
{
    int savejump;
    int blank;
    int n;
    int page = NumP(1);

    savejump = jump = page - jump;
    n = TopOfPage(*infile, &blank);

    /* jump the requested number of lines */
    if (jump > 0) {
	if (n == 0) {
	    while ((blank = LineAt[n].blank) != 0) {
		n++;
	    }
	}
	while (jump > 0) {
	    if (++n >= max_lines) {
		return (-1);
	    }
	    if (blank && LineAt[n].blank)
		continue;
	    blank = LineAt[n].blank;
	    jump--;
	}
    } else {
	while (jump < 0) {
	    if (--n < 0) {
		*infile = 0;	/* take what we can get */
		(void) JumpToLine(*infile);
		return (-1);
	    }
	    if (blank && LineAt[n].blank)
		continue;
	    blank = LineAt[n].blank;
	    jump++;
	}
    }
#if defined(HAVE_WSCRL) && defined(HAVE_WSETSCRREG)
    if (jump != savejump
	&& (n + NumP(1) < max_lines)
	&& (jump - savejump) < NumP(1)
	&& (savejump - jump) < NumP(1)) {
	int y, x;
	getyx(stdscr, y, x);
	move(LINES - 2, 0);
	setscrreg(mark_W + 1, LINES - 2);
	scrl(savejump - jump);
	setscrreg(0, LINES - 1);
	move(y, x);
    }
#endif
    *infile = n;
    return JumpToLine(*infile);
}
Beispiel #4
0
static void show_all(void)
{
	int i;
	char temp[BUFSIZ];
	char *s;

#if CAN_RESIZE
	sprintf(temp, "(%3dx%3d) col %d ", LINES, COLS, shift);
	i = strlen(temp);
	sprintf(temp+i, "view %.*s", (int)(sizeof(temp)-7-i), fname);
#else
	sprintf(temp, "view %.*s", (int)sizeof(temp)-7, fname);
#endif
	move(0,0);
	printw("%.*s", COLS, temp);
	clrtoeol();

	scrollok(stdscr, FALSE); /* prevent screen from moving */
	for (i = 1; i < LINES; i++) {
	    move(i, 0);
	    if ((s = lptr[i-1]) != 0 && (int)strlen(s) > shift)
		printw("%3d:%.*s", lptr+i-lines, COLS-4, s + shift);
	    else
		printw("%3d:", lptr+i-lines);
	    clrtoeol();
	}
	setscrreg(1, LINES-1);
	scrollok(stdscr, TRUE);
	refresh();
}
Beispiel #5
0
static void
set_screensize(void)
{
    screen_full = LINES - 1;
    screen_half = (screen_full + 1) / 2;
    screen_active = TRUE;

#if HAVE_WSETSCRREG
    setscrreg(2, screen_full);
#endif
}
Beispiel #6
0
IoObject *IoCurses_setScrollingRegion(IoCurses *self, IoObject *locals, IoMessage *m) {
    /*doc Curses setScrollingRegion(top, bottom) 
    Sets the scrolling region; top and bottom are the line numbers of the top
    and button margin. Returns self.
    */
    int top = IoNumber_asInt(IoMessage_locals_numberArgAt_(m, locals, 0));
    int bot = IoNumber_asInt(IoMessage_locals_numberArgAt_(m, locals, 1));
    if(setscrreg(top, bot) == ERR)
    {
        IoCurses_showError(self, m, "Curses.scroll", "Failed to set the scrolling region.");
    }
    return self;
}
Beispiel #7
0
/*
 * os_scroll_area
 *
 * Scroll a rectangular area of the screen up (units > 0) or down
 * (units < 0) and fill the empty space with the current background
 * colour. Top left coordinates are (1,1). The cursor stays put.
 *
 */
void os_scroll_area (int top, int left, int bottom, int right, int units)
{
  top--; left--; bottom--; right--;

  if ((left == 0) && (right == h_screen_cols - 1)) {
    static int old_scroll_top = 0;
    static int old_scroll_bottom = 0;

    if (!((old_scroll_top == top) && (old_scroll_bottom == bottom))) {
        old_scroll_top = top; old_scroll_bottom = bottom;
        setscrreg(top, bottom);
    }
    scrollok(stdscr, TRUE);
    scrl(units);
    scrollok(stdscr, FALSE);
  } else {
    int row, col, x, y;
    chtype ch;

    getyx(stdscr, y, x);
    /* Must turn off attributes during copying.  */
    attrset(0);
    if (units > 0) {
      for (row = top; row <= bottom - units; row++)
	for (col = left; col <= right; col++) {
	  ch = mvinch(row + units, col);
	  mvaddch(row, col, ch);
	}
    } else if (units < 0) {
      for (row = bottom; row >= top - units; row--)
	for (col = left; col <= right; col++) {
	  ch = mvinch(row + units, col);
	  mvaddch(row, col, ch);
	}
    }
    /* Restore attributes.  */
    os_set_text_style(u_setup.current_text_style);
    move(y, x);
  }
  if (units > 0)
    os_erase_area(bottom - units + 2, left + 1, bottom + 1, right + 1, 0);
  else if (units < 0)
    os_erase_area(top + 1, left + 1, top - units, right + 1, 0);
}/* os_scroll_area */
Beispiel #8
0
/* The initialization function for this module. Calculates the various
 * screen coordinates and initializes curses, and parses the cmdline
 * option -o.
 */
int outputinit(char *opts[])
{
    struct sigaction act;
    int y, x;

    ego = opts['o'] != NULL;
    noacs = opts['l'] != NULL;

    xwords = 0;
    ywords = height * 2 + 1;
    xstatus = width * 4 + 4;
    ystatus = 0;

    if (!(mode & MM_CURSES))
	return TRUE;

    if (!initscr())
	exit(EXIT_FAILURE);
    nonl();
    noecho();
    cbreak();
    getmaxyx(stdscr, y, x);
    if (xstatus + 1 >= x || ywords + 1 >= y) {
	endwin();
	fputs("Screen too small\n", stderr);
	exit(EXIT_FAILURE);
    }

    setscrreg(ywords, y - 1);
    highlightattr = termattrs() & A_BOLD ? A_BOLD : A_STANDOUT;

    atexit(destroy);

#ifdef SIGWINCH
    act.sa_handler = onresize;
    sigemptyset(&act.sa_mask);
    act.sa_flags = 0;
    sigaction(SIGWINCH, &act, NULL);
#endif /* SIGWINCH */

    return TRUE;
}
Beispiel #9
0
void gui_window_newline(GUI_WINDOW_REC *gui, int visible)
{
    /* FIXME: I'm pretty sure this could be done cleaner :) */
    int lines;

    g_return_if_fail(gui != NULL);

    gui->xpos = 0;

    lines = gui_window_get_linecount(gui, gui->bottom_startline->data);
    if (gui->bottom_subline >= lines) {
        /* after screen gets full after /CLEAR we end up here.. */
        gui->bottom_startline = gui->bottom_startline->next;
        gui->bottom_subline = 0;
    }

    lines = gui_window_get_linecount(gui, gui->startline->data);
    if (gui->subline >= lines) {
        /* after screen gets full after /CLEAR we end up here.. */
        gui->startline = gui->startline->next;
        gui->subline = 0;
    }

    if (gui->empty_linecount > 0) {
        /* window buffer height isn't even the size of the screen yet */
        gui->empty_linecount--;
        if (!gui->bottom) {
            gui->ypos++;
            return;
        }
    }

    if (gui->ypos >= -1 && gui->ypos < gui->parent->lines-1) {
        gui->ypos++;
        return;
    }

    if (!gui->bottom || (gui->startline == gui->bottom_startline &&
                         gui->subline >= gui->bottom_subline)) {
        lines = gui_window_update_bottom(gui, 1);

        if (!gui->bottom) {
            gui->ypos++;
            return;
        }
    } else {
        lines = gui_window_get_linecount(gui, gui->startline->data);
    }

    if (lines > 1+gui->subline)
        gui->subline++;
    else {
        gui->startline = gui->startline->next;
        gui->subline = 0;
    }

    if (visible) {
        WINDOW *cwin;

#ifdef USE_CURSES_WINDOWS
        cwin = gui->parent->curses_win;
#else
        cwin = stdscr;
        setscrreg(gui->parent->first_line, gui->parent->last_line);
#endif
        scrollok(cwin, TRUE);
        wscrl(cwin, 1);
        scrollok(cwin, FALSE);
    }
}
Beispiel #10
0
int t_setscrreg(int top, int bottom)
{
	return setscrreg(top, bottom);
}