From 267cc34eda5d728b4b1f0b9a83b0c84570e8a7ed Mon Sep 17 00:00:00 2001 From: Gustavo Carneiro Date: Thu, 16 Jul 2020 23:09:00 -0300 Subject: [PATCH] Move CharacterFormat class to a new file. --- src/CMakeLists.txt | 1 + src/CharacterFormat.cpp | 43 ++++++++++++++++++++++++++++++++++ src/CharacterFormat.h | 44 +++++++++++++++++++++++++++++++++++ src/History.h | 30 +----------------------- src/autotests/HistoryTest.cpp | 1 + 5 files changed, 90 insertions(+), 29 deletions(-) create mode 100644 src/CharacterFormat.cpp create mode 100644 src/CharacterFormat.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f27f23fc..3d85caca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -68,6 +68,7 @@ set(konsoleprivate_SRCS ${sessionadaptors_SRCS} HistoryScroll.cpp HistoryScrollFile.cpp HistoryScrollNone.cpp + CharacterFormat.cpp HistorySizeDialog.cpp widgets/HistorySizeWidget.cpp widgets/IncrementalSearchBar.cpp diff --git a/src/CharacterFormat.cpp b/src/CharacterFormat.cpp new file mode 100644 index 00000000..9369ffcb --- /dev/null +++ b/src/CharacterFormat.cpp @@ -0,0 +1,43 @@ +/* + This file is part of Konsole, an X terminal. + Copyright 1997,1998 by Lars Doelle + + 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. +*/ + +#include "CharacterFormat.h" + +using namespace Konsole; + +bool CharacterFormat::equalsFormat(const CharacterFormat &other) const +{ + return (other.rendition & ~RE_EXTENDED_CHAR) == (rendition & ~RE_EXTENDED_CHAR) + && other.fgColor == fgColor && other.bgColor == bgColor; +} + +bool CharacterFormat::equalsFormat(const Character &c) const +{ + return (c.rendition & ~RE_EXTENDED_CHAR) == (rendition & ~RE_EXTENDED_CHAR) + && c.foregroundColor == fgColor && c.backgroundColor == bgColor; +} + +void CharacterFormat::setFormat(const Character &c) +{ + rendition = c.rendition; + fgColor = c.foregroundColor; + bgColor = c.backgroundColor; + isRealCharacter = c.isRealCharacter; +} diff --git a/src/CharacterFormat.h b/src/CharacterFormat.h new file mode 100644 index 00000000..62e9fe75 --- /dev/null +++ b/src/CharacterFormat.h @@ -0,0 +1,44 @@ +/* + This file is part of Konsole, an X terminal. + Copyright 1997,1998 by Lars Doelle + + 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 CHARACTERFORMAT_H +#define CHARACTERFORMAT_H + +#include "Character.h" + +namespace Konsole +{ + +class CharacterFormat +{ +public: + bool equalsFormat(const CharacterFormat &other) const; + bool equalsFormat(const Character &c) const; + void setFormat(const Character &c); + + CharacterColor fgColor, bgColor; + quint16 startPos; + RenditionFlags rendition; + bool isRealCharacter; +}; + +} + +#endif diff --git a/src/History.h b/src/History.h index a8b0ccee..69bfb393 100644 --- a/src/History.h +++ b/src/History.h @@ -36,6 +36,7 @@ #include "HistoryScroll.h" #include "HistoryScrollFile.h" #include "HistoryScrollNone.h" +#include "CharacterFormat.h" // Konsole #include "Character.h" @@ -49,35 +50,6 @@ namespace Konsole { ////////////////////////////////////////////////////////////////////// typedef QVector TextLine; -class CharacterFormat -{ -public: - bool equalsFormat(const CharacterFormat &other) const - { - return (other.rendition & ~RE_EXTENDED_CHAR) == (rendition & ~RE_EXTENDED_CHAR) - && other.fgColor == fgColor && other.bgColor == bgColor; - } - - bool equalsFormat(const Character &c) const - { - return (c.rendition & ~RE_EXTENDED_CHAR) == (rendition & ~RE_EXTENDED_CHAR) - && c.foregroundColor == fgColor && c.backgroundColor == bgColor; - } - - void setFormat(const Character &c) - { - rendition = c.rendition; - fgColor = c.foregroundColor; - bgColor = c.backgroundColor; - isRealCharacter = c.isRealCharacter; - } - - CharacterColor fgColor, bgColor; - quint16 startPos; - RenditionFlags rendition; - bool isRealCharacter; -}; - class CompactHistoryBlock { public: diff --git a/src/autotests/HistoryTest.cpp b/src/autotests/HistoryTest.cpp index 6a2a1128..550cf57e 100644 --- a/src/autotests/HistoryTest.cpp +++ b/src/autotests/HistoryTest.cpp @@ -26,6 +26,7 @@ #include "../session/Session.h" #include "../Emulation.h" #include "../History.h" +#include "../HistoryScrollFile.h" using namespace Konsole;