Ace editor: customizing syntax error gutter

时光毁灭记忆、已成空白 提交于 2019-12-22 18:27:16

问题


Just wondering, if the syntax error gutter can be customized? Also is it possible to highlight texts which has syntax error?

For example below I am trying to check value of myString against string a "chetan" but without quotes. Now this is a syntax error. Currently we display the error in gutter prior to line number. But is it possible to customize the ace editor provide inline highlight and change the color?

if myString==chetan:
  //do something
endif 

回答1:


You can add underline similar to the way cloud9 and zed do (see https://github.com/zedapp/zed/commit/59ae66c545db2ad92dc5efc1a069edd16960ebdd) or modify highlighter tokens see https://groups.google.com/d/msg/ace-discuss/_PRUJ_HemNo/wvDf9FqwzhMJ




回答2:


I discovered that the line that has an error does not have spans, so I did the following:

if( editor.getValue() != "" && $('.ace_text-layer.ace_line:not(:has(span))')){
  $('.ace_line:not(:has(span))').css("background","#FCBEA5")
}else {
  $('.ace_line:not(:has(span))').css("background","#000000")
}

There are a few issues with this, such as it highlighting the current line.




回答3:


To customize the gutter you can play around its .ace_gutter properties. Now suppose if you want to change the width of the gutter,

.ace_gutter > .ace_layer {
    width: 20px !important;
}

This will help you in changing the width of the gutter by overriding the present gutter width. Similarly, you can edit other properties too.



来源:https://stackoverflow.com/questions/21284979/ace-editor-customizing-syntax-error-gutter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!