mirror of
https://github.com/prurigro/vnotes.git
synced 2024-12-22 18:30:22 -05:00
Declare variables used locally in functions as local (and don't worry about unsetting them)
This commit is contained in:
parent
0930e740f4
commit
940cb59e00
1 changed files with 12 additions and 8 deletions
20
vnotes
20
vnotes
|
@ -42,7 +42,8 @@ declare max_docwidth=0
|
|||
|
||||
# Display help text
|
||||
function help {
|
||||
script_name="${0//*\/}"
|
||||
local script_name="${0//*\/}"
|
||||
|
||||
printf '\n%s\n\n' "${c_m}vnotes${c_w} - manage your notes$c_c"
|
||||
printf '%s\n' "${c_b}USAGE$c_c"
|
||||
printf ' %-43s%s\n' "${c_d}[${c_y}PATTERN$c_d]$c_c" ' — opens single match or lists multiple'
|
||||
|
@ -55,8 +56,7 @@ function help {
|
|||
# Create a note
|
||||
function create_note {
|
||||
if [[ -n "$1" ]]; then
|
||||
note="$VNOTES_FOLDER/${1}.$VNOTES_EXTENSION"
|
||||
"$EDITOR" "$note"
|
||||
"$EDITOR" "$VNOTES_FOLDER/${1}.$VNOTES_EXTENSION"
|
||||
else
|
||||
printf '%s %s\n' "${c_r}ERROR:$c_c" "${c_w}The name of the note to ${c_y}create$c_w was not provided$c_c" >&2
|
||||
exit 1
|
||||
|
@ -65,6 +65,8 @@ function create_note {
|
|||
|
||||
# Delete a note
|
||||
function delete_note {
|
||||
local note
|
||||
|
||||
if [[ -n "$1" ]]; then
|
||||
note="$VNOTES_FOLDER/${1}.$VNOTES_EXTENSION"
|
||||
|
||||
|
@ -122,10 +124,15 @@ function open_note {
|
|||
|
||||
# Search for notes and open the closest match, or list out options if more than one exists
|
||||
function search_notes {
|
||||
# Take the first input as the key
|
||||
key="$1"
|
||||
# Declare the search term as "key"
|
||||
local key="$1"
|
||||
|
||||
# Declare local variables we'll be using
|
||||
local screen_width maxcolumns digits digits_power cnt count_display value keypress
|
||||
|
||||
# Declare variables with the keycodes for "Q", "q", return/enter and 0-9
|
||||
local alpha_Q alpha_q key_cr key_0 key_1 key_2 key_3 key_4 key_5 key_6 key_7 key_8 key_9
|
||||
|
||||
alpha_Q=$(getkeycode "$(printf '%s' 'Q' | od -t o1)")
|
||||
alpha_q=$(getkeycode "$(printf '%s' 'q' | od -t o1)")
|
||||
key_cr=$(getkeycode "$(printf '\n' | od -t o1)")
|
||||
|
@ -205,8 +212,6 @@ function search_notes {
|
|||
(( digits++ ))
|
||||
done
|
||||
|
||||
unset digits_power
|
||||
|
||||
# Draw the list
|
||||
printf '\n'
|
||||
cnt=1
|
||||
|
@ -227,7 +232,6 @@ function search_notes {
|
|||
fi
|
||||
done
|
||||
|
||||
unset cnt
|
||||
printf '\n'
|
||||
|
||||
# Initialize the interactive entry line
|
||||
|
|
Loading…
Reference in a new issue