Adding upstream version 0.6.1~85-ge6253c0.
This commit is contained in:
parent
cd17ca0509
commit
c844d2379a
@ -1,11 +1,11 @@
|
|||||||
cmake_minimum_required( VERSION 2.8 )
|
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
||||||
|
|
||||||
project(qtermwidget)
|
project(qtermwidget)
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
include(CheckFunctionExists)
|
||||||
|
|
||||||
option(BUILD_TEST "Build test application. Default OFF." OFF)
|
option(BUILD_TEST "Build test application. Default OFF." OFF)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
|
||||||
|
|
||||||
# just change version for releases
|
# just change version for releases
|
||||||
set(QTERMWIDGET_VERSION_MAJOR "0")
|
set(QTERMWIDGET_VERSION_MAJOR "0")
|
||||||
set(QTERMWIDGET_VERSION_MINOR "6")
|
set(QTERMWIDGET_VERSION_MINOR "6")
|
||||||
@ -13,8 +13,23 @@ set(QTERMWIDGET_VERSION_PATCH "0")
|
|||||||
|
|
||||||
set(QTERMWIDGET_VERSION "${QTERMWIDGET_VERSION_MAJOR}.${QTERMWIDGET_VERSION_MINOR}.${QTERMWIDGET_VERSION_PATCH}")
|
set(QTERMWIDGET_VERSION "${QTERMWIDGET_VERSION_MAJOR}.${QTERMWIDGET_VERSION_MINOR}.${QTERMWIDGET_VERSION_PATCH}")
|
||||||
|
|
||||||
include(CheckFunctionExists)
|
# additional cmake files
|
||||||
include(GNUInstallDirs)
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||||
|
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||||
|
if(COMPILER_SUPPORTS_CXX11)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
|
elseif(COMPILER_SUPPORTS_CXX0X)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||||
|
else()
|
||||||
|
message(FATAL "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. C++11 support is required")
|
||||||
|
endif()
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
"${CMAKE_SOURCE_DIR}/lib"
|
"${CMAKE_SOURCE_DIR}/lib"
|
||||||
|
@ -21,8 +21,8 @@ Supported platforms:
|
|||||||
Building
|
Building
|
||||||
|
|
||||||
1. `mkdir -p build && cd build`
|
1. `mkdir -p build && cd build`
|
||||||
2. `cmake `<path/to/source>`
|
2. `cmake <path/to/source>`
|
||||||
3. make
|
3. `make`
|
||||||
|
|
||||||
Run `make install` to install.
|
Run `make install` to install.
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "BlockArray.h"
|
#include "BlockArray.h"
|
||||||
|
|
||||||
// System
|
// System
|
||||||
#include <assert.h>
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -57,7 +56,7 @@ BlockArray::BlockArray()
|
|||||||
BlockArray::~BlockArray()
|
BlockArray::~BlockArray()
|
||||||
{
|
{
|
||||||
setHistorySize(0);
|
setHistorySize(0);
|
||||||
assert(!lastblock);
|
Q_ASSERT(!lastblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BlockArray::append(Block * block)
|
size_t BlockArray::append(Block * block)
|
||||||
@ -149,7 +148,7 @@ const Block * BlockArray::at(size_t i)
|
|||||||
|
|
||||||
size_t j = i; // (current - (index - i) + (index/size+1)*size) % size ;
|
size_t j = i; // (current - (index - i) + (index/size+1)*size) % size ;
|
||||||
|
|
||||||
assert(j < size);
|
Q_ASSERT(j < size);
|
||||||
unmap();
|
unmap();
|
||||||
|
|
||||||
Block * block = (Block *)mmap(0, blocksize, PROT_READ, MAP_PRIVATE, ion, j * blocksize);
|
Block * block = (Block *)mmap(0, blocksize, PROT_READ, MAP_PRIVATE, ion, j * blocksize);
|
||||||
@ -218,7 +217,7 @@ bool BlockArray::setHistorySize(size_t newsize)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!lastblock);
|
Q_ASSERT(!lastblock);
|
||||||
|
|
||||||
lastblock = new Block();
|
lastblock = new Block();
|
||||||
size = newsize;
|
size = newsize;
|
||||||
|
@ -256,13 +256,16 @@ inline bool operator != (const CharacterColor& a, const CharacterColor& b)
|
|||||||
inline const QColor color256(quint8 u, const ColorEntry* base)
|
inline const QColor color256(quint8 u, const ColorEntry* base)
|
||||||
{
|
{
|
||||||
// 0.. 16: system colors
|
// 0.. 16: system colors
|
||||||
if (u < 8) return base[u+2 ].color; u -= 8;
|
if (u < 8) return base[u+2 ].color;
|
||||||
if (u < 8) return base[u+2+BASE_COLORS].color; u -= 8;
|
u -= 8;
|
||||||
|
if (u < 8) return base[u+2+BASE_COLORS].color;
|
||||||
|
u -= 8;
|
||||||
|
|
||||||
// 16..231: 6x6x6 rgb color cube
|
// 16..231: 6x6x6 rgb color cube
|
||||||
if (u < 216) return QColor(((u/36)%6) ? (40*((u/36)%6)+55) : 0,
|
if (u < 216) return QColor(((u/36)%6) ? (40*((u/36)%6)+55) : 0,
|
||||||
((u/ 6)%6) ? (40*((u/ 6)%6)+55) : 0,
|
((u/ 6)%6) ? (40*((u/ 6)%6)+55) : 0,
|
||||||
((u/ 1)%6) ? (40*((u/ 1)%6)+55) : 0); u -= 216;
|
((u/ 1)%6) ? (40*((u/ 1)%6)+55) : 0);
|
||||||
|
u -= 216;
|
||||||
|
|
||||||
// 232..255: gray, leaving out black and white
|
// 232..255: gray, leaving out black and white
|
||||||
int gray = u*10+8; return QColor(gray,gray,gray);
|
int gray = u*10+8; return QColor(gray,gray,gray);
|
||||||
|
@ -558,17 +558,13 @@ ColorSchemeManager::~ColorSchemeManager()
|
|||||||
void ColorSchemeManager::loadAllColorSchemes()
|
void ColorSchemeManager::loadAllColorSchemes()
|
||||||
{
|
{
|
||||||
qDebug() << "loadAllColorSchemes";
|
qDebug() << "loadAllColorSchemes";
|
||||||
int success = 0;
|
|
||||||
int failed = 0;
|
int failed = 0;
|
||||||
|
|
||||||
QList<QString> nativeColorSchemes = listColorSchemes();
|
QList<QString> nativeColorSchemes = listColorSchemes();
|
||||||
|
|
||||||
QListIterator<QString> nativeIter(nativeColorSchemes);
|
QListIterator<QString> nativeIter(nativeColorSchemes);
|
||||||
while ( nativeIter.hasNext() )
|
while ( nativeIter.hasNext() )
|
||||||
{
|
{
|
||||||
if ( loadColorScheme( nativeIter.next() ) )
|
if ( !loadColorScheme( nativeIter.next() ) )
|
||||||
success++;
|
|
||||||
else
|
|
||||||
failed++;
|
failed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,9 +572,7 @@ void ColorSchemeManager::loadAllColorSchemes()
|
|||||||
QListIterator<QString> kde3Iter(kde3ColorSchemes);
|
QListIterator<QString> kde3Iter(kde3ColorSchemes);
|
||||||
while ( kde3Iter.hasNext() )
|
while ( kde3Iter.hasNext() )
|
||||||
{
|
{
|
||||||
if ( loadKDE3ColorScheme( kde3Iter.next() ) )
|
if ( !loadKDE3ColorScheme( kde3Iter.next() ) )
|
||||||
success++;
|
|
||||||
else
|
|
||||||
failed++;
|
failed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,6 +644,11 @@ bool ColorSchemeManager::loadCustomColorScheme(const QString& path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColorSchemeManager::addCustomColorSchemeDir(const QString& custom_dir)
|
||||||
|
{
|
||||||
|
add_custom_color_scheme_dir(custom_dir);
|
||||||
|
}
|
||||||
|
|
||||||
bool ColorSchemeManager::loadColorScheme(const QString& filePath)
|
bool ColorSchemeManager::loadColorScheme(const QString& filePath)
|
||||||
{
|
{
|
||||||
if ( !filePath.endsWith(QLatin1String(".colorscheme")) || !QFile::exists(filePath) )
|
if ( !filePath.endsWith(QLatin1String(".colorscheme")) || !QFile::exists(filePath) )
|
||||||
@ -686,15 +685,18 @@ bool ColorSchemeManager::loadColorScheme(const QString& filePath)
|
|||||||
}
|
}
|
||||||
QList<QString> ColorSchemeManager::listKDE3ColorSchemes()
|
QList<QString> ColorSchemeManager::listKDE3ColorSchemes()
|
||||||
{
|
{
|
||||||
QString dname(get_color_schemes_dir());
|
|
||||||
QDir dir(dname);
|
|
||||||
QStringList filters;
|
|
||||||
filters << "*.schema";
|
|
||||||
dir.setNameFilters(filters);
|
|
||||||
QStringList list = dir.entryList(filters);
|
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
foreach(QString i, list)
|
for (const QString &scheme_dir : get_color_schemes_dirs())
|
||||||
ret << dname + "/" + i;
|
{
|
||||||
|
const QString dname(scheme_dir);
|
||||||
|
QDir dir(dname);
|
||||||
|
QStringList filters;
|
||||||
|
filters << "*.schema";
|
||||||
|
dir.setNameFilters(filters);
|
||||||
|
QStringList list = dir.entryList(filters);
|
||||||
|
for (const QString &i : list)
|
||||||
|
ret << dname + "/" + i;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
//return KGlobal::dirs()->findAllResources("data",
|
//return KGlobal::dirs()->findAllResources("data",
|
||||||
// "konsole/*.schema",
|
// "konsole/*.schema",
|
||||||
@ -703,15 +705,18 @@ QList<QString> ColorSchemeManager::listKDE3ColorSchemes()
|
|||||||
}
|
}
|
||||||
QList<QString> ColorSchemeManager::listColorSchemes()
|
QList<QString> ColorSchemeManager::listColorSchemes()
|
||||||
{
|
{
|
||||||
QString dname(get_color_schemes_dir());
|
|
||||||
QDir dir(dname);
|
|
||||||
QStringList filters;
|
|
||||||
filters << "*.colorscheme";
|
|
||||||
dir.setNameFilters(filters);
|
|
||||||
QStringList list = dir.entryList(filters);
|
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
foreach(QString i, list)
|
for (const QString &scheme_dir : get_color_schemes_dirs())
|
||||||
ret << dname + "/" + i;
|
{
|
||||||
|
const QString dname(scheme_dir);
|
||||||
|
QDir dir(dname);
|
||||||
|
QStringList filters;
|
||||||
|
filters << "*.colorscheme";
|
||||||
|
dir.setNameFilters(filters);
|
||||||
|
QStringList list = dir.entryList(filters);
|
||||||
|
for (const QString &i : list)
|
||||||
|
ret << dname + "/" + i;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
// return KGlobal::dirs()->findAllResources("data",
|
// return KGlobal::dirs()->findAllResources("data",
|
||||||
// "konsole/*.colorscheme",
|
// "konsole/*.colorscheme",
|
||||||
@ -742,12 +747,17 @@ bool ColorSchemeManager::deleteColorScheme(const QString& name)
|
|||||||
QString ColorSchemeManager::findColorSchemePath(const QString& name) const
|
QString ColorSchemeManager::findColorSchemePath(const QString& name) const
|
||||||
{
|
{
|
||||||
// QString path = KStandardDirs::locate("data","konsole/"+name+".colorscheme");
|
// QString path = KStandardDirs::locate("data","konsole/"+name+".colorscheme");
|
||||||
QString path(get_color_schemes_dir() + "/"+ name + ".colorscheme");
|
const QStringList dirs = get_color_schemes_dirs();
|
||||||
|
if ( dirs.isEmpty() )
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
const QString dir = dirs.first();
|
||||||
|
QString path(dir + "/"+ name + ".colorscheme");
|
||||||
if ( !path.isEmpty() )
|
if ( !path.isEmpty() )
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
//path = KStandardDirs::locate("data","konsole/"+name+".schema");
|
//path = KStandardDirs::locate("data","konsole/"+name+".schema");
|
||||||
path = get_color_schemes_dir() + "/"+ name + ".schema";
|
path = dir + "/"+ name + ".schema";
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
@ -777,12 +787,8 @@ const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Q_GLOBAL_STATIC(ColorSchemeManager, theColorSchemeManager)
|
||||||
ColorSchemeManager* ColorSchemeManager::theColorSchemeManager = 0;
|
|
||||||
//K_GLOBAL_STATIC( ColorSchemeManager , theColorSchemeManager )
|
|
||||||
ColorSchemeManager* ColorSchemeManager::instance()
|
ColorSchemeManager* ColorSchemeManager::instance()
|
||||||
{
|
{
|
||||||
if (! theColorSchemeManager)
|
|
||||||
theColorSchemeManager = new ColorSchemeManager();
|
|
||||||
return theColorSchemeManager;
|
return theColorSchemeManager;
|
||||||
}
|
}
|
||||||
|
@ -327,6 +327,14 @@ public:
|
|||||||
* @return Whether the color scheme is loaded successfully.
|
* @return Whether the color scheme is loaded successfully.
|
||||||
*/
|
*/
|
||||||
bool loadCustomColorScheme(const QString& path);
|
bool loadCustomColorScheme(const QString& path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Allows to add a custom location of color schemes.
|
||||||
|
*
|
||||||
|
* @param[in] custom_dir Custom location of color schemes (must end with /).
|
||||||
|
*/
|
||||||
|
void addCustomColorSchemeDir(const QString& custom_dir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// loads a color scheme from a KDE 4+ .colorscheme file
|
// loads a color scheme from a KDE 4+ .colorscheme file
|
||||||
bool loadColorScheme(const QString& path);
|
bool loadColorScheme(const QString& path);
|
||||||
@ -348,8 +356,6 @@ private:
|
|||||||
bool _haveLoadedAll;
|
bool _haveLoadedAll;
|
||||||
|
|
||||||
static const ColorScheme _defaultColorScheme;
|
static const ColorScheme _defaultColorScheme;
|
||||||
|
|
||||||
static ColorSchemeManager * theColorSchemeManager;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "Emulation.h"
|
#include "Emulation.h"
|
||||||
|
|
||||||
// System
|
// System
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -55,7 +54,8 @@ Emulation::Emulation() :
|
|||||||
_codec(0),
|
_codec(0),
|
||||||
_decoder(0),
|
_decoder(0),
|
||||||
_keyTranslator(0),
|
_keyTranslator(0),
|
||||||
_usesMouse(false)
|
_usesMouse(false),
|
||||||
|
_bracketedPasteMode(false)
|
||||||
{
|
{
|
||||||
// create screens with a default size
|
// create screens with a default size
|
||||||
_screen[0] = new Screen(40,80);
|
_screen[0] = new Screen(40,80);
|
||||||
@ -66,8 +66,10 @@ Emulation::Emulation() :
|
|||||||
QObject::connect(&_bulkTimer2, SIGNAL(timeout()), this, SLOT(showBulk()) );
|
QObject::connect(&_bulkTimer2, SIGNAL(timeout()), this, SLOT(showBulk()) );
|
||||||
|
|
||||||
// listen for mouse status changes
|
// listen for mouse status changes
|
||||||
connect( this , SIGNAL(programUsesMouseChanged(bool)) ,
|
connect(this , SIGNAL(programUsesMouseChanged(bool)) ,
|
||||||
SLOT(usesMouseChanged(bool)) );
|
SLOT(usesMouseChanged(bool)));
|
||||||
|
connect(this , SIGNAL(programBracketedPasteModeChanged(bool)) ,
|
||||||
|
SLOT(bracketedPasteModeChanged(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Emulation::programUsesMouse() const
|
bool Emulation::programUsesMouse() const
|
||||||
@ -80,6 +82,16 @@ void Emulation::usesMouseChanged(bool usesMouse)
|
|||||||
_usesMouse = usesMouse;
|
_usesMouse = usesMouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Emulation::programBracketedPasteMode() const
|
||||||
|
{
|
||||||
|
return _bracketedPasteMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::bracketedPasteModeChanged(bool bracketedPasteMode)
|
||||||
|
{
|
||||||
|
_bracketedPasteMode = bracketedPasteMode;
|
||||||
|
}
|
||||||
|
|
||||||
ScreenWindow* Emulation::createWindow()
|
ScreenWindow* Emulation::createWindow()
|
||||||
{
|
{
|
||||||
ScreenWindow* window = new ScreenWindow();
|
ScreenWindow* window = new ScreenWindow();
|
||||||
|
@ -218,6 +218,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool programUsesMouse() const;
|
bool programUsesMouse() const;
|
||||||
|
|
||||||
|
bool programBracketedPasteMode() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
/** Change the size of the emulation's image */
|
/** Change the size of the emulation's image */
|
||||||
@ -325,6 +327,8 @@ signals:
|
|||||||
*/
|
*/
|
||||||
void programUsesMouseChanged(bool usesMouse);
|
void programUsesMouseChanged(bool usesMouse);
|
||||||
|
|
||||||
|
void programBracketedPasteModeChanged(bool bracketedPasteMode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when the contents of the screen image change.
|
* Emitted when the contents of the screen image change.
|
||||||
* The emulation buffers the updates from successive image changes,
|
* The emulation buffers the updates from successive image changes,
|
||||||
@ -471,8 +475,11 @@ private slots:
|
|||||||
|
|
||||||
void usesMouseChanged(bool usesMouse);
|
void usesMouseChanged(bool usesMouse);
|
||||||
|
|
||||||
|
void bracketedPasteModeChanged(bool bracketedPasteMode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _usesMouse;
|
bool _usesMouse;
|
||||||
|
bool _bracketedPasteMode;
|
||||||
QTimer _bulkTimer1;
|
QTimer _bulkTimer1;
|
||||||
QTimer _bulkTimer2;
|
QTimer _bulkTimer2;
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
// System
|
// System
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
@ -110,7 +109,7 @@ HistoryFile::~HistoryFile()
|
|||||||
//to avoid this.
|
//to avoid this.
|
||||||
void HistoryFile::map()
|
void HistoryFile::map()
|
||||||
{
|
{
|
||||||
assert( fileMap == 0 );
|
Q_ASSERT( fileMap == 0 );
|
||||||
|
|
||||||
fileMap = (char*)mmap( 0 , length , PROT_READ , MAP_PRIVATE , ion , 0 );
|
fileMap = (char*)mmap( 0 , length , PROT_READ , MAP_PRIVATE , ion , 0 );
|
||||||
|
|
||||||
@ -119,14 +118,14 @@ void HistoryFile::map()
|
|||||||
{
|
{
|
||||||
readWriteBalance = 0;
|
readWriteBalance = 0;
|
||||||
fileMap = 0;
|
fileMap = 0;
|
||||||
qDebug() << __FILE__ << __LINE__ << ": mmap'ing history failed. errno = " << errno;
|
//qDebug() << __FILE__ << __LINE__ << ": mmap'ing history failed. errno = " << errno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryFile::unmap()
|
void HistoryFile::unmap()
|
||||||
{
|
{
|
||||||
int result = munmap( fileMap , length );
|
int result = munmap( fileMap , length );
|
||||||
assert( result == 0 ); Q_UNUSED( result );
|
Q_ASSERT( result == 0 ); Q_UNUSED( result );
|
||||||
|
|
||||||
fileMap = 0;
|
fileMap = 0;
|
||||||
}
|
}
|
||||||
@ -502,7 +501,7 @@ void HistoryScrollBlockArray::getCells(int lineno, int colno,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(((colno + count) * sizeof(Character)) < ENTRIES);
|
Q_ASSERT(((colno + count) * sizeof(Character)) < ENTRIES);
|
||||||
memcpy(res, b->data + (colno * sizeof(Character)), count * sizeof(Character));
|
memcpy(res, b->data + (colno * sizeof(Character)), count * sizeof(Character));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,7 +512,7 @@ void HistoryScrollBlockArray::addCells(const Character a[], int count)
|
|||||||
if (!b) return;
|
if (!b) return;
|
||||||
|
|
||||||
// put cells in block's data
|
// put cells in block's data
|
||||||
assert((count * sizeof(Character)) < ENTRIES);
|
Q_ASSERT((count * sizeof(Character)) < ENTRIES);
|
||||||
|
|
||||||
memset(b->data, 0, ENTRIES);
|
memset(b->data, 0, ENTRIES);
|
||||||
|
|
||||||
@ -521,7 +520,7 @@ void HistoryScrollBlockArray::addCells(const Character a[], int count)
|
|||||||
b->size = count * sizeof(Character);
|
b->size = count * sizeof(Character);
|
||||||
|
|
||||||
size_t res = m_blockArray.newBlock();
|
size_t res = m_blockArray.newBlock();
|
||||||
assert (res > 0);
|
Q_ASSERT(res > 0);
|
||||||
Q_UNUSED( res );
|
Q_UNUSED( res );
|
||||||
|
|
||||||
m_lineLengths.insert(m_blockArray.getCurrent(), count);
|
m_lineLengths.insert(m_blockArray.getCurrent(), count);
|
||||||
@ -634,7 +633,6 @@ CompactHistoryLine::CompactHistoryLine ( const TextLine& line, CompactHistoryBlo
|
|||||||
Q_ASSERT (text!=NULL);
|
Q_ASSERT (text!=NULL);
|
||||||
|
|
||||||
length=line.size();
|
length=line.size();
|
||||||
formatLength=formatLength;
|
|
||||||
wrapped=false;
|
wrapped=false;
|
||||||
|
|
||||||
// record formats and their positions in the format array
|
// record formats and their positions in the format array
|
||||||
|
@ -884,11 +884,8 @@ bool KeyboardTranslatorManager::deleteTranslator(const QString& name)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//K_GLOBAL_STATIC( KeyboardTranslatorManager , theKeyboardTranslatorManager )
|
Q_GLOBAL_STATIC( KeyboardTranslatorManager , theKeyboardTranslatorManager )
|
||||||
KeyboardTranslatorManager* KeyboardTranslatorManager::theKeyboardTranslatorManager = 0;
|
|
||||||
KeyboardTranslatorManager* KeyboardTranslatorManager::instance()
|
KeyboardTranslatorManager* KeyboardTranslatorManager::instance()
|
||||||
{
|
{
|
||||||
if (! theKeyboardTranslatorManager)
|
|
||||||
theKeyboardTranslatorManager = new KeyboardTranslatorManager();
|
|
||||||
return theKeyboardTranslatorManager;
|
return theKeyboardTranslatorManager;
|
||||||
}
|
}
|
||||||
|
@ -456,6 +456,9 @@ public:
|
|||||||
KeyboardTranslatorManager();
|
KeyboardTranslatorManager();
|
||||||
~KeyboardTranslatorManager();
|
~KeyboardTranslatorManager();
|
||||||
|
|
||||||
|
KeyboardTranslatorManager(const KeyboardTranslatorManager&) = delete;
|
||||||
|
KeyboardTranslatorManager& operator=(const KeyboardTranslatorManager&) = delete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new translator. If a translator with the same name
|
* Adds a new translator. If a translator with the same name
|
||||||
* already exists, it will be replaced by the new translator.
|
* already exists, it will be replaced by the new translator.
|
||||||
@ -507,8 +510,6 @@ private:
|
|||||||
QHash<QString,KeyboardTranslator*> _translators; // maps translator-name -> KeyboardTranslator
|
QHash<QString,KeyboardTranslator*> _translators; // maps translator-name -> KeyboardTranslator
|
||||||
// instance
|
// instance
|
||||||
bool _haveLoadedAll;
|
bool _haveLoadedAll;
|
||||||
|
|
||||||
static KeyboardTranslatorManager * theKeyboardTranslatorManager;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline int KeyboardTranslator::Entry::keyCode() const { return _keyCode; }
|
inline int KeyboardTranslator::Entry::keyCode() const { return _keyCode; }
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@ -1177,7 +1176,7 @@ int Screen::copyLineToStream(int line ,
|
|||||||
static const int MAX_CHARS = 1024;
|
static const int MAX_CHARS = 1024;
|
||||||
static Character characterBuffer[MAX_CHARS];
|
static Character characterBuffer[MAX_CHARS];
|
||||||
|
|
||||||
assert( count < MAX_CHARS );
|
Q_ASSERT( count < MAX_CHARS );
|
||||||
|
|
||||||
LineProperty currentLineProperties = 0;
|
LineProperty currentLineProperties = 0;
|
||||||
|
|
||||||
@ -1202,9 +1201,9 @@ int Screen::copyLineToStream(int line ,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// safety checks
|
// safety checks
|
||||||
assert( start >= 0 );
|
Q_ASSERT( start >= 0 );
|
||||||
assert( count >= 0 );
|
Q_ASSERT( count >= 0 );
|
||||||
assert( (start+count) <= history->getLineLen(line) );
|
Q_ASSERT( (start+count) <= history->getLineLen(line) );
|
||||||
|
|
||||||
history->getCells(line,start,count,characterBuffer);
|
history->getCells(line,start,count,characterBuffer);
|
||||||
|
|
||||||
@ -1216,7 +1215,7 @@ int Screen::copyLineToStream(int line ,
|
|||||||
if ( count == -1 )
|
if ( count == -1 )
|
||||||
count = columns - start;
|
count = columns - start;
|
||||||
|
|
||||||
assert( count >= 0 );
|
Q_ASSERT( count >= 0 );
|
||||||
|
|
||||||
const int screenLine = line-history->getLines();
|
const int screenLine = line-history->getLines();
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include "Session.h"
|
#include "Session.h"
|
||||||
|
|
||||||
// Standard
|
// Standard
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// Qt
|
// Qt
|
||||||
@ -186,6 +185,11 @@ void Session::addView(TerminalDisplay * widget)
|
|||||||
|
|
||||||
widget->setUsesMouse( _emulation->programUsesMouse() );
|
widget->setUsesMouse( _emulation->programUsesMouse() );
|
||||||
|
|
||||||
|
connect( _emulation , SIGNAL(programBracketedPasteModeChanged(bool)) ,
|
||||||
|
widget , SLOT(setBracketedPasteMode(bool)) );
|
||||||
|
|
||||||
|
widget->setBracketedPasteMode(_emulation->programBracketedPasteMode());
|
||||||
|
|
||||||
widget->setScreenWindow(_emulation->createWindow());
|
widget->setScreenWindow(_emulation->createWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +347,7 @@ void Session::setUserTitle( int what, const QString & caption )
|
|||||||
|
|
||||||
if (what == 11) {
|
if (what == 11) {
|
||||||
QString colorString = caption.section(';',0,0);
|
QString colorString = caption.section(';',0,0);
|
||||||
qDebug() << __FILE__ << __LINE__ << ": setting background colour to " << colorString;
|
//qDebug() << __FILE__ << __LINE__ << ": setting background colour to " << colorString;
|
||||||
QColor backColor = QColor(colorString);
|
QColor backColor = QColor(colorString);
|
||||||
if (backColor.isValid()) { // change color via \033]11;Color\007
|
if (backColor.isValid()) { // change color via \033]11;Color\007
|
||||||
if (backColor != _modifiedBackground) {
|
if (backColor != _modifiedBackground) {
|
||||||
|
@ -318,7 +318,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
|
|||||||
,_lineSelectionMode(false)
|
,_lineSelectionMode(false)
|
||||||
,_preserveLineBreaks(false)
|
,_preserveLineBreaks(false)
|
||||||
,_columnSelectionMode(false)
|
,_columnSelectionMode(false)
|
||||||
,_scrollbarLocation(NoScrollBar)
|
,_scrollbarLocation(QTermWidget::NoScrollBar)
|
||||||
,_wordCharacters(":@-./_~")
|
,_wordCharacters(":@-./_~")
|
||||||
,_bellMode(SystemBeepBell)
|
,_bellMode(SystemBeepBell)
|
||||||
,_blinking(false)
|
,_blinking(false)
|
||||||
@ -338,7 +338,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
|
|||||||
,_colorsInverted(false)
|
,_colorsInverted(false)
|
||||||
,_blendColor(qRgba(0,0,0,0xff))
|
,_blendColor(qRgba(0,0,0,0xff))
|
||||||
,_filterChain(new TerminalImageFilterChain())
|
,_filterChain(new TerminalImageFilterChain())
|
||||||
,_cursorShape(BlockCursor)
|
,_cursorShape(QTermWidget::BlockCursor)
|
||||||
,mMotionAfterPasting(NoMoveScreenWindow)
|
,mMotionAfterPasting(NoMoveScreenWindow)
|
||||||
{
|
{
|
||||||
// terminal applications are not designed with Right-To-Left in mind,
|
// terminal applications are not designed with Right-To-Left in mind,
|
||||||
@ -371,6 +371,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
|
|||||||
// KCursor::setAutoHideCursor( this, true );
|
// KCursor::setAutoHideCursor( this, true );
|
||||||
|
|
||||||
setUsesMouse(true);
|
setUsesMouse(true);
|
||||||
|
setBracketedPasteMode(false);
|
||||||
setColorTable(base_color_table);
|
setColorTable(base_color_table);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
@ -552,11 +553,11 @@ void TerminalDisplay::drawLineCharString( QPainter& painter, int x, int y, co
|
|||||||
painter.setPen( currentPen );
|
painter.setPen( currentPen );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerminalDisplay::setKeyboardCursorShape(KeyboardCursorShape shape)
|
void TerminalDisplay::setKeyboardCursorShape(QTermWidget::KeyboardCursorShape shape)
|
||||||
{
|
{
|
||||||
_cursorShape = shape;
|
_cursorShape = shape;
|
||||||
}
|
}
|
||||||
TerminalDisplay::KeyboardCursorShape TerminalDisplay::keyboardCursorShape() const
|
QTermWidget::KeyboardCursorShape TerminalDisplay::keyboardCursorShape() const
|
||||||
{
|
{
|
||||||
return _cursorShape;
|
return _cursorShape;
|
||||||
}
|
}
|
||||||
@ -643,7 +644,7 @@ void TerminalDisplay::drawCursor(QPainter& painter,
|
|||||||
else
|
else
|
||||||
painter.setPen(foregroundColor);
|
painter.setPen(foregroundColor);
|
||||||
|
|
||||||
if ( _cursorShape == BlockCursor )
|
if ( _cursorShape == QTermWidget::BlockCursor )
|
||||||
{
|
{
|
||||||
// draw the cursor outline, adjusting the area so that
|
// draw the cursor outline, adjusting the area so that
|
||||||
// it is draw entirely inside 'rect'
|
// it is draw entirely inside 'rect'
|
||||||
@ -665,12 +666,12 @@ void TerminalDisplay::drawCursor(QPainter& painter,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( _cursorShape == UnderlineCursor )
|
else if ( _cursorShape == QTermWidget::UnderlineCursor )
|
||||||
painter.drawLine(cursorRect.left(),
|
painter.drawLine(cursorRect.left(),
|
||||||
cursorRect.bottom(),
|
cursorRect.bottom(),
|
||||||
cursorRect.right(),
|
cursorRect.right(),
|
||||||
cursorRect.bottom());
|
cursorRect.bottom());
|
||||||
else if ( _cursorShape == IBeamCursor )
|
else if ( _cursorShape == QTermWidget::IBeamCursor )
|
||||||
painter.drawLine(cursorRect.left(),
|
painter.drawLine(cursorRect.left(),
|
||||||
cursorRect.top(),
|
cursorRect.top(),
|
||||||
cursorRect.left(),
|
cursorRect.left(),
|
||||||
@ -833,7 +834,7 @@ void TerminalDisplay::scrollImage(int lines , const QRect& screenWindowRegion)
|
|||||||
int scrollBarWidth = _scrollBar->isHidden() ? 0 : _scrollBar->width();
|
int scrollBarWidth = _scrollBar->isHidden() ? 0 : _scrollBar->width();
|
||||||
const int SCROLLBAR_CONTENT_GAP = 1;
|
const int SCROLLBAR_CONTENT_GAP = 1;
|
||||||
QRect scrollRect;
|
QRect scrollRect;
|
||||||
if ( _scrollbarLocation == ScrollBarLeft )
|
if ( _scrollbarLocation == QTermWidget::ScrollBarLeft )
|
||||||
{
|
{
|
||||||
scrollRect.setLeft(scrollBarWidth+SCROLLBAR_CONTENT_GAP);
|
scrollRect.setLeft(scrollBarWidth+SCROLLBAR_CONTENT_GAP);
|
||||||
scrollRect.setRight(width());
|
scrollRect.setRight(width());
|
||||||
@ -1290,7 +1291,7 @@ void TerminalDisplay::paintFilters(QPainter& painter)
|
|||||||
QPoint cursorPos = mapFromGlobal(QCursor::pos());
|
QPoint cursorPos = mapFromGlobal(QCursor::pos());
|
||||||
int cursorLine;
|
int cursorLine;
|
||||||
int cursorColumn;
|
int cursorColumn;
|
||||||
int scrollBarWidth = (_scrollbarLocation == ScrollBarLeft) ? _scrollBar->width() : 0;
|
int scrollBarWidth = (_scrollbarLocation == QTermWidget::ScrollBarLeft) ? _scrollBar->width() : 0;
|
||||||
|
|
||||||
getCharacterPosition( cursorPos , cursorLine , cursorColumn );
|
getCharacterPosition( cursorPos , cursorLine , cursorColumn );
|
||||||
Character cursorCharacter = _image[loc(cursorColumn,cursorLine)];
|
Character cursorCharacter = _image[loc(cursorColumn,cursorLine)];
|
||||||
@ -1717,12 +1718,12 @@ void TerminalDisplay::scrollToEnd()
|
|||||||
_screenWindow->setTrackOutput( _screenWindow->atEndOfOutput() );
|
_screenWindow->setTrackOutput( _screenWindow->atEndOfOutput() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerminalDisplay::setScrollBarPosition(ScrollBarPosition position)
|
void TerminalDisplay::setScrollBarPosition(QTermWidget::ScrollBarPosition position)
|
||||||
{
|
{
|
||||||
if (_scrollbarLocation == position)
|
if (_scrollbarLocation == position)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( position == NoScrollBar )
|
if ( position == QTermWidget::NoScrollBar )
|
||||||
_scrollBar->hide();
|
_scrollBar->hide();
|
||||||
else
|
else
|
||||||
_scrollBar->show();
|
_scrollBar->show();
|
||||||
@ -1827,7 +1828,7 @@ void TerminalDisplay::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
{
|
{
|
||||||
int charLine = 0;
|
int charLine = 0;
|
||||||
int charColumn = 0;
|
int charColumn = 0;
|
||||||
int scrollBarWidth = (_scrollbarLocation == ScrollBarLeft) ? _scrollBar->width() : 0;
|
int scrollBarWidth = (_scrollbarLocation == QTermWidget::ScrollBarLeft) ? _scrollBar->width() : 0;
|
||||||
|
|
||||||
getCharacterPosition(ev->pos(),charLine,charColumn);
|
getCharacterPosition(ev->pos(),charLine,charColumn);
|
||||||
|
|
||||||
@ -2487,6 +2488,15 @@ bool TerminalDisplay::usesMouse() const
|
|||||||
return _mouseMarks;
|
return _mouseMarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TerminalDisplay::setBracketedPasteMode(bool on)
|
||||||
|
{
|
||||||
|
_bracketedPasteMode = on;
|
||||||
|
}
|
||||||
|
bool TerminalDisplay::bracketedPasteMode() const
|
||||||
|
{
|
||||||
|
return _bracketedPasteMode;
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
/* */
|
/* */
|
||||||
/* Clipboard */
|
/* Clipboard */
|
||||||
@ -2508,6 +2518,11 @@ void TerminalDisplay::emitSelection(bool useXselection,bool appendReturn)
|
|||||||
if ( ! text.isEmpty() )
|
if ( ! text.isEmpty() )
|
||||||
{
|
{
|
||||||
text.replace('\n', '\r');
|
text.replace('\n', '\r');
|
||||||
|
if ( bracketedPasteMode() )
|
||||||
|
{
|
||||||
|
text.prepend("\e[200~");
|
||||||
|
text.append("\e[201~");
|
||||||
|
}
|
||||||
QKeyEvent e(QEvent::KeyPress, 0, Qt::NoModifier, text);
|
QKeyEvent e(QEvent::KeyPress, 0, Qt::NoModifier, text);
|
||||||
emit keyPressedSignal(&e); // expose as a big fat keypress event
|
emit keyPressedSignal(&e); // expose as a big fat keypress event
|
||||||
|
|
||||||
@ -2841,16 +2856,16 @@ void TerminalDisplay::calcGeometry()
|
|||||||
_scrollBar->resize(_scrollBar->sizeHint().width(), contentsRect().height());
|
_scrollBar->resize(_scrollBar->sizeHint().width(), contentsRect().height());
|
||||||
switch(_scrollbarLocation)
|
switch(_scrollbarLocation)
|
||||||
{
|
{
|
||||||
case NoScrollBar :
|
case QTermWidget::NoScrollBar :
|
||||||
_leftMargin = DEFAULT_LEFT_MARGIN;
|
_leftMargin = DEFAULT_LEFT_MARGIN;
|
||||||
_contentWidth = contentsRect().width() - 2 * DEFAULT_LEFT_MARGIN;
|
_contentWidth = contentsRect().width() - 2 * DEFAULT_LEFT_MARGIN;
|
||||||
break;
|
break;
|
||||||
case ScrollBarLeft :
|
case QTermWidget::ScrollBarLeft :
|
||||||
_leftMargin = DEFAULT_LEFT_MARGIN + _scrollBar->width();
|
_leftMargin = DEFAULT_LEFT_MARGIN + _scrollBar->width();
|
||||||
_contentWidth = contentsRect().width() - 2 * DEFAULT_LEFT_MARGIN - _scrollBar->width();
|
_contentWidth = contentsRect().width() - 2 * DEFAULT_LEFT_MARGIN - _scrollBar->width();
|
||||||
_scrollBar->move(contentsRect().topLeft());
|
_scrollBar->move(contentsRect().topLeft());
|
||||||
break;
|
break;
|
||||||
case ScrollBarRight:
|
case QTermWidget::ScrollBarRight:
|
||||||
_leftMargin = DEFAULT_LEFT_MARGIN;
|
_leftMargin = DEFAULT_LEFT_MARGIN;
|
||||||
_contentWidth = contentsRect().width() - 2 * DEFAULT_LEFT_MARGIN - _scrollBar->width();
|
_contentWidth = contentsRect().width() - 2 * DEFAULT_LEFT_MARGIN - _scrollBar->width();
|
||||||
_scrollBar->move(contentsRect().topRight() - QPoint(_scrollBar->width()-1,0));
|
_scrollBar->move(contentsRect().topRight() - QPoint(_scrollBar->width()-1,0));
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Konsole
|
// Konsole
|
||||||
#include "Filter.h"
|
#include "Filter.h"
|
||||||
#include "Character.h"
|
#include "Character.h"
|
||||||
|
#include "qtermwidget.h"
|
||||||
//#include "konsole_export.h"
|
//#include "konsole_export.h"
|
||||||
#define KONSOLEPRIVATE_EXPORT
|
#define KONSOLEPRIVATE_EXPORT
|
||||||
|
|
||||||
@ -102,23 +103,11 @@ public:
|
|||||||
/** Sets the opacity of the terminal display. */
|
/** Sets the opacity of the terminal display. */
|
||||||
void setOpacity(qreal opacity);
|
void setOpacity(qreal opacity);
|
||||||
|
|
||||||
/**
|
|
||||||
* This enum describes the location where the scroll bar is positioned in the display widget.
|
|
||||||
*/
|
|
||||||
enum ScrollBarPosition
|
|
||||||
{
|
|
||||||
/** Do not show the scroll bar. */
|
|
||||||
NoScrollBar=0,
|
|
||||||
/** Show the scroll bar on the left side of the display. */
|
|
||||||
ScrollBarLeft=1,
|
|
||||||
/** Show the scroll bar on the right side of the display. */
|
|
||||||
ScrollBarRight=2
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
void setScrollBarPosition(ScrollBarPosition position);
|
void setScrollBarPosition(QTermWidget::ScrollBarPosition position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current position and range of the display's scroll bar.
|
* Sets the current position and range of the display's scroll bar.
|
||||||
@ -200,25 +189,6 @@ public:
|
|||||||
|
|
||||||
void emitSelection(bool useXselection,bool appendReturn);
|
void emitSelection(bool useXselection,bool appendReturn);
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* Sets the shape of the keyboard cursor. This is the cursor drawn
|
||||||
* at the position in the terminal where keyboard input will appear.
|
* at the position in the terminal where keyboard input will appear.
|
||||||
@ -229,11 +199,11 @@ public:
|
|||||||
*
|
*
|
||||||
* Defaults to BlockCursor
|
* Defaults to BlockCursor
|
||||||
*/
|
*/
|
||||||
void setKeyboardCursorShape(KeyboardCursorShape shape);
|
void setKeyboardCursorShape(QTermWidget::KeyboardCursorShape shape);
|
||||||
/**
|
/**
|
||||||
* Returns the shape of the keyboard cursor. See setKeyboardCursorShape()
|
* Returns the shape of the keyboard cursor. See setKeyboardCursorShape()
|
||||||
*/
|
*/
|
||||||
KeyboardCursorShape keyboardCursorShape() const;
|
QTermWidget::KeyboardCursorShape keyboardCursorShape() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the color used to draw the keyboard cursor.
|
* Sets the color used to draw the keyboard cursor.
|
||||||
@ -505,6 +475,9 @@ public slots:
|
|||||||
/** See setUsesMouse() */
|
/** See setUsesMouse() */
|
||||||
bool usesMouse() const;
|
bool usesMouse() const;
|
||||||
|
|
||||||
|
void setBracketedPasteMode(bool bracketedPasteMode);
|
||||||
|
bool bracketedPasteMode() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a notification that a bell event has occurred in the terminal.
|
* Shows a notification that a bell event has occurred in the terminal.
|
||||||
* TODO: More documentation here
|
* TODO: More documentation here
|
||||||
@ -757,6 +730,7 @@ private:
|
|||||||
bool _terminalSizeStartup;
|
bool _terminalSizeStartup;
|
||||||
bool _bidiEnabled;
|
bool _bidiEnabled;
|
||||||
bool _mouseMarks;
|
bool _mouseMarks;
|
||||||
|
bool _bracketedPasteMode;
|
||||||
|
|
||||||
QPoint _iPntSel; // initial selection point
|
QPoint _iPntSel; // initial selection point
|
||||||
QPoint _pntSel; // current selection point
|
QPoint _pntSel; // current selection point
|
||||||
@ -769,7 +743,7 @@ private:
|
|||||||
|
|
||||||
QClipboard* _clipboard;
|
QClipboard* _clipboard;
|
||||||
QScrollBar* _scrollBar;
|
QScrollBar* _scrollBar;
|
||||||
ScrollBarPosition _scrollbarLocation;
|
QTermWidget::ScrollBarPosition _scrollbarLocation;
|
||||||
QString _wordCharacters;
|
QString _wordCharacters;
|
||||||
int _bellMode;
|
int _bellMode;
|
||||||
|
|
||||||
@ -814,7 +788,7 @@ private:
|
|||||||
TerminalImageFilterChain* _filterChain;
|
TerminalImageFilterChain* _filterChain;
|
||||||
QRegion _mouseOverHotspotArea;
|
QRegion _mouseOverHotspotArea;
|
||||||
|
|
||||||
KeyboardCursorShape _cursorShape;
|
QTermWidget::KeyboardCursorShape _cursorShape;
|
||||||
|
|
||||||
// custom cursor color. if this is invalid then the foreground
|
// custom cursor color. if this is invalid then the foreground
|
||||||
// color of the character under the cursor is used
|
// color of the character under the cursor is used
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
// Standard
|
// Standard
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
// Qt
|
// Qt
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
@ -1170,6 +1169,7 @@ void Vt102Emulation::resetModes()
|
|||||||
resetMode(MODE_Mouse1001); saveMode(MODE_Mouse1001);
|
resetMode(MODE_Mouse1001); saveMode(MODE_Mouse1001);
|
||||||
resetMode(MODE_Mouse1002); saveMode(MODE_Mouse1002);
|
resetMode(MODE_Mouse1002); saveMode(MODE_Mouse1002);
|
||||||
resetMode(MODE_Mouse1003); saveMode(MODE_Mouse1003);
|
resetMode(MODE_Mouse1003); saveMode(MODE_Mouse1003);
|
||||||
|
resetMode(MODE_BracketedPaste); saveMode(MODE_BracketedPaste);
|
||||||
|
|
||||||
resetMode(MODE_AppScreen); saveMode(MODE_AppScreen);
|
resetMode(MODE_AppScreen); saveMode(MODE_AppScreen);
|
||||||
resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys);
|
resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys);
|
||||||
@ -1193,7 +1193,11 @@ void Vt102Emulation::setMode(int m)
|
|||||||
case MODE_Mouse1001:
|
case MODE_Mouse1001:
|
||||||
case MODE_Mouse1002:
|
case MODE_Mouse1002:
|
||||||
case MODE_Mouse1003:
|
case MODE_Mouse1003:
|
||||||
emit programUsesMouseChanged(false);
|
emit programUsesMouseChanged(false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MODE_BracketedPaste:
|
||||||
|
emit programBracketedPasteModeChanged(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_AppScreen : _screen[1]->clearSelection();
|
case MODE_AppScreen : _screen[1]->clearSelection();
|
||||||
@ -1223,6 +1227,10 @@ void Vt102Emulation::resetMode(int m)
|
|||||||
emit programUsesMouseChanged(true);
|
emit programUsesMouseChanged(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MODE_BracketedPaste:
|
||||||
|
emit programBracketedPasteModeChanged(false);
|
||||||
|
break;
|
||||||
|
|
||||||
case MODE_AppScreen :
|
case MODE_AppScreen :
|
||||||
_screen[0]->clearSelection();
|
_screen[0]->clearSelection();
|
||||||
setScreen(0);
|
setScreen(0);
|
||||||
|
@ -355,6 +355,9 @@ protected:
|
|||||||
openMode(QIODevice::ReadWrite)
|
openMode(QIODevice::ReadWrite)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
virtual ~KProcessPrivate()
|
||||||
|
{
|
||||||
|
}
|
||||||
void writeAll(const QByteArray &buf, int fd);
|
void writeAll(const QByteArray &buf, int fd);
|
||||||
void forwardStd(KProcess::ProcessChannel good, int fd);
|
void forwardStd(KProcess::ProcessChannel good, int fd);
|
||||||
void _k_forwardStdout();
|
void _k_forwardStdout();
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
struct KPtyPrivate;
|
class KPtyPrivate;
|
||||||
struct termios;
|
struct termios;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
struct KPtyPrivate {
|
class KPtyPrivate {
|
||||||
|
public:
|
||||||
|
|
||||||
Q_DECLARE_PUBLIC(KPty)
|
Q_DECLARE_PUBLIC(KPty)
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class QSocketNotifier;
|
|||||||
#define Q_DECLARE_PRIVATE_MI(Class, SuperClass) \
|
#define Q_DECLARE_PRIVATE_MI(Class, SuperClass) \
|
||||||
inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(SuperClass::d_ptr); } \
|
inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(SuperClass::d_ptr); } \
|
||||||
inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(SuperClass::d_ptr); } \
|
inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(SuperClass::d_ptr); } \
|
||||||
friend class Class##Private;
|
friend struct Class##Private;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates KPty into a QIODevice, so it can be used with Q*Stream, etc.
|
* Encapsulates KPty into a QIODevice, so it can be used with Q*Stream, etc.
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
class KPtyDevice;
|
class KPtyDevice;
|
||||||
|
|
||||||
struct KPtyProcessPrivate;
|
class KPtyProcessPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class extends KProcess by support for PTYs (pseudo TTYs).
|
* This class extends KProcess by support for PTYs (pseudo TTYs).
|
||||||
@ -155,7 +155,8 @@ private:
|
|||||||
// private data //
|
// private data //
|
||||||
//////////////////
|
//////////////////
|
||||||
|
|
||||||
struct KPtyProcessPrivate : KProcessPrivate {
|
class KPtyProcessPrivate : public KProcessPrivate {
|
||||||
|
public:
|
||||||
KPtyProcessPrivate() :
|
KPtyProcessPrivate() :
|
||||||
ptyChannels(KPtyProcess::NoChannels),
|
ptyChannels(KPtyProcess::NoChannels),
|
||||||
addUtmp(false)
|
addUtmp(false)
|
||||||
|
@ -296,11 +296,13 @@ void QTermWidget::init(int startnow)
|
|||||||
m_searchBar->setFont(font);
|
m_searchBar->setFont(font);
|
||||||
|
|
||||||
setScrollBarPosition(NoScrollBar);
|
setScrollBarPosition(NoScrollBar);
|
||||||
|
setKeyboardCursorShape(BlockCursor);
|
||||||
|
|
||||||
m_impl->m_session->addView(m_impl->m_terminalDisplay);
|
m_impl->m_session->addView(m_impl->m_terminalDisplay);
|
||||||
|
|
||||||
connect(m_impl->m_session, SIGNAL(resizeRequest(QSize)), this, SLOT(setSize(QSize)));
|
connect(m_impl->m_session, SIGNAL(resizeRequest(QSize)), this, SLOT(setSize(QSize)));
|
||||||
connect(m_impl->m_session, SIGNAL(finished()), this, SLOT(sessionFinished()));
|
connect(m_impl->m_session, SIGNAL(finished()), this, SLOT(sessionFinished()));
|
||||||
|
connect(m_impl->m_session, SIGNAL(titleChanged()), this, SLOT(sessionTitleChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -432,6 +434,11 @@ QStringList QTermWidget::availableColorSchemes()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QTermWidget::addCustomColorSchemeDir(const QString& custom_dir)
|
||||||
|
{
|
||||||
|
ColorSchemeManager::instance()->addCustomColorSchemeDir(custom_dir);
|
||||||
|
}
|
||||||
|
|
||||||
void QTermWidget::setSize(const QSize &size)
|
void QTermWidget::setSize(const QSize &size)
|
||||||
{
|
{
|
||||||
if (!m_impl->m_terminalDisplay)
|
if (!m_impl->m_terminalDisplay)
|
||||||
@ -451,7 +458,7 @@ void QTermWidget::setScrollBarPosition(ScrollBarPosition pos)
|
|||||||
{
|
{
|
||||||
if (!m_impl->m_terminalDisplay)
|
if (!m_impl->m_terminalDisplay)
|
||||||
return;
|
return;
|
||||||
m_impl->m_terminalDisplay->setScrollBarPosition((TerminalDisplay::ScrollBarPosition)pos);
|
m_impl->m_terminalDisplay->setScrollBarPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTermWidget::scrollToEnd()
|
void QTermWidget::scrollToEnd()
|
||||||
@ -478,6 +485,11 @@ void QTermWidget::sessionFinished()
|
|||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QTermWidget::sessionTitleChanged()
|
||||||
|
{
|
||||||
|
emit titleChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QTermWidget::copyClipboard()
|
void QTermWidget::copyClipboard()
|
||||||
{
|
{
|
||||||
@ -641,3 +653,20 @@ int QTermWidget::getPtySlaveFd() const
|
|||||||
{
|
{
|
||||||
return m_impl->m_session->getPtySlaveFd();
|
return m_impl->m_session->getPtySlaveFd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QTermWidget::setKeyboardCursorShape(KeyboardCursorShape shape)
|
||||||
|
{
|
||||||
|
if (!m_impl->m_terminalDisplay)
|
||||||
|
return;
|
||||||
|
m_impl->m_terminalDisplay->setKeyboardCursorShape(shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QTermWidget::userTitle() const
|
||||||
|
{
|
||||||
|
return m_impl->m_session->userTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QTermWidget::iconText() const
|
||||||
|
{
|
||||||
|
return m_impl->m_session->iconText();
|
||||||
|
}
|
||||||
|
@ -32,13 +32,35 @@ class QTermWidget : public QWidget {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This enum describes the location where the scroll bar is positioned in the display widget.
|
||||||
|
*/
|
||||||
enum ScrollBarPosition {
|
enum ScrollBarPosition {
|
||||||
/** Do not show the scroll bar. */
|
/** Do not show the scroll bar. */
|
||||||
NoScrollBar=0,
|
NoScrollBar = 0,
|
||||||
/** Show the scroll bar on the left side of the display. */
|
/** Show the scroll bar on the left side of the display. */
|
||||||
ScrollBarLeft=1,
|
ScrollBarLeft = 1,
|
||||||
/** Show the scroll bar on the right side of the display. */
|
/** Show the scroll bar on the right side of the display. */
|
||||||
ScrollBarRight=2
|
ScrollBarRight = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 = 0,
|
||||||
|
/**
|
||||||
|
* A single flat line which occupies the space at the bottom of the cursor
|
||||||
|
* character's area.
|
||||||
|
*/
|
||||||
|
UnderlineCursor = 1,
|
||||||
|
/**
|
||||||
|
* An cursor shaped like the capital letter 'I', similar to the IBeam
|
||||||
|
* cursor used in Qt/KDE text editors.
|
||||||
|
*/
|
||||||
|
IBeamCursor = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
//Creation of widget
|
//Creation of widget
|
||||||
@ -98,6 +120,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setColorScheme(const QString & name);
|
void setColorScheme(const QString & name);
|
||||||
static QStringList availableColorSchemes();
|
static QStringList availableColorSchemes();
|
||||||
|
static void addCustomColorSchemeDir(const QString& custom_dir);
|
||||||
|
|
||||||
// History size for scrolling
|
// History size for scrolling
|
||||||
void setHistorySize(int lines); //infinite if lines < 0
|
void setHistorySize(int lines); //infinite if lines < 0
|
||||||
@ -176,6 +199,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
int getPtySlaveFd() const;
|
int getPtySlaveFd() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the shape of the keyboard cursor. This is the cursor drawn
|
||||||
|
* at the position in the terminal where keyboard input will appear.
|
||||||
|
*/
|
||||||
|
void setKeyboardCursorShape(KeyboardCursorShape shape);
|
||||||
|
|
||||||
|
QString userTitle() const;
|
||||||
|
QString iconText() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
void copyAvailable(bool);
|
void copyAvailable(bool);
|
||||||
@ -199,6 +231,8 @@ signals:
|
|||||||
*/
|
*/
|
||||||
void sendData(const char *,int);
|
void sendData(const char *,int);
|
||||||
|
|
||||||
|
void titleChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Copy selection to clipboard
|
// Copy selection to clipboard
|
||||||
void copyClipboard();
|
void copyClipboard();
|
||||||
@ -231,6 +265,7 @@ protected:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void sessionFinished();
|
void sessionFinished();
|
||||||
|
void sessionTitleChanged();
|
||||||
void selectionChanged(bool textSelected);
|
void selectionChanged(bool textSelected);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -43,36 +43,61 @@ QString get_kb_layout_dir()
|
|||||||
#endif // BUNDLE_KEYBOARDLAYOUTS
|
#endif // BUNDLE_KEYBOARDLAYOUTS
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Helper function to get possible location of layout files.
|
/*! Helper function to add custom location of color schemes.
|
||||||
|
*/
|
||||||
|
namespace {
|
||||||
|
QStringList custom_color_schemes_dirs;
|
||||||
|
}
|
||||||
|
void add_custom_color_scheme_dir(const QString& custom_dir)
|
||||||
|
{
|
||||||
|
if (!custom_color_schemes_dirs.contains(custom_dir))
|
||||||
|
custom_color_schemes_dirs << custom_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Helper function to get possible locations of color schemes.
|
||||||
By default the COLORSCHEMES_DIR is used (linux/BSD/macports).
|
By default the COLORSCHEMES_DIR is used (linux/BSD/macports).
|
||||||
But in some cases (apple bundle) there can be more locations).
|
But in some cases (apple bundle) there can be more locations).
|
||||||
*/
|
*/
|
||||||
QString get_color_schemes_dir()
|
const QStringList get_color_schemes_dirs()
|
||||||
{
|
{
|
||||||
#ifdef BUNDLE_COLORSCHEMES
|
#ifdef BUNDLE_COLORSCHEMES
|
||||||
return QLatin1String(":/");
|
return QLatin1String(":/");
|
||||||
#else
|
#else
|
||||||
// qDebug() << __FILE__ << __FUNCTION__;
|
// qDebug() << __FILE__ << __FUNCTION__;
|
||||||
|
|
||||||
QString rval = "";
|
QStringList rval;
|
||||||
QString k(COLORSCHEMES_DIR);
|
QString k(COLORSCHEMES_DIR);
|
||||||
QDir d(k);
|
QDir d(k);
|
||||||
|
|
||||||
// qDebug() << "default COLORSCHEMES_DIR: " << k;
|
// qDebug() << "default COLORSCHEMES_DIR: " << k;
|
||||||
|
|
||||||
if (d.exists())
|
if (d.exists())
|
||||||
rval = k.append("/");
|
rval << k.append("/");
|
||||||
|
|
||||||
// subdir in the app location
|
// subdir in the app location
|
||||||
d.setPath(QCoreApplication::applicationDirPath() + "/color-schemes/");
|
d.setPath(QCoreApplication::applicationDirPath() + "/color-schemes/");
|
||||||
//qDebug() << d.path();
|
//qDebug() << d.path();
|
||||||
if (d.exists())
|
if (d.exists())
|
||||||
rval = QCoreApplication::applicationDirPath() + "/color-schemes/";
|
{
|
||||||
|
if (!rval.isEmpty())
|
||||||
|
rval.clear();
|
||||||
|
rval << (QCoreApplication::applicationDirPath() + "/color-schemes/");
|
||||||
|
}
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
d.setPath(QCoreApplication::applicationDirPath() + "/../Resources/color-schemes/");
|
d.setPath(QCoreApplication::applicationDirPath() + "/../Resources/color-schemes/");
|
||||||
if (d.exists())
|
if (d.exists())
|
||||||
rval = QCoreApplication::applicationDirPath() + "/../Resources/color-schemes/";
|
{
|
||||||
|
if (!rval.isEmpty())
|
||||||
|
rval.clear();
|
||||||
|
rval << (QCoreApplication::applicationDirPath() + "/../Resources/color-schemes/");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
for (const QString& custom_dir : custom_color_schemes_dirs)
|
||||||
|
{
|
||||||
|
d.setPath(custom_dir);
|
||||||
|
if (d.exists())
|
||||||
|
rval << custom_dir;
|
||||||
|
}
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
if(!rval.isEmpty()) {
|
if(!rval.isEmpty()) {
|
||||||
qDebug() << "Using color-schemes: " << rval;
|
qDebug() << "Using color-schemes: " << rval;
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
#define TOOLS_H
|
#define TOOLS_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
QString get_kb_layout_dir();
|
QString get_kb_layout_dir();
|
||||||
QString get_color_schemes_dir();
|
void add_custom_color_scheme_dir(const QString& custom_dir);
|
||||||
|
const QStringList get_color_schemes_dirs();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
34
pyqt/README.md
Normal file
34
pyqt/README.md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
PyQt5 Bindings for QTermWidget
|
||||||
|
==============================
|
||||||
|
|
||||||
|
|
||||||
|
INSTALL:
|
||||||
|
------------
|
||||||
|
####1. Download QTermWidget -> https://github.com/lxde/qtermwidget
|
||||||
|
|
||||||
|
####2. Compile and install it:
|
||||||
|
$ mkdir build && cd build
|
||||||
|
$ cmake ..
|
||||||
|
$ make
|
||||||
|
$ sudo make install
|
||||||
|
If `make install` command will not work just copy the `qtermwidget.so*` files to /usr/lib directory.
|
||||||
|
####3. Install PyQt5 and PyQt5-devel if not yet installed.
|
||||||
|
####4. Configure, compile and install bindings. Execute in terminal in the qtermwidget bindings folder:
|
||||||
|
|
||||||
|
$ python config.py
|
||||||
|
$ make
|
||||||
|
$ sudo make install
|
||||||
|
|
||||||
|
####5. You can run ./test.py to test the installed module.
|
||||||
|
|
||||||
|
|
||||||
|
ABOUT:
|
||||||
|
---------
|
||||||
|
Based on previous PyQt4 bindings by:
|
||||||
|
- Piotr "Riklaunim" Maliński <riklaunim@gmail.com>,
|
||||||
|
- Alexander Slesarev <alex.slesarev@gmail.com>
|
||||||
|
|
||||||
|
|
||||||
|
PyQt5 QTermWidget Bindings
|
||||||
|
License: GPL3
|
||||||
|
|
85
pyqt/config-old.py
Executable file
85
pyqt/config-old.py
Executable file
@ -0,0 +1,85 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# PyQt4 bindings for th QTermWidget project.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2009 Piotr "Riklaunim" Maliński <riklaunim@gmail.com>,
|
||||||
|
# Alexander Slesarev <alex.slesarev@gmail.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sipconfig
|
||||||
|
from PyQt4 import pyqtconfig
|
||||||
|
|
||||||
|
# The name of the SIP build file generated by SIP and used by the build
|
||||||
|
# system.
|
||||||
|
build_file = "qtermwidget.sbf"
|
||||||
|
|
||||||
|
# Get the PyQt configuration information.
|
||||||
|
config = pyqtconfig.Configuration()
|
||||||
|
|
||||||
|
# Get the extra SIP flags needed by the imported qt module. Note that
|
||||||
|
# this normally only includes those flags (-x and -t) that relate to SIP's
|
||||||
|
# versioning system.
|
||||||
|
qt_sip_flags = config.pyqt_sip_flags
|
||||||
|
|
||||||
|
# Run SIP to generate the code. Note that we tell SIP where to find the qt
|
||||||
|
# module's specification files using the -I flag.
|
||||||
|
os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "-I",
|
||||||
|
config.pyqt_sip_dir, qt_sip_flags, "qtermwidget.sip"]))
|
||||||
|
|
||||||
|
# We are going to install the SIP specification file for this module and
|
||||||
|
# its configuration module.
|
||||||
|
installs = []
|
||||||
|
|
||||||
|
installs.append(["qtermwidget.sip", os.path.join(config.default_sip_dir,
|
||||||
|
"qtermwidget")])
|
||||||
|
|
||||||
|
installs.append(["qtermwidgetconfig.py", config.default_mod_dir])
|
||||||
|
|
||||||
|
# Create the Makefile. The QtModuleMakefile class provided by the
|
||||||
|
# pyqtconfig module takes care of all the extra preprocessor, compiler and
|
||||||
|
# linker flags needed by the Qt library.
|
||||||
|
makefile = pyqtconfig.QtGuiModuleMakefile(
|
||||||
|
configuration = config,
|
||||||
|
build_file = build_file,
|
||||||
|
installs = installs)
|
||||||
|
|
||||||
|
# Add the library we are wrapping. The name doesn't include any platform
|
||||||
|
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
|
||||||
|
# ".dll" extension on Windows).
|
||||||
|
makefile.extra_lib_dirs.append("..")
|
||||||
|
makefile.extra_libs = ["qtermwidget4"]
|
||||||
|
|
||||||
|
# Generate the Makefile itself.
|
||||||
|
makefile.generate()
|
||||||
|
|
||||||
|
# Now we create the configuration module. This is done by merging a Python
|
||||||
|
# dictionary (whose values are normally determined dynamically) with a
|
||||||
|
# (static) template.
|
||||||
|
content = {
|
||||||
|
# Publish where the SIP specifications for this module will be
|
||||||
|
# installed.
|
||||||
|
"qtermwidget_sip_dir": config.default_sip_dir,
|
||||||
|
|
||||||
|
# Publish the set of SIP flags needed by this module. As these are the
|
||||||
|
# same flags needed by the qt module we could leave it out, but this
|
||||||
|
# allows us to change the flags at a later date without breaking
|
||||||
|
# scripts that import the configuration module.
|
||||||
|
"qtermwidget_sip_flags": qt_sip_flags}
|
||||||
|
|
||||||
|
# This creates the qtermwidgetconfig.py module from the qtermwidgetconfig.py.in
|
||||||
|
# template and the dictionary.
|
||||||
|
sipconfig.create_config_module("qtermwidgetconfig.py", "config.py.in", content)
|
93
pyqt/config.py
Executable file
93
pyqt/config.py
Executable file
@ -0,0 +1,93 @@
|
|||||||
|
import os
|
||||||
|
import sipconfig
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
import site
|
||||||
|
import pprint
|
||||||
|
from distutils import sysconfig
|
||||||
|
import pyqtconfig
|
||||||
|
from PyQt5 import QtCore
|
||||||
|
import PyQt5
|
||||||
|
|
||||||
|
class Configuration(sipconfig.Configuration):
|
||||||
|
"""The class that represents PyQt configuration values.
|
||||||
|
"""
|
||||||
|
def getEnv(self,name, default):
|
||||||
|
return os.environ.get(name) or default
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
qtconfig = subprocess.check_output(["/usr/lib64/qt5/bin/qmake", "-query"], universal_newlines=True)
|
||||||
|
qtconfig = dict(x.split(":", 1) for x in qtconfig.splitlines())
|
||||||
|
|
||||||
|
self.pyQtIncludePath = self.getEnv('PYQT_INCLUDE_PATH','/usr/share/sip/PyQt5' )
|
||||||
|
|
||||||
|
pyqtconfig = {
|
||||||
|
"pyqt_config_args": "--confirm-license -v "+str(self.pyQtIncludePath)+" --qsci-api -q /usr/lib64/qt5/bin/qmake",
|
||||||
|
"pyqt_version": QtCore.PYQT_VERSION,
|
||||||
|
"pyqt_version_str": QtCore.PYQT_VERSION_STR,
|
||||||
|
"pyqt_bin_dir": PyQt5.__path__[0],
|
||||||
|
"pyqt_mod_dir": PyQt5.__path__[0],
|
||||||
|
"pyqt_sip_dir": str(self.pyQtIncludePath),
|
||||||
|
"pyqt_modules": "QtCore QtGui QtWidgets", #... and many more
|
||||||
|
"pyqt_sip_flags": QtCore.PYQT_CONFIGURATION['sip_flags'],
|
||||||
|
"qt_version": QtCore.QT_VERSION,
|
||||||
|
"qt_edition": "free",
|
||||||
|
"qt_winconfig": "shared",
|
||||||
|
"qt_framework": 0,
|
||||||
|
"qt_threaded": 1,
|
||||||
|
"qt_dir": qtconfig['QT_INSTALL_PREFIX'],
|
||||||
|
"qt_data_dir": qtconfig['QT_INSTALL_DATA'],
|
||||||
|
"qt_archdata_dir": qtconfig['QT_INSTALL_DATA'],
|
||||||
|
"qt_inc_dir": qtconfig['QT_INSTALL_HEADERS'],
|
||||||
|
"qt_lib_dir": qtconfig['QT_INSTALL_LIBS']
|
||||||
|
}
|
||||||
|
|
||||||
|
macros = sipconfig._default_macros.copy()
|
||||||
|
macros['INCDIR_QT'] = qtconfig['QT_INSTALL_HEADERS']
|
||||||
|
macros['LIBDIR_QT'] = qtconfig['QT_INSTALL_LIBS']
|
||||||
|
macros['MOC'] = os.path.join(qtconfig['QT_INSTALL_BINS'], 'moc')
|
||||||
|
|
||||||
|
sipconfig.Configuration.__init__(self, [pyqtconfig])
|
||||||
|
self.set_build_macros(macros)
|
||||||
|
|
||||||
|
|
||||||
|
## The name of the SIP build file generated by SIP and used by the build system.
|
||||||
|
build_file = "qtermwidget.sbf"
|
||||||
|
|
||||||
|
# Get the SIP configuration information.
|
||||||
|
config = Configuration()
|
||||||
|
|
||||||
|
# Run SIP to generate the build_file
|
||||||
|
os.system(" ".join([config.sip_bin, '-I' , str(config.pyQtIncludePath), str(config.pyqt_sip_flags), "-b", build_file,"-o", "-c", ". " " qtermwidget.sip"]))
|
||||||
|
|
||||||
|
installs = []
|
||||||
|
installs.append(["qtermwidget.sip", os.path.join(config.pyqt_sip_dir,"qtermwidget")])
|
||||||
|
installs.append(["qtermwidgetconfig.py", config.pyqt_mod_dir])
|
||||||
|
|
||||||
|
makefile = sipconfig.SIPModuleMakefile( configuration = config, build_file = build_file, installs = installs, qt=["QtCore" ,"QtGui", "QtWidgets"] )
|
||||||
|
|
||||||
|
# Add the library we are wrapping. The name doesn't include any platform
|
||||||
|
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
|
||||||
|
# ".dll" extension on Windows).
|
||||||
|
makefile.extra_lib_dirs.append("../lib/")
|
||||||
|
makefile.extra_lib_dirs.append("..")
|
||||||
|
makefile.extra_libs = ["qtermwidget5"]
|
||||||
|
|
||||||
|
# Generate the Makefile itself.
|
||||||
|
makefile.generate()
|
||||||
|
|
||||||
|
content = {
|
||||||
|
# Publish where the SIP specifications for this module will be
|
||||||
|
# installed.
|
||||||
|
"qtermwidget_sip_dir": config.pyqt_sip_dir,
|
||||||
|
|
||||||
|
# Publish the set of SIP flags needed by this module. As these are the
|
||||||
|
# same flags needed by the qt module we could leave it out, but this
|
||||||
|
# allows us to change the flags at a later date without breaking
|
||||||
|
# scripts that import the configuration module.
|
||||||
|
"qtermwidget_sip_flags": config.pyqt_sip_flags
|
||||||
|
}
|
||||||
|
|
||||||
|
# This creates the qtermwidgetconfig.py module from the qtermwidgetconfig.py.in
|
||||||
|
# template and the dictionary.
|
||||||
|
sipconfig.create_config_module("qtermwidgetconfig.py", "config.py.in", content)
|
0
pyqt/config.py.in
Normal file
0
pyqt/config.py.in
Normal file
86
pyqt/qtermwidget.sip
Normal file
86
pyqt/qtermwidget.sip
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
%Module QTermWidget
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%Import QtGui/QtGuimod.sip
|
||||||
|
%Import QtCore/QtCoremod.sip
|
||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
class QTermWidget : QWidget {
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <../lib/qtermwidget.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum ScrollBarPosition
|
||||||
|
{
|
||||||
|
NoScrollBar=0,
|
||||||
|
ScrollBarLeft=1,
|
||||||
|
ScrollBarRight=2
|
||||||
|
};
|
||||||
|
|
||||||
|
QTermWidget(int startnow = 1, QWidget *parent = 0);
|
||||||
|
~QTermWidget();
|
||||||
|
|
||||||
|
QSize sizeHint() const;
|
||||||
|
void startShellProgram();
|
||||||
|
int getShellPID();
|
||||||
|
void changeDir(const QString & dir);
|
||||||
|
void setTerminalFont(QFont &font);
|
||||||
|
QFont getTerminalFont();
|
||||||
|
void setTerminalOpacity(qreal level);
|
||||||
|
void setEnvironment(const QStringList & environment);
|
||||||
|
void setShellProgram(const QString & progname);
|
||||||
|
void setWorkingDirectory(const QString & dir);
|
||||||
|
QString workingDirectory();
|
||||||
|
void setArgs(QStringList &args);
|
||||||
|
void setTextCodec(QTextCodec *codec);
|
||||||
|
void setColorScheme(const QString & name);
|
||||||
|
static QStringList availableColorSchemes();
|
||||||
|
void setHistorySize(int lines);
|
||||||
|
void setScrollBarPosition(ScrollBarPosition);
|
||||||
|
void scrollToEnd();
|
||||||
|
void sendText(QString &text);
|
||||||
|
void setFlowControlEnabled(bool enabled);
|
||||||
|
bool flowControlEnabled();
|
||||||
|
void setFlowControlWarningEnabled(bool enabled);
|
||||||
|
static QStringList availableKeyBindings();
|
||||||
|
QString keyBindings();
|
||||||
|
void setMotionAfterPasting(int);
|
||||||
|
int historyLinesCount();
|
||||||
|
int screenColumnsCount();
|
||||||
|
void setSelectionStart(int row, int column);
|
||||||
|
void setSelectionEnd(int row, int column);
|
||||||
|
void getSelectionStart(int& row, int& column);
|
||||||
|
void getSelectionEnd(int& row, int& column);
|
||||||
|
QString selectedText(bool preserveLineBreaks = true);
|
||||||
|
void setMonitorActivity(bool);
|
||||||
|
void setMonitorSilence(bool);
|
||||||
|
void setSilenceTimeout(int seconds);
|
||||||
|
signals:
|
||||||
|
void finished();
|
||||||
|
void copyAvailable(bool);
|
||||||
|
void termGetFocus();
|
||||||
|
void termLostFocus();
|
||||||
|
void termKeyPressed(QKeyEvent *);
|
||||||
|
void urlActivated(const QUrl&);
|
||||||
|
void bell(const QString& message);
|
||||||
|
void activity();
|
||||||
|
void silence();
|
||||||
|
public slots:
|
||||||
|
void copyClipboard();
|
||||||
|
void pasteClipboard();
|
||||||
|
void pasteSelection();
|
||||||
|
void zoomIn();
|
||||||
|
void zoomOut();
|
||||||
|
void setKeyBindings(const QString & kb);
|
||||||
|
void clear();
|
||||||
|
void toggleShowSearchBar();
|
||||||
|
void setSize(const QSize&);
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *e);
|
||||||
|
private:
|
||||||
|
void *createTermWidget(int startnow, void *parent);
|
||||||
|
};
|
0
pyqt/qtermwidgetconfig.py
Normal file
0
pyqt/qtermwidgetconfig.py
Normal file
34
pyqt/test.py
Executable file
34
pyqt/test.py
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# PyQt4 bindings for th QTermWidget project.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2009 Piotr "Riklaunim" Maliński <riklaunim@gmail.com>,
|
||||||
|
# Alexander Slesarev <alex.slesarev@gmail.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import sys, signal
|
||||||
|
from PyQt5 import QtCore,QtWidgets
|
||||||
|
|
||||||
|
import QTermWidget
|
||||||
|
|
||||||
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
|
a = QtWidgets.QApplication(sys.argv)
|
||||||
|
|
||||||
|
w = QTermWidget.QTermWidget()
|
||||||
|
w.finished.connect(a.quit)
|
||||||
|
w.show()
|
||||||
|
|
||||||
|
a.exec_()
|
Loading…
x
Reference in New Issue
Block a user