From bd087fc1d4c3c8609f6d655f477449d93a24ee20 Mon Sep 17 00:00:00 2001 From: kota65535 Date: Sat, 6 Feb 2016 03:53:06 -0800 Subject: [PATCH 1/3] add function of showing breakpoint signs --- plugin/scriptease.vim | 66 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/plugin/scriptease.vim b/plugin/scriptease.vim index 2fc2888..58cac4d 100644 --- a/plugin/scriptease.vim +++ b/plugin/scriptease.vim @@ -507,10 +507,10 @@ augroup scriptease_breakadd autocmd! autocmd FileType vim command! \ -buffer -bar -nargs=? -complete=custom,s:Complete_breakadd Breakadd - \ :exe s:break('add',) + \ :exe s:break('add',) | :exe s:show_breakpoint_signs() autocmd FileType vim command! \ -buffer -bar -nargs=? -complete=custom,s:Complete_breakdel Breakdel - \ :exe s:break('del',) + \ :exe s:break('del',) | :exe s:show_breakpoint_signs() augroup END function! s:breaksnr(arg) abort @@ -786,4 +786,66 @@ augroup END " }}}1 +function! s:to_function_name(symbol) + let result = matchstr(a:symbol, '^.*\d\+_\zs.*\ze$') + return empty(result) ? a:symbol : result +endfunction + +function! s:to_SID(symbol) + return matchstr(a:symbol, '^.*\zs\d\+\ze_.*$') +endfunction + +let s:sign_name = 'scriptease_break' +" ID number of the next sign to place +let s:next_sign_id = 17607 +execute 'sign define ' . s:sign_name . ' texthl=ErrorMsg text=>>' + +function! s:show_breakpoint_signs() + sign unplace * + " get output of :breaklist + redir => result + silent execute 'breaklist' + redir END + if result =~# 'No breakpoints defined' + return + endif + " make breakpoint list + let l:blist = [] + for bstr in split(result, '\n') + let bcols = split(bstr) + let bentry = { 'type' : bcols[1], 'line' : bcols[4] } + if bentry['type'] ==# 'file' + " set fullpath of the file + let bentry['file'] = expand(bcols[2]) + elseif bentry['type'] ==# 'func' + " set SID and function name + let bentry['func'] = { 'SID': s:to_SID(bcols[2]), 'name': s:to_function_name(bcols[2]) } + endif + call add(l:blist, l:bentry) + endfor + PPmsg l:blist + for be in l:blist + if be['type'] ==# 'file' + " place sign to the file + execute 'sign place ' . s:sign_id . ' line=' . be['line'] . ' name=' . s:sign_name . ' file=' . be['file'] + PPmsg 'sign place ' . s:sign_id . ' line=' . be['line'] . ' name=' . s:sign_name . ' file=' . be['file'] + elseif be['type'] ==# 'func' + if be['func']['SID'] !=# scriptease#scriptid('%') + " the script-local function is not of this file + continue + else + " if the function definition found, place sign. + let l:lnum = search('\v^fu.*%()' . be['func']['name'], 'n') + if l:lnum != 0 + execute 'sign place ' . s:sign_id . ' line=' . (l:lnum + be['line']) . ' name=' . s:sign_name . ' file=' . expand('%:p') + PPmsg 'sign place ' . s:sign_id . ' line=' . l:lnum + be['line'] . ' name=' . s:sign_name . ' file=' . expand('%:p') + endif + endif + endif + s:next_sign_id += 1 + endfor +endfunction + +autocmd BufEnter * call show_breakpoint_signs() + " vim:set et sw=2: From 2f98d2a41127added2080de5ca7b543ce6c47b2b Mon Sep 17 00:00:00 2001 From: kota65535 Date: Sat, 6 Feb 2016 04:01:41 -0800 Subject: [PATCH 2/3] modify typo --- plugin/scriptease.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/scriptease.vim b/plugin/scriptease.vim index 58cac4d..0260b73 100644 --- a/plugin/scriptease.vim +++ b/plugin/scriptease.vim @@ -797,7 +797,7 @@ endfunction let s:sign_name = 'scriptease_break' " ID number of the next sign to place -let s:next_sign_id = 17607 +let s:sign_id = 17607 execute 'sign define ' . s:sign_name . ' texthl=ErrorMsg text=>>' function! s:show_breakpoint_signs() @@ -842,7 +842,7 @@ function! s:show_breakpoint_signs() endif endif endif - s:next_sign_id += 1 + let s:sign_id += 1 endfor endfunction From 8df0c93f4ebf4c787959e576c931f8dcbbce4985 Mon Sep 17 00:00:00 2001 From: kota65535 Date: Sun, 14 Feb 2016 16:37:57 -0800 Subject: [PATCH 3/3] fixed bug for global function --- plugin/scriptease.vim | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/plugin/scriptease.vim b/plugin/scriptease.vim index 0260b73..9fa626f 100644 --- a/plugin/scriptease.vim +++ b/plugin/scriptease.vim @@ -507,10 +507,10 @@ augroup scriptease_breakadd autocmd! autocmd FileType vim command! \ -buffer -bar -nargs=? -complete=custom,s:Complete_breakadd Breakadd - \ :exe s:break('add',) | :exe s:show_breakpoint_signs() + \ :exe s:break('add',) | :call s:show_breakpoint_signs() autocmd FileType vim command! \ -buffer -bar -nargs=? -complete=custom,s:Complete_breakdel Breakdel - \ :exe s:break('del',) | :exe s:show_breakpoint_signs() + \ :exe s:break('del',) | :call s:show_breakpoint_signs() augroup END function! s:breaksnr(arg) abort @@ -823,22 +823,31 @@ function! s:show_breakpoint_signs() endif call add(l:blist, l:bentry) endfor - PPmsg l:blist + " PPmsg l:blist for be in l:blist if be['type'] ==# 'file' " place sign to the file execute 'sign place ' . s:sign_id . ' line=' . be['line'] . ' name=' . s:sign_name . ' file=' . be['file'] - PPmsg 'sign place ' . s:sign_id . ' line=' . be['line'] . ' name=' . s:sign_name . ' file=' . be['file'] + " PPmsg 'sign place ' . s:sign_id . ' line=' . be['line'] . ' name=' . s:sign_name . ' file=' . be['file'] elseif be['type'] ==# 'func' - if be['func']['SID'] !=# scriptease#scriptid('%') + if empty(be['func']['SID']) + " search global function and place sign + " PPmsg '\v^\s*fu%[nction]>.*' . be['func']['name'] + let l:lnum = search('\v^\s*fu%[nction]>.*' . be['func']['name'], 'n') + if l:lnum != 0 + execute 'sign place ' . s:sign_id . ' line=' . (l:lnum + be['line']) . ' name=' . s:sign_name . ' file=' . expand('%:p') + " PPmsg 'sign place ' . s:sign_id . ' line=' . l:lnum + be['line'] . ' name=' . s:sign_name . ' file=' . expand('%:p') + endif + elseif be['func']['SID'] !=# scriptease#scriptid('%') " the script-local function is not of this file continue else - " if the function definition found, place sign. - let l:lnum = search('\v^fu.*%()' . be['func']['name'], 'n') + " search script-local function and place sign + " PPmsg '\v^\s*fu%[nction]>.*<(s:|\).*' . be['func']['name'] + let l:lnum = search('\v^\s*fu%[nction]>.*<(s:|\).*' . be['func']['name'], 'n') if l:lnum != 0 execute 'sign place ' . s:sign_id . ' line=' . (l:lnum + be['line']) . ' name=' . s:sign_name . ' file=' . expand('%:p') - PPmsg 'sign place ' . s:sign_id . ' line=' . l:lnum + be['line'] . ' name=' . s:sign_name . ' file=' . expand('%:p') + " PPmsg 'sign place ' . s:sign_id . ' line=' . l:lnum + be['line'] . ' name=' . s:sign_name . ' file=' . expand('%:p') endif endif endif @@ -846,6 +855,6 @@ function! s:show_breakpoint_signs() endfor endfunction -autocmd BufEnter * call show_breakpoint_signs() +autocmd BufEnter vim call s:show_breakpoint_signs() " vim:set et sw=2: