Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

252
Visualizações
¿Es posible obtener sugerencias de línea de tiempo de depuración al estilo de JetBrains en Ace Editor?

Actualmente tengo un editor Ace incrustado en mi navegador. Me gustaría usar sugerencias de línea cuando ejecuto código en la aplicación del navegador. ¿Ace ofrece alguna funcionalidad de este tipo, o sería aconsejable agregar y eliminar comentarios al final de la línea? tenga en cuenta que solo quiero un solo carácter en estas sugerencias. También consideré usar el canalón en mi aplicación, pero los números de línea también son importantes para mí.

ingrese la descripción de la imagen aquí

aquí hay una imagen de mi aplicación

ingrese la descripción de la imagen aquí

Me gustaría que ~F apareciera en la línea verde y ~D en la línea azul. Esta es una ejecución de RISC ISA, pero no creo que eso deba importar.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Hay dos maneras

  1. enganche en el tokenizador para agregar un token adicional
 // update lines editor.session.bgTokenizer.lines[0].push({type: "comment", value: " // ~D "}) // hook into $tokenizeRow to add tokens after text is changed too if (!editor.session.bgTokenizer.$tokenizeRow_orig) editor.session.bgTokenizer.$tokenizeRow_orig = editor.session.bgTokenizer.$tokenizeRow editor.session.bgTokenizer.$tokenizeRow = function(row) { var tokens = editor.session.bgTokenizer.$tokenizeRow_orig(row) tokens.push({type: "comment", value: " // ~D " + row}) return tokens } // redraw editor editor.renderer.updateFull()
  1. agregue un oyente de procesamiento y agregue elementos dom al editor
 var dom = require("ace/lib/dom") var annotations = {5: {text: "foo"}, 25: {text: "bar"}} editor.renderer.on("afterRender", function() { editor.renderer.$textLayer.$lines.cells.forEach(function(cell) { if (annotations[cell.row]) { if (!annotations[cell.row].element) annotations[cell.row].element = dom.buildDom(["span", {style: "color:red"}, annotations[cell.row].text]) cell.element.append(annotations[cell.row].element) } }) }) editor.renderer.updateText() 

 var value = Array(100).fill(0).map((x,i)=>i+3).join(" ~ \n") function isPrime(num) { var max = Math.sqrt(num) + 1 for (var i = 2; i < max; i++) if (num%i == 0) return false return true } var editor = ace.edit("editor", { value }) var annotations = {} editor.on("change", updateAnnotations) function updateAnnotations() { clearAnnotations() editor.session.doc.getAllLines().forEach(function(line, lineNumber) { var num = parseInt(line) if (isPrime(num)) { if (isPrime(num - 2) || isPrime(num + 2)) text = " is a twin prime" else text = " is a prime" annotations[lineNumber] = {text} } }) } function clearAnnotations() { for (var i in annotations) { if (annotations[i]?.element) annotations[i].element.remove() } annotations = {} } var dom = ace.require("ace/lib/dom") function renderAnnotations() { editor.renderer.$textLayer.$lines.cells.forEach(function(cell) { if (annotations[cell.row]) { if (!annotations[cell.row].element) annotations[cell.row].element = dom.buildDom(["span", {style: "color:red"}, annotations[cell.row].text]) cell.element.append(annotations[cell.row].element) } }) } editor.renderer.on("afterRender", renderAnnotations) updateAnnotations() editor.renderer.updateText()
 <script src=https://ajaxorg.github.io/ace-builds/src/ace.js></script> <div id="editor" style="height: 200px"></div>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda