diff --git a/Frontend Angular 4/src/app/layout/matefun/codemirror/function_definition.js b/Frontend Angular 4/src/app/layout/matefun/codemirror/function_definition.js deleted file mode 100644 index 4874252033038024acfaabbf587d090fc910279e..0000000000000000000000000000000000000000 --- a/Frontend Angular 4/src/app/layout/matefun/codemirror/function_definition.js +++ /dev/null @@ -1,10 +0,0 @@ - - -module.exports = { - Completion: function(cm, options) { - return Completion(cm, options); - }, - parseOptions: function(cm, pos, options) { - return parseOptions(cm, pos, options); - } -} diff --git a/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-EN.js b/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-EN.js index 6e5aefc0f50c1297f25fc8968453fd18d613fcc8..1a52ef5c39a96a40eee46c80c4e359dfed69d3df 100644 --- a/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-EN.js +++ b/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-EN.js @@ -28,7 +28,6 @@ const hintWords = require('./hint_words'); var HINT_ELEMENT_CLASS = "CodeMirror-hint"; - var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active"; var mac = /Mac/.test(navigator.platform); function parseOptions(cm, pos, options) { @@ -43,7 +42,8 @@ return out; } - function Completion(cm, options) { + function Completion(cm, options, filename) { + this.filename = filename; this.cm = cm; this.options = options; this.widget = null; @@ -200,18 +200,22 @@ var completions = data.list; for (var i = 0; i < completions.length; ++i) { var elt = hints.appendChild(ownerDocument.createElement("li")), cur = completions[i]; - var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS); + var className = HINT_ELEMENT_CLASS; if (cur.className != null) className = cur.className + " " + className; elt.className = className; if (cur.render) cur.render(elt, data, cur); - else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur))); + else { + var rexp_name = new RegExp(/(.*\:\:)(.*)/.source, "g"); + var m = rexp_name.exec(cur.displayText || getText(cur)); + var b_elem = ownerDocument.createElement("b"); + b_elem.appendChild(ownerDocument.createTextNode(completion.filename + '.' + m[1])); + elt.appendChild(b_elem); + elt.appendChild(ownerDocument.createTextNode(m[2])); + } elt.hintId = i; } var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null); - var left = pos.left, top = pos.bottom, below = true; - hints.style.left = left + "px"; - hints.style.top = top + "px"; // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor. var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth); var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight); @@ -220,20 +224,20 @@ var scrolls = hints.scrollHeight > hints.clientHeight + 1 var startScroll = cm.getScrollInfo(); - if (overlapY > 0) { - var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top); - if (curTop - height > 0) { // Fits above cursor - hints.style.top = (top = pos.top - height) + "px"; - below = false; - } else if (height > winH) { - hints.style.height = (winH - 5) + "px"; - hints.style.top = (top = pos.bottom - box.top) + "px"; - var cursor = cm.getCursor(); - if (data.from.ch != cursor.ch) { - pos = cm.cursorCoords(cursor); - hints.style.left = (left = pos.left) + "px"; - box = hints.getBoundingClientRect(); - } + var height = box.bottom - box.top; + var left = pos.left - 1; + hints.style.left = left + "px"; + hints.style.top = (pos.top - height) + "px"; + var below = false; + + if (overlapY > 0 && height > winH) { + hints.style.height = (winH - 5) + "px"; + hints.style.top = (top = pos.bottom - box.top) + "px"; + var cursor = cm.getCursor(); + if (data.from.ch != cursor.ch) { + pos = cm.cursorCoords(cursor); + hints.style.left = (left = pos.left) + "px"; + box = hints.getBoundingClientRect(); } } var overlapX = box.right - winW; @@ -274,16 +278,11 @@ }); CodeMirror.on(hints, "dblclick", function(e) { - var t = getHintElement(hints, e.target || e.srcElement); - if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();} + completion.close(); }); CodeMirror.on(hints, "click", function(e) { - var t = getHintElement(hints, e.target || e.srcElement); - if (t && t.hintId != null) { - widget.changeActive(t.hintId); - if (completion.options.completeOnSingleClick) widget.pick(); - } + completion.close(); }); CodeMirror.on(hints, "mousedown", function() { @@ -415,7 +414,7 @@ hint: CodeMirror.hint.auto, completeSingle: true, alignWithWord: true, - closeCharacters: /[\s()\[\]{};:>,]/, + closeCharacters: /./, closeOnUnfocus: true, completeOnSingleClick: true, container: null, @@ -439,10 +438,10 @@ // functions definitions - CodeMirror.defineExtension("functionDefinition", function(options) { + CodeMirror.defineExtension("functionDefinition", function(filename, options) { options = parseOptions(this, this.getCursor("start"), options); if (this.state.completionActive) this.state.completionActive.close(); - var completion = this.state.completionActive = new Completion(this, options); + var completion = this.state.completionActive = new Completion(this, options, filename); //if (!completion.options.hint) return; CodeMirror.signal(this, "startFunctionDefinition", this); diff --git a/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts b/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts index 7402447ea383f3367fe1dbbe67f7e976d7129874..153d449e000062b7bf31916adbf57df4f6a96369 100755 --- a/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts +++ b/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts @@ -457,7 +457,7 @@ export class MateFunComponent { } clickEnEditor(event){ - this.codemirror.instance.functionDefinition(this.codemirror.instance.doc, event); + this.codemirror.instance.functionDefinition(this.archivo.nombre, this.codemirror.instance.doc, event); } guardarArchivo(){