All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dorkbox.inputConsole.Terminal Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2010 dorkbox, llc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package dorkbox.inputConsole;

import java.io.IOException;

public abstract class Terminal {

    protected final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(getClass());


    protected static final int DEFAULT_WIDTH = 80;
    protected static final int DEFAULT_HEIGHT = 24;

    private volatile boolean echoEnabled;

    protected Terminal() {}

    public abstract void init() throws IOException;

    public abstract void restore() throws IOException;

    public void setEchoEnabled(boolean enabled) {
        this.echoEnabled = enabled;
    }

    public boolean isEchoEnabled() {
        return this.echoEnabled;
    }

    public abstract int getWidth();

    public abstract int getHeight();

    /**
     * @return a character from whatever underlying input method the terminal has available.
     */
    public abstract int read();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy