• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java WindowsSupport类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.fusesource.jansi.internal.WindowsSupport的典型用法代码示例。如果您正苦于以下问题:Java WindowsSupport类的具体用法?Java WindowsSupport怎么用?Java WindowsSupport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

WindowsSupport类属于org.fusesource.jansi.internal包,在下文中一共展示了WindowsSupport类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: create

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
@Override
public void create(Runnable onInitialized) {
	StaticVars.outputLevel = -1;
	AnsiConsole.systemInstall();
	if (Utils.isWindows() && !Utils.msDosMode) {
		win = true;
		WindowsSupport.setConsoleMode(0x0200);
		Thread t = new Thread(() -> {
			int ch = -1;
			while (true) {
				if (precKey != null) {
					Keyboard.keyReleased(precKey);
					precKey = null;
				}
				ch = WindowsSupport.readByte();
				Key key = null;
				switch (ch) {
					case 72: { // UP
						key = Key.UP;
						break;
					}
					case 80: { // DOWN
						key = Key.DOWN;
						break;
					}
					case 77: { // RIGHT
						key = Key.RIGHT;
						break;
					}
					case 75: { // LEFT
						key = Key.LEFT;
						break;
					}
					case 49: { // 1
						key = Key.NUM1;
						break;
					}
					case 50: { // 2
						key = Key.NUM2;
						break;
					}
					case 51: { // 3
						key = Key.NUM3;
						break;
					}
					case 52: { // 4
						key = Key.NUM4;
						break;
					}
					case 53: { // 5
						key = Key.NUM5;
						break;
					}
					case 54: { // 6
						key = Key.NUM6;
						break;
					}
					default: {
						key = Key.NONE;
						break;
					}
				}
				if (key != null) {
					Keyboard.keyPressed(key);
				}

			}
		});
		t.setDaemon(true);
		t.start();
	}
	stopped = false;
	if (onInitialized != null)
		onInitialized.run();
}
 

开发者ID:XDrake99,
项目名称:WarpPI,
代码行数:76,
代码来源:Headless24bitEngine.java

示例2: getConsoleInfo

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
private void getConsoleInfo() throws IOException {
	out.flush();
	if( GetConsoleScreenBufferInfo(console, info) == 0 ) {
		throw new IOException("Could not get the screen info: "+WindowsSupport.getLastErrorMessage());
	}
	if( negative ) {
		info.attributes = invertAttributeColors(info.attributes); 
	}
}
 

开发者ID:tomas-langer,
项目名称:chalk,
代码行数:10,
代码来源:WindowsAnsiOutputStream.java

示例3: applyAttribute

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
private void applyAttribute() throws IOException {
	out.flush();
	short attributes = info.attributes;
	if( negative ) {
		attributes = invertAttributeColors(attributes); 
	}
	if( SetConsoleTextAttribute(console, attributes) == 0 ) {
		throw new IOException(WindowsSupport.getLastErrorMessage());
	}
}
 

开发者ID:tomas-langer,
项目名称:chalk,
代码行数:11,
代码来源:WindowsAnsiOutputStream.java

示例4: getConsoleMode

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
@Override
protected int getConsoleMode() {
    return WindowsSupport.getConsoleMode();
}
 

开发者ID:aeshell,
项目名称:aesh-readline,
代码行数:5,
代码来源:WinSysTerminal.java

示例5: setConsoleMode

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
@Override
protected void setConsoleMode(int mode) {
    WindowsSupport.setConsoleMode(mode);
}
 

开发者ID:aeshell,
项目名称:aesh-readline,
代码行数:5,
代码来源:WinSysTerminal.java

示例6: getSize

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
public Size getSize() {
    Size size = new Size(WindowsSupport.getWindowsTerminalWidth(),
            WindowsSupport.getWindowsTerminalHeight());
    return size;
}
 

开发者ID:aeshell,
项目名称:aesh-readline,
代码行数:6,
代码来源:WinSysTerminal.java

