mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
Multiply terminal selection
This commit is contained in:
parent
2fd7c6aec7
commit
6fc9adeb43
@ -26,9 +26,20 @@ internal object ConsoleUtils {
|
||||
val dumb = System.getProperty("java.class.path")
|
||||
.contains("idea_rt.jar") || System.getProperty("mirai.idea") !== null || System.getenv("mirai.idea") !== null
|
||||
|
||||
terminal = TerminalBuilder.builder()
|
||||
.jansi(true)
|
||||
.build()
|
||||
terminal = kotlin.runCatching {
|
||||
TerminalBuilder.builder()
|
||||
.dumb(dumb)
|
||||
.build()
|
||||
}.recoverCatching {
|
||||
TerminalBuilder.builder()
|
||||
.jansi(true)
|
||||
.build()
|
||||
}.recoverCatching {
|
||||
TerminalBuilder.builder()
|
||||
.system(true)
|
||||
.build()
|
||||
}.getOrThrow()
|
||||
|
||||
lineReader = LineReaderBuilder.builder()
|
||||
.terminal(terminal)
|
||||
.completer(NullCompleter())
|
||||
|
@ -22,7 +22,8 @@ package net.mamoe.mirai.console.pure
|
||||
|
||||
//import net.mamoe.mirai.console.command.CommandManager
|
||||
//import net.mamoe.mirai.console.utils.MiraiConsoleFrontEnd
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.console.MiraiConsoleBuildConstants
|
||||
import net.mamoe.mirai.console.MiraiConsoleFrontEnd
|
||||
@ -35,7 +36,6 @@ import org.fusesource.jansi.Ansi
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
private val ANSI_RESET = Ansi().reset().toString()
|
||||
|
||||
@ -99,8 +99,8 @@ object MiraiConsoleFrontEndPure : MiraiConsoleFrontEnd {
|
||||
.toString()
|
||||
)
|
||||
}
|
||||
return suspendCancellableCoroutine {
|
||||
it.resume(ConsoleUtils.lineReader.readLine("> "))
|
||||
return withContext(Dispatchers.IO) {
|
||||
ConsoleUtils.lineReader.readLine("> ")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user