Commit 6b56d354 authored by Robert Knight's avatar Robert Knight
Browse files

Fix bug where new lines were being inserted into the selection and copied...

Fix bug where new lines were being inserted into the selection and copied text.  I misunderstood the meaning of the preserveLineBreaks argument passed from the terminal display to the terminal screen when rewriting the terminal characters -> text conversion code.  Also removed dead code.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=740173
parent e98a26e1
......@@ -1248,21 +1248,6 @@ bool Screen::isSelected( const int x,const int y)
}
}
/*static bool isSpace(UINT16 c)
{
if ((c > 32) && (c < 127))
return false;
if ((c == 32) || (c == 0))
return true;
QChar qc(c);
return qc.isSpace();
}*/
//FIXME: preserve_line_breaks not handled yet.
// I considered removing this parameter altogether, requiring
// writeToStream() to be used if text needs to be retrieved as
// it appears on screen.
// -- needs more thought on the issue first though.
QString Screen::selectedText(bool preserveLineBreaks)
{
QString result;
......@@ -1276,40 +1261,6 @@ QString Screen::selectedText(bool preserveLineBreaks)
return result;
}
/*
static QString makeString(int *m, int d, bool stripTrailingSpaces)
{
QChar* qc = new QChar[d];
int last_space = -1;
int j = 0;
for (int i = 0; i < d; i++, j++)
{
if (m[i] == ' ')
{
if (last_space == -1)
last_space = j;
}
else
{
last_space = -1;
}
qc[j] = m[i];
}
if ((last_space != -1) && stripTrailingSpaces)
{
// Strip trailing spaces
j = last_space;
}
QString res(qc, j);
delete [] qc;
return res;
}*/
bool Screen::isSelectionValid() const
{
return ( sel_TL >= 0 && sel_BR >= 0 );
......@@ -1431,7 +1382,7 @@ void Screen::copyLineToStream(int line ,
break;
// add new line character at end
const bool omitLineBreak = (currentLineProperties & LINE_WRAPPED) &&
const bool omitLineBreak = (currentLineProperties & LINE_WRAPPED) ||
!preserveLineBreaks;
if ( !omitLineBreak && appendNewLine && (count+1 < MAX_CHARS) )
......
......@@ -430,10 +430,10 @@ public:
/**
* Convenience method. Returns the currently selected text.
* @param preserve_line_breaks TODO: Not yet handled in KDE 4. See comments near definition.
* (Currently the resulting string always includes line-breaks)
* @param preserveLineBreaks Specifies whether new line characters should be inserted into
* the returned text at the end of each terminal line.
*/
QString selectedText(bool preserve_line_breaks);
QString selectedText(bool preserveLineBreaks);
/**
* Copies part of the output to a stream.
......@@ -457,9 +457,8 @@ public:
* @param decoder A decoder which converts terminal characters into text. PlainTextDecoder
* is the most commonly used decoder which coverts characters into plain
* text with no formatting.
* @param preserveLineBreaks Specifies whether line breaks that have been added
* to break up long lines of text should be preserved in the output ( in which case
* new line characters will be added after the end of each line).
* @param preserveLineBreaks Specifies whether new line characters should be inserted into
* the returned text at the end of each terminal line.
*/
void writeSelectionToStream(TerminalCharacterDecoder* decoder , bool
preserveLineBreaks = true);
......
......@@ -203,7 +203,7 @@ public:
/**
* Returns the text which is currently selected.
*
* @param preserveLineBreaks TODO: Document me
* @param preserveLineBreaks See Screen::selectedText()
*/
QString selectedText( bool preserveLineBreaks ) const;
......
......@@ -258,7 +258,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
,_actSel(0)
,_wordSelectionMode(false)
,_lineSelectionMode(false)
,_preserveLineBreaks(true)
,_preserveLineBreaks(false)
,_columnSelectionMode(false)
,_scrollbarLocation(NoScrollBar)
,_wordCharacters(":@-./_~")
......@@ -2219,7 +2219,7 @@ void TerminalDisplay::copyClipboard()
if ( !_screenWindow )
return;
QString text = _screenWindow->selectedText(false);
QString text = _screenWindow->selectedText(_preserveLineBreaks);
QApplication::clipboard()->setText(text);
}
......
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