📄 rcons_subr.c
字号:
case 'D': /* Cursor Backward (CUB) */ *fb->fb_col -= fb->fb_p0; if (*fb->fb_col < 0) *fb->fb_col = 0; break; case 'E': /* Cursor Next Line (CNL) */ *fb->fb_col = 0; *fb->fb_row += fb->fb_p0; if (*fb->fb_row >= fb->fb_maxrow) *fb->fb_row = fb->fb_maxrow - 1; break; case 'f': /* Horizontal And Vertical Position (HVP) */ case 'H': /* Cursor Position (CUP) */ *fb->fb_col = fb->fb_p1 - 1; if (*fb->fb_col < 0) *fb->fb_col = 0; else if (*fb->fb_col >= fb->fb_maxcol) *fb->fb_col = fb->fb_maxcol - 1; *fb->fb_row = fb->fb_p0 - 1; if (*fb->fb_row < 0) *fb->fb_row = 0; else if (*fb->fb_row >= fb->fb_maxrow) *fb->fb_row = fb->fb_maxrow - 1; break; case 'J': /* Erase in Display (ED) */ rcons_clear2eop(fb); break; case 'K': /* Erase in Line (EL) */ rcons_clear2eol(fb); break; case 'L': /* Insert Line (IL) */ rcons_insertline(fb, fb->fb_p0); break; case 'M': /* Delete Line (DL) */ rcons_delline(fb, fb->fb_p0); break; case 'P': /* Delete Character (DCH) */ rcons_delchar(fb, fb->fb_p0); break; case 'm': /* Select Graphic Rendition (SGR); */ /* (defaults to zero) */ if (fb->fb_bits & FB_P0_DEFAULT) fb->fb_p0 = 0; if (fb->fb_p0) fb->fb_bits |= FB_STANDOUT; else fb->fb_bits &= ~FB_STANDOUT; break; case 'p': /* Black On White (SUNBOW) */ rcons_invert(fb, 0); break; case 'q': /* White On Black (SUNWOB) */ rcons_invert(fb, 1); break; case 'r': /* Set scrolling (SUNSCRL) */ /* (defaults to zero) */ if (fb->fb_bits & FB_P0_DEFAULT) fb->fb_p0 = 0; /* XXX not implemented yet */ fb->fb_scroll = fb->fb_p0; break; case 's': /* Reset terminal emulator (SUNRESET) */ fb->fb_bits &= ~FB_STANDOUT; fb->fb_scroll = 0; if (fb->fb_bits & FB_INVERT) rcons_invert(fb, 0); break; }}/* Paint (or unpaint) the cursor */voidrcons_cursor(fb) register struct fbdevice *fb;{ register int x, y; x = *fb->fb_col * fb->fb_font->width + fb->fb_xorigin; y = *fb->fb_row * fb->fb_font->height + fb->fb_yorigin; raster_op(fb->fb_sp, x, y,#ifdef notdef /* XXX This is the right way but too slow */ fb->fb_font->chars[(int)' '].r->width, fb->fb_font->chars[(int)' '].r->height,#else fb->fb_font->width, fb->fb_font->height,#endif RAS_INVERT, (struct raster *) 0, 0, 0); fb->fb_bits ^= FB_CURSOR;}/* Possibly change to SUNWOB or SUNBOW mode */voidrcons_invert(fb, wob) struct fbdevice *fb; int wob;{ if (((fb->fb_bits & FB_INVERT) != 0) ^ wob) { /* Invert the display */ raster_op(fb->fb_sp, 0, 0, fb->fb_sp->width, fb->fb_sp->height, RAS_INVERT, (struct raster *) 0, 0, 0); /* Swap things around */ fb->fb_ras_blank = RAS_NOT(fb->fb_ras_blank); fb->fb_bits ^= FB_INVERT; }}/* Clear to the end of the page */voidrcons_clear2eop(fb) register struct fbdevice *fb;{ register int y; if (*fb->fb_col == 0 && *fb->fb_row == 0) { /* Clear the entire frame buffer */ raster_op(fb->fb_sp, 0, 0, fb->fb_sp->width, fb->fb_sp->height, fb->fb_ras_blank, (struct raster *) 0, 0, 0); } else { /* Only clear what needs to be cleared */ rcons_clear2eol(fb); y = (*fb->fb_row + 1) * fb->fb_font->height; raster_op(fb->fb_sp, fb->fb_xorigin, fb->fb_yorigin + y, fb->fb_emuwidth, fb->fb_emuheight - y, fb->fb_ras_blank, (struct raster *) 0, 0, 0); }}/* Clear to the end of the line */voidrcons_clear2eol(fb) register struct fbdevice *fb;{ register int x; x = *fb->fb_col * fb->fb_font->width; raster_op(fb->fb_sp, fb->fb_xorigin + x, *fb->fb_row * fb->fb_font->height + fb->fb_yorigin, fb->fb_emuwidth - x, fb->fb_font->height, fb->fb_ras_blank, (struct raster *) 0, 0, 0);}/* Scroll up one line */voidrcons_scroll(fb, n) register struct fbdevice *fb; register int n;{ register int ydiv; /* Can't scroll more than the whole screen */ if (n > fb->fb_maxrow) n = fb->fb_maxrow; /* Calculate new row */ *fb->fb_row -= n; if (*fb->fb_row < 0) *fb->fb_row = 0; /* Calculate number of pixels to scroll */ ydiv = fb->fb_font->height * n; raster_op(fb->fb_sp, fb->fb_xorigin, fb->fb_yorigin, fb->fb_emuwidth, fb->fb_emuheight - ydiv, RAS_SRC, fb->fb_sp, fb->fb_xorigin, ydiv + fb->fb_yorigin); raster_op(fb->fb_sp, fb->fb_xorigin, fb->fb_yorigin + fb->fb_emuheight - ydiv, fb->fb_emuwidth, ydiv, fb->fb_ras_blank, (struct raster *) 0, 0, 0);}/* Delete characters */voidrcons_delchar(fb, n) register struct fbdevice *fb; register int n;{ register int tox, fromx, y, width; /* Can't delete more chars than there are */ if (n > fb->fb_maxcol - *fb->fb_col) n = fb->fb_maxcol - *fb->fb_col; fromx = (*fb->fb_col + n) * fb->fb_font->width; tox = *fb->fb_col * fb->fb_font->width; y = *fb->fb_row * fb->fb_font->height; width = n * fb->fb_font->width; raster_op(fb->fb_sp, tox + fb->fb_xorigin, y + fb->fb_yorigin, fb->fb_emuwidth - fromx, fb->fb_font->height, RAS_SRC, fb->fb_sp, fromx + fb->fb_xorigin, y + fb->fb_yorigin); raster_op(fb->fb_sp, fb->fb_emuwidth - width + fb->fb_xorigin, y + fb->fb_yorigin, width, fb->fb_font->height, fb->fb_ras_blank, (struct raster *) 0, 0, 0);}/* Delete a number of lines */voidrcons_delline(fb, n) register struct fbdevice *fb; register int n;{ register int fromy, toy, height; /* Can't delete more lines than there are */ if (n > fb->fb_maxrow - *fb->fb_row) n = fb->fb_maxrow - *fb->fb_row; fromy = (*fb->fb_row + n) * fb->fb_font->height; toy = *fb->fb_row * fb->fb_font->height; height = fb->fb_font->height * n; raster_op(fb->fb_sp, fb->fb_xorigin, toy + fb->fb_yorigin, fb->fb_emuwidth, fb->fb_emuheight - fromy, RAS_SRC, fb->fb_sp, fb->fb_xorigin, fromy + fb->fb_yorigin); raster_op(fb->fb_sp, fb->fb_xorigin, fb->fb_emuheight - height + fb->fb_yorigin, fb->fb_emuwidth, height, fb->fb_ras_blank, (struct raster *) 0, 0, 0);}/* Insert some characters */voidrcons_insertchar(fb, n) register struct fbdevice *fb; register int n;{ register int tox, fromx, y; /* Can't insert more chars than can fit */ if (n > fb->fb_maxcol - *fb->fb_col) n = fb->fb_maxcol - *fb->fb_col; tox = (*fb->fb_col + n) * fb->fb_font->width; fromx = *fb->fb_col * fb->fb_font->width; y = *fb->fb_row * fb->fb_font->height; raster_op(fb->fb_sp, tox + fb->fb_xorigin, y + fb->fb_yorigin, fb->fb_emuwidth - tox, fb->fb_font->height, RAS_SRC, fb->fb_sp, fromx + fb->fb_xorigin, y + fb->fb_yorigin); raster_op(fb->fb_sp, fromx + fb->fb_xorigin, y + fb->fb_yorigin, fb->fb_font->width * n, fb->fb_font->height, fb->fb_ras_blank, (struct raster *) 0, 0, 0);}/* Insert some lines */voidrcons_insertline(fb, n) register struct fbdevice *fb; register int n;{ register int fromy, toy; /* Can't insert more lines than can fit */ if (n > fb->fb_maxrow - *fb->fb_row) n = fb->fb_maxrow - *fb->fb_row; toy = (*fb->fb_row + n) * fb->fb_font->height; fromy = *fb->fb_row * fb->fb_font->height; raster_op(fb->fb_sp, fb->fb_xorigin, toy + fb->fb_yorigin, fb->fb_emuwidth, fb->fb_emuheight - toy, RAS_SRC, fb->fb_sp, fb->fb_xorigin, fromy + fb->fb_yorigin); raster_op(fb->fb_sp, fb->fb_xorigin, fromy + fb->fb_yorigin, fb->fb_emuwidth, fb->fb_font->height * n, fb->fb_ras_blank, (struct raster *) 0, 0, 0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -