summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server_int.rs2
-rw-r--r--src/ui.rs8
-rw-r--r--src/user_int.rs22
3 files changed, 18 insertions, 14 deletions
diff --git a/src/server_int.rs b/src/server_int.rs
index b7bd7d6..b5077db 100644
--- a/src/server_int.rs
+++ b/src/server_int.rs
@@ -97,7 +97,7 @@ impl Message {
pub fn to_string(&self) -> String {
let mut message = String::new();
- if let &Some(ref prefix) = &self.prefix {
+ if let Some(ref prefix) = self.prefix {
message.push(':');
message.push_str(&prefix.clone());
message.push(' ');
diff --git a/src/ui.rs b/src/ui.rs
index 55f632e..fb2cecd 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -103,7 +103,7 @@ impl UI {
getyx(stdscr(), &mut self.input_y, &mut self.input_x);
{
let mut chars = self.buffer.chars();
- while chars.as_str().len() > max_x as usize - self.nick.len() {
+ while chars.as_str().len() > max_x as usize - self.nick.len() - 1 {
chars.next();
}
mv(max_y-1, self.input_x);
@@ -199,9 +199,9 @@ impl UI {
let prefix = message.prefix.clone().unwrap_or(String::new());
let mut iter = prefix.split("!");
let nick = iter.next().unwrap_or("");
- //let context = &message.params[0];
- let content = &message.params[1];
- self.put_str(&format!("<{}> {}\n", nick, content));
+ if let Some(content) = message.params.get(1) {
+ self.put_str(&format!("<{}> {}\n", nick, content));
+ }
},
_ => {
/*
diff --git a/src/user_int.rs b/src/user_int.rs
index 71349e9..7832913 100644
--- a/src/user_int.rs
+++ b/src/user_int.rs
@@ -156,15 +156,19 @@ impl Session {
},
"MSG" => {
m.command = "PRIVMSG".to_string();
- m.params = vec![m.params[0].clone(),
- m.params.iter().skip(1).fold(String::new(), |acc, x| {
- let mut ret = String::new();
- ret.push_str(&acc);
- ret.push_str(&x);
- ret.push(' ');
- ret
- })];
- Some(m)
+ let old = m.params;
+ if let Some(to) = old.get(0) {
+ m.params = vec![to.to_string(),
+ old.iter().skip(1).fold(String::new(), |acc, x| {
+ let mut ret = String::new();
+ ret.push_str(&acc);
+ ret.push_str(&x);
+ ret.push(' ');
+ ret
+ })];
+ return Some(m);
+ }
+ None
},
"" => None,
_ => Some(m),