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 {
|
||||
if (ConsoleTerminalSettings.noConsole) return@run NoConsole
|
||||
|
||||
val dumb = System.getProperty("java.class.path")
|
||||
.contains("idea_rt.jar") || System.getProperty("mirai.idea") !== null || System.getenv("mirai.idea") !== null
|
||||
|
||||
runCatching {
|
||||
TerminalBuilder.builder()
|
||||
.dumb(dumb)
|
||||
.paused(true)
|
||||
.build()
|
||||
.let { terminal ->
|
||||
if (terminal is AbstractWindowsTerminal) {
|
||||
val pumpField = runCatching {
|
||||
AbstractWindowsTerminal::class.java.getDeclaredField("pump").also {
|
||||
it.isAccessible = true
|
||||
}
|
||||
}.onFailure { err ->
|
||||
err.printStackTrace()
|
||||
return@let terminal.also { it.resume() }
|
||||
}.getOrThrow()
|
||||
var response = terminal
|
||||
terminal.setOnClose {
|
||||
response = NoConsole
|
||||
TerminalBuilder.builder()
|
||||
.name("Mirai Console")
|
||||
.system(true)
|
||||
.jansi(true)
|
||||
.dumb(true)
|
||||
.paused(true)
|
||||
.build()
|
||||
.let { terminal ->
|
||||
if (terminal is AbstractWindowsTerminal) {
|
||||
val pumpField = runCatching {
|
||||
AbstractWindowsTerminal::class.java.getDeclaredField("pump").also {
|
||||
it.isAccessible = true
|
||||
}
|
||||
terminal.resume()
|
||||
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
|
||||
}.onFailure { err ->
|
||||
err.printStackTrace()
|
||||
return@let terminal.also { it.resume() }
|
||||
}.getOrThrow()
|
||||
var response = terminal
|
||||
terminal.setOnClose {
|
||||
response = NoConsole
|
||||
}
|
||||
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 {
|
||||
TerminalBuilder.builder()
|
||||
.jansi(true)
|
||||
.build()
|
||||
}.recoverCatching {
|
||||
TerminalBuilder.builder()
|
||||
.system(true)
|
||||
.build()
|
||||
}.getOrThrow()
|
||||
terminal.resume()
|
||||
terminal
|
||||
}
|
||||
}
|
||||
|
||||
private object ConsoleFrontEndDescImpl : MiraiConsoleFrontEndDescription {
|
||||
|
Loading…
Reference in New Issue
Block a user