Bladeren bron

Fix some issues with the domconsole

Remove unnecessary keys in ui.json
Lucas de Souza 5 jaren geleden
bovenliggende
commit
fb6a369526
4 gewijzigde bestanden met toevoegingen van 21 en 33 verwijderingen
  1. 0 4
      i18n/pt/ui.json
  2. 12 5
      js/io/domConsole.js
  3. 2 1
      js/runner.js
  4. 7 23
      templates/runner.html

+ 0 - 4
i18n/pt/ui.json

@@ -100,12 +100,8 @@
   "var_menu_select_all": "Selecione",
   "var_menu_select_function": "Selecione uma função",
   "expression_menu_select": "Construir uma expressão lógica",
-  "inform_valid_name": "Informe um nome válido! O nome não pode ser uma palavra reservadoa e deve começar com letras e conter apenas letras, números e _",
   "inform_valid_content": "Informe o conteúdo!",
   "inform_valid_expression": "Construa uma expressão lógica!",
-  "inform_valid_name_duplicated": "Este nome já está em uso por outra função!",
-  "inform_valid_global_duplicated": "Já existe uma variável global com o nome informado.",
-  "inform_valid_variable_duplicated" : "Já existe uma variável local com o nome informado.",
   "tooltip_terminal_clear":"Limpa o terminal removendo todos os textos",
   "tooltip_terminal_show":"Exibe o terminal caso esteja escondido",
   "tooltip_terminal_hide":"Esconde o terminal caso não esteja escondido",

+ 12 - 5
js/io/domConsole.js

@@ -39,7 +39,8 @@ export class DOMConsole {
     return 3;
   }
 
-  constructor (elementID) {
+  constructor (elementID, disableMarginTop = false) {
+    this.disableMarginTop = disableMarginTop;
     this.input = null;
     this.cursorInterval = null;
     this.idleInterval = null;
@@ -198,10 +199,16 @@ export class DOMConsole {
   }
 
   getOutputText (text) {
+    if(text.trim().length == 0) {
+      text = " ";
+    }
     return `<span>${text}</span>`;
   }
 
   getUserInputText (text) {
+    if(text.trim().length == 0) {
+      text = "&nbsp;";
+    }
     return `<i class="icon keyboard outline" style="float:left"></i><span>${text}</span>`;
   }
 
@@ -213,8 +220,7 @@ export class DOMConsole {
   focus () {
     this.termDiv.style.display = 'block';
     // Is in draggable mode?
-    console.log(this.parent.style.top.length);
-    if(this.parent.style.top.length == 0) {
+    if(!this.disableMarginTop && this.parent.style.top.length == 0) {
       this.parent.style.marginTop = "-160px";
     }
     if(!isElementInViewport(this.termDiv))
@@ -224,7 +230,7 @@ export class DOMConsole {
 
   hide () {
     // Is in draggable mode?
-    if(this.parent.style.top.length == 0) {
+    if(!this.disableMarginTop && this.parent.style.top.length == 0) {
       this.parent.style.marginTop = "0";
     }
     this.termDiv.style.display = 'none';
@@ -297,7 +303,8 @@ export class DOMConsole {
   sendOutput (text) {
     const output = ""+text;
     output.split("\n").forEach(t => {
-      t = t.replace(/\t/g,'&#9;');
+      t = t.replace(/\t/g,'&nbsp;&nbsp;');
+      t = t.replace(/\s/g,"&nbsp;");
       this.write(t)
     });
   }

+ 2 - 1
js/runner.js

@@ -20,7 +20,8 @@ const ivprogLexer = LanguageService.getCurrentLexer();
 // }
 // const anaSin = new IVProgParser(input, ivprogLexer);
 const editor = new JsonEditor('#json-renderer', {});
-const domConsole = new DOMConsole("#console");
+const domConsole = new DOMConsole("#console", true);
+domConsole.hide();
 // proc.interpretAST().then( sto => {
 //   console.log(sto.applyStore('a'));
 // }).catch(e => console.log(e));

+ 7 - 23
templates/runner.html

@@ -1,31 +1,15 @@
 <!DOCTYPE html>
 <html>
 <head>
-
-  <link rel="stylesheet" type="text/css" href="css/ivprog-term.css">
-
+  <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.0/semantic.min.css" integrity="sha256-9mbkOfVho3ZPXfM7W8sV2SndrGDuh7wuyLjtsWeTI1Q=" crossorigin="anonymous" />
-  <style>
-    .ivprog-io-output {
-      border: 1px solid gainsboro;
-      width: 80%;
-      height: 360px;
-      overflow-y: scroll;
-      background-color: black;
-      color: white;
-    }
-
-    .ivprog-io-input {
-      width: 80%;
-      margin-top: 10px;
-      border: 1.5px solid green;
-      height: 3rem;
-      color: black;
-      font-size: 12pt;
-    }
-  </style>
-  <title></title>
+  <link rel="stylesheet" type="text/css" href="css/ivprog-visual-1.0.css">
+  <link rel="stylesheet" type="text/css" href="css/ivprog-term.css">
   <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
+  <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"
+    integrity="sha256-KM512VNnjElC30ehFwehXjx1YCHPiQkOPmqnrWtpccM="
+    crossorigin="anonymous"></script>
+  <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.0/semantic.min.js" integrity="sha256-x1fC6BXl6BwnUhfQqqqC0Fd/n12wH+u8u9va6+E7xaA=" crossorigin="anonymous"></script>
   <script type="text/javascript" src="js/jquery.json-editor.min.js"></script>
 </head>
 <body>