Commit 61d1e13d authored by Robert Knight's avatar Robert Knight
Browse files

Fix consecutive non-word characters being treated as a single word.

TerminalDisplay::charClass() used to return one of three values to indicate whether
the input was a space, "word character" (letter, number or character from the wordCharacters() array)
or something else.  When double clicking a 'word' was taken to be a run of
characters which had the same charClass().  Fix this by returning the input character
in charClass() if it is not a space or word character.

CCBUG:155416

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=791732
parent 32cc9f25
......@@ -1801,7 +1801,7 @@ void TerminalDisplay::extendSelection( const QPoint& position )
{
// Extend to word boundaries
int i;
int selClass;
QChar selClass;
bool left_not_right = ( here.y() < _iPntSelCorr.y() ||
here.y() == _iPntSelCorr.y() && here.x() < _iPntSelCorr.x() );
......@@ -1878,7 +1878,7 @@ void TerminalDisplay::extendSelection( const QPoint& position )
if ( !_wordSelectionMode && !_lineSelectionMode )
{
int i;
int selClass;
QChar selClass;
bool left_not_right = ( here.y() < _iPntSelCorr.y() ||
here.y() == _iPntSelCorr.y() && here.x() < _iPntSelCorr.x() );
......@@ -2067,7 +2067,7 @@ void TerminalDisplay::mouseDoubleClickEvent(QMouseEvent* ev)
_wordSelectionMode = true;
// find word boundaries...
int selClass = charClass(_image[i].character);
QChar selClass = charClass(_image[i].character);
{
// find the start of the word
int x = bgnSel.x();
......@@ -2206,7 +2206,7 @@ void TerminalDisplay::mouseTripleClickEvent(QMouseEvent* ev)
if (_tripleClickMode == SelectForwardsFromCursor) {
// find word boundary start
int i = loc(_iPntSel.x(),_iPntSel.y());
int selClass = charClass(_image[i].character);
QChar selClass = charClass(_image[i].character);
int x = _iPntSel.x();
while ( ((x>0) ||
......@@ -2252,16 +2252,14 @@ bool TerminalDisplay::focusNextPrevChild( bool next )
}
int TerminalDisplay::charClass(quint16 ch) const
QChar TerminalDisplay::charClass(QChar qch) const
{
QChar qch=QChar(ch);
if ( qch.isSpace() ) return ' ';
if ( qch.isLetterOrNumber() || _wordCharacters.contains(qch, Qt::CaseInsensitive ) )
return 'a';
// Everything else is weird
return 1;
return qch;
}
void TerminalDisplay::setWordCharacters(const QString& wc)
......
......@@ -546,7 +546,13 @@ protected:
QDrag *dragObject;
} dragInfo;
virtual int charClass(quint16) const;
// classifies the 'ch' into one of three categories
// and returns a character to indicate which category it is in
//
// - A space (returns ' ')
// - Part of a word (returns 'a')
// - Other characters (returns the input character)
QChar charClass(QChar ch) const;
void clearImage();
......
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