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
Games
KMuddy
Commits
30368ca5
Commit
30368ca5
authored
May 03, 2020
by
Tomas Mecir
Browse files
fix issues with scrollback
parent
01ef118a
Changes
1
Hide whitespace changes
Inline
Side-by-side
libs/cconsole.cpp
View file @
30368ca5
...
...
@@ -34,7 +34,6 @@
#include <QTextCursor>
#include <QTextDocument>
#include <QToolTip>
#include <QDebug>
#include <KActionCollection>
#include <KLocalizedString>
...
...
@@ -359,6 +358,14 @@ void cConsole::setScrollTextVisible (bool vis)
void
cConsole
::
sliderChanged
(
int
val
)
{
int
maxval
=
verticalScrollBar
()
->
maximum
();
// if we're very close to the bottom, push the slider to the bottom
// this fixes an off-by-one issue where scrollback would open when switching between tabs due to rounding issues
if
((
val
<
maxval
)
&&
(
val
>=
maxval
-
2
))
{
verticalScrollBar
()
->
setValue
(
maxval
);
return
;
}
d
->
atBottom
=
(
val
>=
maxval
);
bool
vis
=
(
val
<
maxval
);
setScrollTextVisible
(
vis
);
...
...
@@ -493,7 +500,12 @@ void cConsole::addNewText (cTextChunk *chunk, bool endTheLine)
int
flines
=
fblock
.
lineCount
();
if
(
totalLines
()
-
flines
<
d
->
historySize
)
break
;
int
fheight
=
d
->
text
->
documentLayout
()
->
blockBoundingRect
(
fblock
).
height
();
// determine the distance between the blocks ... can't just use the height of the bounding block, as that doesn't take spacing into account
QTextBlock
fnextblock
=
fblock
.
next
();
QRectF
rect1
=
d
->
text
->
documentLayout
()
->
blockBoundingRect
(
fblock
);
QRectF
rect2
=
d
->
text
->
documentLayout
()
->
blockBoundingRect
(
fnextblock
);
int
fheight
=
rect2
.
top
()
-
rect1
.
top
();
cursor
=
QTextCursor
(
fblock
);
cursor
.
select
(
QTextCursor
::
BlockUnderCursor
);
cursor
.
movePosition
(
QTextCursor
::
NextCharacter
,
QTextCursor
::
KeepAnchor
);
// need to move, otherwise the empty block is kept
...
...
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