Bug 19771 - [typing] Add column based editing capabilities to textual editors
Summary: [typing] Add column based editing capabilities to textual editors
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement with 68 votes (vote)
Target Milestone: 3.5 M5   Edit
Assignee: Tom Hofmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 22582 23255 32128 33790 40076 44269 45807 50850 78289 82310 83812 89204 93443 115792 123756 124503 155519 157362 180306 184300 204570 235970 (view as bug list)
Depends on: 8521 250170 250171 250172 250174 250175 250177 250178 250179 250180 253057 257236 257237 257238 257240
Blocks: 262679
  Show dependency tree
 
Reported: 2002-06-10 07:02 EDT by Michael CLA
Modified: 2019-11-29 06:30 EST (History)
64 users (show)

See Also:


Attachments
org.eclipse.text.diff.txt (88.07 KB, patch)
2007-01-29 04:43 EST, Tom P. Eicher CLA
no flags Details | Diff
column_mode_icons.zip (1.38 KB, application/zip)
2007-01-29 04:49 EST, Tom P. Eicher CLA
no flags Details
column_mode.zip (39.28 KB, application/zip)
2007-04-29 12:20 EDT, Tom Hofmann CLA
no flags Details
block_selection.patch (94.16 KB, patch)
2008-11-25 16:29 EST, Tom Hofmann CLA
eclipse: review+
Details | Diff
block_selection.patch (106.28 KB, patch)
2008-12-23 09:44 EST, Tom Hofmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael CLA 2002-06-10 07:02:40 EDT
Add column based editing: cut/copy/paste/move, etc. colums of text.
Comment 1 Erich Gamma CLA 2002-06-10 08:37:35 EDT
not for 2.0
Comment 2 Dirk Baeumer CLA 2002-07-18 10:42:03 EDT
IMO this is a general text editor feature request.
Comment 3 Claude Knaus CLA 2002-08-21 10:15:34 EDT
What to do when proportional fonts are used?
Block selection is not possible in StyledText.
Comment 4 Claude Knaus CLA 2002-09-13 09:57:04 EDT
If the font was proportional, it would have to switch to a proportional one to 
allow block selection.
Comment 5 Claude Knaus CLA 2002-09-13 09:57:52 EDT
*** Bug 22582 has been marked as a duplicate of this bug. ***
Comment 6 Chris Beck CLA 2002-11-29 11:46:03 EST
The editor I got this idea from (EditPlus) uses a simple screen drawing 
technique for proportional fonts.




All boundaries are defined by the characters in the top-most select row.


The selection start at the first full character in the top row and ends after 
the last full character.


On each subsequent row it selects the first full character with a horizontal 
poition => the top row start and similarly for the ending.




Another method would be to select characters m to n in each row where m and n 
are defined by the top row range or m by the first selected row and n by the 
last selected row.




