diff --git a/notes.nim b/notes.nim index 91b77fb..98a1d6f 100644 --- a/notes.nim +++ b/notes.nim @@ -87,16 +87,30 @@ proc displayDeleteConfirmationMenu(note: string) = of "no": displayOptionMenu(note) +proc replaceNoteConfirmationMenu(note_idx: int, new_text: string): bool = + let old_note = notes[note_idx] + var diag = newInfo("Replace Note : '" & old_note.text & "', with '" & new_text & "' ?") + diag.selected_bg = default_bg + diag.selected_fg = default_fg + let args = @["yes", "no"] + let choice = outputData(diag,args) + case choice: + of "yes": + echo "here" + return true + else: + return false + proc replaceNote(new_text: string, old_text: string) = for idx, note in notes: if note.text == old_text: - var new_note = note - new_note.text = new_text - notes[idx] = new_note - writeNote(new_note) + if replaceNoteConfirmationMenu(idx,new_text): + var new_note = note + new_note.text = new_text + notes[idx] = new_note + writeNote(new_note) return - proc displayOptionMenu(option: string) = var select = newInfo("Note") select.selected_bg = default_bg @@ -119,7 +133,7 @@ proc displayOptionMenu(option: string) = proc newNote(text: string) = var new_note = Note() - let note_id = times.now().format("yyyyMMddHHmmssffffff") + let note_id = times.now().format("'{'yyyyMMdd-HHmmss-ffffff'}'") new_note.id = note_dir & note_id new_note.text = text writeNote(new_note, is_new = true)