|
20 | 20 | if exists('g:markdown_extras_loaded') && g:markdown_extras_loaded |
21 | 21 | finish |
22 | 22 | endif |
| 23 | +g:markdown_extras_loaded = true |
23 | 24 |
|
24 | | -var release_notes =<< END |
25 | | -# vim-markdown-extras: release notes |
| 25 | +const release_notes =<< END |
26 | 26 |
|
27 | 27 | ## Links |
28 | 28 | Links must have a valid URL format to keep consistency with |
@@ -61,16 +61,42 @@ The default register is 'p' but that can be changed through the |
61 | 61 | g:markdown_extras_config dictionary. |
62 | 62 |
|
63 | 63 |
|
64 | | -Press <Esc> to close this popup. |
| 64 | +Press <Esc> or 'q' to close this popup. |
65 | 65 | END |
66 | 66 |
|
67 | | -def ShowReleaseNotes() |
68 | 67 |
|
| 68 | +def ReleaseNotesFilter(id: number, key: string): bool |
| 69 | + # To handle the keys when release notes popup is visible |
| 70 | + # Close |
| 71 | + if key ==# 'q' || key ==# "\<esc>" |
| 72 | + popup_close(id) |
| 73 | + # Move down |
| 74 | + elseif ["\<tab>", "\<C-n>", "\<Down>", "\<ScrollWheelDown>"]->index(key) != -1 |
| 75 | + win_execute(id, "normal! \<c-e>") |
| 76 | + # Move up |
| 77 | + elseif ["\<S-Tab>", "\<C-p>", "\<Up>", "\<ScrollWheelUp>"]->index(key) != -1 |
| 78 | + win_execute(id, "normal! \<c-y>") |
| 79 | + # Jump down |
| 80 | + elseif key == "\<C-f>" |
| 81 | + win_execute(id, "normal! \<c-f>") |
| 82 | + # Jump up |
| 83 | + elseif key == "\<C-b>" |
| 84 | + win_execute(id, "normal! \<c-b>") |
| 85 | + else |
| 86 | + return false |
| 87 | + endif |
| 88 | + return true |
| 89 | +enddef |
| 90 | + |
| 91 | +def ShowReleaseNotes() |
| 92 | + const title = ' vim-markdown-extras: release notes ' |
69 | 93 | const popup_options = { |
70 | | - border: [1, 1, 1, 1], |
71 | | - borderchars: ['─', '│', '─', '│', '╭', '╮', '╯', '╰'], |
72 | | - filter: 'popup_filter_menu', |
73 | | - } |
| 94 | + border: [1, 1, 1, 1], |
| 95 | + borderchars: ['─', '│', '─', '│', '╭', '╮', '╯', '╰'], |
| 96 | + scrollbar: false, |
| 97 | + title: title, |
| 98 | + filter: ReleaseNotesFilter |
| 99 | + } |
74 | 100 |
|
75 | 101 | const popup_id = popup_create(release_notes, popup_options) |
76 | 102 | win_execute(popup_id, 'set filetype=markdown') |
@@ -167,5 +193,3 @@ enddef |
167 | 193 | command! -nargs=1 -complete=file MDEPathToURL PathToURLReg(<f-args>) |
168 | 194 | command! -nargs=0 MDEReleaseNotes ShowReleaseNotes() |
169 | 195 | command! -nargs=? MDEIndex indices.ShowIndex(<f-args>) |
170 | | - |
171 | | -g:markdown_extras_loaded = true |
|
0 commit comments