diff --git a/notestorm b/notestorm index faf9da4..76cd149 100755 --- a/notestorm +++ b/notestorm @@ -67,16 +67,30 @@ menulist() { # Args: Tag, description. # returns: selected tag dialog --backtitle "$(gettext "Use the up and down arrow keys to find the option you want, then press enter to select it.")" \ - --cancel-label "Exit" \ + --cancel-label "$(gettext "Exit")" \ --extra-button \ - --extra-label "Edit" \ + --extra-label "$(gettext "Edit")" \ --help-button \ - --help-label "Delete" \ - --ok-label "View" \ + --help-label "$(gettext "More")" \ + --ok-label "$(gettext "View")" \ --no-tags \ --menu "$(gettext "Please select one")" 0 0 0 $@ --stdout } +more_menu() { + # Options for the submenu go in the options array. + declare -a options=( + "delete" "$(gettext "Delete")") + local action="$(dialog --backtitle "$(gettext "Use the up and down arrow keys to find the option you want, then press enter to select it.")" \ + --no-tags \ + --menu "$(gettext "Please select one")" \ + 0 0 0 ${options[@]} --stdout)" + case "$action" in + "delete") delete_note "$1";; + "") return;; + esac +} + add_note() { # Notes are named based on number of seconds since 1970. # If the note exists it is incremented until the name is available. @@ -187,13 +201,17 @@ fi while [ "$action" != "exit" ]; do # Get a list of notes - mapfile -t notes < <(find "$xdgPath/notestorm/notes" -type f -iname '*.md') + mapfile -t notes < <(find "$xdgPath/notestorm/notes" -type f -iname '*.md' -o -iname '*.gpg') # Generate the note menu: unset noteMenu declare -a noteMenu for i in "${notes[@]}" ; do noteMenu+=("$i") + if [[ "${i##*.}" == "gpg" ]]; then + noteMenu+=("$(basename "${i}" .gpg)") + else noteMenu+=("$(head -1 "${i}")") + fi done # Create menu of actions and notes. @@ -217,7 +235,7 @@ while [ "$action" != "exit" ]; do *) case $dialogCode in 0) display_note "${action}";; - 2) delete_note "${action#HELP }";; + 2) more_menu "${action#HELP }";; 3) edit_note "${action}";; esac;; esac