abstracttoolkit.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 949 行 · 第 1/3 页
JAVA
949 行
* "man curs_print").
*/
// public abstract void print(String str_) throws TerminfoCapabilityException;
/** Provides an interface to the terminfo "init_pair()" function.
*/
public abstract void initColorPair(int pair_, int fgnd_, int bgnd_)
throws TerminfoCapabilityException;
/** Emulates the terminfo COLOR_PAIR macro.
*/
public static int COLOR_PAIR_ATTRIBUTE(int pair_) {
return (pair_ << 8);
}
/** Returns the tty device name (provides an interface to the
* Unix C function "ttyname()").
*/
public abstract String getTtyName();
//====================================================================
// PACKAGE-PRIVATE METHODS
/**
* Add a window to the list of displayed windows.
* Intended to be called by the Window class only.
*/
void addWindow(Window window_) {
synchronized (_windowList) {
_windowList.add(window_);
}
}
/**
* Remove a window from the list of displayed windows.
* This is intended to be called by the Window object when it hides itself.
*/
void removeWindow(Window window_) {
synchronized (_windowList) {
if (_windowList.remove(window_) == false)
throw new RuntimeException(
"trying to remove window not in windowlist");
}
}
/**
* Returns a Vector of all the currently-displayed Windows. Note that the
* calling thread must synchronize on the returned Vector before using or
* modifying it, because the window list is accessed by the
* keyboard-reading thread as well as by the event-dispatching thread.
*/
Vector getWindowList() {
return _windowList;
}
private static int[] COLOR_TABLE = {
0, //black 0
4, //red 0
2, //green 0
14, //yellow 0
1, //blue 0
5, //magenta 0
3, //cyan 0
7, //white 0
};
/** This method is used for initializing the color constants in the
* Color class.
*/
protected static int getColor(int index) {
return COLOR_TABLE[index];
}
/** Changes the default foreground color.
*/
public static void setDefaultForeground(Color color_) {
_defaultForeground = color_;
}
/** Returns the default foreground color.
*/
public static Color getDefaultForeground() {
return _defaultForeground;
}
/** Changes the default background color.
*/
public static void setDefaultBackground(Color color_) {
_defaultBackground = color_;
}
/** Returns the default background color.
*/
public static Color getDefaultBackground() {
return _defaultBackground;
}
/** Trigger garbage collection. This method can be called inside an
* event handler, but the call to <code>System.gc()</code> will be
* made after the event handler has completed (i.e. after drawing is
* completed). This is a convenient, but OPTIONAL, way of ensuring
* that the heap does not grow too large. Some experts say that it is
* better not to call System.gc() explicitly from inside an application;
* you take your pick.
*
* @param source_ the component that triggered the garbage collection
* (not important).
*/
public void triggerGarbageCollection(Component source_) {
//LS _evtQueue.postEvent( new GarbageCollectionEvent(source_));
}
/** Get information about a mouse event (i.e the coordinates, and which
* button was clicked).
*/
public abstract MouseEventInfo getMouseEventInfo();
//====================================================================
// PRIVATE METHODS
/**
* This method is intended to be called by the keyboard-reading thread
* only.
*/
protected abstract int readKey();
/** Get current X position of cursor.
*/
protected abstract int getx();
/** Get current Y position of cursor.
*/
protected abstract int gety();
private static int[] ATTRIBUTE_TABLE = {
0, //A_NORMAL 0
0, //A_STANDOUT 1
1, //A_UNDERLINE 2
2, //A_REVERSE 3
0, //A_BLINK 4
0, //A_DIM 5
4, //A_BOLD 6
0, //A_ALTCHARSET 7
0, //A_INVIS 8
};
/** This method is used for initializing the curses / ncurses video
* attributes.
*/
protected static int getAttribute(int offset_) {
return ATTRIBUTE_TABLE[offset_];
}
private static int[] ACS_TABLE = new int[]
{
218, //ACS_ULCORNER 0
192, //ACS_LLCORNER 1
191, //ACS_URCORNER 2
217, //ACS_LRCORNER 3
195, //ACS_LTEE 4
180, //ACS_RTEE 5
193, //ACS_BTEE 6
194, //ACS_TTEE 7
196, //ACS_HLINE 8
179, //ACS_VLINE 9
197, //ACS_PLUS 10
0, //ACS_S1 11
0, //ACS_S9 12
254, //ACS_DIAMOND 13 //TODO check it
178, //ACS_CKBOARD 14 //TODO check it
0, //ACS_DEGREE 15
0, //ACS_PLMINUS 16
0, //ACS_BULLET 17
};
/** This method is used for initializing the line-drawing
* characters using curses/ncurses.
*/
private static int getACSchar(int offset_) {
return ACS_TABLE[offset_];
}
//====================================================================
// INSTANCE VARIABLES
//private int _rows;
//private int _columns;
/**
* A list of visible Windows. The first in the list is at the bottom, the
* last is on top.
*/
private Vector _windowList = new Vector();
/**
* A list of color-pairs.
*/
protected Vector _colorPairs = new Vector();
protected EventQueue _evtQueue;
/** Used to record keystrokes if "charva.script.record" is defined.
*/
private static PrintStream _scriptPrintStream = null;
/** Used to save the time the previous key was pressed.
*/
private long _prevTimeMillis = 0;
private long _lastMousePressTime;
private long _lastMouseClickTime;
// Definition as for ISO8859-1 (Latin-1) characters
public static final char Auml = (char) 0xc4;
public static final char Ccedil = (char) 0xc7;
public static final char Eacute = (char) 0xc9;
public static final char Euml = (char) 0xcb;
public static final char Ouml = (char) 0xd6;
public static final char Uuml = (char) 0xdc;
/* This is a static initializer block. It is executed once,
* when the class is initialized.
*/
static {
/* Check if the user wants to record or play back a script.
*/
String scriptfilename = System.getProperty("charva.script.record");
if (scriptfilename != null) {
try {
_scriptPrintStream = new PrintStream(
new FileOutputStream(scriptfilename));
} catch (FileNotFoundException ef) {
System.err.println("Cannot open script file \"" +
scriptfilename + "\" for writing");
System.exit(1);
}
}
// String home = System.getProperty("user.home");
// String logfilename = home + "/charva.log";
// System.loadLibrary("Terminal");
}
/** This flag is true is the system property "charva.color" has been set.
*/
public static final boolean isColorEnabled = true;
//(System.getProperty("charva.color") != null);
/* These are set to match the equivalent definitions in <ncurses.h>
* or <curses.h> (they have to be set dynamically because the values
* differ between curses, ncurses and PDCurses).
*/
public static final int A_NORMAL = getAttribute(0);
public static final int A_STANDOUT = getAttribute(1);
public static final int A_UNDERLINE = getAttribute(2);
public static final int A_REVERSE = getAttribute(3);
public static final int A_BLINK = getAttribute(4);
public static final int A_DIM = getAttribute(5);
public static final int A_BOLD = getAttribute(6);
public static final int A_ALTCHARSET = getAttribute(7);
public static final int A_INVIS = getAttribute(8);
// graphical symbols that must be initialized from <ncurses.h> or
// <curses.h>
public static final int ACS_ULCORNER = getACSchar(0);
public static final int ACS_LLCORNER = getACSchar(1);
public static final int ACS_URCORNER = getACSchar(2);
public static final int ACS_LRCORNER = getACSchar(3);
public static final int ACS_LTEE = getACSchar(4);
public static final int ACS_RTEE = getACSchar(5);
public static final int ACS_BTEE = getACSchar(6);
public static final int ACS_TTEE = getACSchar(7);
public static final int ACS_HLINE = getACSchar(8);
public static final int ACS_VLINE = getACSchar(9);
public static final int ACS_PLUS = getACSchar(10);
public static final int ACS_S1 = getACSchar(11);
public static final int ACS_S9 = getACSchar(12);
public static final int ACS_DIAMOND = getACSchar(13);
public static final int ACS_CKBOARD = getACSchar(14);
public static final int ACS_DEGREE = getACSchar(15);
public static final int ACS_PLMINUS = getACSchar(16);
public static final int ACS_BULLET = getACSchar(17);
// These constants must be the same as in ncurses.h
public static final int BLACK = getColor(0);
public static final int RED = getColor(1);
public static final int GREEN = getColor(2);
public static final int YELLOW = getColor(3);
public static final int BLUE = getColor(4);
public static final int MAGENTA = getColor(5);
public static final int CYAN = getColor(6);
public static final int WHITE = getColor(7);
public static Color _defaultForeground = Color.white;
public static Color _defaultBackground = Color.black;
public static final int KEY_MOUSE = 0631;
public static final int BUTTON1_RELEASED = 000001;
public static final int BUTTON1_PRESSED = 000002;
public static final int BUTTON1_CLICKED = 000004;
public static final int BUTTON2_RELEASED = 000100;
public static final int BUTTON2_PRESSED = 000200;
public static final int BUTTON2_CLICKED = 000400;
public static final int BUTTON3_RELEASED = 010000;
public static final int BUTTON3_PRESSED = 020000;
public static final int BUTTON3_CLICKED = 040000;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?