feat: dayview: jump to next/previous day
This commit is contained in:
@@ -84,10 +84,12 @@ Here is the list of available keybindings:
|
|||||||
| `ctrl-alt-u` | week view | Go back one month |
|
| `ctrl-alt-u` | week view | Go back one month |
|
||||||
| `ctrl-alt-d` | week view | Go forth one month |
|
| `ctrl-alt-d` | week view | Go forth one month |
|
||||||
| `ctrl-s` | week view | Run the synchronization command |
|
| `ctrl-s` | week view | Run the synchronization command |
|
||||||
| `ctrl-l` | week view | Go to current week |
|
| `ctrl-r` | week view | Go to current week |
|
||||||
| `ctrl-g` | week view | Goto date |
|
| `ctrl-g` | week view | Goto date |
|
||||||
| `enter` | day view | Open selected calendar entry in your favorite `$EDITOR` |
|
| `enter` | day view | Open selected calendar entry in your favorite `$EDITOR` |
|
||||||
| `ctrl-n` | day view | Make a new entry |
|
| `ctrl-n` | day view | Make a new entry |
|
||||||
|
| `ctrl-l` | day view | Move to next day |
|
||||||
|
| `ctrl-h` | day view | Move to previous day |
|
||||||
| `esc`, `backspace` or `q` | day view | Go back to week view |
|
| `esc`, `backspace` or `q` | day view | Go back to week view |
|
||||||
| `ctrl-s` | day view | Run the synchronization command |
|
| `ctrl-s` | day view | Run the synchronization command |
|
||||||
| `ctrl-alt-d` | day view | Delete selected entry |
|
| `ctrl-alt-d` | day view | Delete selected entry |
|
||||||
|
@@ -14,7 +14,7 @@ function slice(start, stop, desc) {
|
|||||||
}
|
}
|
||||||
function hrline(hour) {
|
function hrline(hour) {
|
||||||
hour = hour < 10 ? "0"hour : hour
|
hour = hour < 10 ? "0"hour : hour
|
||||||
print hour, "", "", "", FAINT hour ":00 ----------------------" OFF
|
print today, hour, "", "", "", FAINT hour ":00 ----------------------" OFF
|
||||||
}
|
}
|
||||||
function hrlines(start, stop, h, starth, stoph, tmp, i) {
|
function hrlines(start, stop, h, starth, stoph, tmp, i) {
|
||||||
starth = substr(start, 1, 2)
|
starth = substr(start, 1, 2)
|
||||||
@@ -39,11 +39,11 @@ BEGIN {
|
|||||||
OFF = "\033[m"
|
OFF = "\033[m"
|
||||||
OFS = "|"
|
OFS = "|"
|
||||||
}
|
}
|
||||||
$1 == "00:00" && $2 == "00:00" { print $1, $3, $4, $5, allday($6); next }
|
$1 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6); next }
|
||||||
$1 == "00:00" { print $1, $3, $4, $5, endstoday($2, $6); next }
|
$1 == "00:00" { print today, $1, $3, $4, $5, endstoday($2, $6); next }
|
||||||
$1 ~ /^[0-9]{2}:[0-9]{2}$/ {
|
$1 ~ /^[0-9]{2}:[0-9]{2}$/ {
|
||||||
daystart = hrlines($1, $2, daystart, starth, stoph, tmp, i)
|
daystart = hrlines($1, $2, daystart, starth, stoph, tmp, i)
|
||||||
print $1, $3, $4, $5, slice($1, $2, $6)
|
print today, $1, $3, $4, $5, slice($1, $2, $6)
|
||||||
}
|
}
|
||||||
END {
|
END {
|
||||||
hrlines(dayend":00", 0, daystart, starth, stoph, tmp, i)
|
hrlines(dayend":00", 0, daystart, starth, stoph, tmp, i)
|
||||||
|
34
src/main.sh
34
src/main.sh
@@ -162,8 +162,8 @@ __show_day() {
|
|||||||
"$AWK_PARSE" "$file"
|
"$AWK_PARSE" "$file"
|
||||||
done
|
done
|
||||||
})
|
})
|
||||||
if [ -n "$sef" ]; then
|
|
||||||
today=$(date -d "$DISPLAY_DATE" +"%D")
|
today=$(date -d "$DISPLAY_DATE" +"%D")
|
||||||
|
if [ -n "$sef" ]; then
|
||||||
sef=$(echo "$sef" | while IFS= read -r line; do
|
sef=$(echo "$sef" | while IFS= read -r line; do
|
||||||
set -- $line
|
set -- $line
|
||||||
starttime="$1"
|
starttime="$1"
|
||||||
@@ -194,7 +194,7 @@ __show_day() {
|
|||||||
echo "$s|$e|$starttime|$endtime|$fpath|$description"
|
echo "$s|$e|$starttime|$endtime|$fpath|$description"
|
||||||
done)
|
done)
|
||||||
fi
|
fi
|
||||||
echo "$sef" | sort -n | awk -v daystart="$DAY_START" -v dayend="$DAY_END" "$AWK_DAYVIEW"
|
echo "$sef" | sort -n | awk -v today="$today" -v daystart="$DAY_START" -v dayend="$DAY_END" "$AWK_DAYVIEW"
|
||||||
}
|
}
|
||||||
|
|
||||||
__list() {
|
__list() {
|
||||||
@@ -413,23 +413,27 @@ if [ "${1:-}" = "--day" ]; then
|
|||||||
--no-input \
|
--no-input \
|
||||||
--margin='20%,5%' \
|
--margin='20%,5%' \
|
||||||
--border='double' \
|
--border='double' \
|
||||||
--border-label="🗓️ $(date -d "$DISPLAY_DATE" +"%A %e %B %Y")" \
|
|
||||||
--color=label:bold:green \
|
--color=label:bold:green \
|
||||||
--border-label-pos=3 \
|
--border-label-pos=3 \
|
||||||
--cycle \
|
--cycle \
|
||||||
--delimiter='|' \
|
--delimiter='|' \
|
||||||
--with-nth='{5}' \
|
--with-nth='{6}' \
|
||||||
--accept-nth='1,2,3,4' \
|
--accept-nth='2,3,4,5' \
|
||||||
--preview="$0 --preview {}" \
|
--preview="$0 --preview {}" \
|
||||||
--expect="ctrl-n,esc,backspace,q" \
|
--expect="ctrl-n,esc,backspace,q" \
|
||||||
|
--bind='load:transform(echo change-border-label:🗓️ $(date -d {1} +"%A %e %B %Y"))+transform(echo {} | grep \|\| || echo show-preview)' \
|
||||||
--bind='start:hide-preview' \
|
--bind='start:hide-preview' \
|
||||||
|
--bind="ctrl-r:reload:$0 --show-day {1}" \
|
||||||
--bind='ctrl-j:down+hide-preview+transform:echo {} | grep \|\| || echo show-preview' \
|
--bind='ctrl-j:down+hide-preview+transform:echo {} | grep \|\| || echo show-preview' \
|
||||||
--bind='ctrl-k:up+hide-preview+transform:echo {} | grep \|\| || echo show-preview' \
|
--bind='ctrl-k:up+hide-preview+transform:echo {} | grep \|\| || echo show-preview' \
|
||||||
|
--bind="ctrl-l:hide-preview+reload:$0 --show-day {1} '+1 day'" \
|
||||||
|
--bind="ctrl-h:hide-preview+reload:$0 --show-day {1} '-1 day'" \
|
||||||
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)" \
|
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)" \
|
||||||
--bind="ctrl-alt-d:become($0 --delete {})" \
|
--bind="ctrl-alt-d:become($0 --delete {})" \
|
||||||
--bind="j:preview-down" \
|
--bind="j:preview-down" \
|
||||||
--bind="k:preview-down" \
|
--bind="k:preview-down" \
|
||||||
--bind="w:toggle-preview-wrap"
|
--bind="w:toggle-preview-wrap"
|
||||||
|
#--bind="ctrl-u:unbind(load)+reload:$0 --list {2} '-1 week'" \
|
||||||
)
|
)
|
||||||
key=$(echo "$selection" | head -1)
|
key=$(echo "$selection" | head -1)
|
||||||
line=$(echo "$selection" | tail -1)
|
line=$(echo "$selection" | tail -1)
|
||||||
@@ -456,10 +460,10 @@ if [ "${1:-}" = "--date" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${1:-}" = "--preview" ]; then
|
if [ "${1:-}" = "--preview" ]; then
|
||||||
hour=$(echo "$2" | cut -d '|' -f 1)
|
hour=$(echo "$2" | cut -d '|' -f 2)
|
||||||
start=$(echo "$2" | cut -d '|' -f 2)
|
start=$(echo "$2" | cut -d '|' -f 3)
|
||||||
end=$(echo "$2" | cut -d '|' -f 3)
|
end=$(echo "$2" | cut -d '|' -f 4)
|
||||||
fpath=$(echo "$2" | cut -d '|' -f 4 | sed "s/ /|/g")
|
fpath=$(echo "$2" | cut -d '|' -f 5 | sed "s/ /|/g")
|
||||||
if [ -n "$hour" ] && [ -n "$fpath" ]; then
|
if [ -n "$hour" ] && [ -n "$fpath" ]; then
|
||||||
fpath="$ROOT/$fpath"
|
fpath="$ROOT/$fpath"
|
||||||
start=$(__canonical_datetime "$start" "%a ")
|
start=$(__canonical_datetime "$start" "%a ")
|
||||||
@@ -558,7 +562,7 @@ if [ "${1:-}" = "--preview-week" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${1:-}" = "--delete" ]; then
|
if [ "${1:-}" = "--delete" ]; then
|
||||||
fpath=$(echo "$2" | cut -d '|' -f 4 | sed "s/ /|/g")
|
fpath=$(echo "$2" | cut -d '|' -f 5 | sed "s/ /|/g")
|
||||||
if [ -n "$fpath" ]; then
|
if [ -n "$fpath" ]; then
|
||||||
fpath="$ROOT/$fpath"
|
fpath="$ROOT/$fpath"
|
||||||
summary=$(awk -v field="SUMMARY" "$AWK_GET" "$fpath")
|
summary=$(awk -v field="SUMMARY" "$AWK_GET" "$fpath")
|
||||||
@@ -592,6 +596,14 @@ DISPLAY_DATE=${DISPLAY_DATE:-today}
|
|||||||
DISPLAY_DATE=$(date -d "$DISPLAY_DATE" +"%D")
|
DISPLAY_DATE=$(date -d "$DISPLAY_DATE" +"%D")
|
||||||
DISPLAY_POS=$((8 - $(date -d "$DISPLAY_DATE" +"%u")))
|
DISPLAY_POS=$((8 - $(date -d "$DISPLAY_DATE" +"%u")))
|
||||||
|
|
||||||
|
if [ "${1:-}" = "--show-day" ]; then
|
||||||
|
shift
|
||||||
|
DISPLAY_DATE=${*:-today}
|
||||||
|
DISPLAY_POS=$((8 - $(date -d "$DISPLAY_DATE" +"%u")))
|
||||||
|
__show_day
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${1:-}" = "--list" ]; then
|
if [ "${1:-}" = "--list" ]; then
|
||||||
shift
|
shift
|
||||||
DISPLAY_DATE=${*:-today}
|
DISPLAY_DATE=${*:-today}
|
||||||
@@ -633,7 +645,7 @@ selection=$(
|
|||||||
--bind="ctrl-alt-d:unbind(load)+reload:$0 --list {2} '+1 month'" \
|
--bind="ctrl-alt-d:unbind(load)+reload:$0 --list {2} '+1 month'" \
|
||||||
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)" \
|
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)" \
|
||||||
--bind="ctrl-g:become($0 --goto)" \
|
--bind="ctrl-g:become($0 --goto)" \
|
||||||
--bind="ctrl-l:rebind(load)+reload:$0 --list"
|
--bind="ctrl-r:rebind(load)+reload:$0 --list"
|
||||||
)
|
)
|
||||||
|
|
||||||
key=$(echo "$selection" | head -1)
|
key=$(echo "$selection" | head -1)
|
||||||
|
Reference in New Issue
Block a user