Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KDiff3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SDK
KDiff3
Commits
d8d48199
Commit
d8d48199
authored
Aug 30, 2013
by
Joachim Eibl
Committed by
Michael Reeves
Jan 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrections and optimizations for word wrap.
Signed-off-by:
joachim99
<
joachim.eibl@gmx.de
>
parent
1535c52c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
24 deletions
+77
-24
src/common.cpp
src/common.cpp
+1
-2
src/difftextwindow.cpp
src/difftextwindow.cpp
+43
-12
src/kdiff3.h
src/kdiff3.h
+1
-1
src/kreplacements/ShellContextMenu.cpp
src/kreplacements/ShellContextMenu.cpp
+1
-0
src/pdiff.cpp
src/pdiff.cpp
+31
-9
No files found.
src/common.cpp
View file @
d8d48199
...
...
@@ -242,9 +242,8 @@ QFont ValueMap::readFontEntry(const QString& k, const QFont* defaultVal )
f
.
setFamily
(
subSection
(
i
->
second
,
0
,
','
)
);
f
.
setPointSize
(
subSection
(
i
->
second
,
1
,
','
).
toInt
()
);
f
.
setBold
(
subSection
(
i
->
second
,
2
,
','
)
==
"bold"
);
//f.fromString(i->second);
}
f
.
setKerning
(
false
);
return
f
;
}
...
...
src/difftextwindow.cpp
View file @
d8d48199
...
...
@@ -94,6 +94,16 @@ public:
Diff3WrapLineVector
m_diff3WrapLineVector
;
const
ManualDiffHelpList
*
m_pManualDiffHelpList
;
class
WrapLineCacheData
{
public:
WrapLineCacheData
()
:
m_d3LineIdx
(
0
),
m_textStart
(
0
),
m_textLength
(
0
)
{}
WrapLineCacheData
(
int
d3LineIdx
,
int
textStart
,
int
textLength
)
:
m_d3LineIdx
(
d3LineIdx
),
m_textStart
(
textStart
),
m_textLength
(
textLength
)
{}
int
m_d3LineIdx
;
int
m_textStart
;
int
m_textLength
;
};
QVector
<
WrapLineCacheData
>
m_wrapLineCache
;
Options
*
m_pOptions
;
QColor
m_cThis
;
QColor
m_cDiff1
;
...
...
@@ -834,8 +844,8 @@ void DiffTextWindowData::prepareTextLayout( QTextLayout& textLayout, bool bFirst
break
;
height
+=
leading
;
if
(
!
bFirstLine
)
indentation
=
m_pDiffTextWindow
->
fontMetrics
().
width
(
' '
)
*
m_pOptions
->
m_tabSize
;
//
if ( !bFirstLine )
//
indentation = m_pDiffTextWindow->fontMetrics().width(' ') * m_pOptions->m_tabSize;
if
(
visibleTextWidth
>=
0
)
{
line
.
setLineWidth
(
visibleTextWidth
-
indentation
);
...
...
@@ -996,7 +1006,7 @@ void DiffTextWindowData::writeLine(
++
outPos
;
}
// end for
QTextLayout
textLayout
(
lineString
.
mid
(
wrapLineOffset
,
lineLength
),
m_pDiffTextWindow
->
font
(),
m_pDiffTextWindow
);
QTextLayout
textLayout
(
lineString
.
mid
(
wrapLineOffset
,
lineLength
-
wrapLineOffset
),
m_pDiffTextWindow
->
font
(),
m_pDiffTextWindow
);
prepareTextLayout
(
textLayout
,
!
m_bWordWrap
||
wrapLineOffset
==
0
);
textLayout
.
draw
(
&
p
,
QPoint
(
0
,
yOffset
),
frh
.
m_formatRanges
/*, const QRectF & clip = QRectF() */
);
}
...
...
@@ -1526,6 +1536,9 @@ void DiffTextWindow::recalcWordWrap( bool bWordWrap, int wrapLineVectorSize, int
d
->
m_bWordWrap
=
bWordWrap
;
if
(
!
bWordWrap
||
wrapLineVectorSize
==
0
)
d
->
m_wrapLineCache
.
clear
();
if
(
bWordWrap
)
{
ProgressProxy
pp
;
...
...
@@ -1539,27 +1552,45 @@ void DiffTextWindow::recalcWordWrap( bool bWordWrap, int wrapLineVectorSize, int
visibleTextWidth
-=
d
->
leftInfoWidth
()
*
fontMetrics
().
width
(
'0'
);
int
i
;
int
wrapLineIdx
=
0
;
int
wrapLineCacheIdx
=
0
;
int
size
=
d
->
m_pDiff3LineVector
->
size
();
pp
.
setMaxNofSteps
(
size
);
for
(
i
=
0
;
i
<
size
;
++
i
)
{
pp
.
setInformation
(
i18n
(
"Word wrap"
),
double
(
i
)
/
size
,
false
);
if
(
pp
.
wasCancelled
()
)
break
;
return
;
QString
s
=
d
->
getString
(
i
);
QTextLayout
textLayout
(
s
,
font
(),
this
);
d
->
prepareTextLayout
(
textLayout
,
true
,
visibleTextWidth
);
int
linesNeeded
=
textLayout
.
lineCount
();
if
(
wrapLineVectorSize
>
0
)
int
linesNeeded
=
0
;
if
(
wrapLineVectorSize
==
0
)
{
QString
s
=
d
->
getString
(
i
);
QTextLayout
textLayout
(
s
,
font
(),
this
);
d
->
prepareTextLayout
(
textLayout
,
true
,
visibleTextWidth
);
linesNeeded
=
textLayout
.
lineCount
();
for
(
int
l
=
0
;
l
<
linesNeeded
;
++
l
)
{
Diff3WrapLine
*
pDiff3WrapLine
=
&
d
->
m_diff3WrapLineVector
[
wrapLineIdx
+
l
];
//
Diff3WrapLine* pDiff3WrapLine = &d->m_diff3WrapLineVector[ wrapLineIdx + l ];
QTextLine
line
=
textLayout
.
lineAt
(
l
);
pDiff3WrapLine
->
wrapLineOffset
=
line
.
textStart
();
pDiff3WrapLine
->
wrapLineLength
=
line
.
textLength
();
d
->
m_wrapLineCache
.
push_back
(
DiffTextWindowData
::
WrapLineCacheData
(
i
,
line
.
textStart
(),
line
.
textLength
())
);
}
}
else
if
(
wrapLineVectorSize
>
0
)
{
while
(
wrapLineCacheIdx
<
d
->
m_wrapLineCache
.
count
()
&&
d
->
m_wrapLineCache
[
wrapLineCacheIdx
].
m_d3LineIdx
<
i
)
++
wrapLineCacheIdx
;
int
l
=
0
;
while
(
wrapLineCacheIdx
<
d
->
m_wrapLineCache
.
count
()
&&
d
->
m_wrapLineCache
[
wrapLineCacheIdx
].
m_d3LineIdx
==
i
)
{
Diff3WrapLine
*
pDiff3WrapLine
=
&
d
->
m_diff3WrapLineVector
[
wrapLineIdx
+
l
];
pDiff3WrapLine
->
wrapLineOffset
=
d
->
m_wrapLineCache
[
wrapLineCacheIdx
].
m_textStart
;
pDiff3WrapLine
->
wrapLineLength
=
d
->
m_wrapLineCache
[
wrapLineCacheIdx
].
m_textLength
;
++
l
;
++
wrapLineCacheIdx
;
}
linesNeeded
=
l
;
}
Diff3Line
&
d3l
=
*
(
*
d
->
m_pDiff3LineVector
)[
i
];
...
...
src/kdiff3.h
View file @
d8d48199
...
...
@@ -326,7 +326,7 @@ class KDiff3App : public QSplitter
KParts
::
MainWindow
*
m_pKDiff3Shell
;
bool
m_bAutoFlag
;
bool
m_bAutoMode
;
void
recalcWordWrap
(
int
nofVisibleColumns
=-
1
);
bool
recalcWordWrap
(
int
nofVisibleColumns
=-
1
);
bool
m_bRecalcWordWrapPosted
;
void
setHScrollBarRange
();
...
...
src/kreplacements/ShellContextMenu.cpp
View file @
d8d48199
...
...
@@ -22,6 +22,7 @@
#include "stable.h"
#include <windows.h>
#include <shlobj.h>
#include <shlguid.h>
#include <malloc.h>
//#include <QString>
//#include <QStringList>
...
...
src/pdiff.cpp
View file @
d8d48199
...
...
@@ -1523,7 +1523,12 @@ void KDiff3App::slotAutoAdvanceToggled()
void
KDiff3App
::
slotWordWrapToggled
()
{
m_pOptions
->
m_bWordWrap
=
wordWrap
->
isChecked
();
recalcWordWrap
();
bool
bSuccess
=
recalcWordWrap
();
if
(
!
bSuccess
)
{
wordWrap
->
setChecked
(
false
);
slotWordWrapToggled
();
}
}
void
KDiff3App
::
postRecalcWordWrap
()
...
...
@@ -1537,11 +1542,17 @@ void KDiff3App::postRecalcWordWrap()
void
KDiff3App
::
slotRecalcWordWrap
()
{
recalcWordWrap
();
bool
bSuccess
=
recalcWordWrap
();
m_bRecalcWordWrapPosted
=
false
;
if
(
!
bSuccess
)
{
wordWrap
->
setChecked
(
false
);
slotWordWrapToggled
();
}
}
void
KDiff3App
::
recalcWordWrap
(
int
nofVisibleColumns
)
// nofVisibleColumns is >=0 only for printing, otherwise the really visible width is used
bool
KDiff3App
::
recalcWordWrap
(
int
nofVisibleColumns
)
// nofVisibleColumns is >=0 only for printing, otherwise the really visible width is used
{
bool
bPrinting
=
nofVisibleColumns
>=
0
;
int
firstD3LIdx
=
0
;
...
...
@@ -1570,22 +1581,28 @@ void KDiff3App::recalcWordWrap(int nofVisibleColumns) // nofVisibleColumns is >=
}
ProgressProxy
pp
;
pp
.
setMaxNofSteps
(
(
m_bTripleDiff
?
6
:
4
)
);
pp
.
setInformation
(
"Word wrap"
,
false
);
pp
.
setMaxNofSteps
(
(
m_bTripleDiff
?
4
:
3
)
);
pp
.
setInformation
(
i18n
(
"Word wrap (Cancel disables word wrap)"
)
,
false
);
// Let every window calc how many lines will be needed.
if
(
m_pDiffTextWindow1
)
{
m_pDiffTextWindow1
->
recalcWordWrap
(
true
,
0
,
nofVisibleColumns
);
if
(
pp
.
wasCancelled
()
)
return
false
;
pp
.
step
();
}
if
(
m_pDiffTextWindow2
)
{
m_pDiffTextWindow2
->
recalcWordWrap
(
true
,
0
,
nofVisibleColumns
);
if
(
pp
.
wasCancelled
()
)
return
false
;
pp
.
step
();
}
if
(
m_pDiffTextWindow3
)
{
m_pDiffTextWindow3
->
recalcWordWrap
(
true
,
0
,
nofVisibleColumns
);
if
(
pp
.
wasCancelled
()
)
return
false
;
pp
.
step
();
}
...
...
@@ -1601,18 +1618,22 @@ void KDiff3App::recalcWordWrap(int nofVisibleColumns) // nofVisibleColumns is >=
if
(
m_pDiffTextWindow1
)
{
m_pDiffTextWindow1
->
recalcWordWrap
(
true
,
sumOfLines
,
nofVisibleColumns
);
pp
.
step
();
if
(
pp
.
wasCancelled
()
)
return
false
;
}
if
(
m_pDiffTextWindow2
)
{
m_pDiffTextWindow2
->
recalcWordWrap
(
true
,
sumOfLines
,
nofVisibleColumns
);
pp
.
step
();
if
(
pp
.
wasCancelled
()
)
return
false
;
}
if
(
m_pDiffTextWindow3
)
{
m_pDiffTextWindow3
->
recalcWordWrap
(
true
,
sumOfLines
,
nofVisibleColumns
);
pp
.
step
();
if
(
pp
.
wasCancelled
()
)
return
false
;
}
pp
.
step
();
m_neededLines
=
sumOfLines
;
}
...
...
@@ -1627,7 +1648,7 @@ void KDiff3App::recalcWordWrap(int nofVisibleColumns) // nofVisibleColumns is >=
m_pDiffTextWindow3
->
recalcWordWrap
(
false
,
0
,
0
);
}
if
(
bPrinting
)
return
;
return
true
;
if
(
m_pOverview
)
m_pOverview
->
slotRedraw
();
...
...
@@ -1656,6 +1677,7 @@ void KDiff3App::recalcWordWrap(int nofVisibleColumns) // nofVisibleColumns is >=
setHScrollBarRange
();
m_pHScrollBar
->
setValue
(
0
);
}
return
true
;
}
void
KDiff3App
::
slotShowWhiteSpaceToggled
()
...
...
Write
Preview
Markdown
is supported
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