Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Konsole
Commits
55c67162
Commit
55c67162
authored
Oct 17, 2020
by
Gustavo Carneiro
Committed by
Tomaz Canabrava
Dec 13, 2020
Browse files
Remove profile dependency in decoders.
parent
3afa3482
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/SaveHistoryTask.cpp
View file @
55c67162
...
...
@@ -113,7 +113,7 @@ void SaveHistoryTask::execute()
if
(((
dialog
->
selectedNameFilter
()).
contains
(
QLatin1String
(
"html"
),
Qt
::
CaseInsensitive
))
||
((
dialog
->
selectedFiles
()).
at
(
0
).
endsWith
(
QLatin1String
(
"html"
),
Qt
::
CaseInsensitive
)))
{
Profile
::
Ptr
profile
=
SessionManager
::
instance
()
->
sessionProfile
(
session
);
jobInfo
.
decoder
=
new
HTMLDecoder
(
profile
);
jobInfo
.
decoder
=
new
HTMLDecoder
(
profile
->
colorScheme
(),
profile
->
font
()
);
}
else
{
jobInfo
.
decoder
=
new
PlainTextDecoder
();
}
...
...
src/decoders/HTMLDecoder.cpp
View file @
55c67162
...
...
@@ -13,26 +13,30 @@
// Qt
#include
<QTextStream>
#include
<QFont>
using
namespace
Konsole
;
HTMLDecoder
::
HTMLDecoder
(
const
QExplicitlySharedDataPointer
<
Profile
>
&
profile
)
:
_output
(
nullptr
)
,
_profile
(
profile
)
HTMLDecoder
::
HTMLDecoder
(
const
QString
&
colorSchemeName
,
const
QFont
&
profileFont
)
:
_output
(
nullptr
)
,
_colorSchemeName
(
colorSchemeName
)
,
_profileFont
(
profileFont
)
,
_innerSpanOpen
(
false
)
,
_lastRendition
(
DEFAULT_RENDITION
)
,
_lastForeColor
(
CharacterColor
())
,
_lastBackColor
(
CharacterColor
())
,
_validProfile
(
false
)
{
const
ColorScheme
*
colorScheme
=
nullptr
;
if
(
profile
)
{
colorScheme
=
ColorSchemeManager
::
instance
()
->
findColorScheme
(
profile
->
colorScheme
()
);
if
(
!
colorSchemeName
.
isEmpty
()
)
{
colorScheme
=
ColorSchemeManager
::
instance
()
->
findColorScheme
(
colorScheme
Name
);
if
(
colorScheme
==
nullptr
)
{
colorScheme
=
ColorSchemeManager
::
instance
()
->
defaultColorScheme
();
}
_validProfile
=
true
;
}
if
(
colorScheme
!=
nullptr
)
{
...
...
@@ -49,17 +53,16 @@ void HTMLDecoder::begin(QTextStream* output)
_output
=
output
;
if
(
_
p
rofile
)
{
if
(
_
validP
rofile
)
{
QString
style
;
QFont
font
=
_profile
->
font
();
style
.
append
(
QStringLiteral
(
"font-family:'%1',monospace;"
).
arg
(
font
.
family
()));
style
.
append
(
QStringLiteral
(
"font-family:'%1',monospace;"
).
arg
(
_profileFont
.
family
()));
// Prefer point size if set
if
(
f
ont
.
pointSizeF
()
>
0
)
{
style
.
append
(
QStringLiteral
(
"font-size:%1pt;"
).
arg
(
f
ont
.
pointSizeF
()));
if
(
_profileF
ont
.
pointSizeF
()
>
0
)
{
style
.
append
(
QStringLiteral
(
"font-size:%1pt;"
).
arg
(
_profileF
ont
.
pointSizeF
()));
}
else
{
style
.
append
(
QStringLiteral
(
"font-size:%1px;"
).
arg
(
f
ont
.
pixelSize
()));
style
.
append
(
QStringLiteral
(
"font-size:%1px;"
).
arg
(
_profileF
ont
.
pixelSize
()));
}
...
...
@@ -78,7 +81,7 @@ void HTMLDecoder::end()
{
Q_ASSERT
(
_output
);
if
(
_
p
rofile
)
{
if
(
_
validP
rofile
)
{
*
_output
<<
QStringLiteral
(
"</body>"
);
}
else
{
QString
text
;
...
...
@@ -90,8 +93,7 @@ void HTMLDecoder::end()
}
//TODO: Support for LineProperty (mainly double width , double height)
void
HTMLDecoder
::
decodeLine
(
const
Character
*
const
characters
,
int
count
,
LineProperty
/*properties*/
)
void
HTMLDecoder
::
decodeLine
(
const
Character
*
const
characters
,
int
count
,
LineProperty
/*properties*/
)
{
Q_ASSERT
(
_output
);
...
...
@@ -180,6 +182,7 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP
*
_output
<<
text
;
}
void
HTMLDecoder
::
openSpan
(
QString
&
text
,
const
QString
&
style
)
{
text
.
append
(
QStringLiteral
(
"<span style=
\"
%1
\"
>"
).
arg
(
style
));
...
...
src/decoders/HTMLDecoder.h
View file @
55c67162
...
...
@@ -10,7 +10,8 @@
// Konsole
#include
"TerminalCharacterDecoder.h"
#include
"profile/Profile.h"
#include
<QFont>
class
QString
;
namespace
Konsole
{
...
...
@@ -23,7 +24,7 @@ namespace Konsole
/**
* Constructs an HTML decoder using a default black-on-white color scheme.
*/
explicit
HTMLDecoder
(
const
Profile
::
Ptr
&
profile
=
Profile
::
Ptr
());
explicit
HTMLDecoder
(
const
QString
&
colorSchemeName
=
QString
(),
const
QFont
&
profileFont
=
QFont
());
void
decodeLine
(
const
Character
*
const
characters
,
int
count
,
LineProperty
properties
)
override
;
...
...
@@ -36,12 +37,14 @@ namespace Konsole
void
closeSpan
(
QString
&
text
);
QTextStream
*
_output
;
Profile
::
Ptr
_profile
;
QString
_colorSchemeName
;
QFont
_profileFont
;
ColorEntry
_colorTable
[
TABLE_COLORS
];
bool
_innerSpanOpen
;
RenditionFlags
_lastRendition
;
CharacterColor
_lastForeColor
;
CharacterColor
_lastBackColor
;
bool
_validProfile
;
};
}
...
...
src/decoders/PlainTextDecoder.h
View file @
55c67162
...
...
@@ -9,7 +9,7 @@
#include
"konsoleprivate_export.h"
#include
"
../decoders/
TerminalCharacterDecoder.h"
#include
"TerminalCharacterDecoder.h"
class
QTextStream
;
template
<
typename
>
class
QList
;
...
...
src/decoders/TerminalCharacterDecoder.h
View file @
55c67162
...
...
@@ -18,7 +18,6 @@
class
QTextStream
;
namespace
Konsole
{
class
Profile
;
/**
* Base class for terminal character decoders
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment