|
|
|
@ -260,7 +260,7 @@ void TerminalDisplay::setVTFont(const QFont& f)
|
|
|
|
|
|
|
|
|
|
if ( !QFontInfo(font).fixedPitch() )
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "Using an unsupported variable-width font in the terminal. This may produce display errors.";
|
|
|
|
|
qDebug() << "Using a variable-width font in the terminal. This may cause performance degradation and display/alignment errors.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( metrics.height() < height() && metrics.maxWidth() < width() )
|
|
|
|
@ -1398,6 +1398,27 @@ void TerminalDisplay::paintFilters(QPainter& painter)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TerminalDisplay::textWidth(const int startColumn, const int length, const int line) const
|
|
|
|
|
{
|
|
|
|
|
QFontMetrics fm(font());
|
|
|
|
|
int result = 0;
|
|
|
|
|
for (int column = 0; column < length; column++) {
|
|
|
|
|
result += fm.width(_image[loc(startColumn + column, line)].character);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QRect TerminalDisplay::calculateTextArea(int topLeftX, int topLeftY, int startColumn, int line, int length) {
|
|
|
|
|
int left = _fixedFont ? _fontWidth * startColumn : textWidth(0, startColumn, line);
|
|
|
|
|
int top = _fontHeight * line;
|
|
|
|
|
int width = _fixedFont ? _fontWidth * length : textWidth(startColumn, length, line);
|
|
|
|
|
return QRect(_leftMargin + topLeftX + left,
|
|
|
|
|
_topMargin + topLeftY + top,
|
|
|
|
|
width,
|
|
|
|
|
_fontHeight);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TerminalDisplay::drawContents(QPainter &paint, const QRect &rect)
|
|
|
|
|
{
|
|
|
|
|
QPoint tL = contentsRect().topLeft();
|
|
|
|
@ -1496,7 +1517,7 @@ void TerminalDisplay::drawContents(QPainter &paint, const QRect &rect)
|
|
|
|
|
paint.setWorldMatrix(textScale, true);
|
|
|
|
|
|
|
|
|
|
//calculate the area in which the text will be drawn
|
|
|
|
|
QRect textArea = QRect( _leftMargin+tLx+_fontWidth*x , _topMargin+tLy+_fontHeight*y , _fontWidth*len , _fontHeight);
|
|
|
|
|
QRect textArea = calculateTextArea(tLx, tLy, x, y, len);
|
|
|
|
|
|
|
|
|
|
//move the calculated area to take account of scaling applied to the painter.
|
|
|
|
|
//the position of the area from the origin (0,0) is scaled
|
|
|
|
@ -2184,9 +2205,19 @@ void TerminalDisplay::mouseReleaseEvent(QMouseEvent* ev)
|
|
|
|
|
|
|
|
|
|
void TerminalDisplay::getCharacterPosition(const QPoint& widgetPoint,int& line,int& column) const
|
|
|
|
|
{
|
|
|
|
|
column = (widgetPoint.x() + _fontWidth/2 -contentsRect().left()-_leftMargin) / _fontWidth;
|
|
|
|
|
line = (widgetPoint.y()-contentsRect().top()-_topMargin) / _fontHeight;
|
|
|
|
|
|
|
|
|
|
if ( _fixedFont )
|
|
|
|
|
column = (widgetPoint.x() + _fontWidth/2 -contentsRect().left()-_leftMargin) / _fontWidth;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int x = contentsRect().left() + widgetPoint.x() - _fontWidth/2;
|
|
|
|
|
column = 0;
|
|
|
|
|
|
|
|
|
|
while(x > textWidth(0, column, line))
|
|
|
|
|
column++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( line < 0 )
|
|
|
|
|
line = 0;
|
|
|
|
|
if ( column < 0 )
|
|
|
|
@ -2450,8 +2481,11 @@ void TerminalDisplay::setWordCharacters(const QString& wc)
|
|
|
|
|
|
|
|
|
|
void TerminalDisplay::setUsesMouse(bool on)
|
|
|
|
|
{
|
|
|
|
|
if (_mouseMarks != on) {
|
|
|
|
|
_mouseMarks = on;
|
|
|
|
|
setCursor( _mouseMarks ? Qt::IBeamCursor : Qt::ArrowCursor );
|
|
|
|
|
emit usesMouseChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bool TerminalDisplay::usesMouse() const
|
|
|
|
|
{
|
|
|
|
@ -2913,7 +2947,7 @@ void TerminalDisplay::dragEnterEvent(QDragEnterEvent* event)
|
|
|
|
|
{
|
|
|
|
|
if (event->mimeData()->hasFormat("text/plain"))
|
|
|
|
|
event->acceptProposedAction();
|
|
|
|
|
if (event->mimeData()->urls().count());
|
|
|
|
|
if (event->mimeData()->urls().count())
|
|
|
|
|
event->acceptProposedAction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|