Skip to content

Commit

Permalink
don't lowercase name, sd match explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
tuna-f1sh committed Jul 3, 2024
1 parent 1bb7170 commit 41c7286
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ One can also be supplied with `--config`. Copy or refer to './doc/cyme\_example\

See './doc/cyme\_example\_config.json' for an example of how icons can be defined and also the [docs](https://docs.rs/cyme/latest/cyme/icon/enum.Icon.html). The config can exclude the "user"/"colours" keys if one wishes not to define any new icons/colours.

Icons are looked up in an order of User -> Default. For devices: `VidPid` -> `VidPidMsb` -> `Vid` -> `UnknownVendor` -> `get_default_vidpid_icon`, classes: `ClassifierSubProtocol` -> `Classifier` -> `UndefinedClassifier` -> `get_default_classifier_icon`. User supplied colours override all internal; if a key is missing, it will be `None`.
Icons are looked up in an order of User -> Default. For devices: `Name` -> `VidPid` -> `VidPidMsb` -> `Vid` -> `UnknownVendor` -> `get_default_vidpid_icon`, classes: `ClassifierSubProtocol` -> `Classifier` -> `UndefinedClassifier` -> `get_default_classifier_icon`. User supplied colours override all internal; if a key is missing, it will be `None`.

#### Icons not Showing/Boxes with Question Marks

Expand Down
15 changes: 9 additions & 6 deletions src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ lazy_static! {
(Icon::Vid(0x1fc9), "\u{f2db}"), // nxp 
(Icon::Vid(0x1050), "\u{f084}"), // yubikey 
(Icon::Vid(0x0781), "\u{f129e}"), // sandisk 󱊞
(Icon::Name(r".*sd\scard\sreader.*".to_string()), "\u{ef61}"), // sd card reader 
(Icon::Name(r".*^[sS][dD]\s[cC]ard\s[rR]eader.*".to_string()), "\u{ef61}"), // sd card reader 
(Icon::VidPid((0x18D1, 0x2D05)), "\u{e70e}"), // android dev 
(Icon::VidPid((0x18D1, 0xd00d)), "\u{e70e}"), // android 
(Icon::VidPid((0x1d50, 0x606f)), "\u{f191d}"), // candlelight_fw gs_can 󱤝
Expand Down Expand Up @@ -445,7 +445,7 @@ impl IconTheme {
.iter()
.find(|(k, _)| {
if let Icon::Name(s) = k {
regex::Regex::new(s).map_or(false, |r| r.is_match(&name.to_lowercase()))
regex::Regex::new(s).map_or(false, |r| r.is_match(name))
} else {
false
}
Expand All @@ -462,7 +462,7 @@ impl IconTheme {
.iter()
.find(|(k, _)| {
if let Icon::Name(s) = k {
regex::Regex::new(s).map_or(false, |r| r.is_match(&name.to_lowercase()))
regex::Regex::new(s).map_or(false, |r| r.is_match(name))
} else {
false
}
Expand Down Expand Up @@ -511,7 +511,7 @@ pub fn example() -> HashMap<Icon, String> {
), // serial 
(Icon::UndefinedClassifier, "\u{2636}".into()), //☶
(
Icon::Name(r".*sd\scard\sreader.*".to_string()),
Icon::Name(r".*^[sS][dD]\s[cC]ard\s[rR]eader.*".to_string()),
"\u{ef61}".into(),
), // sd card reader 
])
Expand Down Expand Up @@ -622,8 +622,11 @@ mod tests {
let icon = Icon::from_str(str);
assert_eq!(icon.unwrap(), Icon::Name("test".to_string()));

let str = r"name#sd\s+card";
let str = r"name#.*^[sS][dD]\s[cC]ard\s[rR]eader.*";
let icon = Icon::from_str(str);
assert_eq!(icon.unwrap(), Icon::Name("sd\\s+card".to_string()));
assert_eq!(
icon.unwrap(),
Icon::Name(r".*^[sS][dD]\s[cC]ard\s[rR]eader.*".to_string())
);
}
}

0 comments on commit 41c7286

Please sign in to comment.