Commit d1bdb378c1
Unregistered key
Layout: unified · split
config.example.toml +1
| @@ -10,6 +10,7 @@ default_markup = "html" | ||
| 10 | 10 | default_room = "#iamb-users:0x.badd.cafe" |
| 11 | 11 | default_split = "vertical" |
| 12 | 12 | external_edit_file_suffix = ".md" |
| 13 | ignorecase = false | |
| 13 | 14 | log_level = "warn" |
| 14 | 15 | members_split = "vertical" |
| 15 | 16 | message_shortcode_display = false |
docs/iamb.5 +2
| @@ -164,6 +164,8 @@ Suffix to append to temporary file names when using the :editor command. Default | ||
| 164 | 164 | Subsection for configuring image previews. See |
| 165 | 165 | .Sx "IMAGE PREVIEWS" |
| 166 | 166 | for more details. |
| 167 | .It Sy ignorecase | |
| 168 | Defines whether searches ignore case. Defaults to false. | |
| 167 | 169 | .It Sy log_level |
| 168 | 170 | Specifies the lowest log level that should be shown. |
| 169 | 171 | Possible values are: |
src/config.rs +4
| @@ -815,6 +815,7 @@ pub struct TerminalValues { | ||
| 815 | 815 | pub struct TunableValues { |
| 816 | 816 | pub encryption: EncryptionValues, |
| 817 | 817 | pub default_markup: MarkupFormat, |
| 818 | pub ignorecase: bool, | |
| 818 | 819 | pub log_level: String, |
| 819 | 820 | pub max_log_files: usize, |
| 820 | 821 | pub message_shortcode_display: bool, |
| @@ -869,6 +870,7 @@ pub struct Tunables { | ||
| 869 | 870 | pub users: Option<UserOverrides>, |
| 870 | 871 | |
| 871 | 872 | pub default_markup: Option<MarkupFormat>, |
| 873 | pub ignorecase: Option<bool>, | |
| 872 | 874 | pub log_level: Option<String>, |
| 873 | 875 | pub max_log_files: Option<usize>, |
| 874 | 876 | pub message_shortcode_display: Option<bool>, |
| @@ -912,6 +914,7 @@ impl Tunables { | ||
| 912 | 914 | proxy: self.proxy.or(other.proxy), |
| 913 | 915 | |
| 914 | 916 | default_markup: self.default_markup.or(other.default_markup), |
| 917 | ignorecase: self.ignorecase.or(other.ignorecase), | |
| 915 | 918 | log_level: self.log_level.or(other.log_level), |
| 916 | 919 | max_log_files: self.max_log_files.or(other.max_log_files), |
| 917 | 920 | message_shortcode_display: self |
| @@ -958,6 +961,7 @@ impl Tunables { | ||
| 958 | 961 | |
| 959 | 962 | default_markup: self.default_markup.unwrap_or_default(), |
| 960 | 963 | log_level: self.log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL.to_owned()), |
| 964 | ignorecase: self.ignorecase.unwrap_or(false), | |
| 961 | 965 | max_log_files: self.max_log_files.unwrap_or(7), |
| 962 | 966 | message_shortcode_display: self.message_shortcode_display.unwrap_or(false), |
| 963 | 967 | normal_after_send: self.normal_after_send.unwrap_or(false), |
src/tests.rs +1
| @@ -167,6 +167,7 @@ pub fn mock_dirs() -> DirectoryValues { | ||
| 167 | 167 | pub fn mock_tunables() -> TunableValues { |
| 168 | 168 | TunableValues { |
| 169 | 169 | default_markup: Default::default(), |
| 170 | ignorecase: false, | |
| 170 | 171 | default_room: None, |
| 171 | 172 | encryption: Encryption::default().values(), |
| 172 | 173 | log_level: "warn".into(), |
src/util.rs +19
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | //! # Utility functions |
| 2 | 2 | use std::borrow::Cow; |
| 3 | 3 | |
| 4 | use regex::{Regex, RegexBuilder}; | |
| 4 | 5 | use unicode_segmentation::UnicodeSegmentation; |
| 5 | 6 | use unicode_width::UnicodeWidthStr; |
| 6 | 7 | |
| @@ -182,10 +183,28 @@ pub fn replace_emojis_in_line(line: &mut Line) { | ||
| 182 | 183 | } |
| 183 | 184 | } |
| 184 | 185 | |
| 186 | /// Compile a search pattern, optionally ignoring case. | |
| 187 | pub fn compile_search(pattern: &str, case_insensitive: bool) -> Result<Regex, regex::Error> { | |
| 188 | RegexBuilder::new(pattern).case_insensitive(case_insensitive).build() | |
| 189 | } | |
| 190 | ||
| 185 | 191 | #[cfg(test)] |
| 186 | 192 | pub mod tests { |
| 187 | 193 | use super::*; |
| 188 | 194 | |
| 195 | #[test] | |
| 196 | fn test_compile_search_case_insensitive() { | |
| 197 | let re = compile_search("chicken", true).unwrap(); | |
| 198 | assert!(re.is_match("CHICKEN")); | |
| 199 | assert!(re.is_match("Chicken")); | |
| 200 | assert!(re.is_match("chicken")); | |
| 201 | ||
| 202 | let re = compile_search("chicken", false).unwrap(); | |
| 203 | assert!(!re.is_match("CHICKEN")); | |
| 204 | assert!(!re.is_match("Chicken")); | |
| 205 | assert!(re.is_match("chicken")); | |
| 206 | } | |
| 207 | ||
| 189 | 208 | #[test] |
| 190 | 209 | fn test_wrapped_lines_ascii() { |
| 191 | 210 | let s = "hello world!\nabcdefghijklmnopqrstuvwxyz\ngoodbye"; |
src/windows/mod.rs +9
| @@ -584,6 +584,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 584 | 584 | items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator)); |
| 585 | 585 | |
| 586 | 586 | state.set(items); |
| 587 | state.set_ignorecase(store.application.settings.tunables.ignorecase); | |
| 587 | 588 | |
| 588 | 589 | List::new(store) |
| 589 | 590 | .empty_message("No direct messages yet!") |
| @@ -608,6 +609,8 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 608 | 609 | *last_fetch = Some(Instant::now()); |
| 609 | 610 | } |
| 610 | 611 | |
| 612 | state.set_ignorecase(store.application.settings.tunables.ignorecase); | |
| 613 | ||
| 611 | 614 | List::new(store) |
| 612 | 615 | .empty_message("No users here yet!") |
| 613 | 616 | .empty_alignment(Alignment::Center) |
| @@ -628,6 +631,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 628 | 631 | items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator)); |
| 629 | 632 | |
| 630 | 633 | state.set(items); |
| 634 | state.set_ignorecase(store.application.settings.tunables.ignorecase); | |
| 631 | 635 | |
| 632 | 636 | List::new(store) |
| 633 | 637 | .empty_message("You haven't joined any rooms yet") |
| @@ -660,6 +664,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 660 | 664 | items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator)); |
| 661 | 665 | |
| 662 | 666 | state.set(items); |
| 667 | state.set_ignorecase(store.application.settings.tunables.ignorecase); | |
| 663 | 668 | |
| 664 | 669 | List::new(store) |
| 665 | 670 | .empty_message("You do not have rooms or dms yet") |
| @@ -694,6 +699,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 694 | 699 | items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator)); |
| 695 | 700 | |
| 696 | 701 | state.set(items); |
| 702 | state.set_ignorecase(store.application.settings.tunables.ignorecase); | |
| 697 | 703 | |
| 698 | 704 | List::new(store) |
| 699 | 705 | .empty_message("You do not have any unreads yet") |
| @@ -728,6 +734,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 728 | 734 | items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator)); |
| 729 | 735 | |
| 730 | 736 | state.set(items); |
| 737 | state.set_ignorecase(store.application.settings.tunables.ignorecase); | |
| 731 | 738 | |
| 732 | 739 | List::new(store) |
| 733 | 740 | .empty_message("You do not have any unread mentions yet") |
| @@ -749,6 +756,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 749 | 756 | items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator)); |
| 750 | 757 | |
| 751 | 758 | state.set(items); |
| 759 | state.set_ignorecase(store.application.settings.tunables.ignorecase); | |
| 752 | 760 | |
| 753 | 761 | List::new(store) |
| 754 | 762 | .empty_message("You haven't joined any spaces yet") |
| @@ -764,6 +772,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 764 | 772 | items.sort(); |
| 765 | 773 | |
| 766 | 774 | state.set(items); |
| 775 | state.set_ignorecase(store.application.settings.tunables.ignorecase); | |
| 767 | 776 | |
| 768 | 777 | List::new(store) |
| 769 | 778 | .empty_message("No in-progress verifications") |
src/windows/room/chat.rs +3
| @@ -1184,6 +1184,9 @@ impl StatefulWidget for Chat<'_> { | ||
| 1184 | 1184 | }; |
| 1185 | 1185 | |
| 1186 | 1186 | let tbox = TextBox::new().prompt(prompt); |
| 1187 | state | |
| 1188 | .tbox | |
| 1189 | .set_ignorecase(self.store.application.settings.tunables.ignorecase); | |
| 1187 | 1190 | tbox.render(textarea, buf, &mut state.tbox); |
| 1188 | 1191 | |
| 1189 | 1192 | // Render the message scrollback. |
src/windows/room/scrollback.rs +4 −2
| @@ -702,7 +702,8 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { | ||
| 702 | 702 | let dir = flip.resolve(&dir); |
| 703 | 703 | |
| 704 | 704 | let lsearch = store.registers.get_last_search().to_string(); |
| 705 | let needle = Regex::new(lsearch.as_ref())?; | |
| 705 | let ci = store.application.settings.tunables.ignorecase; | |
| 706 | let needle = crate::util::compile_search(lsearch.as_ref(), ci)?; | |
| 706 | 707 | |
| 707 | 708 | let (mc, needs_load) = self.find_message(key, dir, &needle, count, info); |
| 708 | 709 | if needs_load { |
| @@ -778,7 +779,8 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { | ||
| 778 | 779 | let dir = flip.resolve(&dir); |
| 779 | 780 | |
| 780 | 781 | let lsearch = store.registers.get_last_search().to_string(); |
| 781 | let needle = Regex::new(lsearch.as_ref())?; | |
| 782 | let ci = store.application.settings.tunables.ignorecase; | |
| 783 | let needle = crate::util::compile_search(lsearch.as_ref(), ci)?; | |
| 782 | 784 | |
| 783 | 785 | let (mc, needs_load) = self.find_message(key, dir, &needle, count, info); |
| 784 | 786 | if needs_load { |
src/windows/room/space.rs +2
| @@ -202,6 +202,8 @@ impl StatefulWidget for Space<'_> { | ||
| 202 | 202 | type State = SpaceState; |
| 203 | 203 | |
| 204 | 204 | fn render(self, area: Rect, buffer: &mut Buffer, state: &mut Self::State) { |
| 205 | state.set_ignorecase(self.store.application.settings.tunables.ignorecase); | |
| 206 | ||
| 205 | 207 | let mut empty_message = None; |
| 206 | 208 | let need_fetch = match state.last_fetch { |
| 207 | 209 | Some(i) => i.elapsed() >= SPACE_HIERARCHY_DEBOUNCE, |
src/windows/welcome.rs +1
| @@ -52,6 +52,7 @@ impl TerminalCursor for WelcomeState { | ||
| 52 | 52 | |
| 53 | 53 | impl WindowOps<IambInfo> for WelcomeState { |
| 54 | 54 | fn draw(&mut self, area: Rect, buf: &mut Buffer, focused: bool, store: &mut ProgramStore) { |
| 55 | self.tbox.set_ignorecase(store.application.settings.tunables.ignorecase); | |
| 55 | 56 | self.tbox.draw(area, buf, focused, store) |
| 56 | 57 | } |
| 57 | 58 | |