vimã®ãã¬ã¼ã³ãã¼ã«ãã®2
vimのプレゼンツールã§ä½ã£ãã®ãã¡ãã£ã¨ç´ããã
ãã£ããã¨
- ååã¯åã¹ã©ã¤ããä¸æ°ã«è¡¨ç¤ºãã¦ããããh, lã§ã¯ãã¼ã¸ã¿ã¤ãã«ã®ã¿è¡¨ç¤ºããããã«å¤æ´
- j, kã§åè¡ãé çªã«è¡¨ç¤ºãããæ¶ãããã§ããããã«ãã
- ã«ã¼ã½ã«è¡ã強調表示ããããã«ãã
åä½ã¤ã¡ã¼ã¸
ã½ã¼ã¹
" Presentation Object let s:Presentation = { 'slides' : [], 'current' : 0, 'currentLine' : 0 } function! s:Presentation.load() let self.slides = [ \ { \ 'title' : 'presentation.vimã«ã¤ãã¦', \ 'contents' : [ \ '* æ¦è¦', \ '* èµ·åæ¹æ³', \ '* 使ãæ¹', \ '* ä»å¾ã®äºå®', \ ] \ }, \ { \ 'title' : 'æ¦è¦', \ 'contents' : [ \ '* vimã§ãã¬ã¼ã³ããããã®ã¹ã¯ãªãã', \ '* ã¯ã£ãããã£ã¦èªå·±æºè¶³ã§ããæ¬å½ã«ããg(ry', \ ] \ }, \ { \ 'title' : 'èµ·åæ¹æ³', \ 'contents' : [ \ '* ä»»æã®ç©ºãããã¡ä¸ã§:source presentation.vim', \ '* :PresentationEnable ã§ãã¬ã¼ã³ã¢ã¼ãéå§', \ '* :PresentationDisable ã§ãã¬ã¼ã³ã¢ã¼ãçµäº', \ ] \ }, \ { \ 'title' : '使ãæ¹', \ 'contents' : [ \ '* l ã§æ¬¡ã®ã¹ã©ã¤ãã表示', \ '* h ã§åã®ã¹ã©ã¤ãã表示', \ '* j ã§æ¬¡ã®è¡ã¸é²ãã', \ '* k ã§åã®è¡ã¸æ»ã', \ ] \ }, \ { \ 'title' : 'ä»å¾ã®äºå®', \ 'contents' : [ \ '* ã¹ã©ã¤ãã®ä¸èº«ã¯å¤é¨åããããã', \ '* ãã¼ã¸å ¨ä½ããåè¡ãã¨ã«highlightãåãæ¿ãå¯è½ã«ããããã', \ ] \ },] let self.current = 0 let self.currentLine = 0 endfunction " ã«ã¬ã³ãã¹ã©ã¤ãã®ã¿ã¤ãã«ã表示 function! s:Presentation.showPageTitle() execute 'normal o ' call setpos('.', [0, winline(), 1, winwidth(0)/5]) execute 'normal i ' . self.currentSlide()['title'] execute 'normal o ' endfunction " ã«ã¬ã³ãã¹ã©ã¤ãã®ç¾å¨è¡ã表示 function! s:Presentation.showPageContentsLine() execute 'normal o ' call setpos('.', [0, winline(), 1, winwidth(0)/6]) execute 'normal i ' . self.currentSlide()['contents'][self.currentLine] endfunction " ã«ã¬ã³ãã¹ã©ã¤ããè¿ã function! s:Presentation.currentSlide() return self.slides[self.current] endfunction " ã«ã¬ã³ãã¹ã©ã¤ããã¯ãªã¢ãã function! s:Presentation.clearPage() execute 'normal ggdG' let self.currentLine = 0 endfunction " ã«ã¬ã³ãã¹ã©ã¤ãã®ç¾å¨è¡ãã¯ãªã¢ãã function! s:Presentation.clearPageContentsLine() execute 'normal dd' endfunction function! s:Presentation.showNextPage() let nextIndex = self.current + 1 if nextIndex == len(self.slides) echo 'æå¾ã®ãã¼ã¸ã§ã' return endif call self.clearPage() let self.current = nextIndex call self.showPageTitle() endfunction function! s:Presentation.showPrevPage() let prevIndex = self.current - 1 if prevIndex < 0 echo 'æåã®ãã¼ã¸ã§ã' return endif call self.clearPage() let self.current = prevIndex call self.showPageTitle() endfunction function! s:Presentation.showNextLine() let nextIndex = self.currentLine + 1 if nextIndex > len(self.currentSlide()['contents']) " TODO 次ãã¼ã¸ã«é£ã¶ããã«ãã¹ãï¼ return endif call self.showPageContentsLine() let self.currentLine = nextIndex endfunction function! s:Presentation.showPrevLine() let prevIndex = self.currentLine - 1 if prevIndex < 0 " TODO åãã¼ã¸ã«é£ã¶ããã«ãã¹ã? return endif call self.clearPageContentsLine() let self.currentLine = prevIndex endfunction " ã¹ã¯ãªãããã¼ã«ã«ã®é¢æ°å®ç¾© " 次ãã¼ã¸ã表示 function! s:ShowNextPage() call s:Presentation.showNextPage() endfunction " åãã¼ã¸ã表示 function! s:ShowPrevPage() call s:Presentation.showPrevPage() endfunction " ã«ã¬ã³ãã¹ã©ã¤ãã®æ¬¡ã®è¡ã表示 function! s:ShowNextLine() call s:Presentation.showNextLine() endfunction " ã«ã¬ã³ãã¹ã©ã¤ãã®åã®è¡ã表示 function! s:ShowPrevLine() call s:Presentation.showPrevLine() endfunction " ãã¬ã¼ã³ãã¼ã·ã§ã³ãæå¹åãã function! s:Enable() set paste set ve=all set laststatus=0 set cursorline highlight CursorLine ctermfg=184 map <buffer> <silent> j :call <SID>ShowNextLine()<CR> map <buffer> <silent> k :call <SID>ShowPrevLine()<CR> map <buffer> <silent> h :call <SID>ShowPrevPage()<CR> map <buffer> <silent> l :call <SID>ShowNextPage()<CR> call s:Presentation.clearPage() call s:Presentation.load() call s:Presentation.showPageTitle() endfunction " ãã¬ã¼ã³ãã¼ã·ã§ã³ãç¡å¹åãã function! s:Disable() set nopaste set ve= set laststatus=2 set nocursorline highlight clear CursorLine " TODO mapã®å®ç¾©ã解é¤ãã¹ãï¼bufferãã¼ã«ã«ã ããå¥ã«ããããªã¨æããã©ã endfunction " ã³ãã³ãã®å®ç¾© command! -bar -narg=0 PresentationEnable call s:Enable() command! -bar -narg=0 PresentationDisable call s:Disable()