From 8a034459368131e89d281edd9c3c0c74af0c2724 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 2 Oct 2021 08:44:23 -0400 Subject: [PATCH] Move help text to a const --- src/main.rs | 76 ++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/main.rs b/src/main.rs index 59e8949..03fe6a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,42 @@ mod calc; mod event; const BORDER_SIZE: u16 = 2; +const HELP_TEXT: &str = "\ + + => Add s => Sin\n\ + - => Subtract c => Cos\n\ + / => Divide S => ASin\n\ + n => Negate C => ACos\n\ + | => Abs T => ATan\n\ + i => Inverse v => Sqrt\n\ + % => Modulo u => Undo\n\ + \\ => Drop U => Redo\n\ + ? => IntegerDivide ^ => Pow\n\ + => Dup l => Log\n\ + L => Ln e => *10^\n\ + => Swap => Edit\n\ + uU => Undo/Redo ` => Constants\n\ + r => Load Register R => Save Register\n\ + m => Macros @ => Settings\n\ + ^s => Save Config ^l => Load Config\ + "; +const SETTINGS_HELP_TEXT: &str = "\ + d => Degrees\n\ + r => Radians\n\ + g => Grads\n\ + _ => Default\n\ + , => Comma separated\n\ + => Space separated\n\ + s => Scientific\n\ + S => Scientific (stack precision)\n\ + e => Engineering\n\ + E => Engineering (stack precision)\n\ + f => Fixed\n\ + F => Fixed (stack precision)\n\ + w => Do not write settings and stack on quit (default)\n\ + W => Write stack and settings on quit\n\ + L => Left align\n\ + R => Right align\ + "; use calc::{ entries::CalculatorEntry, @@ -71,32 +107,13 @@ impl Default for App { } impl App { // This function is long because it contains help text - #[allow(clippy::too_many_lines)] fn draw_clippy_dialogs(&mut self, f: &mut Frame>) { match (&self.state, &self.calculator.state) { (AppState::Help, _) => { draw_clippy_rect( &ClippyRectangle { title: "Help", - msg: "\ - + => Add s => Sin\n\ - - => Subtract c => Cos\n\ - * => Multiply t => Tan\n\ - / => Divide S => ASin\n\ - n => Negate C => ACos\n\ - | => Abs T => ATan\n\ - i => Inverse v => Sqrt\n\ - % => Modulo u => Undo\n\ - \\ => Drop U => Redo\n\ - ? => IntegerDivide ^ => Pow\n\ - => Dup l => Log\n\ - L => Ln e => *10^\n\ - => Swap => Edit\n\ - uU => Undo/Redo ` => Constants\n\ - r => Load Register R => Save Register\n\ - m => Macros @ => Settings\n\ - ^s => Save Config ^l => Load Config\ - ", + msg: HELP_TEXT, }, f, ); @@ -167,24 +184,7 @@ impl App { draw_clippy_rect( &ClippyRectangle { title: "Settings", - msg: "\ - d => Degrees\n\ - r => Radians\n\ - g => Grads\n\ - _ => Default\n\ - , => Comma separated\n\ - => Space separated\n\ - s => Scientific\n\ - S => Scientific (stack precision)\n\ - e => Engineering\n\ - E => Engineering (stack precision)\n\ - f => Fixed\n\ - F => Fixed (stack precision)\n\ - w => Do not write settings and stack on quit (default)\n\ - W => Write stack and settings on quit\n\ - L => Left align\n\ - R => Right align\ - ", + msg: SETTINGS_HELP_TEXT, }, f, );