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