Scoop API

scoop:scoop.terminal:0.1.0

src/cursor/appearance.scoop

Selected production source · src/cursor/appearance.scoop

1package scoop.terminal.cursor
3import scoop.terminal.Command
5/**
6 * Saves the current cursor position using the terminal's saved-position slot.
7 */
8public object SavePosition : Command {
9 /**
10 * Writes this command's ANSI representation to the supplied writer without flushing it.
11 * Parameter validation happens before or during serialization.
12 */
13 public override fun writeAnsi(writer: TextWriter) { writer.write("\u001b7") }
16/**
17 * Restores the cursor from the terminal's saved-position slot.
18 */
19public object RestorePosition : Command {
20 /**
21 * Writes this command's ANSI representation to the supplied writer without flushing it.
22 * Parameter validation happens before or during serialization.
23 */
24 public override fun writeAnsi(writer: TextWriter) { writer.write("\u001b8") }
27/**
28 * Requests that the terminal hide its cursor.
29 */
30public object Hide : Command {
31 /**
32 * Writes this command's ANSI representation to the supplied writer without flushing it.
33 * Parameter validation happens before or during serialization.
34 */
35 public override fun writeAnsi(writer: TextWriter) { writer.write("\u001b[?25l") }
38/**
39 * Requests that the terminal show its cursor.
40 */
41public object Show : Command {
42 /**
43 * Writes this command's ANSI representation to the supplied writer without flushing it.
44 * Parameter validation happens before or during serialization.
45 */
46 public override fun writeAnsi(writer: TextWriter) { writer.write("\u001b[?25h") }
49/**
50 * Enables cursor blinking where supported by the terminal.
51 */
52public object EnableBlinking : Command {
53 /**
54 * Writes this command's ANSI representation to the supplied writer without flushing it.
55 * Parameter validation happens before or during serialization.
56 */
57 public override fun writeAnsi(writer: TextWriter) { writer.write("\u001b[?12h") }
60/**
61 * Disables cursor blinking where supported by the terminal.
62 */
63public object DisableBlinking : Command {
64 /**
65 * Writes this command's ANSI representation to the supplied writer without flushing it.
66 * Parameter validation happens before or during serialization.
67 */
68 public override fun writeAnsi(writer: TextWriter) { writer.write("\u001b[?12l") }
71/**
72 * Selects the terminal cursor shape and blinking policy.
73 */
74public enum SetCursorStyle : Command {
75 /**
76 * Restores the user's default cursor shape.
77 */
78 DefaultUserShape,
79 /**
80 * Selects a blinking block cursor.
81 */
82 BlinkingBlock,
83 /**
84 * Selects a non-blinking block cursor.
85 */
86 SteadyBlock,
87 /**
88 * Selects a blinking underscore cursor.
89 */
90 BlinkingUnderScore,
91 /**
92 * Selects a non-blinking underscore cursor.
93 */
94 SteadyUnderScore,
95 /**
96 * Selects a blinking vertical-bar cursor.
97 */
98 BlinkingBar,
99 /**
100 * Selects a non-blinking vertical-bar cursor.
101 */
102 SteadyBar
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) {
109 val code = when (this) {
110 case DefaultUserShape -> "0"
111 case BlinkingBlock -> "1"
112 case SteadyBlock -> "2"
113 case BlinkingUnderScore -> "3"
114 case SteadyUnderScore -> "4"
115 case BlinkingBar -> "5"
116 case SteadyBar -> "6"
117 }
118 writer.write("\u001b[" + code + " q")
119 }