// 
// Decompiled by Procyon v0.6.0
// 

package org.jline.terminal.impl.jna.win;

import com.sun.jna.LastErrorException;
import java.io.IOException;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.Pointer;
import org.jline.terminal.impl.AbstractWindowsConsoleWriter;

class JnaWinConsoleWriter extends AbstractWindowsConsoleWriter
{
    private final Pointer console;
    private final IntByReference writtenChars;
    
    JnaWinConsoleWriter(final Pointer console) {
        this.writtenChars = new IntByReference();
        this.console = console;
    }
    
    @Override
    protected void writeConsole(final char[] text, final int len) throws IOException {
        try {
            Kernel32.INSTANCE.WriteConsoleW(this.console, text, len, this.writtenChars, null);
        }
        catch (final LastErrorException e) {
            throw new IOException("Failed to write to console", (Throwable)e);
        }
    }
}
