VSCode extension: How to render colored output in output channel?

萝らか妹 提交于 2021-02-09 11:09:33

问题


I have custom output from API and I want to format it to string with some colored values.


回答1:


The output channel can be colorized with a TmLanguage grammar. The Output Colorizer extension extension does exactly that:

You can do this by targeting the text/x-code-output mimetype:

"contributes": {
    "languages": [{
        "id": "code-output",
        "mimetypes": [
            "text/x-code-output"
        ]
    }],
    "grammars": [{
        "language": "code-output",
        "scopeName": "code.output",
        "path": "./syntaxes/code-output.tmLanguage"
    }]
}

However, since this colorization is mimetype-based, you can't apply the highlighting to a specific output channel only. This means that two extensions providing output channel colorization will conflict.



来源:https://stackoverflow.com/questions/55524643/vscode-extension-how-to-render-colored-output-in-output-channel

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