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 e25bbf542a1c14b1b7285e06d27876741ccbf6f7..cfb65f657cf311f341d0242b42b519b7b8085ecb 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 @@ -29,11 +29,11 @@ var WORD = /[\w$]+/; - var SET = /set\s*([\w\_\d]*?)\s*\=/; + var SET = /set\s+([\w\_\d]+)\s*\=/; var DOM = /\:\:/; - var FUNS = /([\w\_\d]*)\s*\:\:/; + var FUNS = /([\w\_\d]+)\s+\:\:/; var FUN = /([\w\_\d]+)\s*\(([\,\w\_\s\d]*)\)\s*\=/; - var ENUMS = /set\s*[\w\_\d]*\s*\=\s*\{(.*?)\}/; + var ENUMS = /set\s+[\w\_\d]+\s*\=\s*\{(.*?)\}/; var WRITING_SET = /set\s/; var WRITING_COMMENT = /\{\-/; @@ -49,17 +49,19 @@ var list = options && options.list || [], seen = {}; + var re_digits = new RegExp(/^\d+$/, "g"); + // not word = 'Enter' if (options.key == 'Enter'){ var previous_line = editor.getLine(cur.line - 1); var re_funs = new RegExp(FUNS.source, "g"), match; - if (previous_line && (match = re_funs.exec(previous_line))){ + if (previous_line && (match = re_funs.exec(previous_line)) && curLine == ""){ var previous_block = ""; for (var i = 0; i < cur.line; i++){ previous_block += editor.getLine(i) + '\n'; } var next_block = ""; - for (var i = cur.line + 1; i < editor.lastLine(); i++){ + for (var i = cur.line + 1; i <= editor.lastLine(); i++){ next_block += editor.getLine(i) + '\n'; } var file = previous_block + match[1] + ' ()'; @@ -87,7 +89,7 @@ var text = editor.getLine(line), m; while (m = re_sets.exec(text)) { if (line == cur.line && m[1] === curWord) continue; - if ((!curWord || m[1].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[1])) { + if (!re_digits.exec(m[1]) && (!curWord || m[1].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[1])) { seen[m[1]] = true; list.push(m[1]); } @@ -110,54 +112,65 @@ previous_block += editor.getLine(i) + '\n'; } previous_block += previous_part; - var re_fun = new RegExp(FUN.source, "g"), match, last_match; - while (match = re_fun.exec(previous_block)){ last_match = match }; - if (last_match){ - var vars = last_match[2].replace(/\s/g,'').split(','); - for (var i = 0; i < vars.length; i++) { - if ((!curWord || vars[i].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, vars[i])) { - seen[vars[i]] = true; - list.push(vars[i]); + + // no hint in variables + var hint = true; + var re_funs = new RegExp(FUNS.source, "g"), match_dom, last_match_dom; + while (match_dom = re_funs.exec(previous_block)){ last_match_dom = match_dom }; + if (last_match_dom){ + var re_current_fun = new RegExp(last_match_dom[1] + '\\s*\\($', "g"); + hint = !re_current_fun.exec(previous_part); + } + if (hint){ + var re_fun = new RegExp(FUN.source, "g"), match, last_match; + while (match = re_fun.exec(previous_block)){ last_match = match }; + if (last_match){ + var vars = last_match[2].replace(/\s/g,'').split(','); + for (var i = 0; i < vars.length; i++) { + if (!re_digits.exec(vars[i]) && (!curWord || vars[i].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, vars[i])) { + seen[vars[i]] = true; + list.push(vars[i]); + } } - } - // get enums - var re_enums = new RegExp(ENUMS.source, "g"); - for (var dir = -1; dir <= 1; dir += 2) { - var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir; - for (; line != endLine; line += dir) { - var text = editor.getLine(line), m; - while (m = re_enums.exec(text)) { - var enums = m[1].replace(/\s/g,'').split(','); - for (var i = 0; i < enums.length; i++) { - if ((!curWord || enums[i].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, enums[i])) { - seen[enums[i]] = true; - list.push(enums[i]); + // get enums + var re_enums = new RegExp(ENUMS.source, "g"); + for (var dir = -1; dir <= 1; dir += 2) { + var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir; + for (; line != endLine; line += dir) { + var text = editor.getLine(line), m; + while (m = re_enums.exec(text)) { + var enums = m[1].replace(/\s/g,'').split(','); + for (var i = 0; i < enums.length; i++) { + if (!re_digits.exec(enums[i]) && (!curWord || enums[i].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, enums[i])) { + seen[enums[i]] = true; + list.push(enums[i]); + } } } } } - } - // get functions - var re_funs = new RegExp(FUNS.source, "g"); - for (var dir = -1; dir <= 1; dir += 2) { - var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir; - for (; line != endLine; line += dir) { - var text = editor.getLine(line), m; - while (m = re_funs.exec(text)) { - if ((!curWord || m[1].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[1])) { - seen[m[1]] = true; - list.push(m[1]); + // get functions + var re_funs = new RegExp(FUNS.source, "g"); + for (var dir = -1; dir <= 1; dir += 2) { + var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir; + for (; line != endLine; line += dir) { + var text = editor.getLine(line), m; + while (m = re_funs.exec(text)) { + if (!re_digits.exec(m[1]) && (!curWord || m[1].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[1])) { + seen[m[1]] = true; + list.push(m[1]); + } } } } - } - // add default functions - var default_functions = hintWords.EN_functions(); - for (var i = 0; i < default_functions.length; i++) { - if ((!curWord || default_functions[i].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, default_functions[i])) { - seen[default_functions[i]] = true; - list.push(default_functions[i]); + // add default functions + var default_functions = hintWords.EN_functions(); + for (var i = 0; i < default_functions.length; i++) { + if ((!curWord || default_functions[i].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, default_functions[i])) { + seen[default_functions[i]] = true; + list.push(default_functions[i]); + } } } } 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 6087bb47ee5efcba7179aeb53967351c515d18b8..7040c85b67e609f216938739cdd5714609a524be 100755 --- a/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts +++ b/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts @@ -93,7 +93,8 @@ export class MateFunComponent { theme: 'dracula', fontSize: 12, hintOptions: { - completeSingle: false + completeSingle: false, + closeCharacters: /[^\d\w\_]/ } }; themes = ['3024-day', '3024-night', 'abcdef', 'ambiance-mobile', 'ambiance', 'base16-dark', 'base16-light', 'bespin', 'blackboard', 'cobalt', 'colorforth', 'dracula', 'duotone-dark', 'duotone-light', 'eclipse', 'elegant', 'erlang-dark', 'hopscotch', 'icecoder', 'isotope', 'lesser-dark', 'liquibyte', 'material', 'mbo', 'mdn-like', 'midnight', 'monokai', 'neat', 'neo', 'night', 'panda-syntax', 'paraiso-dark', 'paraiso-light', 'pastel-on-dark', 'railscasts', 'rubyblue', 'seti', 'solarized', 'the-matrix', 'tomorrow-night-bright', 'tomorrow-night-eighties', 'ttcn', 'twilight', 'vibrant-ink', 'xq-dark', 'xq-light', 'yeti', 'zenburn'] @@ -417,7 +418,7 @@ export class MateFunComponent { } archivoModificado(event){ - if (!event.ctrlKey && !event.shiftKey && !event.altKey){ + if (!event.ctrlKey && !event.altKey){ if (/^[\w\_\d]$/.test(event.key) || event.key == 'Enter') this.codemirror.instance.showHint(event); if(this.copiaNombreArchivo!=this.archivo.nombre || this.copiaContenidoArchivo != this.archivo.contenido){