Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java11
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java12
2 files changed, 16 insertions, 7 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java
index d0133df46..237beb772 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java
@@ -1705,4 +1705,15 @@ public class StyledTextArea extends Control {
public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() {
return getClassCssMetaData();
}
+
+ /**
+ * navigates to specified line
+ * @param lineIndex
+ */
+ public void navigateToLine(int lineIndex) {
+ if (lineIndex >= 0 && lineIndex <= getContent().getLineCount()) {
+ int offset = getContent().getOffsetAtLine(lineIndex);
+ setCaretOffset(offset);
+ }
+ }
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
index 2f25be6c5..8cb7f9059 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
@@ -1025,10 +1025,7 @@ public class StyledTextBehavior {
}
protected void defaultNavigateToLine(int lineIndex) {
- if (lineIndex >= 0 && lineIndex <= getControl().getContent().getLineCount()) {
- int offset = getControl().getContent().getOffsetAtLine(lineIndex);
- getControl().setCaretOffset(offset);
- }
+ getControl().navigateToLine(lineIndex);
}
@@ -1403,6 +1400,8 @@ public class StyledTextBehavior {
keyMapping.mapKey(new KeyCombo(D, MetaKey), this.ACTION_DELETE_LINE);
keyMapping.mapKey(new KeyCombo(UP, AltKey), this.ACTION_MOVE_LINES_UP);
keyMapping.mapKey(new KeyCombo(DOWN, AltKey), this.ACTION_MOVE_LINES_DOWN);
+
+ keyMapping.mapKey(new KeyCombo(KeyCode.L, MetaKey), this.ACTION_NAVIGATE_TO_LINE);
} else {
keyMapping.mapKey(new KeyCombo(RIGHT, ControlKey), this.ACTION_NAVIGATE_WORD_NEXT);
keyMapping.mapKey(new KeyCombo(LEFT, ControlKey), this.ACTION_NAVIGATE_WORD_PREVIOUS);
@@ -1437,6 +1436,8 @@ public class StyledTextBehavior {
keyMapping.mapKey(new KeyCombo(UP, AltKey), this.ACTION_MOVE_LINES_UP);
keyMapping.mapKey(new KeyCombo(DOWN, AltKey), this.ACTION_MOVE_LINES_DOWN);
+ keyMapping.mapKey(new KeyCombo(KeyCode.L, ControlKey), this.ACTION_NAVIGATE_TO_LINE);
+
}
keyMapping.mapKey(new KeyCombo(TAB), this.ACTION_INDENT, this::isMultilineSelection);
@@ -1459,9 +1460,6 @@ public class StyledTextBehavior {
// action for insert tab support
keyMapping.mapKey(new KeyCombo(TAB), () -> getControl().insert("\t")); //$NON-NLS-1$
-
-
- keyMapping.mapKey(new KeyCombo(KeyCode.L, ControlKey), this.ACTION_NAVIGATE_TO_LINE);
}
// /**

Back to the top