2012-03-19 3 views
1

메모 블록을 세로로 선택하고 복사하려면 ++를 사용하고 있습니다. 마지막으로 클립 보드 버퍼에있는 텍스트 블록을 붙여 넣는 것은 정상적으로 작동하지만 두 번째 및 세 번째 이전 클립 보드 버퍼 (원래 블록으로 복사 된)로 돌아가는 것은 다른 버퍼를 블록으로 붙여 넣지 않고 등 예컨대메모장 ++ 세로 블록 선택 복사 붙여 넣기가 클립간에 유지되지 않음

등 개행, 제 2 라인 개행,이어서 첫 번째 라인은, I는

 test 
     test 
     test 

는 가정으로 다음의 블록을

 test 
     test 
     test 

최신 보드 버퍼 페이스트 복사 차단할 가정 커서는 4 칸이다. 유언. 나는 이전 클립 보드 버퍼를 저장하는 ClipMate을 사용하고

 test 
test 
test 

: 최신 클립 보드 버퍼가 클립 보드 버퍼 큐에서 두 번째 장소로 이동하는 경우 그러나, 나는 다음 붙여 넣기를 얻을.

notepad ++가 (블록으로 복사 된) 최신 클립 보드 텍스트 데이터를 차단하고 마지막 클립 보드 버퍼를 블록하지 않는 이유는 무엇입니까?

클립 보드 클립의 블록 상태를 저장하는 방법이 있습니까?

+0

메모장 ++ 용 MultiClip 플러그인을 찾아서 설치했습니다. 그것은 클립의 블록 상태를 유지합니다. 그러나, 메모장의 외부에서 그것을 사용할 수 없습니다 ++ 일반적으로 애플 리케이션을 통해 클립 보드 공유.메모장에서만 작동합니다. ++. –

답변

2

메모장 ++가 내부 버퍼에서 붙여 넣기 중이며 클립 보드에서 데이터를 가져 오지 않는 것 같습니다. MSDEVColumnSelect라는 개인 데이터 형식이 있지만 ClipMate에서 강제로 캡처하려고하면 데이터가 비어 있습니다. 그래서 이것은 응용 프로그램이 복사/붙여 넣기 기능을 사용하여 연기 및 거울 게임을하는 경우 인 것으로 보이며 사실 클립 보드 기능이 아닙니다.

+0

Visual Studio에서 블록 선택을 처리하는 방식으로, Scintilla가이를 반영합니다. MSDEVColumnSelect 데이터 형식이 있으면 텍스트 열로 해석합니다. 나는 ClipMate가 빈 형식을 저장하지 않는다고 가정합니다. 아마 VS에서 같은 효과를 얻을 것입니다. –

1

저는 Python Script Scintilla 래퍼 메모장 ++ 플러그인을 사용하여 솔루션을 작성했습니다.

복사용으로 사용하십시오. C:\Program Files\Notepad++\plugins\PythonScript\scripts\Samples\Copy.py
지도로
저장 Ctrl 키 + C를 단축키 Ctrl 키 + INS

# $Revision: 1.2 $ 
# $Author: dot $ 
# $Date: 2012/03/23 20:59:46 $ 

from Npp import * 
import string 

# First we'll start an undo action, then Ctrl+z will undo the actions of the whole script 
editor.beginUndoAction() 

if editor.getSelText() != '': 
    strClip = "" 
    if editor.selectionIsRectangle(): 
     strClip = "<vertical>"+editor.getSelText()+"</vertical>" 
    else: 
     strClip = editor.getSelText() 
    editor.copyText(strClip) 

# End the undo action, so Ctrl+z will undo the above two actions 
editor.endUndoAction() 

컷에 대한 사용이 있습니다. C:\Program Files\Notepad++\plugins\PythonScript\scripts\Samples\Cut.py
지도로
저장

# $Revision: 1.2 $ 
# $Author: dot $ 
# $Date: 2012/03/23 20:59:46 $ 

from Npp import * 
import string 

# First we'll start an undo action, then Ctrl+z will undo the actions of the whole script 
editor.beginUndoAction() 

