+++ /dev/null
-" These functions are used by the screenpaste plugin.
-" $Id: screenpaste.vim,v 1bdf402abcdd 2008-10-30 16:27 +0100 blacktrash $
-
-" Script Vars: characters to be escaped on cmdline {{{1
-" static:
-
-" dynamic:
-" these contain the current values for cmdline conversion, and,
-" at startup, are set to the values corresponding to 'noesc'
-" because for 'search' and 'sub' Screen_ClConfig is called with
-" the current value of screen_clmode everytime Screen_CPut is called
-" with the purpose to adapt to current setting of 'magic'
-let s:cl_esc = ''
-let s:cl_eol = '\\n'
-
-" Function: Screen_ClCfgComplete for cmdline-completion {{{1
-function! screenpaste#Screen_ClCfgComplete(A, L, P)
- return "search\nsub\nnoesc"
-endfunction
-
-" Function: Screen_ClConfig configures cmdline insertion {{{1
-" variables configured here and used by Screen_CPut function:
-" global:
-" g:screen_clmode cmdline behaviour
-" internal:
-" s:cl_eol eol-conversion
-" s:cl_esc character group pattern to be escaped
-" s:esc_info displays escaped characters
-" s:eol_info displays eol-conversion
-
-function! screenpaste#Screen_ClConfig(mod, msg)
- if a:mod !~# '^\%(s\%(earch\|ub\)\|noesc\)$'
- echohl WarningMsg
- echon "`" a:mod "': invalid value for screen_clmode\n"
- \ "use one of: search | sub | noesc"
- echohl None
- return ""
- endif
-
- " patterns and strings (for user info)
- let l:esc_search_ma = '][/\^$*.~'
- let l:esc_search_noma = ']/\^$'
- let l:esc_sub_ma = '/\~&'
- let l:esc_sub_noma = '/\'
- let l:info_search_ma = "] [ / \\ ^ $ ~ * . (magic)"
- let l:info_search_noma = "] / \\ ^ $ (nomagic)"
- let l:info_sub_ma = "/ \\ ~ & (magic)"
- let l:info_sub_noma = "/ \\ (nomagic)"
- " dict vars
- let l:cl_esc_dict = {
- \ "search": {0: l:esc_search_noma, 1: l:esc_search_ma},
- \ "sub": {0: l:esc_sub_noma, 1: l:esc_sub_ma },
- \ "noesc": {0: '', 1: '' }
- \ }
- let l:cl_info_dict = {
- \ "search": {0: l:info_search_noma, 1: l:info_search_ma},
- \ "sub" : {0: l:info_sub_noma, 1: l:info_sub_ma },
- \ "noesc" : {0: 'none', 1: 'none' }
- \ }
- let l:eol_conv_dict =
- \ {"search": '\\n', "sub": '\\r', "noesc": '\\n'}
- let l:eol_info_dict =
- \ {"search": '\n', "sub": '\r', "noesc": '\n'}
-
- let g:screen_clmode = a:mod
- let s:cl_esc = l:cl_esc_dict[g:screen_clmode][&magic]
- let s:esc_info = l:cl_info_dict[g:screen_clmode][&magic]
- let s:cl_eol = l:eol_conv_dict[g:screen_clmode]
- let s:eol_info = l:eol_info_dict[g:screen_clmode]
- if a:msg
- echon "set '" g:screen_clmode "' "
- \ "for Screen buffer insertion in cmdline:\n"
- \ "eol-conversion to literal " s:eol_info "\n"
- \ "escaped characters " s:esc_info
- endif
-endfunction
-" }}}1
-" ============================================================================
-" Function: Screen_Yank snatches current Screen buffer {{{1
-" Function: Screen_ReadBuf subroutine returns Screen buffer as text {{{2
-
-function! s:Screen_ReadBuf(screen_tmpfile)
- if !filereadable(a:screen_tmpfile)
- " wait in case screen is late in writing screen-exchange file
- execute "sleep" g:screen_wait
- endif
- try
- return join(readfile(a:screen_tmpfile, "b"), "\n")
- catch /^Vim\%((\a\+)\)\=:E484/
- " Screen buffer empty, no tmpfile created
- return ""
- endtry
-endfunction
-" }}}2
-
-function! screenpaste#Screen_Yank(...)
- let l:screen_tmpfile = tempname()
- call system(g:screen_executable." -X writebuf ".l:screen_tmpfile)
- if !a:0
- return <SID>Screen_ReadBuf(l:screen_tmpfile)
- else
- let l:screen_buf = <SID>Screen_ReadBuf(l:screen_tmpfile)
- if strlen(l:screen_buf)
- if strlen(a:1)
- call setreg(a:1, l:screen_buf)
- else
- call setreg(g:screen_register, l:screen_buf)
- endif
- return 1
- elseif g:screen_register =~ '\u'
- " do nothing
- return 1
- else
- echohl WarningMsg
- echo "Screen buffer is empty"
- echohl None
- return 0
- endif
- endif
-endfunction
-
-" Function: Screen_NPut pastes in normal mode {{{1
-function! screenpaste#Screen_NPut(p)
- if screenpaste#Screen_Yank(g:screen_register)
- execute 'normal! "'.g:screen_register.a:p
- endif
-endfunction
-
-" Function: Screen_IPut pastes in insert mode {{{1
-
-" Function: Screen_TwRestore subroutine restores 'paste' {{{2
-" helper function, only called right after Screen_IPut
-" because Screen_IPut must return result before
-" being able to restore paste its previous value
-function! screenpaste#Screen_TwRestore()
- let &paste = s:curr_paste
- return ""
-endfunction
-" }}}2
-
-function! screenpaste#Screen_IPut()
- let s:curr_paste = &paste
- let &paste = 1
- let l:screen_buf = screenpaste#Screen_Yank()
- return l:screen_buf
-endfunction
-
-" Function: Screen_VPut pastes in visual mode {{{1
-function! screenpaste#Screen_VPut(go)
- if screenpaste#Screen_Yank(g:screen_register)
- if g:screen_register =~ '["@]'
- " we have to use another register because
- " visual selection is deleted into unnamed register
- let l:store_reg = @z
- let @z = @"
- let g:screen_register = "z"
- endif
- execute 'normal! gv"'.g:screen_register.a:go.'p'
- if g:screen_visualselect
- execute "normal! `[".visualmode()."`]"
- endif
- if exists("l:store_reg")
- let g:screen_register = '"'
- let @0 = @z
- let @z = l:store_reg
- endif
- else
- " reset visual after showing message for 3 secs
- sleep 3
- execute "normal! gv"
- endif
-endfunction
-
-" Function: Screen_PutCommand is called from :ScreenPut {{{1
-function! screenpaste#Screen_PutCommand(line, bang, reg)
- if !strlen(a:reg)
- let l:reg = g:screen_register
- else
- let l:reg = a:reg
- endif
- if screenpaste#Screen_Yank(l:reg)
- if a:line
- execute a:line "put".a:bang l:reg
- else
- execute "put".a:bang l:reg
- endif
- endif
-endfunction
-
-" Function: Screen_CPut pastes in cmdline according to cmdtype {{{1
-function! screenpaste#Screen_CPut()
- " automatically adapt 'screen_clmode' to cmdtype if possible
- " or instant paste in case of :insert or :append
- let l:cmdtype = getcmdtype()
- if l:cmdtype == '-' && exists("$STY")
- " Screen call needed for :insert and :append commands in Screen_CPut
- " using slowpaste avoids need for manual redraw
- let l:screen_slowpaste =
- \ g:screen_executable." -X slowpaste 10;".
- \ g:screen_executable." -X paste .;".
- \ g:screen_executable." -X slowpaste 0"
- " :insert, :append inside Screen session
- call system(l:screen_slowpaste)
- return ""
- endif
- " store current cmdline behaviour
- let l:save_clmode = g:screen_clmode
- " detect cmdtype if not 'noesc'
- if g:screen_clmode != "noesc"
- if l:cmdtype =~ '[/?]'
- " search: always call config to adapt to 'magic'
- call screenpaste#Screen_ClConfig("search", 0)
- elseif l:cmdtype =~ '[@-]'
- " input() or :insert, :append outside Screen session
- call screenpaste#Screen_ClConfig("noesc", 0)
- else
- " search, sub: always call config to adapt to 'magic'
- call screenpaste#Screen_ClConfig(g:screen_clmode, 0)
- endif
- endif
- " escape chars in Screen buffer for cmdline
- let l:screen_buf = screenpaste#Screen_Yank()
- if strlen(s:cl_esc)
- let l:screen_buf = escape(l:screen_buf, s:cl_esc)
- endif
- let l:screen_buf = substitute(l:screen_buf, "\<C-J>", s:cl_eol, 'g')
- " restore global 'screen_clmode' if changed
- if l:save_clmode != g:screen_clmode
- call screenpaste#Screen_ClConfig(l:save_clmode, 0)
- endif
- return l:screen_buf
-endfunction
-" }}}1
-" EOF vim600: set foldmethod=marker:
+++ /dev/null
-*screenpaste.txt* Paste/insert GNU Screen buffer in (almost) any mode v5.92
-
-$Id: screenpaste.txt,v 8624db9970aa 2008-11-08 21:33 +0100 blacktrash $
-
-For instructions on installing this file, type
- :help add-local-help
-inside Vim.
-
-Author: Christian Ebert <blacktrash@gmx.net>
-
-
- SCREENPASTE REFERENCE MANUAL~
-
-*screenpaste* *screenpaste.vim*
-
-==============================================================================
-
-1. Contents *screenpaste-toc*
-
- Screen Paste Plugin |screenpaste-intro|
- Installation |screenpaste-install|
- Usage |screenpaste-usage|
- Options |screenpaste-options|
- Changing Mappings |screenpaste-mappings|
- Commands |screenpaste-commands|
- Bugs and Limitations |screenpaste-bugs|
-
-==============================================================================
-
-2. Screen Paste Plugin *screenpaste-intro*
-
-The terminal window manager Screen http://www.gnu.org/software/screen
-offers the capability to copy and paste between windows.
-
-In principle you can just do "C-a ]" (default) to paste the current Screen
-buffer into a vim buffer. However this gives unexpected results when 'paste'
-is not set or in Vim's command-line.
-
-This script provides mappings and commands to get correct results.
-
-As an additional feature the current Screen buffer is available in any Vim
-instance, even those /outside/ the current Screen session.
-
-When pasting into command-line many commands are autodetected and the
-behaviour adapts automatically (|getcmdtype()|).
-
-The underlying mechanism of screenpaste consists in getting hold of the
-current Screen buffer via calling to Screen to write it to a temporary file.
-At this point Vim takes over, reads the contents of the file, and puts them to
-use either directly (in Insert, Replace or Command-line mode) or, in Normal
-and Visual mode, by writing to a register and, most often, putting the
-contents of the register into the Vim buffer. Which is why the default
-keybindings mimic |p|, |P|, |gp|, |gP|, with the |mapleader| prepended, as
-well as |:ScreenPut| and |:ScreenYank| behave almost like |:put| and |:yank|
-respectively.
-
-==============================================================================
-
-3. Installation *screenpaste-install*
-
-The screenpaste plugin comprises three files: screenpastePlugin.vim,
-screenpaste.vim and screenpaste.txt (this file). To install the plugin, copy
-screenpastePlugin.vim into a 'plugin' directory in your runtime path and
-screenpaste.vim into the corresponding 'autoload' directory. See
-|add-global-plugin| and |'runtimepath'|.
-
-This help file goes into a 'doc' directory in the runtime path. Then execute
-|:helptags|, specifying the full path of the 'doc' directory. See
-|add-local-help| for details.
-
-The GNU Screen executable has to be in $PATH. Otherwise screenpaste bails out
-giving an error message.
-
-==============================================================================
-
-4. Usage *screenpaste-usage*
-
-Think of the current Screen buffer as of a register at your disposal via the
-|screenpaste| mappings and commands.
-
- *screenpaste-put*
-When you type the plugin's Ex command
->
- :ScreenPut
-
-this works like executing |:put| with the current Screen buffer as register.
-It puts the text after the current line. Like |:put| it accepts a prepended
-number as parameter designating the target line as well as an appended bang
-to put the text before the indicated line and an optional register argument
-which defaults to |screen_register| when omitted.
-
-|:ScreenPut| differs from |:put| as the register is not only written into the
-buffer but filled with the current Screen buffer beforehand.
-
- *screenpaste-yank*
-If you want to just get hold of the current Screen buffer for further
-processing, type
->
- :ScreenYank
->
-and the Screen buffer is at your disposal in the |screen_register|. Similar
-to |:yank| you can also execute the command with an explicit register
-argument.
-
-Note: Screen's copy mechanism discards spaces at the end and the beginning of
-a selection in case there are printable characters in the same line. In Vim
-terms one could consider this like selecting 'exclusive', and to get a
-|linewise| "yank" the selection has to span visually more than one line, the
-newline at the end of a visually selected single line is not included.
-
-
-All other commands configure the treatment of the current Screen buffer when
-it is pasted into the command-line. Please refer to |screen_clmode| and
-|screenpaste-commands| for further information.
-
-
-Mappings:~
-
-In |Insert|, |Replace|, and |Command-line| modes (by default) simply type: >
- \p
-to paste the current Screen buffer. In these modes the |screen_register| is
-not changed.
-
-Note: mappings are ignored in Insert mode while |'paste'| is set. But in that
-case Screen's "paste" command (bound to "C-a]" by default) works just fine and
-there's no need to work around this via |'pastetoggle'|.
-
-
-The plugin's mappings for |Normal| and |Visual| mode emulate the non-Ex
-commands |p|, |P|, |gp|, and |gP|: They put the text of the current Screen
-buffer after or before the cursor, or replace the visual selection with it,
-just as if the unnamed register would contain the current Screen buffer (see
-|screen_register|).
-
-If the Screen buffer is empty they do nothing, the registers stay untouched,
-and only a corresponding message is displayed in the menu.
-
-Note however that the optional initial [count] argument to the original non-Ex
-commands will not work with these mappings (|screenpaste-bugs|).
-
-In their default state the |Normal| and |Visual| mode mappings consist of the
-same letters as the corresponding non-Ex commands with the |mapleader|
-prepended: >
-
- <Leader>p
- <Leader>P (not in Visual)
- <Leader>gp
- <Leader>gP (not in Visual)
-
-For simplicity we use the default |screenpaste-mappings| and the default
-|<Leader>| "\" in the following description.
-
- *screenpaste-p*
-\p Put current Screen buffer after the cursor.
-
- *screenpaste-P*
-\P Put current Screen buffer before the cursor.
- Not available in Visual mode.
-
- *screenpaste-gp*
-\gp Like "\p" but leave the cursor after the pasted text.
-
- *screenpaste-gP*
-\gP Like "\P" but leave the cursor after the pasted text.
- Not available in Visual mode.
-
-In |Visual| mode we do not need "\P" and "\gP" as "\p" and "\P" have the same
-effect of replacing the Visual selected text with the current Screen buffer.
-
-
-To summarize, supposing the default |<Leader>| "\" and the default
-|screenpaste-mappings| you can type:
->
- \p in Normal mode to put Screen buffer after cursor
- \gp in Normal mode to put Screen buffer after cursor and leave cursor
- after the end of new text
- \P in Normal mode to put Screen buffer before cursor
- \gP in Normal mode to put Screen buffer before cursor and leave cursor
- after the end of new text
- \p in Visual mode to replace visual selection with Screen buffer
- \gp in Visual mode to put Screen buffer after cursor and leave cursor
- after the end of new text
- \p in Insert and Replace mode to paste Screen buffer
- \p in Command-line-mode to put Screen buffer in command line
-
-==============================================================================
-
-5. Options *screenpaste-options*
-
-g:loaded_screenpaste *loaded_screenpaste*
-
- This option normally is set by screenpaste to avoid loading the script
- more than once. But you can use it to get the current script version: >
- :echo loaded_screenpaste
-<
- If you want to disable screenpaste, put the following line in your
- |vimrc|: >
- let g:loaded_screenpaste = 1
-
-g:screen_executable *screen_executable*
-
-Type String
-Default Value 'screen'
-
- Set this option if the name of your GNU Screen executable differs from
- "screen", or if you like to specify it's full path: >
- let g:screen_executable = "/usr/local/bin/screen"
-
-g:screen_wait *screen_wait*
-
-Type String or Number
-Valid Values See |:sleep|
-Default Value '333m'
-
- How long Vim should wait for Screen to write its exchange file. If
- you get messages that the Screen buffer is empty even though you know
- that it actually is not, bump up this setting.
-
-g:screen_visualselect *screen_visualselect*
-Type Boolean
-Default Value 0
-
- If set to 1 and in Visual mode the text from the Screen buffer is
- visually selected after the put operation.
-
-g:screen_register *screen_register*
-
-Type String or Number
-Valid Values "a-z0-9A-Z
-Default Value '"'
-
- The non-Ex put "commands" (mappings) act in a twofold operation when
- executed in Normal or Visual mode: they yank the Screen buffer into a
- register in the background, and then put the register into the buffer
- or command-line. This variable controls the register that is used for
- the first part of the operation. It defaults to the unnamed register
- "" (|quotequote|).
-
- Normally you should be fine with the default setting. But if you
- prefer to reserve a register of your choice for the Screen buffer you
- can do so with this option. Besides the default "", you may choose
- any named (|quote_alpha|) or numbered (|quote_number|) register.
- Consult |registers| about their behaviour.
-
- For a one time operation with a special register the use of
- |ScreenPut| ex-command and its register argument is recommended.
-
- Note: Specifying an uppercase letter means that the contents of the
- Screen buffer will be appended to the register named with the
- corresponding lowercase character (|quote_alpha|).
-
-g:screen_clmode *screen_clmode*
-
-Type String
-Valid Values 'search', 'sub', 'noesc'
-Default Value 'search'
-
- This setting controls how the Screen buffer is treated when pasted in
- the command line.
-
- You can change the setting at startup in your |vimrc|: >
- let g:screen_clmode = "sub"
-<
- To change its value in a vim session you might want to use one of the
- |:ScreenCmdlineConf|, |:ScreenSearch|, |:ScreenSub|, |:ScreenNoEsc|
- commands as they also give a short informative message on how the mode
- of your choice will act, and prevent you from setting an invalid value.
-
- Information on the current value and the resulting behaviour is also
- available via the |:ScreenCmdlineInfo| command.
-
-Modes and their behaviour:
- *screenpaste-search*
-'search' ~
- Converts end-of-line to literal '\n'.
- Escapes characters according to the current setting of 'magic':
- magic: [ ] / \ ^ * . ~ $
- nomagic: ] / \ ^ $
-
- Use this mode to search for occurrences of current Screen buffer.
- Example as typed using default mapleader: >
- :ScreenSearch
- :%s/\p/repl/g
-< If the current Screen buffer is `[hello world.]' and 'magic' is set,
- the above becomes: >
- :%s/\[hello world\.\]/repl/g
-< *screenpaste-sub*
-'sub' ~
- Converts end-of-line to literal '\r'.
- Escapes characters according to the current setting of 'magic':
- magic: / \ ~ &
- nomagic: / \
-
- Use this mode to substitute a pattern with current Screen buffer.
- Example as typed using default mapleader: >
- :ScreenSub
- :%s/pattern/\p/g
-< If the current Screen buffer is `http://www.vim.org', the above
- becomes: >
- :%s/pattern/http:\/\/www.vim.org/g
-< *screenpaste-noesc*
-'noesc' ~
- Converts end-of-line to literal '\n'.
-
- Use this mode to paste current Screen buffer literally into command
- line.
-
- |/|, |?|, |input()|, |:insert|, and |:append| commands are
- autodetected when not in 'noesc' |screen_clmode|. This means that even
- when you are in 'sub' mode you can type: >
- /\p
-< and this becomes (using above example for 'search'): >
- /\[hello world\.\]
-<
- Note: If you paste a Screen buffer containing newlines while in an
- |:insert| or |:append| but outside a running Screen session the
- newlines are escaped because we cannot call Screen's paste mechanism
- without clobbering a parallel Screen session, and Vim would insert
- <Nul> characters instead (see |NL-used-for-Nul|).
-
-==============================================================================
-
-6. Changing Mappings *screenpaste-mappings*
- *ScreenpastePut*
- *ScreenpasteGPut*
- *ScreenpastePutBefore*
- *ScreenpasteGPutBefore*
-
-The right-hand-side |{rhs}| mappings provided by this plugin and the modes in
-which to apply them are: >
-
- <Plug>ScreenpastePut Normal, Visual, Insert, Command-line
- <Plug>ScreenpasteGPut Normal, Visual
- <Plug>ScreenpastePutBefore Normal
- <Plug>ScreenpasteGPutBefore Normal
-<
-Use these to customize the default mappings <Leader>p, <Leader>gp, <Leader>P,
-and <Leader>gP to your taste (see |using-<Plug>| and |:map-modes|).
-
-The default mappings would look like this in a |vimrc|:
-
-map <Leader>p <Plug>ScreenpastePut " Normal, Visual mode
-map! <Leader>p <Plug>ScreenpastePut " Insert, Command-line mode
-map <Leader>gp <Plug>ScreenpasteGPut " Normal, Visual mode
-nmap <Leader>P <Plug>ScreenpastePutBefore " Normal mode
-nmap <Leader>gP <Plug>ScreenpasteGPutBefore " Normal mode
-
-You can tweak them by changing their left-hand-side |{lhs}|.
-
-Normal (put after cursor) and Visual mode:
- default
-:map {lhs} <Plug>ScreenpastePut \p
-:map {lhs} <Plug>ScreenpasteGPut \gp
-
- Vimrc example: >
- map <Leader>P <Plug>ScreenpastePut
-
-Normal mode (put before cursor):
-
-:nmap {lhs} <Plug>ScreenpastePutBefore \P
-:nmap {lhs} <Plug>ScreenpasteGPutBefore \gP
-
- Vimrc example: >
- nmap <Leader>I <Plug>ScreenpastePutBefore
-
-Insert and Command-line mode:
-
-:map! {lhs} <Plug>ScreenpastePut \p
-
- Vimrc example, to avoid character mappings when inserting: >
- map! <F7> <Plug>ScreenpastePut
-
-==============================================================================
-
-7. Commands *screenpaste-commands*
-
- *:ScreenYank*
-:ScreenYank [x] Yank current Screen buffer into register [x] (default
- |screen_register|).
-
- *:ScreenPut*
-:[line]ScreenPut [x] Put the text from current Screen buffer after [line]
- (default current line) using register [x] (default
- |screen_register|).
-
- You can use this command for instance to append the contents of the
- Screen buffer to a named register and then paste in one go: >
- :3 ScreenPut A
-< puts the contents of register "a and the Screen buffer after line 3.
-
-:[line]ScreenPut! [x] Put the text from current Screen buffer before [line]
- (default current line) using register [x] (default
- |screen_register|).
-
- *:ScreenCmdlineConf*
-:ScreenCmdlineConf {mode}
- Tell screenpaste to convert the current Screen
- buffer in command-line-mode according to {mode}.
- Takes one argument of: "search", "sub", "noesc" (w/o
- quotes).
- Changes |screen_clmode| accordingly.
- Example: >
- :ScreenCmdlineConf noesc
-<
- *:ScreenCmdlineInfo*
-:ScreenComdlineInfo Display information on current command-line-mode
- behaviour, ie. current |screen_clmode| and what it
- does.
-
- *:ScreenSearch*
-:ScreenSearch Set |screen_clmode| to 'search'.
- Equivalent to: >
- :ScreenCmdlineConf search
-<
- *:ScreenSub*
-:ScreenSub Set |screen_clmode| to 'sub'.
- Equivalent to: >
- :ScreenCmdlineConf sub
-<
- *:ScreenNoEsc*
-:ScreenNoEsc Set |screen_clmode| to 'noesc'.
- Equivalent to: >
- :ScreenCmdlineConf noesc
-
-==============================================================================
-
-8. Bugs and Limitations *screenpaste-bugs*
-
-Found no way (yet?) to make optional initial [count] argument work with
-(Normal mode) mappings.
-
-Screen's copy mechanism treats spaces (including newlines) at the beginning or
-the end of a selection in a different manner than Vim's visual yank does.
-
-Screen expands tabs, expect incorrect results if the Screen buffer contains
-tabs.
-
-==============================================================================
-
- vim:tw=78:ts=8:ft=help:norl:
+++ /dev/null
-" File: screenpaste.vim
-" Description: pastes/inserts current GNU Screen buffer in (almost) any mode
-" Version: 7.0
-" Mercurial: $Id: screenpastePlugin.vim,v c90c865d65f4 2008-11-15 00:10 +0100 blacktrash $
-" Author: Christian Ebert <blacktrash@gmx.net>
-" URL: http://www.vim.org/script.php?script_id=1512
-" Requirements: GNU Screen must be in $PATH
-" Documentation: in separate file, screenpaste.txt
-"
-" GetLatestVimScripts: 1512 1 :AutoInstall: screenpaste.zip
-
-if exists("g:loaded_screenpaste") || &cp
- finish
-endif
-let g:loaded_screenpaste = "7.0"
-
-" Init: store 'compatible' settings {{{1
-let s:save_cpo = &cpo
-set cpo&vim
-
-" Run Checks: for Vim version, system() and Screen executable {{{1
-function! s:Screen_CleanUp(msg) " {{{2
- echohl WarningMsg
- echomsg "screenpaste:" a:msg "Plugin not loaded"
- echohl None
- let g:loaded_screenpaste = "no"
- let &cpo = s:save_cpo
- unlet! g:screen_clmode g:screen_executable g:screen_register
- \ g:screen_visualselect g:screen_wait
-endfunction
-" }}}2
-
-" bail out if not Vim7 or greater
-if v:version < 700
- call <SID>Screen_CleanUp("Vim7 or greater required.")
- finish
-endif
-
-" bail out if system() is not available
-if !exists("*system")
- call <SID>Screen_CleanUp("builtin system() function not available.")
- finish
-endif
-
-" g:screen_executable: name of GNU Screen executable
-if !exists("g:screen_executable")
- let g:screen_executable = "screen"
-endif
-" bail out if GNUscreen is not present
-if !executable(g:screen_executable)
- call <SID>Screen_CleanUp("`".g:screen_executable."' not executable.")
- finish
-endif
-
-" More Global Variables: {{{1
-function! s:Screen_Default(val,cur,def) " {{{2
- echomsg "screenpaste: `".a:cur."':"
- \ "invalid value for screen_clmode."
- \ "Reset to '".a:def."' (default)"
- execute "let" a:val "= '".a:def."'"
-endfunction
-" }}}2
-
-" g:screen_clmode: how screenpaste behaves in Vim's command-line
-if !exists("g:screen_clmode")
- let g:screen_clmode = "search"
-elseif g:screen_clmode !~# '^\%(s\%(earch\|ub\)\|noesc\)$'
- call <SID>Screen_Default("g:screen_clmode",g:screen_clmode,"search")
-endif
-
-" g:screen_register: instead of register "0 use this one
-if !exists("g:screen_register")
- let g:screen_register = '"'
-elseif g:screen_register !~ '^["0-9a-zA-Z]$'
- call <SID>Screen_Default("g:screen_register",g:screen_register,'"')
-endif
-
-" g:screen_visualselect: select area after paste in visual mode
-if !exists("g:screen_visualselect")
- let g:screen_visualselect = 0
-endif
-
-" g:screen_wait: how long to wait for Screen to write exchange file
-if !exists("g:screen_wait")
- let g:screen_wait = "333m"
-elseif g:screen_wait !~# '^\d\+m\?$'
- call <SID>Screen_Default("g:screen_wait",g:screen_wait,"333m")
-endif
-
-" Mappings: propose defaults {{{1
-if !hasmapto("<Plug>ScreenpastePut") " nvo
- map <unique> <Leader>p <Plug>ScreenpastePut
-endif
-if !hasmapto("<Plug>ScreenpasteGPut") " nvo
- map <unique> <Leader>gp <Plug>ScreenpasteGPut
-endif
-if !hasmapto("<Plug>ScreenpastePutBefore", "n")
- nmap <unique> <Leader>P <Plug>ScreenpastePutBefore
-endif
-if !hasmapto("<Plug>ScreenpasteGPutBefore", "n")
- nmap <unique> <Leader>gP <Plug>ScreenpasteGPutBefore
-endif
-if !hasmapto("<Plug>ScreenpastePut", "ic")
- map! <unique> <Leader>p <Plug>ScreenpastePut
-endif
-
-" Internal Mappings: {{{1
-nnoremap <script> <silent> <Plug>ScreenpastePut
- \ :call screenpaste#Screen_NPut("p")<CR>
-nnoremap <script> <silent> <Plug>ScreenpasteGPut
- \ :call screenpaste#Screen_NPut("gp")<CR>
-nnoremap <script> <silent> <Plug>ScreenpastePutBefore
- \ :call screenpaste#Screen_NPut("P")<CR>
-nnoremap <script> <silent> <Plug>ScreenpasteGPutBefore
- \ :call screenpaste#Screen_NPut("gP")<CR>
-vnoremap <script> <silent> <Plug>ScreenpastePut
- \ :<C-U> call screenpaste#Screen_VPut("")<CR>
-vnoremap <script> <silent> <Plug>ScreenpasteGPut
- \ :<C-U> call screenpaste#Screen_VPut("g")<CR>
-inoremap <script> <silent> <Plug>ScreenpastePut
- \ <C-R>=screenpaste#Screen_IPut()<CR><C-R>=screenpaste#Screen_TwRestore()<CR>
-cnoremap <script> <Plug>ScreenpastePut
- \ <C-R>=screenpaste#Screen_CPut()<CR>
-
-" Commands: {{{1
-" configuration for command-line-mode
-command -nargs=1 -complete=custom,screenpaste#Screen_ClCfgComplete
- \ ScreenCmdlineConf call screenpaste#Screen_ClConfig(<f-args>, 1)
-command ScreenCmdlineInfo call screenpaste#Screen_ClConfig(g:screen_clmode, 1)
-command ScreenSearch call screenpaste#Screen_ClConfig("search", 1)
-command ScreenSub call screenpaste#Screen_ClConfig("sub", 1)
-command ScreenNoEsc call screenpaste#Screen_ClConfig("noesc", 1)
-" yank Screen buffer into register (default: screen_register)
-command -register ScreenYank call screenpaste#Screen_Yank("<register>")
-" buffer operation
-command -count=0 -bang -register ScreenPut
- \ call screenpaste#Screen_PutCommand("<count>", "<bang>", "<register>")
-
-" }}}1
-" Finale: cleanup and restore 'compatible' settings {{{1
-
-" Purge Functions that have done their one-time duty
-delfunction <SID>Screen_CleanUp
-delfunction <SID>Screen_Default
-
-let &cpo = s:save_cpo
-unlet s:save_cpo
-
-finish
-" }}}1
-" EOF vim600: set foldmethod=marker: