Multiply terminal selection

This commit is contained in:
Him188 2020-06-29 16:17:50 +08:00
parent 2fd7c6aec7
commit 6fc9adeb43
2 changed files with 18 additions and 7 deletions

View File

@ -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())

View File

@ -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("> ")
}
}