aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-09 16:51:15 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-09 16:51:15 -0500
commitc02cd7278b23ed0423f8c798a939aff05b69039c (patch)
treebd55efc8300de8068cf4f115bad63f4e1c6ec7e1
parentd3250dbffd9bc64efc5592a8e12578b740a84257 (diff)
downloadtextmode-c02cd7278b23ed0423f8c798a939aff05b69039c.tar.gz
textmode-c02cd7278b23ed0423f8c798a939aff05b69039c.zip
add function to hide or show the cursor
-rw-r--r--CHANGELOG.md6
-rw-r--r--src/lib.rs9
2 files changed, 15 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 02f953f..61a02ee 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+## [Unreleased]
+
+### Added
+
+* `hide_cursor` to hide or show the cursor
+
## [0.2.2] - 2021-12-06
### Changed
diff --git a/src/lib.rs b/src/lib.rs
index 67c0676..6c515c6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -265,4 +265,13 @@ pub trait Textmode: private::Output {
self.write(b"\x1b[27m");
}
}
+
+ /// Sets whether the cursor should be visible.
+ fn hide_cursor(&mut self, hide: bool) {
+ if hide {
+ self.write(b"\x1b[?25l");
+ } else {
+ self.write(b"\x1b[?25h");
+ }
+ }
}