added confirmation to notes replace
This commit is contained in:
parent
541635392d
commit
84ca841406
1 changed files with 20 additions and 6 deletions
18
notes.nim
18
notes.nim
|
@ -87,16 +87,30 @@ proc displayDeleteConfirmationMenu(note: string) =
|
||||||
of "no":
|
of "no":
|
||||||
displayOptionMenu(note)
|
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) =
|
proc replaceNote(new_text: string, old_text: string) =
|
||||||
for idx, note in notes:
|
for idx, note in notes:
|
||||||
if note.text == old_text:
|
if note.text == old_text:
|
||||||
|
if replaceNoteConfirmationMenu(idx,new_text):
|
||||||
var new_note = note
|
var new_note = note
|
||||||
new_note.text = new_text
|
new_note.text = new_text
|
||||||
notes[idx] = new_note
|
notes[idx] = new_note
|
||||||
writeNote(new_note)
|
writeNote(new_note)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
proc displayOptionMenu(option: string) =
|
proc displayOptionMenu(option: string) =
|
||||||
var select = newInfo("Note")
|
var select = newInfo("Note")
|
||||||
select.selected_bg = default_bg
|
select.selected_bg = default_bg
|
||||||
|
@ -119,7 +133,7 @@ proc displayOptionMenu(option: string) =
|
||||||
|
|
||||||
proc newNote(text: string) =
|
proc newNote(text: string) =
|
||||||
var new_note = Note()
|
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.id = note_dir & note_id
|
||||||
new_note.text = text
|
new_note.text = text
|
||||||
writeNote(new_note, is_new = true)
|
writeNote(new_note, is_new = true)
|
||||||
|
|
Loading…
Reference in a new issue