Scoop API

scoop:scoop.terminal:0.1.0

src/internal/platform/query.scoop

Selected production source · src/internal/platform/query.scoop

1package scoop.terminal.internal.platform
3import scoop.platform.memory.NativeByteBuffer
5internal 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 }
15internal class QueryRawScope(private val terminal: TerminalHandle): Closeable {
16 private val changed: Boolean = !terminal.isRaw
17 init {
18 if (changed)
19 terminal.setRaw(true)
20 }
21 public override fun close() {
22 if (changed)
23 terminal.setRaw(false)
24 }