Commit 011238a3 authored by Robert Zenz's avatar Robert Zenz

Removed test code and added documentation.

parent 9535b57d
......@@ -40,55 +40,32 @@ public class ScrollingCaretListener implements CaretListener, MouseListener {
*/
@Override
public void caretMoved(CaretEvent event) {
// Display.getDefault().asyncExec(new Runnable() {
//
// @Override
// public void run() {
System.out.println("move");
Scroller.scroll(textViewer, mouseDown);
// }
// });
}
/**
* {@inheritDoc}
*/
@Override
public void mouseDoubleClick(MouseEvent e) {
// Not needed.
}
/**
* {@inheritDoc}
*/
@Override
public void mouseDown(MouseEvent e) {
mouseDown = true;
}
//
// @Override
// public void mouseEnter(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mouseExit(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mouseHover(MouseEvent e) {
// // TODO Auto-generated method stub
// System.out.println(e.button);
// }
//
/**
* {@inheritDoc}
*/
@Override
public void mouseUp(MouseEvent e) {
mouseDown = false;
Scroller.scroll(textViewer, mouseDown);
}
// @Override
// public void mouseMove(MouseEvent e) {
// // TODO Auto-generated method stub
// System.out.println(e.stateMask);
// }
}
......@@ -13,10 +13,14 @@ import org.bonsaimind.scrolloffset.Activator;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.swt.custom.StyledText;
/**
* {@link Scroller} is the main class which knows how to scroll.
*/
public class Scroller {
/** If the scrolling offset is enabled. */
private static boolean enabled = true;
/** The offset in lines. */
private static int offset = 10;
static {
......@@ -30,6 +34,12 @@ public class Scroller {
// Nothing to do, no instancing.
}
/**
* Performs the scroll.
*
* @param textViewer The {@link ITextViewer} to scroll.
* @param mouseDown If the mouse is currently pressed.
*/
public static final void scroll(ITextViewer textViewer, boolean mouseDown) {
if (!enabled) {
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment