From d328472d3ee15841d6b9ada5a08a67a8f8703030 Mon Sep 17 00:00:00 2001 From: Franco Pariani <franco19ps@gmail.com> Date: Tue, 27 Nov 2018 00:18:05 -0300 Subject: [PATCH] Show pop-up hints when is writing and also accept dashs and underscores --- .../src/app/layout/matefun/codemirror/matefun-mode-EN.js | 4 ++-- .../src/app/layout/matefun/matefun.component.html | 2 +- .../src/app/layout/matefun/matefun.component.ts | 4 +++- 3 files changed, 6 insertions(+), 4 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 ca710ae..eed8c31 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 @@ -31,13 +31,13 @@ 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))) { + 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 inner = anyWord(cm, { word: /[\w$\-\_]+/ }) || {from: from, to: to, list: []}; var filtered_words = defualt_words.filter(w => w.indexOf(term) === 0); diff --git a/Frontend Angular 4/src/app/layout/matefun/matefun.component.html b/Frontend Angular 4/src/app/layout/matefun/matefun.component.html index 55ba8c9..c1bcee0 100755 --- a/Frontend Angular 4/src/app/layout/matefun/matefun.component.html +++ b/Frontend Angular 4/src/app/layout/matefun/matefun.component.html @@ -68,7 +68,7 @@ </ng-template> </form> </div> - <codemirror class="codemirrorPrograma" [(ngModel)]="archivo.contenido" (keyup)="archivoModificado()" [config]="configCodeMirror" [ngStyle]="{'font-size': configCodeMirror.fontSize+'px'}"> + <codemirror class="codemirrorPrograma" [(ngModel)]="archivo.contenido" (keyup)="archivoModificado($event)" [config]="configCodeMirror" [ngStyle]="{'font-size': configCodeMirror.fontSize+'px'}"> </codemirror> </div> 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 2fc79a0..b844381 100755 --- a/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts +++ b/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts @@ -413,7 +413,9 @@ export class MateFunComponent { this.copiaContenidoArchivo = ''; } - archivoModificado(){ + 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{ -- GitLab