Bug 270392 - [typing] Add ability to reverse the direction of the selection
Summary: [typing] Add ability to reverse the direction of the selection
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-29 14:50 EDT by Sandip Chitale CLA
Modified: 2019-09-06 16:05 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sandip Chitale CLA 2009-03-29 14:50:27 EDT
In a text widget such as StyledText the selection can be a forward or backward selection. What I mean by that is that the caret may be positioned at the beginning or at the end of the selection range. However sometimes one needs to move the caret to the other end of the selection to further extend it at that end. To do this one needs to be able to move the caret to the other end of the selection. This is similar to Eclipse's exchange-dot-and-mark command.

I know there is Set, Swap and Clear Mark commands but they do not seem to relate to selection.

Here is how the code may look like:

/**
* Reverses the direction of selection by moving the caret to the other
* end of the selection.
*/
void doReverseSelectionDirection() {
    // check if selection has reversed direction
    if (caretOffset == selection.x) {
        // Change the direction to forward
	setSelection(selection.x, selection.y);
    } else {
        // Change the direction to backward
        setSelection(selection.y, selection.x);
    }
}

Suggested action constant in org.eclipse.swt.custom.ST :

public static final int SELECT_REVERSE_DIRECTION = /* something platform specific that makes sense. CTRL+X CTRL+X in Emacs profile of Eclipse. */;
Comment 1 Sandip Chitale CLA 2009-03-29 14:52:10 EDT
Correcting the summary. 
Comment 2 Felipe Heidrich CLA 2009-03-30 10:29:48 EDT
No need for the StyledText itself to offer this feature. This can be easily implmenent on top of StyledText.

Maybe JFace-Text or Text is a better place to have this API.
Comment 3 Sandip Chitale CLA 2009-03-30 15:39:45 EDT
Moving the enhancement to suggested component.

IMHO this feature will be useful even at the StyledText widget level.
Comment 4 Eclipse Webmaster CLA 2019-09-06 16:05:00 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.