diff options
author | Dani Megert | 2013-08-02 08:58:24 +0000 |
---|---|---|
committer | Dani Megert | 2013-08-02 08:58:24 +0000 |
commit | 534662c2faa5d7008dbad1354e7c432449719d1d (patch) | |
tree | 37f7bf98cf629bc76d41c9f81b646775e100b92f | |
parent | 1726a32434ee8a113d5ab8c3441987c7aa6fdf25 (diff) | |
download | eclipse.platform.text-534662c2faa5d7008dbad1354e7c432449719d1d.tar.gz eclipse.platform.text-534662c2faa5d7008dbad1354e7c432449719d1d.tar.xz eclipse.platform.text-534662c2faa5d7008dbad1354e7c432449719d1d.zip |
CosmeticsI20130813-0800I20130807-2000I20130807-0800I20130806-2000I20130806-0800I20130805-2000I20130805-0800I20130804-2300
-rw-r--r-- | org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RecenterAction.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RecenterAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RecenterAction.java index 3bfd31a43c0..a576bac2f0d 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RecenterAction.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RecenterAction.java @@ -17,6 +17,7 @@ import org.eclipse.swt.custom.StyledText; import org.eclipse.jface.text.source.ISourceViewer; + /** * An action to handle emacs-like recenter. * This function scrolls the selected window to put the cursor at the middle/top/bottom of the screen. @@ -24,10 +25,12 @@ import org.eclipse.jface.text.source.ISourceViewer; * @since 3.3 */ public class RecenterAction extends TextEditorAction { + private static final int RECENTER_MIDDLE= 0; private static final int RECENTER_TOP= 1; private static final int RECENTER_BOTTOM= 2; private static final int RECENTER_POS_SIZE= 3; + private int fPrevOffset= -1; private int fDestPos; @@ -64,7 +67,7 @@ public class RecenterAction extends TextEditorAction { // compute the number of lines displayed int height= st.getClientArea().height; int lineHeight= st.getLineHeight(); - int rowPerScreen= height / lineHeight; + int rowsPerScreen= height / lineHeight; int caretOffset= st.getCaretOffset(); int caretLine= st.getLineAtOffset(caretOffset); @@ -79,13 +82,13 @@ public class RecenterAction extends TextEditorAction { int line= 0; switch (fDestPos) { case RECENTER_MIDDLE: - line= Math.max(0, (caretLine - rowPerScreen / 2)); + line= Math.max(0, (caretLine - rowsPerScreen / 2)); break; case RECENTER_TOP: line= caretLine; break; case RECENTER_BOTTOM: - line= Math.max(0, caretLine - rowPerScreen + 1); + line= Math.max(0, caretLine - rowsPerScreen + 1); break; default: break; |