if editor.getSelText() != '': 
    strClip = "" 
    if editor.selectionIsRectangle(): 
     strClip = "<vertical>"+editor.getSelText()+"</vertical>" 
    else: 
     strClip = editor.getSelText() 
    editor.copyText(strClip) 
    editor.clear() 

# End the undo action, so Ctrl+z will undo the above two actions 
editor.endUndoAction() 

지금 붙여 넣기를 위해 pyperclip.pyC:\Program Files\Notepad++\plugins\PythonScript\lib
사용이 다운로드 Ctrl 키 + X 바로 가기 및 + DEL

시프트합니다. 그것이 실행되는 Ctrl 키 +의 V 바로 가기 및 Shift + INS를이 VirtualSpaceOptions 아래의 다음
코드 C:\projects\misc\PythonScriptNppPlugin\startup.py 파일 3.
수정으로 설정되어 있다고 가정

# $Revision: 1.11 $ 
# $Author: dot $ 
# $Date: 2012/05/18 22:22:22 $ 

from Npp import * 
import pyperclip 
import string 

#debug = True 
debug = False 

# First we'll start an undo action, then Ctrl-z will undo the actions of the whole script 
editor.beginUndoAction() 

# Get the clip 
clip = pyperclip.getcb() 

# Debug 
if debug: 
    bufferID = notepad.getCurrentBufferID() 
    # Show console for debugging 
    console.clear() 
    console.show() 

    console.write("editor.getRectangularSelectionCaret()    = " + str(editor.getRectangularSelectionCaret()) + "\n") 
    console.write("editor.getRectangularSelectionAnchor()    = " + str(editor.getRectangularSelectionAnchor()) + "\n") 
    console.write("editor.getSelectionStart()       = " + str(editor.getSelectionStart()   ) + "\n") 
    console.write("editor.getSelectionEnd()       = " + str(editor.getSelectionEnd()    ) + "\n") 
    console.write("editor.getCurrentPos()        = " + str(editor.getCurrentPos()    ) + "\n") 
    console.write("editor.getAnchor()         = " + str(editor.getAnchor()     ) + "\n") 
    console.write("editor.getRectangularSelectionAnchorVirtualSpace() = " + str(editor.getRectangularSelectionAnchorVirtualSpace()) + "\n") 
    console.write("editor.getRectangularSelectionCaretVirtualSpace() = " + str(editor.getRectangularSelectionCaretVirtualSpace()) + "\n") 
    console.write("editor.getSelectionNCaretVirtualSpace(0)   = " + str(editor.getSelectionNCaretVirtualSpace(0)   ) + "\n") 
    console.write("editor.getSelectionNAnchorVirtualSpace(0)   = " + str(editor.getSelectionNAnchorVirtualSpace(0)  ) + "\n") 

if editor.getRectangularSelectionCaret()    == -1 and \ 
    editor.getRectangularSelectionAnchor()    == -1 and \ 
    editor.getSelectionStart()       == 0 and \ 
    editor.getSelectionEnd()       == 0 and \ 
    editor.getCurrentPos()        == 0 and \ 
    editor.getAnchor()         == 0 and \ 
    editor.getRectangularSelectionAnchorVirtualSpace() == 0 and \ 
    editor.getRectangularSelectionCaretVirtualSpace() == 0 and \ 
    editor.getSelectionNCaretVirtualSpace(0)   == 0 and \ 
    editor.getSelectionNAnchorVirtualSpace(0)   == 0: 
    currentPos = editor.getCurrentPos() 
    # Debug 
    if debug: 
     console.write("state 0\n") 
