Removed unused 0scan plugin
This commit is contained in:
parent
2138287c8e
commit
9509ad6580
@ -1,40 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Module: railmoon#ctags_util
|
||||
" Purpose: some common ctags process operations
|
||||
|
||||
|
||||
function! railmoon#ctags_util#taglist_for_file(filename, language, kinds, fields)
|
||||
let language_for_ctags = a:language
|
||||
if language_for_ctags == 'cpp'
|
||||
let language_for_ctags = 'c++'
|
||||
endif
|
||||
|
||||
let kind_option = "--".language_for_ctags.'-kinds=+'.a:kinds.' --language-force='.language_for_ctags
|
||||
let field_option = '--fields='.a:fields
|
||||
|
||||
if !exists('g:ctags_exe')
|
||||
let g:ctags_exe = 'ctags'
|
||||
endif
|
||||
|
||||
let ctags_tmp_file_name = 't_m_p_f_i_l_e'
|
||||
let ctags_cmd = g:ctags_exe . " -n --sort=no -f " . ctags_tmp_file_name . ' ' . kind_option . ' ' . field_option . ' ' . a:filename
|
||||
|
||||
call system(ctags_cmd)
|
||||
let old_tags = &tags
|
||||
|
||||
let &tags = ctags_tmp_file_name
|
||||
let ctags_tags = taglist('.*')
|
||||
let &tags = old_tags
|
||||
|
||||
call delete(ctags_tmp_file_name)
|
||||
|
||||
return ctags_tags
|
||||
endfunction
|
||||
|
||||
" returns not sorted tags for file treated as c++ file
|
||||
function! railmoon#ctags_util#taglist_for_cppfile(filename)
|
||||
return railmoon#ctags_util#taglist_for_file(a:filename, 'c++', 'cdefgmnpstuvx', 'sikaS')
|
||||
endfunction
|
||||
|
@ -1,115 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Home: www.railmoon.com
|
||||
" Module: railmoon#id
|
||||
" Purpose: util functions for work with id
|
||||
"
|
||||
|
||||
" -
|
||||
" [ public library function ]
|
||||
" Name: railmoon#id#acquire
|
||||
" Purpose: return new unique id for widget
|
||||
" [ parameters ]
|
||||
" pool_name id pool name
|
||||
" -
|
||||
function! railmoon#id#acquire(pool_name)
|
||||
if ! has_key(s:list, a:pool_name)
|
||||
let s:list[a:pool_name] = []
|
||||
endif
|
||||
|
||||
if ! has_key(s:last_id, a:pool_name)
|
||||
let s:last_id[a:pool_name] = 0
|
||||
endif
|
||||
|
||||
if empty(s:list[a:pool_name])
|
||||
let s:last_id[a:pool_name] += 1
|
||||
call add(s:list[a:pool_name], s:last_id[a:pool_name])
|
||||
endif
|
||||
|
||||
let result = s:list[a:pool_name][0]
|
||||
let s:list[a:pool_name] = s:list[a:pool_name][1:]
|
||||
|
||||
call railmoon#trace#debug('id#acquire pool = '.a:pool_name.'; id = '.result)
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ public library function ]
|
||||
" Name: railmoon#id#release
|
||||
" Purpose: return id to pool
|
||||
" [ parameters ]
|
||||
" pool_name id pool name
|
||||
" id id that no longer in use
|
||||
" -
|
||||
function! railmoon#id#release(pool_name, id)
|
||||
call railmoon#trace#debug('id#release pool = '.a:pool_name.'; id = '.a:id)
|
||||
if index(s:list[a:pool_name], a:id) != -1
|
||||
throw 'railmoon:id:release:already_present:'.a:id
|
||||
endif
|
||||
|
||||
if a:id > s:last_id[a:pool_name]
|
||||
throw 'railmoon:id:release:wasnt_acquired'
|
||||
endif
|
||||
call add(s:list[a:pool_name], a:id)
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" store last widget id
|
||||
" -
|
||||
let s:last_id = {}
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" store available ids
|
||||
" -
|
||||
let s:list = {}
|
||||
|
||||
" -
|
||||
" Section: unit testing
|
||||
" -
|
||||
let s:library_unit_test = railmoon#unit_test#create('railmoon#id test')
|
||||
|
||||
function! s:library_unit_test.test_acquire_release()
|
||||
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 1)
|
||||
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 2)
|
||||
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 3)
|
||||
|
||||
call self.assert_equal(railmoon#id#acquire('test2_id_pool'), 1)
|
||||
call self.assert_equal(railmoon#id#acquire('test2_id_pool'), 2)
|
||||
call self.assert_equal(railmoon#id#acquire('test2_id_pool'), 3)
|
||||
|
||||
call railmoon#id#release('test_id_pool', 3)
|
||||
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 3)
|
||||
|
||||
call railmoon#id#release('test2_id_pool', 3)
|
||||
call self.assert_equal(railmoon#id#acquire('test2_id_pool'), 3)
|
||||
|
||||
call railmoon#id#release('test_id_pool', 2)
|
||||
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 2)
|
||||
|
||||
call railmoon#id#release('test_id_pool', 1)
|
||||
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 1)
|
||||
|
||||
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 4)
|
||||
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 5)
|
||||
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 6)
|
||||
|
||||
call railmoon#id#release('test_id_pool', 1)
|
||||
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 1)
|
||||
|
||||
call railmoon#id#release('test_id_pool', 1)
|
||||
call railmoon#id#release('test_id_pool', 2)
|
||||
call railmoon#id#release('test_id_pool', 3)
|
||||
call railmoon#id#release('test_id_pool', 4)
|
||||
call railmoon#id#release('test_id_pool', 5)
|
||||
call railmoon#id#release('test_id_pool', 6)
|
||||
endfunction
|
||||
|
||||
function! s:library_unit_test.test_acquire_release_case_1()
|
||||
call self.assert_equal(railmoon#id#acquire('test_acquire_release_case_1'), 1)
|
||||
call railmoon#id#release('test_acquire_release_case_1', 1)
|
||||
endfunction
|
||||
|
||||
call s:library_unit_test.run()
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,724 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Purpose: quick move through current document or through any entities that can be tagged
|
||||
|
||||
|
||||
if ! exists('g:ctags_exe')
|
||||
if exists('Tlist_Ctags_Cmd')
|
||||
let g:ctags_exe = Tlist_Ctags_Cmd
|
||||
else
|
||||
let g:ctags_exe = "ctags"
|
||||
endif
|
||||
endif
|
||||
|
||||
let s:previous_records_to_print_count = 1
|
||||
let s:previous_suggestions_count = 1
|
||||
let s:records_to_print = []
|
||||
let s:suggestions = []
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Purpose: find tag position inside line.
|
||||
" tag can be with spaces. delimiter is comma.
|
||||
" return list with begin and end ( start from 0 ).
|
||||
" [ parameters ]
|
||||
" line string
|
||||
" column column that starts from 1
|
||||
" -
|
||||
function! s:tag_in_line_position(line, column)
|
||||
let column = a:column - 1
|
||||
|
||||
while a:line[column] == ',' && column > 0
|
||||
let column -= 1
|
||||
endwhile
|
||||
|
||||
let begin = column
|
||||
let end = column
|
||||
let length = len(a:line)
|
||||
|
||||
while begin > 0 && a:line[begin - 1] != ','
|
||||
let begin -= 1
|
||||
endwhile
|
||||
|
||||
while end < length && a:line[end + 1] != ','
|
||||
let end += 1
|
||||
endwhile
|
||||
|
||||
return [begin, end]
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Purpose: find tag inside line.
|
||||
" details in function above
|
||||
" [ parameters ]
|
||||
" line string
|
||||
" column column that starts from 1
|
||||
" -
|
||||
function! s:tag_in_line(line, column)
|
||||
let position = s:tag_in_line_position(a:line, a:column)
|
||||
|
||||
let result = a:line[position[0] : position[1]]
|
||||
if result == ','
|
||||
return ''
|
||||
endif
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" call backs for widgets
|
||||
" -
|
||||
let s:plugin_window_goes_close = 0
|
||||
let s:common_widget_callback = {}
|
||||
|
||||
function! s:common_widget_callback.on_close()
|
||||
call railmoon#trace#push('common_widget_callback.on_close')
|
||||
try
|
||||
|
||||
let s:plugin_window_goes_close = 1
|
||||
|
||||
call s:turnon_unexpected_plugins()
|
||||
|
||||
call railmoon#trace#debug('tabclose')
|
||||
tabclose
|
||||
|
||||
call railmoon#widget#window#load_selected(s:plugin_invoker_position)
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:common_widget_callback.on_tab_leave()
|
||||
call railmoon#trace#push('common_widget_callback.on_tab_leave')
|
||||
try
|
||||
|
||||
call railmoon#trace#debug('leaving tab')
|
||||
if ! s:plugin_window_goes_close
|
||||
let s:plugin_window_goes_close = 1
|
||||
call s:turnon_unexpected_plugins()
|
||||
tabclose " TODO make sure we close right tabpage
|
||||
endif
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:common_widget_callback.on_close_with_tab_page()
|
||||
call railmoon#trace#push('common_widget_callback.on_close_with_tab_page')
|
||||
try
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
let s:suggestion_window_callback = copy(s:common_widget_callback)
|
||||
function! s:suggestion_window_callback.on_select(line)
|
||||
endfunction
|
||||
|
||||
let s:result_window_callback = copy(s:common_widget_callback)
|
||||
function! s:result_window_callback.on_select(line)
|
||||
call s:result_select()
|
||||
endfunction
|
||||
|
||||
let s:tag_enter_window_callback = copy(s:common_widget_callback)
|
||||
let s:tag_enter_window_callback.edit_column = -1
|
||||
|
||||
let s:suggestion_window_model = {}
|
||||
function! s:suggestion_window_model.get_item(i)
|
||||
let item = { 'data':[], 'header':'' }
|
||||
if len(s:suggestions) > 0
|
||||
call add(item.data, s:suggestions[a:i] )
|
||||
endif
|
||||
|
||||
return item
|
||||
endfunction
|
||||
|
||||
function! s:suggestion_window_model.get_item_count()
|
||||
return len(s:suggestions)
|
||||
endfunction
|
||||
|
||||
let s:result_window_model = {}
|
||||
function! s:result_window_model.get_item(i)
|
||||
if len(s:records_to_print) == 0
|
||||
return {'data':[], 'header':''}
|
||||
endif
|
||||
|
||||
let record = s:records_to_print[a:i]
|
||||
let item = { 'data':[], 'header':record.additional_info }
|
||||
call extend( item.data, record.header )
|
||||
return item
|
||||
endfunction
|
||||
|
||||
function! s:result_window_model.get_item_count()
|
||||
return len(s:records_to_print)
|
||||
endfunction
|
||||
|
||||
function! s:tag_enter_window_callback.on_type(character, is_alpha_numeric)
|
||||
let line = getline('.')
|
||||
let column = col('.')
|
||||
|
||||
" magic with ','
|
||||
" change entered part to tag from suggestion list
|
||||
" TODO clean algorithm
|
||||
" TODO extract method and test it
|
||||
if ! a:is_alpha_numeric
|
||||
if a:character == ',' && self.available_tags_window.model.get_item_count() > 0
|
||||
let selected_tag = self.available_tags_window.selected_item()
|
||||
|
||||
let position = s:tag_in_line_position(line, column)
|
||||
let begin = position[0]
|
||||
let end = position[1]
|
||||
|
||||
|
||||
if begin != 0
|
||||
let new_line = line[ : begin - 1]
|
||||
else
|
||||
let new_line = ''
|
||||
endif
|
||||
|
||||
let selected_tag_text = selected_tag.data[0]
|
||||
|
||||
if line[end + 1] == ','
|
||||
let new_line .= selected_tag_text . line[ end + 1: ]
|
||||
else
|
||||
let new_line .= selected_tag_text . ',' . line[ end + 1 : ]
|
||||
endif
|
||||
|
||||
call self.edit_line_window.set_line(new_line)
|
||||
call self.edit_line_window.go_to_position(begin + len(selected_tag_text) + 2)
|
||||
endif
|
||||
return ''
|
||||
endif
|
||||
|
||||
" character isn't at line yet
|
||||
" so imagine it'is here
|
||||
let line_with_character = line[ : column] . a:character . line[column + 1 : ]
|
||||
let current_tag = s:tag_in_line(line_with_character, column)
|
||||
|
||||
let suggestions = self.refresh_suggestion_list(current_tag, line_with_character)
|
||||
|
||||
let self.edit_column = col('.') + 1
|
||||
if empty(suggestions)
|
||||
return ''
|
||||
endif
|
||||
|
||||
return a:character
|
||||
endfunction
|
||||
|
||||
function! s:suggestions_sort(lhs, rhs)
|
||||
if a:lhs == a:rhs
|
||||
return 0
|
||||
endif
|
||||
|
||||
let as_current_tag_start_pattern = '^'.s:current_tag
|
||||
let number_pattern = '\d\+'
|
||||
|
||||
let left_is_number = a:lhs =~ number_pattern
|
||||
let right_is_number = a:rhs =~ number_pattern
|
||||
|
||||
if a:lhs =~ as_current_tag_start_pattern && a:rhs !~ as_current_tag_start_pattern
|
||||
return -1
|
||||
endif
|
||||
|
||||
if left_is_number && right_is_number
|
||||
return a:lhs > a:rhs ? 1 : -1
|
||||
endif
|
||||
|
||||
if left_is_number && ! right_is_number
|
||||
return 1
|
||||
endif
|
||||
|
||||
if right_is_number && ! left_is_number
|
||||
return -1
|
||||
endif
|
||||
|
||||
if a:lhs !~ as_current_tag_start_pattern && a:rhs =~ as_current_tag_start_pattern
|
||||
return 1
|
||||
endif
|
||||
|
||||
return a:lhs > a:rhs ? 1 : -1
|
||||
endfunction
|
||||
|
||||
function! s:tag_enter_window_callback.refresh_suggestion_list(current_tag, line)
|
||||
let entered_tags = split(a:line, ',')
|
||||
|
||||
let current_tag = a:current_tag
|
||||
if current_tag == '.'
|
||||
let current_tag = '\.'
|
||||
endif
|
||||
|
||||
if current_tag =~ '"'
|
||||
call filter(entered_tags, "v:val != '". current_tag. "'")
|
||||
else
|
||||
call filter(entered_tags, 'v:val != "'.current_tag.'"')
|
||||
endif
|
||||
call add(entered_tags, '~'.current_tag)
|
||||
|
||||
let available_records = s:record_browser.get_matched_records( entered_tags )
|
||||
let available_tags = s:record_browser.get_available_tags_for_records( available_records, entered_tags )
|
||||
|
||||
let s:suggestions = []
|
||||
for w in available_tags
|
||||
if w =~ current_tag
|
||||
call add(s:suggestions, w)
|
||||
endif
|
||||
endfor
|
||||
|
||||
let s:current_tag = current_tag
|
||||
call sort(s:suggestions, 's:suggestions_sort')
|
||||
|
||||
let s:records_to_print = available_records
|
||||
let records_to_print_count = len(s:records_to_print)
|
||||
let suggestions_count = len(s:suggestions)
|
||||
|
||||
if records_to_print_count != s:previous_records_to_print_count
|
||||
let self.result_window.selected_item_number = 1
|
||||
endif
|
||||
|
||||
if suggestions_count != s:previous_suggestions_count
|
||||
let self.available_tags_window.selected_item_number = 1
|
||||
endif
|
||||
|
||||
let s:previous_records_to_print_count = records_to_print_count
|
||||
let s:previous_suggestions_count = suggestions_count
|
||||
|
||||
call self.result_window.draw()
|
||||
|
||||
call self.available_tags_window.draw()
|
||||
|
||||
return s:suggestions
|
||||
endfunction
|
||||
|
||||
function! s:tag_enter_window_callback.on_enter()
|
||||
endfunction
|
||||
|
||||
function! s:tag_enter_window_callback.on_insert_move()
|
||||
let line = getline('.')
|
||||
let column = col('.')
|
||||
|
||||
if self.edit_column == column
|
||||
return
|
||||
endif
|
||||
|
||||
let current_tag = s:tag_in_line(line, column)
|
||||
call self.refresh_suggestion_list(current_tag, line)
|
||||
endfunction
|
||||
|
||||
function! s:tag_selection_up()
|
||||
call s:available_tags_window.selection_up(1)
|
||||
endfunction
|
||||
|
||||
function! s:tag_selection_down()
|
||||
call s:available_tags_window.selection_down(1)
|
||||
endfunction
|
||||
|
||||
function! s:result_selection_up()
|
||||
call s:result_window.selection_up(1)
|
||||
endfunction
|
||||
|
||||
function! s:result_selection_down()
|
||||
call s:result_window.selection_down(1)
|
||||
endfunction
|
||||
|
||||
function! s:result_select()
|
||||
call railmoon#trace#push('s:result_select')
|
||||
try
|
||||
|
||||
if empty(s:records_to_print)
|
||||
return
|
||||
endif
|
||||
|
||||
let selected_item_number = s:result_window.selected_item_number
|
||||
let record = s:records_to_print[selected_item_number - 1]
|
||||
|
||||
let s:last_entred_tags_line = s:tag_enter_window_callback.edit_line_window.get_line()
|
||||
let s:last_selected_result_item_number = selected_item_number
|
||||
|
||||
tabclose
|
||||
call railmoon#widget#window#load_selected(s:plugin_invoker_position)
|
||||
|
||||
call s:record_browser.record_extractor.process(record)
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:close_all()
|
||||
call railmoon#trace#debug('close_all')
|
||||
call s:result_window.close()
|
||||
endfunction
|
||||
|
||||
function! s:map_result_moving_keys()
|
||||
let result_down_keys = [ '<down>', '<C-n>', '<C-j>' ]
|
||||
let result_up_keys = [ '<up>', '<C-p>', '<C-k>' ]
|
||||
|
||||
for key in result_down_keys
|
||||
let command = 'inoremap <silent> <buffer> '.key.' <C-R>=<SID>result_selection_down()?"":""<CR>'
|
||||
exec command
|
||||
let command = 'noremap <silent> <buffer> '.key.' :call <SID>result_selection_down()<CR>'
|
||||
exec command
|
||||
endfor
|
||||
|
||||
for key in result_up_keys
|
||||
let command = 'inoremap <silent> <buffer> '.key.' <C-R>=<SID>result_selection_up()?"":""<CR>'
|
||||
exec command
|
||||
let command = 'noremap <silent> <buffer> '.key.' :call <SID>result_selection_up()<CR>'
|
||||
exec command
|
||||
endfor
|
||||
|
||||
inoremap <silent> <buffer> <C-p> <C-R>=<SID>result_selection_up()?'':''<CR>
|
||||
inoremap <silent> <buffer> <cr> <C-R>=<SID>result_select()?' ':' '<CR>
|
||||
endfunction
|
||||
|
||||
function! s:map_suggestion_moving_keys()
|
||||
inoremap <silent> <buffer> <Tab> <C-R>=<SID>tag_selection_down()?'':''<CR>
|
||||
inoremap <silent> <buffer> <C-Tab> <C-R>=<SID>tag_selection_up()?'':''<CR>
|
||||
noremap <silent> <buffer> <Tab> :call <SID>tag_selection_down()<CR>
|
||||
noremap <silent> <buffer> <C-Tab> :call <SID>tag_selection_up()<CR>
|
||||
endfunction
|
||||
|
||||
function! s:map_common_keys()
|
||||
nnoremap <silent> <buffer> <esc> :call <SID>close_all()<CR>
|
||||
endfunction
|
||||
|
||||
" information to help 0scan repeat
|
||||
let s:last_extractor = {}
|
||||
let s:last_record_browser = {}
|
||||
let s:last_entred_tags_line = ''
|
||||
let s:last_selected_result_item_number = 0
|
||||
|
||||
|
||||
function! s:turnoff_unexpected_plugins()
|
||||
if exists('g:loaded_minibufexplorer')
|
||||
CMiniBufExplorer
|
||||
endif
|
||||
|
||||
if exists('g:loaded_autocomplpop')
|
||||
call railmoon#trace#debug('Turn off autocomplpop.vim')
|
||||
AutoComplPopLock
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:turnon_unexpected_plugins()
|
||||
if exists('g:loaded_autocomplpop')
|
||||
call railmoon#trace#debug('Turn on autocomplpop.vim')
|
||||
AutoComplPopUnlock
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:process_last_extractor_new_selection( record_number )
|
||||
let record = s:records_to_print[ a:record_number - 1 ]
|
||||
call s:last_extractor.process(record)
|
||||
endfunction
|
||||
|
||||
function! s:print_error( message )
|
||||
echohl Error | echo '[ 0scan ] '.a:message | echohl None
|
||||
endfunction
|
||||
|
||||
function! s:process_last_extractor_select_next( shift )
|
||||
let records_count = len( s:records_to_print )
|
||||
let new_record_number = s:last_selected_result_item_number + a:shift
|
||||
|
||||
if new_record_number < 1
|
||||
call s:print_error( 'first record reached' )
|
||||
return
|
||||
endif
|
||||
|
||||
if new_record_number > records_count
|
||||
call s:print_error( "last record reached" )
|
||||
return
|
||||
endif
|
||||
|
||||
let s:last_selected_result_item_number = new_record_number
|
||||
call s:process_last_extractor_new_selection( new_record_number )
|
||||
endfunction
|
||||
|
||||
function! s:process_last_extractor_quick_selection( command )
|
||||
if a:command == 'lastup'
|
||||
call s:process_last_extractor_select_next( -1 )
|
||||
elseif a:command == 'lastdown'
|
||||
call s:process_last_extractor_select_next( 1 )
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:create_extractor( name )
|
||||
let extractor = eval('railmoon#oscan#extractor#'.a:name.'#create()')
|
||||
return extractor
|
||||
endfunction
|
||||
|
||||
" returns files from dir
|
||||
"
|
||||
function! s:get_filenames_from_dir( dir )
|
||||
let files_list = split( glob( a:dir."/*" ), "\n" )
|
||||
let result = []
|
||||
|
||||
for item in files_list
|
||||
if filereadable( item )
|
||||
call add( result, item )
|
||||
endif
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" returns list of [ extractor_name, extractor_description, not_implemented_flag ]
|
||||
"
|
||||
function! s:get_available_extractors()
|
||||
let extractor_files = []
|
||||
|
||||
let vimfiles_folders = split( &runtimepath, ',' )
|
||||
for folder in vimfiles_folders
|
||||
if folder =~ 'after$'
|
||||
continue
|
||||
endif
|
||||
|
||||
let extractor_folder = folder.'/autoload/railmoon/oscan/extractor'
|
||||
call extend( extractor_files, s:get_filenames_from_dir( extractor_folder ) )
|
||||
endfor
|
||||
|
||||
let extractors = []
|
||||
|
||||
for extractor_file in extractor_files
|
||||
"echo extractor_file
|
||||
let extractor_name = fnamemodify( extractor_file, ":t:r" )
|
||||
|
||||
try
|
||||
let extractor = s:create_extractor( extractor_name )
|
||||
catch /.*/
|
||||
continue
|
||||
endtry
|
||||
|
||||
let extractor_description = extractor.description
|
||||
let extractor_not_implemented = has_key( extractor, 'not_implemented' ) ? extractor.not_implemented : 0
|
||||
call add( extractors, [ extractor_name, extractor_description, extractor_not_implemented ] )
|
||||
endfor
|
||||
|
||||
return extractors
|
||||
endfunction
|
||||
|
||||
function! s:show_available_extractors()
|
||||
let extractors = s:get_available_extractors()
|
||||
|
||||
let max_extractor_name_len = 0
|
||||
for extractor_description in extractors
|
||||
let len = len( extractor_description[0] )
|
||||
if len > max_extractor_name_len
|
||||
let max_extractor_name_len = len
|
||||
endif
|
||||
endfor
|
||||
|
||||
echohl Comment
|
||||
echo "Please specify scan you would like you use"
|
||||
echo ":OScan scan_name [tag1] [tag2]<CR>"
|
||||
echohl None
|
||||
for extractor_description in extractors
|
||||
echohl Keyword | echo printf( "%".max_extractor_name_len."s\t", extractor_description[0] )
|
||||
|
||||
if extractor_description[2]
|
||||
echohl Error | echon "[ Not implemented ]" | echohl None | echon " "
|
||||
endif
|
||||
|
||||
echohl String | echon extractor_description[1] | echohl None
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" completition function for :OScan command
|
||||
"
|
||||
function! railmoon#oscan#complete( argLead, cmdLine, cursorPos )
|
||||
let result = ''
|
||||
|
||||
let extractors = s:get_available_extractors()
|
||||
|
||||
for extractor_description in extractors
|
||||
if extractor_description[2]
|
||||
continue
|
||||
endif
|
||||
|
||||
if ! empty( result )
|
||||
let result .= "\n"
|
||||
endif
|
||||
|
||||
let result .= extractor_description[0]
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#open(...)
|
||||
"call railmoon#trace#start_debug('oscan.debug')
|
||||
|
||||
if empty( a:000 )
|
||||
call s:show_available_extractors()
|
||||
return
|
||||
endif
|
||||
|
||||
let extractor_name = a:000[0]
|
||||
|
||||
" not real extractor, but convinient way to quick run through last
|
||||
" results
|
||||
"
|
||||
if ( extractor_name == 'lastup' || extractor_name == 'lastdown' ) && !empty( s:last_extractor )
|
||||
call s:process_last_extractor_quick_selection( extractor_name )
|
||||
return
|
||||
endif
|
||||
|
||||
call railmoon#trace#debug('save invoker position')
|
||||
|
||||
let s:plugin_invoker_position = railmoon#widget#window#save_selected()
|
||||
|
||||
call railmoon#trace#debug('create tag browser:'.extractor_name)
|
||||
|
||||
let extractor = {}
|
||||
let extractor_description = ''
|
||||
|
||||
let is_repeat_last_extractor = extractor_name == 'last' && ! empty(s:last_extractor)
|
||||
|
||||
if is_repeat_last_extractor
|
||||
let extractor = s:last_extractor
|
||||
let extractor_description = extractor.description
|
||||
|
||||
let s:record_browser = s:last_record_browser
|
||||
elseif extractor_name == 'last'
|
||||
call s:print_error( 'Nothing to repeat' )
|
||||
return
|
||||
else
|
||||
let extractor = {}
|
||||
try
|
||||
let extractor = s:create_extractor( extractor_name )
|
||||
catch /.*/
|
||||
call s:print_error( "Can't create \"".extractor_name."\" scan" )
|
||||
return
|
||||
endtry
|
||||
|
||||
let extractor_description = extractor.description
|
||||
|
||||
let s:record_browser = railmoon#oscan#record_browser#create(extractor)
|
||||
endif
|
||||
|
||||
if s:record_browser.is_empty()
|
||||
call s:print_error( 'no records with tags found' )
|
||||
return
|
||||
endif
|
||||
|
||||
let s:last_record_browser = deepcopy(s:record_browser)
|
||||
let s:last_extractor = deepcopy(extractor)
|
||||
|
||||
call railmoon#trace#debug('create new tab page')
|
||||
|
||||
try
|
||||
"set lazyredraw
|
||||
silent tab help
|
||||
|
||||
let width = winwidth('%')
|
||||
|
||||
let s:plugin_window_goes_close = 0
|
||||
|
||||
call railmoon#widget#stop_handle_autocommands()
|
||||
call s:turnoff_unexpected_plugins()
|
||||
|
||||
call railmoon#trace#debug('create available_tags_window')
|
||||
let tags_window_width = width/5
|
||||
exec tags_window_width.' vsplit'
|
||||
|
||||
let s:available_tags_window = railmoon#widget#selection_window#create(
|
||||
\ 'Available tags window',
|
||||
\ extractor_description,
|
||||
\ 'TODO',
|
||||
\ s:suggestion_window_model,
|
||||
\ s:suggestion_window_callback)
|
||||
|
||||
call s:map_common_keys()
|
||||
|
||||
call s:available_tags_window.draw()
|
||||
|
||||
|
||||
call railmoon#trace#debug('create result_window')
|
||||
wincmd w
|
||||
let s:result_window = railmoon#widget#selection_window#create(
|
||||
\ 'Result window',
|
||||
\ extractor_description,
|
||||
\ 'DiffAdd',
|
||||
\ s:result_window_model,
|
||||
\ s:result_window_callback)
|
||||
|
||||
call s:map_common_keys()
|
||||
|
||||
call extractor.colorize()
|
||||
|
||||
if is_repeat_last_extractor
|
||||
call s:result_window.select_item(s:last_selected_result_item_number)
|
||||
endif
|
||||
|
||||
call railmoon#trace#debug('create tag_enter_window')
|
||||
split
|
||||
resize 1
|
||||
let edit_line_window = railmoon#widget#edit_line_window#create(
|
||||
\'Tag enter window',
|
||||
\ extractor_description,
|
||||
\ s:tag_enter_window_callback)
|
||||
|
||||
call s:map_common_keys()
|
||||
call s:map_result_moving_keys()
|
||||
call s:map_suggestion_moving_keys()
|
||||
|
||||
|
||||
if ! is_repeat_last_extractor
|
||||
let tag_line = join(a:000[ 1: ], ',')
|
||||
if len(tag_line) > 0
|
||||
let tag_line .= ','
|
||||
endif
|
||||
|
||||
call edit_line_window.set_line(tag_line)
|
||||
else
|
||||
call edit_line_window.set_line(s:last_entred_tags_line)
|
||||
endif
|
||||
|
||||
call railmoon#widget#window#select(edit_line_window.id)
|
||||
startinsert!
|
||||
catch /.*/
|
||||
call s:print_error( v:exception )
|
||||
finally
|
||||
call railmoon#widget#start_handle_autocommands()
|
||||
"set nolazyredraw
|
||||
"redraw
|
||||
endtry
|
||||
|
||||
let s:tag_enter_window_callback.edit_line_window = edit_line_window
|
||||
let s:tag_enter_window_callback.available_tags_window = s:available_tags_window
|
||||
let s:tag_enter_window_callback.result_window = s:result_window
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ testing ]
|
||||
" -
|
||||
let s:unit_test = railmoon#unit_test#create('oscan')
|
||||
|
||||
function! s:unit_test.test_tag_in_line()
|
||||
call self.assert_equal(s:tag_in_line('January,', 7), 'January')
|
||||
call self.assert_equal(s:tag_in_line('January,', 8), 'January')
|
||||
call self.assert_equal(s:tag_in_line('January,', 9), '')
|
||||
call self.assert_equal(s:tag_in_line('January,February', 8), 'January')
|
||||
call self.assert_equal(s:tag_in_line(',word,', 2), 'word')
|
||||
call self.assert_equal(s:tag_in_line(',word,', 3), 'word')
|
||||
call self.assert_equal(s:tag_in_line(',word,', 4), 'word')
|
||||
call self.assert_equal(s:tag_in_line(',word,', 5), 'word')
|
||||
call self.assert_equal(s:tag_in_line(',word,', 6), 'word')
|
||||
call self.assert_equal(s:tag_in_line('word,', 4), 'word')
|
||||
call self.assert_equal(s:tag_in_line('word,', 5), 'word')
|
||||
call self.assert_equal(s:tag_in_line('word,', 6), '')
|
||||
call self.assert_equal(s:tag_in_line('word,,', 6), 'word')
|
||||
call self.assert_equal(s:tag_in_line('', 1), '')
|
||||
call self.assert_equal(s:tag_in_line(',', 1), '')
|
||||
endfunction
|
||||
|
||||
call s:unit_test.run()
|
||||
|
@ -1,73 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#buffers
|
||||
" Purpose: extract buffer names to select
|
||||
|
||||
function! railmoon#oscan#extractor#buffers#create()
|
||||
let new_extractor = copy(s:tag_scan_buffers_extractor)
|
||||
let new_extractor.description = 'Select buffer to edit'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_buffers_extractor = {}
|
||||
function! s:tag_scan_buffers_extractor.process(record)
|
||||
if &modified
|
||||
let choice = inputlist( [ "Buffer is modified.", "1. Save current and continue" , "2. Break", "3. Open in new tab" ] )
|
||||
if 1 == choice
|
||||
update
|
||||
elseif 2 == choice
|
||||
return
|
||||
elseif 3 == choice
|
||||
tab new
|
||||
else
|
||||
tab new
|
||||
endif
|
||||
endif
|
||||
|
||||
exec 'buffer '.a:record.data
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_buffers_extractor.tags_by_name(buffer_name, buffer_number)
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_file_name(a:buffer_name)
|
||||
|
||||
if index(tags, string(a:buffer_number)) == -1
|
||||
call add(tags, a:buffer_number)
|
||||
endif
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_buffers_extractor.header_by_name(buffer_name, buffer_number)
|
||||
return [ a:buffer_name ]
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_buffers_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let buffers = railmoon#oscan#extractor#util#buffer_list()
|
||||
|
||||
for buffer_info in buffers
|
||||
|
||||
let buffer_number = buffer_info[0]
|
||||
let buffer_name = buffer_info[1]
|
||||
|
||||
call add(result, railmoon#oscan#record#create( self.header_by_name(buffer_name, buffer_number),
|
||||
\ self.tags_by_name(buffer_name, buffer_number),
|
||||
\ buffer_number,
|
||||
\ buffer_number))
|
||||
|
||||
endfor
|
||||
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_buffers_extractor.colorize()
|
||||
syntax match FileName /.*\zs\/.*\ze/
|
||||
|
||||
hi link FileName Identifier
|
||||
endfunction
|
||||
|
@ -1,54 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#changes
|
||||
" Purpose: extract recently changed lines to jump to
|
||||
|
||||
function! railmoon#oscan#extractor#changes#create()
|
||||
let new_extractor = copy(s:tag_scan_changes_extractor)
|
||||
let new_extractor.description = 'Select recently changed lines to jump to'
|
||||
let new_extractor.filetype = &filetype
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_changes_extractor = {}
|
||||
function! s:tag_scan_changes_extractor.process(record)
|
||||
exec a:record.data
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_changes_extractor.extract()
|
||||
let result = []
|
||||
|
||||
redir => changes_string
|
||||
silent changes
|
||||
redir END
|
||||
|
||||
let changes_list = split(changes_string, "\n")
|
||||
let pattern = '\s*\(\d\+\)\s*\(\d\+\)\s*\(\d\+\)\s*\(.*\)$'
|
||||
|
||||
call reverse(changes_list)
|
||||
for change_el in changes_list
|
||||
if change_el !~ pattern
|
||||
continue
|
||||
endif
|
||||
|
||||
let line_number = substitute(change_el, pattern, '\2', '')
|
||||
let line = substitute(change_el, pattern, '\4', '')
|
||||
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_line(line)
|
||||
|
||||
let header = [ line ]
|
||||
call add(result, railmoon#oscan#record#create( header,
|
||||
\ tags,
|
||||
\ line_number,
|
||||
\ line_number))
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_changes_extractor.colorize()
|
||||
endfunction
|
||||
|
@ -1,137 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#ctags
|
||||
" Purpose: extract ctags record from current buffer
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#create()
|
||||
let new_extractor = copy(s:tag_scan_ctags_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.buffer_number = bufnr('%')
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.description = 'Extract ctags records from "'.new_extractor.file_name.'"'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#language_function(language, function_name,...)
|
||||
call railmoon#trace#debug( 'call language_function "'.a:function_name.'" for "'.a:language.'"' )
|
||||
try
|
||||
let result = eval('railmoon#oscan#extractor#ctags#'.a:language.'#'.a:function_name.'('.join(a:000,',').')')
|
||||
catch /.*/
|
||||
call railmoon#trace#debug( 'failed.['.v:exception.'] use cpp' )
|
||||
let result = eval('railmoon#oscan#extractor#ctags#cpp#'.a:function_name.'('.join(a:000,',').')')
|
||||
endtry
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#colorize_for_langauge(language)
|
||||
call railmoon#oscan#extractor#ctags#language_function(a:language, 'colorize')
|
||||
endfunction
|
||||
|
||||
" by language name return kinds to use while ctags build tags base
|
||||
" default language c++
|
||||
function! railmoon#oscan#extractor#ctags#kind_types_for_langauge(language)
|
||||
return railmoon#oscan#extractor#ctags#language_function(a:language, 'kinds')
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#process(tag_item)
|
||||
try
|
||||
let previous_magic = &magic
|
||||
set nomagic
|
||||
|
||||
if fnamemodify( @%, ':p' ) != fnamemodify( a:tag_item.filename, ':p' )
|
||||
exec 'silent edit '.a:tag_item.filename
|
||||
endif
|
||||
|
||||
silent 1
|
||||
exec a:tag_item.cmd
|
||||
finally
|
||||
let &magic = previous_magic
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" by language name and ctags tag return record
|
||||
" default language c++
|
||||
function! railmoon#oscan#extractor#ctags#record_for_language_tag( language, ctag_item )
|
||||
return railmoon#oscan#extractor#ctags#language_function( a:language, 'record', a:ctag_item )
|
||||
endfunction
|
||||
|
||||
" return language name by extension
|
||||
" default language c++
|
||||
function! railmoon#oscan#extractor#ctags#language_by_extension( extension )
|
||||
if index(['c', 'cpp', 'h', 'cxx', 'hxx', 'cc', 'hh', 'hpp'], a:extension) != -1
|
||||
return 'cpp'
|
||||
elseif a:extension == 'vim'
|
||||
return 'vim'
|
||||
elseif a:extension == 'pl'
|
||||
return 'perl'
|
||||
elseif a:extension == 'py'
|
||||
return 'python'
|
||||
endif
|
||||
|
||||
return 'cpp'
|
||||
endfunction
|
||||
|
||||
" return language name for current buffer
|
||||
" default language c++
|
||||
function! railmoon#oscan#extractor#ctags#language_by_current_buffer()
|
||||
let extension = fnamemodify(@%, ':e')
|
||||
let language = exists( '&filetype' ) ? &filetype : railmoon#oscan#extractor#ctags#language_by_extension(extension)
|
||||
|
||||
return language
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_ctags_extractor = {}
|
||||
function! s:tag_scan_ctags_extractor.process(record)
|
||||
call railmoon#oscan#extractor#ctags#process(a:record.data)
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_ctags_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let self.language = railmoon#oscan#extractor#ctags#language_by_current_buffer()
|
||||
|
||||
" fields
|
||||
" f - file name
|
||||
" s - structures
|
||||
" i - inherits
|
||||
" k - kinds
|
||||
" K - kinds full written
|
||||
" a - access
|
||||
" l - language
|
||||
" t,m,z - unknown for me yet
|
||||
" n - line numbers
|
||||
" S - signature
|
||||
" extra
|
||||
" q - tag names include namespace
|
||||
" f - file names added
|
||||
let ctags_tags = railmoon#ctags_util#taglist_for_file(self.file_name,
|
||||
\ self.language,
|
||||
\ railmoon#oscan#extractor#ctags#kind_types_for_langauge(self.language),
|
||||
\ 'sikaS')
|
||||
|
||||
for item in ctags_tags
|
||||
let record = railmoon#oscan#extractor#ctags#record_for_language_tag(self.language, item)
|
||||
|
||||
" no need file name to show in each row ( all tags in one file )
|
||||
let record.additional_info = ''
|
||||
|
||||
call add(result, record)
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#colorize_keywords(language)
|
||||
call railmoon#oscan#extractor#ctags#colorize_for_langauge(a:language)
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_ctags_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
call railmoon#oscan#extractor#ctags#colorize_for_langauge(self.language)
|
||||
endfunction
|
@ -1,153 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#ctags#cpp
|
||||
" Purpose: extract ctags cpp record from buffer
|
||||
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#cpp#kinds()
|
||||
return "cdefgmnpstuvx"
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#cpp#colorize()
|
||||
syntax keyword Type variable inner field enumeration function method public private protected global
|
||||
syntax keyword Keyword constructor destructor
|
||||
syntax keyword Identifier decl def
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#cpp#record( tag_item )
|
||||
let tag_list = []
|
||||
let header = ""
|
||||
let line_number = a:tag_item.cmd
|
||||
|
||||
let kind = a:tag_item.kind
|
||||
let namespace = has_key(a:tag_item, 'namespace') ? a:tag_item.namespace : ''
|
||||
|
||||
let is_object = 0
|
||||
let object_name = ''
|
||||
|
||||
for name in ( [ has_key(a:tag_item, 'class') ? a:tag_item.class : ''
|
||||
\, has_key(a:tag_item, 'struct') ? a:tag_item.struct : ''
|
||||
\, has_key(a:tag_item, 'enum') ? a:tag_item.enum : ''
|
||||
\, has_key(a:tag_item, 'union') ? a:tag_item.union : '' ] )
|
||||
if ! empty(name)
|
||||
let object_name = name
|
||||
let is_object = 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
let tagname = split(a:tag_item.name, '::')[ -1]
|
||||
|
||||
let is_constructor = 0
|
||||
let is_destructor = 0
|
||||
|
||||
if is_object
|
||||
let last_part_of_object_name = split(object_name, '::')[ -1]
|
||||
let is_constructor = tagname == last_part_of_object_name
|
||||
let is_destructor = tagname == '~'.last_part_of_object_name
|
||||
endif
|
||||
|
||||
|
||||
if kind == 'f' || kind == 'p'
|
||||
if is_object
|
||||
if is_constructor
|
||||
let header .= 'constructor '
|
||||
call add(tag_list, 'constructor')
|
||||
elseif is_destructor
|
||||
let header .= 'destructor '
|
||||
call add(tag_list, 'destructor')
|
||||
else
|
||||
let header .= 'method '
|
||||
call add(tag_list, 'method')
|
||||
endif
|
||||
else
|
||||
let header .= "function "
|
||||
call add(tag_list, "function")
|
||||
endif
|
||||
|
||||
if kind == 'p'
|
||||
let header .= 'decl. '
|
||||
call add(tag_list, "decl")
|
||||
else
|
||||
let header .= 'def. '
|
||||
call add(tag_list, "def")
|
||||
endif
|
||||
elseif kind == 'c'
|
||||
let header .= "class "
|
||||
call add(tag_list, "class")
|
||||
call add(tag_list, "object")
|
||||
elseif kind == 'u'
|
||||
let header .= "union "
|
||||
call add(tag_list, "union")
|
||||
call add(tag_list, "object")
|
||||
elseif kind == 's'
|
||||
let header .= "struct "
|
||||
call add(tag_list, "struct")
|
||||
call add(tag_list, "object")
|
||||
elseif kind == 'g'
|
||||
let header .= "enum "
|
||||
call add(tag_list, "enum")
|
||||
elseif kind == 'd'
|
||||
let header .= "#define "
|
||||
call add(tag_list, "define")
|
||||
elseif kind == 'm'
|
||||
let header .= "field "
|
||||
call add(tag_list, "field")
|
||||
elseif kind == 'n'
|
||||
let header .= "namespace "
|
||||
call add(tag_list, "namespace")
|
||||
elseif kind == 't'
|
||||
let header .= "typedef "
|
||||
call add(tag_list, "typedef")
|
||||
elseif kind == 'v'
|
||||
let header .= "global variable "
|
||||
call extend(tag_list, ["variable", "global"])
|
||||
elseif kind == 'e'
|
||||
let header .= "enumeration "
|
||||
call add(tag_list, "enumeration")
|
||||
endif
|
||||
|
||||
call add(tag_list, tagname)
|
||||
if is_object
|
||||
call extend(tag_list, split(object_name, '::'))
|
||||
endif
|
||||
|
||||
if ! empty(namespace)
|
||||
call extend(tag_list, split(namespace, '::'))
|
||||
endif
|
||||
|
||||
if is_object
|
||||
let header .= object_name.'::'
|
||||
endif
|
||||
|
||||
if ! empty(namespace)
|
||||
let header .= namespace.'::'
|
||||
endif
|
||||
|
||||
let header .= tagname
|
||||
|
||||
if kind =~ '[fp]' && has_key(a:tag_item, 'signature')
|
||||
let header .= a:tag_item.signature
|
||||
endif
|
||||
|
||||
let access = has_key(a:tag_item, 'access') ? a:tag_item.access : ''
|
||||
|
||||
if ! empty(access)
|
||||
if kind =~ '[csug]'
|
||||
call add(tag_list, 'inner')
|
||||
let header = 'inner '.header
|
||||
endif
|
||||
|
||||
let header = access.' '.header
|
||||
call add(tag_list, access)
|
||||
endif
|
||||
|
||||
let file_name = has_key(a:tag_item, 'filename') ? a:tag_item.filename : ''
|
||||
|
||||
return railmoon#oscan#record#create([header], tag_list, a:tag_item, fnamemodify(file_name, ':t'))
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -1,42 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#ctags#py
|
||||
" Purpose: extract ctags html record from buffer
|
||||
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#html#kinds()
|
||||
return "af"
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#html#colorize()
|
||||
syntax keyword Type anchor function
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#html#record( tag_item )
|
||||
let tag_list = []
|
||||
let header = ""
|
||||
|
||||
let kind = a:tag_item.kind
|
||||
|
||||
let tagname = a:tag_item.name
|
||||
"let tagname = substitute( tagname, "'\\(.*\\)'", "\1", "g" )
|
||||
|
||||
if kind =~ 'a'
|
||||
let header .= 'anchor '
|
||||
call add(tag_list, 'anchor')
|
||||
elseif kind == 'f'
|
||||
let header .= "function "
|
||||
call add(tag_list, "function")
|
||||
endif
|
||||
|
||||
call add(tag_list, tagname)
|
||||
|
||||
let header .= tagname
|
||||
|
||||
let file_name = has_key(a:tag_item, 'filename') ? a:tag_item.filename : ''
|
||||
|
||||
return railmoon#oscan#record#create([header], tag_list, a:tag_item, fnamemodify(file_name, ':t'))
|
||||
endfunction
|
||||
|
@ -1,91 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#ctags#py
|
||||
" Purpose: extract ctags python record from buffer
|
||||
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#python#kinds()
|
||||
return "cfm"
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#python#colorize()
|
||||
syntax keyword Type class function method inner public private
|
||||
syntax keyword Keyword constructor method
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#python#record( tag_item )
|
||||
let tag_list = []
|
||||
let header = ""
|
||||
let line_number = a:tag_item.cmd
|
||||
|
||||
let kind = a:tag_item.kind
|
||||
|
||||
let is_object = 0
|
||||
let object_name = ''
|
||||
|
||||
for name in ( [ has_key(a:tag_item, 'class') ? a:tag_item.class : '' ] )
|
||||
if ! empty(name)
|
||||
let object_name = name
|
||||
let is_object = 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
let tagname = a:tag_item.name
|
||||
|
||||
let is_constructor = 0
|
||||
|
||||
if is_object
|
||||
let is_constructor = tagname == '__init__'
|
||||
endif
|
||||
|
||||
if kind == 'm'
|
||||
if is_object
|
||||
if is_constructor
|
||||
let header .= 'constructor '
|
||||
call add(tag_list, 'constructor')
|
||||
else
|
||||
let header .= 'method '
|
||||
call add(tag_list, 'method')
|
||||
endif
|
||||
endif
|
||||
elseif kind == 'c'
|
||||
let header .= "class "
|
||||
call add(tag_list, "class")
|
||||
call add(tag_list, "object")
|
||||
elseif kind == 'm'
|
||||
let header .= "function "
|
||||
call add(tag_list, "function")
|
||||
endif
|
||||
|
||||
call add(tag_list, tagname)
|
||||
if is_object
|
||||
call extend(tag_list, split(object_name, '::'))
|
||||
endif
|
||||
|
||||
if is_object
|
||||
let header .= object_name.'.'
|
||||
endif
|
||||
|
||||
let header .= tagname
|
||||
|
||||
if kind == 'c' && ! empty(object_name)
|
||||
call add(tag_list, 'inner')
|
||||
let header = 'inner '.header
|
||||
endif
|
||||
|
||||
let access = has_key(a:tag_item, 'access') ? a:tag_item.access : ''
|
||||
if ! empty(access)
|
||||
let header = access.' '.header
|
||||
call add(tag_list, access)
|
||||
endif
|
||||
|
||||
let file_name = has_key(a:tag_item, 'filename') ? a:tag_item.filename : ''
|
||||
|
||||
return railmoon#oscan#record#create([header], tag_list, a:tag_item, fnamemodify(file_name, ':t'))
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#ctags#vim
|
||||
" Purpose: extract ctags vim record from buffer
|
||||
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#vim#kinds()
|
||||
return "afk"
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#vim#colorize()
|
||||
syntax keyword Type function variable autogroup
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#vim#record( tag_item )
|
||||
let tag_list = []
|
||||
let header = ""
|
||||
let line_number = a:tag_item
|
||||
|
||||
let kind = a:tag_item.kind
|
||||
|
||||
call add(tag_list, a:tag_item.name)
|
||||
|
||||
if kind == 'a'
|
||||
let header .= "autogroup "
|
||||
call add(tag_list, "autogroup")
|
||||
elseif kind == 'f'
|
||||
let header .= "function "
|
||||
call add(tag_list, "function")
|
||||
elseif kind == 'v'
|
||||
let header .= "variable "
|
||||
call add(tag_list, "variable")
|
||||
endif
|
||||
|
||||
let header .= a:tag_item.name
|
||||
|
||||
return railmoon#oscan#record#create( [ ' '.header ], tag_list, line_number)
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -1,121 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#definition_declaration
|
||||
" Purpose: extract ctags record from buffer
|
||||
|
||||
function! railmoon#oscan#extractor#definition_declaration#create()
|
||||
let new_extractor = copy(s:tag_scan_definition_declaration_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.buffer_number = bufnr('%')
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.description = 'Go to possible definition/declaration for current function'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
|
||||
let s:tag_scan_definition_declaration_extractor = {}
|
||||
function! s:tag_scan_definition_declaration_extractor.process(record)
|
||||
call railmoon#oscan#extractor#ctags#process(a:record.data)
|
||||
endfunction
|
||||
|
||||
function! s:get_nearest_ctags_tag()
|
||||
let filename = @%
|
||||
let linenumber = line('.')
|
||||
|
||||
let self.language = railmoon#oscan#extractor#ctags#language_by_current_buffer()
|
||||
|
||||
let ctags_tags = railmoon#ctags_util#taglist_for_file(filename, language, railmoon#oscan#extractor#ctags#kind_types_for_langauge(language), 'sikaS')
|
||||
|
||||
let i = len(ctags_tags) - 1
|
||||
while i >= 0
|
||||
let tag_item = ctags_tags[i]
|
||||
|
||||
if linenumber >= tag_item.cmd
|
||||
return tag_item
|
||||
endif
|
||||
let i -= 1
|
||||
endwhile
|
||||
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! s:is_equal_tag_attribute(tag_left, tag_right, attribute)
|
||||
let left_has_attribute = has_key(a:tag_left, a:attribute)
|
||||
let right_has_attribute = has_key(a:tag_right, a:attribute)
|
||||
|
||||
if left_has_attribute && right_has_attribute
|
||||
return a:tag_left[a:attribute] == a:tag_right[a:attribute]
|
||||
endif
|
||||
|
||||
if ! left_has_attribute && ! right_has_attribute
|
||||
return 1
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:return_definitions(ctags_tag)
|
||||
let result = []
|
||||
let similar_tags = taglist('\<'.a:ctags_tag.name.'\>')
|
||||
|
||||
for tag_item in similar_tags
|
||||
if tag_item.kind == 'p'
|
||||
continue
|
||||
endif
|
||||
|
||||
if s:is_equal_tag_attribute(a:ctags_tag, tag_item, 'class') &&
|
||||
\ s:is_equal_tag_attribute(a:ctags_tag, tag_item, 'namespace')
|
||||
|
||||
call add(result, tag_item)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:return_declarations(ctags_tag)
|
||||
let result = []
|
||||
let similar_tags = taglist('\<'.a:ctags_tag.name.'\>')
|
||||
|
||||
for tag_item in similar_tags
|
||||
if tag_item.kind != 'p'
|
||||
continue
|
||||
endif
|
||||
|
||||
if s:is_equal_tag_attribute(a:ctags_tag, tag_item, 'class') &&
|
||||
\ s:is_equal_tag_attribute(a:ctags_tag, tag_item, 'namespace')
|
||||
|
||||
call add(result, tag_item)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_definition_declaration_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let extension = self.file_extension
|
||||
let language = railmoon#oscan#extractor#ctags#language_by_extension(extension)
|
||||
let self.language = language
|
||||
|
||||
let nearest_tag = s:get_nearest_ctags_tag()
|
||||
let ctags_tags = nearest_tag.kind =~ 'p' ? s:return_definitions(nearest_tag) : s:return_declarations(nearest_tag)
|
||||
|
||||
for item in ctags_tags
|
||||
let record = railmoon#oscan#extractor#ctags#record_for_language_tag(language, item)
|
||||
call add(result, record)
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_definition_declaration_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
call railmoon#oscan#extractor#ctags#colorize_keywords(self.language)
|
||||
endfunction
|
@ -1,31 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#file
|
||||
" Purpose: create extractor by file extension and or name
|
||||
|
||||
function! railmoon#oscan#extractor#file#create()
|
||||
let file_name = expand("%:p")
|
||||
let file_extension = expand("%:e")
|
||||
|
||||
|
||||
try
|
||||
return eval('railmoon#oscan#extractor#'.file_extension.'#'.'create()')
|
||||
catch /.*/
|
||||
endtry
|
||||
|
||||
let extractor_name = 'railmoon#oscan#extractor#ctags'
|
||||
|
||||
try
|
||||
let extractor = eval(extractor_name.'#'.'create()')
|
||||
catch /.*/
|
||||
echo 'extractor "'.extractor_name. '" not found. use ctags as default'
|
||||
echo '.'
|
||||
echo '.'
|
||||
echo '.'
|
||||
endtry
|
||||
|
||||
return railmoon#oscan#extractor#ctags#create()
|
||||
endfunction
|
||||
|
@ -1,86 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#files
|
||||
" Purpose: extract files from current file directory to open
|
||||
|
||||
function! railmoon#oscan#extractor#files#create()
|
||||
let new_extractor = copy(s:tag_scan_files_extractor)
|
||||
|
||||
let file_name = expand("%:p")
|
||||
let new_extractor.current_file_dir = fnamemodify(file_name, ":p:h")
|
||||
|
||||
let new_extractor.description = 'Select file from "'.new_extractor.current_file_dir.'" directory to open'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_files_extractor = {}
|
||||
function! s:tag_scan_files_extractor.process(record)
|
||||
if &modified
|
||||
let choice = inputlist( [ "Buffer is modified.", "1. Save current and continue" , "2. Break", "3. Open in new tab" ] )
|
||||
if 1 == choice
|
||||
update
|
||||
elseif 2 == choice
|
||||
return
|
||||
elseif 3 == choice
|
||||
tab new
|
||||
else
|
||||
tab new
|
||||
endif
|
||||
endif
|
||||
|
||||
let buf_number = bufnr(a:record.data)
|
||||
if -1 == buf_number
|
||||
exec 'edit '.escape(a:record.data,' ')
|
||||
else
|
||||
exec 'buffer '.buf_number
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_files_extractor.tags_by_name(buffer_name, buffer_number)
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_file_name(a:buffer_name)
|
||||
|
||||
if index(tags, string(a:buffer_number)) == -1
|
||||
call add(tags, a:buffer_number)
|
||||
endif
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_files_extractor.header_by_name(buffer_name, buffer_number)
|
||||
return [ a:buffer_name ]
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_files_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let files = split(glob( self.current_file_dir."/*" ), "\n")
|
||||
"call extend(files, split(glob( self.current_file_dir."/.*" ), "\n"))
|
||||
|
||||
for file in files
|
||||
|
||||
if ! filereadable(file)
|
||||
continue
|
||||
endif
|
||||
|
||||
let just_name = fnamemodify(file, ":t:r")
|
||||
let ext = fnamemodify(file, ":e")
|
||||
|
||||
let tags = [ just_name, ext ]
|
||||
|
||||
call add(result, railmoon#oscan#record#create( [ just_name ],
|
||||
\ tags,
|
||||
\ file,
|
||||
\ ext))
|
||||
|
||||
endfor
|
||||
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_files_extractor.colorize()
|
||||
endfunction
|
||||
|
@ -1,86 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#marks
|
||||
" Purpose: extract marks to select
|
||||
|
||||
function! railmoon#oscan#extractor#marks#create()
|
||||
let new_extractor = copy(s:tag_scan_marks_extractor)
|
||||
let new_extractor.description = 'Select mark to jump'
|
||||
let new_extractor.filetype = &filetype
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_marks_extractor = {}
|
||||
function! s:tag_scan_marks_extractor.process(record)
|
||||
exec "normal \'".a:record.data
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_marks_extractor.extract()
|
||||
let result = []
|
||||
|
||||
redir => marks_string
|
||||
silent marks
|
||||
redir END
|
||||
|
||||
let marks_list = split(marks_string, "\n")
|
||||
let pattern = '\s*\(\S\+\)\s*\(\d\+\)\s*\(\d\+\)\s*\(.*\)$'
|
||||
|
||||
for mark_value in marks_list
|
||||
if mark_value !~ pattern
|
||||
continue
|
||||
endif
|
||||
|
||||
let mark_symbol = substitute(mark_value, pattern, '\1', '')
|
||||
let mark_line = substitute(mark_value, pattern, '\2', '')
|
||||
let mark_col = substitute(mark_value, pattern, '\3', '')
|
||||
let mark_file_or_line = substitute(mark_value, pattern, '\4', '')
|
||||
|
||||
let tags = []
|
||||
|
||||
let file_name = fnamemodify(mark_file_or_line, ':p')
|
||||
|
||||
let is_file = filereadable(file_name)
|
||||
|
||||
if is_file
|
||||
let header_line = '<# '.file_name.' #>'
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_file_name(file_name)
|
||||
else
|
||||
let header_line = mark_file_or_line
|
||||
let tags = split(mark_file_or_line, '\W')
|
||||
call filter(tags, 'v:val != ""')
|
||||
call add(tags, 'buffer')
|
||||
endif
|
||||
|
||||
if mark_symbol =~ '[QWERTYUIOPASDFGHJKLZXCVBNM1234567890]'
|
||||
call add(tags, 'global')
|
||||
endif
|
||||
|
||||
if mark_symbol =~ '[QWERTYUIOPASDFGHJKLZXCVBNM]'
|
||||
call add(tags, 'user')
|
||||
endif
|
||||
|
||||
let header_line = printf("%5s %5s ", mark_line, mark_col).header_line
|
||||
|
||||
let header = [ header_line ]
|
||||
call add(result, railmoon#oscan#record#create( header,
|
||||
\ tags,
|
||||
\ mark_symbol,
|
||||
\ mark_symbol))
|
||||
endfor
|
||||
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_marks_extractor.colorize()
|
||||
syn match Comment /.*/ contained contains=Identifier
|
||||
syn region Identifier matchgroup=Ignore start='<#' end='#>' contained
|
||||
|
||||
syn match TODO /\|/ nextgroup=Keyword
|
||||
syn match Keyword /\d\+\s/ nextgroup=Statement contained skipwhite
|
||||
syn match Statement /\d\+/ nextgroup=Comment contained skipwhite
|
||||
endfunction
|
||||
|
@ -1,123 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#multiline_search
|
||||
" Purpose: extract strings ( and their neighbours) with search pattern from current file
|
||||
|
||||
function! railmoon#oscan#extractor#multiline_search#create()
|
||||
let new_extractor = copy(s:tag_scan_multiline_search_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.first_line_to_search = 1
|
||||
let new_extractor.last_line_to_search = line('$')
|
||||
let new_extractor.pattern = @/
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.description = 'Mutliline search "'.new_extractor.pattern.'" in "'.new_extractor.file_name.'"'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_multiline_search_extractor = {}
|
||||
function! s:tag_scan_multiline_search_extractor.process(record)
|
||||
exec a:record.data
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_multiline_search_extractor.tags_by_line(line_number_start, data)
|
||||
let tags = []
|
||||
|
||||
let i = 0
|
||||
for line in a:data
|
||||
call extend(tags, railmoon#oscan#extractor#util#tags_from_searched_line(a:line_number_start + i, line) )
|
||||
let i += 1
|
||||
endfor
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_multiline_search_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let pos = getpos('.')
|
||||
|
||||
call cursor(self.first_line_to_search, 1)
|
||||
|
||||
let pattern = self.pattern
|
||||
let last_search_result = -1
|
||||
|
||||
let option = 'Wc'
|
||||
|
||||
let match_pattern_line_numbers = []
|
||||
|
||||
while 1
|
||||
let search_result = search(pattern, option, self.last_line_to_search)
|
||||
|
||||
if search_result == 0
|
||||
break
|
||||
endif
|
||||
|
||||
if search_result != last_search_result
|
||||
call add(match_pattern_line_numbers, search_result)
|
||||
endif
|
||||
|
||||
let last_search_result = search_result
|
||||
let option = 'W'
|
||||
endwhile
|
||||
|
||||
let match_cout = len(match_pattern_line_numbers)
|
||||
|
||||
if match_cout == 0
|
||||
return result
|
||||
endif
|
||||
|
||||
let min_block_size = 2
|
||||
let i = 0
|
||||
|
||||
while i < match_cout
|
||||
|
||||
let block_begin = match_pattern_line_numbers[i] - min_block_size
|
||||
let delta = 0
|
||||
if block_begin < self.first_line_to_search
|
||||
let delta = self.first_line_to_search - block_begin
|
||||
let block_begin = self.first_line_to_search
|
||||
endif
|
||||
|
||||
let block_end = match_pattern_line_numbers[i] + min_block_size + delta
|
||||
if block_end > self.last_line_to_search
|
||||
let block_end = self.last_line_to_search
|
||||
endif
|
||||
|
||||
while i < match_cout
|
||||
if match_pattern_line_numbers[i] - min_block_size > block_end
|
||||
let i -= 1
|
||||
break
|
||||
endif
|
||||
|
||||
let block_end = match_pattern_line_numbers[i] + min_block_size
|
||||
|
||||
let i += 1
|
||||
endwhile
|
||||
|
||||
let data = getline(block_begin, block_end)
|
||||
let tag_list = self.tags_by_line(block_begin, data)
|
||||
|
||||
call add(tag_list, block_begin)
|
||||
|
||||
call add(result, railmoon#oscan#record#create(data, tag_list, block_begin, block_begin))
|
||||
|
||||
let i +=1
|
||||
endwhile
|
||||
|
||||
|
||||
call setpos('.', pos)
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_multiline_search_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
exec 'syn match Search "'.'\c'.self.pattern.'"'
|
||||
" exec 'syn match Identifier "[**].*"'
|
||||
endfunction
|
||||
|
@ -1,69 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#paste
|
||||
" Purpose: extract registers texts to paste
|
||||
|
||||
function! railmoon#oscan#extractor#paste#create()
|
||||
let new_extractor = copy(s:tag_scan_paste_extractor)
|
||||
let new_extractor.description = 'Select register to paste'
|
||||
let new_extractor.filetype = &filetype
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_paste_extractor = {}
|
||||
function! s:tag_scan_paste_extractor.process(record)
|
||||
exec 'normal "'.a:record.data."p"
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_paste_extractor.extract()
|
||||
let result = []
|
||||
|
||||
redir => paste_string
|
||||
silent registers
|
||||
redir END
|
||||
|
||||
let paste_list = split(paste_string, "\n")
|
||||
let pattern = '^"\(\S\)\s\s\s\(.*\)$'
|
||||
|
||||
for line in paste_list
|
||||
if line !~ pattern
|
||||
continue
|
||||
endif
|
||||
|
||||
let register_name = substitute(line, pattern, '\1', '')
|
||||
let register_value = eval('@'.register_name)
|
||||
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_line(register_value)
|
||||
|
||||
let register_value_list = split( register_value, "\n" )
|
||||
let shortened_value_list = register_value_list
|
||||
if len( register_value_list ) > 5
|
||||
let shortened_value_list = register_value_list[0:2]
|
||||
call add(shortened_value_list, "... more ...")
|
||||
call extend(shortened_value_list, register_value_list[-2:-1])
|
||||
endif
|
||||
|
||||
let additional_data = register_name
|
||||
let header = shortened_value_list
|
||||
|
||||
if empty(header)
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(result, railmoon#oscan#record#create(header,
|
||||
\ tags,
|
||||
\ register_name,
|
||||
\ register_name))
|
||||
endfor
|
||||
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_paste_extractor.colorize()
|
||||
syn match Identifier /\.\.\. more \.\.\./
|
||||
endfunction
|
||||
|
@ -1,138 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#sco
|
||||
" Purpose: extract sco taged headers or sco folded result
|
||||
|
||||
function! railmoon#oscan#extractor#sco#create()
|
||||
let new_extractor = copy(s:tag_scan_sco_extractor)
|
||||
|
||||
|
||||
let new_extractor.folded_result_start = searchpair('>>>', '', '<<<', 'bnW')
|
||||
let new_extractor.folded_result_end = searchpair('>>>', '', '<<<', 'nW')
|
||||
|
||||
let new_extractor.buffer_number = bufnr('%')
|
||||
|
||||
let new_extractor.is_extract_tag_headers = 0 == new_extractor.folded_result_start
|
||||
|
||||
if new_extractor.is_extract_tag_headers
|
||||
let new_extractor.description = 'SourceCodeObedience. Select header to move to'
|
||||
else
|
||||
let new_extractor.description = 'SourceCodeObedience. Select result to move to'
|
||||
endif
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_sco_extractor = {}
|
||||
function! s:tag_scan_sco_extractor.process(record)
|
||||
exec 'buffer '.self.buffer_number
|
||||
update
|
||||
e
|
||||
exec a:record.data
|
||||
|
||||
if ! self.is_extract_tag_headers
|
||||
Enter
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_sco_extractor.taged_headers_tags_by_line(line_number, line)
|
||||
return split(substitute(a:line, '^\s*tags:\(.*\)', '\1', ''), ',')
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_sco_extractor.taged_headers_header_by_line(line_number, line)
|
||||
let line_with_header = getline(a:line_number - 1)
|
||||
if line_with_header =~ '^\s*header:'
|
||||
return [ substitute(line_with_header, '^\s*header:\(.*\)', '\1', '') ]
|
||||
endif
|
||||
|
||||
return [ '[ '.substitute(a:line, '^\s*tags:\(.*\)', '\1', '').' ]' ]
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_sco_extractor.extract_taged_headers()
|
||||
let result = []
|
||||
|
||||
let pos = getpos('.')
|
||||
call cursor(1, 1)
|
||||
|
||||
let pattern = '^\s*tags:'
|
||||
|
||||
let option = 'Wc'
|
||||
|
||||
while 1
|
||||
let search_result = search(pattern, option)
|
||||
|
||||
if search_result == 0
|
||||
break
|
||||
endif
|
||||
|
||||
let line = getline(search_result)
|
||||
|
||||
let data = self.taged_headers_header_by_line(search_result, line)
|
||||
let tag_list = self.taged_headers_tags_by_line(search_result, line)
|
||||
|
||||
call add(result, railmoon#oscan#record#create(data, tag_list, search_result, search_result))
|
||||
|
||||
let option = 'W'
|
||||
endwhile
|
||||
|
||||
call setpos('.', pos)
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
let s:smart_mark_pattern_comment = '\s\+```\(.*[^>]\)>>.*$'
|
||||
let s:smart_mark_pattern_without_comment = '@\s\+\(\S\+\)\s\+\(\d*\)\s\(.*\)'
|
||||
let s:smart_mark_pattern = s:smart_mark_pattern_without_comment.s:smart_mark_pattern_comment
|
||||
|
||||
let s:sco_result_pattern = '^#\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\d\+\)\s\+\(.*\)$'
|
||||
|
||||
function! s:tag_scan_sco_extractor.extract_sco_results()
|
||||
let result = []
|
||||
|
||||
let line_number = self.folded_result_start + 1
|
||||
|
||||
while line_number < self.folded_result_end
|
||||
let line = getline(line_number)
|
||||
|
||||
if line =~ s:sco_result_pattern
|
||||
let file_name = substitute(line, s:sco_result_pattern, '\1', '')
|
||||
let function_name = substitute(line, s:sco_result_pattern, '\2', '')
|
||||
let file_line_number = substitute(line, s:sco_result_pattern, '\3', '')
|
||||
let body = substitute(line, s:sco_result_pattern, '\4', '')
|
||||
|
||||
let short_file_name = fnamemodify(file_name, ':t')
|
||||
|
||||
let tag_list = []
|
||||
call extend(tag_list, railmoon#oscan#extractor#util#tags_from_line(body))
|
||||
call add(tag_list, function_name)
|
||||
call extend(tag_list, railmoon#oscan#extractor#util#tags_from_file_name(file_name))
|
||||
|
||||
call add(result, railmoon#oscan#record#create([ body ], tag_list, line_number, short_file_name))
|
||||
endif
|
||||
|
||||
let line_number += 1
|
||||
endwhile
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_sco_extractor.extract()
|
||||
if self.is_extract_tag_headers
|
||||
return self.extract_taged_headers()
|
||||
endif
|
||||
|
||||
|
||||
return self.extract_sco_results()
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_sco_extractor.colorize()
|
||||
if self.is_extract_tag_headers
|
||||
syntax match Comment '\[.*\]' contains=Keyword
|
||||
syntax keyword Keyword tag symbol file include text grep calling contained
|
||||
else
|
||||
setf cpp
|
||||
endif
|
||||
endfunction
|
||||
|
@ -1,85 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#search
|
||||
" Purpose: extract strings with search pattern from current file
|
||||
|
||||
function! railmoon#oscan#extractor#search#create()
|
||||
let new_extractor = copy(s:tag_scan_search_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.buffer_number = bufnr('%')
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.line_number_width = len(line('$'))
|
||||
let new_extractor.first_line_to_search = 1
|
||||
let new_extractor.last_line_to_search = line('$')
|
||||
let new_extractor.pattern = @/
|
||||
let new_extractor.remove_leader_space = 1
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.description = 'Search "'.new_extractor.pattern.'" in "'.new_extractor.file_name.'"'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_search_extractor = {}
|
||||
function! s:tag_scan_search_extractor.process(record)
|
||||
exec 'buffer '.self.buffer_number
|
||||
exec a:record.data
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_extractor.tags_by_line(line_number, line) " line
|
||||
return railmoon#oscan#extractor#util#tags_from_searched_line(a:line_number, a:line)
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_extractor.header_by_line(line_number, line)
|
||||
if self.remove_leader_space
|
||||
let line = substitute(a:line, '^\s*', '', 'g')
|
||||
else
|
||||
let line = a:line
|
||||
endif
|
||||
|
||||
return [ line ]
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let pos = getpos('.')
|
||||
|
||||
call cursor(self.first_line_to_search, 1)
|
||||
|
||||
let pattern = self.pattern
|
||||
let last_search_result = -1
|
||||
|
||||
let option = 'Wc'
|
||||
|
||||
while 1
|
||||
let search_result = search(pattern, option, self.last_line_to_search)
|
||||
|
||||
if search_result == 0
|
||||
break
|
||||
endif
|
||||
|
||||
if search_result != last_search_result
|
||||
let line = getline(search_result)
|
||||
|
||||
let data = self.header_by_line(search_result, line)
|
||||
let tag_list = self.tags_by_line(search_result, line)
|
||||
|
||||
call add(result, railmoon#oscan#record#create(data, tag_list, search_result, search_result))
|
||||
endif
|
||||
|
||||
let last_search_result = search_result
|
||||
let option = 'W'
|
||||
endwhile
|
||||
|
||||
call setpos('.', pos)
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
endfunction
|
||||
|
@ -1,19 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#search_in_scope
|
||||
" Purpose: extract strings that visible in current scope
|
||||
|
||||
function! railmoon#oscan#extractor#search_in_scope#create()
|
||||
let new_extractor = railmoon#oscan#extractor#search#create()
|
||||
|
||||
let new_extractor.first_line_to_search = searchpair('{', '', '}', 'bn')
|
||||
let new_extractor.last_line_to_search = searchpair('{', '', '}', 'n')
|
||||
let new_extractor.pattern = '.*'
|
||||
let new_extractor.remove_leader_space = 0
|
||||
let new_extractor.description = 'Search in current scope. '.new_extractor.first_line_to_search.':'.new_extractor.last_line_to_search
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
@ -1,41 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#search_in_windows
|
||||
" Purpose: extract strings with search pattern from all windows
|
||||
|
||||
function! railmoon#oscan#extractor#search_in_windows#create()
|
||||
let new_extractor = copy(s:tag_scan_search_in_windows_extractor)
|
||||
|
||||
let new_extractor.pattern = @/
|
||||
let new_extractor.buffer_number = bufnr('%')
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.description = 'Search "'.new_extractor.pattern.'" in all opened windows'
|
||||
let new_extractor.not_implemented = 1
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_search_in_windows_extractor = {}
|
||||
function! s:tag_scan_search_in_windows_extractor.process(record)
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_in_windows_extractor.tags_by_line(line_number, line) " line
|
||||
"return railmoon#oscan#extractor#util#tags_from_searched_line(a:line_number, a:line)
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_in_windows_extractor.header_by_line(line_number, line)
|
||||
"let line = substitute(a:line, '^\s*', '', 'g')
|
||||
"return [ line ]
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_in_windows_extractor.search_in_buffer(tabpage_number, window_number)
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_in_windows_extractor.extract()
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_in_windows_extractor.colorize()
|
||||
endfunction
|
||||
|
@ -1,19 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#search_on_screen
|
||||
" Purpose: extract strings that visible on window from current file
|
||||
|
||||
function! railmoon#oscan#extractor#search_on_screen#create()
|
||||
let new_extractor = railmoon#oscan#extractor#search#create()
|
||||
|
||||
let new_extractor.first_line_to_search = line('w0')
|
||||
let new_extractor.last_line_to_search = line('w$')
|
||||
let new_extractor.pattern = '.*'
|
||||
let new_extractor.remove_leader_space = 0
|
||||
let new_extractor.description = 'Search on current window visible range. From line '. new_extractor.first_line_to_search.' to line '.new_extractor.last_line_to_search
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
@ -1,34 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#ctags
|
||||
" Purpose: extract ctags record from tags
|
||||
|
||||
function! railmoon#oscan#extractor#taglist#create()
|
||||
let new_extractor = copy(s:tag_scan_taglist_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.description = 'Move through all tags in "set tags=..." database'
|
||||
let new_extractor.not_implemented = 1
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_taglist_extractor = {}
|
||||
function! s:tag_scan_taglist_extractor.process(record)
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:tag_scan_taglist_extractor.extract()
|
||||
let result = []
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_taglist_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
call railmoon#oscan#extractor#ctags#colorize_keywords()
|
||||
endfunction
|
||||
|
@ -1,11 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#taglist_by_ooo
|
||||
" Purpose: extract records by object oriented type.
|
||||
|
||||
function! railmoon#oscan#extractor#taglist_by_ooo#create()
|
||||
return railmoon#oscan#extractor#taglist_by_type#create('s')
|
||||
endfunction
|
||||
|
@ -1,39 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#taglist_by_type
|
||||
" Purpose: extract records by type. help module for taglist_by_class , etc..
|
||||
|
||||
function! railmoon#oscan#extractor#taglist_by_type#create(type)
|
||||
let new_extractor = copy(s:tag_scan_taglist_by_type_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.type = a:type
|
||||
let new_extractor.description = 'Move through tags with ceratain type in "set tags=..." database "'
|
||||
let new_extractor.not_implemented = 1
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_taglist_by_type_extractor = {}
|
||||
function! s:tag_scan_taglist_by_type_extractor.process(record)
|
||||
endfunction
|
||||
|
||||
function! s:record_for_language_tag( language, ctag_item )
|
||||
return railmoon#oscan#extractor#ctags#language_function( a:language, 'record', a:ctag_item )
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_taglist_by_type_extractor.extract()
|
||||
let result = []
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_taglist_by_type_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
call railmoon#oscan#extractor#ctags#colorize_keywords()
|
||||
endfunction
|
||||
|
@ -1,54 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#taglist_under_cursor
|
||||
" Purpose: extract ctags records that fit word under curosr
|
||||
|
||||
function! railmoon#oscan#extractor#taglist_under_cursor#create()
|
||||
let new_extractor = copy(s:tag_scan_taglist_under_cursor_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.word_under_cursor = expand('<cword>')
|
||||
let new_extractor.description = 'Jump to tag "'.new_extractor.word_under_cursor.'" according to "'.&tags.'" tags dabase'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_taglist_under_cursor_extractor = {}
|
||||
function! s:tag_scan_taglist_under_cursor_extractor.process(record)
|
||||
exec 'tag '.self.word_under_cursor
|
||||
call railmoon#oscan#extractor#ctags#process(a:record.data)
|
||||
endfunction
|
||||
|
||||
function! s:record_for_language_tag( language, ctag_item )
|
||||
return railmoon#oscan#extractor#ctags#language_function( a:language, 'record', a:ctag_item )
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_taglist_under_cursor_extractor.extract()
|
||||
if empty(self.word_under_cursor)
|
||||
return []
|
||||
endif
|
||||
|
||||
let result = []
|
||||
|
||||
let self.language = railmoon#oscan#extractor#ctags#language_by_current_buffer()
|
||||
|
||||
let ctags_tags = taglist('\<'.self.word_under_cursor.'\>')
|
||||
|
||||
for item in ctags_tags
|
||||
let record = s:record_for_language_tag(self.language, item)
|
||||
let record.data = item
|
||||
call add(result, record)
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_taglist_under_cursor_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
call railmoon#oscan#extractor#ctags#colorize_keywords(self.language)
|
||||
endfunction
|
||||
|
@ -1,74 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#util
|
||||
" Purpose: common extration and tag generation functions
|
||||
|
||||
function! railmoon#oscan#extractor#util#tags_from_file_name(file_name)
|
||||
let tags = []
|
||||
let name_tags = split(a:file_name, '\W')
|
||||
|
||||
for l:tag in name_tags
|
||||
if empty(l:tag)
|
||||
continue
|
||||
endif
|
||||
|
||||
if index(tags, string(l:tag)) != -1
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(tags, l:tag)
|
||||
endfor
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#util#tags_from_line(line)
|
||||
let tags = split(a:line, '\W')
|
||||
call filter(tags, 'v:val != ""')
|
||||
|
||||
if a:line =~ '='
|
||||
call extend(tags, ['equal', '='])
|
||||
endif
|
||||
|
||||
if a:line =~ '"' || a:line =~ "'"
|
||||
call extend(tags, ['quotes', '"'])
|
||||
endif
|
||||
|
||||
if a:line =~ '\.'
|
||||
call extend(tags, ['dot', '.'])
|
||||
endif
|
||||
|
||||
if a:line =~ '[+-/\*]'
|
||||
call add(tags, 'sign')
|
||||
endif
|
||||
|
||||
if a:line =~ '&&' || a:line =~ '||' || a:line =~ '==' || a:line =~ '!=' " TODO in one expression
|
||||
call add(tags, 'logic')
|
||||
endif
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#util#tags_from_searched_line(line_number, line)
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_line( a:line )
|
||||
call add(tags, a:line_number)
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#util#buffer_list()
|
||||
let result = []
|
||||
|
||||
for buffer_number in range(1, bufnr('$'))
|
||||
if !buflisted(buffer_number)
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(result, [buffer_number, fnamemodify(bufname(buffer_number), ':p')] )
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
@ -1,84 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#vims
|
||||
" Purpose: extract vim servers to select
|
||||
|
||||
function! railmoon#oscan#extractor#vims#create()
|
||||
let new_extractor = copy(s:tag_scan_vim_extractor)
|
||||
let new_extractor.last_buffer_number = bufnr('$')
|
||||
let new_extractor.buffer_number_width = len(line('$'))
|
||||
let new_extractor.description = "Select buffer to edit among all opened Vims"
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#vims#select_buffer(buffer_number)
|
||||
|
||||
let current_tabpage = tabpagenr()
|
||||
let current_window = winnr()
|
||||
|
||||
for tabpage_number in range(1, tabpagenr('$'))
|
||||
exec (tabpage_number) . 'tabnext'
|
||||
|
||||
for window_number in range(1, winnr('$'))
|
||||
|
||||
let buffer_number = winbufnr(window_number)
|
||||
|
||||
if buffer_number == a:buffer_number
|
||||
exec (window_number) . 'wincmd w'
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
exec (current_tabpage) . 'tabnext'
|
||||
exec (current_window) . 'wincmd w'
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_vim_extractor = {}
|
||||
function! s:tag_scan_vim_extractor.process(record)
|
||||
let server_name = a:record.data[0]
|
||||
let buffer_number = a:record.data[1]
|
||||
|
||||
call remote_foreground(server_name)
|
||||
call remote_expr(server_name, 'railmoon#oscan#extractor#vims#select_buffer('.buffer_number.')')
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_vim_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let vim_servers = split(serverlist(), "\n")
|
||||
|
||||
for servername in vim_servers
|
||||
"echo servername
|
||||
"redraw
|
||||
let buffers_result = remote_expr(servername, 'railmoon#oscan#extractor#util#buffer_list()')
|
||||
let buffers_result = '['.join(split(buffers_result, "\n"), ',').']'
|
||||
|
||||
let buffers_list = eval(buffers_result)
|
||||
|
||||
for buffer_info in buffers_list
|
||||
|
||||
let tags = [ servername ]
|
||||
let buffer_number = buffer_info[0]
|
||||
let buffer_name = buffer_info[1]
|
||||
|
||||
call add(tags, fnamemodify(buffer_name, ':p:t'))
|
||||
|
||||
call add(result, railmoon#oscan#record#create( [ buffer_name ],
|
||||
\ tags,
|
||||
\ [ servername, buffer_number ],
|
||||
\ servername))
|
||||
|
||||
endfor
|
||||
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_vim_extractor.colorize()
|
||||
endfunction
|
||||
|
@ -1,79 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#windows
|
||||
" Purpose: extract window names to select
|
||||
|
||||
function! railmoon#oscan#extractor#windows#create()
|
||||
let new_extractor = copy(s:tag_scan_windows_extractor)
|
||||
let new_extractor.description = 'Select window to be active'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_windows_extractor = {}
|
||||
function! s:tag_scan_windows_extractor.process(record)
|
||||
exec a:record.data[0].'tabnext'
|
||||
exec a:record.data[1].'wincmd w'
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_windows_extractor.tags_by_name(buffer_name, buffer_number, tabpage_number, window_number)
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_file_name(a:buffer_name)
|
||||
|
||||
if index(tags, string(a:buffer_number)) == -1
|
||||
call add(tags, a:buffer_number)
|
||||
endif
|
||||
|
||||
call add(tags, 'tabpage'.a:tabpage_number)
|
||||
call add(tags, 'window'.a:window_number)
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_windows_extractor.header_by_name(buffer_name, buffer_number)
|
||||
return [ a:buffer_name ]
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_windows_extractor.extract()
|
||||
let lazyredraw_status = &lazyredraw
|
||||
|
||||
set lazyredraw
|
||||
let result = []
|
||||
|
||||
try
|
||||
|
||||
for tabpage_number in range(1, tabpagenr('$'))
|
||||
exec (tabpage_number) . 'tabnext'
|
||||
|
||||
for window_number in range(1, winnr('$'))
|
||||
|
||||
let buffer_number = winbufnr(window_number)
|
||||
let buffer_name = bufname(buffer_number)
|
||||
exec window_number.'wincmd w'
|
||||
let line_number = line('.')
|
||||
|
||||
call add(result, railmoon#oscan#record#create( self.header_by_name(buffer_name, buffer_number),
|
||||
\ self.tags_by_name(buffer_name, buffer_number, tabpage_number, window_number),
|
||||
\ [tabpage_number, window_number],
|
||||
\ '[ '.tabpage_number.', '.window_number.' ] '.fnamemodify(buffer_name, ':p:t').' '.line_number))
|
||||
|
||||
endfor
|
||||
endfor
|
||||
|
||||
catch /.*/
|
||||
echo v:exception
|
||||
echo v:throwpoint
|
||||
|
||||
finally
|
||||
let &lazyredraw = lazyredraw_status
|
||||
return result
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_windows_extractor.colorize()
|
||||
syntax match Comment /|.\{-}|/
|
||||
syntax match Keyword /[\\/]/
|
||||
syntax match Number /[0-9]\+/
|
||||
endfunction
|
||||
|
@ -1,138 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: record
|
||||
" Purpose: represent record in oscan
|
||||
|
||||
" -
|
||||
" [ plugin function ]
|
||||
" Name: railmoon#oscan#record#create
|
||||
" Purpose: create record
|
||||
" [ parameters ]
|
||||
" header record header -- list
|
||||
" tag_list list of tags associated with record
|
||||
" data record data ( line number, or buffer number, or whatever )
|
||||
" -
|
||||
function! railmoon#oscan#record#create( header, tag_list, data, ... )
|
||||
let new_record = copy( s:record )
|
||||
let s:record_id += 1
|
||||
|
||||
let new_record.header = a:header
|
||||
let new_record.tag_list = a:tag_list
|
||||
let new_record.data = a:data
|
||||
let new_record.id = s:record_id
|
||||
|
||||
if empty(a:000)
|
||||
let new_record.additional_info = ''
|
||||
else
|
||||
let new_record.additional_info = a:1
|
||||
endif
|
||||
|
||||
return new_record
|
||||
endfunction
|
||||
|
||||
let s:record = {}
|
||||
let s:record_id = 0
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: record
|
||||
" Name: has_tag
|
||||
" Purpose: determine tag presence
|
||||
" [ parameters ]
|
||||
" tag tag
|
||||
" -
|
||||
function! s:record.has_tag( tag )
|
||||
if a:tag[0] == '~'
|
||||
for l:tag in self.tag_list
|
||||
if l:tag =~ '\c'.a:tag[1 : ]
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 0
|
||||
endif
|
||||
|
||||
for l:tag in self.tag_list
|
||||
if l:tag ==? a:tag
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: record
|
||||
" Name: match_by_tags
|
||||
" Purpose: determine if record match with given tags
|
||||
" [ parameters ]
|
||||
" tags list of tags
|
||||
" -
|
||||
function! s:record.match_by_tags( tags )
|
||||
for l:tag in a:tags
|
||||
if ! self.has_tag( l:tag )
|
||||
return 0
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: record
|
||||
" Name: other_tags
|
||||
" Purpose: find tags that not in list but in that record
|
||||
" [ parameters ]
|
||||
" tags1 list of tags
|
||||
" tags2 list of tags
|
||||
" -
|
||||
function! s:record.other_tags( tags1, tags2 )
|
||||
let result = []
|
||||
|
||||
for l:tag in self.tag_list
|
||||
let string_tag = l:tag.''
|
||||
|
||||
if index(a:tags1, string_tag) == -1 &&
|
||||
\index(a:tags2, string_tag) == -1
|
||||
call add(result, string_tag)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ testing ]
|
||||
" -
|
||||
|
||||
function! s:create_test_record1()
|
||||
return railmoon#oscan#record#create( ['createTestRecord1'], [ 'edit', 'gui', 'form' ], 23 )
|
||||
endfunction
|
||||
|
||||
function! s:create_test_record2()
|
||||
return railmoon#oscan#record#create( ['createTestRecord2'], [ 'simple', 'gui' ], 26 )
|
||||
endfunction
|
||||
|
||||
let s:unit_test = railmoon#unit_test#create('oscan#record')
|
||||
|
||||
function! s:unit_test.test_record()
|
||||
call self.assert_equal(s:create_test_record1().match_by_tags(['edit']), 1)
|
||||
call self.assert_equal(s:create_test_record1().match_by_tags(['~dit']), 1)
|
||||
call self.assert_equal(s:create_test_record1().match_by_tags(['gui']), 1)
|
||||
call self.assert_equal(s:create_test_record1().match_by_tags(['form']), 1)
|
||||
call self.assert_equal(s:create_test_record1().match_by_tags(['form', 'gui']), 1)
|
||||
call self.assert_equal(s:create_test_record1().match_by_tags(['edit', 'form', 'gui']), 1)
|
||||
call self.assert_equal(! s:create_test_record1().match_by_tags(['simple', 'gui']), 1)
|
||||
call self.assert_equal(! s:create_test_record1().match_by_tags(['edit', 'fronmt', 'gui']), 1)
|
||||
call self.assert_equal(s:create_test_record1().other_tags(['edit', 'gui'], []), ['form'])
|
||||
call self.assert_equal(s:create_test_record1().other_tags(['gui'], []), ['edit', 'form'])
|
||||
call self.assert_equal(s:create_test_record1().other_tags([''], []), ['edit', 'gui', 'form'])
|
||||
call self.assert_equal(s:create_test_record1().other_tags(['edit', 'gui', 'form'], []), [])
|
||||
endfunction
|
||||
|
||||
call s:unit_test.run()
|
||||
|
@ -1,132 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: record_browser
|
||||
" Purpose: represent record browser in oscan
|
||||
|
||||
function! railmoon#oscan#record_browser#create( record_extractor )
|
||||
let new_record_browser = copy( s:record_browser )
|
||||
|
||||
let new_record_browser.record_extractor = a:record_extractor
|
||||
let new_record_browser.all_records = new_record_browser.record_extractor.extract()
|
||||
|
||||
return new_record_browser
|
||||
endfunction
|
||||
|
||||
let s:record_browser = {}
|
||||
|
||||
function! s:record_browser.is_empty()
|
||||
return empty(self.all_records)
|
||||
endfunction
|
||||
|
||||
" by list of tags return records that match tag list
|
||||
" record1 tags = ['method', 'create', 'button']
|
||||
" record2 tags = ['function', 'create', 'widget']
|
||||
" record3 tags = ['method', 'create', 'file']
|
||||
" tag_list = ['method', 'create']
|
||||
" result = [record1, record3]
|
||||
function! s:record_browser.get_matched_records( tag_list )
|
||||
let result = []
|
||||
|
||||
for record in self.all_records
|
||||
if record.match_by_tags( a:tag_list )
|
||||
call add(result, record)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" by list of tags return tags that can specify other records
|
||||
" example:
|
||||
" record1 tags = ['method', 'create', 'button']
|
||||
" record2 tags = ['method', 'create', 'widget']
|
||||
" record3 tags = ['method', 'create', 'file']
|
||||
" tag_list = ['method', 'create']
|
||||
" result = ['widget', 'button', 'file']
|
||||
function! s:record_browser.get_available_tags( tag_list ) " TODO useful?
|
||||
let result = []
|
||||
|
||||
for record in self.all_records
|
||||
if record.match_by_tags( a:tag_list )
|
||||
call extend(result, record.other_tags( result, a:tag_list ))
|
||||
endif
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" by list of tags return tags that can specify other records
|
||||
" example above
|
||||
function! s:record_browser.get_available_tags_for_records( matched_records, tag_list )
|
||||
let result = []
|
||||
|
||||
for record in a:matched_records
|
||||
let other_tags = record.other_tags( result, a:tag_list )
|
||||
|
||||
for element in other_tags
|
||||
let string_tag = element.''
|
||||
if index(result, string_tag) == -1
|
||||
call add(result, string_tag)
|
||||
endif
|
||||
endfor
|
||||
|
||||
" call extend(result, record.other_tags( result, a:tag_list ))
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ testing ]
|
||||
" -
|
||||
|
||||
function! s:create_test_record1()
|
||||
return railmoon#oscan#record#create( 'createTestRecord1', [ 'edit', 'gui', 'form' ], 23 )
|
||||
endfunction
|
||||
|
||||
function! s:create_test_record2()
|
||||
return railmoon#oscan#record#create( 'createTestRecord2', [ 'simple', 'gui' ], 26 )
|
||||
endfunction
|
||||
|
||||
let s:test_record_extractor = {}
|
||||
function! s:test_record_extractor.new()
|
||||
let new_test_record_extractor = copy( s:test_record_extractor )
|
||||
|
||||
let new_test_record_extractor.record1 = s:create_test_record1()
|
||||
let new_test_record_extractor.record2 = s:create_test_record2()
|
||||
|
||||
let new_test_record_extractor.records = [ new_test_record_extractor.record1, new_test_record_extractor.record2 ]
|
||||
|
||||
return new_test_record_extractor
|
||||
endfunction
|
||||
|
||||
function! s:test_record_extractor.extract()
|
||||
return self.records
|
||||
endfunction
|
||||
|
||||
let s:unit_test = railmoon#unit_test#create('oscan#record_browser')
|
||||
|
||||
function! s:unit_test.test_record_browser()
|
||||
|
||||
let record_extractor = s:test_record_extractor.new()
|
||||
let record_browser = railmoon#oscan#record_browser#create(record_extractor)
|
||||
|
||||
call self.assert_equal(len(record_browser.get_matched_records( [] )), 2)
|
||||
call self.assert_equal(len(record_browser.get_matched_records( ['simple'] )), 1)
|
||||
|
||||
|
||||
call self.assert_equal((record_browser.get_matched_records( ['simple'] ))[0].id, record_extractor.record2.id)
|
||||
call self.assert_equal((record_browser.get_matched_records( ['edit', 'form'] ))[0].id, record_extractor.record1.id)
|
||||
|
||||
let matched_records = record_browser.get_matched_records(['gui'])
|
||||
call self.assert_equal(record_browser.get_available_tags_for_records(matched_records, ['gui']), ['edit', 'form', 'simple'])
|
||||
|
||||
let matched_records = record_browser.get_matched_records(['form', 'gui'])
|
||||
call self.assert_equal(record_browser.get_available_tags_for_records(matched_records, ['form', 'gui']), ['edit'])
|
||||
|
||||
endfunction
|
||||
|
||||
call s:unit_test.run()
|
||||
|
@ -1,45 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Module: railmoon#trace
|
||||
" Purpose: help write debug information and call stack
|
||||
|
||||
|
||||
function! railmoon#trace#start_debug(file_name)
|
||||
let s:is_debug_on = 1
|
||||
let s:debug = 1
|
||||
let s:log_file_name = a:file_name
|
||||
call delete(s:log_file_name)
|
||||
exec 'redir! > '.s:log_file_name
|
||||
echo 'start_debug'
|
||||
exec 'redir END'
|
||||
endfunction
|
||||
|
||||
function! railmoon#trace#push(function_name)
|
||||
if s:is_debug_on
|
||||
call add(s:stack, a:function_name)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! railmoon#trace#pop()
|
||||
if s:is_debug_on
|
||||
let s:stack = s:stack[ : -2]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! railmoon#trace#debug(message)
|
||||
if s:debug
|
||||
call s:write(a:message)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:write(message)
|
||||
exec 'redir >> '.s:log_file_name
|
||||
silent echo '[ '.join(s:stack, ' >> ').'] '.a:message
|
||||
exec 'redir END'
|
||||
endfunction
|
||||
|
||||
let s:is_debug_on = 0
|
||||
let s:debug = 0
|
||||
let s:stack = []
|
||||
|
@ -1,69 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Module: railmoon#unit_test
|
||||
" Purpose: provide unit test object
|
||||
|
||||
" -
|
||||
" [ public library function ]
|
||||
" Name: railmoon#unit_test#create
|
||||
" Purpose: create "unit test" object
|
||||
" [ parameters ]
|
||||
" name name of test
|
||||
" -
|
||||
function! railmoon#unit_test#create(name)
|
||||
let new_object = deepcopy(s:unit_test)
|
||||
|
||||
let new_object.name = a:name
|
||||
let new_object.number_of_test = 0
|
||||
|
||||
return new_object
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: unit_test
|
||||
" Purpose: object "unit test"
|
||||
" -
|
||||
let s:unit_test = {}
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: unit_test
|
||||
" Name: assert_equal
|
||||
" Purpose: compare two values
|
||||
" -
|
||||
function! s:unit_test.assert_equal(first, second)
|
||||
if !( a:second == a:first )
|
||||
throw string(a:first).' != '.string(a:second)
|
||||
endif
|
||||
|
||||
let self.number_of_test += 1
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: unit_test
|
||||
" Name: run
|
||||
" Purpose: run all unit tests from suit
|
||||
" -
|
||||
function! s:unit_test.run()
|
||||
let test_name = ''
|
||||
try
|
||||
for key in keys(self)
|
||||
if key =~ '^test_'
|
||||
let self.number_of_test = 1
|
||||
let call_command = 'call self.'.key.'()'
|
||||
let test_name = substitute(key, '^test_\(.*\)', '\1', '')
|
||||
exec call_command
|
||||
endif
|
||||
endfor
|
||||
catch /.*/
|
||||
echohl Identifier | echo 'Suit:'.self.name | echohl None
|
||||
echohl Identifier | echo 'Test:'.test_name | echohl None
|
||||
echohl Identifier | echo 'Number:'.self.number_of_test | echohl None
|
||||
echohl Statement | echo v:exception | echohl None
|
||||
echohl Statement | echo v:throwpoint | echohl None
|
||||
endtry
|
||||
endfunction
|
||||
|
@ -1,21 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Module: railmoon#widget
|
||||
" Purpose: common util function for widget functionality
|
||||
|
||||
let s:handle_autocommands = 1
|
||||
|
||||
function! railmoon#widget#stop_handle_autocommands()
|
||||
let s:handle_autocommands = 0
|
||||
endfunction
|
||||
|
||||
function! railmoon#widget#start_handle_autocommands()
|
||||
let s:handle_autocommands = 1
|
||||
endfunction
|
||||
|
||||
function! railmoon#widget#handle_autocommands()
|
||||
return s:handle_autocommands
|
||||
endfunction
|
||||
|
||||
|
@ -1,571 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Module: railmoon#widget#base
|
||||
" Purpose: base widget functionality and vim windows triggers handler
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Purpose: collect widget that will be closed
|
||||
" -
|
||||
let s:widget_for_close = []
|
||||
|
||||
function! s:clear_widget_for_close()
|
||||
let s:widget_for_close = []
|
||||
endfunction
|
||||
|
||||
function! s:widget_present(list, widget)
|
||||
for widget in a:list
|
||||
if widget.id == a:widget.id
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:add_widget_for_close(widget)
|
||||
if s:widget_present(s:widget_for_close, a:widget)
|
||||
return
|
||||
endif
|
||||
|
||||
call add(s:widget_for_close, a:widget)
|
||||
endfunction
|
||||
|
||||
function! s:remove_widget_from_delete(widget)
|
||||
if ! s:widget_present(s:widget_for_close, a:widget)
|
||||
return
|
||||
endif
|
||||
|
||||
call filter(s:widget_for_close, 'v:val.id != '.a:widget.id)
|
||||
endfunction
|
||||
|
||||
let s:buffer_name_prefix = 'rmwidget'
|
||||
let s:in_create_widget_state = 0
|
||||
" -
|
||||
" [ public for extend library function ]
|
||||
" Name: railmoon#widget#base#create
|
||||
" Purpose: create base widget
|
||||
" [ parameters ]
|
||||
" name widget window name
|
||||
" titlename name that will on title bar
|
||||
" child widget that inherit base
|
||||
" child_callback_object call back object with following methods that child can
|
||||
" react on
|
||||
" on_close
|
||||
" on_close_with_tab_page
|
||||
" on_focus
|
||||
" on_focus_lost
|
||||
" on_setup
|
||||
" callback_object user defined call back object
|
||||
" -
|
||||
function! railmoon#widget#base#create(name, titlename, child, child_callback_object, callback_object)
|
||||
call s:clear_widget_for_close()
|
||||
|
||||
let new_object = extend( deepcopy(s:base), deepcopy(a:child) )
|
||||
|
||||
call railmoon#trace#debug('create base:'.a:name)
|
||||
call railmoon#trace#debug(string(new_object))
|
||||
|
||||
" if bufexists(escaped_name)
|
||||
" throw 'widget:base:buffer_exists'
|
||||
" endif
|
||||
let new_object.id = railmoon#id#acquire('railmoon_widget_id')
|
||||
let new_object.name = a:name
|
||||
let new_object.titlename = a:titlename
|
||||
let new_object.child_callback_object = a:child_callback_object
|
||||
let new_object.callback_object = a:callback_object
|
||||
let new_object.is_closed = 0
|
||||
|
||||
let buffer_name = s:buffer_name_prefix.new_object.id
|
||||
|
||||
let s:in_create_widget_state = 1
|
||||
|
||||
let buffer_number = bufnr( buffer_name )
|
||||
|
||||
if -1 == buffer_number
|
||||
exec 'silent edit '.buffer_name
|
||||
else
|
||||
exec 'silent buffer '.buffer_number
|
||||
endif
|
||||
|
||||
exec 'setlocal statusline='.escape(new_object.name, ' ')
|
||||
setlocal noreadonly
|
||||
|
||||
let w:widget_id = new_object.id
|
||||
let w:widget = new_object
|
||||
|
||||
let b:widget_id = new_object.id
|
||||
let b:widget = new_object
|
||||
|
||||
call s:buffer_auto_command_setup()
|
||||
call s:buffer_setup()
|
||||
|
||||
let s:in_create_widget_state = 0
|
||||
return new_object
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: railmoon#widget#base#call_back
|
||||
" Purpose: call back method for handlers
|
||||
" -
|
||||
function! railmoon#widget#base#call_back(widget, method_name, ... )
|
||||
let arguments = join(a:000, ';')
|
||||
call railmoon#trace#debug('call back for widget. name:'. a:widget.name. '; method:'.a:method_name.' ; arguments:'.arguments)
|
||||
|
||||
let exec_line = 'call object.'.a:method_name.'('.arguments.')'
|
||||
for object in [ a:widget.child_callback_object, a:widget.callback_object ]
|
||||
if has_key(object, a:method_name)
|
||||
call railmoon#trace#debug(exec_line)
|
||||
exec exec_line
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: buffer_option_setup
|
||||
" Purpose: setup common local options for widget buffer
|
||||
" -
|
||||
function! s:buffer_option_setup()
|
||||
setlocal noswapfile
|
||||
setlocal nomodifiable
|
||||
setlocal bufhidden=delete
|
||||
setlocal buftype=nofile
|
||||
setlocal nobuflisted
|
||||
setlocal nonumber
|
||||
setlocal nowrap
|
||||
setlocal nocursorline
|
||||
endfunction
|
||||
|
||||
function! s:redraw_widget()
|
||||
if has_key(b:widget, 'draw')
|
||||
call b:widget.draw()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: buffer_setup
|
||||
" Purpose: when buffer needs to be resetup. after reopen in widget window
|
||||
" -
|
||||
function! s:buffer_setup()
|
||||
call s:buffer_option_setup()
|
||||
let b:widget = w:widget
|
||||
let b:widget_id = w:widget_id
|
||||
|
||||
call s:set_widget_title()
|
||||
|
||||
if s:in_create_widget_state
|
||||
return
|
||||
endif
|
||||
|
||||
call railmoon#widget#base#call_back(b:widget, 'on_setup')
|
||||
call s:redraw_widget()
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: buffer_auto_command_setup
|
||||
" Purpose: setup common handlers for window triggers
|
||||
" -
|
||||
function! s:buffer_auto_command_setup()
|
||||
autocmd! * <buffer>
|
||||
autocmd BufWinLeave <buffer> call s:on_buffer_win_leave()
|
||||
autocmd WinEnter <buffer> call s:on_window_enter()
|
||||
autocmd WinLeave <buffer> call s:on_window_leave()
|
||||
autocmd TabLeave <buffer> call s:on_tab_leave()
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: auto_command_setup
|
||||
" Purpose: setup handlers for any window or buffer to resolve conflicts
|
||||
" -
|
||||
function! s:auto_command_setup()
|
||||
augroup base_widget_autocommands
|
||||
autocmd!
|
||||
autocmd WinEnter * call s:on_any_window_enter()
|
||||
autocmd BufEnter * call s:on_any_buffer_enter()
|
||||
autocmd BufWinEnter * call s:on_any_buffer_window_enter()
|
||||
" autocmd BufWinLeave * call s:on_any_buffer_win_leave()
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
function! s:widget_in_auto_command()
|
||||
let buffer_name = expand('<afile>')
|
||||
let widget = getbufvar(buffer_name, 'widget')
|
||||
|
||||
if empty(widget)
|
||||
throw 'widget not found!!!! TODO'
|
||||
endif
|
||||
|
||||
return widget
|
||||
endfunction
|
||||
|
||||
function! s:on_any_buffer_window_enter()
|
||||
call railmoon#trace#push('on_any_buffer_window_enter')
|
||||
try
|
||||
|
||||
let buffer_name = expand('<afile>')
|
||||
call railmoon#trace#debug('name: '.buffer_name)
|
||||
|
||||
if empty(buffer_name) " TODO
|
||||
return
|
||||
endif
|
||||
|
||||
if ! railmoon#widget#handle_autocommands()
|
||||
call railmoon#trace#debug('handle autocommands stoped')
|
||||
return
|
||||
endif
|
||||
|
||||
|
||||
if exists('w:widget_id') && !exists('b:widget_id')
|
||||
call railmoon#trace#debug('w:widget_id present but b:widget_id not')
|
||||
call s:remove_widget_from_delete(w:widget)
|
||||
let buffer_number = bufnr(s:buffer_name_prefix.w:widget_id)
|
||||
let buffer_change_cmd = 'buffer '.buffer_number
|
||||
call railmoon#trace#debug(buffer_change_cmd)
|
||||
exec buffer_change_cmd
|
||||
call s:buffer_setup()
|
||||
return
|
||||
endif
|
||||
|
||||
if exists('b:widget_id') && !exists('w:widget_id')
|
||||
call railmoon#trace#debug('b:widget exists but w:widget not')
|
||||
close
|
||||
return
|
||||
endif
|
||||
|
||||
catch /.*/
|
||||
echo v:exception
|
||||
call railmoon#trace#debug(v:exception)
|
||||
|
||||
finally
|
||||
if exists('w:widget')
|
||||
call s:remove_widget_from_delete(w:widget)
|
||||
endif
|
||||
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: on_buffer_win_leave
|
||||
" Purpose: handle widget close event
|
||||
" -
|
||||
function! s:on_buffer_win_leave()
|
||||
call railmoon#trace#push('on_buffer_win_leave')
|
||||
try
|
||||
|
||||
let widget = s:widget_in_auto_command()
|
||||
|
||||
call railmoon#trace#debug('widget for close set up')
|
||||
call s:add_widget_for_close(widget)
|
||||
if widget.is_closed
|
||||
call railmoon#trace#debug('already closed')
|
||||
return
|
||||
endif
|
||||
|
||||
let buffer_name = expand('<afile>')
|
||||
" closed by close tab page
|
||||
" TODO find out another cases
|
||||
" when <afile> != %
|
||||
if buffer_name != bufname('%')
|
||||
let s:close_with_tab_page = 1
|
||||
" TODO s:close_with_tab_page
|
||||
else
|
||||
let s:close_with_tab_page = 0
|
||||
endif
|
||||
|
||||
finally
|
||||
call s:close_ready_for_close_widgets()
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! railmoon#widget#base#gui_tab_label()
|
||||
if v:lnum == s:current_tab_page_number
|
||||
return s:current_widget_name
|
||||
endif
|
||||
|
||||
" let old_line = s:old_gui_tab_label
|
||||
" let old_line = substitute(old_line, '%{\(.\{-}\)}', '\1', 'g')
|
||||
" return eval(old_line)
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! railmoon#widget#base#tab_line()
|
||||
return s:current_widget_name
|
||||
endfunction
|
||||
|
||||
function! s:set_widget_title()
|
||||
let s:current_tab_page_number = tabpagenr()
|
||||
let s:current_widget_name = b:widget.name
|
||||
let s:current_widget_title_name = b:widget.titlename
|
||||
|
||||
if ! exists('s:old_title_string')
|
||||
let s:old_title_string = &titlestring
|
||||
let s:old_gui_tab_label = &guitablabel
|
||||
let s:old_tab_line = &tabline
|
||||
endif
|
||||
|
||||
let &titlestring = s:current_widget_title_name
|
||||
set guitablabel=%{railmoon#widget#base#gui_tab_label()}
|
||||
set tabline=%!railmoon#widget#base#tab_line()
|
||||
|
||||
exec 'setlocal statusline='.escape(s:current_widget_name, ' ')
|
||||
endfunction
|
||||
|
||||
function! s:restore_original_title()
|
||||
if exists('s:old_title_string')
|
||||
let &titlestring = s:old_title_string
|
||||
let &guitablabel = s:old_gui_tab_label
|
||||
let &tabline = s:old_tab_line
|
||||
|
||||
unlet s:old_title_string
|
||||
unlet s:old_gui_tab_label
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: on_window_enter
|
||||
" Purpose: handle gain focus event
|
||||
" -
|
||||
function! s:on_window_enter()
|
||||
call railmoon#trace#push('on_window_enter')
|
||||
try
|
||||
|
||||
let widget = s:widget_in_auto_command()
|
||||
|
||||
call s:set_widget_title()
|
||||
|
||||
call railmoon#widget#base#call_back(widget, 'on_focus')
|
||||
|
||||
catch /widget not found/
|
||||
call railmoon#trace#debug(v:exception)
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:on_any_buffer_enter()
|
||||
call railmoon#trace#push('on_any_buffer_enter')
|
||||
try
|
||||
|
||||
if ! railmoon#widget#handle_autocommands()
|
||||
call railmoon#trace#debug('handle autocommands stoped')
|
||||
return
|
||||
endif
|
||||
|
||||
let buffer_name = expand('<afile>')
|
||||
call railmoon#trace#debug('buffer name:'.buffer_name)
|
||||
call railmoon#trace#debug('in_create_widget_state:'.s:in_create_widget_state)
|
||||
|
||||
" attempt to edit file with name reserved to widget buffers
|
||||
"
|
||||
if !exists('b:widget_id') && ! s:in_create_widget_state
|
||||
call railmoon#trace#debug('b:widget not found')
|
||||
|
||||
if buffer_name =~ s:buffer_name_prefix
|
||||
call railmoon#trace#debug('name of widget buffer')
|
||||
if buffer_name == expand('%')
|
||||
call railmoon#trace#debug('open alternate window')
|
||||
buffer #
|
||||
endif
|
||||
endif
|
||||
"
|
||||
" attempt to re open widget buffer
|
||||
elseif exists('b:widget_id') && ! s:in_create_widget_state
|
||||
call railmoon#widget#base#call_back(b:widget, 'on_setup')
|
||||
call s:redraw_widget()
|
||||
endif
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:close_ready_for_close_widgets()
|
||||
call railmoon#trace#push('s:close_ready_for_close_widgets()')
|
||||
try
|
||||
|
||||
for widget in s:widget_for_close
|
||||
call railmoon#trace#debug('s:widget_for_close exists')
|
||||
|
||||
if widget.is_closed
|
||||
call railmoon#trace#debug('already closed')
|
||||
else
|
||||
if s:close_with_tab_page
|
||||
call railmoon#widget#base#call_back(widget, 'on_close_with_tab_page')
|
||||
else
|
||||
call railmoon#widget#base#call_back(widget, 'on_close')
|
||||
endif
|
||||
let widget.is_closed = 1
|
||||
|
||||
call railmoon#id#release('railmoon_widget_id', widget.id)
|
||||
endif
|
||||
endfor
|
||||
call s:clear_widget_for_close()
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:on_any_window_enter()
|
||||
call railmoon#trace#push('on_any_window_enter')
|
||||
try
|
||||
|
||||
call railmoon#trace#debug('name: '.expand('<afile>'))
|
||||
|
||||
if ! railmoon#widget#handle_autocommands()
|
||||
call railmoon#trace#debug('handle autocommands stoped')
|
||||
return
|
||||
endif
|
||||
|
||||
call s:close_ready_for_close_widgets()
|
||||
|
||||
" split or something like that
|
||||
if exists('b:widget_id') && !exists('w:widget_id') && ! s:in_create_widget_state
|
||||
call railmoon#trace#debug('b:widget_id present but w:widget_id not')
|
||||
|
||||
call railmoon#trace#debug('closing')
|
||||
close
|
||||
endif
|
||||
|
||||
if exists('w:widget_id') && !exists('b:widget_id')
|
||||
call railmoon#trace#debug('w:widget_id present but b:widget_id not')
|
||||
close
|
||||
endif
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: on_tab_leave
|
||||
" Purpose: handle tab page lost focus event
|
||||
" -
|
||||
function! s:on_tab_leave()
|
||||
call railmoon#trace#push('on_window_leave')
|
||||
try
|
||||
|
||||
call railmoon#widget#base#call_back(b:widget, 'on_tab_leave')
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: on_window_leave
|
||||
" Purpose: handle lost focus event
|
||||
" -
|
||||
function! s:on_window_leave()
|
||||
call railmoon#trace#push('on_window_leave')
|
||||
try
|
||||
|
||||
if !exists('b:widget')
|
||||
call railmoon#trace#debug('b:widget not present')
|
||||
return
|
||||
endif
|
||||
|
||||
if b:widget.is_closed
|
||||
call railmoon#trace#debug('already closed')
|
||||
return
|
||||
endif
|
||||
|
||||
call railmoon#widget#base#call_back(b:widget, 'on_focus_lost')
|
||||
|
||||
catch /.*/
|
||||
call railmoon#trace#debug(v:exception)
|
||||
call railmoon#trace#debug(v:throwpoint)
|
||||
|
||||
finally
|
||||
call s:restore_original_title()
|
||||
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: base
|
||||
" Purpose: base widget object
|
||||
" -
|
||||
let s:base = {}
|
||||
|
||||
function! s:base.select()
|
||||
call railmoon#trace#push('base.select')
|
||||
try
|
||||
|
||||
let id = self.id
|
||||
call railmoon#trace#debug('selecting...')
|
||||
call railmoon#widget#window#select(id)
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('id = '.id)
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:base.close()
|
||||
call railmoon#trace#push('base.close')
|
||||
try
|
||||
|
||||
if self.is_closed
|
||||
call railmoon#trace#debug('already closed')
|
||||
return
|
||||
endif
|
||||
|
||||
let not_active = (w:widget_id != self.id)
|
||||
|
||||
if not_active
|
||||
let selected = railmoon#widget#window#save_selected()
|
||||
endif
|
||||
|
||||
call self.select()
|
||||
|
||||
call railmoon#trace#debug('closing.. id = '.self.id)
|
||||
|
||||
let window_numbers = winnr('$')
|
||||
let self.is_closed = 1
|
||||
close
|
||||
|
||||
if not_active
|
||||
call railmoon#widget#window#load_selected(selected)
|
||||
endif
|
||||
|
||||
call railmoon#id#release('railmoon_widget_id', self.id)
|
||||
|
||||
if window_numbers > 1
|
||||
call railmoon#widget#base#call_back(self, 'on_close')
|
||||
else
|
||||
call railmoon#widget#base#call_back(self, 'on_close_with_tab_page')
|
||||
endif
|
||||
|
||||
finally
|
||||
call s:close_ready_for_close_widgets()
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
call s:auto_command_setup()
|
||||
|
@ -1,82 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Module: railmoon#widget#canvas
|
||||
" Purpose: widget for drawing inside it
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: callback_object
|
||||
" Purpose: handler for base back calls
|
||||
" -
|
||||
let s:callback_object = {}
|
||||
|
||||
" -
|
||||
" [ public library function ]
|
||||
" Name: railmoon#widget#canvas#create
|
||||
" Purpose: create "canvas" widget
|
||||
" [ parameters ]
|
||||
" name name of new vim window that will represent widget
|
||||
" callback_object call back object with following methods
|
||||
" on_draw() draw what inside canvas
|
||||
" -
|
||||
function! railmoon#widget#canvas#create(name, callback_object)
|
||||
let new_object = railmoon#widget#base#create(a:name, s:canvas, [a:callback_object, s:callback_object])
|
||||
|
||||
call s:auto_command_setup()
|
||||
|
||||
return new_object
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: auto_command_setup
|
||||
" Purpose: setup handlers for window triggers
|
||||
" -
|
||||
function! s:auto_command_setup()
|
||||
" autocmd CursorMoved <buffer> call s:on_cursor_moved()
|
||||
endfunction
|
||||
|
||||
function! s:callback_object.on_setup()
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: canvas
|
||||
" Purpose: widget object "canvas"
|
||||
" -
|
||||
let s:canvas = {}
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: canvas
|
||||
" Name: draw
|
||||
" Purpose: prepare_canvas for drawing and call user defined on_draw method
|
||||
" -
|
||||
function! s:canvas.draw()
|
||||
call railmoon#trace#push('canvas.draw')
|
||||
try
|
||||
|
||||
let selected = railmoon#widget#window#save_selected()
|
||||
let is_selected = railmoon#widget#window#select(self.id)
|
||||
|
||||
if ! is_selected
|
||||
throw 'widget:selection_window:draw:window_not_found'
|
||||
endif
|
||||
|
||||
setlocal modifiable
|
||||
|
||||
0,$delete _
|
||||
call railmoon#draw#prepare_canvas(winwidth('%'), winheight('%'))
|
||||
call railmoon#widget#base#call_back(self, 'on_draw()')
|
||||
|
||||
setlocal nomodifiable
|
||||
|
||||
call railmoon#widget#window#load_selected(selected)
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
@ -1,207 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Home: www.railmoon.com
|
||||
" Module: railmoon#widget#edit_line_window
|
||||
" Purpose: provide window with callbacks for editing single line
|
||||
|
||||
let s:callback_object = {}
|
||||
" -
|
||||
" [ public library function ]
|
||||
" Name: railmoon#widget#edit_line_window#create
|
||||
" Purpose: create "edit line window" widget
|
||||
" [ parameters ]
|
||||
" name name of new vim window that will represent widget
|
||||
" titlename name that will on title bar
|
||||
" callback_object call back object with following methods
|
||||
" on_normal_move
|
||||
" on_insert_move
|
||||
" on_type(character, is_alpha_numeric) : should return character to type
|
||||
" -- and common handlers
|
||||
" -
|
||||
function! railmoon#widget#edit_line_window#create(name, titlename, callback_object)
|
||||
let new_object = railmoon#widget#base#create(a:name, a:titlename, s:edit_line_window, s:callback_object, a:callback_object)
|
||||
|
||||
call railmoon#trace#debug('create edit line window:'.a:name)
|
||||
" call railmoon#trace#debug(string(new_object))
|
||||
|
||||
setlocal modifiable
|
||||
|
||||
call s:auto_command_setup()
|
||||
call s:insert_mode_key_typing_setup()
|
||||
|
||||
return new_object
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: edit_line_window
|
||||
" Purpose: widget object "edit line window"
|
||||
" -
|
||||
let s:edit_line_window = {}
|
||||
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: edit_line_window
|
||||
" Name: get_line
|
||||
" Purpose: return entered line
|
||||
" -
|
||||
function! s:edit_line_window.get_line()
|
||||
let selected = railmoon#widget#window#save_selected()
|
||||
|
||||
call self.select()
|
||||
let text_line = getline(1)
|
||||
|
||||
call railmoon#widget#window#load_selected(selected)
|
||||
|
||||
return text_line
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: edit_line_window
|
||||
" Name: set_line
|
||||
" Purpose: setup text line to "edit line window"
|
||||
" -
|
||||
function! s:edit_line_window.set_line(line)
|
||||
let selected = railmoon#widget#window#save_selected()
|
||||
|
||||
call self.select()
|
||||
call setline(1, a:line)
|
||||
|
||||
call railmoon#widget#window#load_selected(selected)
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: edit_line_window
|
||||
" Name: go_to_position
|
||||
" Purpose: move cursor to specified position
|
||||
" -
|
||||
function! s:edit_line_window.go_to_position(position)
|
||||
call self.select()
|
||||
|
||||
call cursor(1, a:position)
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: edit_line_window
|
||||
" Name: go_to_end
|
||||
" Purpose: move cursor to end
|
||||
" -
|
||||
function! s:edit_line_window.go_to_end()
|
||||
call self.select()
|
||||
call cursor(1, col('$'))
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: edit_line_window
|
||||
" Name: go_to_start
|
||||
" Purpose: move cursor to start of line
|
||||
" -
|
||||
function! s:edit_line_window.go_to_start()
|
||||
call self.select()
|
||||
call cursor(1, 1)
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: insert_mode_key_typing_setup
|
||||
" Purpose: setup handlers for typing characters
|
||||
" -
|
||||
function! s:insert_mode_key_typing_setup()
|
||||
for item in s:alpha_numeric_characters
|
||||
execute 'inoremap <buffer> <silent> ' . item . ' <C-R>=<SID>on_insert_typing('''.item.''', 1)<CR>'
|
||||
endfor
|
||||
|
||||
for item in s:not_alpha_numeric_characters
|
||||
execute 'inoremap <buffer> <silent> ' . item . ' <C-R>=<SID>on_insert_typing('''.item.''', 0)<CR>'
|
||||
endfor
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:callback_object.on_setup()
|
||||
call s:insert_mode_key_typing_setup()
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: on_insert_typing
|
||||
" Purpose: handle typing
|
||||
" -
|
||||
function! s:on_insert_typing(character, is_alpha_numeric)
|
||||
let callback_object = b:widget.callback_object
|
||||
if has_key(callback_object, 'on_type')
|
||||
return callback_object.on_type( a:character, a:is_alpha_numeric )
|
||||
endif
|
||||
|
||||
return a:character
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: auto_command_setup
|
||||
" Purpose: setup auto commands
|
||||
" -
|
||||
function! s:auto_command_setup()
|
||||
autocmd CursorMoved <buffer> call s:on_cursor_moved(s:normal_mode)
|
||||
autocmd CursorMovedI <buffer> call s:on_cursor_moved(s:insert_mode)
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: on_cursor_moved
|
||||
" Purpose: handle cursor movement
|
||||
" -
|
||||
function! s:on_cursor_moved(mode)
|
||||
if line('$') > 1
|
||||
let new_line = join(getline(1, '$'), '')
|
||||
2,$d
|
||||
call setline(1, new_line)
|
||||
call cursor(1, col('$'))
|
||||
endif
|
||||
|
||||
let callback_object = w:widget.callback_object
|
||||
if a:mode == s:normal_mode
|
||||
call railmoon#widget#base#call_back(w:widget, 'on_normal_move')
|
||||
else
|
||||
call railmoon#widget#base#call_back(w:widget, 'on_insert_move')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: normal_mode
|
||||
" Purpose: enumeration of mode
|
||||
" -
|
||||
let s:normal_mode = 0
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: insert_mode
|
||||
" Purpose: enumeration of mode
|
||||
" -
|
||||
let s:insert_mode = 1
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: alpha_numeric_characters
|
||||
" Purpose: store all typing characters
|
||||
" -
|
||||
let s:alpha_numeric_characters =
|
||||
\ ['a','b','c','d','e','f','g','h','i','j','k','l','m',
|
||||
\ 'n','o','p','q','r','s','t','u','v','w','x','y','z',
|
||||
\ 'A','B','C','D','E','F','G','H','I','J','K','L','M',
|
||||
\ 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
|
||||
\ '0','1','2','3','4','5','6','7','8','9','<space>','_','=','"',':',';','.']
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: not_alpha_numeric_characters
|
||||
" Purpose: store not alpha numeric characters
|
||||
" -
|
||||
let s:not_alpha_numeric_characters =
|
||||
\ ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '-',
|
||||
\ '{', '}', '[', ']', "'", '<', '>', ',', '?', '`', '~', '\', '\|']
|
||||
|
@ -1,408 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Module: railmoon#widget#selection_window
|
||||
" Purpose: provide window with ability to select elements
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: callback_object
|
||||
" Purpose: handler for base back calls
|
||||
" -
|
||||
let s:callback_object = {}
|
||||
|
||||
|
||||
|
||||
"
|
||||
" elements for selection windows are dictionaries that have
|
||||
" .data as list [] of text
|
||||
" .header optional value that will be right aligned at left side of list
|
||||
|
||||
" -
|
||||
" [ public library function ]
|
||||
" Name: railmoon#widget#selection_window#create
|
||||
" Purpose: create "selection window" widget
|
||||
" [ parameters ]
|
||||
" name name of new vim window that will represent widget
|
||||
" titlename name that will on title bar
|
||||
" callback_object call back object with following methods
|
||||
" on_select(selected_line_text)
|
||||
" on_close
|
||||
" on_close_with_tab_page
|
||||
" model model representation with following methods
|
||||
" get_item(element)
|
||||
" get_item_count()
|
||||
" -
|
||||
function! railmoon#widget#selection_window#create(name, titlename, selection_group, model, callback_object)
|
||||
let new_object = railmoon#widget#base#create(a:name, a:titlename, s:selection_window, s:callback_object, a:callback_object)
|
||||
|
||||
call railmoon#trace#debug('create selection_window:'.a:name)
|
||||
call railmoon#trace#debug(string(new_object))
|
||||
|
||||
let new_object.selected_item_number = 1
|
||||
let new_object.selection_group = a:selection_group
|
||||
let new_object.model = a:model
|
||||
let new_object.yoffset = 0
|
||||
|
||||
let new_object.item_positions = []
|
||||
|
||||
" call new_object.draw_selection()
|
||||
|
||||
call s:auto_command_setup()
|
||||
call s:key_mappings_setup()
|
||||
|
||||
return new_object
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: auto_command_setup
|
||||
" Purpose: setup handlers for window triggers
|
||||
" -
|
||||
function! s:auto_command_setup()
|
||||
autocmd CursorMoved <buffer> call s:on_cursor_moved()
|
||||
endfunction
|
||||
|
||||
function! s:callback_object.on_setup()
|
||||
call s:key_mappings_setup()
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: key_mappings_setup
|
||||
" Purpose: setup key handlers for "selection window"
|
||||
" -
|
||||
function! s:key_mappings_setup()
|
||||
nnoremap <buffer> <CR> :call <SID>on_select()<CR>
|
||||
nnoremap <buffer> <2-LeftMouse> :call <SID>on_select()<CR>
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: on_select
|
||||
" Purpose: handle item select command
|
||||
" -
|
||||
function! s:on_select()
|
||||
let selected_item = w:widget.selected_item()
|
||||
call railmoon#widget#base#call_back(w:widget, 'on_select', '"'.escape(string(selected_item),"\"'").'"')
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: on_cursor_moved
|
||||
" Purpose: handle normal mode curor movement
|
||||
" -
|
||||
function! s:on_cursor_moved()
|
||||
let line_number = line('.')
|
||||
call w:widget.select_line(line_number)
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: selection_window
|
||||
" Purpose: widget object "selection window"
|
||||
" -
|
||||
let s:selection_window = {}
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: highlight_line
|
||||
" Purpose: highlight line in selection window
|
||||
" [ parameters ]
|
||||
" line_number number of line to highlight
|
||||
" group highlight group to use as highlight
|
||||
" -
|
||||
function! s:highlight_line(start, end, group)
|
||||
let start = '"\%'.(a:start + 1).'l"'
|
||||
let end = '"\%'.(a:end + 1).'l"'
|
||||
let id = w:widget_id
|
||||
let syn_command = 'syn region selection_window_selected_line'.id.' start='.start.' end = '.end.' contains=Search'
|
||||
let hi_link_command = 'hi link selection_window_selected_line'.id.' '.a:group
|
||||
exec syn_command
|
||||
exec hi_link_command
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Name: clear_highlight_line
|
||||
" Purpose: remove highlight line in selection window
|
||||
" -
|
||||
function! s:clear_highlight_line()
|
||||
let id = w:widget_id
|
||||
try
|
||||
exec 'syntax clear selection_window_selected_line'.id
|
||||
catch /.*/
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: selection_window
|
||||
" Name: draw
|
||||
" Purpose: append all lines to buffer while remove old ones
|
||||
" -
|
||||
function! s:selection_window.draw()
|
||||
call railmoon#trace#push('selection_window.draw')
|
||||
try
|
||||
|
||||
let selected = railmoon#widget#window#save_selected()
|
||||
let is_selected = railmoon#widget#window#select(self.id)
|
||||
|
||||
if ! is_selected
|
||||
throw 'widget:selection_window:draw:window_not_found'
|
||||
endif
|
||||
|
||||
setlocal modifiable
|
||||
|
||||
0,$delete _
|
||||
|
||||
|
||||
let y = 0
|
||||
let i = 0
|
||||
let item_count = self.model.get_item_count()
|
||||
let item_size = len(self.model.get_item(0).data)
|
||||
let header_max_lenght = 0
|
||||
|
||||
let self.item_positions = []
|
||||
|
||||
let items_to_draw = []
|
||||
|
||||
" gathrer visual items on window
|
||||
" determine max header length
|
||||
"
|
||||
while y <= ( winheight('%') - item_size ) && ( i < item_count )
|
||||
let item = self.model.get_item(i)
|
||||
|
||||
let item_header_len = len(item.header)
|
||||
|
||||
if item_header_len > header_max_lenght
|
||||
let header_max_lenght = item_header_len
|
||||
endif
|
||||
|
||||
call add(items_to_draw, item)
|
||||
let item_size = len(item.data)
|
||||
|
||||
call add( self.item_positions, [ y, y + item_size ] )
|
||||
|
||||
let y += item_size
|
||||
let i += 1
|
||||
endwhile
|
||||
|
||||
let is_no_headers = header_max_lenght == 0
|
||||
|
||||
" highlight headers if any
|
||||
"
|
||||
|
||||
let window_id = w:widget_id
|
||||
try
|
||||
exec 'syntax clear selection_window_lines_header'.window_id
|
||||
catch /.*/
|
||||
endtry
|
||||
|
||||
if ! is_no_headers
|
||||
exec 'syntax match selection_window_lines_header'.window_id.' "^[^|]\+|"'
|
||||
endif
|
||||
|
||||
try
|
||||
exec 'hi link selection_window_lines_header'.window_id.' String'
|
||||
catch /.*/
|
||||
endtry
|
||||
|
||||
let lines = []
|
||||
" build lines to append to buffer
|
||||
"
|
||||
for item in items_to_draw
|
||||
let item_header = item.header
|
||||
let is_header_present = len(item_header) > 0
|
||||
|
||||
if is_header_present
|
||||
call add(lines, printf(' %-'.header_max_lenght.'s | ', item_header).item.data[0])
|
||||
elseif is_no_headers
|
||||
call add(lines, ' '.item.data[0])
|
||||
else
|
||||
call add(lines, printf(' %'.header_max_lenght.'s ', item_header).item.data[0])
|
||||
endif
|
||||
|
||||
for line in item.data[1:]
|
||||
if is_header_present
|
||||
call add(lines, printf(' %-'.header_max_lenght.'s | ', '').line)
|
||||
elseif is_no_headers
|
||||
call add(lines, ' '.line)
|
||||
else
|
||||
call add(lines, printf(' %'.header_max_lenght.'s ', '').line)
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
let win_width = winwidth('%')
|
||||
|
||||
let wide_lines = []
|
||||
for line in lines
|
||||
let diff = win_width - len(line)
|
||||
|
||||
let new_line = line
|
||||
if diff > 0
|
||||
let new_line = line . printf('%'.diff.'s', ' ')
|
||||
endif
|
||||
|
||||
call add(wide_lines, new_line)
|
||||
endfor
|
||||
|
||||
call setline(1, wide_lines)
|
||||
call self.draw_selection()
|
||||
|
||||
setlocal nomodifiable
|
||||
|
||||
call railmoon#widget#window#load_selected(selected)
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: selection_window
|
||||
" Name: draw_selection
|
||||
" Purpose: show selection in selection window
|
||||
" -
|
||||
function! s:selection_window.draw_selection()
|
||||
call railmoon#trace#push('selection_window.draw_selection')
|
||||
call railmoon#trace#debug('id = '.self.id)
|
||||
try
|
||||
|
||||
let selected = railmoon#widget#window#save_selected()
|
||||
|
||||
call self.select()
|
||||
|
||||
if len(self.item_positions) > 0
|
||||
let start_line_number_in_window = self.item_positions[ self.selected_item_number - 1 ][0]
|
||||
let end_line_number_in_window = self.item_positions[ self.selected_item_number - 1 ][1]
|
||||
exec start_line_number_in_window
|
||||
|
||||
call s:clear_highlight_line()
|
||||
call s:highlight_line(start_line_number_in_window, end_line_number_in_window, self.selection_group)
|
||||
endif
|
||||
|
||||
call railmoon#widget#window#load_selected(selected)
|
||||
|
||||
finally
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: selection_window
|
||||
" Name: scrool_to
|
||||
" Purpose: scrool window to show given line as first line
|
||||
" [ parameters ]
|
||||
" line_number line to show first in window
|
||||
" -
|
||||
function! s:selection_window.scrool_to(line_number)
|
||||
let self.yoffset = a:line_number
|
||||
|
||||
call self.draw()
|
||||
endfunction
|
||||
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: selection_window
|
||||
" Name: selection_down
|
||||
" Purpose: select next item
|
||||
" [ parameters ]
|
||||
" cycle cycle or not movement
|
||||
" -
|
||||
function! s:selection_window.selection_down(cycle)
|
||||
let last_item_number_on_window = len(self.item_positions)
|
||||
|
||||
if self.selected_item_number >= last_item_number_on_window
|
||||
if ! a:cycle
|
||||
return
|
||||
else
|
||||
let self.selected_item_number = 1
|
||||
endif
|
||||
else
|
||||
let self.selected_item_number += 1
|
||||
endif
|
||||
|
||||
|
||||
call self.draw_selection()
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: selection_window
|
||||
" Name: selection_up
|
||||
" Purpose: select previous item
|
||||
" [ parameters ]
|
||||
" cycle cycle or not movement
|
||||
" -
|
||||
function! s:selection_window.selection_up(cycle)
|
||||
let last_item_number_on_window = len(self.item_positions)
|
||||
|
||||
if self.selected_item_number <= 1
|
||||
if ! a:cycle
|
||||
return
|
||||
else
|
||||
let self.selected_item_number = last_item_number_on_window
|
||||
endif
|
||||
else
|
||||
let self.selected_item_number -= 1
|
||||
endif
|
||||
|
||||
|
||||
call self.draw_selection()
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: selection_window
|
||||
" Name: select_line
|
||||
" Purpose: select pointed line
|
||||
" [ parameters ]
|
||||
" line_number number of line to select
|
||||
" -
|
||||
function! s:selection_window.select_line(line_number)
|
||||
let item_count = self.model.get_item_count()
|
||||
|
||||
let i = 0
|
||||
for region in self.item_positions
|
||||
if a:line_number >= region[0] && a:line_number <= region[1]
|
||||
let self.selected_item_number = i + 1
|
||||
break
|
||||
endif
|
||||
|
||||
let i+=1
|
||||
endfor
|
||||
|
||||
call self.draw_selection()
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: selection_window
|
||||
" Name: select_item
|
||||
" Purpose: select pointed item by number
|
||||
" [ parameters ]
|
||||
" item_number number of item to select
|
||||
" -
|
||||
function! s:selection_window.select_item(item_number)
|
||||
let self.selected_item_number = a:item_number
|
||||
call self.draw_selection()
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: selection_window
|
||||
" Name: selected_item
|
||||
" Purpose: return selected item text
|
||||
" -
|
||||
function! s:selection_window.selected_item()
|
||||
let item = self.model.get_item(self.selected_item_number - 1)
|
||||
return item
|
||||
endfunction
|
||||
|
@ -1,167 +0,0 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Home: www.railmoon.com
|
||||
" Module: railmoon#widget#window
|
||||
" Purpose: util functions for work with widget windows id
|
||||
"
|
||||
|
||||
" -
|
||||
" [ public library function ]
|
||||
" Name: railmoon#widget#window#find_on_tab
|
||||
" Purpose: determine window number on given tab with pointed id
|
||||
" [ parameters ]
|
||||
" tabpage_number number of tabpage
|
||||
" variable_name name of window id variable
|
||||
" id window id to search
|
||||
" -
|
||||
function! railmoon#widget#window#find_on_tab(tabpage_number, variable_name, id)
|
||||
let windows_count = tabpagewinnr(a:tabpage_number, '$')
|
||||
let window_number = 1
|
||||
|
||||
while window_number <= windows_count
|
||||
let window_id = gettabwinvar(a:tabpage_number, window_number, a:variable_name)
|
||||
|
||||
if a:id == window_id
|
||||
return window_number
|
||||
endif
|
||||
|
||||
let window_number += 1
|
||||
|
||||
endwhile
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ public library function ]
|
||||
" Name: railmoon#widget#window#find
|
||||
" Purpose: determine tabpage number and window number as list of two elements with pointed id
|
||||
" [ parameters ]
|
||||
" id widget id to search
|
||||
" -
|
||||
function! railmoon#widget#window#find(id)
|
||||
let tabpage_count = tabpagenr('$')
|
||||
let tabpage_number = 1
|
||||
while tabpage_number <= tabpage_count
|
||||
let window_number = railmoon#widget#window#find_on_tab(tabpage_number, 'widget_id', a:id)
|
||||
if window_number
|
||||
return [ tabpage_number, window_number ]
|
||||
endif
|
||||
let tabpage_number += 1
|
||||
endwhile
|
||||
|
||||
throw 'window with "widget_id" = '.a:id.' not found'
|
||||
return [0, 0]
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ public library function ]
|
||||
" Name: railmoon#widget#window#visible
|
||||
" Purpose: determine visible or not widget window with pointed id
|
||||
" [ parameters ]
|
||||
" id widget id to select
|
||||
" -
|
||||
function! railmoon#widget#window#visible(id)
|
||||
if exists('w:widget_id') && w:widget_id == a:id
|
||||
return 1
|
||||
endif
|
||||
|
||||
let window_number = railmoon#widget#window#find_on_tab(tabpagenr(), 'widget_id', a:id)
|
||||
|
||||
return window_number > 0
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ public library function ]
|
||||
" Name: railmoon#widget#window#select
|
||||
" Purpose: make window with given widget id active
|
||||
" [ parameters ]
|
||||
" id widget id to select
|
||||
" -
|
||||
function! railmoon#widget#window#select(id)
|
||||
call railmoon#trace#push('window#select')
|
||||
call railmoon#trace#debug('id = '.a:id)
|
||||
try
|
||||
|
||||
if exists('w:widget_id') && w:widget_id == a:id
|
||||
return 1
|
||||
endif
|
||||
|
||||
let tabpage_and_window_number = railmoon#widget#window#find(a:id)
|
||||
|
||||
if tabpage_and_window_number[0] == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
call s:select_window(tabpage_and_window_number[0], tabpage_and_window_number[1])
|
||||
return 1
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
|
||||
" -
|
||||
" [ public library function ]
|
||||
" Name: railmoon#widget#window#save_selected
|
||||
" Purpose: save current tabpage number, window mark id, position, mode
|
||||
" -
|
||||
function! railmoon#widget#window#save_selected()
|
||||
call railmoon#trace#push('window#save_selected')
|
||||
try
|
||||
|
||||
if ! exists('w:railmoon_window_mark_id')
|
||||
let w:railmoon_window_mark_id = railmoon#id#acquire('railmoon_window_mark_id')
|
||||
endif
|
||||
return [tabpagenr(), w:railmoon_window_mark_id, getpos('.'), mode()]
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ public library function ]
|
||||
" Name: railmoon#widget#window#load_selected
|
||||
" Purpose: select tabpage number, window number, position, mode
|
||||
" [ parameters ]
|
||||
" selection list with four elements: tabpage number, window mark id,
|
||||
" position, mode
|
||||
" -
|
||||
function! railmoon#widget#window#load_selected(selection)
|
||||
call railmoon#trace#push('window#load_selected')
|
||||
try
|
||||
|
||||
exec a:selection[0].'tabnext'
|
||||
let window_number =
|
||||
\ railmoon#widget#window#find_on_tab(a:selection[0],
|
||||
\ 'railmoon_window_mark_id',
|
||||
\ a:selection[1])
|
||||
|
||||
exec window_number.'wincmd w'
|
||||
|
||||
if a:selection[3] == 'n'
|
||||
stopinsert
|
||||
elseif a:selection[3] == 'i'
|
||||
startinsert
|
||||
endif
|
||||
call setpos('.', a:selection[2])
|
||||
|
||||
finally
|
||||
call railmoon#trace#debug('...')
|
||||
call railmoon#trace#pop()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ internal usage ]
|
||||
" Purpose: open tabpage number and select window number
|
||||
" -
|
||||
function! s:select_window(tabpage_number, window_number)
|
||||
exec a:tabpage_number . 'tabnext'
|
||||
exec a:window_number.'wincmd w'
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user