summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlara Modin <klarasmodin@gmail.com>2022-06-20 20:25:12 +0200
committerKlara Modin <klarasmodin@gmail.com>2022-06-20 20:25:12 +0200
commitadc7fe26cfdeb0e282a79642f20c90980d3eab6c (patch)
tree7be13633edb846cefe6756f90e7b9a2559dd5220
parent55239cb09d27bc77553dc0f243f655896b64b03a (diff)
eliminate some more muts
-rw-r--r--src/ui.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/ui.rs b/src/ui.rs
index 458b3d8..89f6fb7 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -46,6 +46,12 @@ impl UI {
(y, x)
}
+ fn getyx_tup() -> (i32, i32) {
+ let (mut y, mut x) = (0, 0);
+ getyx(stdscr(), &mut y, &mut x);
+ (y, x)
+ }
+
pub fn nick(&mut self, nick: &str) {
self.nick = format!("[{}] ", nick);
let (max_y, max_x) = UI::getmaxyx_tup();
@@ -57,9 +63,7 @@ impl UI {
}
pub fn chan(&mut self, chan: &str) {
- let mut x = 0;
- let mut y = 0;
- getyx(stdscr(), &mut y, &mut x);
+ let (y, x) = UI::getyx_tup();
mv(0, 0);
for i in 0..self.chan.len() {
printw(" ");
@@ -128,9 +132,6 @@ impl UI {
}
fn getstr_unblocking(&mut self) -> Option<String> {
- let mut new_x = 0;
- let mut new_y = 0;
- getyx(stdscr(), &mut new_y, &mut new_x);
while let input = getch() {
if let Some(ch) = char::from_u32(input as u32) {
match ch {
@@ -145,9 +146,7 @@ impl UI {
self.buffer.pop();
mv(self.input_y, self.input_x);
printw(&self.buffer);
- let mut new_x = 0;
- let mut new_y = 0;
- getyx(stdscr(), &mut new_y, &mut new_x);
+ let (new_y, new_x) = UI::getyx_tup();
printw(" ");
mv(new_y, new_x);
}