forked from qt-creator/qt-creator
The rendering has been rewritten to use cached GlyphRuns instead of text layouts. The VTerm specific code was moved into TerminalSurface. Change-Id: I10caa3db4ee932414987c9ddae2dcb777dc1f6e7 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
60 lines
1.3 KiB
C++
60 lines
1.3 KiB
C++
// Copyright (c) 2020, Justin Bronder
|
|
// Copied and modified from: https://github.com/jsbronder/sff
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
#pragma once
|
|
|
|
#include <vterm.h>
|
|
|
|
#include <deque>
|
|
#include <future>
|
|
#include <memory>
|
|
|
|
#include <QFont>
|
|
#include <QTextLayout>
|
|
|
|
namespace Terminal::Internal {
|
|
|
|
class Scrollback
|
|
{
|
|
public:
|
|
class Line
|
|
{
|
|
public:
|
|
Line(int cols, const VTermScreenCell *cells, VTermState *vts);
|
|
Line(Line &&other) = default;
|
|
Line() = delete;
|
|
|
|
int cols() const { return m_cols; };
|
|
const VTermScreenCell *cell(int i) const;
|
|
const VTermScreenCell *cells() const { return &m_cells[0]; };
|
|
|
|
private:
|
|
int m_cols;
|
|
std::unique_ptr<VTermScreenCell[]> m_cells;
|
|
};
|
|
|
|
public:
|
|
Scrollback(size_t capacity);
|
|
Scrollback() = delete;
|
|
|
|
int capacity() const { return m_capacity; };
|
|
int size() const { return static_cast<int>(m_deque.size()); };
|
|
|
|
const Line &line(size_t index) const { return m_deque.at(index); };
|
|
const std::deque<Line> &lines() const { return m_deque; };
|
|
|
|
void emplace(int cols,
|
|
const VTermScreenCell *cells,
|
|
VTermState *vts);
|
|
void popto(int cols, VTermScreenCell *cells);
|
|
|
|
void clear();
|
|
|
|
private:
|
|
size_t m_capacity;
|
|
std::deque<Line> m_deque;
|
|
};
|
|
|
|
} // namespace Terminal::Internal
|