?? vt320.java
字號(hào):
/* * This file is part of "The Java Telnet Application". * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * "The Java Telnet Application" is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */package de.mud.terminal;import java.awt.Font;import java.awt.Dimension;import java.awt.Event;import java.awt.event.KeyEvent;import java.awt.event.KeyListener;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.util.Properties;/** * Implementation of a VT terminal emulation plus ANSI compatible. * <P> * <B>Maintainer:</B> Marcus Mei遪er * * @version $Id: vt320.java,v 2.50 2001/02/27 17:55:46 marcus Exp $ * @author Matthias L. Jugel, Marcus Mei遪er */public abstract class vt320 extends VDU implements KeyListener { /** The current version id tag.<P> * $Id: vt320.java,v 2.50 2001/02/27 17:55:46 marcus Exp $ */ public final static String ID = "$Id: vt320.java,v 2.50 2001/02/27 17:55:46 marcus Exp $"; /** the debug level */ private final static int debug = 0; /** * Write an answer back to the remote host. This is needed to be able to * send terminal answers requests like status and type information. * @param b the array of bytes to be sent */ protected abstract void write(byte[] b); /** * Play the beep sound ... */ protected void beep() { /* do nothing by default */ } /** * Put string at current cursor position. Moves cursor * according to the String. Does NOT wrap. * @param s the string */ public void putString(String s) { int i,len=s.length(); // System.err.println("'"+s+"'"); if(len > 0) { markLine(R,1); for (i=0;i<len;i++) { // System.err.print(s.charAt(i)+"("+(int)s.charAt(i)+")"); putChar(s.charAt(i),false); } setCursorPosition(C, R); redraw(); } } protected void sendTelnetCommand(byte cmd) { } /** * Create a new vt320 terminal and intialize it with useful settings. * @param width the width of the character screen * @param height the amount of rows on screen * @param font the font to be used for rendering characters */ public vt320(int width, int height, Font font) { super(width, height, font); setVMS(false); setIBMCharset(false); // setTerminalID("vt320"); setTerminalID("ANSI"); setBufferSize(100); setBorder(2, false); int nw = getColumns(); if (nw<132) nw=132; //catch possible later 132/80 resizes Tabs = new byte[nw]; for (int i=0;i<nw;i+=8) { Tabs[i]=1; } int nh = getRows(); HTabs = new byte[nh]; for (int i=0;i<nh;i+=8) { // I don't know whether the default vertical tab is 8 HTabs[i]=1; } /* top row of numpad */ PF1 = "\u001bOP"; PF2 = "\u001bOQ"; PF3 = "\u001bOR"; PF4 = "\u001bOS"; /* the 3x2 keyblock on PC keyboards */ Insert = new String[4]; Remove = new String[4]; KeyHome = new String[4]; KeyEnd = new String[4]; NextScn = new String[4]; PrevScn = new String[4]; Escape = new String[4]; BackSpace = new String[4]; TabKey = new String[4]; Insert[0] = Insert[1] = Insert[2] = Insert[3] = "\u001b[2~"; Remove[0] = Remove[1] = Remove[2] = Remove[3] = "\u001b[3~"; PrevScn[0] = PrevScn[1] = PrevScn[2] = PrevScn[3] = "\u001b[5~"; NextScn[0] = NextScn[1] = NextScn[2] = NextScn[3] = "\u001b[6~"; // KeyHome[0] = KeyHome[1] = KeyHome[2] = KeyHome[3] = "\u001b[H"; KeyHome[0] = KeyHome[1] = KeyHome[2] = KeyHome[3] = "\u001b[1~"; // KeyEnd[0] = KeyEnd[1] = KeyEnd[2] = KeyEnd[3] = "\u001b[F"; KeyEnd[0] = KeyEnd[1] = KeyEnd[2] = KeyEnd[3] = "\u001b[4~"; Escape[0] = Escape[1] = Escape[2] = Escape[3] = "\u001b"; BackSpace[0] = BackSpace[1] = BackSpace[2] = BackSpace[3] = "\b"; /* some more VT100 keys */ Find = "\u001b[1~"; Select = "\u001b[4~"; Help = "\u001b[28~"; Do = "\u001b[29~"; FunctionKey = new String[21]; FunctionKey[0]= ""; FunctionKey[1]= PF1; FunctionKey[2]= PF2; FunctionKey[3]= PF3; FunctionKey[4]= PF4; /* following are defined differently for vt220 / vt132 ... */ FunctionKey[5]= "\u001b[15~"; FunctionKey[6]= "\u001b[17~"; FunctionKey[7]= "\u001b[18~"; FunctionKey[8]= "\u001b[19~"; FunctionKey[9]= "\u001b[20~"; FunctionKey[10]= "\u001b[21~"; FunctionKey[11]= "\u001b[23~"; FunctionKey[12]= "\u001b[24~"; FunctionKey[13]= "\u001b[25~"; FunctionKey[14]= "\u001b[26~"; FunctionKey[15]= Help; FunctionKey[16]= Do; FunctionKey[17]= "\u001b[31~"; FunctionKey[18]= "\u001b[32~"; FunctionKey[19]= "\u001b[33~"; FunctionKey[20]= "\u001b[34~"; FunctionKeyShift = new String[21]; FunctionKeyAlt = new String[21]; FunctionKeyCtrl = new String[21]; for (int i=0;i<20;i++) { FunctionKeyShift[i]=""; FunctionKeyAlt[i]=""; FunctionKeyCtrl[i]=""; } FunctionKeyShift[15] = Find; FunctionKeyShift[16] = Select; TabKey[0] = "\u0009"; // TabKey[1] = "\u001bOP\u0009"; TabKey[1] = "\u001b[Z"; TabKey[2] = TabKey[3] = ""; KeyUp = new String[4]; KeyUp[0] = "\u001b[A"; KeyDown = new String[4]; KeyDown[0] = "\u001b[B"; KeyRight = new String[4]; KeyRight[0]= "\u001b[C"; KeyLeft = new String[4]; KeyLeft[0] = "\u001b[D"; Numpad = new String[10]; Numpad[0] = "\u001bOp"; Numpad[1] = "\u001bOq"; Numpad[2] = "\u001bOr"; Numpad[3] = "\u001bOs"; Numpad[4] = "\u001bOt"; Numpad[5] = "\u001bOu"; Numpad[6] = "\u001bOv"; Numpad[7] = "\u001bOw"; Numpad[8] = "\u001bOx"; Numpad[9] = "\u001bOy"; KPMinus = "\u001bOm"; KPComma = "\u001bOl"; KPPeriod = "\u001bOn"; KPEnter = "\u001bOM"; /* ... */ addKeyListener(this); /* I don't think we want that here ... */ addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent evt) { requestFocus(); } public void mousePressed(MouseEvent evt) { if (mouserpt==0) return; int mods = evt.getModifiers(); mousebut = 3; if ((mods & 16)==16) mousebut=0; if ((mods & 8)==8 ) mousebut=1; if ((mods & 4)==4 ) mousebut=2; int mousecode; if (mouserpt == 9) /* X10 Mouse */ mousecode = 0x20|mousebut; else /* normal xterm mouse reporting */ mousecode = mousebut|0x20|((mods & 7)<<2); java.awt.Point pos = mouseGetPos(evt.getPoint()); byte b[] = new byte[6]; b[0] = 27; b[1] = (byte)'['; b[2] = (byte)'M'; b[3] = (byte)mousecode; b[4] = (byte) (0x20 + pos.x + 1); b[5] = (byte) (0x20 + pos.y + 1); write(b); } public void mouseReleased(MouseEvent evt) { if (mouserpt==0) return; java.awt.Point pos = mouseGetPos(evt.getPoint()); int mods = evt.getModifiers(); /* problem is tht modifiers still have the released button set in them. mousebut = 3; if ((mods & 16)==16) mousebut=0; if ((mods & 8)==8 ) mousebut=1; if ((mods & 4)==4 ) mousebut=2; */ int mousecode; if (mouserpt == 9) mousecode = 0x20+mousebut; /* same as press? appears so. */ else mousecode = '#'; byte b[] = new byte[6]; b[0] = 27; b[1] = (byte)'['; b[2] = (byte)'M'; b[3] = (byte)mousecode; b[4] = (byte) (0x20 + pos.x + 1); b[5] = (byte) (0x20 + pos.y + 1); write(b); mousebut = 0; } }); } /** * Create a new terminal emulation with specific width and height. * @param width the width of the character screen * @param height the amount of rows on screen */ public vt320(int width, int height) { this(width, height, new Font("Monospaced", Font.PLAIN, 20)); // this(width, height, new Font("穝燦
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -