Dave Jarvis' Repositories

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

Accept autocomplete on pressing Enter.

Authordjarvis <email>
Date2016-11-18 18:41:31 GMT-0800
Commit43a4e37c40eb9f38439973fd52e93a0acf43f5ba
Parent98ed729
USAGE.Rmd
-# Introduction
-
-This document describes how to write documentation (technical or otherwise) using a one master copy and produce a variety of output formats, such as: HTML pages, PDFs, and EPUBs. What's more, the document provides an overview of how to use variables and--for the unintimidated--leverage the power of R, a programming language.
-
-# Software Requirements
-
-Install Java, ConTeXt, Pandoc, R, and Lib V8. Then install the R packages knitr, yaml, and devtools, and pluralize by running the following commands:
-
- sudo su -
- apt-get install default-jre
- apt-get install context
- apt-get install pandoc
- apt-get install r
- apt-get install libv8-dev
- r
- url <- "http://cran.us.r-project.org"
- install.packages('knitr', repos=url)
- install.packages('yaml', repos=url)
- install.packages('devtools', repos=url)
- devtools::install_github("hrbrmstr/pluralize")
-
-To exit R, press `Ctrl+d` or type `q()` followed by pressing `Enter`.
-
-The required software packages are installed.
-
-# Markdown
-
USAGE.md
+# Introduction
+
+This document describes how to write documentation (technical or otherwise) using a one master copy and produce a variety of output formats, such as: HTML pages, PDFs, and EPUBs. What's more, the document provides an overview of how to use variables and--for the unintimidated--leverage the power of R, a programming language.
+
+# Software Requirements
+
+Install Java, ConTeXt, Pandoc, R, and Lib V8. Then install the R packages knitr, yaml, and devtools, and pluralize by running the following commands:
+
+ sudo su -
+ apt-get install default-jre
+ apt-get install context
+ apt-get install pandoc
+ apt-get install r
+ apt-get install libv8-dev
+ r
+ url <- "http://cran.us.r-project.org"
+ install.packages('knitr', repos=url)
+ install.packages('yaml', repos=url)
+ install.packages('devtools', repos=url)
+ devtools::install_github("hrbrmstr/pluralize")
+
+To exit R, press `Ctrl+d` or type `q()` followed by pressing `Enter`.
+
+The required software packages are installed.
+
+# Markdown
+
src/main/java/com/scrivendor/FileEditor.java
}
- Tab getTab() {
- return this.tab;
- }
-
- Path getPath() {
- return this.path.get();
- }
-
- void setPath( Path path ) {
- this.path.set( path );
- }
-
- ObjectProperty<Path> pathProperty() {
- return this.path;
- }
-
- boolean isModified() {
- return this.modified.get();
- }
-
- ReadOnlyBooleanProperty modifiedProperty() {
- return this.modified.getReadOnlyProperty();
- }
-
- BooleanProperty canUndoProperty() {
- return this.canUndo;
- }
-
- BooleanProperty canRedoProperty() {
- return this.canRedo;
- }
-
private void updateTab() {
final Tab activeTab = getTab();
- final Path filePath = this.path.get();
+ final Path filePath = getPath();
activeTab.setText( (filePath != null) ? filePath.getFileName().toString() : Messages.get( "FileEditor.untitled" ) );
activeTab.setTooltip( (filePath != null) ? new Tooltip( filePath.toString() ) : null );
activeTab.setGraphic( isModified() ? new Text( "*" ) : null );
}
private void activated() {
final Tab activeTab = getTab();
-
+
if( activeTab.getTabPane() == null || !activeTab.isSelected() ) {
// Tab is closed or no longer active
return;
}
final MarkdownEditorPane editorPane = getEditorPane();
- editorPane.pathProperty().bind( path );
+ editorPane.pathProperty().bind( this.path );
if( activeTab.getContent() != null ) {
editorPane.requestFocus();
}
-
+
private void initUndoManager() {
final UndoManager undoManager = getUndoManager();
canUndo.bind( undoManager.undoAvailableProperty() );
canRedo.bind( undoManager.redoAvailableProperty() );
- }
-
- private UndoManager getUndoManager() {
- return getEditorPane().getUndoManager();
- }
-
- public <T extends Event, U extends T> void addEventListener(
- final EventPattern<? super T, ? extends U> event,
- final Consumer<? super U> consumer ) {
- getEditorPane().addEventListener( event, consumer );
- }
-
- public void addEventListener( final InputMap<InputEvent> map ) {
- getEditorPane().addEventListener( map );
- }
-
- public void removeEventListener( final InputMap<InputEvent> map ) {
- getEditorPane().removeEventListener( map );
}
void load() {
- final Path filePath = this.path.get();
+ final Path filePath = getPath();
if( filePath != null ) {
try {
- Files.write( path.get(), bytes );
+ Files.write( getPath(), bytes );
getEditorPane().getUndoManager().mark();
return true;
} catch( IOException ex ) {
final AlertService service = getAlertService();
final AlertMessage message = service.createAlertMessage(
Messages.get( "FileEditor.saveFailed.title" ),
Messages.get( "FileEditor.saveFailed.message" ),
- path.get(),
+ getPath(),
ex.getMessage()
);
final Alert alert = service.createAlertError( message );
alert.showAndWait();
return false;
}
+ }
+
+ Tab getTab() {
+ return this.tab;
+ }
+
+ Path getPath() {
+ return this.path.get();
+ }
+
+ void setPath( Path path ) {
+ this.path.set( path );
+ }
+
+ ObjectProperty<Path> pathProperty() {
+ return this.path;
+ }
+
+ boolean isModified() {
+ return this.modified.get();
+ }
+
+ ReadOnlyBooleanProperty modifiedProperty() {
+ return this.modified.getReadOnlyProperty();
+ }
+
+ BooleanProperty canUndoProperty() {
+ return this.canUndo;
+ }
+
+ BooleanProperty canRedoProperty() {
+ return this.canRedo;
+ }
+
+ private UndoManager getUndoManager() {
+ return getEditorPane().getUndoManager();
+ }
+
+ public <T extends Event, U extends T> void addEventListener(
+ final EventPattern<? super T, ? extends U> event,
+ final Consumer<? super U> consumer ) {
+ getEditorPane().addEventListener( event, consumer );
+ }
+
+ public void addEventListener( final InputMap<InputEvent> map ) {
+ getEditorPane().addEventListener( map );
+ }
+
+ public void removeEventListener( final InputMap<InputEvent> map ) {
+ getEditorPane().removeEventListener( map );
}
src/main/java/com/scrivendor/editor/VariableEditor.java
import static javafx.scene.input.KeyCode.AT;
import static javafx.scene.input.KeyCode.DIGIT2;
+import static javafx.scene.input.KeyCode.ENTER;
import static javafx.scene.input.KeyCode.MINUS;
import static javafx.scene.input.KeyCombination.SHIFT_DOWN;
case ENTER:
- // Fall through.
- stopEventCapture();
-
case PERIOD:
case RIGHT:
case END:
- conditionalAutocomplete();
+ // Stop at a leaf node, ENTER means accept.
+ if( conditionalAutocomplete() && keyCode == ENTER ) {
+ stopEventCapture();
+ }
break;
* in a word. If there is a selected range, then this will complete the most
* recent word and jump to the next child.
+ *
+ * @return true The auto-completed node was a terminal node.
*/
- private void conditionalAutocomplete() {
+ private boolean conditionalAutocomplete() {
acceptPath();
final TreeItem<String> node = getCurrentNode();
+ final boolean terminal = isTerminal( node );
- if( !isTerminal( node ) ) {
+ if( !terminal ) {
typed( SEPARATOR );
}
+
+ return terminal;
}
Delta96 lines added, 90 lines removed, 6-line increase