Skip to content

Instantly share code, notes, and snippets.

@U-MA
Created May 17, 2015 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save U-MA/064eef6f852365e08d9f to your computer and use it in GitHub Desktop.
Save U-MA/064eef6f852365e08d9f to your computer and use it in GitHub Desktop.
文字列"Now loading..."がアニメーションする
" Now loadingというアニメーションする文字列を表示する
" Version: 0.8
" Author: U-MA
" License: VIM LICENSE
" USAGE:
" Command: :NowLoading
"
" Please press 'q' for stop to this program.
let s:strlen = len("Now loading...")
let s:strp = 0 " point to char of a string"
function! s:init()
new
call append('.', " ")
call append(line('.')+1, "Now loading...")
execute "normal 2j"
endfunction
function! s:update()
if getline(line('.')-1)[col('.')-1] != ' '
let pos = getpos('.')
let pos[2] = 1
call setpos('.', pos)
endif
let c =''
let cc = ''
if col('.') == 1
let c = getline('.')[col('.')-1]
let cc = getline(line('.')-1)[col('$')-2]
execute "normal r\<space>kr" . c
if cc == ' '
execute "normal lj"
else
execute "normal $r\<space>jr" . cc
execute "normal ^"
endif
else
let c = getline('.')[col('.')-1]
let cc = getline(line('.')-1)[col('.')-2]
execute "normal r\<space>kr" . c
execute "normal hr\<space>jr" . cc
execute "normal 2l"
endif
echo "c = " . c ", cc = " . cc . " (" . getpos('.')[2] . ", " . getpos('.')[1] . ")"
endfunction
function! s:main()
call s:init()
let c = 0
while c != char2nr('q')
call s:update()
redraw
execute "sleep 160m"
let c = getchar(0)
endwhile
endfunction
command! NowLoading call s:main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment