scoop:scoop.terminal:0.1.0
src/cursor/movement.scoop
Selected production source · src/cursor/movement.scoop
1
package scoop.terminal.cursor3
import scoop.terminal.Command4
import scoop.terminal.requireTerminalParameter5
import scoop.terminal.writeCsiParameter7
/**8
* Moves to a zero-based column and row. Both coordinates must be in 0..65535; ANSI output converts9
* them to one-based positions.10
*/11
public struct MoveTo(val column: Long, val row: Long) : Command {12
/**13
* Writes this command's ANSI representation to the supplied writer without flushing it.14
* Parameter validation happens before or during serialization.15
*/16
public override fun writeAnsi(writer: TextWriter) {17
requireTerminalParameter(column)18
requireTerminalParameter(row)19
writer.write("\u001b[" + (row + 1L).toString() + ";" + (column + 1L).toString() + "H")20
}21
}23
/**24
* Moves to a zero-based column in 0..65535 while retaining the row.25
*/26
public struct MoveToColumn(val column: Long) : Command {27
/**28
* Writes this command's ANSI representation to the supplied writer without flushing it.29
* Parameter validation happens before or during serialization.30
*/31
public override fun writeAnsi(writer: TextWriter) {32
requireTerminalParameter(column)33
writer.write("\u001b[" + (column + 1L).toString() + "G")34
}35
}37
/**38
* Moves to a zero-based row in 0..65535 while retaining the column.39
*/40
public struct MoveToRow(val row: Long) : Command {41
/**42
* Writes this command's ANSI representation to the supplied writer without flushing it.43
* Parameter validation happens before or during serialization.44
*/45
public override fun writeAnsi(writer: TextWriter) {46
requireTerminalParameter(row)47
writer.write("\u001b[" + (row + 1L).toString() + "d")48
}49
}51
/**52
* Moves the cursor up by the supplied count. The ANSI parameter must be in 0..65535; the terminal53
* interprets zero according to its command rules.54
*/55
public struct MoveUp(val count: Long) : Command {56
/**57
* Writes this command's ANSI representation to the supplied writer without flushing it.58
* Parameter validation happens before or during serialization.59
*/60
public override fun writeAnsi(writer: TextWriter) { writeCsiParameter(writer, count, "A") }61
}63
/**64
* Moves the cursor down by the supplied count. The ANSI parameter must be in 0..65535; the65
* terminal interprets zero according to its command rules.66
*/67
public struct MoveDown(val count: Long) : Command {68
/**69
* Writes this command's ANSI representation to the supplied writer without flushing it.70
* Parameter validation happens before or during serialization.71
*/72
public override fun writeAnsi(writer: TextWriter) { writeCsiParameter(writer, count, "B") }73
}75
/**76
* Moves the cursor right by the supplied count. The ANSI parameter must be in 0..65535; the77
* terminal interprets zero according to its command rules.78
*/79
public struct MoveRight(val count: Long) : Command {80
/**81
* Writes this command's ANSI representation to the supplied writer without flushing it.82
* Parameter validation happens before or during serialization.83
*/84
public override fun writeAnsi(writer: TextWriter) { writeCsiParameter(writer, count, "C") }85
}87
/**88
* Moves the cursor left by the supplied count. The ANSI parameter must be in 0..65535; the89
* terminal interprets zero according to its command rules.90
*/91
public struct MoveLeft(val count: Long) : Command {92
/**93
* Writes this command's ANSI representation to the supplied writer without flushing it.94
* Parameter validation happens before or during serialization.95
*/96
public override fun writeAnsi(writer: TextWriter) { writeCsiParameter(writer, count, "D") }97
}99
/**100
* Moves the cursor to the start of following lines by the supplied count. The ANSI parameter must101
* be in 0..65535; the terminal interprets zero according to its command rules.102
*/103
public struct MoveToNextLine(val count: Long) : Command {104
/**105
* Writes this command's ANSI representation to the supplied writer without flushing it.106
* Parameter validation happens before or during serialization.107
*/108
public override fun writeAnsi(writer: TextWriter) { writeCsiParameter(writer, count, "E") }109
}111
/**112
* Moves the cursor to the start of preceding lines by the supplied count. The ANSI parameter must113
* be in 0..65535; the terminal interprets zero according to its command rules.114
*/115
public struct MoveToPreviousLine(val count: Long) : Command {116
/**117
* Writes this command's ANSI representation to the supplied writer without flushing it.118
* Parameter validation happens before or during serialization.119
*/120
public override fun writeAnsi(writer: TextWriter) { writeCsiParameter(writer, count, "F") }121
}