Or, as you say, force proportional.
Comment 7 Dani Megert CLA 2003-07-30 05:20:43 EDT
*** Bug 40076 has been marked as a duplicate of this bug. ***
Comment 8 Dani Megert CLA 2003-07-30 05:21:45 EDT
*** Bug 33790 has been marked as a duplicate of this bug. ***
Comment 9 Dani Megert CLA 2003-10-07 03:27:27 EDT
*** Bug 44269 has been marked as a duplicate of this bug. ***
Comment 10 Dani Megert CLA 2003-10-31 09:13:44 EST
*** Bug 45807 has been marked as a duplicate of this bug. ***
Comment 11 Dani Megert CLA 2004-01-30 06:37:46 EST
*** Bug 50850 has been marked as a duplicate of this bug. ***
Comment 12 Marcelo Alvim CLA 2004-04-29 10:36:28 EDT
Hi!
I was going to post a new feature request, asking for column editing, but saw 
this bug, still open. Any plans to implement this feature, for the next 
releases?
Thanx,
Alvim.
Comment 13 Dani Megert CLA 2004-04-29 10:41:28 EDT
not for 3.0
Comment 14 Chris Beck CLA 2004-04-29 13:05:19 EDT
Not for v2.0, not for v3.0 ... the bookies in Vegas are giving even money on v7.1
Come on Daniel, we all know that you secretly really _want_ to implement this.
Comment 15 thomas menzel CLA 2004-11-10 11:47:46 EST
*** Bug 78289 has been marked as a duplicate of this bug. ***
Comment 16 Dani Megert CLA 2005-01-06 05:13:50 EST
*** Bug 82310 has been marked as a duplicate of this bug. ***
Comment 17 Dani Megert CLA 2005-01-27 06:28:58 EST
*** Bug 83812 has been marked as a duplicate of this bug. ***
Comment 18 Dani Megert CLA 2005-03-28 10:14:02 EST
*** Bug 89204 has been marked as a duplicate of this bug. ***
Comment 19 Dani Megert CLA 2005-05-02 17:08:34 EDT
*** Bug 93443 has been marked as a duplicate of this bug. ***
Comment 20 Tom Hofmann CLA 2005-07-27 03:35:05 EDT
*** Bug 32128 has been marked as a duplicate of this bug. ***
Comment 21 Tom Hofmann CLA 2005-07-27 03:36:05 EDT
See also bug 32128, which calls the feature rectangular selection.
Comment 22 Andrey Loskutov CLA 2005-08-01 10:16:50 EDT
Any plans for 3.2?
Comment 23 Dani Megert CLA 2005-11-10 06:22:40 EST
*** Bug 115792 has been marked as a duplicate of this bug. ***
Comment 24 Dani Megert CLA 2006-01-13 09:57:58 EST
*** Bug 123756 has been marked as a duplicate of this bug. ***
Comment 25 fx CLA 2006-01-13 10:14:58 EST
I think Eclipse platform should support vertical column cuts and paste
function.

UltraEdit has it, EditPad has it, JBuilder has it, Visual Studio has it, but
Eclipse has NOT.

It's a long-waiting function.

I used to had a plugin which can do this, but after update eclipse from 3.1 to
3.2, I lost this function, and I can not rember which plugin I use. After a lot
of search on google, I gave up searching ant report it as a bug.
Comment 26 Chad Barnes CLA 2006-01-13 10:22:57 EST
I believe you were using the Lunar-Eclipse plug-ins:

http://sourceforge.net/projects/lunar-eclipse/
Comment 27 Andrey Loskutov CLA 2006-01-13 10:24:36 EST
The summary should be changed from
"Add column based editing capabilities to Java Editor" 
to 
"Add column based editing capabilities to Text Editors",
because there are lot of editors wich will benefit from this.
Comment 28 Markus Schweizer CLA 2006-01-16 01:44:33 EST
I would prefer the support for vertical column cuts and paste function as in Visual Studio because it's very comfortable. Especially moving vertical selectioned text with the <Tab> key.
I would also integrate this feature into all Text Editors. It always helps formatting text.
Comment 29 Dani Megert CLA 2006-01-19 11:50:01 EST
*** Bug 124503 has been marked as a duplicate of this bug. ***
Comment 30 Philippe Ombredanne CLA 2006-07-28 18:45:51 EDT
FYI:
http://sourceforge.net/projects/columns4eclipse
Comment 31 Dani Megert CLA 2006-08-29 06:43:57 EDT
*** Bug 155519 has been marked as a duplicate of this bug. ***
Comment 32 Anton Leherbauer CLA 2006-09-15 02:47:54 EDT
*** Bug 157362 has been marked as a duplicate of this bug. ***
Comment 33 Matt Baker CLA 2006-09-29 14:05:14 EDT
Adding my vote for this.  We use the editor extensibility and have many requests from our customers to add this feature.  Its a shame that the styled text widget cannot do this when so many other editors can.
Comment 34 Tom P. Eicher CLA 2007-01-29 04:43:01 EST
Created attachment 57686 [details]
org.eclipse.text.diff.txt

Patch against HEAD of 20070129 of org.eclipse.jface.text, o.e.ui.workbench.texteditor, o.e.ui.editors and o.e.jdt.ui. 

This patch implements column mode in Eclipse text editors. It relies on the patches against SWT posted in bug 8521. It is not final but allows to work with column mode and test the functionality, and also serves to preview the API impact of the final patch.

