Commit 17f6836b authored by Robert Knight's avatar Robert Knight

Add facility to set the terminal cursor color.

svn path=/branches/work/konsole-split-view/; revision=650416
parent d6b2fc3b
......@@ -661,6 +661,29 @@ void TerminalDisplay::drawTextFixed(QPainter& painter, int x, int y, QString& st
}
}*/
void TerminalDisplay::setKeyboardCursorShape(KeyboardCursorShape shape)
{
_cursorShape = shape;
}
TerminalDisplay::KeyboardCursorShape TerminalDisplay::keyboardCursorShape() const
{
return _cursorShape;
}
void TerminalDisplay::setKeyboardCursorColor(bool useForegroundColor, const QColor& color)
{
if (useForegroundColor)
_cursorColor = QColor(); // an invalid color means that
// the foreground color of the
// current character should
// be used
else
_cursorColor = color;
}
QColor TerminalDisplay::keyboardCursorColor() const
{
return _cursorColor;
}
/*!
attributed string draw primitive
......@@ -753,18 +776,25 @@ void TerminalDisplay::drawAttrStr(QPainter &paint, const QRect& rect,
QRect r(rect.x(),rect.y()+_lineSpacing/2,rect.width(),h);
if (!_cursorBlinking)
{
paint.setPen(fColor);
if ( _cursorColor.isValid() )
paint.setPen(_cursorColor);
else
paint.setPen(fColor);
if ( _cursorShape == BlockCursor )
{
paint.drawRect(rect.x(),rect.y()+_lineSpacing/2,rect.width()-1,h-1);
if ( hasFocus() )
{
paint.fillRect(r,fColor);
paint.fillRect(r, _cursorColor.isValid() ? _cursorColor : fColor);
}
if ( !_cursorColor.isValid() )
{
// invert the colour used to draw the text to ensure that the character at
// the cursor position is readable
fColor = bColor;
}
// invert the colour used to draw the text to ensure that the character at
// the cursor position is readable
fColor = bColor;
}
else if ( _cursorShape == UnderlineCursor )
paint.drawLine(rect.left(),rect.top()+h-1,rect.right(),rect.top()+h-1);
......
......@@ -195,6 +195,28 @@ public:
*/
KeyboardCursorShape keyboardCursorShape() const;
/**
* Sets the color used to draw the keyboard cursor.
*
* The keyboard cursor defaults to using the foreground color of the character
* underneath it.
*
* @param useForegroundColor If true, the cursor color will change to match
* the foreground color of the character underneath it as it is moved, in this
* case, the @p color parameter is ignored and the color of the character
* under the cursor is inverted to ensure that it is still readable.
* @param color The color to use to draw the cursor. This is only taken into
* account if @p useForegroundColor is false.
*/
void setKeyboardCursorColor(bool useForegroundColor , const QColor& color);
/**
* Returns the color of the keyboard cursor, or an invalid color if the keyboard
* cursor color is set to change according to the foreground color of the character
* underneath it.
*/
QColor keyboardCursorColor() const;
/**
* Returns the number of lines of text which can be displayed in the widget.
*
......@@ -641,6 +663,7 @@ private:
QRect _mouseOverHotspotArea;
KeyboardCursorShape _cursorShape;
QColor _cursorColor;
//the delay in milliseconds between redrawing blinking text
static const int BLINK_DELAY = 500;
......
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