void WindowScroll(TScreen *screen,int top) { register int i, lines; register int scrolltop, scrollheight, refreshtop; register int x = 0; if (top < -screen->savedlines) top = -screen->savedlines; else if (top > 0) top = 0; if((i = screen->topline - top) == 0) { ScrollBarDrawThumb(screen->scrollWidget); return; } /*ScrollSelection(screen, i);*/ if(screen->cursor_state) HideCursor(); lines = i > 0 ? i : -i; if(lines > screen->max_row + 1) lines = screen->max_row + 1; scrollheight = screen->max_row - lines + 1; if(i > 0) refreshtop = scrolltop = 0; else { scrolltop = lines; refreshtop = scrollheight; } /*x = screen->scrollbar + screen->border;*/ x=OriginX(screen); scrolling_copy_area(screen, scrolltop, scrollheight, -i); screen->topline = top; ScrollSelection(screen, i); XClearArea( screen->display, /*TextWindow(screen),*/ VWindow(screen), (int) x, (int) refreshtop * FontHeight(screen) + screen->border, (unsigned) Width(screen), (unsigned) lines * FontHeight(screen), FALSE); ScrnRefresh(screen, refreshtop, 0, lines, screen->max_col + 1, False); ScrollBarDrawThumb(screen->scrollWidget); }
void ResizeScrollBar(XtermWidget xw) { TScreen *screen = TScreenOf(xw); if (screen->scrollWidget != 0) { int height = screen->fullVwin.height + screen->border * 2; int width = screen->scrollWidget->core.width; int ypos = -ScrollBarBorder(xw); #ifdef SCROLLBAR_RIGHT int xpos = ((xw->misc.useRight) ? (screen->fullVwin.fullwidth - screen->scrollWidget->core.width - BorderWidth(screen->scrollWidget)) : -ScrollBarBorder(xw)); #else int xpos = -ScrollBarBorder(xw); #endif TRACE(("ResizeScrollBar at %d,%d %dx%d\n", ypos, xpos, height, width)); XtConfigureWidget( screen->scrollWidget, (Position) xpos, (Position) ypos, (Dimension) width, (Dimension) height, BorderWidth(screen->scrollWidget)); ScrollBarDrawThumb(screen->scrollWidget); } }
void WindowScroll(XtermWidget xw, int top, Bool always GCC_UNUSED) { TScreen *screen = TScreenOf(xw); #if OPT_SCROLL_LOCK if (screen->allowScrollLock && (screen->scroll_lock && !always)) { if (screen->scroll_dirty) { screen->scroll_dirty = False; ScrnRefresh(xw, 0, 0, MaxRows(screen), MaxCols(screen), False); } } else #endif { int i; if (top < -screen->savedlines) { top = -screen->savedlines; } else if (top > 0) { top = 0; } if ((i = screen->topline - top) != 0) { int lines; int scrolltop, scrollheight, refreshtop; if (screen->cursor_state) HideCursor(); lines = i > 0 ? i : -i; if (lines > MaxRows(screen)) lines = MaxRows(screen); scrollheight = screen->max_row - lines + 1; if (i > 0) refreshtop = scrolltop = 0; else { scrolltop = lines; refreshtop = scrollheight; } scrolling_copy_area(xw, scrolltop, scrollheight, -i); screen->topline = top; ScrollSelection(screen, i, True); xtermClear2(xw, OriginX(screen), OriginY(screen) + refreshtop * FontHeight(screen), (unsigned) Width(screen), (unsigned) (lines * FontHeight(screen))); ScrnRefresh(xw, refreshtop, 0, lines, MaxCols(screen), False); #if OPT_BLINK_CURS || OPT_BLINK_TEXT RestartBlinking(screen); #endif } } ScrollBarDrawThumb(screen->scrollWidget); }
void ScrollBarOn(XtermWidget xw, Bool init) { TScreen *screen = TScreenOf(xw); if (screen->fullVwin.sb_info.width || IsIcon(screen)) return; TRACE(("ScrollBarOn(init %s)\n", BtoS(init))); if (init) { /* then create it only */ if (screen->scrollWidget == 0) { /* make it a dummy size and resize later */ screen->scrollWidget = CreateScrollBar(xw, -ScrollBarBorder(xw), -ScrollBarBorder(xw), 5); if (screen->scrollWidget == NULL) { Bell(xw, XkbBI_MinorError, 0); } } } else if (!screen->scrollWidget || !XtIsRealized((Widget) xw)) { Bell(xw, XkbBI_MinorError, 0); Bell(xw, XkbBI_MinorError, 0); } else { ResizeScrollBar(xw); xtermAddInput(screen->scrollWidget); XtRealizeWidget(screen->scrollWidget); TRACE_TRANS("scrollbar", screen->scrollWidget); screen->fullVwin.sb_info.rv_cached = False; screen->fullVwin.sb_info.width = (screen->scrollWidget->core.width + BorderWidth(screen->scrollWidget)); TRACE(("setting scrollbar width %d = %d + %d\n", screen->fullVwin.sb_info.width, screen->scrollWidget->core.width, BorderWidth(screen->scrollWidget))); ScrollBarDrawThumb(screen->scrollWidget); DoResizeScreen(xw); #ifdef SCROLLBAR_RIGHT updateRightScrollbar(xw); #endif XtMapWidget(screen->scrollWidget); update_scrollbar(); if (screen->visbuf) { xtermClear(xw); Redraw(); } } }
void ResizeScrollBar(TScreen *screen) { /* [email protected] Jul-23-2002 */ XtConfigureWidget(screen->scrollWidget, -1,-1, screen->scrollWidget->core.width, screen->fullVwin.height + screen->border * 2, screen->scrollWidget->core.border_width); ScrollBarDrawThumb(screen->scrollWidget); }
void ResizeScrollBar(TScreen *screen) { XtConfigureWidget( screen->scrollWidget, #ifdef SCROLLBAR_RIGHT (term->misc.useRight) ? (term->core.width - screen->scrollWidget->core.width - screen->scrollWidget->core.border_width) : -1, #else -1, #endif -1, screen->scrollWidget->core.width, screen->fullVwin.height + screen->border * 2, screen->scrollWidget->core.border_width); ScrollBarDrawThumb(screen->scrollWidget); }
void ScrollBarOn (XtermWidget xw,int init,int doalloc) { register TScreen *screen = &xw->screen; register int border = 2 * screen->border; register int i,j,k; /* if(screen->scrollbar) return; */ if(screen->fullVwin.sb_info.width) return; if (init) { /* then create it only */ if (screen->scrollWidget) return; /* make it a dummy size and resize later */ if ((screen->scrollWidget = CreateScrollBar (xw, -1, - 1, 5)) == NULL) { Bell(XkbBI_MinorError,0); return; } return; } if (!screen->scrollWidget) { Bell (XkbBI_MinorError,0); Bell (XkbBI_MinorError,0); return; } if (doalloc && screen->allbuf) { /* FIXME: this is not integrated well with Allocate */ if((screen->allbuf = (ScrnBuf) realloc((char *) screen->visbuf, (unsigned) MAX_PTRS*(screen->max_row + 2 + screen->savelines) * sizeof(char *))) == NULL) SysError(ERROR_SBRALLOC); screen->visbuf = &screen->allbuf[MAX_PTRS * screen->savelines]; memmove( (char *)screen->visbuf, (char *)screen->allbuf, MAX_PTRS * (screen->max_row + 2) * sizeof (char *)); for (i = k = 0; i < screen->savelines; i++) { k += BUF_HEAD; for (j = BUF_HEAD; j < MAX_PTRS; j++) { if((screen->allbuf[k++] = (Char *)calloc((unsigned) screen->max_col + 1, sizeof(Char))) == NULL) SysError(ERROR_SBRALLOC2); } } } ResizeScrollBar (screen); xtermAddInput(screen->scrollWidget); XtRealizeWidget (screen->scrollWidget); /* Now set the left ptr cursor for the scrollbar [email protected] */ XDefineCursor(XtDisplay(screen->scrollWidget), XtWindow(screen->scrollWidget), screen->arrow); screen->fullVwin.sb_info.rv_cached = False; screen->fullVwin.sb_info.width = screen->scrollWidget->core.width + screen->scrollWidget->core.border_width; ScrollBarDrawThumb(screen->scrollWidget); DoResizeScreen (xw); XtMapWidget(screen->scrollWidget); update_scrollbar (); if (screen->visbuf) { XClearWindow (screen->display, XtWindow (term)); Redraw (); } /* XXX TODO if scrollbar is on right [email protected] */ }
/* * These routines are used for the jump scroll feature */ void FlushScroll(register TScreen *screen) { register int i; register int shift = -screen->topline; register int bot = screen->max_row - shift; register int refreshtop; register int refreshheight; register int scrolltop; register int scrollheight; if(screen->cursor_state) HideCursor(); if(screen->scroll_amt > 0) { refreshheight = screen->refresh_amt; scrollheight = screen->bot_marg - screen->top_marg - refreshheight + 1; if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) > (i = screen->max_row - screen->scroll_amt + 1)) refreshtop = i; if(screen->scrollWidget && !screen->alternate && screen->top_marg == 0) { scrolltop = 0; if((scrollheight += shift) > i) scrollheight = i; if((i = screen->bot_marg - bot) > 0 && (refreshheight -= i) < screen->scroll_amt) refreshheight = screen->scroll_amt; if((i = screen->savedlines) < screen->savelines) { if((i += screen->scroll_amt) > screen->savelines) i = screen->savelines; screen->savedlines = i; ScrollBarDrawThumb(screen->scrollWidget); } } else { scrolltop = screen->top_marg + shift; if((i = bot - (screen->bot_marg - screen->refresh_amt + screen->scroll_amt)) > 0) { if(bot < screen->bot_marg) refreshheight = screen->scroll_amt + i; } else { scrollheight += i; refreshheight = screen->scroll_amt; if((i = screen->top_marg + screen->scroll_amt - 1 - bot) > 0) { refreshtop += i; refreshheight -= i; } } } } else { refreshheight = -screen->refresh_amt; scrollheight = screen->bot_marg - screen->top_marg - refreshheight + 1; refreshtop = screen->top_marg + shift; scrolltop = refreshtop + refreshheight; if((i = screen->bot_marg - bot) > 0) scrollheight -= i; if((i = screen->top_marg + refreshheight - 1 - bot) > 0) refreshheight -= i; } scrolling_copy_area(screen, scrolltop+screen->scroll_amt, scrollheight, screen->scroll_amt); ScrollSelection(screen, -(screen->scroll_amt)); screen->scroll_amt = 0; screen->refresh_amt = 0; if(refreshheight > 0) { ClearCurBackground(screen, (int) refreshtop * FontHeight(screen) + screen->border, (int) OriginX(screen), (unsigned) refreshheight * FontHeight(screen), (unsigned) Width(screen)); ScrnRefresh(screen, refreshtop, 0, refreshheight, screen->max_col + 1, False); } }
/* * If cursor not in scrolling region, returns. Else, deletes n lines * at the cursor's position, lines added at bottom margin are blank. */ void DeleteLine(register TScreen *screen, register int n) { register int i; register int shift; register int bot; register int refreshtop; register int refreshheight; register int scrolltop; register int scrollheight; if (screen->cur_row < screen->top_marg || screen->cur_row > screen->bot_marg) return; if(screen->cursor_state) HideCursor(); screen->do_wrap = 0; if (n > (i = screen->bot_marg - screen->cur_row + 1)) n = i; if(screen->jumpscroll) { if(screen->scroll_amt >= 0 && screen->cur_row == screen->top_marg) { if(screen->refresh_amt + n > screen->max_row + 1) FlushScroll(screen); screen->scroll_amt += n; screen->refresh_amt += n; } else if(screen->scroll_amt) FlushScroll(screen); } if(!screen->scroll_amt) { shift = -screen->topline; bot = screen->max_row - shift; scrollheight = i - n; refreshheight = n; if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) > (i = screen->max_row - refreshheight + 1)) refreshtop = i; if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0) { scrolltop = 0; if((scrollheight += shift) > i) scrollheight = i; if((i = screen->savedlines) < screen->savelines) { if((i += n) > screen->savelines) i = screen->savelines; screen->savedlines = i; ScrollBarDrawThumb(screen->scrollWidget); } } else { scrolltop = screen->cur_row + shift; if((i = screen->bot_marg - bot) > 0) { scrollheight -= i; if((i = screen->cur_row + n - 1 - bot) >= 0) { refreshheight -= i; } } } vertical_copy_area(screen, scrolltop+n, scrollheight, n); if(refreshheight > 0) { ClearCurBackground(screen, (int) refreshtop * FontHeight(screen) + screen->border, (int) OriginX(screen), (unsigned) refreshheight * FontHeight(screen), (unsigned) Width(screen)); } } /* adjust screen->buf */ if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0) ScrnDeleteLine(screen, screen->allbuf, screen->bot_marg + screen->savelines, 0, n, screen->max_col + 1); else ScrnDeleteLine(screen, screen->visbuf, screen->bot_marg, screen->cur_row, n, screen->max_col + 1); }
/* * scrolls the screen by amount lines, erases bottom, doesn't alter * cursor position (i.e. cursor moves down amount relative to text). * All done within the scrolling region, of course. * requires: amount > 0 */ void Scroll(register TScreen *screen, register int amount) { register int i = screen->bot_marg - screen->top_marg + 1; register int shift; register int bot; register int refreshtop = 0; register int refreshheight; register int scrolltop; register int scrollheight; if(screen->cursor_state) HideCursor(); if (amount > i) amount = i; if(screen->jumpscroll) { if(screen->scroll_amt > 0) { if(screen->refresh_amt + amount > i) FlushScroll(screen); screen->scroll_amt += amount; screen->refresh_amt += amount; } else { if(screen->scroll_amt < 0) FlushScroll(screen); screen->scroll_amt = amount; screen->refresh_amt = amount; } refreshheight = 0; } else { ScrollSelection(screen, -(amount)); if (amount == i) { ClearScreen(screen); return; } shift = -screen->topline; bot = screen->max_row - shift; scrollheight = i - amount; refreshheight = amount; if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) > (i = screen->max_row - refreshheight + 1)) refreshtop = i; if(screen->scrollWidget && !screen->alternate && screen->top_marg == 0) { scrolltop = 0; if((scrollheight += shift) > i) scrollheight = i; if((i = screen->savedlines) < screen->savelines) { if((i += amount) > screen->savelines) i = screen->savelines; screen->savedlines = i; ScrollBarDrawThumb(screen->scrollWidget); } } else { scrolltop = screen->top_marg + shift; if((i = screen->bot_marg - bot) > 0) { scrollheight -= i; if((i = screen->top_marg + amount - 1 - bot) >= 0) { refreshtop += i; refreshheight -= i; } } } if (screen->multiscroll && amount == 1 && screen->topline == 0 && screen->top_marg == 0 && screen->bot_marg == screen->max_row) { if (screen->incopy < 0 && screen->scrolls == 0) CopyWait(screen); screen->scrolls++; } scrolling_copy_area(screen, scrolltop+amount, scrollheight, amount); if(refreshheight > 0) { ClearCurBackground(screen, (int) refreshtop * FontHeight(screen) + screen->border, (int) OriginX(screen), (unsigned) refreshheight * FontHeight(screen), (unsigned) Width(screen)); if(refreshheight > shift) refreshheight = shift; } } if(screen->scrollWidget && !screen->alternate && screen->top_marg == 0) ScrnDeleteLine(screen, screen->allbuf, screen->bot_marg + screen->savelines, 0, amount, screen->max_col + 1); else ScrnDeleteLine(screen, screen->visbuf, screen->bot_marg, screen->top_marg, amount, screen->max_col + 1); if(refreshheight > 0) ScrnRefresh(screen, refreshtop, 0, refreshheight, screen->max_col + 1, False); }
void ScrollBarOn (XtermWidget xw, int init, int doalloc) { #ifdef MOTIF Cursor arrowCursor; #endif /* MOTIF */ register TScreen *screen = &xw->screen; register int i, j, k; if(screen->fullVwin.scrollbar) return; if (init) { /* then create it only */ if (screen->scrollWidget) return; /* make it a dummy size and resize later */ if ((screen->scrollWidget = CreateScrollBar (xw, -1, -1, 5)) == NULL) { Bell(XkbBI_MinorError,0); return; } return; } if (!screen->scrollWidget) { Bell (XkbBI_MinorError,0); Bell (XkbBI_MinorError,0); return; } if (doalloc && screen->allbuf) { /* FIXME: this is not integrated well with Allocate */ if((screen->allbuf = (ScrnBuf) realloc((char *) screen->visbuf, (unsigned) MAX_PTRS*(screen->max_row + 2 + screen->savelines) * sizeof(char *))) == NULL) Error (ERROR_SBRALLOC); screen->visbuf = &screen->allbuf[MAX_PTRS * screen->savelines]; memmove( (char *)screen->visbuf, (char *)screen->allbuf, MAX_PTRS * (screen->max_row + 2) * sizeof (char *)); for (i = k = 0; i < screen->savelines; i++) { k += BUF_HEAD; for (j = BUF_HEAD; j < MAX_PTRS; j++) { if((screen->allbuf[k++] = (Char *)calloc((unsigned) screen->max_col + 1, sizeof(Char))) == NULL) Error (ERROR_SBRALLOC2); } } } ResizeScrollBar (screen); XtRealizeWidget (screen->scrollWidget); #ifdef MOTIF /* define pointer cursor for it */ arrowCursor = XCreateFontCursor(XtDisplay(screen->scrollWidget), XC_left_ptr); XDefineCursor(XtDisplay(screen->scrollWidget), XtWindow(screen->scrollWidget), arrowCursor); XFreeCursor(XtDisplay(screen->scrollWidget), arrowCursor); #endif /* MOTIF */ screen->fullVwin.scrollbar = screen->scrollWidget->core.width + screen->scrollWidget->core.border_width; ScrollBarDrawThumb(screen->scrollWidget); DoResizeScreen (xw); #ifdef SCROLLBAR_RIGHT /* * Adjust the scrollbar position if we're asked to turn on scrollbars * for the first time after the xterm is already running. That makes * the window grow after we've initially configured the scrollbar's * position. (There must be a better way). */ if (term->misc.useRight && screen->fullVwin.fullwidth < term->core.width) XtVaSetValues(screen->scrollWidget, XtNx, screen->fullVwin.fullwidth - screen->scrollWidget->core.border_width, NULL); #endif XtMapWidget(screen->scrollWidget); update_scrollbar (); if (screen->visbuf) { XClearWindow (screen->display, XtWindow (term)); Redraw (); } }