scoop:scoop.terminal:0.1.0
src/internal/platform/query.scoop
Selected production source · src/internal/platform/query.scoop
1
package scoop.terminal.internal.platform3
import scoop.platform.memory.NativeByteBuffer5
internal fun TerminalHandle.sendQuery(command: String) {6
val bytes = command.toByteArray()7
NativeByteBuffer.allocate(bytes.size).use {8
buffer ->9
buffer.writeBytes(bytes)10
while (buffer.readableBytes > 0L)11
write(buffer, buffer.readableBytes)12
}13
}15
internal class QueryRawScope(private val terminal: TerminalHandle): Closeable {16
private val changed: Boolean = !terminal.isRaw17
init {18
if (changed)19
terminal.setRaw(true)20
}21
public override fun close() {22
if (changed)23
terminal.setRaw(false)24
}25
}