if editor.getRectangularSelectionCaret() != 0 and editor.getRectangularSelectionAnchor() != 0: 
    if editor.getSelectionStart() == editor.getRectangularSelectionCaret() and \ 
     editor.getSelectionEnd() == editor.getRectangularSelectionAnchor(): 
     # Debug 
     if debug: 
      console.write("state 1\n") 
     currentPos = min(editor.getRectangularSelectionCaret(),editor.getRectangularSelectionAnchor()) 
    elif editor.getSelectionStart() < editor.getRectangularSelectionCaret(): 
     # Debug 
     if debug: 
      console.write("state 2\n") 
     currentPos = editor.getSelectionStart() 
    elif editor.getSelectionStart() == editor.getRectangularSelectionCaret() and \ 
     editor.getSelectionEnd() > editor.getRectangularSelectionAnchor(): 
     currentPos = min(editor.getRectangularSelectionCaret(),editor.getRectangularSelectionAnchor()) 
     # Debug 
     if debug: 
      console.write("state 3\n") 
elif editor.getCurrentPos() != 0 and editor.getAnchor() != 0: 
    # Debug 
    if debug: 
     console.write("state 4\n") 
    currentPos = min(editor.getCurrentPos(),editor.getAnchor()) 
elif editor.getSelectionStart() == editor.getRectangularSelectionCaret() and \ 
    editor.getSelectionEnd() > editor.getRectangularSelectionAnchor(): 
    # Debug 
    if debug: 
     console.write("state 5\n") 
    currentPos = min(editor.getRectangularSelectionCaret(),editor.getRectangularSelectionAnchor()) 
else: 
    currentPos = editor.getCurrentPos() 
    # Debug 
    if debug: 
     console.write("state 6\n") 

# Debug 
if debug: 
    console.write("currentPos = " + str(currentPos) + "\n") 

if editor.getRectangularSelectionAnchorVirtualSpace() != editor.getRectangularSelectionCaretVirtualSpace() and \ 
    (editor.getRectangularSelectionAnchorVirtualSpace() == editor.getSelectionNCaretVirtualSpace(0)   and \ 
    editor.getSelectionNCaretVirtualSpace(0)   == editor.getSelectionNAnchorVirtualSpace(0)): 
    prefix = editor.getRectangularSelectionCaretVirtualSpace() 
    # Debug 
    if debug: 
     console.write("state 7\n") 
else: 
    prefix = min(editor.getSelectionNCaretVirtualSpace(0),editor.getSelectionNAnchorVirtualSpace(0)) 
    # Debug 
    if debug: 
     console.write("state 8\n") 

# Debug 
if debug: 
    console.write("prefix = " + str(prefix) + "\n") 

prefixSpaces = "".ljust(prefix,' ') 
eolmode  = editor.getEOLMode() 

# SC_EOL_CRLF (0), SC_EOL_CR (1), or SC_EOL_LF (2) 
if eolmode == 0: 
    eol = "\r\n" 
    eolcnt = 2 
elif eolmode == 1: 
    eol = '\r' 
    eolcnt = 1 
elif eolmode == 2: 
    eol = "\n" 
    eolcnt = 1 

if prefix > 0: 
    if currentPos < editor.getCurrentPos(): 
     editor.insertText(editor.getLineEndPosition(editor.lineFromPosition(currentPos)),prefixSpaces) 
     editor.gotoPos(editor.getLineEndPosition(editor.lineFromPosition(currentPos+prefix))) 
     start = currentPos+prefix 
     # Debug 
     if debug: 
      console.write("state 9\n") 
    else: 
     editor.insertText(editor.getLineEndPosition(editor.lineFromPosition(editor.getCurrentPos())),prefixSpaces) 
     editor.gotoPos(editor.getLineEndPosition(editor.lineFromPosition(editor.getCurrentPos()))) 
     start = editor.getCurrentPos() 
     # Debug 
     if debug: 
      console.write("state 10\n") 
else: 
    start = currentPos 
    # Debug 
    if debug: 
     console.write("state 11\n") 

# Debug 
if debug: 
    console.write("start = " + str(start) + "\n") 

