From 6ce6182178df33d9cf5fff2c76efd26145d91a6f Mon Sep 17 00:00:00 2001 From: Franco Pariani <franco19ps@gmail.com> Date: Mon, 26 Nov 2018 23:46:02 -0300 Subject: [PATCH] Showing hints and default words with ctrl+space --- .../matefun/codemirror/matefun-mode-EN.js | 26 ++++++++++++++++++- .../app/layout/matefun/matefun.component.ts | 5 +++- 2 files changed, 29 insertions(+), 2 deletions(-) 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 7bf015b3..ca710ae3 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,6 +25,30 @@ var specialRE = /[(),;[\]`{}]/; var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer + var defualt_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) || {from: from, to: to, list: []}; + + var filtered_words = defualt_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; @@ -255,4 +279,4 @@ CodeMirror.defineMIME("text/x-matefun", "matefun-EN"); -}); \ 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 74867fe9..2fc79a02 100755 --- a/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts +++ b/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts @@ -88,7 +88,10 @@ export class MateFunComponent { }, gutters: ["CodeMirror-linenumbers", "breakpoints"], theme: 'dracula', - fontSize: 12 + fontSize: 12, + hintOptions: { + completeSingle: false + } }; 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'] version: string = npm.version; -- GitLab