int SLscroll_pageup (SLscroll_Window_Type *win) { SLscroll_Type *l, *top; unsigned int nrows, hidden_mask; unsigned int n; if (win == NULL) return -1; (void) SLscroll_find_top (win); nrows = win->nrows; if ((NULL != (top = win->top_window_line)) && (nrows > 2)) { n = 0; hidden_mask = win->hidden_mask; l = win->current_line; while ((l != NULL) && (l != top)) { l = l->prev; if ((hidden_mask == 0) || ((l != NULL) && (0 == (l->flags & hidden_mask)))) n++; } if (l != NULL) { unsigned int save_line_num; int ret = 0; win->current_line = l; win->line_num -= n; /* Compute a new top/bottom header */ save_line_num = win->line_num; if ((0 == SLscroll_prev_n (win, nrows - 1)) && (n == 0)) ret = -1; win->top_window_line = win->current_line; win->current_line = l; win->line_num = save_line_num; find_window_bottom (win); return ret; } } if (nrows < 2) nrows++; if (0 == SLscroll_prev_n (win, nrows - 1)) return -1; return 0; }
int SLscroll_pagedown (SLscroll_Window_Type *win) { SLscroll_Type *l, *bot; unsigned int nrows, hidden_mask; unsigned int n; if (win == NULL) return -1; (void) SLscroll_find_top (win); nrows = win->nrows; if ((NULL != (bot = win->bot_window_line)) && (nrows > 2)) { n = 0; hidden_mask = win->hidden_mask; l = win->current_line; while ((l != NULL) && (l != bot)) { l = l->next; if ((hidden_mask == 0) || ((l != NULL) && (0 == (l->flags & hidden_mask)))) n++; } if (l != NULL) { win->current_line = l; win->top_window_line = l; win->line_num += n; find_window_bottom (win); if (n || (bot != win->bot_window_line)) return 0; return -1; } } if (nrows < 2) nrows++; if (0 == SLscroll_next_n (win, nrows - 1)) return -1; return 0; }
static void update_display (void) { unsigned int row, nrows; File_Line_Type *line; /* All well behaved applications should block signals that may affect * the display while performing screen update. */ SLsig_block_signals (); Line_Window.nrows = nrows = SLtt_Screen_Rows - 1; /* Always make the current line equal to the top window line. */ if (Line_Window.top_window_line != NULL) Line_Window.current_line = Line_Window.top_window_line; SLscroll_find_top (&Line_Window); row = 0; line = (File_Line_Type *) Line_Window.top_window_line; SLsmg_normal_video (); while (row < Line_Window.nrows) { SLsmg_gotorc (row, 0); if (line != NULL) { SLsmg_write_string (line->data); line = line->next; } SLsmg_erase_eol (); row++; } SLsmg_gotorc (row, 0); SLsmg_reverse_video (); SLsmg_printf ("%s | UTF-8 = %d", (File_Name == NULL) ? "<stdin>" : File_Name, SLutf8_is_utf8_mode ()); SLsmg_erase_eol (); SLsmg_refresh (); SLsig_unblock_signals (); }