示例7: readConsoleInput

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
protected byte[] readConsoleInput() {
    // XXX does how many events to read in one call matter?
    INPUT_RECORD[] events = null;
    try {
        events = WindowsSupport.readConsoleInput(1);
    } catch (IOException e) {
        LOGGER.log(Level.INFO, "read Windows terminal input error: ", e);
    }
    if (events == null) {
        return new byte[0];
    }
    StringBuilder sb = new StringBuilder();
    for (INPUT_RECORD event : events) {
        KEY_EVENT_RECORD keyEvent = event.keyEvent;
        // support some C1 control sequences: ALT + [@-_] (and [a-z]?) => ESC <ascii>
        // http://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_set
        final int altState = KEY_EVENT_RECORD.LEFT_ALT_PRESSED | KEY_EVENT_RECORD.RIGHT_ALT_PRESSED;
        // Pressing "Alt Gr" is translated to Alt-Ctrl, hence it has to be checked that Ctrl is _not_ pressed,
        // otherwise inserting of "Alt Gr" codes on non-US keyboards would yield errors
        final int ctrlState = KEY_EVENT_RECORD.LEFT_CTRL_PRESSED | KEY_EVENT_RECORD.RIGHT_CTRL_PRESSED;
        // Compute the overall alt state
        boolean isAlt = ((keyEvent.controlKeyState & altState) != 0) && ((keyEvent.controlKeyState & ctrlState) == 0);

        //Log.trace(keyEvent.keyDown? "KEY_DOWN" : "KEY_UP", "key code:", keyEvent.keyCode, "char:", (long)keyEvent.uchar);
        if (keyEvent.keyDown) {
            if (keyEvent.uchar > 0) {
                boolean shiftPressed = (keyEvent.controlKeyState & KEY_EVENT_RECORD.SHIFT_PRESSED) != 0;
                if (keyEvent.uchar == '\t' && shiftPressed) {
                    sb.append(getSequence(Capability.key_btab));
                } else {
                    if (isAlt) {
                        sb.append('\033');
                    }
                    sb.append(keyEvent.uchar);
                }
            }
            else {
                // virtual keycodes: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
                // TODO: numpad keys, modifiers
                String escapeSequence = getEscapeSequence(keyEvent.keyCode);
                if (escapeSequence != null) {
                    for (int k = 0; k < keyEvent.repeatCount; k++) {
                        if (isAlt) {
                            sb.append('\033');
                        }
                        sb.append(escapeSequence);
                    }
                }
            }
        } else {
            // key up event
            // support ALT+NumPad input method
            if (keyEvent.keyCode == 0x12/*VK_MENU ALT key*/ && keyEvent.uchar > 0) {
                sb.append(keyEvent.uchar);
            }
        }
    }
    return sb.toString().getBytes();
}
 

开发者ID:aeshell,
项目名称:aesh-readline,
代码行数:60,
代码来源:WinSysTerminal.java

示例8: applyCursorPosition

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
private void applyCursorPosition() throws IOException {
	if( SetConsoleCursorPosition(console, info.cursorPosition.copy()) == 0 ) {
		throw new IOException(WindowsSupport.getLastErrorMessage());
	}
}
 

开发者ID:tomas-langer,
项目名称:chalk,
代码行数:6,
代码来源:WindowsAnsiOutputStream.java

示例9: getConsoleMode

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
private int getConsoleMode() {
    return WindowsSupport.getConsoleMode();
}
 

开发者ID:AcademicTorrents,
项目名称:AcademicTorrents-Downloader,
代码行数:4,
代码来源:WindowsTerminal.java

示例10: setConsoleMode

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
private void setConsoleMode(int mode) {
    WindowsSupport.setConsoleMode(mode);
}
 

开发者ID:AcademicTorrents,
项目名称:AcademicTorrents-Downloader,
代码行数:4,
代码来源:WindowsTerminal.java

