Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for vimconfig/vim/modules/database-client.vim between version 1.4 and 1.5

version 1.4, 2004/02/24 07:43:02 version 1.5, 2004/02/29 20:01:11
Line 35  endif
Line 35  endif
   
 " width of main window  " width of main window
 if !exists('g:SQL_main_window_width')  if !exists('g:SQL_main_window_width')
         let g:SQL_main_window_width = 20          "let g:SQL_main_window_width = 20
           let g:SQL_main_window_width = 39
 endif  endif
 " height of command window  " height of command window
 if !exists('g:SQL_cmd_window_height')  if !exists('g:SQL_cmd_window_height')
Line 58  endif
Line 59  endif
 "-------------------- END OF USER CONFIGURABLE OPTIONS ---------------------  "-------------------- END OF USER CONFIGURABLE OPTIONS ---------------------
 "---------------------------------------------------------------------------  "---------------------------------------------------------------------------
   
   " Initialize the SQL plugin local variables for the supported file types
 " Initialize the taglist plugin local variables for the supported file types  
 " and tag types  " and tag types
   
 " Are we displaying brief help text  " Are we displaying brief help text
 let s:sql_brief_help = 1  let s:sql_brief_help = 1
   
   " Include the empty line displayed after the help text
   let s:brief_help_size = 2
   let s:full_help_size = 4
   
   
 " autosource this file on write  " autosource this file on write
 augroup DBIclient  augroup DBIclient
Line 189  function! SQL_Connect() " {{{
Line 193  function! SQL_Connect() " {{{
                 $main::connections->{"$db_host; $db_user;"} = {                  $main::connections->{"$db_host; $db_user;"} = {
                         'dbh'   => $dbh,                          'dbh'   => $dbh,
                         'desc'  => "$db_user\@$db_host",                          'desc'  => "$db_user\@$db_host",
                           'list_tables'   => 1,
                 };                  };
                 $main::current_conn = "$db_host; $db_user;";                  $main::current_conn = "$db_host; $db_user;";
         }          }
Line 208  function! SQL_Connect() " {{{
Line 213  function! SQL_Connect() " {{{
         VIM::Msg("Connect to database succsesfull");          VIM::Msg("Connect to database succsesfull");
   
 EOF  EOF
           call s:SQL_UpdateDatabaseList()
   
 endfunction  endfunction
 " }}}  " }}}
   
Line 280  EOF
Line 287  EOF
   
         let &guioptions = s:save_guioptions          let &guioptions = s:save_guioptions
   
           call s:SQL_UpdateDatabaseList()
   
 endfunction  endfunction
 " }}}  " }}}
   
