From ad0e73f7467dcfb279a9906345eea08d66a05ffe Mon Sep 17 00:00:00 2001 From: ThatBoiDev Date: Mon, 18 Mar 2024 17:40:38 +0100 Subject: [PATCH] cap character limit of title to 64 to avoid line overflow --- src/note.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/note.rs b/src/note.rs index 385b539..8406f6f 100644 --- a/src/note.rs +++ b/src/note.rs @@ -37,9 +37,23 @@ impl Note { println!( "If you're done inputting a field, you can press Enter twice to continue or save, or Alt/Option-Q to return to the main menu.\r" ); + + let mut name: String; + loop { + name = input("Name:", "".to_string())?; + if name.len() > 64 { + cursor_to_origin()?; + println!( + "If you're done inputting a field, you can press Enter twice to continue or save, or Alt/Option-Q to return to the main menu.\n\n\ + error: The name is too long, it must be 64 characters or less.\r" + ); + } else { + break; + } + } let inputted_note = Note { id: id, - name: input("Name:", "".to_string())?, + name: name, content: input("Content:", "".to_string())?, created: format!("{}", Local::now().format("%A %e %B, %H:%M")), };