示例11: readConsoleInput

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
private byte[] readConsoleInput() {
    // XXX does how many events to read in one call matter?
    INPUT_RECORD[] events = null;
    try {
        events = WindowsSupport.readConsoleInput(1);
    } catch (IOException e) {
        Log.debug("read Windows console input error: ", e);
    }
    if (events == null) {
        return new byte[0];
    }
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < events.length; i++ ) {
        KEY_EVENT_RECORD keyEvent = events[i].keyEvent;
        //Log.trace(keyEvent.keyDown? "KEY_DOWN" : "KEY_UP", "key code:", keyEvent.keyCode, "char:", (long)keyEvent.uchar); 
        if (keyEvent.keyDown) {
            if (keyEvent.uchar > 0) {
                // support some C1 control sequences: ALT + [@-_] (and [a-z]?) => ESC <ascii>
                // http://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_set
                int altState = KEY_EVENT_RECORD.LEFT_ALT_PRESSED | KEY_EVENT_RECORD.RIGHT_ALT_PRESSED;
                if (((keyEvent.uchar >= '@' && keyEvent.uchar <= '_') || (keyEvent.uchar >= 'a' && keyEvent.uchar <= 'z'))
                    && (keyEvent.controlKeyState & altState) != 0) {
                    sb.append('\u001B'); // ESC
                }

                sb.append(keyEvent.uchar);
                continue;
            }
            // virtual keycodes: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
            // just add support for basic editing keys (no control state, no numpad keys)
            String escapeSequence = null;
            switch (keyEvent.keyCode) {
            case 0x21: // VK_PRIOR PageUp
                escapeSequence = "\u001B[5~";
                break;
            case 0x22: // VK_NEXT PageDown
                escapeSequence = "\u001B[6~";
                break;
            case 0x23: // VK_END
                escapeSequence = "\u001B[4~";
                break;
            case 0x24: // VK_HOME
                escapeSequence = "\u001B[1~";
                break;
            case 0x25: // VK_LEFT
                escapeSequence = "\u001B[D";
                break;
            case 0x26: // VK_UP
                escapeSequence = "\u001B[A";
                break;
            case 0x27: // VK_RIGHT
                escapeSequence = "\u001B[C";
                break;
            case 0x28: // VK_DOWN
                escapeSequence = "\u001B[B";
                break;
            case 0x2D: // VK_INSERT
                escapeSequence = "\u001B[2~";
                break;
            case 0x2E: // VK_DELETE
                escapeSequence = "\u001B[3~";
                break;
            default:
                break;
            }
            if (escapeSequence != null) {
                for (int k = 0; k < keyEvent.repeatCount; k++) {
                    sb.append(escapeSequence);
                }
            }
        } else {
            // key up event
            // support ALT+NumPad input method
            if (keyEvent.keyCode == 0x12/*VK_MENU ALT key*/ && keyEvent.uchar > 0) {
                sb.append(keyEvent.uchar);
            }
        }
    }
    return sb.toString().getBytes();
}
 

开发者ID:AcademicTorrents,
项目名称:AcademicTorrents-Downloader,
代码行数:81,
代码来源:WindowsTerminal.java

示例12: getWindowsTerminalWidth

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
private int getWindowsTerminalWidth() {
    return WindowsSupport.getWindowsTerminalWidth();
}
 

开发者ID:AcademicTorrents,
项目名称:AcademicTorrents-Downloader,
代码行数:4,
代码来源:WindowsTerminal.java

示例13: getWindowsTerminalHeight

点赞 2

import org.fusesource.jansi.internal.WindowsSupport; //导入依赖的package包/类
private int getWindowsTerminalHeight() {
    return WindowsSupport.getWindowsTerminalHeight();
}
 

开发者ID:AcademicTorrents,
项目名称:AcademicTorrents-Downloader,
代码行数:4,
代码来源:WindowsTerminal.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)