An open API service indexing awesome lists of open source software.

https://github.com/mguludag/qt_ansicolor_handler

ansi color code parser class from qt-creator's source code and modified and added new features (italic and underline) then aims easy to use with current QTextEdit and QPlainTextEdit without creating custom classes
https://github.com/mguludag/qt_ansicolor_handler

ansi-colors cpp log-viewer qt qt5 qt5-gui qt5-widgets spdlog widget

Last synced: about 2 months ago
JSON representation

ansi color code parser class from qt-creator's source code and modified and added new features (italic and underline) then aims easy to use with current QTextEdit and QPlainTextEdit without creating custom classes

Awesome Lists containing this project

README

          

# qt_ansicolor_handler
ansi color code parser class from qt-creator's source code and modified and added new features (italic and underline) then aims easy to use with current QTextEdit and QPlainTextEdit without creating custom classes

## Usage

### mainwindow.h
```C++
#include "ui_mainwindow.h"
#include "ansiescapecodehandler.hpp"
#include
#include
#include

#include

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();

void log();

private:
Ui::MainWindow ui;
Utils::AnsiEscapeCodeHandler handler;
};
```

### mainwindow.cpp
```C++
#include "mainwindow.h"
#include
#include

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
// give the plainTextEdit's textCursor and verticalScrollBar to AnsiEscapeCodeHandler class
// appendAnsiText(const QString&) slot will parse and append styled plain text into plainTextEdit
handler = Utils::AnsiEscapeCodeHandler(ui.plainTextEdit->textCursor(), ui.plainTextEdit->verticalScrollBar());
mLogger = spdlog::qt_logger_color_mt("qt_logger", &handler, true, "appendAnsiText");
spdlog::set_pattern("%^[%Y-%m-%d %H:%M:%S.%e] [%n] [%l] %v%$");
...
}
```
![screenshot](https://github.com/mguludag/qt_ansicolor_handler/blob/main/Screenshot%202022-03-28%20233842.png?raw=true)