From: <kp...@us...> - 2011-12-09 17:41:29
|
Revision: 20593 http://jedit.svn.sourceforge.net/jedit/?rev=20593&view=rev Author: kpouer Date: 2011-12-09 17:41:23 +0000 (Fri, 09 Dec 2011) Log Message: ----------- factored some duplicate code Modified Paths: -------------- jEdit/trunk/org/gjt/sp/jedit/Registers.java Modified: jEdit/trunk/org/gjt/sp/jedit/Registers.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/Registers.java 2011-12-09 17:35:30 UTC (rev 20592) +++ jEdit/trunk/org/gjt/sp/jedit/Registers.java 2011-12-09 17:41:23 UTC (rev 20593) @@ -273,54 +273,7 @@ } JEditBuffer buffer = textArea.getBuffer(); applyMode(mode, buffer); - try - { - buffer.beginCompoundEdit(); - - /* vertical paste */ - if(vertical && textArea.getSelectionCount() == 0) - { - int caret = textArea.getCaretPosition(); - int caretLine = textArea.getCaretLine(); - Selection.Rect rect = new Selection.Rect( - caretLine,caret,caretLine,caret); - textArea.setSelectedText(rect,selection); - caretLine = textArea.getCaretLine(); - - if(caretLine != textArea.getLineCount() - 1) - { - - int startColumn = rect.getStartColumn( - buffer); - int offset = buffer - .getOffsetOfVirtualColumn( - caretLine + 1,startColumn,null); - if(offset == -1) - { - buffer.insertAtColumn(caretLine + 1,startColumn,""); - textArea.setCaretPosition( - buffer.getLineEndOffset( - caretLine + 1) - 1); - } - else - { - textArea.setCaretPosition( - buffer.getLineStartOffset( - caretLine + 1) + offset); - } - } - } - else /* Regular paste */ - { - textArea.replaceSelection(selection); - } - } - finally - { - buffer.endCompoundEdit(); - } - - HistoryModel.getModel("clipboard").addItem(selection); + _paste(textArea, vertical, selection, buffer); } /** @@ -387,6 +340,11 @@ applyMode(_mode, buffer); } } */ + _paste(textArea, vertical, selection, buffer); + } + + private static void _paste(TextArea textArea, boolean vertical, String selection, JEditBuffer buffer) + { try { buffer.beginCompoundEdit(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |