Browse Source

- warn user if source not available

cl-refactor
yann300 10 years ago
parent
commit
55e34ddade
  1. 11
      mix/qml/CodeEditorView.qml
  2. 5
      mix/qml/WebCodeEditor.qml
  3. 16
      mix/qml/html/codeeditor.js

11
mix/qml/CodeEditorView.qml

@ -67,8 +67,8 @@ Item {
return null; return null;
} }
function highlightExecution(documentId, location) { function highlightExecution(documentId, location)
{
var editor = getEditor(documentId); var editor = getEditor(documentId);
if (editor) if (editor)
{ {
@ -81,15 +81,12 @@ Item {
// Execution is not in the current document. Try: // Execution is not in the current document. Try:
// Open targeted document and hightlight (TODO) or // Open targeted document and hightlight (TODO) or
// Relevant hightlighting on the current document // Warn user that file is not available
function findAndHightlight(start, end, sourceName) function findAndHightlight(start, end, sourceName)
{ {
var editor = getEditor(currentDocumentId); var editor = getEditor(currentDocumentId);
if (editor) if (editor)
{ editor.showWarning(qsTr("Currently debugging in " + sourceName + ". Source not available."));
var sourceIndex = editor.getText().indexOf(sourceName);
highlightExecution(currentDocumentId, { start: sourceIndex, end: sourceIndex + sourceName.length, sourceName: currentDocumentId });
}
} }
function editingContract() { function editingContract() {

5
mix/qml/WebCodeEditor.qml

@ -45,6 +45,11 @@ Item {
editorBrowser.runJavaScript("highlightExecution(" + location.start + "," + location.end + ")"); editorBrowser.runJavaScript("highlightExecution(" + location.start + "," + location.end + ")");
} }
function showWarning(content) {
if (initialized)
editorBrowser.runJavaScript("showWarning('" + content + "')");
}
function getBreakpoints() { function getBreakpoints() {
return currentBreakpoints; return currentBreakpoints;
} }

16
mix/qml/html/codeeditor.js

@ -134,6 +134,8 @@ highlightExecution = function(start, end) {
executionMark.clear(); executionMark.clear();
if (start === 0 && end + 1 === editor.getValue().length) if (start === 0 && end + 1 === editor.getValue().length)
return; // Do not hightlight the whole document. return; // Do not hightlight the whole document.
if (debugWarning)
debugWarning.clear();
executionMark = editor.markText(editor.posFromIndex(start), editor.posFromIndex(end), { className: "CodeMirror-exechighlight" }); executionMark = editor.markText(editor.posFromIndex(start), editor.posFromIndex(end), { className: "CodeMirror-exechighlight" });
} }
@ -148,6 +150,20 @@ isClean = function()
return editor.isClean(changeId); return editor.isClean(changeId);
} }
var debugWarning = null;
showWarning = function(content)
{
if (executionMark)
executionMark.clear();
if (debugWarning)
debugWarning.clear();
var node = document.createElement("div");
node.id = "annotation"
node.innerHTML = content;
node.className = "CodeMirror-errorannotation-context";
debugWarning = editor.addLineWidget(0, node, { coverGutter: false, above: true });
}
var annotation = null; var annotation = null;
var compilationCompleteBool = true; var compilationCompleteBool = true;
compilationError = function(line, column, content) compilationError = function(line, column, content)

Loading…
Cancel
Save