2
0
mirror of https://github.com/xvxx/phetch synced 2024-11-10 13:10:54 +00:00

don't try to open unsupported types

This commit is contained in:
dvkt 2019-12-27 11:42:49 -08:00
parent dd8aeeb569
commit a48bfbc4fa
2 changed files with 9 additions and 1 deletions

View File

@ -53,6 +53,13 @@ impl Type {
} }
impl Type { impl Type {
pub fn is_supported(self) -> bool {
match self {
Type::CSOEntity | Type::Mirror | Type::Telnet3270 => false,
_ => true,
}
}
pub fn to_char(self) -> Option<char> { pub fn to_char(self) -> Option<char> {
Some(match self { Some(match self {
Type::Text => '0', Type::Text => '0',

View File

@ -167,8 +167,8 @@ impl Menu {
Type::HTML => push!("92", name), Type::HTML => push!("92", name),
Type::Error => push!("91", name), Type::Error => push!("91", name),
Type::Telnet => push!("4;97;90", name), Type::Telnet => push!("4;97;90", name),
Type::Telnet3270 | Type::Mirror | Type::CSOEntity => push!("107;30", name),
typ if typ.is_download() => push!("4;97", name), typ if typ.is_download() => push!("4;97", name),
typ if !typ.is_supported() => push!("107;91", name),
_ => push!("0", name), _ => push!("0", name),
} }
out.push('\n'); out.push('\n');
@ -503,6 +503,7 @@ impl Menu {
} }
Type::Error => Action::Error(line.name.to_string()), Type::Error => Action::Error(line.name.to_string()),
Type::Telnet => Action::Error("Telnet support coming soon".into()), Type::Telnet => Action::Error("Telnet support coming soon".into()),
t if !t.is_supported() => Action::Error(format!("{:?} not supported", t)),
_ => Action::Open(line.name.to_string(), url), _ => Action::Open(line.name.to_string(), url),
} }
} else { } else {