-rw-r--r-- | core/apps/embeddedkonsole/TEmuVt102.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/core/apps/embeddedkonsole/TEmuVt102.cpp b/core/apps/embeddedkonsole/TEmuVt102.cpp index 752c49f..275c18d 100644 --- a/core/apps/embeddedkonsole/TEmuVt102.cpp +++ b/core/apps/embeddedkonsole/TEmuVt102.cpp @@ -698,98 +698,127 @@ void TEmuVt102::onMouse( int cb, int cx, int cy ) } // 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 //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 + /// very hacky + if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='A')) sendString("\01"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='B')) sendString("\02"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='C')) sendString("\03"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='D')) sendString("\04"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='E')) sendString("\05"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='F')) sendString("\06"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='G')) sendString("\07"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='H')) sendString("\010"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='I')) sendString("\011"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='J')) sendString("\012"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='K')) sendString("\013"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='L')) sendString("\014"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='M')) sendString("\015"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='N')) sendString("\016"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='O')) sendString("\017"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='P')) sendString("\020"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Q')) sendString("\021"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='R')) sendString("\022"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='S')) sendString("\023"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='T')) sendString("\024"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='U')) sendString("\025"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='V')) sendString("\026"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='W')) sendString("\027"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='X')) sendString("\030"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Y')) sendString("\031"); + else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Z')) sendString("\032"); + else { 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 this 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, which represent plain characters. This conversion it 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 operation work on the current screen, the following two are different. */ void TEmuVt102::resetCharset(int scrno) |