diff --git a/src/components/mail/listing.rs b/src/components/mail/listing.rs index d6798e0ca..ae4f85f04 100644 --- a/src/components/mail/listing.rs +++ b/src/components/mail/listing.rs @@ -84,9 +84,9 @@ impl Default for Modifier { #[derive(Debug, Default, Clone)] pub struct DataColumns { - pub columns: [CellBuffer; 12], + pub columns: Box<[CellBuffer; 12]>, pub widths: [usize; 12], // widths of columns calculated in first draw and after size changes - pub segment_tree: [SegmentTree; 12], + pub segment_tree: Box<[SegmentTree; 12]>, } #[derive(Debug, Default)] diff --git a/src/components/mail/listing/compact.rs b/src/components/mail/listing/compact.rs index bf051ced8..2ae5ce0dc 100644 --- a/src/components/mail/listing/compact.rs +++ b/src/components/mail/listing/compact.rs @@ -188,7 +188,7 @@ pub struct CompactListing { force_draw: bool, /// If `self.view` exists or not. focus: Focus, - view: ThreadView, + view: Box, row_updates: SmallVec<[ThreadHash; 8]>, color_cache: ColorCache, @@ -307,7 +307,7 @@ impl MailListingTrait for CompactListing { } else if self.unfocused() { let thread = self.get_thread_under_cursor(self.cursor_pos.2); - self.view = ThreadView::new(self.new_cursor_pos, thread, None, context); + self.view = Box::new(ThreadView::new(self.new_cursor_pos, thread, None, context)); } } @@ -491,7 +491,7 @@ impl ListingTrait for CompactListing { fn set_coordinates(&mut self, coordinates: (AccountHash, MailboxHash)) { self.new_cursor_pos = (coordinates.0, coordinates.1, 0); self.focus = Focus::None; - self.view = ThreadView::default(); + self.view = Box::new(ThreadView::default()); self.filtered_selection.clear(); self.filtered_order.clear(); self.filter_term.clear(); @@ -897,7 +897,7 @@ impl CompactListing { rows: vec![], dirty: true, force_draw: true, - view: ThreadView::default(), + view: Box::new(ThreadView::default()), color_cache: ColorCache::default(), movement: None, modifier_active: false, @@ -1785,7 +1785,7 @@ impl Component for CompactListing { || shortcut!(k == shortcuts[Listing::DESCRIPTION]["focus_right"])) => { let thread = self.get_thread_under_cursor(self.cursor_pos.2); - self.view = ThreadView::new(self.cursor_pos, thread, None, context); + self.view = Box::new(ThreadView::new(self.cursor_pos, thread, None, context)); self.set_focus(Focus::Entry, context); return true; } diff --git a/src/components/mail/listing/thread.rs b/src/components/mail/listing/thread.rs index dd9b11147..464fc352b 100644 --- a/src/components/mail/listing/thread.rs +++ b/src/components/mail/listing/thread.rs @@ -131,7 +131,7 @@ pub struct ThreadListing { /// If `self.view` is focused or not. focus: Focus, initialised: bool, - view: Option, + view: Option>, movement: Option, id: ComponentId, } @@ -773,7 +773,7 @@ impl ListingTrait for ThreadListing { if let Some(ref mut v) = self.view { v.update(coordinates, context); } else { - self.view = Some(MailView::new(coordinates, None, None, context)); + self.view = Some(Box::new(MailView::new(coordinates, None, None, context))); } if let Some(ref mut s) = self.view { @@ -1239,7 +1239,7 @@ impl Component for ThreadListing { if let Some(ref mut v) = self.view { v.update(coordinates, context); } else { - self.view = Some(MailView::new(coordinates, None, None, context)); + self.view = Some(Box::new(MailView::new(coordinates, None, None, context))); } if let Some(v) = self.view.as_mut() { diff --git a/src/state.rs b/src/state.rs index a67e2faca..73f8c220c 100644 --- a/src/state.rs +++ b/src/state.rs @@ -97,7 +97,7 @@ impl InputHandler { /// A context container for loaded settings, accounts, UI changes, etc. pub struct Context { pub accounts: IndexMap, - pub settings: Settings, + pub settings: Box, /// Areas of the screen that must be redrawn in the next render pub dirty_areas: VecDeque, @@ -168,13 +168,13 @@ impl Context { /// A State object to manage and own components and components of the UI. `State` is responsible for /// managing the terminal and interfacing with `melib` pub struct State { - screen: Screen, + screen: Box, draw_rate_limit: RateLimit, child: Option, pub mode: UIMode, overlay: Vec>, components: Vec>, - pub context: Context, + pub context: Box, timer: thread::JoinHandle<()>, display_messages: SmallVec<[DisplayMessage; 8]>, @@ -228,11 +228,11 @@ impl State { let input_thread_pipe = nix::unistd::pipe() .map_err(|err| Box::new(err) as Box)?; let backends = Backends::new(); - let settings = if let Some(settings) = settings { + let settings = Box::new(if let Some(settings) = settings { settings } else { Settings::new()? - }; + }); /* let mut plugin_manager = PluginManager::new(); for (_, p) in settings.plugins.clone() { @@ -307,7 +307,7 @@ impl State { let working = Arc::new(()); let control = Arc::downgrade(&working); let mut s = State { - screen: Screen { + screen: Box::new(Screen { cols, rows, grid: CellBuffer::new(cols, rows, Cell::with_char(' ')), @@ -319,7 +319,7 @@ impl State { } else { Screen::draw_horizontal_segment_no_color }, - }, + }), child: None, mode: UIMode::Normal, components: Vec::with_capacity(8), @@ -333,7 +333,7 @@ impl State { display_messages_dirty: false, display_messages_initialised: false, display_messages_area: ((0, 0), (0, 0)), - context: Context { + context: Box::new(Context { accounts, settings, dirty_areas: VecDeque::with_capacity(5), @@ -351,7 +351,7 @@ impl State { }, sender, receiver, - }, + }), }; if s.context.settings.terminal.ascii_drawing { s.screen.grid.set_ascii_drawing(true); @@ -395,7 +395,7 @@ impl State { } let Context { ref mut accounts, .. - } = &mut self.context; + } = &mut *self.context; if let Some(notification) = accounts[&account_hash].reload(event, mailbox_hash) { if let UIEvent::Notification(_, _, _) = notification { @@ -948,10 +948,10 @@ impl State { if toml::Value::try_from(&new_settings) == toml::Value::try_from(&self.context.settings) { return Err("No changes detected.".into()); } - Ok(new_settings) + Ok(Box::new(new_settings)) }) { Ok(new_settings) => { - let old_settings = Box::new(std::mem::replace(&mut self.context.settings, new_settings)); + let old_settings = std::mem::replace(&mut self.context.settings, new_settings); self.context.replies.push_back(UIEvent::ConfigReload { old_settings }); diff --git a/src/terminal.rs b/src/terminal.rs index 57e3774e5..916c77f23 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -463,6 +463,7 @@ pub mod screen { use termion::{clear, cursor}; pub type StateStdout = termion::screen::AlternateScreen>>; + pub struct Screen { pub cols: usize, pub rows: usize,