mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 17:00:14 +08:00
KDoc; Adjust the order of property
This commit is contained in:
parent
81aa60fe5d
commit
cce3749661
@ -91,6 +91,17 @@ public interface MiraiConsole : CoroutineScope {
|
|||||||
@ConsoleExperimentalApi
|
@ConsoleExperimentalApi
|
||||||
public fun createLogger(identity: String?): MiraiLogger
|
public fun createLogger(identity: String?): MiraiLogger
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否支持使用 Ansi 输出彩色信息
|
||||||
|
*
|
||||||
|
* 注: 不是每个前端都可能提供 `org.fusesource.jansi:jansi` 库支持,
|
||||||
|
* 请不要直接使用 `org.fusesource.jansi:jansi`
|
||||||
|
*
|
||||||
|
* @see [AnsiMessageBuilder]
|
||||||
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
|
public val isAnsiSupported: Boolean
|
||||||
|
|
||||||
public companion object INSTANCE : MiraiConsole by MiraiConsoleImplementationBridge {
|
public companion object INSTANCE : MiraiConsole by MiraiConsoleImplementationBridge {
|
||||||
/**
|
/**
|
||||||
* 获取 [MiraiConsole] 的 [Job]
|
* 获取 [MiraiConsole] 的 [Job]
|
||||||
@ -154,16 +165,6 @@ public interface MiraiConsole : CoroutineScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否支持使用 Ansi 输出彩色信息
|
|
||||||
*
|
|
||||||
* 注: 不是每个前端都可能提供 `org.fusesource.jansi:jansi` 库支持,
|
|
||||||
* 请不要直接使用 `org.fusesource.jansi:jansi`
|
|
||||||
*
|
|
||||||
* @see [AnsiMessageBuilder]
|
|
||||||
*/
|
|
||||||
@ConsoleExperimentalApi
|
|
||||||
public val isAnsiSupported: Boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,6 +83,9 @@ public open class AnsiMessageBuilder internal constructor(
|
|||||||
public companion object {
|
public companion object {
|
||||||
private val DROP_ANSI_PATTERN = """\u001b\[([0-9]+)(;[0-9]+)*m""".toRegex()
|
private val DROP_ANSI_PATTERN = """\u001b\[([0-9]+)(;[0-9]+)*m""".toRegex()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 [String] 中剔除 ansi 控制符
|
||||||
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
public fun String.dropAnsi(): String = DROP_ANSI_PATTERN.replace(this, "")
|
public fun String.dropAnsi(): String = DROP_ANSI_PATTERN.replace(this, "")
|
||||||
|
|
||||||
@ -107,6 +110,9 @@ public open class AnsiMessageBuilder internal constructor(
|
|||||||
noAnsi: Boolean = false
|
noAnsi: Boolean = false
|
||||||
): AnsiMessageBuilder = invoke(StringBuilder(capacity), noAnsi)
|
): AnsiMessageBuilder = invoke(StringBuilder(capacity), noAnsi)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断 [sender] 是否支持带 ansi 控制符的正确显示
|
||||||
|
*/
|
||||||
@ConsoleExperimentalApi
|
@ConsoleExperimentalApi
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
public fun isAnsiSupported(sender: CommandSender): Boolean =
|
public fun isAnsiSupported(sender: CommandSender): Boolean =
|
||||||
@ -114,6 +120,9 @@ public open class AnsiMessageBuilder internal constructor(
|
|||||||
MiraiConsoleImplementationBridge.isAnsiSupported
|
MiraiConsoleImplementationBridge.isAnsiSupported
|
||||||
} else false
|
} else false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 往 [StringBuilder] 追加 ansi 控制符
|
||||||
|
*/
|
||||||
public inline fun StringBuilder.appendAnsi(
|
public inline fun StringBuilder.appendAnsi(
|
||||||
noAnsi: Boolean = false,
|
noAnsi: Boolean = false,
|
||||||
action: AnsiMessageBuilder.() -> Unit
|
action: AnsiMessageBuilder.() -> Unit
|
||||||
@ -172,12 +181,23 @@ public open class AnsiMessageBuilder internal constructor(
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建一条 ansi 信息
|
||||||
|
*
|
||||||
|
* @see [AnsiMessageBuilder]
|
||||||
|
*/
|
||||||
public inline fun buildAnsiMessage(
|
public inline fun buildAnsiMessage(
|
||||||
capacity: Int = 16,
|
capacity: Int = 16,
|
||||||
action: AnsiMessageBuilder.() -> Unit
|
action: AnsiMessageBuilder.() -> Unit
|
||||||
): String = AnsiMessageBuilder(capacity, false).apply(action).toString()
|
): String = AnsiMessageBuilder(capacity, false).apply(action).toString()
|
||||||
|
|
||||||
// 不在 top-level 使用者会得到 Internal error: Couldn't inline sendAnsiMessage
|
// 不在 top-level 使用者会得到 Internal error: Couldn't inline sendAnsiMessage
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向 [CommandSender] 发送一条带有 ansi 控制符的信息
|
||||||
|
*
|
||||||
|
* @see [AnsiMessageBuilder]
|
||||||
|
*/
|
||||||
public suspend inline fun CommandSender.sendAnsiMessage(
|
public suspend inline fun CommandSender.sendAnsiMessage(
|
||||||
capacity: Int = 16,
|
capacity: Int = 16,
|
||||||
builder: AnsiMessageBuilder.() -> Unit
|
builder: AnsiMessageBuilder.() -> Unit
|
||||||
@ -189,6 +209,11 @@ public suspend inline fun CommandSender.sendAnsiMessage(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向 [CommandSender] 发送一条带有 ansi 控制符的信息
|
||||||
|
*
|
||||||
|
* @see [AnsiMessageBuilder.Companion.dropAnsi]
|
||||||
|
*/
|
||||||
public suspend inline fun CommandSender.sendAnsiMessage(message: String) {
|
public suspend inline fun CommandSender.sendAnsiMessage(message: String) {
|
||||||
sendMessage(
|
sendMessage(
|
||||||
if (AnsiMessageBuilder.isAnsiSupported(this))
|
if (AnsiMessageBuilder.isAnsiSupported(this))
|
||||||
|
Loading…
Reference in New Issue
Block a user