aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-04-09 03:07:48 -0500
committerJesse Luehrs <doy@tozt.net>2013-04-09 03:07:48 -0500
commitc881c744b38932d3d96a0fcec9deb81ca4d25fcb (patch)
tree7216b9ea0ab8eef96900e0b8fa788f5f6d931def
parent9289b18119a0b8636a014a396bd0b2174ee49e3a (diff)
downloadrust-term-c881c744b38932d3d96a0fcec9deb81ca4d25fcb.tar.gz
rust-term-c881c744b38932d3d96a0fcec9deb81ca4d25fcb.zip
apparently ::new is the convention these days
-rw-r--r--src/hexes.rs61
-rw-r--r--test/rl.rs2
2 files changed, 32 insertions, 31 deletions
diff --git a/src/hexes.rs b/src/hexes.rs
index 4de2f12..01d4c65 100644
--- a/src/hexes.rs
+++ b/src/hexes.rs
@@ -28,32 +28,33 @@ struct Term {
priv w: Writer,
}
-/**
- * Creates a new `Term` instance.
- *
- * This can be used to manipulate the terminal for full screen applications.
- */
-pub fn Term () -> Term {
- info::init();
-
- cbreak();
- echo(false);
-
- // XXX need to come up with a better way to handle optional caps
- // should be able to use something like has_keypad_xmit or something
- for ["smkx", "smcup", "sgr0", "cnorm"].each() |&cap| {
- match info::escape(cap) {
- Some(e) => print(e),
- None => (), // not a big deal if these don't exist
+impl Term {
+ /**
+ * Creates a new `Term` instance.
+ *
+ * This can be used to manipulate the terminal for full screen
+ * applications.
+ */
+ pub fn new () -> Term {
+ info::init();
+
+ cbreak();
+ echo(false);
+
+ // XXX need to come up with a better way to handle optional caps
+ // should be able to use something like has_keypad_xmit or something
+ for ["smkx", "smcup", "sgr0", "cnorm"].each() |&cap| {
+ match info::escape(cap) {
+ Some(e) => print(e),
+ None => (), // not a big deal if these don't exist
+ }
}
- }
- print(info::clear_screen());
+ print(info::clear_screen());
- Term { r: Reader(), w: Writer() }
-}
+ Term { r: Reader::new(), w: Writer::new() }
+ }
-impl Term {
/// Clears the screen.
pub fn clear (&mut self) {
self.w.clear();
@@ -196,10 +197,6 @@ struct AttrState {
blink: bool,
}
-fn Writer () -> Writer {
- Writer { buf: ~"", state: AttrState() }
-}
-
fn AttrState () -> AttrState {
AttrState {
fg: None,
@@ -213,6 +210,10 @@ fn AttrState () -> AttrState {
}
impl Writer {
+ fn new () -> Writer {
+ Writer { buf: ~"", state: AttrState() }
+ }
+
fn clear (&mut self) {
self.buf.push_str(info::clear_screen());
}
@@ -378,11 +379,11 @@ struct Reader {
priv buf: ~str,
}
-fn Reader () -> Reader {
- Reader { escapes: build_escapes_trie(), buf: ~"" }
-}
-
impl Reader {
+ fn new () -> Reader {
+ Reader { escapes: build_escapes_trie(), buf: ~"" }
+ }
+
fn read (&mut self) -> Option<Keypress> {
if self.buf.len() > 0 {
return Some(self.next_key());
diff --git a/test/rl.rs b/test/rl.rs
index 8771056..7ba3cd0 100644
--- a/test/rl.rs
+++ b/test/rl.rs
@@ -40,7 +40,7 @@ fn main () {
let (cols, rows) = term::ios::size();
{
- let mut term = Term();
+ let mut term = Term::new();
let mut (x, y) = (0u, 0u);
let mut cursor = true;