Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 2c04e149 authored by Joachim Eibl's avatar Joachim Eibl

Adjusted Wordwrap for variable width fonts

Signed-off-by: default avatarjoachim99 <joachim.eibl@gmx.de>
parent fa7f0a25
This diff is collapsed.
......@@ -61,7 +61,7 @@ public:
int getMaxTextWidth();
int getNofLines();
int getNofVisibleLines();
int getVisibleTextWidth();
int getVisibleTextAreaWidth();
int convertLineToDiff3LineIdx( int line );
int convertDiff3LineIdxToLine( int d3lIdx );
......
......@@ -844,12 +844,11 @@ void KDiff3App::slotFilePrint()
QRect view2( 1*(columnWidth + columnDistance), view.top(), columnWidth, view.height() );
QRect view3( 2*(columnWidth + columnDistance), view.top(), columnWidth, view.height() );
int linesPerPage = view.height() / fm.height();
int charactersPerLine = columnWidth / fm.width("W");
int linesPerPage = view.height() / fm.lineSpacing();
if ( m_pOptions->m_bWordWrap )
{
// For printing the lines are wrapped differently (this invalidates the first line)
recalcWordWrap( charactersPerLine );
recalcWordWrap( columnWidth );
}
int totalNofLines = max2(m_pDiffTextWindow1->getNofLines(), m_pDiffTextWindow2->getNofLines());
......
......@@ -541,7 +541,7 @@ int MergeResultWindow::getNofLines()
return m_totalSize;
}
int MergeResultWindow::getVisibleTextWidth()
int MergeResultWindow::getVisibleTextAreaWidth()
{
QFontMetrics fm = fontMetrics();
return width() - 4 * fm.width('0');
......@@ -550,7 +550,7 @@ int MergeResultWindow::getVisibleTextWidth()
int MergeResultWindow::getNofVisibleLines()
{
QFontMetrics fm = fontMetrics();
return (height()-3)/fm.height()-2;
return (height()-3)/fm.lineSpacing()-2;
}
int MergeResultWindow::getTextXOffset()
......@@ -1700,7 +1700,7 @@ void MergeResultWindow::writeLine(
)
{
const QFontMetrics& fm = fontMetrics();
int fontHeight = fm.height();
int fontHeight = fm.lineSpacing();
int fontAscent = fm.ascent();
int topLineYOffset = 0;
......@@ -1750,27 +1750,6 @@ void MergeResultWindow::writeLine(
QTextLayout textLayout( str, font(), this );
QVector<QTextLayout::FormatRange> selectionFormat = getTextLayoutForLine( line, str, textLayout );
// // TODO tabs
// QVector<QTextLayout::FormatRange> selectionFormat;
// textLayout.beginLayout();
// if ( m_selection.lineWithin( line ) )
// {
// int firstPosInText = convertToPosInText( str, m_selection.firstPosInLine(line), m_pOptions->m_tabSize );
// int lastPosInText = convertToPosInText( str, m_selection.lastPosInLine(line), m_pOptions->m_tabSize );
// int lengthInText = max2(0,lastPosInText - firstPosInText);
// if (lengthInText>0)
// m_selection.bSelectionContainsData = true;
// QTextLayout::FormatRange selection;
// selection.start = firstPosInText;
// selection.length = lengthInText;
// selection.format.setBackground( palette().highlight() );
// selection.format.setForeground( palette().highlightedText().color() );
// selectionFormat.push_back( selection );
// }
// QTextLine textLine = textLayout.createLine();
// textLine.setPosition(QPointF(0, fm.leading()));
// textLayout.endLayout();
textLayout.draw( &p, QPointF(xOffset - m_horizScrollOffset, yOffset), selectionFormat );
if ( line == m_cursorYPos )
......@@ -1852,7 +1831,7 @@ void MergeResultWindow::paintEvent( QPaintEvent* )
bool bOldSelectionContainsData = m_selection.bSelectionContainsData;
const QFontMetrics& fm = fontMetrics();
int fontHeight = fm.height();
int fontHeight = fm.lineSpacing();
int fontWidth = fm.width('0');
int fontAscent = fm.ascent();
......@@ -1994,7 +1973,7 @@ void MergeResultWindow::focusInEvent( QFocusEvent* e )
int MergeResultWindow::convertToLine( int y )
{
const QFontMetrics& fm = fontMetrics();
int fontHeight = fm.height();
int fontHeight = fm.lineSpacing();
int topLineYOffset = 0;
int yOffset = topLineYOffset - m_firstLine * fontHeight;
......@@ -2187,7 +2166,7 @@ void MergeResultWindow::slotCursorUpdate()
const QFontMetrics& fm = fontMetrics();
int topLineYOffset = 0;
//int xOffset = getTextXOffset();
int yOffset = ( m_cursorYPos - m_firstLine ) * fm.height() + topLineYOffset;
int yOffset = ( m_cursorYPos - m_firstLine ) * fm.lineSpacing() + topLineYOffset;
//int xCursor = ( m_cursorXPos - m_firstColumn ) * fontWidth + xOffset;
//if (!m_pOptions->m_bRightToLeftLanguage)
......
......@@ -122,7 +122,7 @@ public:
int getMaxTextWidth(); // width of longest text line
int getNofLines();
int getVisibleTextWidth(); // area width - border
int getVisibleTextAreaWidth(); // text area width without the border
int getNofVisibleLines();
QString getSelection();
void resetSelection();
......
......@@ -492,10 +492,10 @@ void KDiff3App::setHScrollBarRange()
int wm = m_pMergeResultWindow!=0 && m_pMergeResultWindow->isVisible() ? m_pMergeResultWindow->getMaxTextWidth() : 0;
int v1 = m_pDiffTextWindow1!=0 && m_pDiffTextWindow1->isVisible() ? m_pDiffTextWindow1->getVisibleTextWidth() : 0;
int v2 = m_pDiffTextWindow2!=0 && m_pDiffTextWindow2->isVisible() ? m_pDiffTextWindow2->getVisibleTextWidth() : 0;
int v3 = m_pDiffTextWindow3!=0 && m_pDiffTextWindow3->isVisible() ? m_pDiffTextWindow3->getVisibleTextWidth() : 0;
int vm = m_pMergeResultWindow!=0 && m_pMergeResultWindow->isVisible() ? m_pMergeResultWindow->getVisibleTextWidth() : 0;
int v1 = m_pDiffTextWindow1!=0 && m_pDiffTextWindow1->isVisible() ? m_pDiffTextWindow1->getVisibleTextAreaWidth() : 0;
int v2 = m_pDiffTextWindow2!=0 && m_pDiffTextWindow2->isVisible() ? m_pDiffTextWindow2->getVisibleTextAreaWidth() : 0;
int v3 = m_pDiffTextWindow3!=0 && m_pDiffTextWindow3->isVisible() ? m_pDiffTextWindow3->getVisibleTextAreaWidth() : 0;
int vm = m_pMergeResultWindow!=0 && m_pMergeResultWindow->isVisible() ? m_pMergeResultWindow->getVisibleTextAreaWidth() : 0;
// Find the minimum, but don't consider 0.
int pageStep = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment