diff --git a/Frontend Angular 4/.angular-cli.json b/Frontend Angular 4/.angular-cli.json index ce654106465498153093c13f88c34696eaa0252b..530ff8d1ff73419bdd22e1733ac450113e273376 100644 --- a/Frontend Angular 4/.angular-cli.json +++ b/Frontend Angular 4/.angular-cli.json @@ -23,6 +23,7 @@ "../node_modules/font-awesome/css/font-awesome.css", "styles/app.scss", "styles/console.css", + "styles/hints.css", "../node_modules/tippy.js/dist/tippy.css", "../node_modules/codemirror/lib/codemirror.css", "../node_modules/codemirror/addon/hint/show-hint.css", diff --git a/Frontend Angular 4/src/app/layout/matefun/codemirror/hint_words.js b/Frontend Angular 4/src/app/layout/matefun/codemirror/hint_words.js new file mode 100644 index 0000000000000000000000000000000000000000..38d9f50d2aa93484fd8af9606153b956969f9df8 --- /dev/null +++ b/Frontend Angular 4/src/app/layout/matefun/codemirror/hint_words.js @@ -0,0 +1,102 @@ +// English words + +let EN_default_words = [ + 'squareroot', 'rgb', 'rect', 'circ', 'line', 'poli', 'join', 'color', 'move', 'rotate', 'scale', 'toFig', 'line3D', 'sphere', 'cylinder', 'cube', 'ring', 'scale3D', 'range', 'first', 'rest', 'A' +] + +var EN_keywords = [ + "include" + ,"set","in" + ,"if", "or" + ,"isEmpty" +]; + +let EN_types = [ + "Red", "Green", "Blue", "Black","White","Gray","Yellow","FigEmpty", "[]" + ,"R", "Fig", "Fig3D", "Color", "color3D", "join3D", "rotate3D", "move3D" +] + +let EN_functions = [ + "abs", "acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf", + "asin", "asinh", "atan", "atan2", "atanh", "break", "catch", "ceiling", + "compare", "concat", "concatMap", "const", "cos", "cosh", "curry", + "cycle", "decodeFloat", "div", "divMod", "drop", "dropWhile", "either", + "elem", "encodeFloat", "enumFrom", "enumFromThen", "enumFromThenTo", + "enumFromTo", "error", "even", "exp", "exponent", "fail", "filter", + "flip", "floatDigits", "floatRadix", "floatRange", "floor", "fmap", + "foldl", "foldl1", "foldr", "foldr1", "fromEnum", "fromInteger", + "fromIntegral", "fromRational", "fst", "gcd", "getChar", "getContents", + "getLine", "head", "id", "init", "interact", "ioError", "isDenormalized", + "isIEEE", "isInfinite", "isNaN", "isNegativeZero", "iterate", "last", + "lcm", "length", "lex", "lines", "log", "logBase", "lookup", "map", + "mapM", "mapM_", "max", "maxBound", "maximum", "maybe", "min", "minBound", + "minimum", "mod", "negate", "not", "notElem", "null", "odd", "or", + "otherwise", "pi", "pred", "print", "product", "properFraction", + "putChar", "putStr", "putStrLn", "quot", "quotRem", "read", "readFile", + "readIO", "readList", "readLn", "readParen", "reads", "readsPrec", + "realToFrac", "recip", "rem", "repeat", "replicate", "return", "reverse", + "round", "scaleFloat", "scanl", "scanl1", "scanr", "scanr1", "seq", + "sequence", "sequence_", "show", "showChar", "showList", "showParen", + "showString", "shows", "showsPrec", "significand", "signum", "sin", + "sinh", "snd", "span", "splitAt", "sqrt", "subtract", "succ", "sum", + "tail", "take", "takeWhile", "tan", "tanh", "toEnum", "toInteger", + "toRational", "truncate", "uncurry", "undefined", "unlines", "until", + "unwords", "unzip", "unzip3", "userError", "words", "writeFile", "zip", + "zip3", "zipWith", "zipWith3" +] + +// Spanish words + +let ES_default_words = [ + 'red', 'sen', 'raizcuad', 'rgb', 'rect', 'circ', 'linea', 'poli', 'juntar', 'color', 'mover', 'rotar', 'escalar', 'aFig', 'linea3D', 'esfera', 'cilindro', 'cubo', 'anillo', 'juntar3D', 'color3D', 'mover3D', 'rotar3D', 'escalar3D', 'rango', 'primero', 'resto', 'A' +] + +var ES_keywords = [ + "incluir" + ,"conj","en" + ,"si", "o" + ,"esVacia" +]; + +let ES_types = [ + "Rojo", "Verde", "Azul", "Negro","Blanco", "Gris","Amarillo", "FigVacia", "[]" + ,"R", "Fig", "Color" +] + +let ES_functions = [ + "abs", "acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf", + "asin", "asinh", "atan", "atan2", "atanh", "break", "catch", "ceiling", + "compare", "concat", "concatMap", "const", "cos", "cosh", "curry", + "cycle", "decodeFloat", "div", "divMod", "drop", "dropWhile", "either", + "elem", "encodeFloat", "enumFrom", "enumFromThen", "enumFromThenTo", + "enumFromTo", "error", "even", "exp", "exponent", "fail", "filter", + "flip", "floatDigits", "floatRadix", "floatRange", "floor", "fmap", + "foldl", "foldl1", "foldr", "foldr1", "fromEnum", "fromInteger", + "fromIntegral", "fromRational", "fst", "gcd", "getChar", "getContents", + "getLine", "head", "id", "init", "interact", "ioError", "isDenormalized", + "isIEEE", "isInfinite", "isNaN", "isNegativeZero", "iterate", "last", + "lcm", "length", "lex", "lines", "log", "logBase", "lookup", "map", + "mapM", "mapM_", "max", "maxBound", "maximum", "maybe", "min", "minBound", + "minimum", "mod", "negate", "not", "notElem", "null", "odd", "or", + "otherwise", "pi", "pred", "print", "product", "properFraction", + "putChar", "putStr", "putStrLn", "quot", "quotRem", "read", "readFile", + "readIO", "readList", "readLn", "readParen", "reads", "readsPrec", + "realToFrac", "recip", "rem", "repeat", "replicate", "return", "reverse", + "round", "scaleFloat", "scanl", "scanl1", "scanr", "scanr1", "seq", + "sequence", "sequence_", "show", "showChar", "showList", "showParen", + "showString", "shows", "showsPrec", "significand", "signum", "sin", + "sinh", "snd", "span", "splitAt", "sqrt", "subtract", "succ", "sum", + "tail", "take", "takeWhile", "tan", "tanh", "toEnum", "toInteger", + "toRational", "truncate", "uncurry", "undefined", "unlines", "until", + "unwords", "unzip", "unzip3", "userError", "words", "writeFile", "zip", + "zip3", "zipWith", "zipWith3" +] + +module.exports = { + EN_words: function() { + return EN_default_words.concat(EN_keywords).concat(EN_types).concat(EN_functions); + }, + ES_words: function() { + return ES_default_words.concat(ES_keywords).concat(ES_types).concat(ES_functions); + } +} 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 eed8c31296917620b2eb0f568b014b4526051060..0e2a623d3935fee5ad77c4abd8cbb84277f954e8 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 @@ -25,7 +25,7 @@ var specialRE = /[(),;[\]`{}]/; var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer - var defualt_words = []; + const hintWords = require('./hint_words'); var anyWord = CodeMirror.hint.anyword; CodeMirror.hint.anyword = function(cm) { @@ -39,7 +39,7 @@ } var inner = anyWord(cm, { word: /[\w$\-\_]+/ }) || {from: from, to: to, list: []}; - var filtered_words = defualt_words.filter(w => w.indexOf(term) === 0); + var filtered_words = hintWords.EN_words().filter(w => w.indexOf(term) === 0); for(var i= 0; i < filtered_words.length; i++){ if (inner.list.indexOf(filtered_words[i]) === -1) diff --git a/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-ES.js b/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-ES.js index 72c0d89e0c93de1b29bda44673535033def1987e..c820e81a2ba725883a837be14ffda2ec0deae810 100755 --- a/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-ES.js +++ b/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-ES.js @@ -25,6 +25,30 @@ var specialRE = /[(),;[\]`{}]/; var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer + const hintWords = require('./hint_words'); + + var anyWord = CodeMirror.hint.anyword; + CodeMirror.hint.anyword = function(cm) { + var cur = cm.getCursor(), token = cm.getTokenAt(cur) + var term, from = CodeMirror.Pos(cur.line, token.start), to = cur + if (token.start < cur.ch && /[\w\-\_]/.test(token.string.charAt(cur.ch - token.start - 1))) { + term = token.string.substr(0, cur.ch - token.start) + } else { + term = "" + from = cur + } + var inner = anyWord(cm, { word: /[\w$\-\_]+/ }) || {from: from, to: to, list: []}; + + var filtered_words = hintWords.ES_words().filter(w => w.indexOf(term) === 0); + + for(var i= 0; i < filtered_words.length; i++){ + if (inner.list.indexOf(filtered_words[i]) === -1) + inner.list.push(filtered_words[i]); + } + + return inner; + }; + function normal(source, setState) { if (source.eatWhile(whiteCharRE)) { return null; @@ -258,4 +282,4 @@ CodeMirror.defineMIME("text/x-matefun", "matefun-ES"); -}); \ No newline at end of file +}); 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 b844381c1876cb3ec54f60b0f5f435d69f0ddec7..d6b1729e9da106e457e04b9cdf66866f7eb13ca4 100755 --- a/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts +++ b/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts @@ -39,6 +39,8 @@ import 'codemirror/addon/search/search'; import 'codemirror/addon/search/matchesonscrollbar'; import 'codemirror/addon/search/jump-to-line'; import 'codemirror/addon/edit/matchbrackets'; +import 'codemirror/addon/selection/active-line'; +import 'codemirror/addon/comment/comment.js'; import './codemirror/matefun-mode-ES.js' import './codemirror/matefun-mode-EN.js' @@ -81,6 +83,7 @@ export class MateFunComponent { lineNumbers: true, lineWrapping : true, matchBrackets: true, + styleActiveLine: true, extraKeys: {"Ctrl-Space": "autocomplete"}, mode: { name: "matefun-EN", @@ -414,13 +417,17 @@ export class MateFunComponent { } archivoModificado(event){ - if (/^[a-zA-Z\-\_]$/.test(event.key)) - this.codemirror.instance.showHint(event); - if(this.copiaNombreArchivo!=this.archivo.nombre || this.copiaContenidoArchivo != this.archivo.contenido){ - this.modificado = true; - }else{ - this.modificado = false; + if (!event.ctrlKey && !event.shiftKey && !event.altKey){ + if (/^[a-zA-Z\-\_]$/.test(event.key)) + this.codemirror.instance.showHint(event); + if(this.copiaNombreArchivo!=this.archivo.nombre || this.copiaContenidoArchivo != this.archivo.contenido){ + this.modificado = true; + }else{ + this.modificado = false; + } } + if (event.ctrlKey && event.shiftKey && event.key == 'K') + this.codemirror.instance.toggleComment(); } guardarArchivo(){ diff --git a/Frontend Angular 4/src/styles/hints.css b/Frontend Angular 4/src/styles/hints.css new file mode 100644 index 0000000000000000000000000000000000000000..e533fc2863ba89cdfa3a9e7686ed8be3d5062353 --- /dev/null +++ b/Frontend Angular 4/src/styles/hints.css @@ -0,0 +1,32 @@ +.CodeMirror-hints { + position: absolute; + z-index: 10; + overflow: hidden; + list-style: none; + + margin: 0; + padding: 2px; + box-shadow: 2px 3px 5px rgba(0,0,0,.2); + border-radius: 3px; + border: 1px solid rgb(43, 43, 43) !important; + background: black !important; + font-size: 90%; + font-family: monospace; + + max-height: 20em; + overflow-y: auto; +} + +.CodeMirror-hint { + margin: 0; + padding: 0 4px; + border-radius: 2px; + white-space: pre; + color: white !important; + cursor: pointer; +} + +li.CodeMirror-hint-active { + background: rgb(21, 117, 226) !important; + color: white; +}