From 7eda5e2cc7c0141140aa87649521a7db4b334f09 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 10 May 2011 22:37:06 +0200 Subject: [PATCH] vim/bundle/screenpaste: Update to 7.0. --- .../screenpaste/autoload/screenpaste.vim | 234 ++++ vim/bundle/screenpaste/doc/screenpaste.txt | 63 +- vim/bundle/screenpaste/plugin/screenpaste.vim | 1007 ----------------- .../screenpaste/plugin/screenpastePlugin.vim | 151 +++ 4 files changed, 418 insertions(+), 1037 deletions(-) create mode 100644 vim/bundle/screenpaste/autoload/screenpaste.vim delete mode 100644 vim/bundle/screenpaste/plugin/screenpaste.vim create mode 100644 vim/bundle/screenpaste/plugin/screenpastePlugin.vim diff --git a/vim/bundle/screenpaste/autoload/screenpaste.vim b/vim/bundle/screenpaste/autoload/screenpaste.vim new file mode 100644 index 0000000..a6d9e93 --- /dev/null +++ b/vim/bundle/screenpaste/autoload/screenpaste.vim @@ -0,0 +1,234 @@ +" 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 Screen_ReadBuf(l:screen_tmpfile) + else + let l:screen_buf = 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, "\", 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: diff --git a/vim/bundle/screenpaste/doc/screenpaste.txt b/vim/bundle/screenpaste/doc/screenpaste.txt index 11a50e8..49cfeb6 100644 --- a/vim/bundle/screenpaste/doc/screenpaste.txt +++ b/vim/bundle/screenpaste/doc/screenpaste.txt @@ -1,5 +1,11 @@ *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 @@ -12,13 +18,12 @@ Author: Christian Ebert 1. Contents *screenpaste-toc* Screen Paste Plugin |screenpaste-intro| - Activation |screenpaste-activate| + Installation |screenpaste-install| Usage |screenpaste-usage| Options |screenpaste-options| Changing Mappings |screenpaste-mappings| Commands |screenpaste-commands| Bugs and Limitations |screenpaste-bugs| - Credits |screenpaste-credits| ============================================================================== @@ -36,7 +41,7 @@ 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 in Vim7 many commands are autodetected and the +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 @@ -51,15 +56,17 @@ respectively. ============================================================================== -3. Activation *screenpaste-activate* +3. Installation *screenpaste-install* -Either copy screenpaste.vim to your plugin directory (|add-global-plugin|), -or to your macros directory and source it (manually or from |vimrc|): > - :runtime macros/screenpaste.vim -or > - :source $HOME/.vim/macros/screenpaste.vim +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'|. -The Vim Help documentation installs itself when you restart Vim. +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. @@ -199,16 +206,26 @@ Default Value 'screen' "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. + 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 +Type String or Number Valid Values "a-z0-9A-Z Default Value '"' @@ -228,12 +245,9 @@ Default Value '"' For a one time operation with a special register the use of |ScreenPut| ex-command and its register argument is recommended. - Note: Due to the mechanics of the script even a numbered register has - to be passed as string, ie. it has to quoted when you set it; eg. > - :let g:screen_register = "8" -< Note as well that 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|). + 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* @@ -291,7 +305,6 @@ Modes and their behaviour: Use this mode to paste current Screen buffer literally into command line. -Vim7: |/|, |?|, |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: > @@ -305,9 +318,6 @@ Vim7: without clobbering a parallel Screen session, and Vim would insert characters instead (see |NL-used-for-Nul|). -Vim6: - For |:insert| and |:append| commands use Screen's "C-a ]" - ============================================================================== 6. Changing Mappings *screenpaste-mappings* @@ -425,13 +435,6 @@ 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. -============================================================================== - -Credits *screenpaste-credits* - -Mathieu Clabaut, Guo-Peng Wen let me steal and tweak the inline - self-install code for this Help document. - ============================================================================== vim:tw=78:ts=8:ft=help:norl: diff --git a/vim/bundle/screenpaste/plugin/screenpaste.vim b/vim/bundle/screenpaste/plugin/screenpaste.vim deleted file mode 100644 index 5ae6ec4..0000000 --- a/vim/bundle/screenpaste/plugin/screenpaste.vim +++ /dev/null @@ -1,1007 +0,0 @@ -" File: screenpaste.vim -" Description: pastes/inserts current GNU Screen buffer in (almost) any mode -" Version: 5.92 -" Mercurial: $Id: screenpaste.vim,v 41183f681647 2008-01-06 17:29 +0100 blacktrash $ -" Author: Christian Ebert -" Credits: Mathieu Clabaut and Guo-Peng Wen for inline doc self-install code -" URL: http://www.vim.org/script.php?script_id=1512 -" Requirements: GNU Screen must be in $PATH -" Documentation: :help screenpaste -" self installing to its current version when plugin is loaded -" to review before install go to last section of this file -" -" GetLatestVimScripts: 1512 1 :AutoInstall: screenpaste.vim - -" Init: store 'compatible' settings {{{1 -let s:save_cpo = &cpo -set cpo&vim - -if !exists("g:loaded_screenpaste") - " Fast Load: global vars, mappings, commands, doc install - " load functions only on demand via autocmd - " at Vim startup only run checks, load global vars, mappings, commands, - " and install Help if not up to date or not present - - " full path to plugin -- needed for Screen_UpdateDocs and demand load - let s:plug_path = expand(":p") - " name of plugin w/o extension for messages - let s:plug_name = fnamemodify(s:plug_path, ":t:r") - - " Global Variables: {{{1 - " g:screen_executable: name of GNU Screen executable - if !exists("g:screen_executable") - let g:screen_executable = "screen" - endif - - " 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\)$' - echomsg s:plug_name.": `".g:screen_clmode."':" - \ "invalid value for screen_clmode." - \ "Reset to 'search' (default)" - let 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]$' - echomsg s:plug_name.": `".g:screen_register."':" - \ "invalid value for screen_register." - \ "Reset to '\"' (default)" - let g:screen_register = '"' - endif - - if !exists("g:screen_visualselect") - let g:screen_visualselect = 0 - endif - - " Checks: for system() and Screen executable {{{1 - function! s:Screen_CleanUp(msg) - echohl WarningMsg - echomsg s:plug_name.":" a:msg "Plugin not loaded" - echohl None - let g:loaded_screenpaste = "no" - let &cpo = s:save_cpo - unlet s:save_cpo s:plug_name g:screen_executable g:screen_clmode - endfunction - - " bail out if system() is not available - if !exists("*system") - call Screen_CleanUp("builtin system() function not available.") - finish - endif - - " bail out if GNUscreen is not present - if !executable(g:screen_executable) - call Screen_CleanUp("`".g:screen_executable."' not executable.") - finish - endif - - let s:curr_version = "v5.92" - - " Mappings: propose defaults {{{1 - if !hasmapto("ScreenpastePut") " nvo - map p ScreenpastePut - endif - if !hasmapto("ScreenpasteGPut") " nvo - map gp ScreenpasteGPut - endif - if !hasmapto("ScreenpastePutBefore", "n") - nmap P ScreenpastePutBefore - endif - if !hasmapto("ScreenpasteGPutBefore", "n") - nmap gP ScreenpasteGPutBefore - endif - if !hasmapto("ScreenpastePut", "ic") - map! p ScreenpastePut - endif - - " Internal Mappings: {{{1 - nnoremap