Commit 30dd90d3 authored by Alexander Weigl's avatar Alexander Weigl

fix show marker hightlighting and context menü

parent aa630358
Pipeline #11979 failed with stage
in 1 minute and 29 seconds
...@@ -5,10 +5,7 @@ import org.antlr.v4.runtime.Token; ...@@ -5,10 +5,7 @@ import org.antlr.v4.runtime.Token;
import org.fxmisc.richtext.model.StyleSpans; import org.fxmisc.richtext.model.StyleSpans;
import org.fxmisc.richtext.model.StyleSpansBuilder; import org.fxmisc.richtext.model.StyleSpansBuilder;
import java.util.Collection; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
/** /**
...@@ -33,7 +30,8 @@ public class ANTLR4LexerHighlighter { ...@@ -33,7 +30,8 @@ public class ANTLR4LexerHighlighter {
tokens.forEach(token -> { tokens.forEach(token -> {
String clazz = lexer.getVocabulary().getSymbolicName(token.getType()); String clazz = lexer.getVocabulary().getSymbolicName(token.getType());
Set<String> clazzes = Collections.singleton(clazz); Set<String> clazzes = new HashSet<>();
clazzes.add(clazz);
//System.out.format("%25s %s%n", clazz, token.getText()); //System.out.format("%25s %s%n", clazz, token.getText());
spansBuilder.add( spansBuilder.add(
clazzes, clazzes,
......
...@@ -22,6 +22,7 @@ import javafx.geometry.Insets; ...@@ -22,6 +22,7 @@ import javafx.geometry.Insets;
import javafx.geometry.Point2D; import javafx.geometry.Point2D;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.input.ContextMenuEvent;
import javafx.scene.input.MouseButton; import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*; import javafx.scene.layout.*;
...@@ -114,6 +115,8 @@ public class ScriptArea extends CodeArea { ...@@ -114,6 +115,8 @@ public class ScriptArea extends CodeArea {
highlightNonExecutionArea(); highlightNonExecutionArea();
}); });
markedRegions.addListener((InvalidationListener) o -> updateHighlight()); markedRegions.addListener((InvalidationListener) o -> updateHighlight());
/* .successionEnds(Duration.ofMillis(100)) /* .successionEnds(Duration.ofMillis(100))
...@@ -138,11 +141,17 @@ public class ScriptArea extends CodeArea { ...@@ -138,11 +141,17 @@ public class ScriptArea extends CodeArea {
}); });
mainScript.addListener((observable) -> updateMainScriptMarker()); mainScript.addListener((observable) -> updateMainScriptMarker());
} }
private void highlightNonExecutionArea() { private void highlightNonExecutionArea() {
if (hasExecutionMarker()) { if (hasExecutionMarker()) {
setStyle(0, getExecutionMarkerPosition(), Collections.singleton("NON_EXE_AREA")); getStyleSpans(0, getExecutionMarkerPosition()).forEach(span -> {
span.getStyle().add("NON_EXE_AREA");
});
//setStyle(0, getExecutionMarkerPosition(), Collections.singleton("NON_EXE_AREA"));
} }
} }
...@@ -172,7 +181,9 @@ public class ScriptArea extends CodeArea { ...@@ -172,7 +181,9 @@ public class ScriptArea extends CodeArea {
} }
markedRegions.forEach(reg -> { markedRegions.forEach(reg -> {
setStyle(reg.start, reg.stop, Collections.singleton(reg.clazzName)); Collection<String> list = new HashSet<>();
list.add(reg.clazzName);
setStyle(reg.start, reg.stop, list);
}); });
} }
...@@ -237,8 +248,10 @@ public class ScriptArea extends CodeArea { ...@@ -237,8 +248,10 @@ public class ScriptArea extends CodeArea {
problems.setAll(ls.check(Facade.getAST(CharStreams.fromString(getText())))); problems.setAll(ls.check(Facade.getAST(CharStreams.fromString(getText()))));
for (LintProblem p : problems) { for (LintProblem p : problems) {
for (Token tok : p.getMarkTokens()) { for (Token tok : p.getMarkTokens()) {
Set<String> problem = new HashSet<>();
problem.add("problem");
setStyle(tok.getStartIndex(), setStyle(tok.getStartIndex(),
tok.getStopIndex() + 1, Collections.singleton("problem")); tok.getStopIndex() + 1, problem);
} }
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -300,8 +313,11 @@ public class ScriptArea extends CodeArea { ...@@ -300,8 +313,11 @@ public class ScriptArea extends CodeArea {
return list; return list;
} }
private void showBreakPointMenu(MouseEvent event, int line) { private void showBreakPointMenu(ContextMenuEvent event, int line) {
event.consume();
PopOver d = new PopOver(); PopOver d = new PopOver();
d.setStyle("-fx-font-family:sans-serif; -fx-font-size:9pt");
//d.initStyle(StageStyle.UNDECORATED); //d.initStyle(StageStyle.UNDECORATED);
// d.setX(event.getScreenX()); // d.setX(event.getScreenX());
//d.setY(event.getScreenY()); //d.setY(event.getScreenY());
...@@ -527,6 +543,7 @@ public class ScriptArea extends CodeArea { ...@@ -527,6 +543,7 @@ public class ScriptArea extends CodeArea {
public BreakpointDialog() { public BreakpointDialog() {
Utils.createWithFXML(this); Utils.createWithFXML(this);
getStyleClass().add("breakpoint-menu");
} }
public void save(ActionEvent e) { public void save(ActionEvent e) {
...@@ -579,10 +596,13 @@ public class ScriptArea extends CodeArea { ...@@ -579,10 +596,13 @@ public class ScriptArea extends CodeArea {
GutterView hbox = new GutterView(model); GutterView hbox = new GutterView(model);
model.textProperty().bind(formatted); model.textProperty().bind(formatted);
hbox.setOnContextMenuRequested(mevent ->
showBreakPointMenu(mevent, idx)
);
hbox.setOnMouseClicked((mevent) -> { hbox.setOnMouseClicked((mevent) -> {
if (mevent.getButton() == MouseButton.SECONDARY) mevent.consume();
showBreakPointMenu(mevent, idx); if (mevent.getButton() == MouseButton.PRIMARY)
else
toggleBreakpoint(idx); toggleBreakpoint(idx);
}); });
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<?import de.jensd.fx.glyphs.materialdesignicons.*?> <?import de.jensd.fx.glyphs.materialdesignicons.*?>
<?import edu.kit.formal.gui.controls.DebuggerStatusBar?> <?import edu.kit.formal.gui.controls.DebuggerStatusBar?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.input.KeyCodeCombination?>
<?import javafx.scene.layout.BorderPane?> <?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import org.dockfx.DockPane?> <?import org.dockfx.DockPane?>
...@@ -38,17 +39,16 @@ ...@@ -38,17 +39,16 @@
<menus> <menus>
<Menu fx:id="fileMenu" text="File"> <Menu fx:id="fileMenu" text="File">
<items> <items>
<MenuItem fx:id="newScriptMenuItem" onAction="#newScript" text="New Script"/> <MenuItem fx:id="newScriptMenuItem" onAction="#newScript" text="_New Script" accelerator="Shortcut+n"/>
<MenuItem fx:id="openScriptFileMenuItem" onAction="#openScript" text="_Open Script" accelerator="Shortcut+o"/>
<MenuItem fx:id="openScriptFileMenuItem" onAction="#openScript" text="Open Script"/>
<SeparatorMenuItem/> <SeparatorMenuItem/>
<MenuItem fx:id="loadKeYFileMenuItem" onAction="#loadKeYFile" text="Load KeY File"/> <MenuItem fx:id="loadKeYFileMenuItem" onAction="#loadKeYFile" text="Load _KeY File" accelerator="Shortcut+Alt+o"/>
<MenuItem fx:id="loadJavaFileMenuItem" onAction="#loadJavaFile" text="Load Java File"/> <MenuItem fx:id="loadJavaFileMenuItem" onAction="#loadJavaFile" text="Load _Java File" accelerator="Shortcut+Shift+o"/>
<SeparatorMenuItem/> <SeparatorMenuItem/>
<MenuItem onAction="#saveScript" text="Save Script"/> <MenuItem onAction="#saveScript" text="_Save Script" accelerator="Shortcut+s"/>
<MenuItem onAction="#saveAsScript" text="Save Script As ..."/> <MenuItem onAction="#saveAsScript" text="Save Script _As ..." accelerator="Shortcut+Shift+s"/>
<MenuItem onAction="#saveProof" text="Save Proof"/> <MenuItem onAction="#saveProof" text="_Save Proof" accelerator="Shortcut+Alt+s"/>
<MenuItem fx:id="closeMenuItem" onAction="#closeProgram" text="Close"/> <MenuItem fx:id="closeMenuItem" onAction="#closeProgram" text="_Close" accelerator="Shortcut+q"/>
</items> </items>
</Menu> </Menu>
<Menu text="Edit"> <Menu text="Edit">
......
...@@ -126,6 +126,13 @@ ...@@ -126,6 +126,13 @@
} }
.breakpoint-menu {
-fx-skin: "com.sun.javafx.scene.control.skin.ContextMenuSkin";
-fx-font-family: sans-serif;
-fx-font-size: 9pt;
}
.java-area { .java-area {
-fx-background-color: @base3; -fx-background-color: @base3;
-fx-font-family: "Fira Code Medium", monospace; -fx-font-family: "Fira Code Medium", monospace;
......
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