1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//! A simple crate to facilitate input and output within programs, with a set of macros.
//! Example:
//! ```
//! use quick_io::*;
//!
//! clear!();
//! addstr!("Input something: ");
//!
//! println!("You typed: {}.", getstr!());
//!
//! getstr!();
//!
//! down!(10);
//! right!(20);
//! addstr!("Went down 10 characters and right 20 characters");
//!
//! getstr!();
//!
//! addstr!(0, 10, "Moved to 0, 10 within addstr!");
//!
//! getstr!();
//!
//! mv!(0, 20);
//! addstr!("Moved to 0, 20 with mv!");
//!
//! getstr!();
//!
//! down!(20);
//! addln!("Press enter to clear this line.");
//!
//! getstr!();
//!
//! line_up!(2);
//! clear_line!();
//! line_down!(2);
//!
//! println!("Press enter to clear the entire screen.");
//!
//! getstr!();
//!
//! clear!();
//! ```
//! Copypaste this into a main.rs for a demonstration of the crate (rust playground doesn't support input for some reason?)
//! Note: Since this uses ANSI escape codes for clear!(), mv!(), etc. it may not work on some terminals/systems.
/// Moves the cursor to the specified location. Moves to top left corner (0, 0) if no arguments are
/// provided. If argument specified is out of bounds, it clamps it to be in bounds. I have no idea
/// what happens if you provide a number outside of the u16 limits.
/// Clears the entire screen.
/// Clears the line the cursor is on. Does not move it to the beginning of the line.
/// Moves the cursor up a specified amount of lines, and positions it at the start of that line.
/// If no arguments are given, defaults to 1.
/// Moves the cursor down a specified amount of lines, and positions it at the start of that line.
/// If no arguments are given, defaults to 1.
/// Moves the cusor up the specified amount of characters. If no arguments are given, defaults to
/// 1.
/// Moves the cusor down the specified amount of characters. If no arguments are given, defaults to
/// 1.
/// Moves the cusor right the specified amount of characters. If no arguments are given, defaults to
/// 1.
/// Moves the cusor left the specified amount of characters. If no arguments are given, defaults to
/// 1.
/// Adds a string at the cursor location, or at a specified location. Flushes buffer as well
/// (normally stdout is only flushed on newlines.)
/// Gets a string from stdin. Output trimmed.