Commit 42cdb545 authored by Sarah Grebing's avatar Sarah Grebing

line highlighting preparation

parent 0efab96a
Pipeline #11258 failed with stage
in 2 minutes and 27 seconds
......@@ -234,6 +234,9 @@ public class DebuggerMainWindowController implements Initializable {
}
blocker.install(currentInterpreter);
System.out.println("Start of Script in: " + scripts.get(0).getStartPosition());
tabPane.getActiveScriptAreaTab().getScriptArea().setDebugMark(scripts.get(0).getStartPosition().getLineNumber());
interpreterService.interpreter.set(currentInterpreter);
interpreterService.mainScript.set(scripts.get(0));
interpreterService.start();
......@@ -416,6 +419,12 @@ public class DebuggerMainWindowController implements Initializable {
return executeNotPossible;
}
public void stopDebugMode(ActionEvent actionEvent) {
//linenumberMainscript from model?
// tabPane.getActiveScriptAreaTab().getScriptArea().removeHighlightStmt(lineNumberMainScript);
//inspectionViewTabPane.getInspectionViewTab.clear();
}
public class ContractLoaderService extends Service<List<Contract>> {
@Override
protected Task<List<Contract>> createTask() {
......
......@@ -100,7 +100,9 @@ public class InspectionViewTab extends Tab implements Initializable {
@Override
public void initialize(URL location, ResourceBundle resources) {
getGoalView().getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
getSequentView().setNode(newValue.getData().getNode());
if (newValue != null && newValue.getData() != null) {
getSequentView().setNode(newValue.getData().getNode());
}
});
getGoalView().setCellFactory(GoalNodeListCell::new);
......
......@@ -54,6 +54,7 @@ public class ScriptArea extends CodeArea {
* Lines to highlight?
*/
private ObservableSet<Integer> markedLines = FXCollections.observableSet();
private GutterFactory gutter;
private ANTLR4LexerHighlighter highlighter;
private ListProperty<LintProblem> problems = new SimpleListProperty<>(FXCollections.observableArrayList());
......@@ -187,20 +188,44 @@ public class ScriptArea extends CodeArea {
/**
* Highlight line given by the characterindex
*
* @param chrIdx
* @param lineNumber
*/
public void highlightLine(int chrIdx) {
public void highlightStmt(int lineNumber, String cssStyleTag) {
//calculate line number from characterindex
int lineNumber = this.offsetToPosition(chrIdx, Bias.Forward).getMajor();
//int lineNumber = this.offsetToPosition(chrIdx, Bias.Forward).getMajor();
Paragraph<Collection<String>, StyledText<Collection<String>>, Collection<String>> paragraph = this.getParagraph(lineNumber);
//calculate start and endposition
int startPos = getAbsolutePosition(this.offsetToPosition(chrIdx, Bias.Forward).getMajor(), 0);
//int startPos = getAbsolutePosition(this.offsetToPosition(chrIdx, Bias.Forward).getMajor(), 0);
int startPos = getAbsolutePosition(lineNumber, 0);
int length = paragraph.length();
//highlight line
this.setStyle(startPos, startPos + length, Collections.singleton("line-highlight-postmortem"));
this.setStyle(startPos, startPos + length, Collections.singleton(cssStyleTag));
}
/**
* Remove the highlighting of a statement
*
* @param lineNumber
*/
public void removeHighlightStmt(int lineNumber) {
highlightStmt(lineNumber, "line-unhighlight");
}
/**
* Set a mark in the gutter next to the definition of the main script
*
* @param lineNumberOfSigMainScript
*/
public void setDebugMark(int lineNumberOfSigMainScript) {
highlightStmt(lineNumberOfSigMainScript - 1, "line-highlight-mainScript");
}
public void unsetDebugMark(int lineNumberOfSigMainScript) {
removeHighlightStmt(lineNumberOfSigMainScript - 1);
}
......@@ -299,7 +324,8 @@ public class ScriptArea extends CodeArea {
ScriptArea area = (ScriptArea) cm.getOwnerNode();
int chrIdx = currentIdx.get().getCharacterIndex().orElse(0);
if (chrIdx != 0) {
area.highlightLine(chrIdx);
int lineNumber = area.offsetToPosition(chrIdx, Bias.Forward).getMajor();
area.highlightStmt(lineNumber, "line-highlight-postmortem");
}
});
......
......@@ -89,7 +89,7 @@
</tooltip>
</Button>
<Button disable="${! controller.debugMode}">
<Button onAction="#stopDebugMode" disable="${! controller.debugMode}">
<graphic>
<MaterialDesignIconView glyphName="STOP" size="24.0"/>
</graphic>
......
......@@ -83,6 +83,15 @@
.line-highlight-postmortem{
-rtfx-background-color: @blue;
}
.line-unhighlight{
-fx-background-color: @base3;
}
.line-highlight-mainScript{
-rtfx-background-color: @green;
}
}
/**********************************************************************************************************************/
......
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