⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 temuvt102.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/**/void TEmuVt102::reportStatus(){  sendString("\033[0n"); //VT100. Device status report. 0 = Ready.}/**/#define ANSWER_BACK "" // This is really obsolete VT100 stuff.void TEmuVt102::reportAnswerBack(){  sendString(ANSWER_BACK);}// Mouse Handling ---------------------------------------------------------- --/*    Mouse clicks are possibly reported to the client    application if it has expressed interest in them.    They are normally consumed by the widget for copy    and paste, but may be propagated from the widget    when gui->setMouseMarks is set via setMode(MODE_Mouse1000).    `x',`y' are 1-based.    `ev' (event) indicates the button pressed (0-2)                 or a general mouse release (3).*/void TEmuVt102::onMouse( int cb, int cx, int cy ){ char tmp[20];  if (!connected) return;  sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040);  sendString(tmp);}// Keyboard Handling ------------------------------------------------------- --#define encodeMode(M,B) BITS(B,getMode(M))#define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M)))/*   Keyboard event handling has been simplified somewhat by pushing   the complications towards a configuration file [see KeyTrans class].*/void TEmuVt102::onKeyPress( QKeyEvent* ev ){  if (!connected) return; // someone else gets the keys  if (ev->key() == Key_F11)  {    QPEMenuToolFocusManager *manager = QPEMenuToolFocusManager::manager();    manager->setActive( !manager->isActive() );    return;  }//printf("State/Key: 0x%04x 0x%04x (%d,%d)\n",ev->state(),ev->key(),ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0);  // revert to non-history when typing  if (scr->getHistCursor() != scr->getHistLines());    scr->setHistCursor(scr->getHistLines());  // lookup in keyboard translation table ...  int cmd; const char* txt; int len;  if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine  , BITS_NewLine   ) + // OLD,                                     encodeMode(MODE_Ansi     , BITS_Ansi      ) + // OBSOLETE,                                     encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff                                     encodeStat(ControlButton , BITS_Control   ) +                                     encodeStat(ShiftButton   , BITS_Shift     ) +                                     encodeStat(AltButton     , BITS_Alt       ),                          &cmd, &txt, &len ))//printf("cmd: %d, %s, %d\n",cmd,txt,len);  switch(cmd) // ... and execute if found.  {    case CMD_emitSelection  : gui->emitSelection();           return;    case CMD_scrollPageUp   : gui->doScroll(-gui->Lines()/2); return;    case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return;    case CMD_scrollLineUp   : gui->doScroll(-1             ); return;    case CMD_scrollLineDown : gui->doScroll(+1             ); return;    case CMD_send           : emit sndBlock(txt,len);         return;    case CMD_prevSession    : emit prevSession();             return;    case CMD_nextSession    : emit nextSession();             return;  }  // fall back handling  if (!ev->text().isEmpty())  {    if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix    QCString s = codec->fromUnicode(ev->text());     // encode for application    emit sndBlock(s.data(),s.length());              // we may well have s.length() > 1     return;  }}/* ------------------------------------------------------------------------- *//*                                                                           *//*                                VT100 Charsets                             *//*                                                                           *//* ------------------------------------------------------------------------- */// Character Set Conversion ------------------------------------------------ --/*    The processing contains a VT100 specific code translation layer.   It's still in use and mainly responsible for the line drawing graphics.   These and some other glyphs are assigned to codes (0x5f-0xfe)   normally occupied by the latin letters. Since these codes also   appear within control sequences, the extra code conversion   does not permute with the tokenizer and is placed behind it   in the pipeline. It only applies to tokens that represent   plain characters.   This conversion is eventually continued in TEWidget.C, since   it might involve VT100 enhanced fonts, which have these   particular glyphs allocated in (0x00-0x1f) in their code page.*/#define CHARSET charset[scr==screen[1]]// Apply current character map.unsigned short TEmuVt102::applyCharset(unsigned short c){  if (CHARSET.graphic && 0x5f <= c && c <= 0x7e) return vt100_graphics[c-0x5f];  if (CHARSET.pound                && c == '#' ) return 0xa3; //This mode is obsolete  return c;}/*   "Charset" related part of the emulation state.   This configures the VT100 charset filter.   While most operations work on the current screen,   the following two are different.*/void TEmuVt102::resetCharset(int scrno){  charset[scrno].cu_cs   = 0;  strncpy(charset[scrno].charset,"BBBB",4);  charset[scrno].sa_graphic = FALSE;  charset[scrno].sa_pound   = FALSE;  charset[scrno].graphic = FALSE;  charset[scrno].pound   = FALSE;}/**/void TEmuVt102::setCharset(int n, int cs) // on both screens.{  charset[0].charset[n&3] = cs; useCharset(charset[0].cu_cs);  charset[1].charset[n&3] = cs; useCharset(charset[1].cu_cs);}/**/void TEmuVt102::setAndUseCharset(int n, int cs){  CHARSET.charset[n&3] = cs;  useCharset(n&3);}/**/void TEmuVt102::useCharset(int n){  CHARSET.cu_cs   = n&3;  CHARSET.graphic = (CHARSET.charset[n&3] == '0');  CHARSET.pound   = (CHARSET.charset[n&3] == 'A'); //This mode is obsolete}/* Save the cursor position and the rendition attribute settings. */void TEmuVt102::saveCursor(){  CHARSET.sa_graphic = CHARSET.graphic;  CHARSET.sa_pound   = CHARSET.pound; //This mode is obsolete  // we are not clear about these  //sa_charset = charsets[cScreen->charset];  //sa_charset_num = cScreen->charset;  scr->saveCursor();}/* Restore the cursor position and the rendition attribute settings. */void TEmuVt102::restoreCursor(){  CHARSET.graphic = CHARSET.sa_graphic;  CHARSET.pound   = CHARSET.sa_pound; //This mode is obsolete  scr->restoreCursor();}/* ------------------------------------------------------------------------- *//*                                                                           *//*                                Mode Operations                            *//*                                                                           *//* ------------------------------------------------------------------------- *//*   Some of the emulations states are added to the state of the screens.   This causes some scoping problems, since different emulations choose to   located the mode either to the current screen or to both.   For strange reasons, the extend/t? of the rendition attributes ranges over   all screens and not over the actual screen.   We decided on the precise precise extend/t?, somehow.*/// "Mode" related part of the state. These are all booleans.void TEmuVt102::resetModes(){  resetMode(MODE_Mouse1000); saveMode(MODE_Mouse1000);  resetMode(MODE_AppScreen); saveMode(MODE_AppScreen);  // here come obsolete modes  resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys);  resetMode(MODE_NewLine  );    setMode(MODE_Ansi     );}void TEmuVt102::setMode(int m){  currParm.mode[m] = TRUE;  switch (m)  {    case MODE_Mouse1000 : gui->setMouseMarks(FALSE);    break;    case MODE_AppScreen : screen[1]->clearSelection();                          screen[1]->clearEntireScreen();                          setScreen(1);	  break;  }  if (m < MODES_SCREEN || m == MODE_NewLine)  {    screen[0]->setMode(m);    screen[1]->setMode(m);  }}void TEmuVt102::resetMode(int m){  currParm.mode[m] = FALSE;  switch (m)  {    case MODE_Mouse1000 : gui->setMouseMarks(TRUE);    break;    case MODE_AppScreen : screen[0]->clearSelection();                          setScreen(0);    break;  }  if (m < MODES_SCREEN || m == MODE_NewLine)  {    screen[0]->resetMode(m);    screen[1]->resetMode(m);  }}void TEmuVt102::saveMode(int m){  saveParm.mode[m] = currParm.mode[m];}void TEmuVt102::restoreMode(int m){  if(saveParm.mode[m]) setMode(m); else resetMode(m);}BOOL TEmuVt102::getMode(int m){  return currParm.mode[m];}void TEmuVt102::setConnect(bool c){  TEmulation::setConnect(c);  if (c)  { // refresh mouse mode    if (getMode(MODE_Mouse1000))      setMode(MODE_Mouse1000);    else      resetMode(MODE_Mouse1000);  }}/* ------------------------------------------------------------------------- *//*                                                                           *//*                               Diagnostic                                  *//*                                                                           *//* ------------------------------------------------------------------------- *//*? shows the contents of the scan buffer.    This functions is used for diagnostics. It is called by \e ReportErrorToken    to report about strings that cannot be decoded or handled by the emulation.    \sa ReportErrorToken*//*?*/static void hexdump(int* s, int len){ int i;  for (i = 0; i < len; i++)  {    if (s[i] == '\\')      printf("\\\\");    else    if ((s[i]) > 32 && s[i] < 127)      printf("%c",s[i]);    else      printf("\\%04x(hex)",s[i]);  }}void TEmuVt102::scan_buffer_report(){  if (ppos == 0 || ppos == 1 && (pbuf[0] & 0xff) >= 32) return;  printf("token: "); hexdump(pbuf,ppos); printf("\n");}/**/void TEmuVt102::ReportErrorToken(){  printf("undecodable "); scan_buffer_report();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -