src/jdk.internal.le/windows/classes/jdk/internal/org/jline/terminal/impl/jna/win/JnaWinConsoleWriter.java
equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2002-2017, the original author or authors. |
|
3 * |
|
4 * This software is distributable under the BSD license. See the terms of the |
|
5 * BSD license in the documentation provided with this software. |
|
6 * |
|
7 * http://www.opensource.org/licenses/bsd-license.php |
|
8 */ |
|
9 package jdk.internal.org.jline.terminal.impl.jna.win; |
|
10 |
|
11 //import com.sun.jna.LastErrorException; |
|
12 //import com.sun.jna.Pointer; |
|
13 //import com.sun.jna.ptr.IntByReference; |
|
14 import jdk.internal.org.jline.terminal.impl.AbstractWindowsConsoleWriter; |
|
15 |
|
16 import java.io.IOException; |
|
17 |
|
18 class JnaWinConsoleWriter extends AbstractWindowsConsoleWriter { |
|
19 |
|
20 private final Pointer consoleHandle; |
|
21 private final IntByReference writtenChars = new IntByReference(); |
|
22 |
|
23 JnaWinConsoleWriter(Pointer consoleHandle) { |
|
24 this.consoleHandle = consoleHandle; |
|
25 } |
|
26 |
|
27 @Override |
|
28 protected void writeConsole(char[] text, int len) throws IOException { |
|
29 try { |
|
30 Kernel32.INSTANCE.WriteConsoleW(this.consoleHandle, text, len, this.writtenChars, null); |
|
31 } catch (LastErrorException e) { |
|
32 throw new IOException("Failed to write to console", e); |
|
33 } |
|
34 } |
|
35 |
|
36 } |