Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Scroll to top on load.

Authordjarvis <email>
Date2017-10-12 22:46:13 GMT-0700
Commit1938ebd74074e3c00f3186f90f1d760a60745b78
Parent5160e2f
Delta25 lines added, 20 lines removed, 5-line increase
src/main/java/com/scrivenvar/editors/EditorPane.java
*/
public class EditorPane extends AbstractPane {
-
+
private StyleClassedTextArea editor;
private VirtualizedScrollPane<StyleClassedTextArea> scrollPane;
private final ObjectProperty<Path> path = new SimpleObjectProperty<>();
/**
* Set when entering variable edit mode; retrieved upon exiting.
*/
private InputMap<InputEvent> nodeMap;
-
+
@Override
public void requestFocus() {
Platform.runLater( () -> getEditor().requestFocus() );
}
-
+
public void undo() {
getUndoManager().undo();
}
-
+
public void redo() {
getUndoManager().redo();
public void findPrevious() {
}
-
+
public UndoManager getUndoManager() {
return getEditor().getUndoManager();
}
-
+
public String getText() {
return getEditor().getText();
}
-
+
public void setText( final String text ) {
getEditor().deselect();
* @param listener Receives editor text change events.
*/
- public void addTextChangeListener( final ChangeListener<? super String> listener ) {
+ public void addTextChangeListener(
+ final ChangeListener<? super String> listener ) {
getEditor().textProperty().addListener( listener );
}
return "org.fxmisc.wellbehaved.event.inputmap";
}
-
+
+ /**
+ * Repositions the cursor and scroll bar to the top of the file.
+ */
public void scrollToTop() {
getEditor().moveTo( 0 );
+ getScrollPane().scrollYToPixel( 0 );
}
-
- private void setEditor( StyleClassedTextArea textArea ) {
+
+ private void setEditor( final StyleClassedTextArea textArea ) {
this.editor = textArea;
}
-
+
public synchronized StyleClassedTextArea getEditor() {
if( this.editor == null ) {
setEditor( createTextArea() );
}
-
+
return this.editor;
}
this.scrollPane = createScrollPane();
}
-
+
return this.scrollPane;
}
-
+
protected VirtualizedScrollPane<StyleClassedTextArea> createScrollPane() {
final VirtualizedScrollPane<StyleClassedTextArea> pane
= new VirtualizedScrollPane<>( getEditor() );
pane.setVbarPolicy( ScrollPane.ScrollBarPolicy.ALWAYS );
-
+
return pane;
}
-
+
protected StyleClassedTextArea createTextArea() {
return new StyleClassedTextArea( false );
}
-
+
public Path getPath() {
return this.path.get();
}
-
+
public void setPath( final Path path ) {
this.path.set( path );
}
-
+
public ObjectProperty<Path> pathProperty() {
return this.path;