Line 345  endfunction
Line 354  endfunction
   
   
 "create menu  "create menu
 function! CreateMenu() " {{{  function! SQL_CreateMenu() " {{{
         " remove whole menu          " remove whole menu
         silent! aunmenu SQL          silent! aunmenu SQL
         amenu 200.10 S&QL.&Connect :call SQL_Connect()<Return>          amenu 200.10 S&QL.&Connect :call SQL_Connect()<Return>
Line 356  function! CreateMenu() " {{{
Line 365  function! CreateMenu() " {{{
         amenu 200.40.30 S&QL.&Show.&tables :call SQL_Do('SHOW TABLES')<Return>          amenu 200.40.30 S&QL.&Show.&tables :call SQL_Do('SHOW TABLES')<Return>
         amenu 200.40.40 S&QL.&Show.&variables :call SQL_Do('SHOW VARIABLES')<Return>          amenu 200.40.40 S&QL.&Show.&variables :call SQL_Do('SHOW VARIABLES')<Return>
         amenu 200.40.50 S&QL.&Show.&server\ status :call SQL_Do('SHOW STATUS')<Return>          amenu 200.40.50 S&QL.&Show.&server\ status :call SQL_Do('SHOW STATUS')<Return>
         amenu 200.50.10 S&QL.&Windows.&create :call CreateWindows()<Return>          amenu 200.50.10 S&QL.&Windows.&create :call <SID>SQL_CreateWindows()<Return>
 endfunction  endfunction
 " }}}  " }}}
 call CreateMenu()  call SQL_CreateMenu()
   
 function! s:CloseWindow(winnum) " {{{  function! s:CloseWindow(winnum) " {{{
         " if window exists          " if window exists
Line 371  endfunction
Line 380  endfunction
 " }}}  " }}}
   
 " create windows  " create windows
 function! CreateWindows() " {{{  function! s:SQL_CreateWindows() " {{{
         let s:main_winnum = bufwinnr(g:SQL_main_window_title)          let s:main_winnum = bufwinnr(g:SQL_main_window_title)
         call s:CloseWindow(s:main_winnum)          call s:CloseWindow(s:main_winnum)
   
Line 390  function! CreateWindows() " {{{
Line 399  function! CreateWindows() " {{{
         setlocal norightleft          setlocal norightleft
         setlocal foldcolumn=0          setlocal foldcolumn=0
         setlocal modifiable          setlocal modifiable
         set filetype=sql          setlocal filetype=sql
   
   
         execute g:SQL_main_window_width " vsplit " . g:SQL_main_window_title          execute g:SQL_main_window_width " vsplit " . g:SQL_main_window_title
Line 402  function! CreateWindows() " {{{
Line 411  function! CreateWindows() " {{{
         setlocal norightleft          setlocal norightleft
         setlocal foldcolumn=0          setlocal foldcolumn=0
         setlocal modifiable          setlocal modifiable
           setlocal filetype=sql_menu
         call s:SQL_Display_Help()          call s:SQL_Display_Help()
   
         let s:winnr_SQL_cmd = bufwinnr(g:SQL_cmd_window_title)          let s:winnr_SQL_cmd = bufwinnr(g:SQL_cmd_window_title)
Line 424  function! CreateWindows() " {{{
Line 434  function! CreateWindows() " {{{
         setlocal norightleft          setlocal norightleft
         setlocal foldcolumn=0          setlocal foldcolumn=0
         setlocal modifiable          setlocal modifiable
           setlocal filetype=sql_data
   
         call s:Map_SQL_mappings()          call s:Map_SQL_mappings()
           call s:SQL_UpdateDatabaseList()
   
 endfunction  endfunction
 " }}}  " }}}