Features:
- toggle column mode by pressing Alt+C or pushing the toolbar button (you may need to show the "Editor Presentation" toolbar to see it).
- support for delete, insert, cut, copy paste etc. 
- automatic font switching if the normal editor font is proportional

API impact:

- org.eclipse.jface.text:
  - new interface IColumnTextSelection extends ITextSelection
  - with default implementation ColumnTextSelection extends TextSelection

- org.eclipse.ui.workbench.texteditor:
  - new interface ITextEditorExtension5 adding column mode functionality
  - AbstractTextEditor to implement the new interface
  - new method AbstractTextEditor::enableColumnSelectionMode(boolean) that allows subclasses to selectively enable column mode (column mode is disabled by default in order to not break existing subclasses)
  - new constant AbstractTextEditor::COLUMN_MODE_FONT for the column mode font preference
  - new constants for the column mode action / command in
    - IAbstractTextEditorHelpContextIds.java
    - ITextEditorActionConstants.java
    - ITextEditorActionDefinitionIds.java
    - ITextEditorExtension5.java
Comment 35 Tom P. Eicher CLA 2007-01-29 04:49:40 EST
Created attachment 57687 [details]
column_mode_icons.zip

Icons for the column mode toolbar button. The icons are a quick attempt and should merely serve as a placeholder / input for an icon designer. They should go into org.eclipse.ui.workbench.texteditor/icons/full.
Comment 36 Dani Megert CLA 2007-01-29 05:00:39 EST
Tom, I will look at this patch as soon as SWT officially commits to that for 3.3 and has a milestone assigned.

Note that "Alt+ char" key bindings must not be used as they interfere with mnemonics.
Comment 37 Dani Megert CLA 2007-03-31 03:27:25 EDT
*** Bug 180306 has been marked as a duplicate of this bug. ***
Comment 38 Dani Megert CLA 2007-04-27 17:57:45 EDT
*** Bug 184300 has been marked as a duplicate of this bug. ***
Comment 39 Tom Hofmann CLA 2007-04-29 12:20:24 EDT
Created attachment 65347 [details]
column_mode.zip

The attached zip file contains a workspace patch based on the previous patches for all affected plug-ins (swt, jface.text, ui.workbench.texteditor, ui.editors, jdt.ui) and also includes icons. The patch is against Eclipse 3.3M6.

Also, I set up a micro-site providing the patched plug-ins of Eclipse 3.3M6 at http://tkilla.ch/column_mode, which should make it easy to try the patch out for any interested parties.
Comment 40 Markus Schweizer CLA 2007-05-08 10:05:51 EDT
The patch is working fine with the JDT and Text editor but NOT with the C/C++ editor (CDT). It should work for any kind of textual based editors in eclipse! It's very nice, that drag 'n drop is almost working too but moving the the selected column within a line is not always working correctly! 
Comment 41 Fedja Jeleskovic CLA 2007-05-22 11:09:42 EDT
Just added another vote and have a question - the block selecting feature in Code Write is done by use of the Right mouse button and it an excellent extension to the use of the mouse that I could think of. Is there any chance that we might see something similar for the Eclipse too?

