| | import javafx.scene.control.Alert; |
| | import javafx.scene.control.Alert.AlertType; |
| | +import javafx.scene.control.SingleSelectionModel; |
| | +import javafx.scene.input.KeyCode; |
| | +import javafx.scene.input.KeyCombination; |
| | import javafx.scene.control.SplitPane; |
| | import javafx.scene.control.Tab; |
| | +import javafx.scene.control.TabPane; |
| | import javafx.scene.control.Tooltip; |
| | import javafx.scene.text.Text; |
| | import org.fxmisc.undo.UndoManager; |
| | +import org.fxmisc.wellbehaved.event.EventHandlerHelper; |
| | +import org.fxmisc.wellbehaved.event.EventPattern; |
| | import org.markdownwriterfx.editor.MarkdownEditorPane; |
| | import org.markdownwriterfx.preview.MarkdownPreviewPane; |
 |
| | tab.setTooltip((path != null) ? new Tooltip(path.toString()) : null); |
| | tab.setGraphic(isModified() ? new Text("*") : null); |
| | + } |
| | + |
| | + private void selectNextPreviousTab(int offset) { |
| | + TabPane tabPane = tab.getTabPane(); |
| | + SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel(); |
| | + |
| | + int selectIndex = selectionModel.getSelectedIndex() + offset; |
| | + if (selectIndex < 0) |
| | + selectionModel.selectLast(); |
| | + else if(selectIndex >= tabPane.getTabs().size()) |
| | + selectionModel.selectFirst(); |
| | + else |
| | + selectionModel.select(selectIndex); |
| | } |
| | |
 |
| | |
| | markdownEditorPane.installEditorShortcuts(mainWindow.getEditorShortcuts()); |
| | + markdownEditorPane.installEditorShortcuts(EventHandlerHelper |
| | + .on(EventPattern.keyPressed(KeyCode.TAB, KeyCombination.CONTROL_DOWN)).act(e -> selectNextPreviousTab(1)) |
| | + .on(EventPattern.keyPressed(KeyCode.TAB, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN)).act(e -> selectNextPreviousTab(-1)) |
| | + .create()); |
| | |
| | load(); |