📄 terminalxterm.java
字号:
break; case 27: term.setAttribute(Terminal.ATTR_INVERSE, false); break; case 28: if(DEBUGNOTIMPL) notImplemented("SGR visible"); break; case 10: if(DEBUG) System.out.println("SGR ASCII: " + scsType); gSets[scsType] = CHARSET_ASCII; break; case 11: case 12: if(DEBUG) System.out.println("SGR LINEDRAW: " + scsType); gSets[scsType] = CHARSET_LINES; break; case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: term.setForegroundColor(param[i] - 30); break; case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: term.setForegroundColor(param[i] - 90); break; case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: term.setBackgroundColor(param[i] - 40); break; case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: term.setBackgroundColor(param[i] - 100); break; case 39: term.setForegroundColor(-1); // Reset to default color break; case 49: term.setBackgroundColor(-1); // Reset to default color break; default: if(DEBUGNOTIMPL) notImplemented("SGR: " + param[i]); } } } protected void dpModes(boolean set) { for(int i = 0; i < nparam; i++) { switch(param[i]) { case 1: if(DEBUG) System.out.println("DECCKM"); cursorKeysMode = set; break; case 2: if(DEBUG) System.out.println("ANSI/VT52"); if(set) { resetGSets(); } break; case 3: if(DEBUG) System.out.println("DECCOLM"); term.setOption(Terminal.OPT_DECCOLM, set); break; case 4: if(DEBUGNOTIMPL)notImplemented("DECSCLM"); break; case 5: if(DEBUG) System.out.println("DECSCNM"); term.setOption(Terminal.OPT_REV_VIDEO, set); break; case 6: if(DEBUG) System.out.println("DECOM"); windowRelative = set; break; case 7: if(DEBUG) System.out.println("DECAWM"); term.setOption(Terminal.OPT_AUTO_WRAP, set); break; case 8: // Not much we can do about autorepeat... if(DEBUG) System.out.println("DECARM"); break; case 9: if(DEBUG) System.out.println("MOUSE_X10"); if(set) sendMousePos = MOUSE_X10COMP; else sendMousePos = MOUSE_DONTSEND; break; case 18: if(DEBUGNOTIMPL) notImplemented("DECPFF"); break; case 19: if(DEBUGNOTIMPL) notImplemented("DECPEF"); break; case 25: if(DEBUG) System.out.println("VT220-VISCUR"); term.setOption(Terminal.OPT_VIS_CURSOR, set); break; case 38: if(DEBUGNOTIMPL) notImplemented("DECTEK"); break; case 40: if(DEBUG) System.out.println("DEC132COLS"); term.setOption(Terminal.OPT_DEC132COLS, set); break; case 41: if(DEBUGNOTIMPL) notImplemented("DECCUR-HACK"); break; case 42: if(DEBUGNOTIMPL) notImplemented("DECNRCM"); break; case 44: if(DEBUGNOTIMPL) notImplemented("DECMRGBEL"); break; case 45: if(DEBUG) System.out.println("DECREVWR"); term.setOption(Terminal.OPT_REV_WRAP, set); break; case 46: if(DEBUGNOTIMPL) notImplemented("DECLOG"); break; case 47: toggleAlternateBuffer(set); break; case 67: if(DEBUGNOTIMPL) notImplemented("DECBKM"); break; case 1000: if(DEBUG) System.out.println("MOUSE_DECVT200"); if(set) sendMousePos = MOUSE_DECVT200; else sendMousePos = MOUSE_DONTSEND; break; case 1001: if(DEBUGNOTIMPL) notImplemented("MOUSE_HLTRACK"); if(set) sendMousePos = MOUSE_HLTRACK; else sendMousePos = MOUSE_DONTSEND; break; case 1002: if(DEBUGNOTIMPL) notImplemented("Cell Motion Mouse Tracking"); break; case 1003: if(DEBUGNOTIMPL) notImplemented("All Motion Mouse Tracking"); break; case 1047: if(DEBUGNOTIMPL) notImplemented("Use Alternate Screen Buffer"); break; case 1048: if(DEBUGNOTIMPL) notImplemented("Save cursor as in DECSC"); break; case 1049: if(DEBUGNOTIMPL) notImplemented("Save cursor as in DECSC + Use Alternate Screen Buffer"); break; default: if(DEBUGNOTIMPL) notImplemented("DEC-private: " + param[i] + "(" + set + ")"); } } } protected void xtermModes() { switch(param[0]) { case 0: if(DEBUG) System.out.println("XTERM-Change icon-name/title: " + xtermSeq); case 1: if(DEBUG) System.out.println("XTERM-Change icon-name: " + xtermSeq); case 2: if(DEBUG) System.out.println("XTERM-Change title: " + xtermSeq); if(term instanceof TerminalWin) { ((TerminalWin)term).setTitle(xtermSeq); } break; case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: if(DEBUGNOTIMPL) notImplemented("XTERM-Change colors: " + xtermSeq); break; case 20: if(DEBUGNOTIMPL) notImplemented("XITERM-Change bg-pixmap: " + xtermSeq); break; case 39: if(DEBUGNOTIMPL) notImplemented("XITERM-Change fg-color: " + xtermSeq); break; case 49: if(DEBUGNOTIMPL) notImplemented("XITERM-Change bg-color: " + xtermSeq); break; case 46: if(DEBUGNOTIMPL) notImplemented("XTERM-new log-file: " + xtermSeq); break; case 50: if(DEBUGNOTIMPL) notImplemented("XTERM-set font: " + xtermSeq); break; default: if(DEBUGNOTIMPL) notImplemented("XTERM-unknown: " + xtermSeq); break; } } protected void xtermWinCtrl() { for(int i = 0; i < nparam; i++) { switch(param[i]) { case 1: if(DEBUGNOTIMPL) notImplemented("XTERM-deiconify"); break; case 2: if(DEBUGNOTIMPL) notImplemented("XTERM-iconify"); break; case 3: if(DEBUGNOTIMPL) notImplemented("XTERM-move (x,y): " + param[++i] + ", " + param[++i]); break; case 4: if(DEBUGNOTIMPL) notImplemented("XTERM-resize (h,w): " + param[++i] + ", " + param[++i]); break; case 5: if(DEBUGNOTIMPL) notImplemented("XTERM-raise"); break; case 6: if(DEBUGNOTIMPL) notImplemented("XTERM-lower"); break; case 7: if(DEBUGNOTIMPL) notImplemented("XTERM-refresh"); break; case 8: if(DEBUGNOTIMPL) notImplemented("XTERM-resize-txt (h,w): " + param[++i] + ", " + param[++i]); break; case 11: if(DEBUGNOTIMPL) notImplemented("XTERM-report state"); break; case 13: if(DEBUGNOTIMPL) notImplemented("XTERM-report pos."); break; case 14: if(DEBUGNOTIMPL) notImplemented("XTERM-report size"); break; case 18: if(DEBUGNOTIMPL) notImplemented("XTERM-report size-txt"); break; case 20: if(DEBUGNOTIMPL) notImplemented("XTERM-report icon-label"); break; case 21: if(DEBUGNOTIMPL) notImplemented("XTERM-report title"); break; case 24: default: if(DEBUGNOTIMPL) notImplemented("XTERM-resize to lines: " + param[i]); break; } } } protected void xtermSavemodes() { // !!! TODO, not much... } protected void xtermRestoremodes() { // !!! TODO, not much... } protected void ansiPrinterCtrl(int val) { switch(val) { case 0: if(DEBUG) System.out.println("ANSI print screen"); term.printScreen(); break; case 4: if(DEBUG) System.out.println("ANSI stop printer"); term.stopPrinter(); break; case 5: if(DEBUG) System.out.println("ANSI start printer"); term.startPrinter(); break; default: if(DEBUGNOTIMPL) notImplemented("<esc>[: " + val + "i not suppored"); break; } } protected void toggleAlternateBuffer(boolean set) { // !!! TODO, do we want this? I don't like it... } final protected void resetGSets() { gSets[0] = CHARSET_ASCII; gSets[1] = CHARSET_LINES; gSets[2] = CHARSET_ASCII; gSets[3] = CHARSET_ASCII; curGL = 0; } public void vtReset() { resetGSets(); curSS = 0; parseState = groundTable; windowRelative = false; keypadAppl = false; cursorKeysMode = false; sendMousePos = MOUSE_DONTSEND; if(term != null) { term.resetWindow(); term.clearScreen(); term.cursorSetPos(0, 0, false); term.resetTabs(); } } protected void notImplemented(String cmd) { System.out.println("not implemented: " + cmd); } final int mapVKToXVK(int vk) { int i; for(i = 0; i < XVK_MAX; i++) { if(vk2xvk[i] == vk) break; } return i; } public final int mapModToTab(int modifiers) { int table = 0; if((modifiers & InputEvent.SHIFT_MASK) != 0) table = 1; if((modifiers & InputEvent.CTRL_MASK) != 0) table += 2; return table; } public final String mapSpecialKeys(int virtualKey, int modifiers) { int xvk = mapVKToXVK(virtualKey); int modTable = mapModToTab(modifiers); String[][] specKeyMap = theSpecialKeyMaps[modTable]; return specKeyMap[xvk][whoAmIReally]; } public void keyHandler(int virtualKey, int modifiers) { String specialKey = null; String prefix = ""; // // switch(virtualKey) { case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: case KeyEvent.VK_RIGHT: case KeyEvent.VK_LEFT: if(cursorKeysMode) prefix = replyTypes[R_SS3]; else prefix = replyTypes[R_CSI]; specialKey = mapSpecialKeys(virtualKey, modifiers); break; case KeyEvent.VK_PAGE_UP: case KeyEvent.VK_PAGE_DOWN: case KeyEvent.VK_END: case KeyEvent.VK_HOME: if(!term.getOption(Terminal.OPT_LOCAL_PGKEYS)) { prefix = replyTypes[R_CSI]; specialKey = mapSpecialKeys(virtualKey, modifiers); } break; case KeyEvent.VK_INSERT: prefix = replyTypes[R_CSI]; specialKey = mapSpecialKeys(virtualKey, modifiers); break; case KeyEvent.VK_F1: case KeyEvent.VK_F2: case KeyEvent.VK_F3: case KeyEvent.VK_F4: case KeyEvent.VK_F5: case KeyEvent.VK_F6: case KeyEvent.VK_F7: case KeyEvent.VK_F8: case KeyEvent.VK_F9: case KeyEvent.VK_F10: case KeyEvent.VK_F11: case KeyEvent.VK_F12: if(whoAmIReally == EMUL_VT100 || whoAmIReally == EMUL_ANSI || whoAmIReally == EMUL_ATT6386) { prefix = replyTypes[R_SS3]; } else if(whoAmIReally == EMUL_VT220) { if(virtualKey > KeyEvent.VK_F4) prefix = replyTypes[R_CSI]; else prefix = replyTypes[R_SS3]; } else if(whoAmIReally == EMUL_VT52) { prefix = replyTypes[R_ESC]; } else { prefix = replyTypes[R_CSI]; } specialKey = mapSpecialKeys(virtualKey, modifiers); break; case KeyEvent.VK_NUMPAD0: case KeyEvent.VK_NUMPAD1: case KeyEvent.VK_NUMPAD2: case KeyEvent.VK_NUMPAD3: case KeyEvent.VK_NUMPAD4: case KeyEvent.VK_NUMPAD5: case KeyEvent.VK_NUMPAD6: case KeyEvent.VK_NUMPAD7: case KeyEvent.VK_NUMPAD8: case KeyEvent.VK_NUMPAD9: case KeyEvent.VK_MULTIPLY: case KeyEvent.VK_ADD: case KeyEvent.VK_SUBTRACT: case KeyEvent.VK_DIVIDE:/* !!! I give up on these, java is pretty immature concerning the virtual keys IMHO... Anyway, we should only send the key when in keypadAppl mode (the keyReleased/keyTyped must be handled accordingly since we must suppres the keyTyped...). All this is pretty messy, it would be POSSIBLE to do a huge kludge doing keyboard input using MOSTLY the keyReleased events and filling it in with the keyTyped that are not giving a sane VK_*. However, I am not in the mood of doing this right now. The virtual key handling/mapping should be refined in java IMHO if(keypadAppl) { prefix = replyTypes[R_SS3]; specialKey = mapSpecialKeys(virtualKey); }*/ default: // !!! System.out.println("XTerm keyHandler: " + virtualKey); break; } if(specialKey != null) { specialKey = prefix + specialKey; term.sendBytes(specialKey.getBytes()); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -