package net.torvald.terrarum.modulecomputers.virtualcomputer.terminal

import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.Second

/**
 * A terminal
 *
 * Framebuffer: USE net.torvald.aa.AAFrame
 *
 * Background color is fixed; text color is variable
 *
 * Created by minjaesong on 2016-09-07.
 */
interface Terminal : net.torvald.terrarum.modulecomputers.virtualcomputer.terminal.Teletype {
    override val width: Int
    val height: Int
    override val coloursCount: Int
    override var cursorX: Int
    var cursorY: Int
    var cursorBlink: Boolean
    var backColour: Int
    var foreColour: Int

    // to be used in UI
    override val displayW: Int
    val displayH: Int

    fun getColor(index: Int): Color
    override fun update(delta: Float)
    override fun render(batch: SpriteBatch)
    override fun keyPressed(key: Int, c: Char)

    // API calls
    fun setCursor(x: Int, y: Int)
    /** Emits a bufferChar. Does not move cursor
     *  It is also not affected by the control sequences; just print them out as symbol */
    fun emitChar(bufferChar: Int, x: Int, y: Int)
    /** Emits a char. Does not move cursor
     *  It is also not affected by the control sequences; just print them out as symbol */
    fun emitChar(c: Char, x: Int, y: Int)
    /** Prints a char and move cursor accordingly. */
    override fun printChar(c: Char)
    /** Emits a string, does not affected by control sequences. Does not move cursor */
    fun emitString(s: String, x: Int, y: Int)
    /** Emits a string and move cursor accordingly, then do LF */
    fun printString(s: String, x: Int, y: Int)
    /** Emits a string and move cursor accordingly. */
    fun writeString(s: String, x: Int, y: Int)
    fun clear()
    fun clearLine()
    override fun newLine()
    override fun scroll(amount: Int)
    fun setColour(back: Int, fore: Int)
    fun resetColour()
    /**
     * @param duration: milliseconds
     * @param freg: Frequency (float)
     */
    fun emitTone(duration: Second, freq: Double)

    override fun bell(pattern: String)
}