Line 440  function! s:SQL_Display_Help()
Line 451  function! s:SQL_Display_Help()
         if s:sql_brief_help          if s:sql_brief_help
                 " Add the brief help                  " Add the brief help
                 call append(0, '" Press ? to display help text')                  call append(0, '" Press ? to display help text')
                   call append(1, '')
         else          else
                 " Add the extensive help                  " Add the extensive help
                 call append(0, '" u : Update table list')                  call append(0, '" u : Update table list')
                 call append(1, '" U : Update database list')                  call append(1, '" U : Update database list')
                 call append(2, '" ? : Remove help text')                  call append(2, '" ? : Remove help text')
                   call append(3, '')
         endif          endif
 endfunction  endfunction
 " }}}  " }}}
   
 " SQL_Toggle_Help_Text() {{{  " s:SQL_Toggle_Help_Text() {{{
 " Toggle SQL plugin help text between the full version and the brief  " Toggle SQL plugin help text between the full version and the brief
 " version  " version
 " Function from taglist.vim plugin  " Function from taglist.vim plugin
Line 460  function! s:SQL_Toggle_Help_Text()
Line 473  function! s:SQL_Toggle_Help_Text()
                 return                  return
         endif          endif
   
         " Include the empty line displayed after the help text  
         let brief_help_size = 1  
         let full_help_size = 3  
   
         setlocal modifiable          setlocal modifiable
   
         " Set report option to a huge value to prevent informational messages          " Set report option to a huge value to prevent informational messages
Line 480  function! s:SQL_Toggle_Help_Text()
Line 489  function! s:SQL_Toggle_Help_Text()
                 let s:sql_brief_help = 0                  let s:sql_brief_help = 0
   
                 " Remove the previous help                  " Remove the previous help
                 exe '1,' . brief_help_size . ' delete _'                  exe '1,' . s:brief_help_size . ' delete _'
   
                 " Adjust the start/end line numbers for the files                  " Adjust the start/end line numbers for the files
                 "call s:SQL_Update_Line_Offsets(0, 1, full_help_size - brief_help_size)                  "call s:SQL_Update_Line_Offsets(0, 1, s:full_help_size - s:brief_help_size)
         else          else
                 let s:sql_brief_help = 1                  let s:sql_brief_help = 1
   
                 " Remove the previous help                  " Remove the previous help
                 exe '1,' . full_help_size . ' delete _'                  exe '1,' . s:full_help_size . ' delete _'
   
                 " Adjust the start/end line numbers for the files                  " Adjust the start/end line numbers for the files
                 "call s:SQL_Update_Line_Offsets(0, 0, full_help_size - brief_help_size)                  "call s:SQL_Update_Line_Offsets(0, 0, s:full_help_size - s:brief_help_size)
         endif          endif
   
         call s:SQL_Display_Help()          call s:SQL_Display_Help()
Line 503  function! s:SQL_Toggle_Help_Text()
Line 512  function! s:SQL_Toggle_Help_Text()
 endfunction  endfunction
 " }}}  " }}}
   
 " Map_SQL_cmd_mappings() {{{  " s:Map_SQL_cmd_mappings() {{{
 function! s:Map_SQL_mappings()  function! s:Map_SQL_mappings()
         " get number of current window          " get number of current window
         let curwinnum = bufwinnr('%')          let curwinnum = bufwinnr('%')
   
         let winnum = bufwinnr("SQL")          let winnum = bufwinnr(g:SQL_main_window_title)
         if winnum >= 0 " if window exists          if winnum >= 0 " if window exists
                 " toggle to SQL window and then back                  " toggle to SQL window and then back
                 execute "normal \<c-w>" . winnum . "w"                  execute "normal \<c-w>" . winnum . "w"
   
                 inoremap <buffer> <silent> ?    <C-o>:call <SID>SQL_Toggle_Help_Text()<CR>                  inoremap <buffer> <silent> ? <C-o>:call <SID>SQL_Toggle_Help_Text()<CR>
                 nnoremap <buffer> <silent> ? :call <SID>SQL_Toggle_Help_Text()<CR>                  nnoremap <buffer> <silent> ? :call <SID>SQL_Toggle_Help_Text()<CR>
   
                   inoremap <buffer> <silent> U <C-o>:call <SID>SQL_UpdateDatabaseList()<CR>
                   nnoremap <buffer> <silent> U :call <SID>SQL_UpdateDatabaseList()<CR>
   
                 execute "normal \<c-w>" . curwinnum . "w"                  execute "normal \<c-w>" . curwinnum . "w"
         endif          endif
   
 endfunction  endfunction
 " }}}  " }}}
   
   " s:SQL_UpdateDatabaseList() {{{
   function! s:SQL_UpdateDatabaseList()
   
           " get number of current window
           let curwinnum = bufwinnr('%')
   
           let winnum = bufwinnr(g:SQL_main_window_title)
           if winnum >= 0 " if window exists
                   " toggle to SQL window and then back
                   execute "normal \<c-w>" . winnum . "w"
   
                   setlocal modifiable
   
                   " remove all lines after help lines
                   if s:sql_brief_help
                           exe (s:brief_help_size + 1) . ',$ delete _'
                   else
                           exe (s:full_help_size + 1) . ',$ delete _'
                   endif
   
                   perl << EOF
                   use DBI;
   
                   package main;
   
                   my $count = 0;
                   foreach my $key (sort keys %{$main::connections}) {
                           $count++;
                           # reorder connections
                           my $conn = $main::connections->{$key};
                           $conn->{order} = $count;
                           $main::curbuf->Append($main::curbuf->Count(),
                                   ($conn->{list_tables} ?
                                           ($main::current_conn eq $key ? '* ' : '+ ' ) :
                                           '- ')
                                   . "$main::connections->{$key}->{desc}"
                           );
                   }
   
                   if ($count == 0) { # No connections
                           $main::curbuf->Append($main::curbuf->Count(), '" -- No connections');
                   }
   
   EOF
   
                   setlocal nomodifiable
                   execute "normal \<c-w>" . curwinnum . "w"
           endif
   
   endfunction
   " }}}
   
 " Modeline {{{  " Modeline {{{
 " vim: ts=4  " vim: ts=4

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top