本文整理汇总了Java中org.fxmisc.richtext.CodeArea.setOnKeyPressed方法的典型用法代码示例。如果您正苦于以下问题:Java CodeArea.setOnKeyPressed方法的具体用法?Java CodeArea.setOnKeyPressed怎么用?Java CodeArea.setOnKeyPressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fxmisc.richtext.CodeArea
的用法示例。
在下文中一共展示了CodeArea.setOnKeyPressed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GroovyEditorComponent
import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
/**
* Instantiates a new Groovy editor component.
*
* @param editable the editable
*/
public GroovyEditorComponent(final boolean editable) {
codeArea = new CodeArea();
codeArea.richChanges()
.filter(ch -> !ch.getInserted().equals(ch.getRemoved()))
.subscribe(change -> codeArea.setStyleSpans(0, getStyleSpans(codeArea.getText())));
codeArea.prefHeightProperty().bind(heightProperty());
codeArea.prefWidthProperty().bind(widthProperty());
codeArea.setEditable(editable);
codeArea.setOnKeyReleased(UIUtils::consumeIfIsNotHotKey);
codeArea.setOnKeyPressed(UIUtils::consumeIfIsNotHotKey);
FXUtils.addToPane(codeArea, this);
FXUtils.addClassesTo(this, CSSClasses.TEXT_EDITOR_TEXT_AREA, CSSClasses.GROOVY_EDITOR_COMPONENT);
}
示例2: FXMLTextArea
import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
public FXMLTextArea() {
codeArea = new CodeArea();
codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
codeArea.richChanges().subscribe(change -> {
codeArea.setStyleSpans(0, computeHighlighting(codeArea.getText()));
});
codeArea.selectionProperty().addListener((oba, oldval, newval) -> {
int start = newval.getStart();
int end = newval.getEnd();
int caretColumn = codeArea.getCaretColumn();
String format = String.format("line : %d selectionStart : %d selectionEnd : %d column : %d anchor : %d",
codeArea.getCurrentParagraph() + 1, start + 1, end + 1, caretColumn + 1, codeArea.getAnchor());
lblLineInfo.setText(format);
});
codeArea.setOnKeyPressed(this::codeAreaKeyClick);
lblLineInfo.setPrefHeight(USE_COMPUTED_SIZE);
lblLineInfo.setMinHeight(USE_COMPUTED_SIZE);
lblLineInfo.setMaxHeight(USE_COMPUTED_SIZE);
this.setCenter(codeArea);
this.setBottom(lblLineInfo);
// this.getChildren().add(codeArea);
this.getStylesheets().add(FXMLTextArea.class.getResource("java-keywords.css").toExternalForm());
}
示例3: initialize
import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
@FXML
public void initialize() {
codeArea = new CodeArea();
codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
codeArea.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
// Tab 없이 처리되는 클래스들도 있음....
DockTab tab2 = SimpleTextView.this.tab;
if (tab2 != null) {
if (tab2.getText().charAt(0) == '*') {
return;
}
String modifyTabName = "*".concat(tab2.getText());
tab2.setText(modifyTabName);
}
}
});
codeArea.setOnKeyPressed(ev -> {
if (ev.getCode() == KeyCode.S && ev.isControlDown()) {
if (ev.isConsumed())
return;
miSaveOnAction();
ev.consume();
} else if (ev.getCode() == KeyCode.N && ev.isControlDown()) {
if (ev.isConsumed())
return;
miNewOnAction();
ev.consume();
}
});
initHelpers();
initGraphics();
// miSaveAs.setAccelerator(new KeyCodeCombination(KeyCode.S,
// KeyCombination.CONTROL_DOWN));
}
示例4: SqlKeywords
import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
public SqlKeywords() {
codeArea = new CodeArea();
codeHelperDeligator = new SqlCodeAreaHelper(codeArea);
codeArea.appendText("");
codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
// codeArea.richChanges().subscribe(change -> {
// Platform.runLater(() -> {
// codeArea.setStyleSpans(0, computeHighlighting(codeArea.getText()));
//
// });
// });
codeArea.richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
.successionEnds(Duration.ofMillis(500)).supplyTask(this::computeHighlightingAsync).awaitLatest(codeArea.richChanges())
.filterMap(t -> {
if (t.isSuccess()) {
return Optional.of(t.get());
} else {
t.getFailure().printStackTrace();
return Optional.empty();
}
}).subscribe(this::applyHighlighting);
/**CodeArea 'Tab' Size handler *************************************************************/
//17.01.14 Deprecated
//codeArea.addEventHandler(KeyEvent.KEY_PRESSED, new CodeAreaTabSizeHandler(codeArea));
// 마우스 클릭이벤트 정의
codeArea.addEventHandler(KeyEvent.KEY_PRESSED, this::codeAreaKeyClick);
codeArea.setOnKeyPressed(this::codeAreaKeyClick);
//
// codeArea.setOnMouseClicked(defaultSelectionHandler);
// 선택라인정보 보여주는 기능 추가.
codeArea.selectionProperty().addListener((oba, oldval, newval) -> {
int start = newval.getStart();
int end = newval.getEnd();
int caretColumn = codeArea.getCaretColumn();
String format = String.format("line : %d selectionStart : %d selectionEnd : %d column : %d ",
codeArea.getCurrentParagraph() + 1, start + 1, end + 1, caretColumn + 1);
lblLineInfo.setText(format);
});
lblLineInfo.setPrefHeight(USE_COMPUTED_SIZE);
this.setCenter(codeArea);
this.setBottom(lblLineInfo);
// this.getChildren().add();
this.getStylesheets().add(SqlKeywords.class.getResource("java-keywords.css").toExternalForm());
}