<commit_before>#include "outputwidget.h"
#include "ui_outputwidget.h"

#include "highlighter.h"

#include <cmath>

#include <QTextDocumentFragment>
#include <QJsonObject>
#include <QTextTable>
#include <QTextFrame>
#include <QPainter>
#include <QScrollBar>
#include <QClipboard>
#include <QTextStream>
#include <QDebug>
#include <QMenu>
#include <QPainterPath>
#include <QCheckBox>
#include "ideutils.h"

OutputWidget::OutputWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::OutputWidget)
{
    ui->setupUi(this);

    ui->textBrowser->installEventFilter(this);
    ui->textBrowser->viewport()->installEventFilter(this);
    ui->textBrowser->setOpenLinks(false);
    connect(ui->textBrowser, &QTextBrowser::anchorClicked, this, &OutputWidget::onAnchorClicked);

    auto* arrow = new OutputWidgetArrow;
    arrow->setParent(this);
    ui->textBrowser->document()->documentLayout()->registerHandler(TextObject::Arrow, arrow);
    _frame = ui->textBrowser->document()->rootFrame();

    _headerTableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100));
    _headerTableFormat.setBorder(0);
    _headerTableFormat.setCellSpacing(0);
    _headerTableFormat.setProperty(Property::ToggleFrame, true);

    _arrowFormat.setObjectType(TextObject::Arrow);
    _arrowFormat.setProperty(Property::Expanded, true);
    _arrowFormat.setForeground(Qt::gray);

    _frameFormat.setLeftMargin(10);
    _frameFormat.setProperty(Property::Expanded, true);

    _rightAlignBlockFormat.setAlignment(Qt::AlignRight);
    _rightAlignBlockFormat.setLeftMargin(10);
#ifdef Q_OS_MAC
    ui->toggleAll_pushButton->setMinimumWidth(85);
#else
    setStyleSheet("QPushButton { padding: 2px 6px; }");
#endif
}

OutputWidget::~OutputWidget()
{
    delete ui;
}

void OutputWidget::setDarkMode(bool darkMode)
{
    _noticeCharFormat.setForeground(Themes::currentTheme.functionColor.get(darkMode));
    _errorCharFormat.setForeground(Themes::currentTheme.errorColor.get(darkMode));
    _errorCharFormat.setForeground(Themes::currentTheme.errorColor.get(darkMode));
    _infoCharFormat.setForeground(Qt::gray);
    _commentCharFormat.setForeground(Themes::currentTheme.commentColor.get(darkMode));

    ui->textBrowser->viewport()->setStyleSheet(Themes::currentTheme.styleSheet(darkMode));
}

void OutputWidget::scrollToBottom()
{
    auto* scrollbar = ui->textBrowser->verticalScrollBar();
    scrollbar->setValue(scrollbar->maximum());
}

void OutputWidget::startExecution(const QString& label)
{<commit_msg>Reduce output widget wasted space on macOS<commit_after>#include "outputwidget.h"
#include "ui_outputwidget.h"

#include "highlighter.h"

#include <cmath>

#include <QTextDocumentFragment>
#include <QJsonObject>
#include <QTextTable>
#include <QTextFrame>
#include <QPainter>
#include <QScrollBar>
#include <QClipboard>
#include <QTextStream>
#include <QDebug>
#include <QMenu>
#include <QPainterPath>
#include <QCheckBox>
#include "ideutils.h"

OutputWidget::OutputWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::OutputWidget)
{
    ui->setupUi(this);

    ui->textBrowser->installEventFilter(this);
    ui->textBrowser->viewport()->installEventFilter(this);
    ui->textBrowser->setOpenLinks(false);
    connect(ui->textBrowser, &QTextBrowser::anchorClicked, this, &OutputWidget::onAnchorClicked);

    auto* arrow = new OutputWidgetArrow;
    arrow->setParent(this);
    ui->textBrowser->document()->documentLayout()->registerHandler(TextObject::Arrow, arrow);
    _frame = ui->textBrowser->document()->rootFrame();

    _headerTableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100));
    _headerTableFormat.setBorder(0);
    _headerTableFormat.setCellSpacing(0);
    _headerTableFormat.setProperty(Property::ToggleFrame, true);

    _arrowFormat.setObjectType(TextObject::Arrow);
    _arrowFormat.setProperty(Property::Expanded, true);
    _arrowFormat.setForeground(Qt::gray);

    _frameFormat.setLeftMargin(10);
    _frameFormat.setProperty(Property::Expanded, true);

    _rightAlignBlockFormat.setAlignment(Qt::AlignRight);
    _rightAlignBlockFormat.setLeftMargin(10);
#ifdef Q_OS_MAC
    ui->toggleAll_pushButton->setMinimumWidth(85);
    layout()->setSpacing(8);
#else
    setStyleSheet("QPushButton { padding: 2px 6px; }");
#endif
}

OutputWidget::~OutputWidget()
{
    delete ui;
}

void OutputWidget::setDarkMode(bool darkMode)
{
    _noticeCharFormat.setForeground(Themes::currentTheme.functionColor.get(darkMode));
    _errorCharFormat.setForeground(Themes::currentTheme.errorColor.get(darkMode));
    _errorCharFormat.setForeground(Themes::currentTheme.errorColor.get(darkMode));
    _infoCharFormat.setForeground(Qt::gray);
    _commentCharFormat.setForeground(Themes::currentTheme.commentColor.get(darkMode));

    ui->textBrowser->viewport()->setStyleSheet(Themes::currentTheme.styleSheet(darkMode));
}

void OutputWidget::scrollToBottom()
{
    auto* scrollbar = ui->textBrowser->verticalScrollBar();
    scrollbar->setValue(scrollbar->maximum());
}

void OutputWidget::startExecution(const QString& label)
{
{'fraction_non_alphanumeric': 0.13740608936338475, 'fraction_numerical': 0.005338078291814947, 'mean_word_length': 6.795069337442219, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 82, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4011221', 'n_tokens_mistral': 1613, 'n_tokens_neox': 1588, 'n_words': 211}