Thanks!!
Comment 42 Andre Bossert CLA 2007-07-03 02:55:21 EDT
The Plugin for M6 is working fine with Text editor! It would be great to use it with Eclipse 3.3 and CDT4.0 editor. Any plans to update this plugin for final Europa releases?
Thanks!
Comment 43 Doug Schaefer CLA 2007-07-03 11:14:47 EDT
(In reply to comment #42)
> The Plugin for M6 is working fine with Text editor! It would be great to use it
> with Eclipse 3.3 and CDT4.0 editor. Any plans to update this plugin for final
> Europa releases?

Obviously Europa has left the station. Daniel, what are your current plans for this feature? We have significant customer interest in it and would be willing to help however you need.
Comment 44 Dani Megert CLA 2007-07-03 12:12:38 EDT
Hi Doug. Please note that this strongly depends on bug 8531 i.e. until SWT's StyledTextWidget provides support there's nothing I can do here.
Comment 45 Doug Schaefer CLA 2007-07-03 12:47:44 EDT
Cool. Thanks, Daniel. I'll check out the SWT bug.
Comment 46 Martin Oberhuber CLA 2007-07-04 04:51:57 EDT
(In reply to comment #44)
Typofix - the SWT bug in question is bug #8521.
Comment 47 Dani Megert CLA 2007-07-16 08:09:44 EDT
*** Bug 23255 has been marked as a duplicate of this bug. ***
Comment 48 Anton Leherbauer CLA 2007-10-02 05:54:10 EDT
*** Bug 204570 has been marked as a duplicate of this bug. ***
Comment 49 stefan CLA 2007-11-22 09:24:42 EST
any plans for a release of this feature? 3.4?
Comment 50 Martin Oberhuber CLA 2007-11-22 09:34:52 EST
Looks like we're all waiting on bug #8521 to get fixed first, aren't we?
Comment 51 Dani Megert CLA 2007-11-22 09:37:45 EST
>Looks like we're all waiting on bug #8521 to get fixed first, aren't we?
Yep.
Comment 52 Dani Megert CLA 2008-06-08 15:37:50 EDT
*** Bug 235970 has been marked as a duplicate of this bug. ***
Comment 53 Tom Hofmann CLA 2008-07-27 12:33:01 EDT
Comment on attachment 65347 [details]
column_mode.zip

I have updated the combined SWT/Text patch attached to the SWT bug (see bug 8521 comment 38) with an Eclipse 3.4 version, obsoleting this patch. 

For Eclipse 3.4 users, there is also an update site at

  http://tkilla.ch/column_mode

which offers feature patches containing the patch.
Comment 54 Tom Hofmann CLA 2008-09-30 02:21:24 EDT
Investigating...
Comment 55 Tom Hofmann CLA 2008-11-25 16:29:53 EST
Created attachment 118701 [details]
block_selection.patch

This patch against HEAD of 20081125 updates the previous 3.4 version of the patch using the new SWT APIs published in 3.5M3. It is quite incomplete feature-wise but enables playing with block selection.

What's working:
- block selection mode toggling using Alt+C (I know...) or the toolbar button (must be enabled via 'Customize Perspective > Editor Presentation').
- monospace font toggling when block mode is enabled
- copy, paste, typing

What's not working:
- undo (works only one line at a time, I guess SWT sends out n events for n changed lines)
- DND (commented out, I will have to look into this)
- any modifications within the whitespace beyond the end of a line

The following plug-ins are affected:
- org.eclipse.jface.text
- org.eclipse.ui.workbench.texteditor (note that the icons must be extracted from the previous obsolete zip)
- org.eclipse.ui.editors
- org.eclipse.jdt.ui
Comment 56 Dani Megert CLA 2008-12-02 12:57:16 EST
I've reviewed the patch and how it feels in the UI. So far I see no show stopper in the patch itself (detailed comments will follow in next comment). The only thing we need to get a feeling for is how much effort is needed to complete the patch feature-wise. Having said that I see stop ship issues in the resulting LAF that comes from StyledText:
P1 bug 257237: cut/copy & paste not usable without virtual spaces
P1 bug 257238: block selection mode: trouble with caret and newline
P2 bug 257240: cross cursor is unexpected when in block selection mode
P2 bug 257236: strange selection look
P2 bug 250179: it's not obvious which characters are part of the selection 

Comment 57 Dani Megert CLA 2008-12-02 13:01:09 EST
Some feedback to the patch itself (in random order):
- supportsColumnSelection() ==> isSupportingColumnSelection() or isColumnSelectionAvailable()
- however, I'm not sure we really need this: the action in the action set and in the ATE is there for all textual editors. What's the risk of offering if for all editors? I mean it's off by default anyway.
- in the editor code don't use getTextWidget().getBlockSelection() but call isColumnMode() instead
- some interfaces look strange/artificial to me (or at least needs better doc):
org.eclipse.ui.texteditor.IDeleteLineTargetExtension.deleteLine(IDocument, ITextSelection, int, boolean)
- Column Mode Font ==> Text (Editor) Column Mode Font
- XXX should TextSelection open its document to subclasses? */
	==> I think it's OK to make it protected
- access to widget in propertyChanged should be protected against being disposed
- org.eclipse.jface.text.IColumnTextSelection.getRegions() and getText() look like helpers. Do we really need this in the interface?
- org.eclipse.jface.text.SelectionProcessor: I'm declined to make this API. So far only two methods are used outside jface.text
	==> we could put the must-have methods into JFaceTextUtil for now
- replace outdated 3.3 occurrences with 3.5
- icons: I assume you also see those as placeholders that we will repalce with icons from the designers
- tool bar: Toogle Column Sel... ==> 'Enable Column Mode'
- we no longer use hoverIcon
	==> remove from icons dir and from plugin.xml
- as you already marked: some classes need Javadoc
- help doc is needed
Comment 58 Dani Megert CLA 2008-12-08 09:26:16 EST
I've discussed the review feedback with Tom and we are on the same page. Currently we are still discussing some of the remaining SWT issues. This will have to wait for early M5.
Comment 59 Tom Hofmann CLA 2008-12-23 09:44:18 EST
Created attachment 121140 [details]
block_selection.patch

This is the current state of the work addressing the issues from comment #57. None of the other problems mentioned in my previous post (most notably undo support) have been addressed.

> Some feedback to the patch itself (in random order):
> - supportsColumnSelection() ==> isSupportingColumnSelection() or
> isColumnSelectionAvailable()

DONE. I have also replaced "column mode" or "column selection" by "block selection", which I believe is the name the feature runs under now. I think it is not required but helpful if SWT and the platform use the same terminology; also, the text editors already use the term 'column' for the rulers (IVerticalRulerColumn).

> - however, I'm not sure we really need this: the action in the action set and
> in the ATE is there for all textual editors. What's the risk of offering if 
> for all editors? I mean it's off by default anyway.

Well, the risk is that some concrete editor may have some actions that implicitely expect a linear selection and do not work as expected with column selection. The actions wouldn't fail hard, its just that the user may not see the expected result and the plug-in owners may have to provide similar code to what we had to do in JavaEditor (none of these fixes was very bad, though).

DONE: removed ITextEditorExtension::isBlockSelectionSupported. This also reduces the set of modified plug-ins, as there org.eclipse.ui.editors is no longer touched by the patch.


> - in the editor code don't use getTextWidget().getBlockSelection() but call
> isColumnMode() instead

DONE.

> - some interfaces look strange/artificial to me (or at least needs better doc):
> org.eclipse.ui.texteditor.IDeleteLineTargetExtension.deleteLine(IDocument,
> ITextSelection, int, boolean)

OK - IDeleteLineTarget is not API anyway as its is package private. I removed IDeleteLineTargetExtension but left the public method in TextViewerDeleteLineTarget, clarifying the meaning of the passed selection.

> - Column Mode Font ==> Text (Editor) Column Mode Font

DONE.

> - XXX should TextSelection open its document to subclasses? */
>         ==> I think it's OK to make it protected

DONE.

> - access to widget in propertyChanged should be protected against being
> disposed
> - org.eclipse.jface.text.IColumnTextSelection.getRegions() and getText() look
> like helpers. Do we really need this in the interface?

getText(): only adds some doc stating the nature of the returned text - the method is declared on ITextSelection.

getRegions(): true, there are no clients so far. On the other side, typically clients want to know which document regions are covered by a selection. For linear selection, this information is provided by the offset / length pair, for column selection, we need to provide it somehow else.

> - org.eclipse.jface.text.SelectionProcessor: I'm declined to make this API. So
> far only two methods are used outside jface.text
>         ==> we could put the must-have methods into JFaceTextUtil for now

Hmmmm... there aren't any real clients. CaseAction uses it, but really only because of ITextSelection's ... well ... peculiar definition of emptyness. I only moved this to API in order to get around the errors. DONE: moved it back to internal and added two predicates to JFaceTextUtil.

> - replace outdated 3.3 occurrences with 3.5
> - icons: I assume you also see those as placeholders that we will repalce with
> icons from the designers

Certainly.

> - tool bar: Toogle Column Sel... ==> 'Enable Column Mode'
> - we no longer use hoverIcon
>         ==> remove from icons dir and from plugin.xml
> - as you already marked: some classes need Javadoc

DONE.

> - help doc is needed

Not done yet.
Comment 60 Dani Megert CLA 2009-01-06 06:39:04 EST
>Well, the risk is that some concrete editor may have some actions that
>implicitely expect a linear selection
I guess users (who explicitly switched to column mode) would then detect this and report a bug. The only thing we must have is a protected method where an editor can disable column mode if required.

Tom, given your latest patch, once bug 257237 is fixed I'd like to commit the current state and then work on the remaining issues one by one. Do you agree?
Comment 61 Tom Hofmann CLA 2009-01-06 07:34:04 EST
(In reply to comment #60)
> I guess users (who explicitly switched to column mode) would then detect this
> and report a bug. The only thing we must have is a protected method where an
> editor can disable column mode if required.

OK to make block selection an opt-out rather than opt-in feature.

> Tom, given your latest patch, once bug 257237 is fixed I'd like to commit the
> current state and then work on the remaining issues one by one. Do you agree?

+1 after that opt-out method is re-added. I'll also see if I can solve the undo/redo problems in an easy and transparent way, but I am fine with committing the current state so that early adopters can start to play.

Just noticed that the patch also contains quite some clean-up code adding final modifiers to fields... I will of course remove those before committing.

Comment 62 Dani Megert CLA 2009-01-07 02:56:51 EST
Tom, feel free to commit when ready. Just give me a heads up before to avoid conflicts.
Comment 63 Tom Hofmann CLA 2009-01-13 16:28:17 EST
Fixed > 20090113

I released the patch (attachment 121140 [details]) with minor modifications, most notably I re-added the protected method to AbstractTextEditor that allows sub-classes to opt-out of block selection switching.

I filed the following bugs to track the issues noted in comment 55:

- bug 260921: [typing] undo does not fold events in block selection mode
- bug 260922: [dnd] text drag and and drop does not work in block selection mode

The issue with modifications in whitespace beyond EOL is essentially covered by the SWT bugs #257237 and #21000.
Comment 64 Dani Megert CLA 2009-01-14 03:00:01 EST
Thanks again Tom!
Comment 65 Arno Unkrig CLA 2009-04-03 05:51:11 EDT
Hi Tom,

the column mode patch that one can install from http://tkilla.ch/column_mode appears to be broken all of a sudden -- I tried it both on a fresh 3.4.1 and a fresh 3.4.2 installation, and Alt+C does not work as before (where "before" means a few months ago).

Have you changed anything on the update site, or am I fooling myself? In my old 3.3M6 installation, Alt+C still works...

We need a solution urgently, because we're planning to update the entire software department to 3.4!


CU

Arno
Comment 66 Tom Hofmann CLA 2009-04-03 06:23:49 EDT
(In reply to comment #65)
> the column mode patch that one can install from http://tkilla.ch/column_mode
> appears to be broken all of a sudden -- I tried it both on a fresh 3.4.1 and a
> fresh 3.4.2 installation, and Alt+C does not work as before (where "before"
> means a few months ago).
> 
> Have you changed anything on the update site, or am I fooling myself? In my old
> 3.3M6 installation, Alt+C still works...

Hi Arno, the binary patch provided by above site only works for 3.4, not for 3.4.1 or 3.4.2. There is a testing version for 3.4.1 (but again not 3.4.2) available from http://tkilla.ch/column_mode/test.

Porting the code to 3.4.2 is trivial, however, providing an update site that works for all 3.4.x versions at the same time is challenging given some Eclipse P2 ... well ... characteristics.

Given the fact that column mode made it into 3.5, I don't feel too inclined to invest much time into the 3.4 patching effort.
Comment 67 Arno Unkrig CLA 2009-04-03 09:22:07 EDT
> Hi Arno, the binary patch provided by above site only works for 3.4, not for
> 3.4.1 or 3.4.2. There is a testing version for 3.4.1 (but again not 3.4.2)
> available from http://tkilla.ch/column_mode/test.

Thanks for the info! However, both patches are compiled with a JDK 1.6 compiler, and thus don't run in an 1.5 JRE :-( We're currently bound at an (IBM) 1.5.0 JDK... I assume you're not really inclined to recompile the 3.4.1 patch with an 1.4 or 1.5 compiler?


CU

Arno