itchyny / calendar.vim

A calendar application for Vim
MIT License
1.95k stars 71 forks source link

meaning of function names? #211

Closed rionda closed 1 year ago

rionda commented 1 year ago

The documentation is quite good, but one wonders what some of the functions do and how they differ. For example, what is the difference between calendar_down and calendar_move_down? What does calendar_next do that calendar_left or calendar_down, or calendar_space do not?

I got to the above question because I was really trying to understand how to quickly get to the next week or the next month from the week view or the month view respectively, so I would also like to know that, if possible.

Thank you for a great plug-in, or actually, app!

itchyny commented 1 year ago

Sorry for uninformative document for the key mappings. The calendar_down action is typically invoked by j and moves the focus down. The calendar_move_down action is for moving a task down in the task list (may be used for moving something else in some another list in the future but not yet). The calendar_next action moves the focus to the next element (always next day in the month view regardless of the week), whereas the calendar_right moves to focus to the right position (stops at the end of week in the month view). The calendar_space is for the space key and behaves almost same as calendar_next, but can be used to toggle the focus of year and month (where you can switch the focus to by tab).

rionda commented 1 year ago

No worries about the docs, thanks for the help.

Can you please tell me if there is a function to move to the next "page", i.e., to the next week if in week view, to the next month if in month view, to the next day if in day view, as if one was turning a page in a physical calendar?

Thanks, Matteo

itchyny commented 1 year ago

The default C-f (calendar_down_large) moves the focus in hours, that will not achieve what you want. Looks ugly a bit but how about the following configuration?

autocmd FileType calendar map <buffer><expr> <C-f>
      \ b:calendar.view.get_calendar_views() ==# 'week' ? "7\<Plug>(calendar_next)" :
      \ b:calendar.view.get_calendar_views() =~# 'day' ?
      \   matchstr(b:calendar.view.get_calendar_views(), '\d\+') . "\<Plug>(calendar_next)" :
      \ "\<Plug>(calendar_down_large)"
autocmd FileType calendar map <buffer><expr> <C-b>
      \ b:calendar.view.get_calendar_views() ==# 'week' ? "7\<Plug>(calendar_prev)" :
      \ b:calendar.view.get_calendar_views() =~# 'day' ?
      \   matchstr(b:calendar.view.get_calendar_views(), '\d\+') . "\<Plug>(calendar_prev)" :
      \ "\<Plug>(calendar_up_large)"
rionda commented 1 year ago

This is great, thanks!