.vim/autoload/DrawIt.vim
changeset 23 c5009fa9a990
parent 22 2cd71622bc9c
child 24 648f80b485ed
equal deleted inserted replaced
22:2cd71622bc9c 23:c5009fa9a990
     1 " DrawIt.vim: a simple way to draw things in Vim -- just put this file in
       
     2 "
       
     3 " Maintainer:	Charles E. Campbell, Jr.  (Charles.E.Campbell.1@gsfc.nasa.gov)
       
     4 " Authors:	Charles E. Campbell, Jr. (NdrchipO@ScampbellPfamily.AbizM - NOSPAM)
       
     5 "   		Sylvain Viart (molo@multimania.com)
       
     6 " Version:	7
       
     7 " Date:		Apr 10, 2006
       
     8 "
       
     9 " Quick Setup: {{{1
       
    10 "              tar -oxvf DrawIt.tar
       
    11 "              Should put DrawItPlugin.vim in your .vim/plugin directory,
       
    12 "                     put DrawIt.vim       in your .vim/autoload directory
       
    13 "                     put DrawIt.txt       in your .vim/doc directory.
       
    14 "             Then, use \di to start DrawIt,
       
    15 "                       \ds to stop  Drawit, and
       
    16 "                       draw by simply moving about using the cursor keys.
       
    17 "
       
    18 "             You may also use visual-block mode to select endpoints and
       
    19 "             draw lines, arrows, and ellipses.
       
    20 "
       
    21 " Copyright:    Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1
       
    22 "               Permission is hereby granted to use and distribute this code,
       
    23 "               with or without modifications, provided that this copyright
       
    24 "               notice is copied with it. Like anything else that's free,
       
    25 "               DrawIt.vim is provided *as is* and comes with no warranty
       
    26 "               of any kind, either expressed or implied. By using this
       
    27 "               plugin, you agree that in no event will the copyright
       
    28 "               holder be liable for any damages resulting from the use
       
    29 "               of this software.
       
    30 "
       
    31 " Required:		THIS SCRIPT REQUIRES VIM 7.0 (or later) {{{1
       
    32 " GetLatestVimScripts: 40 1 :AutoInstall: DrawIt.vim
       
    33 " GetLatestVimScripts: 1066 1 cecutil.vim
       
    34 "
       
    35 "  Woe to her who is rebellious and polluted, the oppressing {{{1
       
    36 "  city! She didn't obey the voice. She didn't receive correction.
       
    37 "  She didn't trust in Yahweh. She didn't draw near to her God. (Zeph 3:1,2 WEB)
       
    38 
       
    39 " ---------------------------------------------------------------------
       
    40 " Load Once: {{{1
       
    41 if &cp || exists("g:loaded_DrawIt")
       
    42  finish
       
    43 endif
       
    44 let s:keepcpo= &cpo
       
    45 set cpo&vim
       
    46 
       
    47 " ---------------------------------------------------------------------
       
    48 "  Script Variables: {{{1
       
    49 if !exists("s:saveposn_count")
       
    50  let s:saveposn_count= 0
       
    51 endif
       
    52 let g:loaded_DrawIt= "v7"
       
    53 
       
    54 " =====================================================================
       
    55 " Drawit Functions: (by Charles E. Campbell, Jr.) {{{1
       
    56 " =====================================================================
       
    57 
       
    58 " ---------------------------------------------------------------------
       
    59 " StartDrawIt: this function maps the cursor keys, sets up default {{{2
       
    60 "              drawing characters, and makes some settings
       
    61 fun! DrawIt#StartDrawIt()
       
    62 "  call Dfunc("StartDrawIt()")
       
    63 
       
    64   " report on [DrawIt] mode {{{3
       
    65   if exists("b:dodrawit") && b:dodrawit == 1
       
    66    " already in DrawIt mode
       
    67     if exists("mapleader") && mapleader != ""
       
    68      let usermaplead= mapleader
       
    69     else
       
    70      let usermaplead= '\'
       
    71     endif
       
    72     echo "[DrawIt] (already on, use ".usermaplead."ds to stop)"
       
    73 "   call Dret("StartDrawIt")
       
    74    return
       
    75   endif
       
    76   let b:dodrawit= 1
       
    77 
       
    78   " indicate in DrawIt mode
       
    79   echo "[DrawIt]"
       
    80 
       
    81   " turn on mouse {{{3
       
    82   if !exists("b:drawit_keep_mouse")
       
    83    let b:drawit_keep_mouse= &mouse
       
    84   endif
       
    85   set mouse=a
       
    86 
       
    87   " set up DrawIt commands
       
    88   com! -nargs=1 -range SetBrush <line1>,<line2>call DrawIt#SetBrush(<q-args>)
       
    89 
       
    90   " set up default drawing characters {{{3
       
    91   if !exists("b:di_vert")
       
    92    let b:di_vert= "|"
       
    93   endif
       
    94   if !exists("b:di_horiz")
       
    95    let b:di_horiz= "-"
       
    96   endif
       
    97   if !exists("b:di_plus")
       
    98    let b:di_plus= "+"
       
    99   endif
       
   100   if !exists("b:di_upright")		" also downleft
       
   101    let b:di_upright= "/"
       
   102   endif
       
   103   if !exists("b:di_upleft")	" also downright
       
   104    let b:di_upleft= "\\"
       
   105   endif
       
   106   if !exists("b:di_cross")
       
   107    let b:di_cross= "X"
       
   108   endif
       
   109 
       
   110   " set up initial DrawIt behavior (as opposed to erase behavior)
       
   111   let b:di_erase= 0
       
   112 
       
   113   " option recording {{{3
       
   114   let b:di_aikeep    = &ai
       
   115   let b:di_cinkeep   = &cin
       
   116   let b:di_cpokeep   = &cpo
       
   117   let b:di_etkeep    = &et
       
   118   let b:di_fokeep    = &fo
       
   119   let b:di_gdkeep    = &gd
       
   120   let b:di_gokeep    = &go
       
   121   let b:di_magickeep = &magic
       
   122   let b:di_remapkeep = &remap
       
   123   let b:di_repkeep   = &report
       
   124   let b:di_sikeep    = &si
       
   125   let b:di_stakeep   = &sta
       
   126   let b:di_vekeep    = &ve
       
   127   set cpo&vim
       
   128   set nocin noai nosi nogd sta et ve="" report=10000
       
   129   set go-=aA
       
   130   set fo-=a
       
   131   set remap magic
       
   132 
       
   133   " save and unmap user maps {{{3
       
   134   let b:lastdir    = 1
       
   135   if exists("mapleader")
       
   136    let usermaplead  = mapleader
       
   137   else
       
   138    let usermaplead  = "\\"
       
   139   endif
       
   140   call SaveUserMaps("n","","><^v","DrawIt")
       
   141   call SaveUserMaps("v",usermaplead,"abeflsy","DrawIt")
       
   142   call SaveUserMaps("n",usermaplead,"h><v^","DrawIt")
       
   143   call SaveUserMaps("n","","<left>","DrawIt")
       
   144   call SaveUserMaps("n","","<right>","DrawIt")
       
   145   call SaveUserMaps("n","","<up>","DrawIt")
       
   146   call SaveUserMaps("n","","<down>","DrawIt")
       
   147   call SaveUserMaps("n","","<left>","DrawIt")
       
   148   call SaveUserMaps("n","","<s-right>","DrawIt")
       
   149   call SaveUserMaps("n","","<s-up>","DrawIt")
       
   150   call SaveUserMaps("n","","<s-down>","DrawIt")
       
   151   call SaveUserMaps("n","","<space>","DrawIt")
       
   152   call SaveUserMaps("n","","<home>","DrawIt")
       
   153   call SaveUserMaps("n","","<end>","DrawIt")
       
   154   call SaveUserMaps("n","","<pageup>","DrawIt")
       
   155   call SaveUserMaps("n","","<pagedown>","DrawIt")
       
   156   call SaveUserMaps("n","","<leftmouse>","DrawIt")
       
   157   call SaveUserMaps("n","","<middlemouse>","DrawIt")
       
   158   call SaveUserMaps("n","","<rightmouse>","DrawIt")
       
   159   call SaveUserMaps("n","","<leftdrag>","DrawIt")
       
   160   call SaveUserMaps("n","","<s-leftmouse>","DrawIt")
       
   161   call SaveUserMaps("n","","<s-leftdrag>","DrawIt")
       
   162   call SaveUserMaps("n","","<s-leftrelease>","DrawIt")
       
   163   call SaveUserMaps("n",usermaplead,"pa","DrawIt")
       
   164   call SaveUserMaps("n",usermaplead,"pb","DrawIt")
       
   165   call SaveUserMaps("n",usermaplead,"pc","DrawIt")
       
   166   call SaveUserMaps("n",usermaplead,"pd","DrawIt")
       
   167   call SaveUserMaps("n",usermaplead,"pe","DrawIt")
       
   168   call SaveUserMaps("n",usermaplead,"pf","DrawIt")
       
   169   call SaveUserMaps("n",usermaplead,"pg","DrawIt")
       
   170   call SaveUserMaps("n",usermaplead,"ph","DrawIt")
       
   171   call SaveUserMaps("n",usermaplead,"pi","DrawIt")
       
   172   call SaveUserMaps("n",usermaplead,"pj","DrawIt")
       
   173   call SaveUserMaps("n",usermaplead,"pk","DrawIt")
       
   174   call SaveUserMaps("n",usermaplead,"pl","DrawIt")
       
   175   call SaveUserMaps("n",usermaplead,"pm","DrawIt")
       
   176   call SaveUserMaps("n",usermaplead,"pn","DrawIt")
       
   177   call SaveUserMaps("n",usermaplead,"po","DrawIt")
       
   178   call SaveUserMaps("n",usermaplead,"pp","DrawIt")
       
   179   call SaveUserMaps("n",usermaplead,"pq","DrawIt")
       
   180   call SaveUserMaps("n",usermaplead,"pr","DrawIt")
       
   181   call SaveUserMaps("n",usermaplead,"ps","DrawIt")
       
   182   call SaveUserMaps("n",usermaplead,"pt","DrawIt")
       
   183   call SaveUserMaps("n",usermaplead,"pu","DrawIt")
       
   184   call SaveUserMaps("n",usermaplead,"pv","DrawIt")
       
   185   call SaveUserMaps("n",usermaplead,"pw","DrawIt")
       
   186   call SaveUserMaps("n",usermaplead,"px","DrawIt")
       
   187   call SaveUserMaps("n",usermaplead,"py","DrawIt")
       
   188   call SaveUserMaps("n",usermaplead,"pz","DrawIt")
       
   189   call SaveUserMaps("n",usermaplead,"ra","DrawIt")
       
   190   call SaveUserMaps("n",usermaplead,"rb","DrawIt")
       
   191   call SaveUserMaps("n",usermaplead,"rc","DrawIt")
       
   192   call SaveUserMaps("n",usermaplead,"rd","DrawIt")
       
   193   call SaveUserMaps("n",usermaplead,"re","DrawIt")
       
   194   call SaveUserMaps("n",usermaplead,"rf","DrawIt")
       
   195   call SaveUserMaps("n",usermaplead,"rg","DrawIt")
       
   196   call SaveUserMaps("n",usermaplead,"rh","DrawIt")
       
   197   call SaveUserMaps("n",usermaplead,"ri","DrawIt")
       
   198   call SaveUserMaps("n",usermaplead,"rj","DrawIt")
       
   199   call SaveUserMaps("n",usermaplead,"rk","DrawIt")
       
   200   call SaveUserMaps("n",usermaplead,"rl","DrawIt")
       
   201   call SaveUserMaps("n",usermaplead,"rm","DrawIt")
       
   202   call SaveUserMaps("n",usermaplead,"rn","DrawIt")
       
   203   call SaveUserMaps("n",usermaplead,"ro","DrawIt")
       
   204   call SaveUserMaps("n",usermaplead,"rp","DrawIt")
       
   205   call SaveUserMaps("n",usermaplead,"rq","DrawIt")
       
   206   call SaveUserMaps("n",usermaplead,"rr","DrawIt")
       
   207   call SaveUserMaps("n",usermaplead,"rs","DrawIt")
       
   208   call SaveUserMaps("n",usermaplead,"rt","DrawIt")
       
   209   call SaveUserMaps("n",usermaplead,"ru","DrawIt")
       
   210   call SaveUserMaps("n",usermaplead,"rv","DrawIt")
       
   211   call SaveUserMaps("n",usermaplead,"rw","DrawIt")
       
   212   call SaveUserMaps("n",usermaplead,"rx","DrawIt")
       
   213   call SaveUserMaps("n",usermaplead,"ry","DrawIt")
       
   214   call SaveUserMaps("n",usermaplead,"rz","DrawIt")
       
   215   if exists("g:drawit_insertmode") && g:drawit_insertmode
       
   216    call SaveUserMaps("i","","<left>","DrawIt")
       
   217    call SaveUserMaps("i","","<right>","DrawIt")
       
   218    call SaveUserMaps("i","","<up>","DrawIt")
       
   219    call SaveUserMaps("i","","<down>","DrawIt")
       
   220    call SaveUserMaps("i","","<left>","DrawIt")
       
   221    call SaveUserMaps("i","","<s-right>","DrawIt")
       
   222    call SaveUserMaps("i","","<s-up>","DrawIt")
       
   223    call SaveUserMaps("i","","<s-down>","DrawIt")
       
   224    call SaveUserMaps("i","","<home>","DrawIt")
       
   225    call SaveUserMaps("i","","<end>","DrawIt")
       
   226    call SaveUserMaps("i","","<pageup>","DrawIt")
       
   227    call SaveUserMaps("i","","<pagedown>","DrawIt")
       
   228    call SaveUserMaps("i","","<leftmouse>","DrawIt")
       
   229   endif
       
   230   call SaveUserMaps("n","",":\<c-v>","DrawIt")
       
   231 
       
   232   " DrawIt maps (Charles Campbell) {{{3
       
   233   nmap <silent> <left>     :set lz<CR>:silent! call <SID>DrawLeft()<CR>:set nolz<CR>
       
   234   nmap <silent> <right>    :set lz<CR>:silent! call <SID>DrawRight()<CR>:set nolz<CR>
       
   235   nmap <silent> <up>       :set lz<CR>:silent! call <SID>DrawUp()<CR>:set nolz<CR>
       
   236   nmap <silent> <down>     :set lz<CR>:silent! call <SID>DrawDown()<CR>:set nolz<CR>
       
   237   nmap <silent> <s-left>   :set lz<CR>:silent! call <SID>MoveLeft()<CR>:set nolz<CR>
       
   238   nmap <silent> <s-right>  :set lz<CR>:silent! call <SID>MoveRight()<CR>:set nolz<CR>
       
   239   nmap <silent> <s-up>     :set lz<CR>:silent! call <SID>MoveUp()<CR>:set nolz<CR>
       
   240   nmap <silent> <s-down>   :set lz<CR>:silent! call <SID>MoveDown()<CR>:set nolz<CR>
       
   241   nmap <silent> <space>    :set lz<CR>:silent! call <SID>DrawErase()<CR>:set nolz<CR>
       
   242   nmap <silent> >          :set lz<CR>:silent! call <SID>DrawSpace('>',1)<CR>:set nolz<CR>
       
   243   nmap <silent> <          :set lz<CR>:silent! call <SID>DrawSpace('<',2)<CR>:set nolz<CR>
       
   244   nmap <silent> ^          :set lz<CR>:silent! call <SID>DrawSpace('^',3)<CR>:set nolz<CR>
       
   245   nmap <silent> v          :set lz<CR>:silent! call <SID>DrawSpace('v',4)<CR>:set nolz<CR>
       
   246   nmap <silent> <home>     :set lz<CR>:silent! call <SID>DrawSlantUpLeft()<CR>:set nolz<CR>
       
   247   nmap <silent> <end>      :set lz<CR>:silent! call <SID>DrawSlantDownLeft()<CR>:set nolz<CR>
       
   248   nmap <silent> <pageup>   :set lz<CR>:silent! call <SID>DrawSlantUpRight()<CR>:set nolz<CR>
       
   249   nmap <silent> <pagedown> :set lz<CR>:silent! call <SID>DrawSlantDownRight()<CR>:set nolz<CR>
       
   250   nmap <silent> <Leader>>	:set lz<CR>:silent! call <SID>DrawFatRArrow()<CR>:set nolz<CR>
       
   251   nmap <silent> <Leader><	:set lz<CR>:silent! call <SID>DrawFatLArrow()<CR>:set nolz<CR>
       
   252   nmap <silent> <Leader>^	:set lz<CR>:silent! call <SID>DrawFatUArrow()<CR>:set nolz<CR>
       
   253   nmap <silent> <Leader>v	:set lz<CR>:silent! call <SID>DrawFatDArrow()<CR>:set nolz<CR>
       
   254   nmap <silent> <Leader>f  :call <SID>Flood()<cr>
       
   255 
       
   256   " Set up insertmode maps {{{3
       
   257   if exists("g:drawit_insertmode") && g:drawit_insertmode
       
   258    imap <silent> <left>     <Esc><left>a
       
   259    imap <silent> <right>    <Esc><right>a
       
   260    imap <silent> <up>       <Esc><up>a
       
   261    imap <silent> <down>     <Esc><down>a
       
   262    imap <silent> <left>   <Esc><left>a
       
   263    imap <silent> <s-right>  <Esc><s-right>a
       
   264    imap <silent> <s-up>     <Esc><s-up>a
       
   265    imap <silent> <s-down>   <Esc><s-down>a
       
   266    imap <silent> <home>     <Esc><home>a
       
   267    imap <silent> <end>      <Esc><end>a
       
   268    imap <silent> <pageup>   <Esc><pageup>a
       
   269    imap <silent> <pagedown> <Esc><pagedown>a
       
   270   endif
       
   271 
       
   272   " set up drawing mode mappings (Sylvain Viart) {{{3
       
   273 "  nnoremap <silent> <c-v>      :call <SID>LeftStart()<CR><c-v>
       
   274   nnoremap <silent> <c-v>      :call <SID>LeftStart()<CR><c-v>
       
   275   vmap     <silent> <Leader>a  :<c-u>call <SID>Call_corner('Arrow')<CR>
       
   276   vmap     <silent> <Leader>b  :<c-u>call <SID>Call_corner('Box')<cr>
       
   277   nmap              <Leader>h  :call <SID>Holer()<cr>
       
   278   vmap     <silent> <Leader>l  :<c-u>call <SID>Call_corner('DrawPlainLine')<CR>
       
   279   vmap     <silent> <Leader>s  :<c-u>call <SID>Spacer(line("'<"), line("'>"))<cr>
       
   280 
       
   281   " set up drawing mode mappings (Charles Campbell) {{{3
       
   282   " \pa ... \pb : blanks are transparent
       
   283   " \ra ... \rb : blanks copy over
       
   284   vmap <silent> <Leader>e   :<c-u>call <SID>Call_corner('Ellipse')<CR>
       
   285   
       
   286   let allreg= "abcdefghijklmnopqrstuvwxyz"
       
   287   while strlen(allreg) > 0
       
   288    let ireg= strpart(allreg,0,1)
       
   289    exe "nmap <silent> <Leader>p".ireg.'  :<c-u>set lz<cr>:silent! call <SID>PutBlock("'.ireg.'",0)<cr>:set nolz<cr>'
       
   290    exe "nmap <silent> <Leader>r".ireg.'  :<c-u>set lz<cr>:silent! call <SID>PutBlock("'.ireg.'",1)<cr>:set nolz<cr>'
       
   291    let allreg= strpart(allreg,1)
       
   292   endwhile
       
   293 
       
   294   " mouse maps  (Sylvain Viart) {{{3
       
   295   " start visual-block with leftmouse
       
   296   nnoremap <silent> <leftmouse>    <leftmouse>:call <SID>LeftStart()<CR><c-v>
       
   297   vnoremap <silent> <rightmouse>   <leftmouse>:<c-u>call <SID>RightStart(1)<cr>
       
   298   vnoremap <silent> <middlemouse>  <leftmouse>:<c-u>call <SID>RightStart(0)<cr>
       
   299 
       
   300   " mouse maps (Charles Campbell) {{{3
       
   301   " Draw with current brush
       
   302   nnoremap <silent> <s-leftmouse>  <leftmouse>:call <SID>SLeftStart()<CR><c-v>
       
   303 
       
   304  " Menu support {{{3
       
   305  if has("gui_running") && has("menu") && &go =~ 'm'
       
   306   exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Stop\ \ DrawIt<tab>\\ds				<Leader>ds'
       
   307   exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Toggle\ Erase\ Mode<tab><space>	<space>'
       
   308   exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Arrow<tab>\\a					<Leader>a'
       
   309   exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Box<tab>\\b						<Leader>b'
       
   310   exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Ellipse<tab>\\e					<Leader>e'
       
   311   exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Flood<tab>\\e					<Leader>f'
       
   312   exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Line<tab>\\l						<Leader>l'
       
   313   exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Make\ Blank\ Zone<tab>\\h			<Leader>h'
       
   314   exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Append\ Blanks<tab>\\s				<Leader>s'
       
   315   exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Start\ DrawIt'
       
   316  endif
       
   317 " call Dret("StartDrawIt")
       
   318 endfun
       
   319 
       
   320 " ---------------------------------------------------------------------
       
   321 " StopDrawIt: this function unmaps the cursor keys and restores settings {{{2
       
   322 fun! DrawIt#StopDrawIt()
       
   323 "  call Dfunc("StopDrawIt()")
       
   324  
       
   325   " report on [DrawIt off] mode {{{3
       
   326   if !exists("b:dodrawit")
       
   327    echo "[DrawIt off]"
       
   328 "   call Dret("StopDrawIt")
       
   329    return
       
   330   endif
       
   331 
       
   332   " restore mouse {{{3
       
   333   if exists("b:drawit_keep_mouse")
       
   334    let &mouse= b:drawit_keep_mouse
       
   335    unlet b:drawit_keep_mouse
       
   336   endif
       
   337   unlet b:dodrawit
       
   338   echo "[DrawIt off]"
       
   339 
       
   340   if exists("b:drawit_holer_used")
       
   341    " clean up trailing white space
       
   342    call s:SavePosn()
       
   343    silent! %s/\s\+$//e
       
   344    unlet b:drawit_holer_used
       
   345    call s:RestorePosn()
       
   346   endif
       
   347 
       
   348   " remove drawit commands {{{3
       
   349   delc SetBrush
       
   350 
       
   351   " insure that erase mode is off {{{3
       
   352   " (thanks go to Gary Johnson for this)
       
   353   if b:di_erase == 1
       
   354   	call s:DrawErase()
       
   355   endif
       
   356 
       
   357   " restore user map(s), if any {{{3
       
   358   call RestoreUserMaps("DrawIt")
       
   359 
       
   360   " restore user's options {{{3
       
   361   let &ai     = b:di_aikeep
       
   362   let &cin    = b:di_cinkeep
       
   363   let &cpo    = b:di_cpokeep
       
   364   let &et     = b:di_etkeep
       
   365   let &fo     = b:di_fokeep
       
   366   let &gd     = b:di_gdkeep
       
   367   let &go     = b:di_gokeep
       
   368   let &magic  = b:di_magickeep
       
   369   let &remap  = b:di_remapkeep
       
   370   let &report = b:di_repkeep
       
   371   let &si     = b:di_sikeep
       
   372   let &sta    = b:di_stakeep
       
   373   let &ve     = b:di_vekeep
       
   374   unlet b:di_aikeep  
       
   375   unlet b:di_cinkeep 
       
   376   unlet b:di_cpokeep 
       
   377   unlet b:di_etkeep  
       
   378   unlet b:di_fokeep  
       
   379   unlet b:di_gdkeep  
       
   380   unlet b:di_gokeep  
       
   381   unlet b:di_magickeep
       
   382   unlet b:di_remapkeep
       
   383   unlet b:di_repkeep
       
   384   unlet b:di_sikeep  
       
   385   unlet b:di_stakeep 
       
   386   unlet b:di_vekeep  
       
   387 
       
   388  " DrChip menu support: {{{3
       
   389  if has("gui_running") && has("menu") && &go =~ 'm'
       
   390   exe 'menu   '.g:DrChipTopLvlMenu.'DrawIt.Start\ DrawIt<tab>\\di		<Leader>di'
       
   391   exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Stop\ \ DrawIt'
       
   392   exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Toggle\ Erase\ Mode'
       
   393   exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Arrow'
       
   394   exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Box'
       
   395   exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Ellipse'
       
   396   exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Flood'
       
   397   exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Line'
       
   398   exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Make\ Blank\ Zone'
       
   399   exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Append\ Blanks'
       
   400  endif
       
   401 " call Dret("StopDrawIt")
       
   402 endfun
       
   403 
       
   404 " ---------------------------------------------------------------------
       
   405 " SetDrawIt: this function allows one to change the drawing characters {{{2
       
   406 fun! SetDrawIt(di_vert,di_horiz,di_plus,di_upleft,di_upright,di_cross)
       
   407 "  call Dfunc("SetDrawIt(vert<".a:di_vert."> horiz<".a:di_horiz."> plus<".a:di_plus."> upleft<".a:di_upleft."> upright<".a:di_upright."> cross<".a:di_cross.">)")
       
   408   let b:di_vert    = a:di_vert
       
   409   let b:di_horiz   = a:di_horiz
       
   410   let b:di_plus    = a:di_plus
       
   411   let b:di_upleft  = a:di_upleft
       
   412   let b:di_upright = a:di_upright
       
   413   let b:di_cross   = a:di_cross
       
   414 "  call Dret("SetDrawIt")
       
   415 endfun
       
   416 
       
   417 " =====================================================================
       
   418 " DrawLeft: {{{2
       
   419 fun! s:DrawLeft()
       
   420 "  call Dfunc("DrawLeft()")
       
   421   let curline   = getline(".")
       
   422   let curcol    = col(".")
       
   423   let b:lastdir = 2
       
   424 
       
   425   if curcol > 0
       
   426     let curchar= strpart(curline,curcol-1,1)
       
   427 
       
   428     " replace
       
   429    if curchar == b:di_vert || curchar == b:di_plus
       
   430      exe "norm! r".b:di_plus
       
   431    else
       
   432      exe "norm! r".b:di_horiz
       
   433    endif
       
   434 
       
   435    " move and replace
       
   436    if curcol >= 2
       
   437     call s:MoveLeft()
       
   438     let curchar= strpart(curline,curcol-2,1)
       
   439     if curchar == b:di_vert || curchar == b:di_plus
       
   440      exe "norm! r".b:di_plus
       
   441     else
       
   442      exe "norm! r".b:di_horiz
       
   443     endif
       
   444    endif
       
   445   endif
       
   446 "  call Dret("DrawLeft")
       
   447 endfun
       
   448 
       
   449 " ---------------------------------------------------------------------
       
   450 " DrawRight: {{{2
       
   451 fun! s:DrawRight()
       
   452 "  call Dfunc("DrawRight()")
       
   453   let curline   = getline(".")
       
   454   let curcol    = col(".")
       
   455   let b:lastdir = 1
       
   456 
       
   457   " replace
       
   458   if curcol == col("$")
       
   459    exe "norm! a".b:di_horiz."\<Esc>"
       
   460   else
       
   461     let curchar= strpart(curline,curcol-1,1)
       
   462     if curchar == b:di_vert || curchar == b:di_plus
       
   463      exe "norm! r".b:di_plus
       
   464     else
       
   465      exe "norm! r".b:di_horiz
       
   466     endif
       
   467   endif
       
   468 
       
   469   " move and replace
       
   470   call s:MoveRight()
       
   471   if curcol == col("$")
       
   472    exe "norm! i".b:di_horiz."\<Esc>"
       
   473   else
       
   474    let curchar= strpart(curline,curcol,1)
       
   475    if curchar == b:di_vert || curchar == b:di_plus
       
   476     exe "norm! r".b:di_plus
       
   477    else
       
   478     exe "norm! r".b:di_horiz
       
   479    endif
       
   480   endif
       
   481 "  call Dret("DrawRight")
       
   482 endfun
       
   483 
       
   484 " ---------------------------------------------------------------------
       
   485 " DrawUp: {{{2
       
   486 fun! s:DrawUp()
       
   487 "  call Dfunc("DrawUp()")
       
   488   let curline   = getline(".")
       
   489   let curcol    = col(".")
       
   490   let b:lastdir = 3
       
   491 
       
   492   " replace
       
   493   if curcol == 1 && col("$") == 1
       
   494    exe "norm! i".b:di_vert."\<Esc>"
       
   495   else
       
   496    let curchar= strpart(curline,curcol-1,1)
       
   497    if curchar == b:di_horiz || curchar == b:di_plus
       
   498     exe "norm! r".b:di_plus
       
   499    else
       
   500     exe "norm! r".b:di_vert
       
   501    endif
       
   502   endif
       
   503 
       
   504   " move and replace/insert
       
   505   call s:MoveUp()
       
   506   let curline= getline(".")
       
   507   let curchar= strpart(curline,curcol-1,1)
       
   508 
       
   509   if     curcol == 1 && col("$") == 1
       
   510    exe "norm! i".b:di_vert."\<Esc>"
       
   511   elseif curchar == b:di_horiz || curchar == b:di_plus
       
   512    exe "norm! r".b:di_plus
       
   513   else
       
   514    exe "norm! r".b:di_vert
       
   515    endif
       
   516   endif
       
   517 "  call Dret("DrawUp")
       
   518 endfun
       
   519 
       
   520 " ---------------------------------------------------------------------
       
   521 " DrawDown: {{{2
       
   522 fun! s:DrawDown()
       
   523 "  call Dfunc("DrawDown()")
       
   524   let curline   = getline(".")
       
   525   let curcol    = col(".")
       
   526   let b:lastdir = 4
       
   527 
       
   528   " replace
       
   529   if curcol == 1 && col("$") == 1
       
   530    exe "norm! i".b:di_vert."\<Esc>"
       
   531   else
       
   532     let curchar= strpart(curline,curcol-1,1)
       
   533     if curchar == b:di_horiz || curchar == b:di_plus
       
   534      exe "norm! r".b:di_plus
       
   535     else
       
   536      exe "norm! r".b:di_vert
       
   537     endif
       
   538   endif
       
   539 
       
   540   " move and replace/insert
       
   541   call s:MoveDown()
       
   542   let curline= getline(".")
       
   543   let curchar= strpart(curline,curcol-1,1)
       
   544   if     curcol == 1 && col("$") == 1
       
   545    exe "norm! i".b:di_vert."\<Esc>"
       
   546   elseif curchar == b:di_horiz || curchar == b:di_plus
       
   547    exe "norm! r".b:di_plus
       
   548   else
       
   549    exe "norm! r".b:di_vert
       
   550   endif
       
   551 "  call Dret("DrawDown")
       
   552 endfun
       
   553 
       
   554 " ---------------------------------------------------------------------
       
   555 " DrawErase: toggle [DrawIt on] and [DrawIt erase] modes {{{2
       
   556 fun! s:DrawErase()
       
   557 "  call Dfunc("DrawErase() b:di_erase=".b:di_erase)
       
   558   if b:di_erase == 0
       
   559    let b:di_erase= 1
       
   560    echo "[DrawIt erase]"
       
   561    let b:di_vert_save    = b:di_vert
       
   562    let b:di_horiz_save   = b:di_horiz
       
   563    let b:di_plus_save    = b:di_plus
       
   564    let b:di_upright_save = b:di_upright
       
   565    let b:di_upleft_save  = b:di_upleft
       
   566    let b:di_cross_save   = b:di_cross
       
   567    call SetDrawIt(' ',' ',' ',' ',' ',' ')
       
   568   else
       
   569    let b:di_erase= 0
       
   570    echo "[DrawIt]"
       
   571    call SetDrawIt(b:di_vert_save,b:di_horiz_save,b:di_plus_save,b:di_upleft_save,b:di_upright_save,b:di_cross_save)
       
   572   endif
       
   573 "  call Dret("DrawErase")
       
   574 endfun
       
   575 
       
   576 " ---------------------------------------------------------------------
       
   577 " DrawSpace: clear character and move right {{{2
       
   578 fun! s:DrawSpace(chr,dir)
       
   579 "  call Dfunc("DrawSpace(chr<".a:chr."> dir<".a:dir.">)")
       
   580   let curcol= col(".")
       
   581 
       
   582   " replace current location with arrowhead/space
       
   583   if curcol == col("$")-1
       
   584    exe "norm! r".a:chr
       
   585   else
       
   586    exe "norm! r".a:chr
       
   587   endif
       
   588 
       
   589   if a:dir == 0
       
   590    let dir= b:lastdir
       
   591   else
       
   592    let dir= a:dir
       
   593   endif
       
   594 
       
   595   " perform specified move
       
   596   if dir == 1
       
   597    call s:MoveRight()
       
   598   elseif dir == 2
       
   599    call s:MoveLeft()
       
   600   elseif dir == 3
       
   601    call s:MoveUp()
       
   602   else
       
   603    call s:MoveDown()
       
   604   endif
       
   605 "  call Dret("DrawSpace")
       
   606 endfun
       
   607 
       
   608 " ---------------------------------------------------------------------
       
   609 " DrawSlantDownLeft: / {{{2
       
   610 fun! s:DrawSlantDownLeft()
       
   611 "  call Dfunc("DrawSlantDownLeft()")
       
   612   call s:ReplaceDownLeft()		" replace
       
   613   call s:MoveDown()				" move
       
   614   call s:MoveLeft()				" move
       
   615   call s:ReplaceDownLeft()		" replace
       
   616 "  call Dret("DrawSlantDownLeft")
       
   617 endfun
       
   618 
       
   619 " ---------------------------------------------------------------------
       
   620 " DrawSlantDownRight: \ {{{2
       
   621 fun! s:DrawSlantDownRight()
       
   622 "  call Dfunc("DrawSlantDownRight()")
       
   623   call s:ReplaceDownRight()	" replace
       
   624   call s:MoveDown()			" move
       
   625   call s:MoveRight()		" move
       
   626   call s:ReplaceDownRight()	" replace
       
   627 "  call Dret("DrawSlantDownRight")
       
   628 endfun
       
   629 
       
   630 " ---------------------------------------------------------------------
       
   631 " DrawSlantUpLeft: \ {{{2
       
   632 fun! s:DrawSlantUpLeft()
       
   633 "  call Dfunc("DrawSlantUpLeft()")
       
   634   call s:ReplaceDownRight()	" replace
       
   635   call s:MoveUp()			" move
       
   636   call s:MoveLeft()			" move
       
   637   call s:ReplaceDownRight()	" replace
       
   638 "  call Dret("DrawSlantUpLeft")
       
   639 endfun
       
   640 
       
   641 " ---------------------------------------------------------------------
       
   642 " DrawSlantUpRight: / {{{2
       
   643 fun! s:DrawSlantUpRight()
       
   644 "  call Dfunc("DrawSlantUpRight()")
       
   645   call s:ReplaceDownLeft()	" replace
       
   646   call s:MoveUp()			" move
       
   647   call s:MoveRight()		" replace
       
   648   call s:ReplaceDownLeft()	" replace
       
   649 "  call Dret("DrawSlantUpRight")
       
   650 endfun
       
   651 
       
   652 " ---------------------------------------------------------------------
       
   653 " MoveLeft: {{{2
       
   654 fun! s:MoveLeft()
       
   655 "  call Dfunc("MoveLeft()")
       
   656   norm! h
       
   657   let b:lastdir= 2
       
   658 "  call Dret("MoveLeft : b:lastdir=".b:lastdir)
       
   659 endfun
       
   660 
       
   661 " ---------------------------------------------------------------------
       
   662 " MoveRight: {{{2
       
   663 fun! s:MoveRight()
       
   664 "  call Dfunc("MoveRight()")
       
   665   if col(".") >= col("$") - 1
       
   666    exe "norm! A \<Esc>"
       
   667   else
       
   668    norm! l
       
   669   endif
       
   670   let b:lastdir= 1
       
   671 "  call Dret("MoveRight : b:lastdir=".b:lastdir)
       
   672 endfun
       
   673 
       
   674 " ---------------------------------------------------------------------
       
   675 " MoveUp: {{{2
       
   676 fun! s:MoveUp()
       
   677 "  call Dfunc("MoveUp()")
       
   678   if line(".") == 1
       
   679    let curcol= col(".") - 1
       
   680    if curcol == 0 && col("$") == 1
       
   681      exe "norm! i \<Esc>"
       
   682    elseif curcol == 0
       
   683      exe "norm! YP:s/./ /ge\<CR>0r "
       
   684    else
       
   685      exe "norm! YP:s/./ /ge\<CR>0".curcol."lr "
       
   686    endif
       
   687   else
       
   688    let curcol= col(".")
       
   689    norm! k
       
   690    while col("$") <= curcol
       
   691      exe "norm! A \<Esc>"
       
   692    endwhile
       
   693   endif
       
   694   let b:lastdir= 3
       
   695 "  call Dret("MoveUp : b:lastdir=".b:lastdir)
       
   696 endfun
       
   697 
       
   698 " ---------------------------------------------------------------------
       
   699 " MoveDown: {{{2
       
   700 fun! s:MoveDown()
       
   701 "  call Dfunc("MoveDown()")
       
   702   if line(".") == line("$")
       
   703    let curcol= col(".") - 1
       
   704    if curcol == 0 && col("$") == 1
       
   705     exe "norm! i \<Esc>"
       
   706    elseif curcol == 0
       
   707     exe "norm! Yp:s/./ /ge\<CR>0r "
       
   708    else
       
   709     exe "norm! Yp:s/./ /ge\<CR>0".curcol."lr "
       
   710    endif
       
   711   else
       
   712    let curcol= col(".")
       
   713    norm! j
       
   714    while col("$") <= curcol
       
   715     exe "norm! A \<Esc>"
       
   716    endwhile
       
   717   endif
       
   718   let b:lastdir= 4
       
   719 "  call Dret("MoveDown : b:lastdir=".b:lastdir)
       
   720 endfun
       
   721 
       
   722 " ---------------------------------------------------------------------
       
   723 " ReplaceDownLeft: / X  (upright) {{{2
       
   724 fun! s:ReplaceDownLeft()
       
   725 "  call Dfunc("ReplaceDownLeft()")
       
   726   let curcol = col(".")
       
   727   if curcol != col("$")
       
   728    let curchar= strpart(getline("."),curcol-1,1)
       
   729    if curchar == "\\" || curchar == "X"
       
   730     exe "norm! r".b:di_cross
       
   731    else
       
   732     exe "norm! r".b:di_upright
       
   733    endif
       
   734   else
       
   735    exe "norm! i".b:di_upright."\<Esc>"
       
   736   endif
       
   737 "  call Dret("ReplaceDownLeft")
       
   738 endfun
       
   739 
       
   740 " ---------------------------------------------------------------------
       
   741 " ReplaceDownRight: \ X  (upleft) {{{2
       
   742 fun! s:ReplaceDownRight()
       
   743 "  call Dfunc("ReplaceDownRight()")
       
   744   let curcol = col(".")
       
   745   if curcol != col("$")
       
   746    let curchar= strpart(getline("."),curcol-1,1)
       
   747    if curchar == "/" || curchar == "X"
       
   748     exe "norm! r".b:di_cross
       
   749    else
       
   750     exe "norm! r".b:di_upleft
       
   751    endif
       
   752   else
       
   753    exe "norm! i".b:di_upleft."\<Esc>"
       
   754   endif
       
   755 "  call Dret("ReplaceDownRight")
       
   756 endfun
       
   757 
       
   758 " ---------------------------------------------------------------------
       
   759 " DrawFatRArrow: ----|> {{{2
       
   760 fun! s:DrawFatRArrow()
       
   761 "  call Dfunc("DrawFatRArrow()")
       
   762   call s:MoveRight()
       
   763   norm! r|
       
   764   call s:MoveRight()
       
   765   norm! r>
       
   766 "  call Dret("DrawFatRArrow")
       
   767 endfun
       
   768 
       
   769 " ---------------------------------------------------------------------
       
   770 " DrawFatLArrow: <|---- {{{2
       
   771 fun! s:DrawFatLArrow()
       
   772 "  call Dfunc("DrawFatLArrow()")
       
   773   call s:MoveLeft()
       
   774   norm! r|
       
   775   call s:MoveLeft()
       
   776   norm! r<
       
   777 "  call Dret("DrawFatLArrow")
       
   778 endfun
       
   779 
       
   780 " ---------------------------------------------------------------------
       
   781 "                 .
       
   782 " DrawFatUArrow: /_\ {{{2
       
   783 "                 |
       
   784 fun! s:DrawFatUArrow()
       
   785 "  call Dfunc("DrawFatUArrow()")
       
   786   call s:MoveUp()
       
   787   norm! r_
       
   788   call s:MoveRight()
       
   789   norm! r\
       
   790   call s:MoveLeft()
       
   791   call s:MoveLeft()
       
   792   norm! r/
       
   793   call s:MoveRight()
       
   794   call s:MoveUp()
       
   795   norm! r.
       
   796 "  call Dret("DrawFatUArrow")
       
   797 endfun
       
   798 
       
   799 " ---------------------------------------------------------------------
       
   800 " DrawFatDArrow: _|_ {{{2
       
   801 "                \ /
       
   802 "                 '
       
   803 fun! s:DrawFatDArrow()
       
   804 "  call Dfunc("DrawFatDArrow()")
       
   805   call s:MoveRight()
       
   806   norm! r_
       
   807   call s:MoveLeft()
       
   808   call s:MoveLeft()
       
   809   norm! r_
       
   810   call s:MoveDown()
       
   811   norm! r\
       
   812   call s:MoveRight()
       
   813   call s:MoveRight()
       
   814   norm! r/
       
   815   call s:MoveDown()
       
   816   call s:MoveLeft()
       
   817   norm! r'
       
   818 "  call Dret("DrawFatDArrow")
       
   819 endfun
       
   820 
       
   821 " ---------------------------------------------------------------------
       
   822 " DrawEllipse: Bresenham-like ellipse drawing algorithm {{{2
       
   823 "      2   2      can
       
   824 "     x   y       be             2 2   2 2   2 2
       
   825 "     - + - = 1   rewritten     b x + a y = a b
       
   826 "     a   b       as
       
   827 "
       
   828 "     Take step which has minimum error
       
   829 "     (x,y-1)  (x+1,y)  (x+1,y-1)
       
   830 "
       
   831 "             2 2   2 2   2 2
       
   832 "     Ei = | b x + a y - a b |
       
   833 "
       
   834 "     Algorithm only draws arc from (0,b) to (a,0) and uses
       
   835 "     DrawFour() to reflect points to other three quadrants
       
   836 fun! s:Ellipse(x0,y0,x1,y1)
       
   837 "  call Dfunc("Ellipse(x0=".a:x0." y0=".a:y0." x1=".a:x1." y1=".a:y1.")")
       
   838   let x0   = a:x0
       
   839   let y0   = a:y0
       
   840   let x1   = a:x1
       
   841   let y1   = a:y1
       
   842   let xoff = (x0+x1)/2
       
   843   let yoff = (y0+y1)/2
       
   844   let a    = s:Abs(x1-x0)/2
       
   845   let b    = s:Abs(y1-y0)/2
       
   846   let a2   = a*a
       
   847   let b2   = b*b
       
   848   let twoa2= a2 + a2
       
   849   let twob2= b2 + b2
       
   850 
       
   851   let xi= 0
       
   852   let yi= b
       
   853   let ei= 0
       
   854   call s:DrawFour(xi,yi,xoff,yoff,a,b)
       
   855   while xi <= a && yi >= 0
       
   856 
       
   857      let dy= a2 - twoa2*yi
       
   858      let ca= ei + twob2*xi + b2
       
   859      let cb= ca + dy
       
   860      let cc= ei + dy
       
   861 
       
   862      let aca= s:Abs(ca)
       
   863      let acb= s:Abs(cb)
       
   864      let acc= s:Abs(cc)
       
   865 
       
   866      " pick case: (xi+1,yi) (xi,yi-1) (xi+1,yi-1)
       
   867      if aca <= acb && aca <= acc
       
   868         let xi= xi + 1
       
   869         let ei= ca
       
   870      elseif acb <= aca && acb <= acc
       
   871         let ei= cb
       
   872         let xi= xi + 1
       
   873         let yi= yi - 1
       
   874      else
       
   875         let ei= cc
       
   876         let yi= yi - 1
       
   877      endif
       
   878      if xi > a:x1
       
   879         break
       
   880      endif
       
   881      call s:DrawFour(xi,yi,xoff,yoff,a,b)
       
   882   endw
       
   883 "  call Dret("Ellipse")
       
   884 endf
       
   885 
       
   886 " ---------------------------------------------------------------------
       
   887 " DrawFour: reflect a point to four quadrants {{{2
       
   888 fun! s:DrawFour(x,y,xoff,yoff,a,b)
       
   889 "  call Dfunc("DrawFour(xy[".a:x.",".a:y."] off[".a:xoff.",".a:yoff."] a=".a:a." b=".a:b.")")
       
   890   let x  = a:xoff + a:x
       
   891   let y  = a:yoff + a:y
       
   892   let lx = a:xoff - a:x
       
   893   let by = a:yoff - a:y
       
   894   call s:SetCharAt('*',  x, y)
       
   895   call s:SetCharAt('*', lx, y)
       
   896   call s:SetCharAt('*', lx,by)
       
   897   call s:SetCharAt('*',  x,by)
       
   898 "  call Dret("DrawFour")
       
   899 endf
       
   900 
       
   901 " ---------------------------------------------------------------------
       
   902 " SavePosn: saves position of cursor on screen so NetWrite can restore it {{{2
       
   903 fun! s:SavePosn()
       
   904 "  call Dfunc("SavePosn() saveposn_count=".s:saveposn_count)
       
   905   let s:saveposn_count= s:saveposn_count + 1
       
   906 
       
   907   " Save current line and column
       
   908   let b:drawit_line_{s:saveposn_count} = line(".")
       
   909   let b:drawit_col_{s:saveposn_count}  = col(".") - 1
       
   910 
       
   911   " Save top-of-screen line
       
   912   norm! H
       
   913   let b:drawit_hline_{s:saveposn_count}= line(".")
       
   914 
       
   915   " restore position
       
   916   exe "norm! ".b:drawit_hline_{s:saveposn_count}."G0z\<CR>"
       
   917   if b:drawit_col_{s:saveposn_count} == 0
       
   918    exe "norm! ".b:drawit_line_{s:saveposn_count}."G0"
       
   919   else
       
   920    exe "norm! ".b:drawit_line_{s:saveposn_count}."G0".b:drawit_col_{s:saveposn_count}."l"
       
   921   endif
       
   922 "  call Dret("SavePosn : saveposn_count=".s:saveposn_count)
       
   923 endfun
       
   924 
       
   925 " ------------------------------------------------------------------------
       
   926 " RestorePosn: {{{2
       
   927 fun! s:RestorePosn()
       
   928 "  call Dfunc("RestorePosn() saveposn_count=".s:saveposn_count)
       
   929   if s:saveposn_count <= 0
       
   930   	return
       
   931   endif
       
   932   " restore top-of-screen line
       
   933   exe "norm! ".b:drawit_hline_{s:saveposn_count}."G0z\<CR>"
       
   934 
       
   935   " restore position
       
   936   if b:drawit_col_{s:saveposn_count} == 0
       
   937    exe "norm! ".b:drawit_line_{s:saveposn_count}."G0"
       
   938   else
       
   939    exe "norm! ".b:drawit_line_{s:saveposn_count}."G0".b:drawit_col_{s:saveposn_count}."l"
       
   940   endif
       
   941   if s:saveposn_count > 0
       
   942 	unlet b:drawit_hline_{s:saveposn_count}
       
   943 	unlet b:drawit_line_{s:saveposn_count}
       
   944 	unlet b:drawit_col_{s:saveposn_count}
       
   945    let s:saveposn_count= s:saveposn_count - 1
       
   946   endif
       
   947 "  call Dret("RestorePosn : saveposn_count=".s:saveposn_count)
       
   948 endfun
       
   949 
       
   950 " ------------------------------------------------------------------------
       
   951 " Flood: this function begins a flood of a region {{{2
       
   952 "        based on b:di... characters as boundaries
       
   953 "        and starting at the current cursor location.
       
   954 fun! s:Flood()
       
   955 "  call Dfunc("Flood()")
       
   956 
       
   957   let s:bndry  = b:di_vert.b:di_horiz.b:di_plus.b:di_upright.b:di_upleft.b:di_cross
       
   958   let row      = line(".")
       
   959   let col      = virtcol(".")
       
   960   let athold   = @0
       
   961   let s:DIrows = line("$")
       
   962   call s:SavePosn()
       
   963 
       
   964   " get fill character from user
       
   965   " Put entire fillchar string into the s:bndry (boundary characters),
       
   966   " although only use the first such character for filling
       
   967   call inputsave()
       
   968   let s:fillchar= input("Enter fill character: ")
       
   969   call inputrestore()
       
   970   let s:bndry= "[".escape(s:bndry.s:fillchar,'\-]^')."]"
       
   971   if strlen(s:fillchar) > 1
       
   972    let s:fillchar= strpart(s:fillchar,0,1)
       
   973   endif
       
   974 
       
   975   " flood the region
       
   976   call s:DI_Flood(row,col)
       
   977 
       
   978   " restore
       
   979   call s:RestorePosn()
       
   980   let @0= athold
       
   981   unlet s:DIrows s:bndry s:fillchar
       
   982 
       
   983 "  call Dret("Flood")
       
   984 endfun
       
   985 
       
   986 " ------------------------------------------------------------------------
       
   987 " DI_Flood: fill up to the boundaries all characters to the left and right. {{{2
       
   988 "           Then, based on the left/right column extents reached, check
       
   989 "           adjacent rows to see if any characters there need filling.
       
   990 fun! s:DI_Flood(frow,fcol)
       
   991 "  call Dfunc("DI_Flood(frow=".a:frow." fcol=".a:fcol.")")
       
   992   if a:frow <= 0 || a:fcol <= 0 || s:SetPosn(a:frow,a:fcol) || s:IsBoundary(a:frow,a:fcol)
       
   993 "   call Dret("DI_Flood")
       
   994    return
       
   995   endif
       
   996 
       
   997   " fill current line
       
   998   let colL= s:DI_FillLeft(a:frow,a:fcol)
       
   999   let colR= s:DI_FillRight(a:frow,a:fcol+1)
       
  1000 
       
  1001   " do a filladjacent on the next line up
       
  1002   if a:frow > 1
       
  1003    call s:DI_FillAdjacent(a:frow-1,colL,colR)
       
  1004   endif
       
  1005 
       
  1006   " do a filladjacent on the next line down
       
  1007   if a:frow < s:DIrows
       
  1008    call s:DI_FillAdjacent(a:frow+1,colL,colR)
       
  1009   endif
       
  1010 
       
  1011 "  call Dret("DI_Flood")
       
  1012 endfun
       
  1013 
       
  1014 " ------------------------------------------------------------------------
       
  1015 "  DI_FillLeft: Starting at (frow,fcol), non-boundary locations are {{{2
       
  1016 "               filled with the fillchar.  The leftmost extent reached
       
  1017 "               is returned.
       
  1018 fun! s:DI_FillLeft(frow,fcol)
       
  1019 "  call Dfunc("DI_FillLeft(frow=".a:frow." fcol=".a:fcol.")")
       
  1020   if s:SetPosn(a:frow,a:fcol)
       
  1021 "   call Dret("DI_FillLeft ".a:fcol)
       
  1022    return a:fcol
       
  1023   endif
       
  1024 
       
  1025   let Lcol= a:fcol
       
  1026   while Lcol >= 1
       
  1027    if !s:IsBoundary(a:frow,Lcol)
       
  1028     exe  "silent! norm! r".s:fillchar."h"
       
  1029    else
       
  1030     break
       
  1031    endif
       
  1032    let Lcol= Lcol - 1
       
  1033   endwhile
       
  1034 
       
  1035  let Lcol= (Lcol < 1)? 1 : Lcol + 1
       
  1036 
       
  1037 " call Dret("DI_FillLeft ".Lcol)
       
  1038  return Lcol
       
  1039 endfun
       
  1040 
       
  1041 " ---------------------------------------------------------------------
       
  1042 "  DI_FillRight: Starting at (frow,fcol), non-boundary locations are {{{2
       
  1043 "                filled with the fillchar.  The rightmost extent reached
       
  1044 "                is returned.
       
  1045 fun! s:DI_FillRight(frow,fcol)
       
  1046 "  call Dfunc("DI_FillRight(frow=".a:frow." fcol=".a:fcol.")")
       
  1047   if s:SetPosn(a:frow,a:fcol)
       
  1048 "   call Dret("DI_FillRight ".a:fcol)
       
  1049    return a:fcol
       
  1050   endif
       
  1051 
       
  1052   let Rcol   = a:fcol
       
  1053   while Rcol <= virtcol("$")
       
  1054    if !s:IsBoundary(a:frow,Rcol)
       
  1055     exe "silent! norm! r".s:fillchar."l"
       
  1056    else
       
  1057     break
       
  1058    endif
       
  1059    let Rcol= Rcol + 1
       
  1060   endwhile
       
  1061 
       
  1062   let DIcols = virtcol("$")
       
  1063   let Rcol   = (Rcol > DIcols)? DIcols : Rcol - 1
       
  1064 
       
  1065 "  call Dret("DI_FillRight ".Rcol)
       
  1066   return Rcol
       
  1067 endfun
       
  1068 
       
  1069 " ---------------------------------------------------------------------
       
  1070 "  DI_FillAdjacent: {{{2
       
  1071 "     DI_Flood does FillLeft and FillRight, so the run from left to right
       
  1072 "    (fcolL to fcolR) is known to have been filled.  FillAdjacent is called
       
  1073 "    from (fcolL to fcolR) on the lines one row up and down; if any character
       
  1074 "    on the run is not a boundary character, then a flood is needed on that
       
  1075 "    location.
       
  1076 fun! s:DI_FillAdjacent(frow,fcolL,fcolR)
       
  1077 "  call Dfunc("DI_FillAdjacent(frow=".a:frow." fcolL=".a:fcolL." fcolR=".a:fcolR.")")
       
  1078 
       
  1079   let icol  = a:fcolL
       
  1080   while icol <= a:fcolR
       
  1081 	if !s:IsBoundary(a:frow,icol)
       
  1082 	 call s:DI_Flood(a:frow,icol)
       
  1083 	endif
       
  1084    let icol= icol + 1
       
  1085   endwhile
       
  1086 
       
  1087 "  call Dret("DI_FillAdjacent")
       
  1088 endfun
       
  1089 
       
  1090 " ---------------------------------------------------------------------
       
  1091 " SetPosn: set cursor to given position on screen {{{2
       
  1092 "    srow,scol: -s-creen    row and column
       
  1093 "   Returns  1 : failed sanity check
       
  1094 "            0 : otherwise
       
  1095 fun! s:SetPosn(row,col)
       
  1096 "  call Dfunc("SetPosn(row=".a:row." col=".a:col.")")
       
  1097   " sanity checks
       
  1098   if a:row < 1
       
  1099 "   call Dret("SetPosn 1")
       
  1100    return 1
       
  1101   endif
       
  1102   if a:col < 1
       
  1103 "   call Dret("SetPosn 1")
       
  1104    return 1
       
  1105   endif
       
  1106 
       
  1107   exe "norm! ".a:row."G".a:col."\<Bar>"
       
  1108 
       
  1109 "  call Dret("SetPosn 0")
       
  1110   return 0
       
  1111 endfun
       
  1112 
       
  1113 " ---------------------------------------------------------------------
       
  1114 " IsBoundary: returns 0 if not on boundary, 1 if on boundary {{{2
       
  1115 "             The "boundary" also includes the fill character.
       
  1116 fun! s:IsBoundary(row,col)
       
  1117 "  call Dfunc("IsBoundary(row=".a:row." col=".a:col.")")
       
  1118 
       
  1119   let orow= line(".")
       
  1120   let ocol= virtcol(".")
       
  1121   exe "norm! ".a:row."G".a:col."\<Bar>"
       
  1122   norm! vy
       
  1123   let ret= @0 =~ s:bndry
       
  1124   if a:row != orow || a:col != ocol
       
  1125    exe "norm! ".orow."G".ocol."\<Bar>"
       
  1126   endif
       
  1127 
       
  1128 "  call Dret("IsBoundary ".ret)
       
  1129   return ret
       
  1130 endfun
       
  1131 
       
  1132 " ---------------------------------------------------------------------
       
  1133 " PutBlock: puts a register's contents into the text at the current {{{2
       
  1134 "           cursor location
       
  1135 "              replace= 0: Blanks are transparent
       
  1136 "                     = 1: Blanks copy over
       
  1137 "                     = 2: Erase all drawing characters
       
  1138 fun! s:PutBlock(block,replace)
       
  1139 "  call Dfunc("PutBlock(block<".a:block."> replace=".a:replace.")")
       
  1140   let keep_ve= &ve
       
  1141   set ve=
       
  1142   call s:SavePosn()
       
  1143   exe "let block  = @".a:block
       
  1144   let blocklen    = strlen(block)
       
  1145   let drawit_line = line('.')
       
  1146   let drawchars   = '['.escape(b:di_vert.b:di_horiz.b:di_plus.b:di_upright.b:di_upleft.b:di_cross,'\-').']'
       
  1147 
       
  1148   let iblock      = 0
       
  1149   while iblock < blocklen
       
  1150   	let chr= strpart(block,iblock,1)
       
  1151 
       
  1152 	if char2nr(chr) == 10
       
  1153 	 " handle newline
       
  1154 	 let drawit_line= drawit_line + 1
       
  1155     if b:drawit_col_{s:saveposn_count} == 0
       
  1156      exe "norm! ".drawit_line."G0"
       
  1157     else
       
  1158      exe "norm! ".drawit_line."G0".b:drawit_col_{s:saveposn_count}."l"
       
  1159     endif
       
  1160 
       
  1161 	elseif a:replace == 2
       
  1162 	 " replace all drawing characters with blanks
       
  1163 	 if match(chr,drawchars) != -1
       
  1164 	  norm! r l
       
  1165 	 else
       
  1166 	  norm! l
       
  1167 	 endif
       
  1168 
       
  1169 	elseif chr == ' ' && a:replace == 0
       
  1170 	 " allow blanks to be transparent
       
  1171 	 norm! l
       
  1172 
       
  1173 	else
       
  1174 	 " usual replace character
       
  1175 	 exe "norm! r".chr."l"
       
  1176 	endif
       
  1177   	let iblock = iblock + 1
       
  1178   endwhile
       
  1179   call s:RestorePosn()
       
  1180 
       
  1181   let &ve= keep_ve
       
  1182 "  call Dret("PutBlock")
       
  1183 endfun
       
  1184 
       
  1185 " =====================================================================
       
  1186 "  Drawit Functions: (by Sylvain Viart) {{{1
       
  1187 " =====================================================================
       
  1188 
       
  1189 " Spacer: fill end of line with space until textwidth. {{{2
       
  1190 fun! s:Spacer(debut, fin)
       
  1191 "  call Dfunc("Spacer(debut<".a:debut."> fin<".a:fin.">)")
       
  1192 
       
  1193   let l   = a:debut
       
  1194   let max = &textwidth
       
  1195   if max <= 0
       
  1196      let max= &columns
       
  1197   endif
       
  1198   while l <= a:fin
       
  1199      let content = getline(l)
       
  1200      let long    = strlen(content)
       
  1201      let i       = long
       
  1202      let space   = ''
       
  1203      while i < max
       
  1204         let space = space . ' '
       
  1205         let i     = i + 1
       
  1206      endw
       
  1207      call setline(l, content.space)
       
  1208      let l = l + 1
       
  1209   endw
       
  1210 
       
  1211 "  call Dret("Spacer")
       
  1212 endf
       
  1213 
       
  1214 " ---------------------------------------------------------------------
       
  1215 " Holer: {{{2
       
  1216 fun! s:Holer()
       
  1217 "  call Dfunc("Holer()")
       
  1218 
       
  1219   let nb = input("how many lines under the cursor? ")
       
  1220   exe "norm ".nb."o\e"
       
  1221   let fin = line('.')
       
  1222   call s:Spacer(fin-nb+1, fin)
       
  1223   exe "norm ".(nb-1)."k"
       
  1224   let b:drawit_holer_used= 1
       
  1225 
       
  1226 "  call Dret("Holer")
       
  1227 endf
       
  1228 
       
  1229 " ---------------------------------------------------------------------
       
  1230 " Box: {{{2
       
  1231 fun! s:Box(x0, y0, x1, y1)
       
  1232 "  call Dfunc("Box(xy0[".a:x0.",".a:y0." xy1[".a:x1.",".a:y1."])")
       
  1233    " loop each line
       
  1234    let l = a:y0
       
  1235    while l <= a:y1
       
  1236       let c = a:x0
       
  1237       while c <= a:x1
       
  1238          if l == a:y0 || l == a:y1
       
  1239             let remp = '-'
       
  1240             if c == a:x0 || c == a:x1
       
  1241                let remp = '+'
       
  1242             endif
       
  1243          else
       
  1244             let remp = '|'
       
  1245             if c != a:x0 && c != a:x1
       
  1246                let remp = '.'
       
  1247             endif
       
  1248          endif
       
  1249 
       
  1250          if remp != '.'
       
  1251             call s:SetCharAt(remp, c, l)
       
  1252          endif
       
  1253          let c  = c + 1
       
  1254       endw
       
  1255       let l = l + 1
       
  1256    endw
       
  1257 
       
  1258 "  call Dret("Box")
       
  1259 endf
       
  1260 
       
  1261 " ---------------------------------------------------------------------
       
  1262 " SetCharAt: set the character at the specified position (must exist) {{{2
       
  1263 fun! s:SetCharAt(char, x, y)
       
  1264 "  call Dfunc("SetCharAt(char<".a:char."> xy[".a:x.",".a:y."])")
       
  1265 
       
  1266   let content = getline(a:y)
       
  1267   let long    = strlen(content)
       
  1268   let deb     = strpart(content, 0, a:x - 1)
       
  1269   let fin     = strpart(content, a:x, long)
       
  1270   call setline(a:y, deb.a:char.fin)
       
  1271 
       
  1272 "  call Dret("SetCharAt")
       
  1273 endf
       
  1274 
       
  1275 " ---------------------------------------------------------------------
       
  1276 " Bresenham line-drawing algorithm {{{2
       
  1277 " taken from :
       
  1278 " http://www.graphics.lcs.mit.edu/~mcmillan/comp136/Lecture6/Lines.html
       
  1279 fun! s:DrawLine(x0, y0, x1, y1, horiz)
       
  1280 "  call Dfunc("DrawLine(xy0[".a:x0.",".a:y0."] xy1[".a:x1.",".a:y1."] horiz=".a:horiz.")")
       
  1281 
       
  1282   if ( a:x0 < a:x1 && a:y0 > a:y1 ) || ( a:x0 > a:x1 && a:y0 > a:y1 )
       
  1283     " swap direction
       
  1284     let x0   = a:x1
       
  1285     let y0   = a:y1
       
  1286     let x1   = a:x0
       
  1287     let y1   = a:y0
       
  1288   else
       
  1289     let x0 = a:x0
       
  1290     let y0 = a:y0
       
  1291     let x1 = a:x1
       
  1292     let y1 = a:y1
       
  1293   endif
       
  1294   let dy = y1 - y0
       
  1295   let dx = x1 - x0
       
  1296 
       
  1297   if dy < 0
       
  1298      let dy    = -dy
       
  1299      let stepy = -1
       
  1300   else
       
  1301      let stepy = 1
       
  1302   endif
       
  1303 
       
  1304   if dx < 0
       
  1305      let dx    = -dx
       
  1306      let stepx = -1
       
  1307   else
       
  1308      let stepx = 1
       
  1309   endif
       
  1310 
       
  1311   let dy = 2*dy
       
  1312   let dx = 2*dx
       
  1313 
       
  1314   if dx > dy
       
  1315      " move under x
       
  1316      let char = a:horiz
       
  1317      call s:SetCharAt(char, x0, y0)
       
  1318      let fraction = dy - (dx / 2)  " same as 2*dy - dx
       
  1319      while x0 != x1
       
  1320         let char = a:horiz
       
  1321         if fraction >= 0
       
  1322            if stepx > 0
       
  1323               let char = '\'
       
  1324            else
       
  1325               let char = '/'
       
  1326            endif
       
  1327            let y0 = y0 + stepy
       
  1328            let fraction = fraction - dx    " same as fraction -= 2*dx
       
  1329         endif
       
  1330         let x0 = x0 + stepx
       
  1331         let fraction = fraction + dy	" same as fraction = fraction - 2*dy
       
  1332         call s:SetCharAt(char, x0, y0)
       
  1333      endw
       
  1334   else
       
  1335      " move under y
       
  1336      let char = '|'
       
  1337      call s:SetCharAt(char, x0, y0)
       
  1338      let fraction = dx - (dy / 2)
       
  1339      while y0 != y1
       
  1340         let char = '|'
       
  1341         if fraction >= 0
       
  1342            if stepy > 0 || stepx < 0
       
  1343               let char = '\'
       
  1344            else
       
  1345               let char = '/'
       
  1346            endif
       
  1347            let x0 = x0 + stepx
       
  1348            let fraction = fraction - dy
       
  1349         endif
       
  1350         let y0 = y0 + stepy
       
  1351         let fraction = fraction + dx
       
  1352         call s:SetCharAt(char, x0, y0)
       
  1353      endw
       
  1354   endif
       
  1355 
       
  1356 "  call Dret("DrawLine")
       
  1357 endf
       
  1358 
       
  1359 " ---------------------------------------------------------------------
       
  1360 " Arrow: {{{2
       
  1361 fun! s:Arrow(x0, y0, x1, y1)
       
  1362 "  call Dfunc("Arrow(xy0[".a:x0.",".a:y0."] xy1[".a:x1.",".a:y1."])")
       
  1363 
       
  1364   call s:DrawLine(a:x0, a:y0, a:x1, a:y1,'-')
       
  1365   let dy = a:y1 - a:y0
       
  1366   let dx = a:x1 - a:x0
       
  1367   if s:Abs(dx) > <SID>Abs(dy)
       
  1368      " move x
       
  1369      if dx > 0
       
  1370         call s:SetCharAt('>', a:x1, a:y1)
       
  1371      else
       
  1372         call s:SetCharAt('<', a:x1, a:y1)
       
  1373      endif
       
  1374   else
       
  1375      " move y
       
  1376      if dy > 0
       
  1377         call s:SetCharAt('v', a:x1, a:y1)
       
  1378      else
       
  1379         call s:SetCharAt('^', a:x1, a:y1)
       
  1380      endif
       
  1381   endif
       
  1382 
       
  1383 "  call Dret("Arrow")
       
  1384 endf
       
  1385 
       
  1386 " ---------------------------------------------------------------------
       
  1387 " Abs: return absolute value {{{2
       
  1388 fun! s:Abs(val)
       
  1389   if a:val < 0
       
  1390    return - a:val
       
  1391   else
       
  1392    return a:val
       
  1393   endif
       
  1394 endf
       
  1395 
       
  1396 " ---------------------------------------------------------------------
       
  1397 " Call_corner: call the specified function with the corner position of {{{2
       
  1398 " the current visual selection.
       
  1399 fun! s:Call_corner(func_name)
       
  1400 "  call Dfunc("Call_corner(func_name<".a:func_name.">)")
       
  1401 
       
  1402   let xdep = b:xmouse_start
       
  1403   let ydep = b:ymouse_start
       
  1404   let x0   = col("'<")
       
  1405   let y0   = line("'<")
       
  1406   let x1   = col("'>")
       
  1407   let y1   = line("'>")
       
  1408 
       
  1409   if x1 == xdep && y1 ==ydep
       
  1410      let x1 = x0
       
  1411      let y1 = y0
       
  1412      let x0 = xdep
       
  1413      let y0 = ydep
       
  1414   endif
       
  1415 
       
  1416 "  call Decho("exe call s:".a:func_name."(".x0.','.y0.','.x1.','.y1.")")
       
  1417   exe "call s:".a:func_name."(".x0.','.y0.','.x1.','.y1.")"
       
  1418   let b:xmouse_start= 0
       
  1419   let b:ymouse_start= 0
       
  1420 
       
  1421 "  call Dret("Call_corner")
       
  1422 endf
       
  1423 
       
  1424 " ---------------------------------------------------------------------
       
  1425 " DrawPlainLine: {{{2
       
  1426 fun! s:DrawPlainLine(x0,y0,x1,y1)
       
  1427 "  call Dfunc("DrawPlainLine(xy0[".a:x0.",".a:y0."] xy1[".a:x1.",".a:y1."])")
       
  1428 
       
  1429 "   call Decho("exe call s:DrawLine(".a:x0.','.a:y0.','.a:x1.','.a:y1.',"_")')
       
  1430    exe "call s:DrawLine(".a:x0.','.a:y0.','.a:x1.','.a:y1.',"_")'
       
  1431 
       
  1432 "  call Dret("DrawPlainLine")
       
  1433 endf
       
  1434 
       
  1435 " =====================================================================
       
  1436 "  Mouse Functions: {{{1
       
  1437 " =====================================================================
       
  1438 
       
  1439 " LeftStart: Read visual drag mapping {{{2
       
  1440 " The visual start point is saved in b:xmouse_start and b:ymouse_start
       
  1441 fun! s:LeftStart()
       
  1442 "  call Decho("LeftStart()")
       
  1443   let b:xmouse_start = col('.')
       
  1444   let b:ymouse_start = line('.')
       
  1445   vnoremap <silent> <leftrelease> <leftrelease>:<c-u>call <SID>LeftRelease()<cr>
       
  1446 "  call Decho("LeftStart()")
       
  1447 endf!
       
  1448 
       
  1449 " ---------------------------------------------------------------------
       
  1450 " LeftRelease: {{{2
       
  1451 fun! s:LeftRelease()
       
  1452 "  call Dfunc("LeftRelease()")
       
  1453   vunmap <leftrelease>
       
  1454   norm! gv
       
  1455 "  call Dret("LeftRelease")
       
  1456 endf
       
  1457 
       
  1458 " ---------------------------------------------------------------------
       
  1459 " SLeftStart: begin drawing with a brush {{{2
       
  1460 fun! s:SLeftStart()
       
  1461   if !exists("b:drawit_brush")
       
  1462    let b:drawit_brush= "a"
       
  1463   endif
       
  1464 "  call Dfunc("SLeftStart() brush=".b:drawit_brush)
       
  1465   noremap <silent> <s-leftdrag>    <leftmouse>:<c-u>call <SID>SLeftDrag()<cr>
       
  1466   noremap <silent> <s-leftrelease> <leftmouse>:<c-u>call <SID>SLeftRelease()<cr>
       
  1467 "  call Dret("SLeftStart")
       
  1468 endfun
       
  1469 
       
  1470 " ---------------------------------------------------------------------
       
  1471 " SLeftDrag: {{{2
       
  1472 fun! s:SLeftDrag()
       
  1473 "  call Dfunc("SLeftDrag()")
       
  1474   call s:SavePosn()
       
  1475   call s:PutBlock(b:drawit_brush,0)
       
  1476   call s:RestorePosn()
       
  1477 "  call Dret("SLeftDrag")
       
  1478 endfun
       
  1479 
       
  1480 " ---------------------------------------------------------------------
       
  1481 " SLeftRelease: {{{2
       
  1482 fun! s:SLeftRelease()
       
  1483 "  call Dfunc("SLeftRelease()")
       
  1484   call s:SLeftDrag()
       
  1485   nunmap <s-leftdrag>
       
  1486   nunmap <s-leftrelease>
       
  1487 "  call Dret("SLeftRelease")
       
  1488 endfun
       
  1489 
       
  1490 " ---------------------------------------------------------------------
       
  1491 " DrawIt#SetBrush: {{{2
       
  1492 fun! DrawIt#SetBrush(brush) range
       
  1493 "  call Dfunc("DrawIt#SetBrush(brush<".a:brush.">)")
       
  1494   let b:drawit_brush= a:brush
       
  1495 "  call Decho("visualmode<".visualmode()."> range[".a:firstline.",".a:lastline."] visrange[".line("'<").",".line("'>")."]")
       
  1496   if visualmode() == "\<c-v>" && ((a:firstline == line("'>") && a:lastline == line("'<")) || (a:firstline == line("'<") && a:lastline == line("'>")))
       
  1497    " last visual mode was visual block mode, and
       
  1498    " either [firstline,lastline] == ['<,'>] or ['>,'<]
       
  1499    " Assuming that SetBrush called from a visual-block selection!
       
  1500    " Yank visual block into selected register (brush)
       
  1501 "   call Decho("yanking visual block into register ".b:drawit_brush)
       
  1502    exe 'norm! gv"'.b:drawit_brush.'y'
       
  1503   endif
       
  1504 "  call Dret("DrawIt#SetBrush : b:drawit_brush=".b:drawit_brush)
       
  1505 endfun
       
  1506 
       
  1507 " ------------------------------------------------------------------------
       
  1508 " Modelines: {{{1
       
  1509 " vim: fdm=marker
       
  1510 let &cpo= s:keepcpo
       
  1511 unlet s:keepcpo