Commit d6b2fc3b authored by Robert Knight's avatar Robert Knight

Add support for different cursor shapes in the terminal. Currently supported...

Add support for different cursor shapes in the terminal.  Currently supported are Block, Underline and IBeam.

svn path=/branches/work/konsole-split-view/; revision=650413
parent 814fdfbc
......@@ -397,6 +397,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
,_isIMEdit(false)
,_blendColor(qRgba(0,0,0,0xff))
,_filterChain(new TerminalImageFilterChain())
,_cursorShape(BlockCursor)
{
// The offsets are not yet calculated.
// Do not calculate these too often to be more smoothly when _resizing
......@@ -750,18 +751,26 @@ void TerminalDisplay::drawAttrStr(QPainter &paint, const QRect& rect,
paint.setBackgroundMode( Qt::TransparentMode );
int h = _fontHeight - _lineSpacing;
QRect r(rect.x(),rect.y()+_lineSpacing/2,rect.width(),h);
if (hasFocus())
if (!_cursorBlinking)
{
if (!_cursorBlinking)
paint.setPen(fColor);
if ( _cursorShape == BlockCursor )
{
paint.fillRect(r, fColor);
fColor = bColor;
paint.drawRect(rect.x(),rect.y()+_lineSpacing/2,rect.width()-1,h-1);
if ( hasFocus() )
{
paint.fillRect(r,fColor);
}
// invert the colour used to draw the text to ensure that the character at
// the cursor position is readable
fColor = bColor;
}
}
else
{
paint.setPen(fColor);
paint.drawRect(rect.x(),rect.y()+_lineSpacing/2,rect.width()-1,h-1);
else if ( _cursorShape == UnderlineCursor )
paint.drawLine(rect.left(),rect.top()+h-1,rect.right(),rect.top()+h-1);
else if ( _cursorShape == IBeamCursor )
paint.drawLine(rect.left(),rect.top(),rect.left(),rect.top()+h-1);
}
}
......
......@@ -160,6 +160,41 @@ public:
void setCursorPos(const int curx, const int cury);
/**
* This enum describes the available shapes for the keyboard cursor.
* See setKeyboardCursorShape()
*/
enum KeyboardCursorShape
{
/** A rectangular block which covers the entire area of the cursor character. */
BlockCursor,
/**
* A single flat line which occupies the space at the bottom of the cursor
* character's area.
*/
UnderlineCursor,
/**
* An cursor shaped like the capital letter 'I', similar to the IBeam
* cursor used in Qt/KDE text editors.
*/
IBeamCursor
};
/**
* Sets the shape of the keyboard cursor. This is the cursor drawn
* at the position in the terminal where keyboard input will appear.
*
* In addition the terminal display widget also has a cursor for
* the mouse pointer, which can be set using the QWidget::setCursor()
* method.
*
* Defaults to BlockCursor
*/
void setKeyboardCursorShape(KeyboardCursorShape shape);
/**
* Returns the shape of the keyboard cursor. See setKeyboardCursorShape()
*/
KeyboardCursorShape keyboardCursorShape() const;
/**
* Returns the number of lines of text which can be displayed in the widget.
*
......@@ -406,6 +441,7 @@ protected:
void drawAttrStr(QPainter &paint, const QRect& rect,
QString& str, const Character *attr, bool pm, bool clear);
void paintEvent( QPaintEvent * );
void paintContents(QPainter &paint, const QRect &rect);
......@@ -604,8 +640,10 @@ private:
TerminalImageFilterChain* _filterChain;
QRect _mouseOverHotspotArea;
KeyboardCursorShape _cursorShape;
//the delay in milliseconds between redrawing blinking text
static const int BLINK_DELAY = 750;
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