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;
}
function highlightExecution(documentId, location) {
function highlightExecution(documentId, location)
{
var editor = getEditor(documentId);
if (editor)
{
@ -81,15 +81,12 @@ Item {
// Execution is not in the current document. Try:
// 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)
{
var editor = getEditor(currentDocumentId);
if (editor)
{
var sourceIndex = editor.getText().indexOf(sourceName);
highlightExecution(currentDocumentId, { start: sourceIndex, end: sourceIndex + sourceName.length, sourceName: currentDocumentId });
}
editor.showWarning(qsTr("Currently debugging in " + sourceName + ". Source not available."));
}
function editingContract() {

5
mix/qml/WebCodeEditor.qml

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

16
mix/qml/html/codeeditor.js

@ -134,6 +134,8 @@ highlightExecution = function(start, end) {
executionMark.clear();
if (start === 0 && end + 1 === editor.getValue().length)
return; // Do not hightlight the whole document.
if (debugWarning)
debugWarning.clear();
executionMark = editor.markText(editor.posFromIndex(start), editor.posFromIndex(end), { className: "CodeMirror-exechighlight" });
}
@ -148,6 +150,20 @@ isClean = function()
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 compilationCompleteBool = true;
compilationError = function(line, column, content)

Loading…
Cancel
Save