commit 030eadbad26a370a331fb85fe1f9ab26f11e4af8 from: leo date: Mon Feb 4 08:20:53 2002 UTC added colors configuration for BOLD and INVERT commit - 22436e76609122bc60ef6f0433f0b03a7c41bb2c commit + 030eadbad26a370a331fb85fe1f9ab26f11e4af8 blob - 8029f31163249c3b122c71d3d19de2ae0eac05d2 blob + e5d0a80d439ffc465c75c42323d2a2a3deb79b54 --- de/mud/jta/plugin/Terminal.java +++ de/mud/jta/plugin/Terminal.java @@ -6,11 +6,11 @@ * 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 + * "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, @@ -19,56 +19,39 @@ package de.mud.jta.plugin; +import de.mud.jta.FilterPlugin; import de.mud.jta.Plugin; +import de.mud.jta.PluginBus; import de.mud.jta.PluginConfig; -import de.mud.jta.FilterPlugin; import de.mud.jta.VisualTransferPlugin; -import de.mud.jta.PluginBus; - -import de.mud.terminal.vt320; - import de.mud.jta.event.ConfigurationListener; -import de.mud.jta.event.OnlineStatusListener; -import de.mud.jta.event.TerminalTypeListener; -import de.mud.jta.event.WindowSizeListener; -import de.mud.jta.event.LocalEchoListener; import de.mud.jta.event.FocusStatus; +import de.mud.jta.event.LocalEchoListener; +import de.mud.jta.event.OnlineStatusListener; import de.mud.jta.event.ReturnFocusListener; -import de.mud.jta.event.AppletListener; import de.mud.jta.event.SoundRequest; import de.mud.jta.event.TelnetCommandRequest; +import de.mud.jta.event.TerminalTypeListener; +import de.mud.jta.event.WindowSizeListener; +import de.mud.terminal.vt320; +import de.mud.terminal.VDU; -import java.awt.Component; -import java.awt.Panel; -import java.awt.BorderLayout; -import java.awt.Menu; -import java.awt.MenuItem; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Color; -import java.awt.Scrollbar; -import java.awt.Cursor; - -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; -import java.awt.event.FocusListener; -import java.awt.event.FocusEvent; - +import java.awt.*; import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.ClipboardOwner; -import java.awt.datatransfer.Transferable; import java.awt.datatransfer.DataFlavor; - +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.io.IOException; -import java.io.InputStream; - -import java.net.URL; import java.net.MalformedURLException; - -import java.util.Properties; -import java.util.Hashtable; +import java.net.URL; import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Properties; /** * The terminal plugin represents the actual terminal where the @@ -80,16 +63,16 @@ import java.util.Enumeration; * @version $Id$ * @author Matthias L. Jugel, Marcus Meißner */ -public class Terminal extends Plugin +public class Terminal extends Plugin implements FilterPlugin, VisualTransferPlugin, ClipboardOwner, Runnable { private final static boolean personalJava = false; private final static int debug = 0; - + /** holds the actual terminal emulation */ protected vt320 terminal; - /** + /** * The default encoding is ISO 8859-1 (western). * However, as you see the value is set to latin1 which is a value that * is not even documented and thus incorrect, but it forces the default @@ -112,6 +95,20 @@ public class Terminal extends Plugin private boolean localecho_overridden = false; + private Color codeToColor(String code) { + if(colors.get(code) != null) + return (Color) colors.get(code); + else + try { + if(Color.getColor(code) != null) + return Color.getColor(code); + else + return Color.decode(code); + } catch(Exception e) { + error("ignoring unknown color code: " + code); + } + return null; + } /** * Create a new terminal plugin and initialize the terminal emulation. */ @@ -133,103 +130,103 @@ public class Terminal extends Plugin if(!personalJava) { - menu = new Menu("Terminal"); - MenuItem item; + menu = new Menu("Terminal"); + MenuItem item; - Menu fgm = new Menu("Foreground"); - Menu bgm = new Menu("Background"); - Enumeration cols = colors.keys(); - ActionListener fgl = new ActionListener() { - public void actionPerformed(ActionEvent e) { - terminal.setForeground((Color)colors.get(e.getActionCommand())); - tPanel.repaint(); + Menu fgm = new Menu("Foreground"); + Menu bgm = new Menu("Background"); + Enumeration cols = colors.keys(); + ActionListener fgl = new ActionListener() { + public void actionPerformed(ActionEvent e) { + terminal.setForeground((Color) colors.get(e.getActionCommand())); + tPanel.repaint(); + } + }; + ActionListener bgl = new ActionListener() { + public void actionPerformed(ActionEvent e) { + terminal.setBackground((Color) colors.get(e.getActionCommand())); + tPanel.repaint(); + } + }; + while(cols.hasMoreElements()) { + String color = (String) cols.nextElement(); + fgm.add(item = new MenuItem(color)); + item.addActionListener(fgl); + bgm.add(item = new MenuItem(color)); + item.addActionListener(bgl); } - }; - ActionListener bgl = new ActionListener() { - public void actionPerformed(ActionEvent e) { - terminal.setBackground((Color)colors.get(e.getActionCommand())); - tPanel.repaint(); - } - }; - while(cols.hasMoreElements()) { - String color = (String)cols.nextElement(); - fgm.add(item = new MenuItem(color)); - item.addActionListener(fgl); - bgm.add(item = new MenuItem(color)); - item.addActionListener(bgl); - } - menu.add(fgm); - menu.add(bgm); + menu.add(fgm); + menu.add(bgm); - menu.add(item = new MenuItem("Smaller Font")); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Font font = terminal.getFont(); - terminal.setFont(new Font(font.getName(), - font.getStyle(), font.getSize()-1)); - if(tPanel.getParent() != null) { - Component parent = tPanel.getParent(); - if(parent instanceof java.awt.Frame) - ((java.awt.Frame)parent).pack(); - tPanel.getParent().doLayout(); - tPanel.getParent().validate(); - } - } - }); - menu.add(item = new MenuItem("Larger Font")); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Font font = terminal.getFont(); - terminal.setFont(new Font(font.getName(), - font.getStyle(), font.getSize()+1)); - if(tPanel.getParent() != null) { - Component parent = tPanel.getParent(); - if(parent instanceof java.awt.Frame) - ((java.awt.Frame)parent).pack(); - tPanel.getParent().doLayout(); - tPanel.getParent().validate(); - } - } - }); - menu.add(item = new MenuItem("Buffer +50")); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - terminal.setBufferSize(terminal.getBufferSize() + 50); - } - }); - menu.add(item = new MenuItem("Buffer -50")); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - terminal.setBufferSize(terminal.getBufferSize() - 50); - } - }); - menu.addSeparator(); - menu.add(item = new MenuItem("Reset Terminal")); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - terminal.reset(); - } - }); - + menu.add(item = new MenuItem("Smaller Font")); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Font font = terminal.getFont(); + terminal.setFont(new Font(font.getName(), + font.getStyle(), font.getSize() - 1)); + if(tPanel.getParent() != null) { + Component parent = tPanel.getParent(); + if(parent instanceof java.awt.Frame) + ((java.awt.Frame) parent).pack(); + tPanel.getParent().doLayout(); + tPanel.getParent().validate(); + } + } + }); + menu.add(item = new MenuItem("Larger Font")); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Font font = terminal.getFont(); + terminal.setFont(new Font(font.getName(), + font.getStyle(), font.getSize() + 1)); + if(tPanel.getParent() != null) { + Component parent = tPanel.getParent(); + if(parent instanceof java.awt.Frame) + ((java.awt.Frame) parent).pack(); + tPanel.getParent().doLayout(); + tPanel.getParent().validate(); + } + } + }); + menu.add(item = new MenuItem("Buffer +50")); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + terminal.setBufferSize(terminal.getBufferSize() + 50); + } + }); + menu.add(item = new MenuItem("Buffer -50")); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + terminal.setBufferSize(terminal.getBufferSize() - 50); + } + }); + menu.addSeparator(); + menu.add(item = new MenuItem("Reset Terminal")); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + terminal.reset(); + } + }); + } // !personalJava // create the terminal emulation terminal = new vt320() { public void write(byte[] b) { try { - Terminal.this.write(b); - } catch(IOException e) { - reader = null; - } + Terminal.this.write(b); + } catch(IOException e) { + reader = null; + } } // provide audio feedback if that is configured public void beep() { - if(audioBeep != null) bus.broadcast(audioBeep); + if(audioBeep != null) bus.broadcast(audioBeep); } public void sendTelnetCommand(byte cmd) { - bus.broadcast(new TelnetCommandRequest(cmd)); + bus.broadcast(new TelnetCommandRequest(cmd)); } }; @@ -240,6 +237,7 @@ public class Terminal extends Plugin public void update(java.awt.Graphics g) { paint(g); } + // we don't want to print the container, just the terminal contents public void print(java.awt.Graphics g) { terminal.print(g); @@ -250,14 +248,15 @@ public class Terminal extends Plugin terminal.addFocusListener(new FocusListener() { public void focusGained(FocusEvent evt) { if(debug > 0) - System.err.println("Terminal: focus gained"); - terminal.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); + System.err.println("Terminal: focus gained"); + terminal.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); bus.broadcast(new FocusStatus(Terminal.this, evt)); } + public void focusLost(FocusEvent evt) { if(debug > 0) - System.err.println("Terminal: focus lost"); - terminal.setCursor(Cursor.getDefaultCursor()); + System.err.println("Terminal: focus lost"); + terminal.setCursor(Cursor.getDefaultCursor()); bus.broadcast(new FocusStatus(Terminal.this, evt)); } }); @@ -265,7 +264,7 @@ public class Terminal extends Plugin // register an online status listener bus.registerPluginListener(new OnlineStatusListener() { public void online() { - if(debug > 0) System.err.println("Terminal: online "+reader); + if(debug > 0) System.err.println("Terminal: online " + reader); if(reader == null) { reader = new Thread(Terminal.this); reader.start(); @@ -293,8 +292,8 @@ public class Terminal extends Plugin bus.registerPluginListener(new LocalEchoListener() { public void setLocalEcho(boolean echo) { - if (!localecho_overridden) - terminal.setLocalEcho(echo); + if(!localecho_overridden) + terminal.setLocalEcho(echo); } }); @@ -323,10 +322,12 @@ public class Terminal extends Plugin try { terminal.setColorPrinting(Boolean.valueOf(tmp).booleanValue()); } catch(Exception e) { - error("Terminal.color.print: must be either true or false, not "+tmp); + error("Terminal.color.print: must be either true or false, not " + tmp); } - + + System.err.print("colorSet: "); if((tmp = cfg.getProperty("Terminal", id, "colorSet")) != null) { + System.err.println(tmp); Properties colorSet = new Properties(); try { @@ -335,27 +336,32 @@ public class Terminal extends Plugin try { colorSet.load(new URL(tmp).openStream()); } catch(Exception ue) { - error("cannot find colorSet: "+tmp); - error("resource access failed: "+e); - error("URL access failed: "+ue); - colorSet = null; + error("cannot find colorSet: " + tmp); + error("resource access failed: " + e); + error("URL access failed: " + ue); + colorSet = null; } } if(colorSet != null) { Color set[] = terminal.getColorSet(); - for(int i = 0; i < 8; i++) - if((tmp = colorSet.getProperty("color"+i)) != null) - if(colors.get(tmp) != null) - set[i] = (Color)colors.get(tmp); - else try { - if(Color.getColor(tmp) != null) - set[i] = Color.getColor(tmp); - else - set[i] = Color.decode(tmp); - } catch(Exception e) { - error("ignoring unknown color code: "+tmp); - } + Color color = null; + for(int i = 0; i < 8; i++) { + if((tmp = colorSet.getProperty("color" + i)) != null && + (color = codeToColor(tmp)) != null) { + set[i] = color; + } + } + // special color for bold + if((tmp = colorSet.getProperty("bold")) != null && + (color = codeToColor(tmp)) != null) { + set[vt320.COLOR_BOLD] = color; + } + // special color for invert + if((tmp = colorSet.getProperty("invert")) != null && + (color = codeToColor(tmp)) != null) { + set[vt320.COLOR_INVERT] = color; + } terminal.setColorSet(set); } } @@ -363,18 +369,18 @@ public class Terminal extends Plugin String cFG = cfg.getProperty("Terminal", id, "cursor.foreground"); String cBG = cfg.getProperty("Terminal", id, "cursor.background"); if(cFG != null || cBG != null) - try { - Color fg = (cFG == null ? - terminal.getBackground() : - (Color.getColor(cFG) != null ? Color.getColor(cFG):Color.decode(cFG))); - Color bg = (cBG == null ? - terminal.getForeground() : - (Color.getColor(cBG) != null ? Color.getColor(cBG):Color.decode(cBG))); - terminal.setCursorColors(fg, bg); - } catch(Exception e) { - error("ignoring unknown cursor color code: "+tmp); - } - + try { + Color fg = (cFG == null ? + terminal.getBackground() : + (Color.getColor(cFG) != null ? Color.getColor(cFG):Color.decode(cFG))); + Color bg = (cBG == null ? + terminal.getForeground() : + (Color.getColor(cBG) != null ? Color.getColor(cBG):Color.decode(cBG))); + terminal.setCursorColors(fg, bg); + } catch(Exception e) { + error("ignoring unknown cursor color code: " + tmp); + } + if((tmp = cfg.getProperty("Terminal", id, "border")) != null) { String size = tmp; boolean raised = false; @@ -387,9 +393,9 @@ public class Terminal extends Plugin terminal.setLocalEcho(Boolean.valueOf(tmp).booleanValue()); localecho_overridden = true; } - - if((tmp = cfg.getProperty("Terminal", id, "scrollBar")) != null && - !personalJava) { + + if((tmp = cfg.getProperty("Terminal", id, "scrollBar")) != null && + !personalJava) { String direction = tmp; if(!direction.equals("none")) { if(!direction.equals("East") && !direction.equals("West")) @@ -406,28 +412,29 @@ public class Terminal extends Plugin if((tmp = cfg.getProperty("Terminal", id, "answerback")) != null) terminal.setAnswerBack(tmp); - if((tmp = cfg.getProperty("Terminal", id, "buffer")) != null) + if((tmp = cfg.getProperty("Terminal", id, "buffer")) != null) terminal.setBufferSize(Integer.parseInt(tmp)); - if((tmp = cfg.getProperty("Terminal", id, "size")) != null) try { - int idx = tmp.indexOf(','); - int width = Integer.parseInt(tmp.substring(1, idx).trim()); - int height = Integer.parseInt(tmp.substring(idx+1,tmp.length()-1).trim()); - terminal.setScreenSize(width, height); - } catch(Exception e) { - error("screen size is wrong: "+tmp); - error("error: "+e); - } + if((tmp = cfg.getProperty("Terminal", id, "size")) != null) + try { + int idx = tmp.indexOf(','); + int width = Integer.parseInt(tmp.substring(1, idx).trim()); + int height = Integer.parseInt(tmp.substring(idx + 1, tmp.length() - 1).trim()); + terminal.setScreenSize(width, height); + } catch(Exception e) { + error("screen size is wrong: " + tmp); + error("error: " + e); + } if((tmp = cfg.getProperty("Terminal", id, "resize")) != null) if(tmp.equals("font")) - terminal.setResizeStrategy(terminal.RESIZE_FONT); + terminal.setResizeStrategy(terminal.RESIZE_FONT); else if(tmp.equals("screen")) terminal.setResizeStrategy(terminal.RESIZE_SCREEN); - else + else terminal.setResizeStrategy(terminal.RESIZE_NONE); - - + + if((tmp = cfg.getProperty("Terminal", id, "font")) != null) { String font = tmp; int style = Font.PLAIN, fsize = 12; @@ -452,17 +459,17 @@ public class Terminal extends Plugin keyCodes.load(getClass().getResourceAsStream(tmp)); } catch(Exception e) { try { - keyCodes.load(new URL(tmp).openStream()); + keyCodes.load(new URL(tmp).openStream()); } catch(Exception ue) { - error("cannot find keyCodes: "+tmp); - error("resource access failed: "+e); - error("URL access failed: "+ue); - keyCodes = null; + error("cannot find keyCodes: " + tmp); + error("resource access failed: " + e); + error("URL access failed: " + ue); + keyCodes = null; } } // set the key codes if we got the properties - if(keyCodes != null) + if(keyCodes != null) terminal.setKeyCodes(keyCodes); } @@ -477,7 +484,7 @@ public class Terminal extends Plugin try { audioBeep = new SoundRequest(new URL(tmp)); } catch(MalformedURLException e) { - error("incorrect URL for audio ping: "+e); + error("incorrect URL for audio ping: " + e); } tPanel.setBackground(terminal.getBackground()); @@ -489,22 +496,23 @@ public class Terminal extends Plugin public void run() { byte[] t, b = new byte[256]; int n = 0; - while(n >= 0) try { - n = read(b); - if(debug > 0 && n > 0) - System.err.println("Terminal: \""+(new String(b, 0, n, encoding))+"\""); - if(n > 0) terminal.putString(new String(b, 0, n, encoding)); - tPanel.repaint(); - } catch(IOException e) { - reader = null; - break; - } + while(n >= 0) + try { + n = read(b); + if(debug > 0 && n > 0) + System.err.println("Terminal: \"" + (new String(b, 0, n, encoding)) + "\""); + if(n > 0) terminal.putString(new String(b, 0, n, encoding)); + tPanel.repaint(); + } catch(IOException e) { + reader = null; + break; + } } protected FilterPlugin source; public void setFilterSource(FilterPlugin source) { - if(debug > 0) System.err.println("Terminal: connected to: "+source); + if(debug > 0) System.err.println("Terminal: connected to: " + source); this.source = source; } @@ -539,14 +547,14 @@ public class Terminal extends Plugin /* InputStream is = (InputStream)t.getTransferData(DataFlavor.plainTextFlavor); - if(debug > 0) + if(debug > 0) System.out.println("Clipboard: available: "+is.available()); byte buffer[] = new byte[is.available()]; is.read(buffer); is.close(); */ - byte buffer[] = - ((String)t.getTransferData(DataFlavor.stringFlavor)).getBytes(); + byte buffer[] = + ((String) t.getTransferData(DataFlavor.stringFlavor)).getBytes(); try { write(buffer); } catch(IOException e) { blob - 5b0f4604bbe78075494943c8a2fcbcb034446c90 blob + 131f408a229d5bc1d48dd9d6e889efd505c816ed --- de/mud/terminal/VDU.java +++ de/mud/terminal/VDU.java @@ -6,11 +6,11 @@ * 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 + * "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, @@ -19,40 +19,16 @@ package de.mud.terminal; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Point; -import java.awt.Insets; -import java.awt.Event; -import java.awt.Label; -import java.awt.Frame; -import java.awt.Rectangle; -import java.awt.Scrollbar; -import java.awt.Image; - -/* -import java.awt.Graphics; -import java.awt.print.Printable; -import java.awt.print.PrinterJob; -import java.awt.print.PrinterException; -import java.awt.print.PageFormat; -*/ - -import java.awt.AWTEvent; -import java.awt.AWTEventMulticaster; -import java.awt.event.KeyListener; -import java.awt.event.KeyEvent; -import java.awt.event.AdjustmentListener; +import java.awt.*; import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; -import java.awt.event.MouseEvent; -import java.awt.event.FocusListener; -import java.awt.event.FocusEvent; /** * Video Display Unit emulation. This class implements all necessary @@ -70,7 +46,7 @@ import java.awt.event.FocusEvent; * @version $Id$ * @author Matthias L. Jugel, Marcus Meißner */ -public class VDU extends Component +public class VDU extends Component implements MouseListener, MouseMotionListener { /** The current version id tag */ public final static String ID = "$Id$"; @@ -79,12 +55,12 @@ public class VDU extends Component public final static int debug = 0; /** lightweight component definitions */ - private final static long VDU_EVENTS = AWTEvent.KEY_EVENT_MASK - | AWTEvent.FOCUS_EVENT_MASK - | AWTEvent.ACTION_EVENT_MASK - | AWTEvent.MOUSE_MOTION_EVENT_MASK - | AWTEvent.MOUSE_EVENT_MASK; - + private final static long VDU_EVENTS = AWTEvent.KEY_EVENT_MASK + | AWTEvent.FOCUS_EVENT_MASK + | AWTEvent.ACTION_EVENT_MASK + | AWTEvent.MOUSE_MOTION_EVENT_MASK + | AWTEvent.MOUSE_EVENT_MASK; + private Dimension size; /* rows and columns */ private Insets insets; /* size of the border */ private boolean raised; /* indicator if the border is raised */ @@ -111,11 +87,11 @@ public class VDU extends Component private String selection; /* contains the selected text */ private Scrollbar scrollBar; - private SoftFont sf = new SoftFont(); + private SoftFont sf = new SoftFont(); private boolean update[]; /* contains the lines that need update */ private boolean colorPrinting = false; /* print display in color */ - + private Image backingStore = null; /** @@ -125,35 +101,43 @@ public class VDU extends Component * @return the new brighter color */ - private double max(double f1,double f2) { return (f1 bottomMargin) /* We do not scroll below bottom margin (below the scrolling region). */ - return; - int top = (l < topMargin ? - 0 : (l > bottomMargin ? - (bottomMargin + 1 < size.height ? - bottomMargin + 1 : size.height - 1) : topMargin)); + if(l > bottomMargin) /* We do not scroll below bottom margin (below the scrolling region). */ + return; + int top = (l < topMargin ? + 0 : (l > bottomMargin ? + (bottomMargin + 1 < size.height ? + bottomMargin + 1 : size.height - 1) : topMargin)); int bottom = (l > bottomMargin ? - size.height - 1 : (l < topMargin ? - (topMargin > 0 ? - topMargin - 1 : 0) : bottomMargin)); + size.height - 1 : (l < topMargin ? + (topMargin > 0 ? + topMargin - 1 : 0) : bottomMargin)); // System.out.println("l is "+l+", top is "+top+", bottom is "+bottom+", bottomargin is "+bottomMargin+", topMargin is "+topMargin); - + if(scrollDown) { if(n > (bottom - top)) n = (bottom - top); cbuf = new char[bottom - l - (n - 1)][size.width]; abuf = new int[bottom - l - (n - 1)][size.width]; - + System.arraycopy(charArray, oldBase + l, cbuf, 0, bottom - l - (n - 1)); - System.arraycopy(charAttributes, oldBase + l, - abuf, 0, bottom - l - (n - 1)); - System.arraycopy(cbuf, 0, charArray, oldBase + l + n, - bottom - l - (n - 1)); - System.arraycopy(abuf, 0, charAttributes, oldBase + l + n, - bottom - l - (n - 1)); + System.arraycopy(charAttributes, oldBase + l, + abuf, 0, bottom - l - (n - 1)); + System.arraycopy(cbuf, 0, charArray, oldBase + l + n, + bottom - l - (n - 1)); + System.arraycopy(abuf, 0, charAttributes, oldBase + l + n, + bottom - l - (n - 1)); cbuf = charArray; abuf = charAttributes; - } else try { - if(n > (bottom - top) + 1) n = (bottom - top) + 1; - if(bufSize < maxBufSize) { - if(bufSize + n > maxBufSize) { - offset = n - (maxBufSize - bufSize); - bufSize = maxBufSize; - screenBase = maxBufSize - size.height - 1; - windowBase = screenBase; + } else + try { + if(n > (bottom - top) + 1) n = (bottom - top) + 1; + if(bufSize < maxBufSize) { + if(bufSize + n > maxBufSize) { + offset = n - (maxBufSize - bufSize); + bufSize = maxBufSize; + screenBase = maxBufSize - size.height - 1; + windowBase = screenBase; + } else { + screenBase += n; + windowBase += n; + bufSize += n; + } + cbuf = new char[bufSize][size.width]; + abuf = new int[bufSize][size.width]; } else { - screenBase += n; - windowBase += n; - bufSize += n; + offset = n; + cbuf = charArray; + abuf = charAttributes; } - cbuf = new char[bufSize][size.width]; - abuf = new int[bufSize][size.width]; - } else { - offset = n; - cbuf = charArray; - abuf = charAttributes; + // copy anything from the top of the buffer (+offset) to the new top + // up to the screenBase. + if(oldBase > 0) { + System.arraycopy(charArray, offset, + cbuf, 0, + oldBase - offset); + System.arraycopy(charAttributes, offset, + abuf, 0, + oldBase - offset); + } + // copy anything from the top of the screen (screenBase) up to the + // topMargin to the new screen + if(top > 0) { + System.arraycopy(charArray, oldBase, + cbuf, screenBase, + top); + System.arraycopy(charAttributes, oldBase, + abuf, screenBase, + top); + } + // copy anything from the topMargin up to the amount of lines inserted + // to the gap left over between scrollback buffer and screenBase + if(oldBase > 0) { + System.arraycopy(charArray, oldBase + top, + cbuf, oldBase - offset, + n); + System.arraycopy(charAttributes, oldBase + top, + abuf, oldBase - offset, + n); + } + // copy anything from topMargin + n up to the line linserted to the + // topMargin + System.arraycopy(charArray, oldBase + top + n, + cbuf, screenBase + top, + l - top - (n - 1)); + System.arraycopy(charAttributes, oldBase + top + n, + abuf, screenBase + top, + l - top - (n - 1)); + // + // copy the all lines next to the inserted to the new buffer + if(l < size.height - 1) { + System.arraycopy(charArray, oldBase + l + 1, + cbuf, screenBase + l + 1, + (size.height - 1) - l); + System.arraycopy(charAttributes, oldBase + l + 1, + abuf, screenBase + l + 1, + (size.height - 1) - l); + } + } catch(ArrayIndexOutOfBoundsException e) { + // this should not happen anymore, but I will leave the code + // here in case something happens anyway. That code above is + // so complex I always have a hard time understanding what + // I did, even though there are comments + System.err.println("*** Error while scrolling up:"); + System.err.println("--- BEGIN STACK TRACE ---"); + e.printStackTrace(); + System.err.println("--- END STACK TRACE ---"); + System.err.println("bufSize=" + bufSize + ", maxBufSize=" + maxBufSize); + System.err.println("top=" + top + ", bottom=" + bottom); + System.err.println("n=" + n + ", l=" + l); + System.err.println("screenBase=" + screenBase + ", windowBase=" + windowBase); + System.err.println("oldBase=" + oldBase); + System.err.println("size.width=" + size.width + ", size.height=" + size.height); + System.err.println("abuf.length=" + abuf.length + ", cbuf.length=" + cbuf.length); + System.err.println("*** done dumping debug information"); } - // copy anything from the top of the buffer (+offset) to the new top - // up to the screenBase. - if(oldBase > 0) { - System.arraycopy(charArray, offset, - cbuf, 0, - oldBase - offset); - System.arraycopy(charAttributes, offset, - abuf, 0, - oldBase - offset); - } - // copy anything from the top of the screen (screenBase) up to the - // topMargin to the new screen - if(top > 0) { - System.arraycopy(charArray, oldBase, - cbuf, screenBase, - top); - System.arraycopy(charAttributes, oldBase, - abuf, screenBase, - top); - } - // copy anything from the topMargin up to the amount of lines inserted - // to the gap left over between scrollback buffer and screenBase - if(oldBase > 0) { - System.arraycopy(charArray, oldBase + top, - cbuf, oldBase - offset, - n); - System.arraycopy(charAttributes, oldBase + top, - abuf, oldBase - offset, - n); - } - // copy anything from topMargin + n up to the line linserted to the - // topMargin - System.arraycopy(charArray, oldBase + top + n, - cbuf, screenBase + top, - l - top - (n - 1)); - System.arraycopy(charAttributes, oldBase + top + n, - abuf, screenBase + top, - l - top - (n - 1)); - // - // copy the all lines next to the inserted to the new buffer - if(l < size.height - 1) { - System.arraycopy(charArray, oldBase + l + 1, - cbuf, screenBase + l + 1, - (size.height - 1) - l); - System.arraycopy(charAttributes, oldBase + l + 1, - abuf, screenBase + l + 1, - (size.height - 1) - l); - } - } catch(ArrayIndexOutOfBoundsException e) { - // this should not happen anymore, but I will leave the code - // here in case something happens anyway. That code above is - // so complex I always have a hard time understanding what - // I did, even though there are comments - System.err.println("*** Error while scrolling up:"); - System.err.println("--- BEGIN STACK TRACE ---"); - e.printStackTrace(); - System.err.println("--- END STACK TRACE ---"); - System.err.println("bufSize="+bufSize+", maxBufSize="+maxBufSize); - System.err.println("top="+top+", bottom="+bottom); - System.err.println("n="+n+", l="+l); - System.err.println("screenBase="+screenBase+", windowBase="+windowBase); - System.err.println("oldBase="+oldBase); - System.err.println("size.width="+size.width+", size.height="+size.height); - System.err.println("abuf.length="+abuf.length+", cbuf.length="+cbuf.length); - System.err.println("*** done dumping debug information"); - } - + for(int i = 0; i < n; i++) { - cbuf[(screenBase + l) + (scrollDown ? i : -i) ] = new char[size.width]; - abuf[(screenBase + l) + (scrollDown ? i : -i) ] = new int[size.width]; + cbuf[(screenBase + l) + (scrollDown ? i : -i)] = new char[size.width]; + abuf[(screenBase + l) + (scrollDown ? i : -i)] = new int[size.width]; } charArray = cbuf; charAttributes = abuf; - + if(scrollDown) markLine(l, bottom - l + 1); else @@ -608,10 +595,10 @@ public class VDU extends Component if(scrollBar != null) scrollBar.setValues(windowBase, size.height, 0, bufSize); } - + /** - * Delete a line at a specific position. Subsequent lines will be scrolled - * up to fill the space and a blank line is inserted at the end of the + * Delete a line at a specific position. Subsequent lines will be scrolled + * up to fill the space and a blank line is inserted at the end of the * screen. * @param l the y-coordinate to insert the line * @see #deleteLine @@ -619,12 +606,12 @@ public class VDU extends Component public void deleteLine(int l) { l = checkBounds(l, 0, size.height - 1); - int bottom = (l>bottomMargin?size.height-1: - (l bottomMargin?size.height - 1: + (l < topMargin?topMargin:bottomMargin + 1)); System.arraycopy(charArray, screenBase + l + 1, - charArray, screenBase + l, bottom - l -1 ); + charArray, screenBase + l, bottom - l - 1); System.arraycopy(charAttributes, screenBase + l + 1, - charAttributes, screenBase + l, bottom - l -1); + charAttributes, screenBase + l, bottom - l - 1); charArray[screenBase + bottom - 1] = new char[size.width]; charAttributes[screenBase + bottom - 1] = new int[size.width]; markLine(l, bottom - l); @@ -650,9 +637,8 @@ public class VDU extends Component char cbuf[] = new char[w]; int abuf[] = new int[w]; - for(int i = 0; i < w ; i++) abuf[i] = curAttr; - for(int i = 0; i < h && l + i < size.height; i++) - { + for(int i = 0; i < w; i++) abuf[i] = curAttr; + for(int i = 0; i < h && l + i < size.height; i++) { System.arraycopy(cbuf, 0, charArray[screenBase + l + i], c, w); System.arraycopy(abuf, 0, charAttributes[screenBase + l + i], c, w); } @@ -677,8 +663,7 @@ public class VDU extends Component char cbuf[] = new char[w]; int abuf[] = new int[w]; - for(int i = 0; i < h && l + i < size.height; i++) - { + for(int i = 0; i < h && l + i < size.height; i++) { System.arraycopy(cbuf, 0, charArray[screenBase + l + i], c, w); System.arraycopy(abuf, 0, charAttributes[screenBase + l + i], c, w); } @@ -701,8 +686,8 @@ public class VDU extends Component } public void showCursor(boolean doshow) { - if (doshow != showcursor) - markLine(cursorY,1); + if(doshow != showcursor) + markLine(cursorY, 1); showcursor = doshow; } @@ -724,8 +709,7 @@ public class VDU extends Component if(l > bottomMargin) { topMargin = bottomMargin; bottomMargin = l; - } - else + } else topMargin = l; if(topMargin < 0) topMargin = 0; if(bottomMargin > size.height - 1) bottomMargin = size.height - 1; @@ -748,8 +732,7 @@ public class VDU extends Component if(l < topMargin) { bottomMargin = topMargin; topMargin = l; - } - else + } else bottomMargin = l; if(topMargin < 0) topMargin = 0; if(bottomMargin > size.height - 1) bottomMargin = size.height - 1; @@ -761,7 +744,7 @@ public class VDU extends Component public int getBottomMargin() { return bottomMargin; } - + /** * Set scrollback buffer size. * @param amount new size of the buffer @@ -784,7 +767,7 @@ public class VDU extends Component windowBase = screenBase; } maxBufSize = amount; - + update[0] = true; redraw(); } @@ -812,7 +795,8 @@ public class VDU extends Component * @see getBufferSize */ public void setWindowBase(int line) { - if(line > screenBase) line = screenBase; + if(line > screenBase) + line = screenBase; else if(line < 0) line = 0; windowBase = line; update[0] = true; @@ -842,9 +826,9 @@ public class VDU extends Component if(update != null) update[0] = true; redraw(); } - + /** - * Change the size of the screen. This will include adjustment of the + * Change the size of the screen. This will include adjustment of the * scrollback buffer. * @param columns width of the screen * @param columns height of the screen @@ -855,11 +839,11 @@ public class VDU extends Component int bsize = bufSize; if(width < 1 || height < 1) return; - + if(debug > 0) - System.err.println("VDU: screen size ["+width+","+height+"]"); + System.err.println("VDU: screen size [" + width + "," + height + "]"); - if(height > maxBufSize) + if(height > maxBufSize) maxBufSize = height; if(height > bufSize) { @@ -868,22 +852,22 @@ public class VDU extends Component windowBase = 0; } - if(windowBase+height >= bufSize) - windowBase = bufSize-height; + if(windowBase + height >= bufSize) + windowBase = bufSize - height; - if(screenBase+height >= bufSize) - screenBase = bufSize-height; + if(screenBase + height >= bufSize) + screenBase = bufSize - height; cbuf = new char[bufSize][width]; abuf = new int[bufSize][width]; - + if(charArray != null && charAttributes != null) for(int i = 0; i < bsize && i < bufSize; i++) { - System.arraycopy(charArray[i], 0, cbuf[i], 0, - width < size.width ? width : size.width); - System.arraycopy(charAttributes[i], 0, abuf[i], 0, - width < size.width ? width : size.width); + System.arraycopy(charArray[i], 0, cbuf[i], 0, + width < size.width ? width : size.width); + System.arraycopy(charAttributes[i], 0, abuf[i], 0, + width < size.width ? width : size.width); } charArray = cbuf; charAttributes = abuf; @@ -914,16 +898,20 @@ public class VDU extends Component public void setResizeStrategy(int strategy) { resizeStrategy = strategy; } - + /** * Get amount of rows on the screen. */ - public int getRows() { return size.height; } + public int getRows() { + return size.height; + } /** * Get amount of columns on the screen. */ - public int getColumns() { return size.width; } + public int getColumns() { + return size.width; + } /** * Set the border thickness and the border type. @@ -931,9 +919,11 @@ public class VDU extends Component * @param raised a boolean indicating a raised or embossed border */ public void setBorder(int thickness, boolean raised) { - if(thickness == 0) insets = null; - else insets = new Insets(thickness+1, thickness+1, - thickness+1, thickness+1); + if(thickness == 0) + insets = null; + else + insets = new Insets(thickness + 1, thickness + 1, + thickness + 1, thickness + 1); this.raised = raised; } @@ -964,7 +954,7 @@ public class VDU extends Component for(int i = 0; (i < n) && (l + i < size.height); i++) update[l + i + 1] = true; } - + /** * Redraw marked lines. * @see #markLine @@ -990,29 +980,29 @@ public class VDU extends Component g.setFont(normalFont); - - /* for debug only - if (update[0]) { - System.err.println("Redrawing all"); - } else { - for (int l = 1; l < size.height+1; l++) { - if (update[l]) { - for (int c = 0; c < size.height-l;c++) { - if (!update[c+l]) { - System.err.println("Redrawing "+(l-1)+" - "+(l+c-2)); - l=l+c; - break; - } - } - } - } - } - */ + /* for debug only + if (update[0]) { + System.err.println("Redrawing all"); + } else { + for (int l = 1; l < size.height+1; l++) { + if (update[l]) { + for (int c = 0; c < size.height-l;c++) { + if (!update[c+l]) { + System.err.println("Redrawing "+(l-1)+" - "+(l+c-2)); + l=l+c; + break; + } + } + } + } + } + */ + for(int l = 0; l < size.height; l++) { if(!update[0] && !update[l + 1]) continue; update[l + 1] = false; - if(debug > 2) System.err.println("redraw(): line "+l); + if(debug > 2) System.err.println("redraw(): line " + l); for(int c = 0; c < size.width; c++) { int addr = 0; int currAttr = charAttributes[windowBase + l][c]; @@ -1021,90 +1011,114 @@ public class VDU extends Component bg = darken(getBackground()); if((currAttr & COLOR_FG) != 0) - fg = darken(color[((currAttr & COLOR_FG) >> 4)-1]); + fg = darken(color[((currAttr & COLOR_FG) >> 4) - 1]); if((currAttr & COLOR_BG) != 0) - bg = darken(darken(color[((currAttr & COLOR_BG) >> 8)-1])); + bg = darken(darken(color[((currAttr & COLOR_BG) >> 8) - 1])); - if((currAttr & BOLD) != 0) + if((currAttr & BOLD) != 0) { + g.setFont(normalFont.deriveFont(Font.BOLD)); + if(null != color[COLOR_BOLD]) { + fg = color[COLOR_BOLD]; + } + /* if(fg.equals(Color.black)) { fg = Color.gray; } else { - fg = brighten(fg); - // bg = bg.brighter(); -- make some programs ugly - } + fg = brighten(fg); + // bg = bg.brighter(); -- make some programs ugly + } + */ + } else { + g.setFont(normalFont); + } - if((currAttr & LOW) != 0) { fg = darken(fg); } - if((currAttr & INVERT) != 0) { Color swapc = bg; bg=fg;fg=swapc; } + if((currAttr & LOW) != 0) { + fg = darken(fg); + } + if((currAttr & INVERT) != 0) { + if(null == color[COLOR_INVERT]) { + Color swapc = bg; + bg = fg; + fg = swapc; + } else { + if(null == color[COLOR_BOLD]) { + fg = bg; + } else { + fg = color[COLOR_BOLD]; + } + bg = color[COLOR_INVERT]; + } + } - if (sf.inSoftFont(charArray[windowBase + l][c])) { - g.setColor(bg); - g.fillRect(c * charWidth + xoffset, l * charHeight + yoffset, + if(sf.inSoftFont(charArray[windowBase + l][c])) { + g.setColor(bg); + g.fillRect(c * charWidth + xoffset, l * charHeight + yoffset, charWidth, charHeight); - g.setColor(fg); - sf.drawChar(g,charArray[windowBase + l][c],xoffset+c*charWidth, - l*charHeight+yoffset, charWidth, charHeight); + g.setColor(fg); + sf.drawChar(g, charArray[windowBase + l][c], xoffset + c * charWidth, + l * charHeight + yoffset, charWidth, charHeight); if((currAttr & UNDERLINE) != 0) g.drawLine(c * charWidth + xoffset, - (l+1) * charHeight - charDescent / 2 + yoffset, - c * charWidth + charWidth + xoffset, - (l+1) * charHeight - charDescent / 2 + yoffset); + (l + 1) * charHeight - charDescent / 2 + yoffset, + c * charWidth + charWidth + xoffset, + (l + 1) * charHeight - charDescent / 2 + yoffset); continue; } - + // determine the maximum of characters we can print in one go - while((c + addr < size.width) && - ( (charArray[windowBase + l][c + addr] < ' ') || - (charAttributes[windowBase + l][c + addr] == currAttr) - ) && - !sf.inSoftFont(charArray[windowBase + l ][c+addr]) - ) { + while((c + addr < size.width) && + ((charArray[windowBase + l][c + addr] < ' ') || + (charAttributes[windowBase + l][c + addr] == currAttr) + ) && + !sf.inSoftFont(charArray[windowBase + l][c + addr]) + ) { if(charArray[windowBase + l][c + addr] < ' ') { charArray[windowBase + l][c + addr] = ' '; - charAttributes[windowBase + l][c + addr] = 0; - continue; - } + charAttributes[windowBase + l][c + addr] = 0; + continue; + } addr++; } - + // clear the part of the screen we want to change (fill rectangle) g.setColor(bg); g.fillRect(c * charWidth + xoffset, l * charHeight + yoffset, addr * charWidth, charHeight); g.setColor(fg); - + // draw the characters - g.drawChars(charArray[windowBase + l], c, addr, - c * charWidth + xoffset, - (l+1) * charHeight - charDescent + yoffset); + g.drawChars(charArray[windowBase + l], c, addr, + c * charWidth + xoffset, + (l + 1) * charHeight - charDescent + yoffset); if((currAttr & UNDERLINE) != 0) g.drawLine(c * charWidth + xoffset, - (l+1) * charHeight - charDescent / 2 + yoffset, - c * charWidth + addr * charWidth + xoffset, - (l+1) * charHeight - charDescent / 2 + yoffset); - + (l + 1) * charHeight - charDescent / 2 + yoffset, + c * charWidth + addr * charWidth + xoffset, + (l + 1) * charHeight - charDescent / 2 + yoffset); + c += addr - 1; } // selection code, highlites line or part of it when it was // selected previously if(l >= selectStartLine && l <= selectEndLine) { - int selectStartColumn = (l == selectStartLine ? selectBegin.x : 0); - int selectEndColumn = - (l == selectEndLine ? - (l == selectStartLine ? selectEnd.x - selectStartColumn : - selectEnd.x) : size.width); - if(selectStartColumn != selectEndColumn) { - if(debug > 0) - System.err.println("select("+selectStartColumn+"-" - +selectEndColumn+")"); + int selectStartColumn = (l == selectStartLine ? selectBegin.x : 0); + int selectEndColumn = + (l == selectEndLine ? + (l == selectStartLine ? selectEnd.x - selectStartColumn : + selectEnd.x) : size.width); + if(selectStartColumn != selectEndColumn) { + if(debug > 0) + System.err.println("select(" + selectStartColumn + "-" + + selectEndColumn + ")"); g.setXORMode(bg); - g.fillRect(selectStartColumn * charWidth + xoffset, - l * charHeight + yoffset, - selectEndColumn * charWidth, - charHeight); - g.setPaintMode(); + g.fillRect(selectStartColumn * charWidth + xoffset, + l * charHeight + yoffset, + selectEndColumn * charWidth, + charHeight); + g.setPaintMode(); } } @@ -1112,12 +1126,12 @@ public class VDU extends Component // draw cursor if(showcursor && ( - screenBase + cursorY >= windowBase && - screenBase + cursorY < windowBase + size.height) + screenBase + cursorY >= windowBase && + screenBase + cursorY < windowBase + size.height) ) { g.setColor(cursorColorFG); g.setXORMode(cursorColorBG); - g.fillRect( cursorX * charWidth + xoffset, + g.fillRect(cursorX * charWidth + xoffset, (cursorY + screenBase - windowBase) * charHeight + yoffset, charWidth, charHeight); g.setPaintMode(); @@ -1127,10 +1141,11 @@ public class VDU extends Component // draw border if(insets != null) { g.setColor(getBackground()); - xoffset--; yoffset--; + xoffset--; + yoffset--; for(int i = insets.top - 1; i >= 0; i--) g.draw3DRect(xoffset - i, yoffset - i, - charWidth * size.width + 1 + i * 2, + charWidth * size.width + 1 + i * 2, charHeight * size.height + 1 + i * 2, raised); } @@ -1159,7 +1174,7 @@ public class VDU extends Component } if(debug > 1) - System.err.println("Clip region: "+g.getClipBounds()); + System.err.println("Clip region: " + g.getClipBounds()); g.drawImage(backingStore, 0, 0, this); } @@ -1176,7 +1191,7 @@ public class VDU extends Component /** * Set default for printing black&white or colorized as displayed on - * screen. + * screen. * @param name colorPrint true = print in full color, default b&w only */ public void setColorPrinting(boolean colorPrint) { @@ -1193,15 +1208,17 @@ public class VDU extends Component setForeground(Color.black); setBackground(Color.white); colorSave = color; - color = new Color[] { Color.black, - Color.black, - Color.black, - Color.black, - Color.black, - Color.black, - Color.black, - Color.white - }; + color = new Color[]{Color.black, + Color.black, + Color.black, + Color.black, + Color.black, + Color.black, + Color.black, + Color.white, + null, + null, + }; } redraw(g); @@ -1224,11 +1241,10 @@ public class VDU extends Component * @param the mouse point to be converted * @return Character cell coordinate of passed point */ - public Point mouseGetPos(Point evtpt) - { + public Point mouseGetPos(Point evtpt) { Point mousepos; - mousepos = new Point(0,0); + mousepos = new Point(0, 0); int xoffset = (super.getSize().width - size.width * charWidth) / 2; int yoffset = (super.getSize().height - size.height * charHeight) / 2; @@ -1249,34 +1265,37 @@ public class VDU extends Component * @param fg foreground color or null * @param bg background color or null */ - public void setCursorColors(Color fg, Color bg) - { - if (fg == null) cursorColorFG = color[COLOR_FG_STD]; - else cursorColorFG = fg; - if (bg == null) cursorColorBG = color[COLOR_BG_STD]; - else cursorColorBG = bg; + public void setCursorColors(Color fg, Color bg) { + if(fg == null) + cursorColorFG = color[COLOR_FG_STD]; + else + cursorColorFG = fg; + if(bg == null) + cursorColorBG = color[COLOR_BG_STD]; + else + cursorColorBG = bg; repaint(); } - + /** * Reshape character display according to resize strategy. * @see #setResizeStrategy */ public void setBounds(int x, int y, int w, int h) { if(debug > 0) - System.err.println("VDU: setBounds("+x+","+y+","+w+","+h+")"); + System.err.println("VDU: setBounds(" + x + "," + y + "," + w + "," + h + ")"); super.setBounds(x, y, w, h); int xborder = 0, yborder = 0; - + if(insets != null) { w -= (xborder = insets.left + insets.right); h -= (yborder = insets.top + insets.bottom); } if(debug > 0) - System.err.println("VDU: looking for better match for "+normalFont); + System.err.println("VDU: looking for better match for " + normalFont); Font tmpFont = normalFont; String fontName = tmpFont.getName(); @@ -1286,55 +1305,55 @@ public class VDU extends Component charWidth = fm.charWidth('@'); charHeight = fm.getHeight(); } - + switch(resizeStrategy) { - case RESIZE_SCREEN: - setScreenSize(w / charWidth, size.height = h / charHeight); - break; - case RESIZE_FONT: - int height = h / size.height; - int width = w / size.width; - - fm = getFontMetrics(normalFont = new Font(fontName, fontStyle, - charHeight)); - - // adapt current font size (from small up to best fit) - if(fm.getHeight() < height || fm.charWidth('@') < width) - do { - fm = getFontMetrics(normalFont = new Font(fontName, fontStyle, - ++charHeight)); - } while(fm.getHeight() < height || fm.charWidth('@') < width); - - // now check if we got a font that is too large - if(fm.getHeight() > height || fm.charWidth('@') > width) - do { - fm = getFontMetrics(normalFont = new Font(fontName, fontStyle, - --charHeight)); - } while(charHeight > 1 && - (fm.getHeight() > height || - fm.charWidth('@') > width)); - - if(charHeight <= 1) { - System.err.println("VDU: error during resize, resetting"); - normalFont = tmpFont; - System.err.println("VDU: disabling font/screen resize"); - resizeStrategy = RESIZE_NONE; - } + case RESIZE_SCREEN: + setScreenSize(w / charWidth, size.height = h / charHeight); + break; + case RESIZE_FONT: + int height = h / size.height; + int width = w / size.width; - setFont(normalFont); - fm = getFontMetrics(normalFont); - charWidth = fm.charWidth('@'); - charHeight = fm.getHeight(); - charDescent = fm.getDescent(); - break; - case RESIZE_NONE: - default: - break; + fm = getFontMetrics(normalFont = new Font(fontName, fontStyle, + charHeight)); + + // adapt current font size (from small up to best fit) + if(fm.getHeight() < height || fm.charWidth('@') < width) + do { + fm = getFontMetrics(normalFont = new Font(fontName, fontStyle, + ++charHeight)); + } while(fm.getHeight() < height || fm.charWidth('@') < width); + + // now check if we got a font that is too large + if(fm.getHeight() > height || fm.charWidth('@') > width) + do { + fm = getFontMetrics(normalFont = new Font(fontName, fontStyle, + --charHeight)); + } while(charHeight > 1 && + (fm.getHeight() > height || + fm.charWidth('@') > width)); + + if(charHeight <= 1) { + System.err.println("VDU: error during resize, resetting"); + normalFont = tmpFont; + System.err.println("VDU: disabling font/screen resize"); + resizeStrategy = RESIZE_NONE; + } + + setFont(normalFont); + fm = getFontMetrics(normalFont); + charWidth = fm.charWidth('@'); + charHeight = fm.getHeight(); + charDescent = fm.getDescent(); + break; + case RESIZE_NONE: + default: + break; } if(debug > 0) { - System.err.println("VDU: charWidth="+charWidth+", "+ - "charHeight="+charHeight+", "+ - "charDescent="+charDescent); + System.err.println("VDU: charWidth=" + charWidth + ", " + + "charHeight=" + charHeight + ", " + + "charDescent=" + charDescent); } // delete the double buffer image and mark all lines @@ -1353,7 +1372,7 @@ public class VDU extends Component xborder = insets.left + insets.right; yborder = insets.top + insets.bottom; } - return new Dimension(size.width * charWidth + xborder, + return new Dimension(size.width * charWidth + xborder, size.height * charHeight + yborder); } @@ -1376,8 +1395,8 @@ public class VDU extends Component } public void clearSelection() { - selectBegin = new Point(0,0); - selectEnd = new Point(0,0); + selectBegin = new Point(0, 0); + selectEnd = new Point(0, 0); selection = null; } @@ -1395,8 +1414,8 @@ public class VDU extends Component public void mouseDragged(MouseEvent evt) { if(buttonCheck(evt.getModifiers(), MouseEvent.BUTTON1_MASK) || - // Windows NT/95 etc: returns 0, which is a bug - evt.getModifiers() == 0) { + // Windows NT/95 etc: returns 0, which is a bug + evt.getModifiers() == 0) { int xoffset = (super.getSize().width - size.width * charWidth) / 2; int yoffset = (super.getSize().height - size.height * charHeight) / 2; int x = (evt.getX() - xoffset) / charWidth; @@ -1410,12 +1429,12 @@ public class VDU extends Component selectEnd.x = x; selectEnd.y = y; } - + if(oldx != x || oldy != y) { - update[0] = true; - if(debug > 0) - System.err.println("select(["+selectBegin.x+","+selectBegin.y+"],"+ - "["+selectEnd.x+","+selectEnd.y+"])"); + update[0] = true; + if(debug > 0) + System.err.println("select([" + selectBegin.x + "," + selectBegin.y + "]," + + "[" + selectEnd.x + "," + selectEnd.y + "])"); redraw(); } } @@ -1462,10 +1481,10 @@ public class VDU extends Component int xoffset = (super.getSize().width - size.width * charWidth) / 2; int yoffset = (super.getSize().height - size.height * charHeight) / 2; mouseDragged(evt); - + if(selectBegin.x == selectEnd.x && - selectBegin.y == selectEnd.y) { - update[0] = true; + selectBegin.y == selectEnd.y) { + update[0] = true; redraw(); return; } @@ -1474,21 +1493,21 @@ public class VDU extends Component if(selectEnd.x < 0) selectEnd.x = 0; if(selectEnd.y < 0) selectEnd.y = 0; if(selectEnd.y >= charArray.length) - selectEnd.y = charArray.length-1; + selectEnd.y = charArray.length - 1; if(selectEnd.x > charArray[0].length) selectEnd.x = charArray[0].length; for(int l = selectBegin.y; l <= selectEnd.y; l++) { int start, end; - start = (l == selectBegin.y ? start = selectBegin.x : 0); - end = (l == selectEnd.y ? end = selectEnd.x : charArray[l].length ); - // Trim all spaces from end of line, like xterm does. - selection += ("-" + (new String(charArray[l])).substring(start,end)).trim().substring(1); - if(end == charArray[l].length) - selection += "\n"; + start = (l == selectBegin.y ? start = selectBegin.x : 0); + end = (l == selectEnd.y ? end = selectEnd.x : charArray[l].length); + // Trim all spaces from end of line, like xterm does. + selection += ("-" + (new String(charArray[l])).substring(start, end)).trim().substring(1); + if(end == charArray[l].length) + selection += "\n"; } } - } + } // lightweight component event handling @@ -1514,14 +1533,14 @@ public class VDU extends Component } private MouseMotionListener mouseMotionListener; - + /** * Add a mouse motion listener to the VDU. This is the implementation for * the lightweight event handling. * @param listener the mouse motion listener */ public void addMouseMotionListener(MouseMotionListener listener) { - mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener,listener); + mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener, listener); enableEvents(AWTEvent.MOUSE_EVENT_MASK); } @@ -1531,12 +1550,12 @@ public class VDU extends Component * @param listener the mouse motion listener to remove */ public void removeMouseMotionListener(MouseMotionListener listener) { - mouseMotionListener = + mouseMotionListener = AWTEventMulticaster.remove(mouseMotionListener, listener); } /** - * Process mouse events for this component. It will call the + * Process mouse events for this component. It will call the * methods (mouseClicked() etc) in the added mouse listeners. * @param evt the dispatched mouse event */ @@ -1545,36 +1564,43 @@ public class VDU extends Component if(mouseListener != null) switch(evt.getID()) { case MouseEvent.MOUSE_CLICKED: - mouseListener.mouseClicked(evt); break; + mouseListener.mouseClicked(evt); + break; case MouseEvent.MOUSE_ENTERED: - mouseListener.mouseEntered(evt); break; + mouseListener.mouseEntered(evt); + break; case MouseEvent.MOUSE_EXITED: - mouseListener.mouseExited(evt); break; + mouseListener.mouseExited(evt); + break; case MouseEvent.MOUSE_PRESSED: - mouseListener.mousePressed(evt); break; + mouseListener.mousePressed(evt); + break; case MouseEvent.MOUSE_RELEASED: - mouseListener.mouseReleased(evt); break; + mouseListener.mouseReleased(evt); + break; } - super.processMouseEvent(evt); - } + super.processMouseEvent(evt); + } /** - * Process mouse motion events for this component. It will call the + * Process mouse motion events for this component. It will call the * methods (mouseDragged() etc) in the added mouse motion listeners. * @param evt the dispatched mouse event */ - public void processMouseMotionEvent(MouseEvent evt) { + public void processMouseMotionEvent(MouseEvent evt) { // handle mouse motion events if(mouseMotionListener != null) switch(evt.getID()) { case MouseEvent.MOUSE_DRAGGED: - mouseMotionListener.mouseDragged(evt); break; + mouseMotionListener.mouseDragged(evt); + break; case MouseEvent.MOUSE_MOVED: - mouseMotionListener.mouseMoved(evt); break; + mouseMotionListener.mouseMoved(evt); + break; } super.processMouseMotionEvent(evt); } - + private KeyListener keyListener; /** @@ -1602,14 +1628,17 @@ public class VDU extends Component * @param evt the dispatched key event */ public void processKeyEvent(KeyEvent evt) { - if(keyListener != null) + if(keyListener != null) switch(evt.getID()) { case KeyEvent.KEY_PRESSED: - keyListener.keyPressed(evt); break; + keyListener.keyPressed(evt); + break; case KeyEvent.KEY_RELEASED: - keyListener.keyReleased(evt); break; + keyListener.keyReleased(evt); + break; case KeyEvent.KEY_TYPED: - keyListener.keyTyped(evt); break; + keyListener.keyTyped(evt); + break; } // consume TAB keys if they originate from our component if(evt.getKeyCode() == KeyEvent.VK_TAB && evt.getSource() == this) @@ -1631,9 +1660,11 @@ public class VDU extends Component if(focusListener != null) switch(evt.getID()) { case FocusEvent.FOCUS_GAINED: - focusListener.focusGained(evt); break; - case FocusEvent.FOCUS_LOST: - focusListener.focusLost(evt); break; + focusListener.focusGained(evt); + break; + case FocusEvent.FOCUS_LOST: + focusListener.focusLost(evt); + break; } super.processFocusEvent(evt); } blob - 5e59df002d1b446409ec595fc4954298134feb12 blob + 6bd89130c41a34209b511e14f35bd718a1ef2bb6 --- doc/plugins/Terminal.html +++ doc/plugins/Terminal.html @@ -1,621 +1,566 @@ - + - - - - - - The Java Telnet Application/Applet v2.0: Script Plugin + + + + + + + + + + + The Java Telnet Application/Applet v2.0: Script Plugin - -  -
- -
- - - - - - - - - - -
-
-

-The Javatm -Telnet Application/Applet: Terminal Plugin

-© 1996-2000 Matthias L. Jugel and -Marcus -Meißner -

Version 2.0 / Java 2 and 1.1.x -
Available under GNU General Public -License

HomepageApplet + +   +
+ + + + + + +
+ + + + + + + + - - - - - - + + - + + + +
+
+

The Java +tm Telnet Application/Applet: Terminal Plugin

+
+ © 1996-2000 Matthias L. Jugel and + Marcus Meißner +

Version 2.0 / Java 2 and 1.1.x
+Available under GNU General Public License

+
+HomepageApplet TestDownloadDocumentationUsers + +DownloadDocumentationUsers / Opinions
+
-
- - - - + + + +
-
-

-Terminal (ANSI/vt320) Plugin

-The terminal plugin is a visual software component that acts as the front -end. It displays the data that is transmitted by the remote host and translates -keystrokes to be sent to the remote host. It implements an ANSI, -vt320/vt220/vt100 -and SCOANSI compliant terminal. -

Most of the features of the terminal emulation can be configured using -the properties explained below. Additionally it provides a plugin menu -that can be operated if a menu bar is available. -

You can configure the plugin using the following properties: -
  -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + +
PropertyDocumentation
-
General Properties
-
Terminal.foregroundSet the foreground color of the terminal. You can use 24 but hexadecimal -values: -
#ffffff is white and #000000 is black. -This is just like the encoding you use in HTML.
Terminal.backgroundSet the background color of the terminal. You can use 24 but hexadecimal -values: -
#ffffff is white and #000000 is black. -This is just like the encoding you use in HTML.
Terminal.cursor.foregroundSet the cursor foreground color. If unset -this is the inverted current foreground.
Terminal.cursor.backgroundSet the cursor background color. If unset this is the inverted current + + + + + + - - + - -
+
+

Terminal (ANSI/vt320) Plugin

+
+ The terminal plugin is a visual software component that acts as the front +end. It displays the data that is transmitted by the remote host and translates +keystrokes to be sent to the remote host. It implements an ANSI, +vt320/vt220/vt100 and SCOANSI compliant terminal. +

Most of the features of the terminal emulation can be configured +using the properties explained below. Additionally it provides a plugin menu +that can be operated if a menu bar is available.

+

You can configure the plugin using the following properties:

+
+ + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - - + + + + + + + - - - - - - + + + - - - - - - - -
PropertyDocumentation
+
+General Properties
+
Terminal.foregroundSet the foreground color of the terminal. You can use 24 but hexadecimal +values:
+ #ffffff is white and #000000 +is black. This is just like the encoding you use in HTML.
Terminal.backgroundSet the background color of the terminal. You can use 24 but hexadecimal +values:
+ #ffffff is white and #000000 +is black. This is just like the encoding you use in HTML.
Terminal.cursor.foregroundSet the cursor foreground color. +If unset this is the inverted current foreground.
Terminal.cursor.backgroundSet the cursor background color. If unset this is the inverted current background.
Terminal.localechoWhile both SSH and Telnet client part detect localechostate automatically, -it can be overridden using this option. This is only recommended if you -really need it. -
Set to true for always localecho and false for never.
 Terminal.print.colorSet to true to print the terminal in full color. The -default setting false will force the Terminal to print -black & white only.
Terminal.colorSetUse this property to define a complete color set for the terminal. -A color set contains eight colors as defined by the ANSI standard. -

The colorset should be in a file that is referenced by this property -as either a file name relative to the jar file or a complete URL. -

The default value is /de/mud/terminal/colorSet.conf. -

The file contains a line for each color: -

color0 = color -
color1 = color -
... -
color7 = color -

color can be either a name or a number similar to the foreground -and background above.

Terminal.borderDeclare the size of the border that will sourround the terminal.
Terminal.borderRaisedThis property has no effect if Terminal.border is not set -or zero. It may be set to "true" or "false".
Terminal.scrollBarAdds a scroll bar to the terminal using the direction set in the property. -Possible directions are "East" and "West". +
Terminal.localechoWhile both SSH and Telnet client part detect localechostate automatically, +it can be overridden using this option. This is only recommended if you really +need it.
+Set to true for always localecho and false for never.
 Terminal.print.colorSet to true to print the terminal in full color. The +default setting false will force the Terminal to print black +& white only.
Terminal.colorSetUse this property to define a complete color set for the terminal. A +color set contains eight colors as defined by the ANSI standard. +

The colorset should be in a file that is referenced by this +property as either a file name relative to the jar file or a complete URL. +

+

The default value is /de/mud/terminal/colorSet.conf +.

+

The file contains a line for each color:

+

color0 = color
+ color1 = color
+ ...
+ color7 = color
+bold = color
+invert = color
+

+

color can be either a name or a number similar to +the foreground and background above. The keywords bold and invert will set +a color instead of the actual attribute for display. Bold text will be displayed +using the color and inverted text will show up with a background color that +is set.

+
Terminal.borderDeclare the size of the border that will sourround the terminal.
Terminal.borderRaisedThis property has no effect if Terminal.border is not set or +zero. It may be set to "true" or "false".
Terminal.scrollBarAdds a scroll bar to the terminal using the direction set in the property. +Possible directions are "East" and "West". Using a "none" removes the scrollbar completely.
Terminal.beepIf this property points to a fully qualified -URL of a sound file this will be played in case of a terminal bell -signal. This works for applets only. -
Note: Some browsers (Netscape 4, IE 5.5 or earlier) sometimes can only -play .au files here. In IE the sound needs to be on the same server as -the applet or you get a security exception.
-
Terminal -Emulation Properties
-
Terminal.idUsed to identify the type of the terminal. This is the string that -is sent to the remote host. Default is "vt320" but you may use any -string, like "vt100", "vt220" or "xterm" if -it suits you. -

If you change it to scoansi, it will change the linedrawing characters -to match the scoansi ones.

Terminal.answerbackThe string the terminal sents back when it gets an 'ENQ' code. You -can set it to anything you want or what your local environment requires. -(The default is just a pointer to this config option.)
Terminal.bufferThis sets the size of the scroll back buffer the terminal uses. The -buffer is allocated dynamically until it reaches this size. You cannot -set the scrollback buffer to a value smaller than the amount of lines on -the screen.
Terminal.sizeSet the size of the terminal in terms of rows and lines. The value -has to be given in the following format: -
[width,height]
-Whitespaces are allowed within the brackets and just before and after the +
Terminal.beepIf this property points to a fully +qualified URL of a sound file this will be played in case of a terminal +bell signal. This works for applets only.
+Note: Some browsers (Netscape 4, IE 5.5 or earlier) sometimes can only play +.au files here. In IE the sound needs to be on the same server as the applet +or you get a security exception.
+
+Terminal Emulation Properties
+
Terminal.idUsed to identify the type of the terminal. This is the string that is +sent to the remote host. Default is "vt320" but you may use any string, +like "vt100", "vt220" or "xterm" if it suits you. +

If you change it to scoansi, it will change the linedrawing +characters to match the scoansi ones.

+
Terminal.answerbackThe string the terminal sents back when it gets an 'ENQ' code. You can +set it to anything you want or what your local environment requires. (The +default is just a pointer to this config option.)
Terminal.bufferThis sets the size of the scroll back buffer the terminal uses. The +buffer is allocated dynamically until it reaches this size. You cannot set +the scrollback buffer to a value smaller than the amount of lines on the +screen.
Terminal.sizeSet the size of the terminal in terms of rows and lines. The value has +to be given in the following format: +
[width,height +]
+ Whitespaces are allowed within the brackets and just before and after the comma. The standard is "[80,24]"
Terminal.resizeThis property defines the method that is applied when the terminal -window is resized. It may be either "font" - to resize -the font to match the window size or "screen" - to change -the amount of lines and columns displayed or "none" - to -do nothing.
Terminal.fontTells the terminal which font to use for the display of characters. -This is usually "Monospaced" as any other font name might +
Terminal.resizeThis property defines the method that is applied when the terminal window +is resized. It may be either "font" - to resize the font +to match the window size or "screen" - to change the amount +of lines and columns displayed or "none" - to do nothing.
Terminal.fontTells the terminal which font to use for the display of characters. +This is usually "Monospaced" as any other font name might not be available on the client host.
Terminal.fontStyleThe font style to be used when looking up the font. The font style -may be "plain", "bold" or "italic". -The default is "plain".
Terminal.fontSizeThe size of the font to be used. If you use automatic font resize this +
Terminal.fontStyleThe font style to be used when looking up the font. The font style may +be "plain", "bold" or "italic +". The default is "plain".
Terminal.fontSizeThe size of the font to be used. If you use automatic font resize this will be used as the initial font size.
Terminal.keyCodesThis should be set to the URL of a property file that contains the -key codes  you would like to use. The file is first tried using the -resource loading mechanism, which looks in the CLASSPATH and then as a -URL. Have a look at the file format for the key codes -definition.
Terminal.VMSSet this property to "true" if you are connecting to +
Terminal.keyCodesThis should be set to the URL of a property file that contains the key +codes  you would like to use. The file is first tried using the resource +loading mechanism, which looks in the CLASSPATH and then as a URL. Have a +look at the file format for the key codes definition +.
Terminal.VMSSet this property to "true" if you are connecting to a VMS system.
Terminal.IBMSet this to "true" if you would like to use PC ANSI +
Terminal.IBMSet this to "true" if you would like to use PC ANSI graphics characters as used by some BBS's.
Terminal.encodingUse this property if you have real UNICODE fonts installed on your -system or at least fonts that include the characters you would like to -display. The default setting it ISO8859_1 but it may be used to -make the terminal aware of special characters like in the japanese (i.e. -SJIS) -or chinese region.
- -

-Definition of Key Codes

-The definition of key codes should only be done if -your application uses a very different keyboard layout than the standard -vt320. The definition of almost all special keys is possible and follows -rules described below: -
# here is the rule -
[SCA]KEY=STRING
-The characters enclosed in [ and ] -are optional and only one of the characters 'S' (Shift), -'C' (Control) or 'A' (Alt) may appear before -the KEY, which is a textual representation (F1, PGUP etc) of the -key you would like to redefine. -

The new STRING you define to be sent when -pressing the key should come after the equal sign (=). -Hash marks (#) in the file declare a line as comment and will -be ignored. Some examples explain the syntax: -
  -

-Send the string "test" when pressing the F1 -key:
- -
-F1 = test
- -
-On pressing Control + PGUP send the string -"pgup pressed":
- -
-CPGUP = pgup pressed
- -
-Redefine the key Alt + F12 to send an escape -character:
- -
-AF12 = \\e
- -
  -

  -
  -
  -
  -
  -
  -
  -

As you can see the string you can define may contain -special characters which may be escaped using the backslash (\). Allowed -special characters follow in the table below: -

(Important: for some of the -escape codes you need two backslashes as these are our own definitions -and not known by the Java Property mechanism) -
  -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Special CharacterExplanation
\\bBackspace, this character is usually sent by the <-key -(not the cursor left key!).
\\eEscape, this character is usually sent by the Esc key.
\n -
(only one backslash)
Newline, this character will move the cursor to a new line. -On UNIX systems it is equivalent to carriage return + newline. Usually -the Enter key send this character.
\r -
(only one backslash)
Carriage Return, this key moves the cursor to the beginning -of the line. In conjunction with Newline it moves the cursor to -the beginning of a new line.
\t -
(only one backslash)
Tabulator, the tab character is sent by the ->| key -and moves the cursor to the next tab stop defined by the terminal.
\\vVertical Tabulator, sends a vertical tabulator character.
\\aBell, sends a terminal bell character which should make the -terminal sound its bell, but the implementation is a silent one ;-)
\\numberInserts the character that is defined by this number in the -ISO Latin1 character set. The number should be a decimal value.
- -

The following table explains which key may be -redefined. As explained above each of the keys may be prefixed by a character -defining the redefinition that occures if it is pressed in conjunction -with the shift, control or alt keys. -
  -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Key RepresentationRemarks
-
F1 - F20
-
The function key, F1, F2 ... up to F20.
-
PGUP
-
The Page Up key.
-
PGDOWN
-
The Page Down key.
-
END
-
The End key.
-
HOME
-
The Home (Pos 1) key.
-
INSERT
-
The Insert key.
-
REMOVE
-
The Remove key.
-
UP
-
The Cursor Up key.
-
DOWN
-
The Cursor Down key.
-
LEFT
-
The Cursor Left key.
-
RIGHT
-
The Cursor right key.
-
NUMPAD0 - NUMPAD9
-
The numbered Numpad keys.
-
ESCAPE
-
The ESCAPE key.
-
BACKSPACE
-
The backspace key.
-
TAB
-
The tabulator key.
-
Additional -Programmer Documentation is available: -
  -
- - - - - - + + + + + + +
de.mud.jta.plugin.Terminal
This is the programmer documentation for the plugin. Use it as an example +
Terminal.encodingUse this property if you have real UNICODE fonts installed on your system +or at least fonts that include the characters you would like to display. +The default setting it ISO8859_1 but it may be used to make the terminal +aware of special characters like in the japanese (i.e. SJIS) or chinese +region.
+
+ +

Definition of Key +Codes

+ The definition of key codes should only be done if +your application uses a very different keyboard layout than the standard vt320. +The definition of almost all special keys is possible and follows rules described +below: +
# here is the rule +
+ [SCA] +KEY=STRING
+ The characters enclosed in [ and ] + are optional and only one of the characters 'S' (Shift), +'C' (Control) or 'A' (Alt) may appear before +the KEY, which is a textual representation (F1, PGUP etc) of the key +you would like to redefine. +

The new STRING you define to be +sent when pressing the key should come after the equal sign (= +). Hash marks (#) in the file declare a line as comment and will +be ignored. Some examples explain the syntax:

+
Send the string "test" when pressing +the F1 key:
+
F1 = test
+
On pressing Control + PGUP send the +string "pgup pressed":
+
CPGUP = pgup pressed
+
Redefine the key Alt + F12 to send +an escape character:
+
AF12 = \\e
+
+  +

 





+

As you can see the string +you can define may contain special characters which may be escaped using +the backslash (\). Allowed special characters follow in the table below: +

+

(Important +: for some of the escape codes you need two backslashes as these are our +own definitions and not known by the Java Property mechanism) +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Special CharacterExplanation
\\bBackspace, this character is usually sent by the <- +key (not the cursor left key!).
\\eEscape, this character is usually sent by the Esc key.
\n
+ (only +one backslash)
Newline, this character will move the cursor to a new line. On +UNIX systems it is equivalent to carriage return + newline. Usually the +Enter key send this character.
\r
+ (only +one backslash)
Carriage Return, this key moves the cursor to the +beginning of the line. In conjunction with Newline it moves the cursor +to the beginning of a new line.
\t
+ (only +one backslash)
Tabulator, the tab character is sent by the ->| +key and moves the cursor to the next tab stop defined by the terminal.
\\vVertical Tabulator, sends a vertical tabulator character.
\\aBell, sends a terminal bell character which should make the terminal +sound its bell, but the implementation is a silent one ;-)
\\numberInserts the character that is defined by this number in the ISO +Latin1 character set. The number should be a decimal value.
+
+ +

The following table explains +which key may be redefined. As explained above each of the keys may be prefixed +by a character defining the redefinition that occures if it is pressed in +conjunction with the shift, control or alt keys.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Key RepresentationRemarks
+
F1 - F20
+
The function key, F1, F2 ... up to F20.
+
PGUP
+
The Page Up key.
+
PGDOWN
+
The Page Down key.
+
END
+
The End key.
+
HOME
+
The Home (Pos 1) key.
+
INSERT
+
The Insert key.
+
REMOVE
+
The Remove key.
+
UP
+
The Cursor Up key.
+
DOWN
+
The Cursor Down key.
+
LEFT
+
The Cursor Left key.
+
RIGHT
+
The Cursor right key.
+
NUMPAD0 - NUMPAD9
+
The numbered Numpad keys.
+
ESCAPE
+
The ESCAPE key.
+
BACKSPACE
+
The backspace key.
+
TAB
+
The tabulator key.
+
+
+Additional Programmer Documentation is available:
+  +
+ + + + + + + - - - - - - - - - - - - - - - - - -
+de.mud.jta.plugin.Terminal
This is the programmer documentation for the plugin. Use it as an example if you want to write your own back end plugins.
de.mud.jta.event
This plugins uses some of the events and listeners described here.
de.mud.terminal
Have a look here for the underlying terminal emulation package.
- -

If you produced keyCode definition -files you'd like to share with others send -them to us and we will publish them here. -
  -
  - - - - - - - + + + + + + + + + + + + + + +
AT -386 Terminal
A key code definition file for an AT-386 Terminal. It should +
+de.mud.jta.event
This plugins uses some of the events and listeners described here.
+de.mud.terminal
Have a look here for the underlying terminal emulation package.
+ + +

If you produced +keyCode definition files you'd like to share with others +send them to us and we will publish them here.

+  + + + + + + + - -
+AT 386 Terminal
A key code definition file for an AT-386 Terminal. It should work with ANSI and most version of UNIX. More info is in the file.
-

- -
- - + + + +
- - - + + +
Copyright 1996-2000 Matthias L. +
+

+
+ +
+ + + + - -
+ + + + - - - - - - - -
Copyright 1996-2000 Matthias L. Jugel, Marcus Meißner - -
-
$Id: Terminal.html,v 1.9 2000/03/19 10:51:48 marcus Exp -$
-
-
- - - +
+ +
+
$Id: Terminal.html,v 1.9 2000/03/19 +10:51:48 marcus Exp $
+
+
+ + + +