Adding upstream version 0.7.1.

Signed-off-by: Alf Gaida <agaida@siduction.org>
upstream/0.7.1
Alf Gaida 8 years ago
parent 8876f8d930
commit c5d1ed45e8
No known key found for this signature in database
GPG Key ID: CD280A0B4D72827C

@ -1,7 +1,24 @@
qtermwidget-0.7.0 / 2016-09-24 qtermwidget-0.7.1 / 2016-12-21
============================== ==============================
* Bump patch version (#105)
* Added a modified Breeze color scheme (#104)
* Accept hex color strings as well (#101)
* Remove the stale lib/README (#102)
* Implement background images (#95)
* Implement other BOX DRAWING characters (#98)
* Preparations for context menu actions on URLs (#97)
* Drop the ancient wcwidth impl. and use utf8proc if possible (#99)
* Remove widget size checks in setVTFont() (#86)
* Delete unused tooltip code (#81)
* Fix size of the array passed to memset() (#79)
* Remove cpack (#93)
0.7.0 / 2016-09-24
==================
* Release 0.7.0: Add changelog
* Bump version to 0.7.0 (#92) * Bump version to 0.7.0 (#92)
* Add Solarized Color Schemes * Add Solarized Color Schemes
* Update README.md * Update README.md

@ -9,7 +9,7 @@ option(BUILD_TEST "Build test application. Default OFF." OFF)
# just change version for releases # just change version for releases
set(QTERMWIDGET_VERSION_MAJOR "0") set(QTERMWIDGET_VERSION_MAJOR "0")
set(QTERMWIDGET_VERSION_MINOR "7") set(QTERMWIDGET_VERSION_MINOR "7")
set(QTERMWIDGET_VERSION_PATCH "0") set(QTERMWIDGET_VERSION_PATCH "1")
set(QTERMWIDGET_VERSION "${QTERMWIDGET_VERSION_MAJOR}.${QTERMWIDGET_VERSION_MINOR}.${QTERMWIDGET_VERSION_PATCH}") set(QTERMWIDGET_VERSION "${QTERMWIDGET_VERSION_MAJOR}.${QTERMWIDGET_VERSION_MINOR}.${QTERMWIDGET_VERSION_PATCH}")
@ -42,6 +42,16 @@ add_definitions(-Wall)
set(QTERMWIDGET_LIBRARY_NAME qtermwidget5) set(QTERMWIDGET_LIBRARY_NAME qtermwidget5)
include(qtermwidget5_use) include(qtermwidget5_use)
option(USE_UTF8PROC "Use libutf8proc for better Unicode support. Default OFF" OFF)
if(USE_UTF8PROC)
find_package(Utf8Proc)
endif()
if (UTF8PROC_FOUND)
add_definitions(-DHAVE_UTF8PROC)
include_directories("${UTF8PROC_INCLUDE_DIRS}")
endif()
# main library # main library
@ -129,6 +139,9 @@ set_target_properties( ${QTERMWIDGET_LIBRARY_NAME} PROPERTIES
SOVERSION ${QTERMWIDGET_VERSION_MAJOR} SOVERSION ${QTERMWIDGET_VERSION_MAJOR}
VERSION ${QTERMWIDGET_VERSION} VERSION ${QTERMWIDGET_VERSION}
) )
if (UTF8PROC_FOUND)
target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} ${UTF8PROC_LIBRARIES})
endif()
if(APPLE) if(APPLE)
set (CMAKE_SKIP_RPATH 1) set (CMAKE_SKIP_RPATH 1)
# this is a must to load the lib correctly # this is a must to load the lib correctly
@ -182,16 +195,3 @@ CONFIGURE_FILE(
ADD_CUSTOM_TARGET(uninstall ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
) )
# make dist custom target
SET(CPACK_PACKAGE_NAME "qtermwidget")
# TODO/FIXME: versioning from player subdir... I don't know why it's separated...
SET(CPACK_PACKAGE_VERSION ${QTERMWIDGET_VERSION_MAJOR}.${QTERMWIDGET_VERSION_MINOR}.${QTERMWIDGET_VERSION_PATCH})
SET(CPACK_SOURCE_GENERATOR "TGZ;TBZ2")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
SET(CPACK_IGNORE_FILES "/\\\\.git/;\\\\.swp$;\\\\.#;/#;\\\\.tar.gz$;/CMakeFiles/;CMakeCache.txt;\\\\.qm$;/build/;\\\\.diff$;.DS_Store'")
SET(CPACK_SOURCE_IGNORE_FILES ${CPACK_IGNORE_FILES})
INCLUDE(CPack)
# simulate autotools' "make dist"
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)

@ -0,0 +1,59 @@
#.rst:
# FindUtf8Proc
# --------
#
# Find utf8proc
#
# Find the UTF-8 processing library
#
# ::
#
# This module defines the following variables:
# UTF8PROC_FOUND - True if UTF8PROC_INCLUDE_DIR & UTF8PROC_LIBRARY are found
# UTF8PROC_LIBRARIES - Set when UTF8PROC_LIBRARY is found
# UTF8PROC_INCLUDE_DIRS - Set when UTF8PROC_INCLUDE_DIR is found
#
#
#
# ::
#
# UTF8PROC_INCLUDE_DIR - where to find utf8proc.h
# UTF8PROC_LIBRARY - the utf8proc library
#=============================================================================
# This module is adapted from FindALSA.cmake. Below are the original license
# header.
#=============================================================================
# Copyright 2009-2011 Kitware, Inc.
# Copyright 2009-2011 Philip Lowman <philip@yhbt.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
find_path(
UTF8PROC_INCLUDE_DIR NAMES utf8proc.h DOC "The utf8proc include directory"
)
find_library(
UTF8PROC_LIBRARY NAMES utf8proc DOC "The utf8proc library"
)
# handle the QUIETLY and REQUIRED arguments and set UTF8PROC_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
UTF8PROC
REQUIRED_VARS UTF8PROC_LIBRARY UTF8PROC_INCLUDE_DIR
)
if(UTF8PROC_FOUND)
set( UTF8PROC_LIBRARIES ${UTF8PROC_LIBRARY} )
set( UTF8PROC_INCLUDE_DIRS ${UTF8PROC_INCLUDE_DIR} )
endif()
mark_as_advanced(UTF8PROC_INCLUDE_DIR UTF8PROC_LIBRARY)

@ -30,6 +30,7 @@
#include <QtDebug> #include <QtDebug>
#include <QSettings> #include <QSettings>
#include <QDir> #include <QDir>
#include <QRegularExpression>
// KDE // KDE
@ -329,19 +330,55 @@ QString ColorScheme::translatedColorNameForIndex(int index)
void ColorScheme::readColorEntry(QSettings * s , int index) void ColorScheme::readColorEntry(QSettings * s , int index)
{ {
s->beginGroup(colorNameForIndex(index)); QString colorName = colorNameForIndex(index);
s->beginGroup(colorName);
ColorEntry entry; ColorEntry entry;
QStringList rgbList = s->value("Color", QStringList()).toStringList(); QVariant colorValue = s->value("Color");
if (rgbList.count() != 3) QString colorStr;
int r, g, b;
bool ok = false;
// XXX: Undocumented(?) QSettings behavior: values with commas are parsed
// as QStringList and others QString
if (colorValue.type() == QVariant::StringList)
{ {
Q_ASSERT(0); QStringList rgbList = colorValue.toStringList();
colorStr = rgbList.join(",");
if (rgbList.count() == 3)
{
bool parse_ok;
ok = true;
r = rgbList[0].toInt(&parse_ok);
ok = ok && parse_ok && (r >= 0 && r <= 0xff);
g = rgbList[1].toInt(&parse_ok);
ok = ok && parse_ok && (g >= 0 && g <= 0xff);
b = rgbList[2].toInt(&parse_ok);
ok = ok && parse_ok && (b >= 0 && b <= 0xff);
}
}
else
{
colorStr = colorValue.toString();
QRegularExpression hexColorPattern("^#[0-9a-f]{6}$",
QRegularExpression::CaseInsensitiveOption);
if (hexColorPattern.match(colorStr).hasMatch())
{
// Parsing is always ok as already matched by the regexp
r = colorStr.midRef(1, 2).toInt(nullptr, 16);
g = colorStr.midRef(3, 2).toInt(nullptr, 16);
b = colorStr.midRef(5, 2).toInt(nullptr, 16);
ok = true;
}
}
if (!ok)
{
qWarning().nospace() << "Invalid color value " << colorStr
<< " for " << colorName << ". Fallback to black.";
r = g = b = 0;
} }
int r, g, b;
r = rgbList[0].toInt();
g = rgbList[1].toInt();
b = rgbList[2].toInt();
entry.color = QColor(r, g, b); entry.color = QColor(r, g, b);
entry.transparent = s->value("Transparent",false).toBool(); entry.transparent = s->value("Transparent",false).toBool();

@ -287,10 +287,6 @@ Filter::HotSpot::HotSpot(int startLine , int startColumn , int endLine , int end
, _type(NotSpecified) , _type(NotSpecified)
{ {
} }
QString Filter::HotSpot::tooltip() const
{
return QString();
}
QList<QAction*> Filter::HotSpot::actions() QList<QAction*> Filter::HotSpot::actions()
{ {
return QList<QAction*>(); return QList<QAction*>();
@ -407,7 +403,7 @@ RegExpFilter::HotSpot* UrlFilter::newHotSpot(int startLine,int startColumn,int e
{ {
HotSpot *spot = new UrlFilter::HotSpot(startLine,startColumn, HotSpot *spot = new UrlFilter::HotSpot(startLine,startColumn,
endLine,endColumn); endLine,endColumn);
connect(spot->getUrlObject(), SIGNAL(activated(QUrl)), this, SIGNAL(activated(QUrl))); connect(spot->getUrlObject(), &FilterObject::activated, this, &UrlFilter::activated);
return spot; return spot;
} }
@ -418,19 +414,6 @@ UrlFilter::HotSpot::HotSpot(int startLine,int startColumn,int endLine,int endCol
setType(Link); setType(Link);
} }
QString UrlFilter::HotSpot::tooltip() const
{
QString url = capturedTexts().first();
const UrlType kind = urlType();
if ( kind == StandardUrl )
return QString();
else if ( kind == Email )
return QString();
else
return QString();
}
UrlFilter::HotSpot::UrlType UrlFilter::HotSpot::urlType() const UrlFilter::HotSpot::UrlType UrlFilter::HotSpot::urlType() const
{ {
QString url = capturedTexts().first(); QString url = capturedTexts().first();
@ -455,7 +438,7 @@ void UrlFilter::HotSpot::activate(const QString& actionName)
return; return;
} }
if ( actionName.isEmpty() || actionName == "open-action" ) if ( actionName.isEmpty() || actionName == "open-action" || actionName == "click-action" )
{ {
if ( kind == StandardUrl ) if ( kind == StandardUrl )
{ {
@ -471,7 +454,7 @@ void UrlFilter::HotSpot::activate(const QString& actionName)
url.prepend("mailto:"); url.prepend("mailto:");
} }
_urlObject->emitActivated(url); _urlObject->emitActivated(url, actionName != "click-action");
} }
} }
@ -502,12 +485,12 @@ UrlFilter::HotSpot::~HotSpot()
delete _urlObject; delete _urlObject;
} }
void FilterObject::emitActivated(const QUrl& url) void FilterObject::emitActivated(const QUrl& url, bool fromContextMenu)
{ {
emit activated(url); emit activated(url, fromContextMenu);
} }
void FilterObject::activated() void FilterObject::activate()
{ {
_filter->activate(sender()->objectName()); _filter->activate(sender()->objectName());
} }
@ -545,8 +528,8 @@ QList<QAction*> UrlFilter::HotSpot::actions()
openAction->setObjectName( QLatin1String("open-action" )); openAction->setObjectName( QLatin1String("open-action" ));
copyAction->setObjectName( QLatin1String("copy-action" )); copyAction->setObjectName( QLatin1String("copy-action" ));
QObject::connect( openAction , SIGNAL(triggered()) , _urlObject , SLOT(activated()) ); QObject::connect( openAction , &QAction::triggered , _urlObject , &FilterObject::activate );
QObject::connect( copyAction , SIGNAL(triggered()) , _urlObject , SLOT(activated()) ); QObject::connect( copyAction , &QAction::triggered , _urlObject , &FilterObject::activate );
list << openAction; list << openAction;
list << copyAction; list << copyAction;

@ -117,14 +117,6 @@ public:
*/ */
virtual QList<QAction*> actions(); virtual QList<QAction*> actions();
/**
* Returns the text of a tooltip to be shown when the mouse moves over the hotspot, or
* an empty string if there is no tooltip associated with this hotspot.
*
* The default implementation returns an empty string.
*/
virtual QString tooltip() const;
protected: protected:
/** Sets the type of a hotspot. This should only be set once */ /** Sets the type of a hotspot. This should only be set once */
void setType(Type type); void setType(Type type);
@ -272,7 +264,6 @@ public:
*/ */
virtual void activate(const QString& action = QString()); virtual void activate(const QString& action = QString());
virtual QString tooltip() const;
private: private:
enum UrlType enum UrlType
{ {
@ -298,7 +289,7 @@ private:
// combined OR of FullUrlRegExp and EmailAddressRegExp // combined OR of FullUrlRegExp and EmailAddressRegExp
static const QRegExp CompleteUrlRegExp; static const QRegExp CompleteUrlRegExp;
signals: signals:
void activated(const QUrl& url); void activated(const QUrl& url, bool fromContextMenu);
}; };
class FilterObject : public QObject class FilterObject : public QObject
@ -307,13 +298,13 @@ class FilterObject : public QObject
public: public:
FilterObject(Filter::HotSpot* filter) : _filter(filter) {} FilterObject(Filter::HotSpot* filter) : _filter(filter) {}
void emitActivated(const QUrl& url); void emitActivated(const QUrl& url, bool fromContextMenu);
private slots: public slots:
void activated(); void activate();
private: private:
Filter::HotSpot* _filter; Filter::HotSpot* _filter;
signals: signals:
void activated(const QUrl& url); void activated(const QUrl& url, bool fromContextMenu);
}; };
/** /**

@ -514,7 +514,7 @@ void HistoryScrollBlockArray::addCells(const Character a[], int count)
// put cells in block's data // put cells in block's data
Q_ASSERT((count * sizeof(Character)) < ENTRIES); Q_ASSERT((count * sizeof(Character)) < ENTRIES);
memset(b->data, 0, ENTRIES); memset(b->data, 0, sizeof(b->data));
memcpy(b->data, a, count * sizeof(Character)); memcpy(b->data, a, count * sizeof(Character));
b->size = count * sizeof(Character); b->size = count * sizeof(Character);

@ -1,7 +0,0 @@
lib.pro is a *.pro-file for qmake
It produces static lib (libqtermwidget.a) only.
For creating shared lib (*.so) uncomment "dll" in "CONFIG" line in *.pro-file
Library was tested both with HAVE_POSIX_OPENPT and HAVE_GETPT precompiler directives,
defined in "DEFINES" line. You should select variant which would be correct for your system.

@ -39,7 +39,6 @@
#include <QScrollBar> #include <QScrollBar>
#include <QStyle> #include <QStyle>
#include <QTimer> #include <QTimer>
#include <QToolTip>
#include <QtDebug> #include <QtDebug>
#include <QUrl> #include <QUrl>
#include <QMimeData> #include <QMimeData>
@ -263,21 +262,18 @@ void TerminalDisplay::setVTFont(const QFont& f)
qDebug() << "Using a variable-width font in the terminal. This may cause performance degradation and display/alignment 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() ) // hint that text should be drawn without anti-aliasing.
{ // depending on the user's font configuration, this may not be respected
// hint that text should be drawn without anti-aliasing. if (!_antialiasText)
// depending on the user's font configuration, this may not be respected font.setStyleStrategy( QFont::NoAntialias );
if (!_antialiasText)
font.setStyleStrategy( QFont::NoAntialias ); // experimental optimization. Konsole assumes that the terminal is using a
// mono-spaced font, in which case kerning information should have an effect.
// experimental optimization. Konsole assumes that the terminal is using a // Disabling kerning saves some computation when rendering text.
// mono-spaced font, in which case kerning information should have an effect. font.setKerning(false);
// Disabling kerning saves some computation when rendering text.
font.setKerning(false); QWidget::setFont(font);
fontChange(font);
QWidget::setFont(font);
fontChange(font);
}
} }
void TerminalDisplay::setFont(const QFont &) void TerminalDisplay::setFont(const QFont &)
@ -531,6 +527,87 @@ static void drawLineChar(QPainter& paint, int x, int y, int w, int h, uchar code
} }
static void drawOtherChar(QPainter& paint, int x, int y, int w, int h, uchar code)
{
//Calculate cell midpoints, end points.
const int cx = x + w / 2;
const int cy = y + h / 2;
const int ex = x + w - 1;
const int ey = y + h - 1;
// Double dashes
if (0x4C <= code && code <= 0x4F) {
const int xHalfGap = qMax(w / 15, 1);
const int yHalfGap = qMax(h / 15, 1);
switch (code) {
case 0x4D: // BOX DRAWINGS HEAVY DOUBLE DASH HORIZONTAL
paint.drawLine(x, cy - 1, cx - xHalfGap - 1, cy - 1);
paint.drawLine(x, cy + 1, cx - xHalfGap - 1, cy + 1);
paint.drawLine(cx + xHalfGap, cy - 1, ex, cy - 1);
paint.drawLine(cx + xHalfGap, cy + 1, ex, cy + 1);
// No break!
case 0x4C: // BOX DRAWINGS LIGHT DOUBLE DASH HORIZONTAL
paint.drawLine(x, cy, cx - xHalfGap - 1, cy);
paint.drawLine(cx + xHalfGap, cy, ex, cy);
break;
case 0x4F: // BOX DRAWINGS HEAVY DOUBLE DASH VERTICAL
paint.drawLine(cx - 1, y, cx - 1, cy - yHalfGap - 1);
paint.drawLine(cx + 1, y, cx + 1, cy - yHalfGap - 1);
paint.drawLine(cx - 1, cy + yHalfGap, cx - 1, ey);
paint.drawLine(cx + 1, cy + yHalfGap, cx + 1, ey);
// No break!
case 0x4E: // BOX DRAWINGS LIGHT DOUBLE DASH VERTICAL
paint.drawLine(cx, y, cx, cy - yHalfGap - 1);
paint.drawLine(cx, cy + yHalfGap, cx, ey);
break;
}
}
// Rounded corner characters
else if (0x6D <= code && code <= 0x70) {
const int r = w * 3 / 8;
const int d = 2 * r;
switch (code) {
case 0x6D: // BOX DRAWINGS LIGHT ARC DOWN AND RIGHT
paint.drawLine(cx, cy + r, cx, ey);
paint.drawLine(cx + r, cy, ex, cy);
paint.drawArc(cx, cy, d, d, 90 * 16, 90 * 16);
break;
case 0x6E: // BOX DRAWINGS LIGHT ARC DOWN AND LEFT
paint.drawLine(cx, cy + r, cx, ey);
paint.drawLine(x, cy, cx - r, cy);
paint.drawArc(cx - d, cy, d, d, 0 * 16, 90 * 16);
break;
case 0x6F: // BOX DRAWINGS LIGHT ARC UP AND LEFT
paint.drawLine(cx, y, cx, cy - r);
paint.drawLine(x, cy, cx - r, cy);
paint.drawArc(cx - d, cy - d, d, d, 270 * 16, 90 * 16);
break;
case 0x70: // BOX DRAWINGS LIGHT ARC UP AND RIGHT
paint.drawLine(cx, y, cx, cy - r);
paint.drawLine(cx + r, cy, ex, cy);
paint.drawArc(cx, cy - d, d, d, 180 * 16, 90 * 16);
break;
}
}
// Diagonals
else if (0x71 <= code && code <= 0x73) {
switch (code) {
case 0x71: // BOX DRAWINGS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT
paint.drawLine(ex, y, x, ey);
break;
case 0x72: // BOX DRAWINGS LIGHT DIAGONAL UPPER LEFT TO LOWER RIGHT
paint.drawLine(x, y, ex, ey);
break;
case 0x73: // BOX DRAWINGS LIGHT DIAGONAL CROSS
paint.drawLine(ex, y, x, ey);
paint.drawLine(x, y, ex, ey);
break;
}
}
}
void TerminalDisplay::drawLineCharString( QPainter& painter, int x, int y, const QString& str, void TerminalDisplay::drawLineCharString( QPainter& painter, int x, int y, const QString& str,
const Character* attributes) const Character* attributes)
{ {
@ -548,6 +625,8 @@ void TerminalDisplay::drawLineCharString( QPainter& painter, int x, int y, co
uchar code = str[i].cell(); uchar code = str[i].cell();
if (LineChars[code]) if (LineChars[code])
drawLineChar(painter, x + (_fontWidth*i), y, _fontWidth, _fontHeight, code); drawLineChar(painter, x + (_fontWidth*i), y, _fontWidth, _fontHeight, code);
else
drawOtherChar(painter, x + (_fontWidth * i), y, _fontWidth, _fontHeight, code);
} }
painter.setPen( currentPen ); painter.setPen( currentPen );
@ -596,6 +675,20 @@ void TerminalDisplay::setOpacity(qreal opacity)
_blendColor = color.rgba(); _blendColor = color.rgba();
} }
void TerminalDisplay::setBackgroundImage(QString backgroundImage)
{
if (!backgroundImage.isEmpty())
{
_backgroundImage.load(backgroundImage);
setAttribute(Qt::WA_OpaquePaintEvent, false);
}
else
{
_backgroundImage = QPixmap();
setAttribute(Qt::WA_OpaquePaintEvent, true);
}
}
void TerminalDisplay::drawBackground(QPainter& painter, const QRect& rect, const QColor& backgroundColor, bool useOpacitySetting ) void TerminalDisplay::drawBackground(QPainter& painter, const QRect& rect, const QColor& backgroundColor, bool useOpacitySetting )
{ {
// the area of the widget showing the contents of the terminal display is drawn // the area of the widget showing the contents of the terminal display is drawn
@ -614,13 +707,15 @@ void TerminalDisplay::drawBackground(QPainter& painter, const QRect& rect, const
if ( HAVE_TRANSPARENCY && qAlpha(_blendColor) < 0xff && useOpacitySetting ) if ( HAVE_TRANSPARENCY && qAlpha(_blendColor) < 0xff && useOpacitySetting )
{ {
QColor color(backgroundColor); if (_backgroundImage.isNull()) {
color.setAlpha(qAlpha(_blendColor)); QColor color(backgroundColor);
color.setAlpha(qAlpha(_blendColor));
painter.save();
painter.setCompositionMode(QPainter::CompositionMode_Source); painter.save();
painter.fillRect(contentsRect, color); painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.restore(); painter.fillRect(contentsRect, color);
painter.restore();
}
} }
else else
painter.fillRect(contentsRect, backgroundColor); painter.fillRect(contentsRect, backgroundColor);
@ -1229,6 +1324,14 @@ void TerminalDisplay::paintEvent( QPaintEvent* pe )
{ {
QPainter paint(this); QPainter paint(this);
if ( !_backgroundImage.isNull() && qAlpha(_blendColor) < 0xff )
{
paint.drawPixmap(0, 0, _backgroundImage);
QColor background = _colorTable[DEFAULT_BACK_COLOR].color;
background.setAlpha(qAlpha(_blendColor));
paint.fillRect(contentsRect(), background);
}
foreach (const QRect &rect, (pe->region() & contentsRect()).rects()) foreach (const QRect &rect, (pe->region() & contentsRect()).rects())
{ {
drawBackground(paint,rect,palette().background().color(), drawBackground(paint,rect,palette().background().color(),
@ -1795,7 +1898,7 @@ void TerminalDisplay::mousePressEvent(QMouseEvent* ev)
Filter::HotSpot *spot = _filterChain->hotSpotAt(charLine, charColumn); Filter::HotSpot *spot = _filterChain->hotSpotAt(charLine, charColumn);
if (spot && spot->type() == Filter::HotSpot::Link) if (spot && spot->type() == Filter::HotSpot::Link)
spot->activate("open-action"); spot->activate("click-action");
} }
} }
else if ( ev->button() == Qt::MidButton ) else if ( ev->button() == Qt::MidButton )
@ -1865,13 +1968,6 @@ void TerminalDisplay::mouseMoveEvent(QMouseEvent* ev)
(spot->endLine()+1)*_fontHeight ); (spot->endLine()+1)*_fontHeight );
_mouseOverHotspotArea |= r; _mouseOverHotspotArea |= r;
} }
// display tooltips when mousing over links
// TODO: Extend this to work with filter types other than links
const QString& tooltip = spot->tooltip();
if ( !tooltip.isEmpty() )
{
QToolTip::showText( mapToGlobal(ev->pos()) , tooltip , this , _mouseOverHotspotArea.boundingRect() );
}
update( _mouseOverHotspotArea | previousHotspotArea ); update( _mouseOverHotspotArea | previousHotspotArea );
} }

@ -103,6 +103,9 @@ public:
/** Sets the opacity of the terminal display. */ /** Sets the opacity of the terminal display. */
void setOpacity(qreal opacity); void setOpacity(qreal opacity);
/** Sets the background image of the terminal display. */
void setBackgroundImage(QString backgroundImage);
/** /**
* Specifies whether the terminal display has a vertical scroll bar, and if so whether it * Specifies whether the terminal display has a vertical scroll bar, and if so whether it
* is shown on the left or right side of the display. * is shown on the left or right side of the display.
@ -783,6 +786,8 @@ private:
QRgb _blendColor; QRgb _blendColor;
QPixmap _backgroundImage;
// list of filters currently applied to the display. used for links and // list of filters currently applied to the display. used for links and
// search highlight // search highlight
TerminalImageFilterChain* _filterChain; TerminalImageFilterChain* _filterChain;

@ -0,0 +1,95 @@
[Background]
Color=49,54,59
[BackgroundFaint]
Color=49,54,59
[BackgroundIntense]
Color=35,38,41
[Color0]
Color=7,54,66
[Color0Faint]
Color=32,43,54
[Color0Intense]
Color=255,85,0
[Color1]
Color=237,21,21
[Color1Faint]
Color=120,50,40
[Color1Intense]
Color=192,57,43
[Color2]
Color=17,209,22
[Color2Faint]
Color=23,162,98
[Color2Intense]
Color=28,220,154
[Color3]
Color=246,116,0
[Color3Faint]
Color=182,86,25
[Color3Intense]
Color=253,188,75
[Color4]
Color=29,153,243
[Color4Faint]
Color=27,102,143
[Color4Intense]
Color=61,174,233
[Color5]
Color=155,89,182
[Color5Faint]
Color=97,74,115
[Color5Intense]
Color=142,68,173
[Color6]
Color=26,188,156
[Color6Faint]
Color=24,108,96
[Color6Intense]
Color=22,160,133
[Color7]
Color=239,240,241
[Color7Faint]
Color=99,104,109
[Color7Intense]
Color=252,252,252
[Foreground]
Color=239,240,241
[ForegroundFaint]
Color=220,230,231
[ForegroundIntense]
Color=252,252,252
[General]
Description=BreezeModified
Opacity=0.95
Wallpaper=

@ -7,6 +7,7 @@
<qresource><file>DarkPastels.colorscheme</file></qresource> <qresource><file>DarkPastels.colorscheme</file></qresource>
<qresource><file>GreenOnBlack.colorscheme</file></qresource> <qresource><file>GreenOnBlack.colorscheme</file></qresource>
<qresource><file>WhiteOnBlack.schema</file></qresource> <qresource><file>WhiteOnBlack.schema</file></qresource>
<qresource><file>BreezeModified.schema</file></qresource>
<qresource><file>historic/vim.schema</file></qresource> <qresource><file>historic/vim.schema</file></qresource>
<qresource><file>historic/Transparent.schema</file></qresource> <qresource><file>historic/Transparent.schema</file></qresource>
<qresource><file>historic/Transparent_MC.schema</file></qresource> <qresource><file>historic/Transparent_MC.schema</file></qresource>

@ -9,218 +9,36 @@
#include <QString> #include <QString>
#include "konsole_wcwidth.h" #ifdef HAVE_UTF8PROC
#include <utf8proc.h>
struct interval { #else
unsigned short first; #include <cwchar>
unsigned short last; #endif
};
/* auxiliary function for binary search in interval table */
static int bisearch(quint16 ucs, const struct interval * table, int max)
{
int min = 0;
int mid;
if (ucs < table[0].first || ucs > table[max].last) {
return 0;
}
while (max >= min) {
mid = (min + max) / 2;
if (ucs > table[mid].last) {
min = mid + 1;
} else if (ucs < table[mid].first) {
max = mid - 1;
} else {
return 1;
}
}
return 0;
}
/* The following functions define the column width of an ISO 10646
* character as follows:
*
* - The null character (U+0000) has a column width of 0.
*
* - Other C0/C1 control characters and DEL will lead to a return
* value of -1.
*
* - Non-spacing and enclosing combining characters (general
* category code Mn or Me in the Unicode database) have a
* column width of 0.
*
* - Other format characters (general category code Cf in the Unicode
* database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
*
* - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
* have a column width of 0.
*
* - Spacing characters in the East Asian Wide (W) or East Asian
* FullWidth (F) category as defined in Unicode Technical
* Report #11 have a column width of 2.
*
* - All remaining characters (including all printable
* ISO 8859-1 and WGL4 characters, Unicode control characters,
* etc.) have a column width of 1.
*
* This implementation assumes that quint16 characters are encoded
* in ISO 10646.
*/
int konsole_wcwidth(quint16 ucs)
{
/* sorted list of non-overlapping intervals of non-spacing characters */
static const struct interval combining[] = {
{ 0x0300, 0x034E }, { 0x0360, 0x0362 }, { 0x0483, 0x0486 },
{ 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 },
{ 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
{ 0x05C4, 0x05C4 }, { 0x064B, 0x0655 }, { 0x0670, 0x0670 },
{ 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
{ 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A },
{ 0x07A6, 0x07B0 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C },
{ 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 },
{ 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC },
{ 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 },
{ 0x0A02, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 },
{ 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 },
{ 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 },
{ 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0B01, 0x0B01 },
{ 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 },
{ 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 },
{ 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 },
{ 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 },
{ 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD },
{ 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA },
{ 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 },
{ 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 },
{ 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD },
{ 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 },
{ 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 },
{ 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC },
{ 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 },
{ 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 },
{ 0x1160, 0x11FF }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 },
{ 0x17C9, 0x17D3 }, { 0x180B, 0x180E }, { 0x18A9, 0x18A9 },
{ 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x206A, 0x206F },
{ 0x20D0, 0x20E3 }, { 0x302A, 0x302F }, { 0x3099, 0x309A },
{ 0xFB1E, 0xFB1E }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF },
{ 0xFFF9, 0xFFFB }
};
/* test for 8-bit control characters */
if (ucs == 0) {
return 0;
}
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) {
return -1;
}
/* binary search in table of non-spacing characters */
if (bisearch(ucs, combining,
sizeof(combining) / sizeof(struct interval) - 1)) {
return 0;
}
/* if we arrive here, ucs is not a combining or C0/C1 control character */
return 1 + #include "konsole_wcwidth.h"
(ucs >= 0x1100 &&
(ucs <= 0x115f || /* Hangul Jamo init. consonants */
(ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a &&
ucs != 0x303f) || /* CJK ... Yi */
(ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
(ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
(ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
(ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */
(ucs >= 0xffe0 && ucs <= 0xffe6) /* do not compare UINT16 with 0x20000 ||
(ucs >= 0x20000 && ucs <= 0x2ffff) */));
}
#if 0 int konsole_wcwidth(wchar_t ucs)
/*
* The following function is the same as konsole_wcwidth(), except that
* spacing characters in the East Asian Ambiguous (A) category as
* defined in Unicode Technical Report #11 have a column width of 2.
* This experimental variant might be useful for users of CJK legacy
* encodings who want to migrate to UCS. It is not otherwise
* recommended for general use.
*/
int konsole_wcwidth_cjk(quint16 ucs)
{ {
/* sorted list of non-overlapping intervals of East Asian Ambiguous #ifdef HAVE_UTF8PROC
* characters */ utf8proc_category_t cat = utf8proc_category( ucs );
static const struct interval ambiguous[] = { if (cat == UTF8PROC_CATEGORY_CO) {
{ 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 }, // Co: Private use area. libutf8proc makes them zero width, while tmux
{ 0x00AA, 0x00AA }, { 0x00AD, 0x00AD }, { 0x00B0, 0x00B4 }, // assumes them to be width 1, and glibc's default width is also 1
{ 0x00B6, 0x00BA }, { 0x00BC, 0x00BF }, { 0x00C6, 0x00C6 }, return 1;
{ 0x00D0, 0x00D0 }, { 0x00D7, 0x00D8 }, { 0x00DE, 0x00E1 },
{ 0x00E6, 0x00E6 }, { 0x00E8, 0x00EA }, { 0x00EC, 0x00ED },
{ 0x00F0, 0x00F0 }, { 0x00F2, 0x00F3 }, { 0x00F7, 0x00FA },
{ 0x00FC, 0x00FC }, { 0x00FE, 0x00FE }, { 0x0101, 0x0101 },
{ 0x0111, 0x0111 }, { 0x0113, 0x0113 }, { 0x011B, 0x011B },
{ 0x0126, 0x0127 }, { 0x012B, 0x012B }, { 0x0131, 0x0133 },
{ 0x0138, 0x0138 }, { 0x013F, 0x0142 }, { 0x0144, 0x0144 },
{ 0x0148, 0x014A }, { 0x014D, 0x014D }, { 0x0152, 0x0153 },
{ 0x0166, 0x0167 }, { 0x016B, 0x016B }, { 0x01CE, 0x01CE },
{ 0x01D0, 0x01D0 }, { 0x01D2, 0x01D2 }, { 0x01D4, 0x01D4 },
{ 0x01D6, 0x01D6 }, { 0x01D8, 0x01D8 }, { 0x01DA, 0x01DA },
{ 0x01DC, 0x01DC }, { 0x0251, 0x0251 }, { 0x0261, 0x0261 },
{ 0x02C7, 0x02C7 }, { 0x02C9, 0x02CB }, { 0x02CD, 0x02CD },
{ 0x02D0, 0x02D0 }, { 0x02D8, 0x02DB }, { 0x02DD, 0x02DD },
{ 0x0391, 0x03A1 }, { 0x03A3, 0x03A9 }, { 0x03B1, 0x03C1 },
{ 0x03C3, 0x03C9 }, { 0x0401, 0x0401 }, { 0x0410, 0x044F },
{ 0x0451, 0x0451 }, { 0x2010, 0x2010 }, { 0x2013, 0x2016 },
{ 0x2018, 0x2019 }, { 0x201C, 0x201D }, { 0x2020, 0x2021 },
{ 0x2025, 0x2027 }, { 0x2030, 0x2030 }, { 0x2032, 0x2033 },
{ 0x2035, 0x2035 }, { 0x203B, 0x203B }, { 0x2074, 0x2074 },
{ 0x207F, 0x207F }, { 0x2081, 0x2084 }, { 0x20AC, 0x20AC },
{ 0x2103, 0x2103 }, { 0x2105, 0x2105 }, { 0x2109, 0x2109 },
{ 0x2113, 0x2113 }, { 0x2121, 0x2122 }, { 0x2126, 0x2126 },
{ 0x212B, 0x212B }, { 0x2154, 0x2155 }, { 0x215B, 0x215B },
{ 0x215E, 0x215E }, { 0x2160, 0x216B }, { 0x2170, 0x2179 },
{ 0x2190, 0x2199 }, { 0x21D2, 0x21D2 }, { 0x21D4, 0x21D4 },
{ 0x2200, 0x2200 }, { 0x2202, 0x2203 }, { 0x2207, 0x2208 },
{ 0x220B, 0x220B }, { 0x220F, 0x220F }, { 0x2211, 0x2211 },
{ 0x2215, 0x2215 }, { 0x221A, 0x221A }, { 0x221D, 0x2220 },
{ 0x2223, 0x2223 }, { 0x2225, 0x2225 }, { 0x2227, 0x222C },
{ 0x222E, 0x222E }, { 0x2234, 0x2237 }, { 0x223C, 0x223D },
{ 0x2248, 0x2248 }, { 0x224C, 0x224C }, { 0x2252, 0x2252 },
{ 0x2260, 0x2261 }, { 0x2264, 0x2267 }, { 0x226A, 0x226B },
{ 0x226E, 0x226F }, { 0x2282, 0x2283 }, { 0x2286, 0x2287 },
{ 0x2295, 0x2295 }, { 0x2299, 0x2299 }, { 0x22A5, 0x22A5 },
{ 0x22BF, 0x22BF }, { 0x2312, 0x2312 }, { 0x2460, 0x24BF },
{ 0x24D0, 0x24E9 }, { 0x2500, 0x254B }, { 0x2550, 0x2574 },
{ 0x2580, 0x258F }, { 0x2592, 0x2595 }, { 0x25A0, 0x25A1 },
{ 0x25A3, 0x25A9 }, { 0x25B2, 0x25B3 }, { 0x25B6, 0x25B7 },
{ 0x25BC, 0x25BD }, { 0x25C0, 0x25C1 }, { 0x25C6, 0x25C8 },
{ 0x25CB, 0x25CB }, { 0x25CE, 0x25D1 }, { 0x25E2, 0x25E5 },
{ 0x25EF, 0x25EF }, { 0x2605, 0x2606 }, { 0x2609, 0x2609 },
{ 0x260E, 0x260F }, { 0x261C, 0x261C }, { 0x261E, 0x261E },
{ 0x2640, 0x2640 }, { 0x2642, 0x2642 }, { 0x2660, 0x2661 },
{ 0x2663, 0x2665 }, { 0x2667, 0x266A }, { 0x266C, 0x266D },
{ 0x266F, 0x266F }, { 0x300A, 0x300B }, { 0x301A, 0x301B },
{ 0xE000, 0xF8FF }, { 0xFFFD, 0xFFFD }
};
/* binary search in table of non-spacing characters */
if (bisearch(ucs, ambiguous,
sizeof(ambiguous) / sizeof(struct interval) - 1)) {
return 2;
} }
return utf8proc_charwidth( ucs );
return konsole_wcwidth(ucs); #else
} return wcwidth( ucs );
#endif #endif
}
// single byte char: +1, multi byte char: +2 // single byte char: +1, multi byte char: +2
int string_width( const QString & txt ) int string_width( const QString & txt )
{ {
int w = 0; int w = 0;
for ( int i = 0; i < txt.length(); ++i ) { std::wstring wstr = txt.toStdWString();
w += konsole_wcwidth( txt[ i ].unicode() ); for ( size_t i = 0; i < wstr.length(); ++i ) {
w += konsole_wcwidth( wstr[ i ] );
} }
return w; return w;
} }

@ -11,14 +11,9 @@
#define _KONSOLE_WCWIDTH_H_ #define _KONSOLE_WCWIDTH_H_
// Qt // Qt
#include <QtGlobal>
class QString; class QString;
int konsole_wcwidth(quint16 ucs); int konsole_wcwidth(wchar_t ucs);
#if 0
int konsole_wcwidth_cjk(Q_UINT16 ucs);
#endif
int string_width( const QString & txt ); int string_width( const QString & txt );

@ -258,7 +258,7 @@ void QTermWidget::init(int startnow)
// That's OK, FilterChain's dtor takes care of UrlFilter. // That's OK, FilterChain's dtor takes care of UrlFilter.
UrlFilter *urlFilter = new UrlFilter(); UrlFilter *urlFilter = new UrlFilter();
connect(urlFilter, SIGNAL(activated(QUrl)), this, SIGNAL(urlActivated(QUrl))); connect(urlFilter, &UrlFilter::activated, this, &QTermWidget::urlActivated);
m_impl->m_terminalDisplay->filterChain()->addFilter(urlFilter); m_impl->m_terminalDisplay->filterChain()->addFilter(urlFilter);
m_searchBar = new SearchBar(this); m_searchBar = new SearchBar(this);
@ -335,6 +335,14 @@ void QTermWidget::setTerminalOpacity(qreal level)
m_impl->m_terminalDisplay->setOpacity(level); m_impl->m_terminalDisplay->setOpacity(level);
} }
void QTermWidget::setTerminalBackgroundImage(QString backgroundImage)
{
if (!m_impl->m_terminalDisplay)
return;
m_impl->m_terminalDisplay->setBackgroundImage(backgroundImage);
}
void QTermWidget::setShellProgram(const QString &progname) void QTermWidget::setShellProgram(const QString &progname)
{ {
if (!m_impl->m_session) if (!m_impl->m_session)
@ -643,6 +651,11 @@ Filter::HotSpot* QTermWidget::getHotSpotAt(int row, int column) const
return m_impl->m_terminalDisplay->filterChain()->hotSpotAt(row, column); return m_impl->m_terminalDisplay->filterChain()->hotSpotAt(row, column);
} }
QList<QAction*> QTermWidget::filterActions(const QPoint& position)
{
return m_impl->m_terminalDisplay->filterActions(position);
}
int QTermWidget::getPtySlaveFd() const int QTermWidget::getPtySlaveFd() const
{ {
return m_impl->m_session->getPtySlaveFd(); return m_impl->m_session->getPtySlaveFd();

@ -96,6 +96,7 @@ public:
void setTerminalFont(const QFont & font); void setTerminalFont(const QFont & font);
QFont getTerminalFont(); QFont getTerminalFont();
void setTerminalOpacity(qreal level); void setTerminalOpacity(qreal level);
void setTerminalBackgroundImage(QString backgroundImage);
//environment //environment
void setEnvironment(const QStringList & environment); void setEnvironment(const QStringList & environment);
@ -192,6 +193,11 @@ public:
*/ */
Filter::HotSpot* getHotSpotAt(int row, int column) const; Filter::HotSpot* getHotSpotAt(int row, int column) const;
/*
* Proxy for TerminalDisplay::filterActions
* */
QList<QAction*> filterActions(const QPoint& position);
/** /**
* Returns a pty slave file descriptor. * Returns a pty slave file descriptor.
* This can be used for display and control * This can be used for display and control
@ -220,7 +226,7 @@ signals:
void termKeyPressed(QKeyEvent *); void termKeyPressed(QKeyEvent *);
void urlActivated(const QUrl&); void urlActivated(const QUrl&, bool fromContextMenu);
void bell(const QString& message); void bell(const QString& message);

Loading…
Cancel
Save