📄 ecurcvr.c
字号:
case 1: shm->cursor_x = 0; } if(shm->cursor_x >= tcap_COLS) shm->cursor_x = 0; if(shm->cursor_y >= tcap_LINES) shm->cursor_y = 0; if(!tty_is_multiscreen) tcap_cursor(shm->cursor_y,shm->cursor_x);} /* end of ansi_CUP *//*+------------------------------------------------------------------------- ansi_CUU() - cursor up--------------------------------------------------------------------------*/voidansi_CUU(){ register uint count; register uint y; if(ansilen == 2) /* no param */ count = 1; else count = atoi(ansibuf + 1); y = shm->cursor_y - count; if(y >= tcap_LINES) /* unsigned comparison */ y = 0; if(y != shm->cursor_y) { shm->cursor_y = y; if(!tty_is_multiscreen) tcap_cursor(shm->cursor_y,shm->cursor_x); }} /* end of ansi_CUU *//*+------------------------------------------------------------------------- ansi_CUD() - cursor down (also VPR vertical position relative)--------------------------------------------------------------------------*/voidansi_CUD(){ register uint count; register uint y; if(ansilen == 2) /* no param */ count = 1; else count = atoi(ansibuf + 1); y = shm->cursor_y + count; if(y >= tcap_LINES) y = tcap_LINES - 1; if(y != shm->cursor_y) { shm->cursor_y = y; if(!tty_is_multiscreen) tcap_cursor(shm->cursor_y,shm->cursor_x); }} /* end of ansi_CUD *//*+------------------------------------------------------------------------- ansi_CUF() - cursor forward (also HPR horizontal position relative)--------------------------------------------------------------------------*/voidansi_CUF(){ register uint count; register uint x; if(ansilen == 2) /* no param */ count = 1; else count = atoi(ansibuf + 1); x = shm->cursor_x + count; if(x >= tcap_COLS) x = tcap_COLS - 1; if(x != shm->cursor_x) { shm->cursor_x = x; if(!tty_is_multiscreen) tcap_cursor(shm->cursor_y,shm->cursor_x); }} /* end of ansi_CUF *//*+------------------------------------------------------------------------- ansi_CUB() - cursor forward--------------------------------------------------------------------------*/voidansi_CUB(){ register uint count; register uint x; if(ansilen == 2) /* no param */ count = 1; else count = atoi(ansibuf + 1); x = shm->cursor_x - count; if(x >= tcap_COLS) /* unsigned comparison */ x = 0; if(x != shm->cursor_x) { shm->cursor_x = x; if(!tty_is_multiscreen) tcap_cursor(shm->cursor_y,shm->cursor_x); }} /* end of ansi_CUB *//*+------------------------------------------------------------------------- ansi_DSR() - device status report--------------------------------------------------------------------------*/voidansi_DSR(){ char response[MAX_ANSI_LEN]; sprintf(response,"\033[%d;%dR",shm->cursor_y + 1,shm->cursor_x + 1); write(shm->Liofd,response,strlen(response));} /* end of ansi_DSR *//*+------------------------------------------------------------------------- ansi_ED() - erase in display--------------------------------------------------------------------------*/voidansi_ED(){ register uint param; int y; if(ansilen == 2) /* no param */ param = 0; else param = atoi(ansibuf + 1); switch(param) { case 0: /* erase to end of display */ spaces(&shm->screen[shm->cursor_y][shm->cursor_x], LINESxCOLS - ((shm->cursor_y * tcap_COLS) + shm->cursor_x)); if(!tty_is_multiscreen) tcap_eeod(); break; case 1: /* erase from beginning of display */ spaces((char *)shm->screen,(shm->cursor_y * tcap_COLS) + shm->cursor_x); if(!tty_is_multiscreen) { for(y = 0; y < shm->cursor_y - 1; y++) { tcap_cursor(y,0); tcap_eeol(); } if(shm->cursor_x) { tcap_cursor(shm->cursor_y,0); tcap_clear_area_char(shm->cursor_x,' '); } else tcap_cursor(shm->cursor_y,shm->cursor_x); } break; case 2: /* clear display */ shm->cursor_y = 0; shm->cursor_x = 0; spaces((char *)shm->screen,LINESxCOLS); if(!tty_is_multiscreen) { tcap_clear_screen(); tcap_cursor(shm->cursor_y,shm->cursor_x); } break; }} /* end of ansi_ED *//*+------------------------------------------------------------------------- ansi_EL() - erase in line--------------------------------------------------------------------------*/voidansi_EL(){ register uint param; char cr = CRET; if(ansilen == 2) /* no param */ param = 0; else param = atoi(ansibuf + 1); switch(param) { case 2: /* clear line */ shm->cursor_x = 0; if(!tty_is_multiscreen) rcvrdisp(&cr,1); /* fall thru */ case 0: /* erase to end of line */ spaces(&shm->screen[shm->cursor_y][shm->cursor_x], tcap_COLS - shm->cursor_x); if(!tty_is_multiscreen) tcap_eeol(); break; case 1: /* erase from beginning of line */ spaces(&shm->screen[shm->cursor_y][0],shm->cursor_x); if(!tty_is_multiscreen && shm->cursor_x) { rcvrdisp(&cr,1); tcap_clear_area_char(shm->cursor_x,' '); } break; }} /* end of ansi_EL *//*+------------------------------------------------------------------------- ansi_ECH() - erase characters--------------------------------------------------------------------------*/voidansi_ECH(){ register uint param; register uint screen_pos; if(ansilen == 2) /* no param */ param = 1; else param = atoi(ansibuf + 1); if((shm->cursor_x + param) >= tcap_COLS) return; screen_pos = (shm->cursor_y * tcap_COLS) + shm->cursor_x; mem_cpy((char *)shm->screen + screen_pos, (char *)shm->screen + screen_pos + param,param); spaces((char *)shm->screen + ((shm->cursor_y + 1) * tcap_COLS) - param,param); if(!tty_is_multiscreen) tcap_delete_chars(param);} /* end of ansi_ECH *//*+------------------------------------------------------------------------- ansi_SU() - scroll up (new blank lines at the bottom)--------------------------------------------------------------------------*/voidansi_SU(){ register uint param; register uint count; if(ansilen == 2) /* no param */ param = 1; else param = atoi(ansibuf + 1); if(param > tcap_LINES) param = tcap_LINES; if(!param) return;#ifdef ANSI_DEBUG_3 if(wfp) fprintf(wfp,"SU: param=%u y,x=%d,%d\n",param, shm->cursor_y,shm->cursor_x);#endif count = tcap_COLS * param; mem_cpy((char *)shm->screen,(char *)shm->screen + count, LINESxCOLS - count); spaces((char *)shm->screen + LINESxCOLS - count,count); if(!tty_is_multiscreen) { tcap_cursor(tcap_LINES - 1,0); while(param--) ff(se,"\r\n"); tcap_cursor(shm->cursor_y,shm->cursor_x); }} /* end of ansi_SU *//*+------------------------------------------------------------------------- ansi_SD() - scroll down (new blank lines at the top)--------------------------------------------------------------------------*/voidansi_SD(){ register uint param; register uint count; if(ansilen == 2) /* no param */ param = 1; else param = atoi(ansibuf + 1); if(param > tcap_LINES) param = tcap_LINES; if(!param) return;#ifdef ANSI_DEBUG_3 if(wfp) fprintf(wfp,"SD: param=%u y,x=%d,%d\n",param, shm->cursor_y,shm->cursor_x);#endif count = tcap_COLS * param; mem_cpy((char *)shm->screen,(char *)shm->screen + count, LINESxCOLS - count); spaces((char *)shm->screen + LINESxCOLS - count,count); if(!tty_is_multiscreen) { tcap_cursor(0,0); tcap_insert_lines(param); tcap_cursor(shm->cursor_y,shm->cursor_x); }} /* end of ansi_SD *//*+------------------------------------------------------------------------- ansi_HPA() - horizontal position absolute--------------------------------------------------------------------------*/voidansi_HPA(){ register uint param; if(ansilen == 2) /* no param */ param = 1; else param = atoi(ansibuf + 1); if(param >= tcap_LINES) return; if((unsigned)(shm->cursor_x = param) >= (unsigned)tcap_COLS) shm->cursor_x = tcap_COLS - 1; if(!tty_is_multiscreen) tcap_cursor(shm->cursor_y,shm->cursor_x);} /* end of ansi_HPA *//*+------------------------------------------------------------------------- ansi_VPA() - vertical position absolute--------------------------------------------------------------------------*/voidansi_VPA(){ register uint param; if(ansilen == 2) /* no param */ param = 1; else param = atoi(ansibuf + 1); if(param >= tcap_COLS) return; if((unsigned)(shm->cursor_y = param) >= (unsigned)tcap_LINES) shm->cursor_y = tcap_LINES - 1; if(!tty_is_multiscreen) tcap_cursor(shm->cursor_y,shm->cursor_x);} /* end of ansi_VPA *//*+------------------------------------------------------------------------- ansi_IL() - insert lines--------------------------------------------------------------------------*/voidansi_IL(){ register uint param; register uint count; register uint screen_pos; if(ansilen == 2) /* no param */ param = 1; else param = atoi(ansibuf + 1); if((shm->cursor_y + param) >= tcap_LINES) return; count = tcap_COLS * param; screen_pos = shm->cursor_y * tcap_COLS; mem_cpy((char *)shm->screen + screen_pos + count, (char *)shm->screen + screen_pos, LINESxCOLS - screen_pos - count); spaces((char *)shm->screen + screen_pos,count); if(!tty_is_multiscreen) tcap_insert_lines(param);} /* end of ansi_IL *//*+------------------------------------------------------------------------- ansi_ICH() - insert characters--------------------------------------------------------------------------*/voidansi_ICH(){ register uint param; register uint count; register uint screen_pos; if(ansilen == 2) /* no param */ param = 1; else param = atoi(ansibuf + 1); if(param > tcap_COLS - shm->cursor_x) param = tcap_COLS - shm->cursor_x; if(!param) return; screen_pos = (shm->cursor_y * tcap_COLS) + shm->cursor_x; count = tcap_COLS - shm->cursor_x - param; mem_cpy((char *)shm->screen + screen_pos + param, (char *)shm->screen + screen_pos,count); spaces((char *)shm->screen + screen_pos,param); if(!tty_is_multiscreen) tcap_insert_chars(param);} /* end of ansi_ICH *//*+------------------------------------------------------------------------- ansi_DL() - delete lines--------------------------------------------------------------------------*/voidansi_DL(){ register uint param; register uint count; register uint screen_pos; if(ansilen == 2) /* no param */ param = 1; else param = atoi(ansibuf + 1); if(param > (tcap_LINES - shm->cursor_y)) param = tcap_LINES - shm->cursor_y; if(!param) return; count = tcap_COLS * param; screen_pos = shm->cursor_y * tcap_COLS; mem_cpy((char *)shm->screen + screen_pos, (char *)shm->screen + screen_pos + count, LINESxCOLS - screen_pos - count); spaces((char *)shm->screen + LINESxCOLS - count,count); if(!tty_is_multiscreen) tcap_delete_lines(param);} /* end of ansi_DL *//*+------------------------------------------------------------------------- ansi_DCH() - delete characters--------------------------------------------------------------------------*/voidansi_DCH(){ register uint param; register uint count; register uint screen_pos; if(ansilen == 2) /* no param */ param = 1; else param = atoi(ansibuf + 1); if(ansilen == 2) /* no param */ param = 1; else param = atoi(ansibuf + 1); if(param > tcap_COLS - shm->cursor_x) param = tcap_COLS - shm->cursor_x; if(!param) return; screen_pos = (shm->cursor_y * tcap_COLS) + shm->cursor_x; count = tcap_COLS - shm->cursor_x - param; mem_cpy((char *)shm->screen + screen_pos, (char *)shm->screen + screen_pos + param,count); screen_pos = ((shm->cursor_y + 1) * tcap_COLS) - param; spaces((char *)shm->screen + screen_pos,param);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -