Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 222518 Details for
Bug 386472
[block selection] Block selection editing does not work with Korean encoding
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch v3
patch386472_201210181500.txt (text/plain), 5.75 KB, created by
Szymon Ptaszkiewicz
on 2012-10-18 09:08:49 EDT
(
hide
)
Description:
Patch v3
Filename:
MIME Type:
Creator:
Szymon Ptaszkiewicz
Created:
2012-10-18 09:08:49 EDT
Size:
5.75 KB
patch
obsolete
>diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java >index a7733f5..f8a6cce 100644 >--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java >+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009, 2010 Avaloq Evolution AG and others. >+ * Copyright (c) 2009, 2012 Avaloq Evolution AG and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -11,6 +11,9 @@ > package org.eclipse.jface.internal.text; > > import java.util.Arrays; >+ >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.graphics.GC; > > import org.eclipse.core.runtime.Assert; > >@@ -216,7 +219,7 @@ > }; > > private final Implementation COLUMN_IMPLEMENTATION= new Implementation() { >- TextEdit replace(ISelection selection, String replacement) throws BadLocationException { >+ private TextEdit replace(ISelection selection, String replacement, boolean delete) throws BadLocationException { > try { > MultiTextEdit root; > IBlockTextSelection cts= (IBlockTextSelection)selection; >@@ -244,7 +247,7 @@ > lastDelim= index[0] + delimiters[index[1]].length(); > } > } >- TextEdit replace= createReplaceEdit(line, visualStartColumn, visualEndColumn, string); >+ TextEdit replace= createReplaceEdit(line, visualStartColumn, visualEndColumn, string, delete); > root.addChild(replace); > } > while (lastDelim != -1) { >@@ -261,7 +264,7 @@ > endLine++; > TextEdit edit; > if (endLine < fDocument.getNumberOfLines()) { >- edit= createReplaceEdit(endLine, visualStartColumn, visualEndColumn, string); >+ edit= createReplaceEdit(endLine, visualStartColumn, visualEndColumn, string, delete); > } else { > // insertion reaches beyond the last line > int insertLocation= root.getExclusiveEnd(); >@@ -279,6 +282,10 @@ > Assert.isTrue(false); > return null; > } >+ } >+ >+ TextEdit replace(ISelection selection, String replacement) throws BadLocationException { >+ return replace(selection, replacement, false); > } > > String getText(ISelection selection) throws BadLocationException { >@@ -321,7 +328,7 @@ > IBlockTextSelection cts= (IBlockTextSelection)selection; > selection= new BlockTextSelection(fDocument, cts.getStartLine(), cts.getStartColumn(), cts.getEndLine(), cts.getEndColumn() + 1, fTabWidth); > } >- return replace(selection, ""); //$NON-NLS-1$ >+ return replace(selection, "", true); //$NON-NLS-1$ > } > > TextEdit backspace(ISelection selection) throws BadLocationException { >@@ -392,7 +399,7 @@ > return ts.getEndLine() - ts.getStartLine() + 1; > } > >- private TextEdit createReplaceEdit(int line, int visualStartColumn, int visualEndColumn, String replacement) throws BadLocationException { >+ private TextEdit createReplaceEdit(int line, int visualStartColumn, int visualEndColumn, String replacement, boolean delete) throws BadLocationException { > IRegion info= fDocument.getLineInformation(line); > int lineLength= info.getLength(); > String content= fDocument.get(info.getOffset(), lineLength); >@@ -400,11 +407,30 @@ > int endColumn= -1; > int visual= 0; > for (int offset= 0; offset < lineLength; offset++) { >- if (startColumn == -1 && visual >= visualStartColumn) >- startColumn= offset; >- if (visual >= visualEndColumn) { >- endColumn= offset; >- break; >+ if (startColumn == -1) { >+ if (visual == visualStartColumn) >+ if (!delete && isWider(content.charAt(offset), visual) && replacement.length() == 0) >+ startColumn= offset - 1; >+ else >+ startColumn= offset; >+ else if (visual > visualStartColumn) { >+ if (isWider(content.charAt(offset - 1), visual)) >+ startColumn= offset - 1; >+ else >+ startColumn= offset; >+ } >+ } >+ if (startColumn != -1) { >+ if (visual == visualEndColumn) { >+ endColumn= offset; >+ break; >+ } else if (visual > visualEndColumn) { >+ if (!delete && isWider(content.charAt(offset - 1), visual)) >+ endColumn= offset - 1; >+ else >+ endColumn= offset; >+ break; >+ } > } > visual+= visualSizeIncrement(content.charAt(offset), visual); > } >@@ -476,6 +502,10 @@ > return lineLength + Math.max(0, visualColumn - visual); > } > >+ private boolean isWider(char character, int visual) { >+ return visualSizeIncrement(character, visual) > 1; >+ } >+ > /** > * Returns the increment in visual length represented by <code>character</code> given the > * current visual length. The visual length is <code>1</code> unless <code>character</code> >@@ -487,6 +517,18 @@ > * <code>[0,fTabWidth]</code> > */ > private int visualSizeIncrement(char character, int visual) { >+ if (character > 255 && fStyledText != null) { >+ GC gc= null; >+ try { >+ gc= new GC(fStyledText); >+ int charWidth= gc.stringExtent(new String(Character.toString(character))).x; >+ int singleCharWidth= gc.stringExtent(" ").x; //$NON-NLS-1$ >+ return (int)Math.ceil(charWidth / singleCharWidth); >+ } finally { >+ if (gc != null) >+ gc.dispose(); >+ } >+ } > if (character != '\t') > return 1; > if (fTabWidth <= 0) >@@ -503,6 +545,8 @@ > > private ISelectionProvider fSelectionProvider; > >+ private StyledText fStyledText; >+ > /** > * Creates a new processor on the given viewer. > * >@@ -515,6 +559,7 @@ > fRewriteTarget= ext.getRewriteTarget(); > } > fSelectionProvider= viewer.getSelectionProvider(); >+ fStyledText= viewer.getTextWidget(); > } > > /**
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
daniel_megert
:
review+
Actions:
View
|
Diff
Attachments on
bug 386472
:
219474
|
219475
|
219515
|
219589
|
219595
|
219602
|
222508
| 222518