Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
e48c0369
Commit
e48c0369
authored
Sep 04, 2022
by
Waqar Ahmed
Browse files
Diff: Improve line number area
parent
085a684a
Changes
1
Hide whitespace changes
Inline
Side-by-side
apps/lib/diff/difflinenumarea.cpp
View file @
e48c0369
...
...
@@ -10,6 +10,8 @@
#include
<KTextEditor/Editor>
static
constexpr
int
Margin
=
4
;
LineNumArea
::
LineNumArea
(
DiffEditor
*
parent
)
:
QWidget
(
parent
)
,
textEdit
(
parent
)
...
...
@@ -33,7 +35,7 @@ LineNumArea::LineNumArea(DiffEditor *parent)
int
LineNumArea
::
lineNumAreaWidth
()
const
{
int
digits
=
2
;
int
digits
=
1
;
int
max
=
std
::
max
(
1
,
maxLineNum
);
while
(
max
>=
10
)
{
max
/=
10
;
...
...
@@ -81,7 +83,9 @@ void LineNumArea::paintEvent(QPaintEvent *event)
const
QString
number
=
QString
::
number
(
n
);
auto
isCurrentLine
=
textEdit
->
textCursor
().
blockNumber
()
==
blockNumber
;
painter
.
setPen
(
isCurrentLine
?
currentLine
:
otherLines
);
painter
.
drawText
(
-
5
,
top
,
sizeHint
().
width
(),
textEdit
->
fontMetrics
().
height
(),
Qt
::
AlignRight
,
number
);
QRect
numRect
(
0
,
top
,
sizeHint
().
width
(),
textEdit
->
fontMetrics
().
height
());
numRect
.
adjust
(
0
,
0
,
-
(
Margin
*
2
),
0
);
painter
.
drawText
(
numRect
,
Qt
::
AlignRight
|
Qt
::
AlignVCenter
|
Qt
::
TextDontClip
,
number
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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