Commit 68ab8f55 authored by Gustavo Carneiro's avatar Gustavo Carneiro Committed by Kurt Hindenburg
Browse files

Move Painter Methods to a new class TerminalPainter

parent 5c9c22fa
......@@ -179,6 +179,7 @@ set(konsoleprivate_SRCS ${windowadaptors_SRCS}
widgets/RenameTabWidget.cpp
widgets/TabTitleFormatButton.cpp
terminalDisplay/TerminalDisplay.cpp
terminalDisplay/TerminalPainter.cpp
widgets/TerminalDisplayAccessible.cpp
widgets/TerminalHeaderBar.cpp
widgets/ViewContainer.cpp
......
......@@ -77,7 +77,7 @@ uint ExtendedCharTable::createExtendedChar(const uint *unicodePoints, ushort len
const QList<Session *> sessionsList = SessionManager::instance()->sessions();
for (const Session *s : sessionsList) {
const QList<TerminalDisplay *> displayList = s->views();
for (const TerminalDisplay *display : displayList) {
for (const QPointer<TerminalDisplay> display : displayList) {
usedExtendedChars += display->screenWindow()->screen()->usedExtendedChars();
}
}
......
......@@ -38,7 +38,7 @@ void EscapeSequenceUrlFilter::process()
if (!_window->screenWindow() && _window->screenWindow()->screen()) {
return;
}
auto *sWindow = _window->screenWindow();
auto sWindow = _window->screenWindow();
const auto urls = sWindow->screen()->urlExtractor()->history();
for (const auto &escapedUrl : urls) {
......
This diff is collapsed.
......@@ -50,6 +50,7 @@ class QTimerEvent;
class KMessageWidget;
namespace Konsole {
class TerminalPainter;
class FilterChain;
class TerminalImageFilterChain;
class SessionController;
......@@ -337,7 +338,10 @@ public:
*/
void setScreenWindow(ScreenWindow *window);
/** Returns the terminal screen section which is displayed in this widget. See setScreenWindow() */
ScreenWindow *screenWindow() const;
QPointer<ScreenWindow> screenWindow() const
{
return _screenWindow;
}
// Select the current line.
void selectCurrentLine();
......@@ -393,6 +397,8 @@ public:
// a character which left edge is closest to the point.
void getCharacterPosition(const QPoint &widgetPoint, int &line, int &column, bool edge) const;
friend class TerminalPainter;
public Q_SLOTS:
/**
* Scrolls current ScreenWindow
......@@ -921,6 +927,7 @@ private:
int _displayVerticalLineAtChar;
QKeySequence _peekPrimaryShortcut;
TerminalPainter *_terminalPainter;
};
}
......
This diff is collapsed.
/*
Copyright 2020-2020 by Gustavo Carneiro <gcarneiroa@hotmail.com>
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
#ifndef TERMINALPAINTER_HPP
#define TERMINALPAINTER_HPP
// Qt
#include <QVector>
#include <QWidget>
#include <QPointer>
#include <QScrollBar>
// Konsole
#include "Character.h"
#include "ScreenWindow.h"
#include "Enumeration.h"
#include "colorscheme/ColorSchemeWallpaper.h"
class QRect;
class QColor;
class QRegion;
class QPainter;
class QString;
class QTimer;
namespace Konsole
{
class Character;
class TerminalDisplay;
class TerminalPainter
{
public:
explicit TerminalPainter(TerminalDisplay *display);
~TerminalPainter() = default;
// -- Drawing helpers --
// divides the part of the display specified by 'rect' into
// fragments according to their colors and styles and calls
// drawTextFragment() or drawPrinterFriendlyTextFragment()
// to draw the fragments
void drawContents(QPainter &paint, const QRect &rect);
// draw a transparent rectangle over the line of the current match
void drawCurrentResultRect(QPainter &painter);
// draw a thin highlight on the left of the screen for lines that have been scrolled into view
void highlightScrolledLines(QPainter& painter);
// compute which region need to be repainted for scrolled lines highlight
QRegion highlightScrolledLinesRegion(bool nothingChanged);
// draws a section of text, all the text in this section
// has a common color and style
void drawTextFragment(QPainter &painter, const QRect &rect, const QString &text,
const Character *style);
void drawPrinterFriendlyTextFragment(QPainter &painter, const QRect &rect, const QString &text,
const Character *style);
// draws the background for a text fragment
// if useOpacitySetting is true then the color's alpha value will be set to
// the display's transparency (set with setOpacity()), otherwise the background
// will be drawn fully opaque
void drawBackground(QPainter &painter, const QRect &rect, const QColor &backgroundColor,
bool useOpacitySetting);
// draws the cursor character
void drawCursor(QPainter &painter, const QRect &rect, const QColor &foregroundColor,
const QColor &backgroundColor, QColor &characterColor);
// draws the characters or line graphics in a text fragment
void drawCharacters(QPainter &painter, const QRect &rect, const QString &text,
const Character *style, const QColor &characterColor);
// draws a string of line graphics
void drawLineCharString(QPainter &painter, int x, int y, const QString &str,
const Character *attributes);
// draws the preedit string for input methods
void drawInputMethodPreeditString(QPainter &painter, const QRect &rect);
private:
int loc(int x, int y) const;
QPoint cursorPosition() const;
bool isCursorOnDisplay() const;
TerminalDisplay *_display;
};
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment