Move help text to a const

This commit is contained in:
Austen Adler 2021-10-02 08:44:23 -04:00
parent 2f2976bfd7
commit 8a03445936

View File

@ -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\
<ret> => Dup l => Log\n\
L => Ln e => *10^\n\
<right> => Swap <down> => 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> => 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<T: Write>(&mut self, f: &mut Frame<CrosstermBackend<T>>) {
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\
<ret> => Dup l => Log\n\
L => Ln e => *10^\n\
<right> => Swap <down> => 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> => 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,
);