if clip != "": 
    if editor.getSelectionStart() != editor.getSelectionEnd() and           \ 
     (editor.getColumn(editor.getSelectionStart()) != editor.getColumn(editor.getSelectionEnd()) or \ 
     (editor.getColumn(editor.getSelectionStart()) == editor.getColumn(editor.getSelectionEnd()) and \ 
      editor.getColumn(editor.getSelectionStart()) == 0)) and          \ 
     prefix == 0: 
     editor.clear() 
     # Debug 
     if debug: 
      console.write("state 12\n") 

    # We are dealing with a vertical paste 
    if clip.startswith("<vertical>") and clip.endswith("</vertical>"): 
     clip = clip[10:-11] 

     startCol = editor.getColumn(start) 
     startRow = editor.lineFromPosition(start) 

     # Debug 
     if debug: 
      console.write("startCol = " + str(startCol) + "\n") 

     # Debug 
     if debug:  
      console.write("startRow = " + str(startRow) + "\n") 

     # keepends = False 
     clipSplit = clip.splitlines(False) 

     clipSplitLen = len(clipSplit) 

     for index,line in enumerate(clipSplit): 
      if index == 0: 
       localPrefixSpaces = "" 
      elif index == (clipSplitLen-1): 
       localPrefixSpaces = prefixSpaces 
      else: 
       localPrefixSpaces = prefixSpaces 

      try: 
       editorLine = editor.getLine(startRow+index).strip(eol) 
       editorLineLen = len(editorLine) 

       # Empty line 
       if editorLineLen == 0: 
        editor.insertText(editor.positionFromLine(startRow+index),"".ljust(startCol,' ')) 
        editor.insertText(editor.findColumn(startRow+index,startCol),line) 
       else: 
        if editorLineLen < startCol: 
         editor.insertText(editor.getLineEndPosition(startRow+index),"".ljust(startCol-editorLineLen,' ')) 
        editor.insertText(editor.findColumn(startRow+index,startCol),line) 

      # End of file 
      except IndexError: 
       editor.documentEnd() 
       editor.appendText(eol) 
       editor.appendText("".ljust(startCol,' ') + line) 

     editor.setCurrentPos(start) 
     editor.setSelection(start,start) 
    # We are dealing with a horizontal paste 
    else: 
     editor.insertText(start, clip) 
     editor.setCurrentPos(start + len(clip)) 
     editor.setSelection(start + len(clip),start + len(clip)) 

# End the undo action, so Ctrl-z will undo the above two actions 
editor.endUndoAction() 

# Debug 
if debug: 
    notepad.activateBufferID(bufferID) 

및 보장하기 위해 C:\Program Files\Notepad++\plugins\PythonScript\scripts\Samples\Paste.py
지도로
저장 모든 메모장이 시작됩니다.

# $Revision: 1.2 $ 
# $Author: dot $ 
# $Date: 2012/03/23 20:59:46 $ 

# The lines up to and including sys.stderr should always come first 
# Then any errors that occur later get reported to the console 
# If you'd prefer to report errors to a file, you can do that instead here. 
import sys 
from Npp import * 

# Set the stderr to the normal console as early as possible, in case of early errors 
sys.stderr = console 

# Define a class for writing to the console in red 
class ConsoleError: 
    def __init__(self): 
     global console 
     self._console = console; 

    def write(self, text): 
     self._console.writeError(text); 

    def flush(self): 
     pass 

# Set the stderr to write errors in red 
sys.stderr = ConsoleError() 

# This imports the "normal" functions, including "help" 
import site 

# See docs 
# http://npppythonscript.sourceforge.net/docs/latest/intro.html 
# http://npppythonscript.sourceforge.net/docs/latest/scintilla.html 
def set_word_chars(args): 
    # Enable the virtual space options for both Scintilla views 
    # For more information, see the Scintilla documentation on virtual space and the SCI_SETVIRTUALSPACEOPTIONS message. 
    editor.setVirtualSpaceOptions(3) 
    # Set the word characters 
    editor.setWordChars('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$') 

notepad.callback(set_word_chars, [NOTIFICATION.BUFFERACTIVATED]) 

# This sets the stdout to be the currently active document, so print "hello world", 
# will insert "hello world" at the current cursor position of the current document 
sys.stdout = editor 

editor.setVirtualSpaceOptions(3) 
# Set the word characters 
editor.setWordChars('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$') 
#console.show() 
관련 문제