From f677516a70ad3ff64f0c2ee2faa3e79a4865cd09 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Fri, 11 Sep 2020 20:02:51 +0800 Subject: [PATCH] Review: Incoming stream should only `\n` coming. --- .../mirai/console/pure/noconsole/NoConsole.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/noconsole/NoConsole.kt b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/noconsole/NoConsole.kt index c42aef863..8d3350fd0 100644 --- a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/noconsole/NoConsole.kt +++ b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/noconsole/NoConsole.kt @@ -30,12 +30,12 @@ import java.io.InputStream import java.io.OutputStream import java.io.PrintWriter -private const val SPACE_INT = ' '.toInt() -private const val SPACE_BYTE = ' '.toByte() +private const val LN_INT = '\n'.toInt() +private const val LN_BYTE = '\n'.toByte() internal object NoNonBlockingReader : NonBlockingReader() { override fun read(timeout: Long, isPeek: Boolean): Int { - return SPACE_INT + return LN_INT } override fun close() { @@ -46,9 +46,9 @@ internal object NoNonBlockingReader : NonBlockingReader() { } } -internal object AllSpaceInputStream : InputStream() { +internal object AllNextLineInputStream : InputStream() { override fun read(): Int { - return SPACE_INT + return LN_INT } override fun available(): Int { @@ -57,7 +57,7 @@ internal object AllSpaceInputStream : InputStream() { override fun read(b: ByteArray, off: Int, len: Int): Int { for (i in off until (off + len)) { - b[i] = SPACE_BYTE + b[i] = LN_BYTE } return len } @@ -219,7 +219,7 @@ internal object NoConsole : AbstractTerminal( // We don't need it. Mirai-Console using LineReader to print messages. override fun writer(): PrintWriter = AllIgnoredPrintWriter - override fun input(): InputStream = AllSpaceInputStream + override fun input(): InputStream = AllNextLineInputStream override fun output(): OutputStream = AllIgnoredOutputStream private val attributes0 = Attributes()