mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 19:02:13 +07:00
IDEA-86461 Mouse wheel tilt doesn't scroll horizontally
'Scroll left' and 'Scroll right' actions have been added
This commit is contained in:
+8
-2
@@ -75,15 +75,21 @@ public class EditorActionUtil {
|
||||
* Tries to change given editor's viewport position in vertical dimension by the given number of visual lines.
|
||||
*
|
||||
* @param editor target editor which viewport position should be changed
|
||||
* @param lineShift defines viewport position's change length
|
||||
* @param lineShift defines viewport position's vertical change length
|
||||
* @param columnShift defines viewport position's horizontal change length
|
||||
* @param moveCaret flag that identifies whether caret should be moved if its current position becomes off-screen
|
||||
*/
|
||||
public static void scrollRelatively(Editor editor, int lineShift, boolean moveCaret) {
|
||||
public static void scrollRelatively(Editor editor, int lineShift, int columnShift, boolean moveCaret) {
|
||||
if (lineShift != 0) {
|
||||
editor.getScrollingModel().scrollVertically(
|
||||
editor.getScrollingModel().getVerticalScrollOffset() + lineShift * editor.getLineHeight()
|
||||
);
|
||||
}
|
||||
if (columnShift != 0) {
|
||||
editor.getScrollingModel().scrollHorizontally(
|
||||
editor.getScrollingModel().getHorizontalScrollOffset() + columnShift * EditorUtil.getSpaceWidth(Font.PLAIN, editor)
|
||||
);
|
||||
}
|
||||
|
||||
if (!moveCaret) {
|
||||
return;
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class ScrollDownAction extends InactiveEditorAction {
|
||||
private static class Handler extends EditorActionHandler {
|
||||
@Override
|
||||
public void execute(Editor editor, DataContext dataContext) {
|
||||
EditorActionUtil.scrollRelatively(editor, 1, false);
|
||||
EditorActionUtil.scrollRelatively(editor, 1, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class ScrollDownAndMoveAction extends InactiveEditorAction {
|
||||
private static class Handler extends EditorActionHandler {
|
||||
@Override
|
||||
public void execute(Editor editor, DataContext dataContext) {
|
||||
EditorActionUtil.scrollRelatively(editor, 1, true);
|
||||
EditorActionUtil.scrollRelatively(editor, 1, 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.editor.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 5/25/12 9:26 AM
|
||||
*/
|
||||
public class ScrollLeftAction extends InactiveEditorAction {
|
||||
public ScrollLeftAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
@Override
|
||||
public void execute(Editor editor, DataContext dataContext) {
|
||||
EditorActionUtil.scrollRelatively(editor, 0, -1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.editor.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 5/25/12 9:25 AM
|
||||
*/
|
||||
public class ScrollRightAction extends InactiveEditorAction {
|
||||
|
||||
public ScrollRightAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
@Override
|
||||
public void execute(Editor editor, DataContext dataContext) {
|
||||
EditorActionUtil.scrollRelatively(editor, 0, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class ScrollUpAction extends InactiveEditorAction {
|
||||
private static class Handler extends EditorActionHandler {
|
||||
@Override
|
||||
public void execute(Editor editor, DataContext dataContext) {
|
||||
EditorActionUtil.scrollRelatively(editor, -1, false);
|
||||
EditorActionUtil.scrollRelatively(editor, -1, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class ScrollUpAndMoveAction extends InactiveEditorAction {
|
||||
private static class Handler extends EditorActionHandler {
|
||||
@Override
|
||||
public void execute(Editor editor, DataContext dataContext) {
|
||||
EditorActionUtil.scrollRelatively(editor, -1, true);
|
||||
EditorActionUtil.scrollRelatively(editor, -1, 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,8 @@ action.EditorScrollUp.text=Scroll Up
|
||||
action.EditorScrollDown.text=Scroll Down
|
||||
action.EditorScrollUpAndMove.text=Scroll Up and Move if Necessary
|
||||
action.EditorScrollDownAndMove.text=Scroll Down and Move if Necessary
|
||||
action.EditorScrollLeft.text=Scroll Left
|
||||
action.EditorScrollRight.text=Scroll Right
|
||||
action.EditorScrollTop.text=Scroll to Top
|
||||
action.EditorScrollBottom.text=Scroll to Bottom
|
||||
action.EditorMoveUpAndScroll.text=Move Up and Scroll
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
<action id="EditorScrollDown" class="com.intellij.openapi.editor.actions.ScrollDownAction"/>
|
||||
<action id="EditorScrollUpAndMove" class="com.intellij.openapi.editor.actions.ScrollUpAndMoveAction"/>
|
||||
<action id="EditorScrollDownAndMove" class="com.intellij.openapi.editor.actions.ScrollDownAndMoveAction"/>
|
||||
<action id="EditorScrollRight" class="com.intellij.openapi.editor.actions.ScrollRightAction"/>
|
||||
<action id="EditorScrollLeft" class="com.intellij.openapi.editor.actions.ScrollLeftAction"/>
|
||||
<action id="EditorScrollTop" class="com.intellij.openapi.editor.actions.ScrollToTopAction"/>
|
||||
<action id="EditorScrollBottom" class="com.intellij.openapi.editor.actions.ScrollToBottomAction"/>
|
||||
<action id="EditorMoveUpAndScroll" class="com.intellij.openapi.editor.actions.MoveUpAndScrollAction"/>
|
||||
|
||||
Reference in New Issue
Block a user