ConsolePrinter

控制台操作类。

有关概念说明:

  • 缓存下标:

      程序会给每一个缓存分配一个下标(从 0 开始),第一个被显示的下标为最后一个缓存,调用一次 flush 后将会显示下标为 0 的缓存。 正在显示的缓存我们称之为活动缓存或前台,直接向活动缓存写入数据会直接显示在屏幕上,向非活动缓存写入数据会在其变为活动缓存时显示到屏幕上。

      请注意,出于性能方面的考虑,当一个缓存由活动缓存变为非活动缓存时,其内容不会被清空,再向该缓存写入数据时上一帧的数据将仍然存在,如果有必要, 请手动调用 clear 系列函数清空缓存。(这里的上一帧是指该缓存的上一帧,而非整个程序的上一帧,当缓存数量大于 1 时这两个概念将显示出不同.)

      所有接收缓存下标的函数都会缺省填入活动缓存的下一个缓存。

      活动缓存的判定是在 JVM 端完成的,如果使用反射等方法调用了 flushN 函数,请务必手动更新 JVM 端的缓存下标。

  • ATTR:

      这是用于控制终端字体颜色、背景颜色等属性的值,所有支持的类型已在 ConsolePrinter 中列出。需要注意的是,在调用 flush 函数时, 同样不会清除上一次设置的 ATTR 信息。

      除 clear 系列函数外的所有函数,传入 attr = -1 表示无效 attr,渲染内容时将忽略 attr 信息。

  • 字符宽度:

      在控制台中,不同字符宽度不同,拉丁文字符宽度为 1,而中文字符宽度为 2。 计算字符宽度时,满足 char < 0x100 的宽度视为 1,否则为 2.

Author

空梦

Functions

Link copied to clipboard

销毁控制台

Link copied to clipboard
external fun drawDottedLine(char: Char, charWidth: Int, x: Int, y: Int, width: Int, height: Int, lineLength: Int, spaceLength: Int, offset: Int, index: Int = this.index)

以指定字符为填充绘制一条虚线。

Link copied to clipboard
external fun drawString(text: String, x: Int, y: Int, index: Int = this.index)

打印一个字符串

Link copied to clipboard
external fun drawVerticalDottedLine(char: Char, charWidth: Int, x: Int, y: Int, width: Int, height: Int, lineLength: Int, spaceLength: Int, offset: Int, index: Int = this.index)
Link copied to clipboard
external fun fillRect(char: Char, x: Int, y: Int, width: Int, height: Int, index: Int = this.index)
Link copied to clipboard
external fun fillRectHollow(char: Char, x: Int, y: Int, width: Int, height: Int, index: Int = this.index)

使用指定字符填充一个空心矩形

Link copied to clipboard
fun flush(index: Int = this.index)
Link copied to clipboard

获取一个字符的宽度

Link copied to clipboard
fun init(width: Int, height: Int, fontWidth: Int, cache: Int = 2, ignoreClose: Boolean = false, path: File = File("./libs/utils.dll"))

初始化控制台信息,开始使用前必须调用该函数。

Link copied to clipboard
external fun modifyAttr(attr: Int, x: Int, y: Int, width: Int, height: Int, index: Int = this.index)

修改指定区域的填充属性

Link copied to clipboard
fun quickClear(char: Char = ' ', attr: Int = -1, index: Int = this.index)

快速清空全图字符和 attr

Link copied to clipboard
fun quickClearAllAttr(attr: Int, index: Int = this.index)

快速清空全图的 attr

Link copied to clipboard
fun quickClearAllChar(char: Char = ' ', index: Int = this.index)

快速清空全图的字符

Link copied to clipboard
external fun quickFillAttr(attr: Int, x: Int, y: Int, amount: Int, index: Int = this.index)

快速填充 attr,若填充宽度超过当前行宽,会跨行填充而非截止

fun quickFillAttr(attr: Int, x1: Int, y1: Int, x2: Int, y2: Int, index: Int = this.index)

快速填充 attr,若填充宽度超过当前行宽,会跨行填充而非截止。

Link copied to clipboard
external fun quickFillChar(char: Char, x: Int, y: Int, amount: Int, index: Int = this.index)

快速填充字符,若填充宽度超过当前行款,会跨行填充而非截止

fun quickFillChar(char: Char, x1: Int, y1: Int, x2: Int, y2: Int, index: Int = this.index)

快速填充字符,若填充宽度超过当前行宽,会跨行填充而非截止。

Properties

Link copied to clipboard
const val BACKGROUND_BLUE: Int = 16

背景色:蓝

Link copied to clipboard
const val BACKGROUND_GREEN: Int = 32

背景色:绿

Link copied to clipboard
const val BACKGROUND_INTENSITY: Int = 128

背景色:高亮

Link copied to clipboard
const val BACKGROUND_RED: Int = 64

背景色:红

Link copied to clipboard

背景色:高亮白

Link copied to clipboard
Link copied to clipboard

顶部水平网格

Link copied to clipboard
const val COMMON_LVB_GRID_LVERTICAL: Int = 2048

左侧竖直网格

Link copied to clipboard
const val COMMON_LVB_GRID_RVERTICAL: Int = 4096

右侧竖直网格

Link copied to clipboard
const val COMMON_LVB_LEADING_BYTE: Int = 256

前导字节

Link copied to clipboard
const val COMMON_LVB_REVERSE_VIDEO: Int = 16384

前景色、背景色反转

Link copied to clipboard
const val COMMON_LVB_TRAILING_BYTE: Int = 512

尾随字节

Link copied to clipboard
const val COMMON_LVB_UNDERSCORE: Int = 32768

下划线

Link copied to clipboard
const val FOREGROUND_BLUE: Int = 1

前景色:蓝

Link copied to clipboard
const val FOREGROUND_GREEN: Int = 2

前景色:绿

Link copied to clipboard
const val FOREGROUND_INTENSITY: Int = 8

前景色:高亮

Link copied to clipboard
const val FOREGROUND_RED: Int = 4

前景色:红

Link copied to clipboard

前景色:高亮白

Link copied to clipboard
Link copied to clipboard

标记当前正在写入的缓存下标

Link copied to clipboard