mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 10:30:13 +08:00
Suppress jline warning
This commit is contained in:
parent
77b38a9ba3
commit
1c7ebe2413
@ -103,48 +103,38 @@ val lineReader: LineReader by lazy {
|
|||||||
val terminal: Terminal = run {
|
val terminal: Terminal = run {
|
||||||
if (ConsoleTerminalSettings.noConsole) return@run NoConsole
|
if (ConsoleTerminalSettings.noConsole) return@run NoConsole
|
||||||
|
|
||||||
val dumb = System.getProperty("java.class.path")
|
TerminalBuilder.builder()
|
||||||
.contains("idea_rt.jar") || System.getProperty("mirai.idea") !== null || System.getenv("mirai.idea") !== null
|
.name("Mirai Console")
|
||||||
|
.system(true)
|
||||||
runCatching {
|
.jansi(true)
|
||||||
TerminalBuilder.builder()
|
.dumb(true)
|
||||||
.dumb(dumb)
|
.paused(true)
|
||||||
.paused(true)
|
.build()
|
||||||
.build()
|
.let { terminal ->
|
||||||
.let { terminal ->
|
if (terminal is AbstractWindowsTerminal) {
|
||||||
if (terminal is AbstractWindowsTerminal) {
|
val pumpField = runCatching {
|
||||||
val pumpField = runCatching {
|
AbstractWindowsTerminal::class.java.getDeclaredField("pump").also {
|
||||||
AbstractWindowsTerminal::class.java.getDeclaredField("pump").also {
|
it.isAccessible = true
|
||||||
it.isAccessible = true
|
|
||||||
}
|
|
||||||
}.onFailure { err ->
|
|
||||||
err.printStackTrace()
|
|
||||||
return@let terminal.also { it.resume() }
|
|
||||||
}.getOrThrow()
|
|
||||||
var response = terminal
|
|
||||||
terminal.setOnClose {
|
|
||||||
response = NoConsole
|
|
||||||
}
|
}
|
||||||
terminal.resume()
|
}.onFailure { err ->
|
||||||
val pumpThread = pumpField[terminal] as? Thread ?: return@let NoConsole
|
err.printStackTrace()
|
||||||
@Suppress("ControlFlowWithEmptyBody")
|
return@let terminal.also { it.resume() }
|
||||||
while (pumpThread.state == Thread.State.NEW);
|
}.getOrThrow()
|
||||||
Thread.sleep(1000)
|
var response = terminal
|
||||||
terminal.setOnClose(null)
|
terminal.setOnClose {
|
||||||
return@let response
|
response = NoConsole
|
||||||
}
|
}
|
||||||
terminal.resume()
|
terminal.resume()
|
||||||
terminal
|
val pumpThread = pumpField[terminal] as? Thread ?: return@let NoConsole
|
||||||
|
@Suppress("ControlFlowWithEmptyBody")
|
||||||
|
while (pumpThread.state == Thread.State.NEW);
|
||||||
|
Thread.sleep(1000)
|
||||||
|
terminal.setOnClose(null)
|
||||||
|
return@let response
|
||||||
}
|
}
|
||||||
}.recoverCatching {
|
terminal.resume()
|
||||||
TerminalBuilder.builder()
|
terminal
|
||||||
.jansi(true)
|
}
|
||||||
.build()
|
|
||||||
}.recoverCatching {
|
|
||||||
TerminalBuilder.builder()
|
|
||||||
.system(true)
|
|
||||||
.build()
|
|
||||||
}.getOrThrow()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private object ConsoleFrontEndDescImpl : MiraiConsoleFrontEndDescription {
|
private object ConsoleFrontEndDescImpl : MiraiConsoleFrontEndDescription {
|
||||||
|
Loading…
Reference in New Issue
Block a user