* Messages now grow from the top to the bottom(new messages ontop)
+ Option to enable/disable message-box borders * Switching over to using bold! macro where applicable (especially in command.rs) This change mostly reduces the eyesoreness of the termion code
This commit is contained in:
parent
6fff48cfab
commit
a098121ab8
@ -1,3 +1,4 @@
|
|||||||
|
use crate::{bold, normal};
|
||||||
use tui::text::{Span, Spans};
|
use tui::text::{Span, Spans};
|
||||||
use tui::style::{Style, Modifier};
|
use tui::style::{Style, Modifier};
|
||||||
|
|
||||||
@ -7,6 +8,9 @@ pub enum Command {
|
|||||||
Channel(u64),
|
Channel(u64),
|
||||||
// Choose server based on hostname
|
// Choose server based on hostname
|
||||||
Server(String),
|
Server(String),
|
||||||
|
// List out available hosts
|
||||||
|
ListHost,
|
||||||
|
Text(String),
|
||||||
// Send regular message
|
// Send regular message
|
||||||
Message(String),
|
Message(String),
|
||||||
// Command that failed with some message
|
// Command that failed with some message
|
||||||
@ -43,6 +47,7 @@ impl Command {
|
|||||||
|
|
||||||
pub fn from(s: String) -> Command {
|
pub fn from(s: String) -> Command {
|
||||||
let s = s.trim();
|
let s = s.trim();
|
||||||
|
// NOTE: could probably do this smarter but a handful of string comparisons is fine too
|
||||||
if s.starts_with("/chan") {
|
if s.starts_with("/chan") {
|
||||||
match Command::parse_chan_id(s.as_ref()) {
|
match Command::parse_chan_id(s.as_ref()) {
|
||||||
Some(id) => Command::Channel(id),
|
Some(id) => Command::Channel(id),
|
||||||
@ -55,6 +60,8 @@ impl Command {
|
|||||||
}
|
}
|
||||||
} else if s.starts_with("/help") {
|
} else if s.starts_with("/help") {
|
||||||
Command::Help
|
Command::Help
|
||||||
|
} else if s.starts_with("/lh") {
|
||||||
|
Command::ListHost
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if s.starts_with("/") {
|
if s.starts_with("/") {
|
||||||
@ -68,26 +75,26 @@ impl Command {
|
|||||||
pub fn styled(&self) -> Spans {
|
pub fn styled(&self) -> Spans {
|
||||||
use Command::*;
|
use Command::*;
|
||||||
return match self {
|
return match self {
|
||||||
Help => Spans::from(vec![
|
Help => Spans::from(bold!("! /help ! /channel <u64> ! /server <u64>")),
|
||||||
Span::styled("! /help\n", Style::default().add_modifier(Modifier::BOLD)),
|
Text(s) => Spans::from(vec![normal!(s)]),
|
||||||
Span::styled("! /channel <u64>", Style::default().add_modifier(Modifier::BOLD)),
|
|
||||||
Span::styled("! /server <u64>", Style::default().add_modifier(Modifier::BOLD)),
|
|
||||||
]),
|
|
||||||
Channel(id) => Spans::from(vec![
|
Channel(id) => Spans::from(vec![
|
||||||
Span::styled(format!("! /channel "), Style::default().add_modifier(Modifier::BOLD)),
|
bold!("! /channel "),
|
||||||
Span::raw(format!("{}", id)),
|
normal!(format!("{}", id)),
|
||||||
]),
|
]),
|
||||||
Server(hostname) => Spans::from(vec![
|
Server(hostname) => Spans::from(vec![
|
||||||
Span::styled("! /server ", Style::default().add_modifier(Modifier::BOLD)),
|
bold!("! /server "),
|
||||||
Span::raw(hostname)
|
normal!(hostname)
|
||||||
|
]),
|
||||||
|
ListHost => Spans::from(vec![
|
||||||
|
bold!("! /lh"),
|
||||||
]),
|
]),
|
||||||
Message(msg) => Spans::from(vec![
|
Message(msg) => Spans::from(vec![
|
||||||
Span::styled("(You) ", Style::default().add_modifier(Modifier::BOLD)),
|
bold!("(You) "),
|
||||||
Span::raw(msg)
|
normal!(msg)
|
||||||
]),
|
]),
|
||||||
Failure(msg) => Spans::from(vec![
|
Failure(msg) => Spans::from(vec![
|
||||||
Span::styled("! error ", Style::default().add_modifier(Modifier::BOLD)),
|
bold!("! error "),
|
||||||
Span::raw(msg)
|
normal!(msg)
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user