 
                        
        
                        
        org.jline.utils.Curses Maven / Gradle / Ivy
/*
 * Copyright (c) 2002-2018, the original author or authors.
 *
 * 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.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 - 2025 Weber Informatics LLC | Privacy Policy