本页内容

Utils::AnsiEscapeCodeHandler Class

class Utils::AnsiEscapeCodeHandler

AnsiEscapeCodeHandler 类用于解析文本并从中提取 ANSI 转义码。更多内容...

Header: #include <AnsiEscapeCodeHandler>

详细说明

为了在不同文本段之间保留颜色信息,必须在流的整个生命周期内保留该类的实例。此外,该类的单个实例不应处理多个流(至少不应同时处理)。

其主要函数是 parseText(),该函数接受文本和默认的 `QTextCharFormat`。该函数旨在解析文本并将带颜色的文本拆分为较小的字符串,并将相应的格式化信息设置在 `QTextCharFormat` 中。

用法:

  • 为流创建 AnsiEscapeCodeHandler 的新实例。
  • 要添加新文本,请调用 parseText() 函数,并传入文本和默认的QTextCharFormat 。该函数的返回结果是一个字符串列表,其中各字符串的格式均设置在相应的QTextCharFormat 中。

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.