" fakeclip - pseude clipboard register for non-GUI version of Vim
" Version: 0.2.10
" Copyright (C) 2007-2012 Kana Natsuno
" License: So-called MIT/X license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be included
" in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
" Prologue "{{{1
if exists('g:loaded_fakeclip')
finish
endif
" Key Mappings "{{{1
" Interface key mappings "{{{2
nnoremap (fakeclip-y)
\ :set operatorfunc=fakeclip#clipboard_yankg@
vnoremap (fakeclip-y)
\ :call fakeclip#yank('clipboard', visualmode())
nnoremap (fakeclip-Y)
\ :call fakeclip#yank_Y('clipboard')
vnoremap (fakeclip-Y)
\ :call fakeclip#yank('clipboard', 'V')
nnoremap (fakeclip-p)
\ :call fakeclip#put('clipboard', '', 'p')
nnoremap (fakeclip-P)
\ :call fakeclip#put('clipboard', '', 'P')
nnoremap (fakeclip-gp)
\ :call fakeclip#put('clipboard', '', 'gp')
nnoremap (fakeclip-gP)
\ :call fakeclip#put('clipboard', '', 'gP')
nnoremap (fakeclip-]p)
\ :call fakeclip#put('clipboard', '', ']p')
nnoremap (fakeclip-]P)
\ :call fakeclip#put('clipboard', '', ']P')
nnoremap (fakeclip-[p)
\ :call fakeclip#put('clipboard', '', '[p')
nnoremap (fakeclip-[P)
\ :call fakeclip#put('clipboard', '', '[P')
vnoremap (fakeclip-p)
\ :call fakeclip#put('clipboard', visualmode(), 'p')
vnoremap (fakeclip-P)
\ :call fakeclip#put('clipboard', visualmode(), 'P')
vnoremap (fakeclip-gp)
\ :call fakeclip#put('clipboard', visualmode(), 'gp')
vnoremap (fakeclip-gP)
\ :call fakeclip#put('clipboard', visualmode(), 'gP')
vnoremap (fakeclip-]p)
\ :call fakeclip#put('clipboard', visualmode(), ']p')
vnoremap (fakeclip-]P)
\ :call fakeclip#put('clipboard', visualmode(), ']P')
vnoremap (fakeclip-[p)
\ :call fakeclip#put('clipboard', visualmode(), '[p')
vnoremap (fakeclip-[P)
\ :call fakeclip#put('clipboard', visualmode(), '[P')
noremap! (fakeclip-insert)
\ =fakeclip#content('clipboard')
noremap! (fakeclip-insert-r)
\ =fakeclip#content('clipboard')
noremap! (fakeclip-insert-o)
\ =fakeclip#content('clipboard')
inoremap (fakeclip-insert-p)
\ =fakeclip#content('clipboard')
nnoremap (fakeclip-d)
\ :set operatorfunc=fakeclip#clipboard_deleteg@
vnoremap (fakeclip-d)
\ :call fakeclip#delete('clipboard', visualmode())
nnoremap (fakeclip-dd)
\ :set operatorfunc=fakeclip#clipboard_deleteg@g@
nnoremap (fakeclip-D)
\ :set operatorfunc=fakeclip#clipboard_deleteg@$
vnoremap (fakeclip-D)
\ :call fakeclip#delete('clipboard', 'V')
nnoremap (fakeclip-screen-y)
\ :set operatorfunc=fakeclip#pastebuffer_yankg@
vnoremap (fakeclip-screen-y)
\ :call fakeclip#yank('pastebuffer', visualmode())
nnoremap (fakeclip-screen-Y)
\ :call fakeclip#yank_Y('pastebuffer')
vnoremap (fakeclip-screen-Y)
\ :call fakeclip#yank('pastebuffer', 'V')
nnoremap (fakeclip-screen-p)
\ :call fakeclip#put('pastebuffer', '', 'p')
nnoremap (fakeclip-screen-P)
\ :call fakeclip#put('pastebuffer', '', 'P')
nnoremap (fakeclip-screen-gp)
\ :call fakeclip#put('pastebuffer', '', 'gp')
nnoremap (fakeclip-screen-gP)
\ :call fakeclip#put('pastebuffer', '', 'gP')
nnoremap (fakeclip-screen-]p)
\ :call fakeclip#put('pastebuffer', '', ']p')
nnoremap (fakeclip-screen-]P)
\ :call fakeclip#put('pastebuffer', '', ']P')
nnoremap (fakeclip-screen-[p)
\ :call fakeclip#put('pastebuffer', '', '[p')
nnoremap (fakeclip-screen-[P)
\ :call fakeclip#put('pastebuffer', '', '[P')
vnoremap (fakeclip-screen-p)
\ :call fakeclip#put('pastebuffer', visualmode(), 'p')
vnoremap (fakeclip-screen-P)
\ :call fakeclip#put('pastebuffer', visualmode(), 'P')
vnoremap (fakeclip-screen-gp)
\ :call fakeclip#put('pastebuffer', visualmode(), 'gp')
vnoremap (fakeclip-screen-gP)
\ :call fakeclip#put('pastebuffer', visualmode(), 'gP')
vnoremap (fakeclip-screen-]p)
\ :call fakeclip#put('pastebuffer', visualmode(), ']p')
vnoremap (fakeclip-screen-]P)
\ :call fakeclip#put('pastebuffer', visualmode(), ']P')
vnoremap (fakeclip-screen-[p)
\ :call fakeclip#put('pastebuffer', visualmode(), '[p')
vnoremap (fakeclip-screen-[P)
\ :call fakeclip#put('pastebuffer', visualmode(), '[P')
noremap! (fakeclip-screen-insert)
\ =fakeclip#content('pastebuffer')
noremap! (fakeclip-screen-insert-r)
\ =fakeclip#content('pastebuffer')
noremap! (fakeclip-screen-insert-o)
\ =fakeclip#content('pastebuffer')
inoremap (fakeclip-screen-insert-p)
\ =fakeclip#content('pastebuffer')
nnoremap (fakeclip-screen-d)
\ :set operatorfunc=fakeclip#pastebuffer_deleteg@
vnoremap (fakeclip-screen-d)
\ :call fakeclip#delete('pastebuffer', visualmode())
nnoremap (fakeclip-screen-dd)
\ :set operatorfunc=fakeclip#pastebuffer_deleteg@g@
nnoremap (fakeclip-screen-D)
\ :set operatorfunc=fakeclip#pastebuffer_deleteg@$
vnoremap (fakeclip-screen-D)
\ :call fakeclip#delete('pastebuffer', 'V')
" Default key mappings "{{{2
command! -bang -bar -nargs=0 FakeclipDefaultKeyMappings
\ call s:cmd_FakeclipDefaultKeyMappings(0)
function! s:cmd_FakeclipDefaultKeyMappings(banged_p)
let modifier = a:banged_p ? '' : ''
" Clipboard
if !has('clipboard')
for _ in ['+', '*']
execute 'silent! nmap '.modifier.' "'._.'y (fakeclip-y)'
execute 'silent! nmap '.modifier.' "'._.'Y (fakeclip-Y)'
execute 'silent! nmap '.modifier.' "'._.'yy (fakeclip-Y)'
execute 'silent! vmap '.modifier.' "'._.'y (fakeclip-y)'
execute 'silent! vmap '.modifier.' "'._.'Y (fakeclip-Y)'
execute 'silent! nmap '.modifier.' "'._.'p (fakeclip-p)'
execute 'silent! nmap '.modifier.' "'._.'P (fakeclip-P)'
execute 'silent! nmap '.modifier.' "'._.'gp (fakeclip-gp)'
execute 'silent! nmap '.modifier.' "'._.'gP (fakeclip-gP)'
execute 'silent! nmap '.modifier.' "'._.']p (fakeclip-]p)'
execute 'silent! nmap '.modifier.' "'._.']P (fakeclip-]P)'
execute 'silent! nmap '.modifier.' "'._.'[p (fakeclip-[p)'
execute 'silent! nmap '.modifier.' "'._.'[P (fakeclip-[P)'
execute 'silent! vmap '.modifier.' "'._.'p (fakeclip-p)'
execute 'silent! vmap '.modifier.' "'._.'P (fakeclip-P)'
execute 'silent! vmap '.modifier.' "'._.'gp (fakeclip-gp)'
execute 'silent! vmap '.modifier.' "'._.'gP (fakeclip-gP)'
execute 'silent! vmap '.modifier.' "'._.']p (fakeclip-]p)'
execute 'silent! vmap '.modifier.' "'._.']P (fakeclip-]P)'
execute 'silent! vmap '.modifier.' "'._.'[p (fakeclip-[p)'
execute 'silent! vmap '.modifier.' "'._.'[P (fakeclip-[P)'
execute 'silent! map! '.modifier.' '._.'