More functionality coming soon, partially implemented more menu.

This commit is contained in:
Storm Dragon
2019-07-30 02:48:40 -04:00
parent 861c6ee83a
commit be2663c88d

View File

@@ -67,16 +67,30 @@ menulist() {
# Args: Tag, description. # Args: Tag, description.
# returns: selected tag # 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.")" \ 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-button \
--extra-label "Edit" \ --extra-label "$(gettext "Edit")" \
--help-button \ --help-button \
--help-label "Delete" \ --help-label "$(gettext "More")" \
--ok-label "View" \ --ok-label "$(gettext "View")" \
--no-tags \ --no-tags \
--menu "$(gettext "Please select one")" 0 0 0 $@ --stdout --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() { add_note() {
# Notes are named based on number of seconds since 1970. # Notes are named based on number of seconds since 1970.
# If the note exists it is incremented until the name is available. # If the note exists it is incremented until the name is available.
@@ -187,13 +201,17 @@ fi
while [ "$action" != "exit" ]; do while [ "$action" != "exit" ]; do
# Get a list of notes # 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: # Generate the note menu:
unset noteMenu unset noteMenu
declare -a noteMenu declare -a noteMenu
for i in "${notes[@]}" ; do for i in "${notes[@]}" ; do
noteMenu+=("$i") noteMenu+=("$i")
if [[ "${i##*.}" == "gpg" ]]; then
noteMenu+=("$(basename "${i}" .gpg)")
else
noteMenu+=("$(head -1 "${i}")") noteMenu+=("$(head -1 "${i}")")
fi
done done
# Create menu of actions and notes. # Create menu of actions and notes.
@@ -217,7 +235,7 @@ while [ "$action" != "exit" ]; do
*) *)
case $dialogCode in case $dialogCode in
0) display_note "${action}";; 0) display_note "${action}";;
2) delete_note "${action#HELP }";; 2) more_menu "${action#HELP }";;
3) edit_note "${action}";; 3) edit_note "${action}";;
esac;; esac;;
esac esac