org.pkl.thirdparty.jline.utils.Curses Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pkl-tools Show documentation
Show all versions of pkl-tools Show documentation
Fat Jar containing pkl-cli, pkl-codegen-java, pkl-codegen-kotlin, pkl-config-java, pkl-core, pkl-doc, and their shaded third-party dependencies.
/*
* Copyright (c) 2002-2018, the original author(s).
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
*
* https://opensource.org/licenses/BSD-3-Clause
*/
package org.pkl.thirdparty.jline.utils;
import java.io.Flushable;
import java.io.IOError;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayDeque;
/**
* Curses helper methods.
*
* @author Guillaume Nodet
*/
public final class Curses {
private static final Object[] sv = new Object[26];
private static final Object[] dv = new Object[26];
private static final int IFTE_NONE = 0;
private static final int IFTE_IF = 1;
private static final int IFTE_THEN = 2;
private static final int IFTE_ELSE = 3;
private Curses() {}
/**
* Print the given terminal capabilities
*
* @param cap the capability to output
* @param params optional parameters
* @return the result string
*/
public static String tputs(String cap, Object... params) {
if (cap != null) {
StringWriter sw = new StringWriter();
tputs(sw, cap, params);
return sw.toString();
}
return null;
}
/**
* Print the given terminal capabilities
*
* @param out the output stream
* @param str the capability to output
* @param params optional parameters
*/
public static void tputs(Appendable out, String str, Object... params) {
try {
doTputs(out, str, params);
} catch (Exception e) {
throw new IOError(e);
}
}
private static void doTputs(Appendable out, String str, Object... params) throws IOException {
int index = 0;
int length = str.length();
int ifte = IFTE_NONE;
boolean exec = true;
ArrayDeque
© 2015 - 2024 Weber Informatics LLC | Privacy Policy