mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-03-14 06:38:38 +00:00
Fix trailing whitespaces
Fixed some whitespaces "errors" which i found when going through the source.
This commit is contained in:
parent
c2fca955c4
commit
61621516bc
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of Konsole, KDE's terminal.
|
||||
|
||||
|
||||
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
|
||||
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||
|
||||
@ -53,7 +53,7 @@ static const int LINE_DOUBLEHEIGHT = (1 << 2);
|
||||
class Character
|
||||
{
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* Constructs a new character.
|
||||
*
|
||||
* @param _c The unicode character value of this character.
|
||||
@ -71,25 +71,25 @@ public:
|
||||
{
|
||||
/** The unicode character value for this character. */
|
||||
quint16 character;
|
||||
/**
|
||||
/**
|
||||
* Experimental addition which allows a single Character instance to contain more than
|
||||
* one unicode character.
|
||||
*
|
||||
* charSequence is a hash code which can be used to look up the unicode
|
||||
* character sequence in the ExtendedCharTable used to create the sequence.
|
||||
*/
|
||||
quint16 charSequence;
|
||||
quint16 charSequence;
|
||||
};
|
||||
|
||||
/** A combination of RENDITION flags which specify options for drawing the character. */
|
||||
quint8 rendition;
|
||||
|
||||
/** The foreground color used to draw this character. */
|
||||
CharacterColor foregroundColor;
|
||||
CharacterColor foregroundColor;
|
||||
/** The color used to draw this character's background. */
|
||||
CharacterColor backgroundColor;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns true if this character has a transparent background when
|
||||
* it is drawn with the specified @p palette.
|
||||
*/
|
||||
@ -97,16 +97,16 @@ public:
|
||||
/**
|
||||
* Returns true if this character should always be drawn in bold when
|
||||
* it is drawn with the specified @p palette, independent of whether
|
||||
* or not the character has the RE_BOLD rendition flag.
|
||||
* or not the character has the RE_BOLD rendition flag.
|
||||
*/
|
||||
ColorEntry::FontWeight fontWeight(const ColorEntry* base) const;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* returns true if the format (color, rendition flag) of the compared characters is equal
|
||||
*/
|
||||
bool equalsFormat(const Character &other) const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Compares two characters and returns true if they have the same unicode character value,
|
||||
* rendition and colors.
|
||||
*/
|
||||
@ -119,36 +119,36 @@ public:
|
||||
};
|
||||
|
||||
inline bool operator == (const Character& a, const Character& b)
|
||||
{
|
||||
return a.character == b.character &&
|
||||
a.rendition == b.rendition &&
|
||||
a.foregroundColor == b.foregroundColor &&
|
||||
{
|
||||
return a.character == b.character &&
|
||||
a.rendition == b.rendition &&
|
||||
a.foregroundColor == b.foregroundColor &&
|
||||
a.backgroundColor == b.backgroundColor;
|
||||
}
|
||||
|
||||
inline bool operator != (const Character& a, const Character& b)
|
||||
{
|
||||
return a.character != b.character ||
|
||||
a.rendition != b.rendition ||
|
||||
a.foregroundColor != b.foregroundColor ||
|
||||
return a.character != b.character ||
|
||||
a.rendition != b.rendition ||
|
||||
a.foregroundColor != b.foregroundColor ||
|
||||
a.backgroundColor != b.backgroundColor;
|
||||
}
|
||||
|
||||
inline bool Character::isTransparent(const ColorEntry* base) const
|
||||
{
|
||||
return ((backgroundColor._colorSpace == COLOR_SPACE_DEFAULT) &&
|
||||
return ((backgroundColor._colorSpace == COLOR_SPACE_DEFAULT) &&
|
||||
base[backgroundColor._u+0+(backgroundColor._v?BASE_COLORS:0)].transparent)
|
||||
|| ((backgroundColor._colorSpace == COLOR_SPACE_SYSTEM) &&
|
||||
|| ((backgroundColor._colorSpace == COLOR_SPACE_SYSTEM) &&
|
||||
base[backgroundColor._u+2+(backgroundColor._v?BASE_COLORS:0)].transparent);
|
||||
}
|
||||
|
||||
inline bool Character::equalsFormat(const Character& other) const
|
||||
{
|
||||
return
|
||||
return
|
||||
backgroundColor==other.backgroundColor &&
|
||||
foregroundColor==other.foregroundColor &&
|
||||
rendition==other.rendition;
|
||||
}
|
||||
}
|
||||
|
||||
inline ColorEntry::FontWeight Character::fontWeight(const ColorEntry* base) const
|
||||
{
|
||||
@ -193,7 +193,7 @@ public:
|
||||
* which was added to the table using createExtendedChar().
|
||||
*
|
||||
* @param hash The hash key returned by createExtendedChar()
|
||||
* @param length This variable is set to the length of the
|
||||
* @param length This variable is set to the length of the
|
||||
* character sequence.
|
||||
*
|
||||
* @return A unicode character sequence of size @p length.
|
||||
@ -205,7 +205,7 @@ public:
|
||||
private:
|
||||
// calculates the hash key of a sequence of unicode points of size 'length'
|
||||
ushort extendedCharHash(ushort* unicodePoints , ushort length) const;
|
||||
// tests whether the entry in the table specified by 'hash' matches the
|
||||
// tests whether the entry in the table specified by 'hash' matches the
|
||||
// character sequence 'unicodePoints' of size 'length'
|
||||
bool extendedCharMatch(ushort hash , ushort* unicodePoints , ushort length) const;
|
||||
// internal, maps hash keys to character sequence buffers. The first ushort
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of Konsole, KDE's terminal.
|
||||
|
||||
|
||||
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
|
||||
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||
|
||||
@ -29,14 +29,14 @@
|
||||
//#include <kdemacros.h>
|
||||
#define KDE_NO_EXPORT
|
||||
|
||||
/**
|
||||
* An entry in a terminal display's color palette.
|
||||
/**
|
||||
* An entry in a terminal display's color palette.
|
||||
*
|
||||
* A color palette is an array of 16 ColorEntry instances which map
|
||||
* system color indexes (from 0 to 15) into actual colors.
|
||||
*
|
||||
* Each entry can be set as bold, in which case any text
|
||||
* drawn using the color should be drawn in bold.
|
||||
* drawn using the color should be drawn in bold.
|
||||
*
|
||||
* Each entry can also be transparent, in which case the terminal
|
||||
* display should avoid drawing the background for any characters
|
||||
@ -46,58 +46,58 @@ class ColorEntry
|
||||
{
|
||||
public:
|
||||
/** Specifies the weight to use when drawing text with this color. */
|
||||
enum FontWeight
|
||||
enum FontWeight
|
||||
{
|
||||
/** Always draw text in this color with a bold weight. */
|
||||
Bold,
|
||||
/** Always draw text in this color with a normal weight. */
|
||||
Normal,
|
||||
/**
|
||||
* Use the current font weight set by the terminal application.
|
||||
/**
|
||||
* Use the current font weight set by the terminal application.
|
||||
* This is the default behavior.
|
||||
*/
|
||||
UseCurrentFormat
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* Constructs a new color palette entry.
|
||||
*
|
||||
* @param c The color value for this entry.
|
||||
* @param tr Specifies that the color should be transparent when used as a background color.
|
||||
* @param weight Specifies the font weight to use when drawing text with this color.
|
||||
* @param weight Specifies the font weight to use when drawing text with this color.
|
||||
*/
|
||||
ColorEntry(QColor c, bool tr, FontWeight weight = UseCurrentFormat)
|
||||
ColorEntry(QColor c, bool tr, FontWeight weight = UseCurrentFormat)
|
||||
: color(c), transparent(tr), fontWeight(weight) {}
|
||||
|
||||
/**
|
||||
* Constructs a new color palette entry with an undefined color, and
|
||||
* with the transparent and bold flags set to false.
|
||||
*/
|
||||
ColorEntry() : transparent(false), fontWeight(UseCurrentFormat) {}
|
||||
|
||||
*/
|
||||
ColorEntry() : transparent(false), fontWeight(UseCurrentFormat) {}
|
||||
|
||||
/**
|
||||
* Sets the color, transparency and boldness of this color to those of @p rhs.
|
||||
*/
|
||||
void operator=(const ColorEntry& rhs)
|
||||
{
|
||||
color = rhs.color;
|
||||
transparent = rhs.transparent;
|
||||
fontWeight = rhs.fontWeight;
|
||||
*/
|
||||
void operator=(const ColorEntry& rhs)
|
||||
{
|
||||
color = rhs.color;
|
||||
transparent = rhs.transparent;
|
||||
fontWeight = rhs.fontWeight;
|
||||
}
|
||||
|
||||
/** The color value of this entry for display. */
|
||||
QColor color;
|
||||
|
||||
/**
|
||||
* If true character backgrounds using this color should be transparent.
|
||||
/**
|
||||
* If true character backgrounds using this color should be transparent.
|
||||
* This is not applicable when the color is used to render text.
|
||||
*/
|
||||
bool transparent;
|
||||
/**
|
||||
* Specifies the font weight to use when drawing text with this color.
|
||||
* Specifies the font weight to use when drawing text with this color.
|
||||
* This is not applicable when the color is used to draw a character's background.
|
||||
*/
|
||||
FontWeight fontWeight;
|
||||
FontWeight fontWeight;
|
||||
};
|
||||
|
||||
|
||||
@ -148,15 +148,15 @@ class CharacterColor
|
||||
|
||||
public:
|
||||
/** Constructs a new CharacterColor whoose color and color space are undefined. */
|
||||
CharacterColor()
|
||||
: _colorSpace(COLOR_SPACE_UNDEFINED),
|
||||
_u(0),
|
||||
_v(0),
|
||||
_w(0)
|
||||
CharacterColor()
|
||||
: _colorSpace(COLOR_SPACE_UNDEFINED),
|
||||
_u(0),
|
||||
_v(0),
|
||||
_w(0)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Constructs a new CharacterColor using the specified @p colorSpace and with
|
||||
/**
|
||||
* Constructs a new CharacterColor using the specified @p colorSpace and with
|
||||
* color value @p co
|
||||
*
|
||||
* The meaning of @p co depends on the @p colorSpace used.
|
||||
@ -165,10 +165,10 @@ public:
|
||||
*
|
||||
* TODO : Add documentation about available color spaces.
|
||||
*/
|
||||
CharacterColor(quint8 colorSpace, int co)
|
||||
: _colorSpace(colorSpace),
|
||||
_u(0),
|
||||
_v(0),
|
||||
CharacterColor(quint8 colorSpace, int co)
|
||||
: _colorSpace(colorSpace),
|
||||
_u(0),
|
||||
_v(0),
|
||||
_w(0)
|
||||
{
|
||||
switch (colorSpace)
|
||||
@ -180,7 +180,7 @@ public:
|
||||
_u = co & 7;
|
||||
_v = (co >> 3) & 1;
|
||||
break;
|
||||
case COLOR_SPACE_256:
|
||||
case COLOR_SPACE_256:
|
||||
_u = co & 255;
|
||||
break;
|
||||
case COLOR_SPACE_RGB:
|
||||
@ -193,32 +193,32 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns true if this character color entry is valid.
|
||||
*/
|
||||
bool isValid()
|
||||
bool isValid()
|
||||
{
|
||||
return _colorSpace != COLOR_SPACE_UNDEFINED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Toggles the value of this color between a normal system color and the corresponding intensive
|
||||
* system color.
|
||||
*
|
||||
*
|
||||
* This is only applicable if the color is using the COLOR_SPACE_DEFAULT or COLOR_SPACE_SYSTEM
|
||||
* color spaces.
|
||||
*/
|
||||
void toggleIntensive();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the color within the specified color @p palette
|
||||
*
|
||||
* The @p palette is only used if this color is one of the 16 system colors, otherwise
|
||||
* it is ignored.
|
||||
*/
|
||||
QColor color(const ColorEntry* palette) const;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Compares two colors and returns true if they represent the same color value and
|
||||
* use the same color space.
|
||||
*/
|
||||
@ -232,14 +232,14 @@ public:
|
||||
private:
|
||||
quint8 _colorSpace;
|
||||
|
||||
// bytes storing the character color
|
||||
quint8 _u;
|
||||
quint8 _v;
|
||||
quint8 _w;
|
||||
// bytes storing the character color
|
||||
quint8 _u;
|
||||
quint8 _v;
|
||||
quint8 _w;
|
||||
};
|
||||
|
||||
inline bool operator == (const CharacterColor& a, const CharacterColor& b)
|
||||
{
|
||||
{
|
||||
return a._colorSpace == b._colorSpace &&
|
||||
a._u == b._u &&
|
||||
a._v == b._v &&
|
||||
@ -260,7 +260,7 @@ inline const QColor color256(quint8 u, const ColorEntry* base)
|
||||
if (u < 216) return QColor(((u/36)%6) ? (40*((u/36)%6)+55) : 0,
|
||||
((u/ 6)%6) ? (40*((u/ 6)%6)+55) : 0,
|
||||
((u/ 1)%6) ? (40*((u/ 1)%6)+55) : 0); u -= 216;
|
||||
|
||||
|
||||
// 232..255: gray, leaving out black and white
|
||||
int gray = u*10+8; return QColor(gray,gray,gray);
|
||||
}
|
||||
|
@ -163,15 +163,15 @@ void ColorScheme::setColorTableEntry(int index , const ColorEntry& entry)
|
||||
{
|
||||
Q_ASSERT( index >= 0 && index < TABLE_COLORS );
|
||||
|
||||
if ( !_table )
|
||||
if ( !_table )
|
||||
{
|
||||
_table = new ColorEntry[TABLE_COLORS];
|
||||
|
||||
for (int i=0;i<TABLE_COLORS;i++)
|
||||
_table[i] = defaultTable[i];
|
||||
}
|
||||
|
||||
_table[index] = entry;
|
||||
|
||||
_table[index] = entry;
|
||||
}
|
||||
ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const
|
||||
{
|
||||
@ -182,19 +182,19 @@ ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const
|
||||
|
||||
ColorEntry entry = colorTable()[index];
|
||||
|
||||
if ( randomSeed != 0 &&
|
||||
_randomTable != 0 &&
|
||||
if ( randomSeed != 0 &&
|
||||
_randomTable != 0 &&
|
||||
!_randomTable[index].isNull() )
|
||||
{
|
||||
const RandomizationRange& range = _randomTable[index];
|
||||
|
||||
|
||||
|
||||
int hueDifference = range.hue ? (qrand() % range.hue) - range.hue/2 : 0;
|
||||
int saturationDifference = range.saturation ? (qrand() % range.saturation) - range.saturation/2 : 0;
|
||||
int valueDifference = range.value ? (qrand() % range.value) - range.value/2 : 0;
|
||||
|
||||
QColor& color = entry.color;
|
||||
|
||||
|
||||
int newHue = qAbs( (color.hue() + hueDifference) % MAX_HUE );
|
||||
int newValue = qMin( qAbs(color.value() + valueDifference) , 255 );
|
||||
int newSaturation = qMin( qAbs(color.saturation() + saturationDifference) , 255 );
|
||||
@ -215,13 +215,13 @@ bool ColorScheme::randomizedBackgroundColor() const
|
||||
}
|
||||
void ColorScheme::setRandomizedBackgroundColor(bool randomize)
|
||||
{
|
||||
// the hue of the background colour is allowed to be randomly
|
||||
// the hue of the background colour is allowed to be randomly
|
||||
// adjusted as much as possible.
|
||||
//
|
||||
// the value and saturation are left alone to maintain read-ability
|
||||
if ( randomize )
|
||||
{
|
||||
setRandomizationRange( 1 /* background color index */ , MAX_HUE , 255 , 0 );
|
||||
setRandomizationRange( 1 /* background color index */ , MAX_HUE , 255 , 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -304,7 +304,7 @@ void ColorScheme::write(KConfig& config) const
|
||||
|
||||
configGroup.writeEntry("Description",_description);
|
||||
configGroup.writeEntry("Opacity",_opacity);
|
||||
|
||||
|
||||
for (int i=0 ; i < TABLE_COLORS ; i++)
|
||||
{
|
||||
RandomizationRange random = _randomTable != 0 ? _randomTable[i] : RandomizationRange();
|
||||
@ -313,13 +313,13 @@ void ColorScheme::write(KConfig& config) const
|
||||
}
|
||||
#endif
|
||||
|
||||
QString ColorScheme::colorNameForIndex(int index)
|
||||
QString ColorScheme::colorNameForIndex(int index)
|
||||
{
|
||||
Q_ASSERT( index >= 0 && index < TABLE_COLORS );
|
||||
|
||||
return QString(colorNames[index]);
|
||||
}
|
||||
QString ColorScheme::translatedColorNameForIndex(int index)
|
||||
QString ColorScheme::translatedColorNameForIndex(int index)
|
||||
{
|
||||
Q_ASSERT( index >= 0 && index < TABLE_COLORS );
|
||||
|
||||
@ -329,7 +329,7 @@ QString ColorScheme::translatedColorNameForIndex(int index)
|
||||
void ColorScheme::readColorEntry(QSettings * s , int index)
|
||||
{
|
||||
s->beginGroup(colorNameForIndex(index));
|
||||
|
||||
|
||||
ColorEntry entry;
|
||||
|
||||
QStringList rgbList = s->value("Color", QStringList()).toStringList();
|
||||
@ -342,7 +342,7 @@ void ColorScheme::readColorEntry(QSettings * s , int index)
|
||||
g = rgbList[1].toInt();
|
||||
b = rgbList[2].toInt();
|
||||
entry.color = QColor(r, g, b);
|
||||
|
||||
|
||||
entry.transparent = s->value("Transparent",false).toBool();
|
||||
|
||||
// Deprecated key from KDE 4.0 which set 'Bold' to true to force
|
||||
@ -361,7 +361,7 @@ void ColorScheme::readColorEntry(QSettings * s , int index)
|
||||
setColorTableEntry( index , entry );
|
||||
|
||||
if ( hue != 0 || value != 0 || saturation != 0 )
|
||||
setRandomizationRange( index , hue , saturation , value );
|
||||
setRandomizationRange( index , hue , saturation , value );
|
||||
|
||||
s->endGroup();
|
||||
}
|
||||
@ -378,8 +378,8 @@ void ColorScheme::writeColorEntry(KConfig& config , const QString& colorName, co
|
||||
configGroup.writeEntry("Bold",entry.fontWeight == ColorEntry::Bold);
|
||||
}
|
||||
|
||||
// record randomization if this color has randomization or
|
||||
// if one of the keys already exists
|
||||
// record randomization if this color has randomization or
|
||||
// if one of the keys already exists
|
||||
if ( !random.isNull() || configGroup.hasKey("MaxRandomHue") )
|
||||
{
|
||||
configGroup.writeEntry("MaxRandomHue",(int)random.hue);
|
||||
@ -389,28 +389,28 @@ void ColorScheme::writeColorEntry(KConfig& config , const QString& colorName, co
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
//
|
||||
// Work In Progress - A color scheme for use on KDE setups for users
|
||||
// with visual disabilities which means that they may have trouble
|
||||
// reading text with the supplied color schemes.
|
||||
//
|
||||
// This color scheme uses only the 'safe' colors defined by the
|
||||
// KColorScheme class.
|
||||
// KColorScheme class.
|
||||
//
|
||||
// A complication this introduces is that each color provided by
|
||||
// A complication this introduces is that each color provided by
|
||||
// KColorScheme is defined as a 'background' or 'foreground' color.
|
||||
// Only foreground colors are allowed to be used to render text and
|
||||
// Only foreground colors are allowed to be used to render text and
|
||||
// only background colors are allowed to be used for backgrounds.
|
||||
//
|
||||
// The ColorEntry and TerminalDisplay classes do not currently
|
||||
// support this restriction.
|
||||
// support this restriction.
|
||||
//
|
||||
// Requirements:
|
||||
// - A color scheme which uses only colors from the KColorScheme class
|
||||
// - Ability to restrict which colors the TerminalDisplay widget
|
||||
// - Ability to restrict which colors the TerminalDisplay widget
|
||||
// uses as foreground and background color
|
||||
// - Make use of KGlobalSettings::allowDefaultBackgroundImages() as
|
||||
// a hint to determine whether this accessible color scheme should
|
||||
// a hint to determine whether this accessible color scheme should
|
||||
// be used by default.
|
||||
//
|
||||
//
|
||||
@ -443,13 +443,13 @@ AccessibleColorScheme::AccessibleColorScheme()
|
||||
colorScheme.foreground( colorScheme.NeutralText )
|
||||
};
|
||||
|
||||
for ( int i = 0 ; i < TABLE_COLORS ; i++ )
|
||||
for ( int i = 0 ; i < TABLE_COLORS ; i++ )
|
||||
{
|
||||
ColorEntry entry;
|
||||
entry.color = colors[ i % ColorRoleCount ].color();
|
||||
|
||||
setColorTableEntry( i , entry );
|
||||
}
|
||||
setColorTableEntry( i , entry );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -457,7 +457,7 @@ KDE3ColorSchemeReader::KDE3ColorSchemeReader( QIODevice* device ) :
|
||||
_device(device)
|
||||
{
|
||||
}
|
||||
ColorScheme* KDE3ColorSchemeReader::read()
|
||||
ColorScheme* KDE3ColorSchemeReader::read()
|
||||
{
|
||||
Q_ASSERT( _device->openMode() == QIODevice::ReadOnly ||
|
||||
_device->openMode() == QIODevice::ReadWrite );
|
||||
@ -488,7 +488,7 @@ ColorScheme* KDE3ColorSchemeReader::read()
|
||||
{
|
||||
qDebug() << "KDE 3 color scheme contains an unsupported feature, '" <<
|
||||
line << "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return scheme;
|
||||
@ -501,7 +501,7 @@ bool KDE3ColorSchemeReader::readColorLine(const QString& line,ColorScheme* schem
|
||||
return false;
|
||||
if (list.first() != "color")
|
||||
return false;
|
||||
|
||||
|
||||
int index = list[1].toInt();
|
||||
int red = list[2].toInt();
|
||||
int green = list[3].toInt();
|
||||
@ -612,7 +612,7 @@ bool ColorSchemeManager::loadKDE3ColorScheme(const QString& filePath)
|
||||
delete scheme;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QFileInfo info(filePath);
|
||||
|
||||
if ( !_colorSchemes.contains(info.baseName()) )
|
||||
@ -627,7 +627,7 @@ bool ColorSchemeManager::loadKDE3ColorScheme(const QString& filePath)
|
||||
return true;
|
||||
}
|
||||
#if 0
|
||||
void ColorSchemeManager::addColorScheme(ColorScheme* scheme)
|
||||
void ColorSchemeManager::addColorScheme(ColorScheme* scheme)
|
||||
{
|
||||
_colorSchemes.insert(scheme->name(),scheme);
|
||||
|
||||
@ -644,17 +644,17 @@ bool ColorSchemeManager::loadColorScheme(const QString& filePath)
|
||||
return false;
|
||||
|
||||
QFileInfo info(filePath);
|
||||
|
||||
|
||||
ColorScheme* scheme = new ColorScheme();
|
||||
scheme->setName(info.baseName());
|
||||
scheme->read(filePath);
|
||||
|
||||
if (scheme->name().isEmpty())
|
||||
if (scheme->name().isEmpty())
|
||||
{
|
||||
qDebug() << "Color scheme in" << filePath << "does not have a valid name and was not loaded.";
|
||||
delete scheme;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !_colorSchemes.contains(info.baseName()) )
|
||||
{
|
||||
@ -664,11 +664,11 @@ bool ColorSchemeManager::loadColorScheme(const QString& filePath)
|
||||
{
|
||||
qDebug() << "color scheme with name" << scheme->name() << "has already been" <<
|
||||
"found, ignoring.";
|
||||
|
||||
|
||||
delete scheme;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
QList<QString> ColorSchemeManager::listKDE3ColorSchemes()
|
||||
{
|
||||
@ -677,7 +677,7 @@ QList<QString> ColorSchemeManager::listKDE3ColorSchemes()
|
||||
QStringList filters;
|
||||
filters << "*.schema";
|
||||
dir.setNameFilters(filters);
|
||||
QStringList list = dir.entryList(filters);
|
||||
QStringList list = dir.entryList(filters);
|
||||
QStringList ret;
|
||||
foreach(QString i, list)
|
||||
ret << dname + "/" + i;
|
||||
@ -712,7 +712,7 @@ bool ColorSchemeManager::deleteColorScheme(const QString& name)
|
||||
{
|
||||
Q_ASSERT( _colorSchemes.contains(name) );
|
||||
|
||||
// lookup the path and delete
|
||||
// lookup the path and delete
|
||||
QString path = findColorSchemePath(name);
|
||||
if ( QFile::remove(path) )
|
||||
{
|
||||
@ -730,14 +730,14 @@ QString ColorSchemeManager::findColorSchemePath(const QString& name) const
|
||||
// QString path = KStandardDirs::locate("data","konsole/"+name+".colorscheme");
|
||||
QString path(get_color_schemes_dir() + "/"+ name + ".colorscheme");
|
||||
if ( !path.isEmpty() )
|
||||
return path;
|
||||
return path;
|
||||
|
||||
//path = KStandardDirs::locate("data","konsole/"+name+".schema");
|
||||
path = get_color_schemes_dir() + "/"+ name + ".schema";
|
||||
|
||||
return path;
|
||||
}
|
||||
const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
|
||||
const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
|
||||
{
|
||||
if ( name.isEmpty() )
|
||||
return defaultColorScheme();
|
||||
@ -747,12 +747,12 @@ const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
|
||||
else
|
||||
{
|
||||
// look for this color scheme
|
||||
QString path = findColorSchemePath(name);
|
||||
QString path = findColorSchemePath(name);
|
||||
if ( !path.isEmpty() && loadColorScheme(path) )
|
||||
{
|
||||
return findColorScheme(name);
|
||||
}
|
||||
else
|
||||
return findColorScheme(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!path.isEmpty() && loadKDE3ColorScheme(path))
|
||||
return findColorScheme(name);
|
||||
@ -760,7 +760,7 @@ const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
|
||||
|
||||
qDebug() << "Could not find color scheme - " << name;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,16 +38,16 @@ class QIODevice;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a color scheme for a terminal display.
|
||||
* Represents a color scheme for a terminal display.
|
||||
*
|
||||
* The color scheme includes the palette of colors used to draw the text and character backgrounds
|
||||
* in the display and the opacity level of the display background.
|
||||
* in the display and the opacity level of the display background.
|
||||
*/
|
||||
class ColorScheme
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructs a new color scheme which is initialised to the default color set
|
||||
/**
|
||||
* Constructs a new color scheme which is initialised to the default color set
|
||||
* for Konsole.
|
||||
*/
|
||||
ColorScheme();
|
||||
@ -76,7 +76,7 @@ public:
|
||||
/** Sets a single entry within the color palette. */
|
||||
void setColorTableEntry(int index , const ColorEntry& entry);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Copies the color entries which form the palette for this color scheme
|
||||
* into @p table. @p table should be an array with TABLE_COLORS entries.
|
||||
*
|
||||
@ -86,7 +86,7 @@ public:
|
||||
* palette to be randomized. The seed is used to pick the random color.
|
||||
*/
|
||||
void getColorTable(ColorEntry* table, uint randomSeed = 0) const;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves a single color entry from the table.
|
||||
*
|
||||
@ -94,28 +94,28 @@ public:
|
||||
*/
|
||||
ColorEntry colorEntry(int index , uint randomSeed = 0) const;
|
||||
|
||||
/**
|
||||
* Convenience method. Returns the
|
||||
* foreground color for this scheme,
|
||||
* this is the primary color used to draw the
|
||||
/**
|
||||
* Convenience method. Returns the
|
||||
* foreground color for this scheme,
|
||||
* this is the primary color used to draw the
|
||||
* text in this scheme.
|
||||
*/
|
||||
QColor foregroundColor() const;
|
||||
/**
|
||||
* Convenience method. Returns the background color for
|
||||
* this scheme, this is the primary color used to
|
||||
* Convenience method. Returns the background color for
|
||||
* this scheme, this is the primary color used to
|
||||
* draw the terminal background in this scheme.
|
||||
*/
|
||||
QColor backgroundColor() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns true if this color scheme has a dark background.
|
||||
* The background color is said to be dark if it has a value of less than 127
|
||||
* in the HSV color space.
|
||||
*/
|
||||
bool hasDarkBackground() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the opacity level of the display background. @p opacity ranges
|
||||
* between 0 (completely transparent background) and 1 (completely
|
||||
* opaque background).
|
||||
@ -125,18 +125,18 @@ public:
|
||||
* TODO: More documentation
|
||||
*/
|
||||
void setOpacity(qreal opacity);
|
||||
/**
|
||||
/**
|
||||
* Returns the opacity level for this color scheme, see setOpacity()
|
||||
* TODO: More documentation
|
||||
*/
|
||||
qreal opacity() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Enables randomization of the background color. This will cause
|
||||
* the palette returned by getColorTable() and colorEntry() to
|
||||
* be adjusted depending on the value of the random seed argument
|
||||
* to them.
|
||||
*/
|
||||
*/
|
||||
void setRandomizedBackgroundColor(bool randomize);
|
||||
|
||||
/** Returns true if the background color is randomized. */
|
||||
@ -152,7 +152,7 @@ private:
|
||||
public:
|
||||
RandomizationRange() : hue(0) , saturation(0) , value(0) {}
|
||||
|
||||
bool isNull() const
|
||||
bool isNull() const
|
||||
{
|
||||
return ( hue == 0 && saturation == 0 && value == 0 );
|
||||
}
|
||||
@ -170,14 +170,14 @@ private:
|
||||
// implemented upstream - user apps
|
||||
// reads a single colour entry from a KConfig source
|
||||
// and sets the palette entry at 'index' to the entry read.
|
||||
void readColorEntry(KConfig& config , int index);
|
||||
void readColorEntry(KConfig& config , int index);
|
||||
// writes a single colour entry to a KConfig source
|
||||
void writeColorEntry(KConfig& config , const QString& colorName, const ColorEntry& entry,const RandomizationRange& range) const;
|
||||
#endif
|
||||
void readColorEntry(QSettings *s, int index);
|
||||
|
||||
// sets the amount of randomization allowed for a particular color
|
||||
// in the palette. creates the randomization table if
|
||||
// sets the amount of randomization allowed for a particular color
|
||||
// in the palette. creates the randomization table if
|
||||
// it does not already exist
|
||||
void setRandomizationRange( int index , quint16 hue , quint8 saturation , quint8 value );
|
||||
|
||||
@ -200,7 +200,7 @@ private:
|
||||
static const ColorEntry defaultTable[]; // table of default color entries
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* A color scheme which uses colors from the standard KDE color palette.
|
||||
*
|
||||
* This is designed primarily for the benefit of users who are using specially
|
||||
@ -226,13 +226,13 @@ public:
|
||||
class KDE3ColorSchemeReader
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructs a new reader which reads from the specified device.
|
||||
* The device should be open in read-only mode.
|
||||
/**
|
||||
* Constructs a new reader which reads from the specified device.
|
||||
* The device should be open in read-only mode.
|
||||
*/
|
||||
KDE3ColorSchemeReader( QIODevice* device );
|
||||
|
||||
/**
|
||||
/**
|
||||
* Reads and parses the contents of the .schema file from the input
|
||||
* device and returns the ColorScheme defined within it.
|
||||
*
|
||||
@ -275,7 +275,7 @@ public:
|
||||
* Returns the default color scheme for Konsole
|
||||
*/
|
||||
const ColorScheme* defaultColorScheme() const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the color scheme with the given name or 0 if no
|
||||
* scheme with that name exists. If @p name is empty, the
|
||||
@ -296,18 +296,18 @@ public:
|
||||
void addColorScheme(ColorScheme* scheme);
|
||||
#endif
|
||||
/**
|
||||
* Deletes a color scheme. Returns true on successful deletion or false otherwise.
|
||||
* Deletes a color scheme. Returns true on successful deletion or false otherwise.
|
||||
*/
|
||||
bool deleteColorScheme(const QString& name);
|
||||
|
||||
/**
|
||||
* Returns a list of the all the available color schemes.
|
||||
/**
|
||||
* Returns a list of the all the available color schemes.
|
||||
* This may be slow when first called because all of the color
|
||||
* scheme resources on disk must be located, read and parsed.
|
||||
*
|
||||
* Subsequent calls will be inexpensive.
|
||||
* Subsequent calls will be inexpensive.
|
||||
*/
|
||||
QList<const ColorScheme*> allColorSchemes();
|
||||
QList<const ColorScheme*> allColorSchemes();
|
||||
|
||||
/** Returns the global color scheme manager instance. */
|
||||
static ColorSchemeManager* instance();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2007-2008 Robert Knight <robertknight@gmail.com>
|
||||
Copyright 2007-2008 Robert Knight <robertknight@gmail.com>
|
||||
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||
Copyright 1996 by Matthias Ettrich <ettrich@kde.org>
|
||||
|
||||
@ -62,7 +62,7 @@ Emulation::Emulation() :
|
||||
|
||||
QObject::connect(&_bulkTimer1, SIGNAL(timeout()), this, SLOT(showBulk()) );
|
||||
QObject::connect(&_bulkTimer2, SIGNAL(timeout()), this, SLOT(showBulk()) );
|
||||
|
||||
|
||||
// listen for mouse status changes
|
||||
connect( this , SIGNAL(programUsesMouseChanged(bool)) ,
|
||||
SLOT(usesMouseChanged(bool)) );
|
||||
@ -110,7 +110,7 @@ void Emulation::setScreen(int n)
|
||||
{
|
||||
Screen *old = _currentScreen;
|
||||
_currentScreen = _screen[n & 1];
|
||||
if (_currentScreen != old)
|
||||
if (_currentScreen != old)
|
||||
{
|
||||
// tell all windows onto this emulation to switch to the newly active screen
|
||||
foreach(ScreenWindow* window,_windows)
|
||||
@ -189,7 +189,7 @@ void Emulation::receiveChar(int c)
|
||||
void Emulation::sendKeyEvent( QKeyEvent* ev )
|
||||
{
|
||||
emit stateSet(NOTIFYNORMAL);
|
||||
|
||||
|
||||
if (!ev->text().isEmpty())
|
||||
{ // A block of text
|
||||
// Note that the text is proper unicode.
|
||||
@ -218,7 +218,7 @@ void Emulation::receiveData(const char* text, int length)
|
||||
emit stateSet(NOTIFYACTIVITY);
|
||||
|
||||
bufferedUpdate();
|
||||
|
||||
|
||||
QString unicodeText = _decoder->toUnicode(text,length);
|
||||
|
||||
//send characters to terminal emulator
|
||||
@ -246,13 +246,13 @@ void Emulation::receiveData(const char* text, int length)
|
||||
//
|
||||
//There is something about stopping the _decoder if "we get a control code halfway a multi-byte sequence" (see below)
|
||||
//which hasn't been ported into the newer function (above). Hopefully someone who understands this better
|
||||
//can find an alternative way of handling the check.
|
||||
//can find an alternative way of handling the check.
|
||||
|
||||
|
||||
/*void Emulation::onRcvBlock(const char *s, int len)
|
||||
{
|
||||
emit notifySessionState(NOTIFYACTIVITY);
|
||||
|
||||
|
||||
bufferedUpdate();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
@ -287,9 +287,9 @@ void Emulation::receiveData(const char* text, int length)
|
||||
}
|
||||
}*/
|
||||
|
||||
void Emulation::writeToStream( TerminalCharacterDecoder* _decoder ,
|
||||
void Emulation::writeToStream( TerminalCharacterDecoder* _decoder ,
|
||||
int startLine ,
|
||||
int endLine)
|
||||
int endLine)
|
||||
{
|
||||
_currentScreen->writeLinesToStream(_decoder,startLine,endLine);
|
||||
}
|
||||
@ -332,7 +332,7 @@ char Emulation::eraseChar() const
|
||||
|
||||
void Emulation::setImageSize(int lines, int columns)
|
||||
{
|
||||
if ((lines < 1) || (columns < 1))
|
||||
if ((lines < 1) || (columns < 1))
|
||||
return;
|
||||
|
||||
QSize screenSize[2] = { QSize(_screen[0]->getColumns(),
|
||||
@ -342,7 +342,7 @@ void Emulation::setImageSize(int lines, int columns)
|
||||
QSize newSize(columns,lines);
|
||||
|
||||
if (newSize == screenSize[0] && newSize == screenSize[1])
|
||||
return;
|
||||
return;
|
||||
|
||||
_screen[0]->resizeImage(lines,columns);
|
||||
_screen[1]->resizeImage(lines,columns);
|
||||
@ -370,17 +370,17 @@ bool ExtendedCharTable::extendedCharMatch(ushort hash , ushort* unicodePoints ,
|
||||
{
|
||||
ushort* entry = extendedCharTable[hash];
|
||||
|
||||
// compare given length with stored sequence length ( given as the first ushort in the
|
||||
// stored buffer )
|
||||
if ( entry == 0 || entry[0] != length )
|
||||
// compare given length with stored sequence length ( given as the first ushort in the
|
||||
// stored buffer )
|
||||
if ( entry == 0 || entry[0] != length )
|
||||
return false;
|
||||
// if the lengths match, each character must be checked. the stored buffer starts at
|
||||
// entry[1]
|
||||
for ( int i = 0 ; i < length ; i++ )
|
||||
{
|
||||
if ( entry[i+1] != unicodePoints[i] )
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
ushort ExtendedCharTable::createExtendedChar(ushort* unicodePoints , ushort length)
|
||||
@ -393,7 +393,7 @@ ushort ExtendedCharTable::createExtendedChar(ushort* unicodePoints , ushort leng
|
||||
{
|
||||
if ( extendedCharMatch(hash,unicodePoints,length) )
|
||||
{
|
||||
// this sequence already has an entry in the table,
|
||||
// this sequence already has an entry in the table,
|
||||
// return its hash
|
||||
return hash;
|
||||
}
|
||||
@ -403,16 +403,16 @@ ushort ExtendedCharTable::createExtendedChar(ushort* unicodePoints , ushort leng
|
||||
// points then try next hash
|
||||
hash++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// add the new sequence to the table and
|
||||
// return that index
|
||||
ushort* buffer = new ushort[length+1];
|
||||
buffer[0] = length;
|
||||
for ( int i = 0 ; i < length ; i++ )
|
||||
buffer[i+1] = unicodePoints[i];
|
||||
|
||||
buffer[i+1] = unicodePoints[i];
|
||||
|
||||
extendedCharTable.insert(hash,buffer);
|
||||
|
||||
return hash;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of Konsole, an X terminal.
|
||||
|
||||
|
||||
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
|
||||
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
// System
|
||||
#include <stdio.h>
|
||||
|
||||
// Qt
|
||||
// Qt
|
||||
#include <QtGui/QKeyEvent>
|
||||
//#include <QPointer>
|
||||
#include <QtCore/QTextCodec>
|
||||
@ -43,56 +43,56 @@ class Screen;
|
||||
class ScreenWindow;
|
||||
class TerminalCharacterDecoder;
|
||||
|
||||
/**
|
||||
* This enum describes the available states which
|
||||
/**
|
||||
* This enum describes the available states which
|
||||
* the terminal emulation may be set to.
|
||||
*
|
||||
* These are the values used by Emulation::stateChanged()
|
||||
* These are the values used by Emulation::stateChanged()
|
||||
*/
|
||||
enum
|
||||
{
|
||||
enum
|
||||
{
|
||||
/** The emulation is currently receiving user input. */
|
||||
NOTIFYNORMAL=0,
|
||||
/**
|
||||
NOTIFYNORMAL=0,
|
||||
/**
|
||||
* The terminal program has triggered a bell event
|
||||
* to get the user's attention.
|
||||
*/
|
||||
NOTIFYBELL=1,
|
||||
/**
|
||||
* The emulation is currently receiving data from its
|
||||
NOTIFYBELL=1,
|
||||
/**
|
||||
* The emulation is currently receiving data from its
|
||||
* terminal input.
|
||||
*/
|
||||
NOTIFYACTIVITY=2,
|
||||
|
||||
// unused here?
|
||||
NOTIFYSILENCE=3
|
||||
// unused here?
|
||||
NOTIFYSILENCE=3
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for terminal emulation back-ends.
|
||||
*
|
||||
* The back-end is responsible for decoding an incoming character stream and
|
||||
* The back-end is responsible for decoding an incoming character stream and
|
||||
* producing an output image of characters.
|
||||
*
|
||||
* When input from the terminal is received, the receiveData() slot should be called with
|
||||
* the data which has arrived. The emulation will process the data and update the
|
||||
* the data which has arrived. The emulation will process the data and update the
|
||||
* screen image accordingly. The codec used to decode the incoming character stream
|
||||
* into the unicode characters used internally can be specified using setCodec()
|
||||
* into the unicode characters used internally can be specified using setCodec()
|
||||
*
|
||||
* The size of the screen image can be specified by calling setImageSize() with the
|
||||
* The size of the screen image can be specified by calling setImageSize() with the
|
||||
* desired number of lines and columns. When new lines are added, old content
|
||||
* is moved into a history store, which can be set by calling setHistory().
|
||||
* is moved into a history store, which can be set by calling setHistory().
|
||||
*
|
||||
* The screen image can be accessed by creating a ScreenWindow onto this emulation
|
||||
* by calling createWindow(). Screen windows provide access to a section of the
|
||||
* output. Each screen window covers the same number of lines and columns as the
|
||||
* The screen image can be accessed by creating a ScreenWindow onto this emulation
|
||||
* by calling createWindow(). Screen windows provide access to a section of the
|
||||
* output. Each screen window covers the same number of lines and columns as the
|
||||
* image size returned by imageSize(). The screen window can be moved up and down
|
||||
* and provides transparent access to both the current on-screen image and the
|
||||
* and provides transparent access to both the current on-screen image and the
|
||||
* previous output. The screen windows emit an outputChanged signal
|
||||
* when the section of the image they are looking at changes.
|
||||
* Graphical views can then render the contents of a screen window, listening for notifications
|
||||
* of output changes from the screen window which they are associated with and updating
|
||||
* accordingly.
|
||||
* of output changes from the screen window which they are associated with and updating
|
||||
* accordingly.
|
||||
*
|
||||
* The emulation also is also responsible for converting input from the connected views such
|
||||
* as keypresses and mouse activity into a character string which can be sent
|
||||
@ -105,9 +105,9 @@ enum
|
||||
* character sequences. The name of the key bindings set used can be specified using
|
||||
* setKeyBindings()
|
||||
*
|
||||
* The emulation maintains certain state information which changes depending on the
|
||||
* input received. The emulation can be reset back to its starting state by calling
|
||||
* reset().
|
||||
* The emulation maintains certain state information which changes depending on the
|
||||
* input received. The emulation can be reset back to its starting state by calling
|
||||
* reset().
|
||||
*
|
||||
* The emulation also maintains an activity state, which specifies whether
|
||||
* terminal is currently active ( when data is received ), normal
|
||||
@ -118,12 +118,12 @@ enum
|
||||
* a 'bell' event in different ways.
|
||||
*/
|
||||
class KONSOLEPRIVATE_EXPORT Emulation : public QObject
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/** Constructs a new terminal emulation */
|
||||
|
||||
/** Constructs a new terminal emulation */
|
||||
Emulation();
|
||||
~Emulation();
|
||||
|
||||
@ -139,15 +139,15 @@ public:
|
||||
|
||||
/**
|
||||
* Returns the total number of lines, including those stored in the history.
|
||||
*/
|
||||
*/
|
||||
int lineCount() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the history store used by this emulation. When new lines
|
||||
* are added to the output, older lines at the top of the screen are transferred to a history
|
||||
* store.
|
||||
* store.
|
||||
*
|
||||
* The number of lines which are kept and the storage location depend on the
|
||||
* The number of lines which are kept and the storage location depend on the
|
||||
* type of store.
|
||||
*/
|
||||
void setHistory(const HistoryType&);
|
||||
@ -156,49 +156,49 @@ public:
|
||||
/** Clears the history scroll. */
|
||||
void clearHistory();
|
||||
|
||||
/**
|
||||
* Copies the output history from @p startLine to @p endLine
|
||||
/**
|
||||
* Copies the output history from @p startLine to @p endLine
|
||||
* into @p stream, using @p decoder to convert the terminal
|
||||
* characters into text.
|
||||
* characters into text.
|
||||
*
|
||||
* @param decoder A decoder which converts lines of terminal characters with
|
||||
* @param decoder A decoder which converts lines of terminal characters with
|
||||
* appearance attributes into output text. PlainTextDecoder is the most commonly
|
||||
* used decoder.
|
||||
* @param startLine Index of first line to copy
|
||||
* @param endLine Index of last line to copy
|
||||
*/
|
||||
virtual void writeToStream(TerminalCharacterDecoder* decoder,int startLine,int endLine);
|
||||
|
||||
|
||||
/** Returns the codec used to decode incoming characters. See setCodec() */
|
||||
const QTextCodec* codec() const { return _codec; }
|
||||
/** Sets the codec used to decode incoming characters. */
|
||||
void setCodec(const QTextCodec*);
|
||||
|
||||
/**
|
||||
* Convenience method.
|
||||
/**
|
||||
* Convenience method.
|
||||
* Returns true if the current codec used to decode incoming
|
||||
* characters is UTF-8
|
||||
*/
|
||||
bool utf8() const
|
||||
{ Q_ASSERT(_codec); return _codec->mibEnum() == 106; }
|
||||
|
||||
|
||||
|
||||
/** TODO Document me */
|
||||
virtual char eraseChar() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the key bindings used to key events
|
||||
* ( received through sendKeyEvent() ) into character
|
||||
* streams to send to the terminal.
|
||||
*/
|
||||
void setKeyBindings(const QString& name);
|
||||
/**
|
||||
/**
|
||||
* Returns the name of the emulation's current key bindings.
|
||||
* See setKeyBindings()
|
||||
*/
|
||||
QString keyBindings() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Copies the current image into the history and clears the screen.
|
||||
*/
|
||||
virtual void clearEntireScreen() =0;
|
||||
@ -206,7 +206,7 @@ public:
|
||||
/** Resets the state of the terminal. */
|
||||
virtual void reset() =0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns true if the active terminal program wants
|
||||
* mouse input events.
|
||||
*
|
||||
@ -215,42 +215,42 @@ public:
|
||||
*/
|
||||
bool programUsesMouse() const;
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
|
||||
/** Change the size of the emulation's image */
|
||||
virtual void setImageSize(int lines, int columns);
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Interprets a sequence of characters and sends the result to the terminal.
|
||||
* This is equivalent to calling sendKeyEvent() for each character in @p text in succession.
|
||||
*/
|
||||
virtual void sendText(const QString& text) = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Interprets a key press event and emits the sendData() signal with
|
||||
* the resulting character stream.
|
||||
* the resulting character stream.
|
||||
*/
|
||||
virtual void sendKeyEvent(QKeyEvent*);
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Converts information about a mouse event into an xterm-compatible escape
|
||||
* sequence and emits the character sequence via sendData()
|
||||
*/
|
||||
virtual void sendMouseEvent(int buttons, int column, int line, int eventType);
|
||||
|
||||
|
||||
/**
|
||||
* Sends a string of characters to the foreground terminal process.
|
||||
* Sends a string of characters to the foreground terminal process.
|
||||
*
|
||||
* @param string The characters to send.
|
||||
* @param string The characters to send.
|
||||
* @param length Length of @p string or if set to a negative value, @p string will
|
||||
* be treated as a null-terminated string and its length will be determined automatically.
|
||||
*/
|
||||
virtual void sendString(const char* string, int length = -1) = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Processes an incoming stream of characters. receiveData() decodes the incoming
|
||||
* character buffer using the current codec(), and then calls receiveChar() for
|
||||
* each unicode character in the resulting buffer.
|
||||
* each unicode character in the resulting buffer.
|
||||
*
|
||||
* receiveData() also starts a timer which causes the outputChanged() signal
|
||||
* to be emitted when it expires. The timer allows multiple updates in quick
|
||||
@ -263,8 +263,8 @@ public slots:
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
* Emitted when a buffer of data is ready to send to the
|
||||
/**
|
||||
* Emitted when a buffer of data is ready to send to the
|
||||
* standard input of the terminal.
|
||||
*
|
||||
* @param data The buffer of data ready to be sent
|
||||
@ -272,20 +272,20 @@ signals:
|
||||
*/
|
||||
void sendData(const char* data,int len);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Requests that sending of input to the emulation
|
||||
* from the terminal process be suspended or resumed.
|
||||
*
|
||||
* @param suspend If true, requests that sending of
|
||||
* input from the terminal process' stdout be
|
||||
* @param suspend If true, requests that sending of
|
||||
* input from the terminal process' stdout be
|
||||
* suspended. Otherwise requests that sending of
|
||||
* input be resumed.
|
||||
* input be resumed.
|
||||
*/
|
||||
void lockPtyRequest(bool suspend);
|
||||
|
||||
/**
|
||||
* Requests that the pty used by the terminal process
|
||||
* be set to UTF 8 mode.
|
||||
* be set to UTF 8 mode.
|
||||
*
|
||||
* TODO: More documentation
|
||||
*/
|
||||
@ -313,7 +313,7 @@ signals:
|
||||
*/
|
||||
void changeTabTextColorRequest(int color);
|
||||
|
||||
/**
|
||||
/**
|
||||
* This is emitted when the program running in the shell indicates whether or
|
||||
* not it is interested in mouse events.
|
||||
*
|
||||
@ -322,7 +322,7 @@ signals:
|
||||
*/
|
||||
void programUsesMouseChanged(bool usesMouse);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Emitted when the contents of the screen image change.
|
||||
* The emulation buffers the updates from successive image changes,
|
||||
* and only emits outputChanged() at sensible intervals when
|
||||
@ -332,14 +332,14 @@ signals:
|
||||
* created with createWindow() to listen for this signal.
|
||||
*
|
||||
* ScreenWindow objects created using createWindow() will emit their
|
||||
* own outputChanged() signal in response to this signal.
|
||||
* own outputChanged() signal in response to this signal.
|
||||
*/
|
||||
void outputChanged();
|
||||
|
||||
/**
|
||||
* Emitted when the program running in the terminal wishes to update the
|
||||
* Emitted when the program running in the terminal wishes to update the
|
||||
* session's title. This also allows terminal programs to customize other
|
||||
* aspects of the terminal emulation display.
|
||||
* aspects of the terminal emulation display.
|
||||
*
|
||||
* This signal is emitted when the escape sequence "\033]ARG;VALUE\007"
|
||||
* is received in the input string, where ARG is a number specifying what
|
||||
@ -347,7 +347,7 @@ signals:
|
||||
*
|
||||
* TODO: The name of this method is not very accurate since this method
|
||||
* is used to perform a whole range of tasks besides just setting
|
||||
* the user-title of the session.
|
||||
* the user-title of the session.
|
||||
*
|
||||
* @param title Specifies what to change.
|
||||
* <ul>
|
||||
@ -356,16 +356,16 @@ signals:
|
||||
* <li>2 - Set session title to @p newTitle</li>
|
||||
* <li>11 - Set the session's default background color to @p newTitle,
|
||||
* where @p newTitle can be an HTML-style string ("#RRGGBB") or a named
|
||||
* color (eg 'red', 'blue').
|
||||
* color (eg 'red', 'blue').
|
||||
* See http://doc.trolltech.com/4.2/qcolor.html#setNamedColor for more
|
||||
* details.
|
||||
* </li>
|
||||
* <li>31 - Supposedly treats @p newTitle as a URL and opens it (NOT IMPLEMENTED)</li>
|
||||
* <li>32 - Sets the icon associated with the session. @p newTitle is the name
|
||||
* <li>32 - Sets the icon associated with the session. @p newTitle is the name
|
||||
* of the icon to use, which can be the name of any icon in the current KDE icon
|
||||
* theme (eg: 'konsole', 'kate', 'folder_home')</li>
|
||||
* </ul>
|
||||
* @param newTitle Specifies the new title
|
||||
* @param newTitle Specifies the new title
|
||||
*/
|
||||
|
||||
void titleChanged(int title,const QString& newTitle);
|
||||
@ -376,9 +376,9 @@ signals:
|
||||
*/
|
||||
void imageSizeChanged(int lineCount , int columnCount);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Emitted when the terminal program requests to change various properties
|
||||
* of the terminal display.
|
||||
* of the terminal display.
|
||||
*
|
||||
* A profile change command occurs when a special escape sequence, followed
|
||||
* by a string containing a series of name and value pairs is received.
|
||||
@ -389,7 +389,7 @@ signals:
|
||||
*/
|
||||
void profileChangeCommandReceived(const QString& text);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Emitted when a flow control key combination ( Ctrl+S or Ctrl+Q ) is pressed.
|
||||
* @param suspendKeyPressed True if Ctrl+S was pressed to suspend output or Ctrl+Q to
|
||||
* resume output.
|
||||
@ -399,21 +399,21 @@ signals:
|
||||
protected:
|
||||
virtual void setMode(int mode) = 0;
|
||||
virtual void resetMode(int mode) = 0;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Processes an incoming character. See receiveData()
|
||||
* @p ch A unicode character code.
|
||||
* @p ch A unicode character code.
|
||||
*/
|
||||
virtual void receiveChar(int ch);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the active screen. The terminal has two screens, primary and alternate.
|
||||
* The primary screen is used by default. When certain interactive programs such
|
||||
* as Vim are run, they trigger a switch to the alternate screen.
|
||||
*
|
||||
* @param index 0 to switch to the primary screen, or 1 to switch to the alternate screen
|
||||
*/
|
||||
void setScreen(int index);
|
||||
void setScreen(int index);
|
||||
|
||||
enum EmulationCodec
|
||||
{
|
||||
@ -424,35 +424,35 @@ protected:
|
||||
|
||||
|
||||
QList<ScreenWindow*> _windows;
|
||||
|
||||
Screen* _currentScreen; // pointer to the screen which is currently active,
|
||||
|
||||
Screen* _currentScreen; // pointer to the screen which is currently active,
|
||||
// this is one of the elements in the screen[] array
|
||||
|
||||
Screen* _screen[2]; // 0 = primary screen ( used by most programs, including the shell
|
||||
// scrollbars are enabled in this mode )
|
||||
// 1 = alternate ( used by vi , emacs etc.
|
||||
// scrollbars are not enabled in this mode )
|
||||
|
||||
|
||||
//decodes an incoming C-style character stream into a unicode QString using
|
||||
|
||||
|
||||
//decodes an incoming C-style character stream into a unicode QString using
|
||||
//the current text codec. (this allows for rendering of non-ASCII characters in text files etc.)
|
||||
const QTextCodec* _codec;
|
||||
QTextDecoder* _decoder;
|
||||
const KeyboardTranslator* _keyTranslator; // the keyboard layout
|
||||
|
||||
protected slots:
|
||||
/**
|
||||
/**
|
||||
* Schedules an update of attached views.
|
||||
* Repeated calls to bufferedUpdate() in close succession will result in only a single update,
|
||||
* much like the Qt buffered update of widgets.
|
||||
* much like the Qt buffered update of widgets.
|
||||
*/
|
||||
void bufferedUpdate();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
|
||||
// triggered by timer, causes the emulation to send an updated screen image to each
|
||||
// view
|
||||
void showBulk();
|
||||
void showBulk();
|
||||
|
||||
void usesMouseChanged(bool usesMouse);
|
||||
|
||||
@ -460,7 +460,7 @@ private:
|
||||
bool _usesMouse;
|
||||
QTimer _bulkTimer1;
|
||||
QTimer _bulkTimer2;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
||||
FilterChain::~FilterChain()
|
||||
{
|
||||
QMutableListIterator<Filter*> iter(*this);
|
||||
|
||||
|
||||
while ( iter.hasNext() )
|
||||
{
|
||||
Filter* filter = iter.next();
|
||||
@ -140,7 +140,7 @@ void TerminalImageFilterChain::setImage(const Character* const image , int lines
|
||||
|
||||
PlainTextDecoder decoder;
|
||||
decoder.setTrailingWhitespace(false);
|
||||
|
||||
|
||||
// setup new shared buffers for the filters to process on
|
||||
QString* newBuffer = new QString();
|
||||
QList<int>* newLinePositions = new QList<int>();
|
||||
@ -166,7 +166,7 @@ void TerminalImageFilterChain::setImage(const Character* const image , int lines
|
||||
// being treated as part of a link that occurs at the start of the next line
|
||||
//
|
||||
// the downside is that links which are spread over more than one line are not
|
||||
// highlighted.
|
||||
// highlighted.
|
||||
//
|
||||
// TODO - Use the "line wrapped" attribute associated with lines in a
|
||||
// terminal image to avoid adding this imaginary character for wrapped
|
||||
@ -218,7 +218,7 @@ void Filter::getLineColumn(int position , int& startLine , int& startColumn)
|
||||
else
|
||||
nextLine = _linePositions->value(i+1);
|
||||
|
||||
if ( _linePositions->value(i) <= position && position < nextLine )
|
||||
if ( _linePositions->value(i) <= position && position < nextLine )
|
||||
{
|
||||
startLine = i;
|
||||
startColumn = string_width(buffer()->mid(_linePositions->value(i),position - _linePositions->value(i)));
|
||||
@ -226,7 +226,7 @@ void Filter::getLineColumn(int position , int& startLine , int& startColumn)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*void Filter::addLine(const QString& text)
|
||||
{
|
||||
@ -248,7 +248,7 @@ void Filter::addHotSpot(HotSpot* spot)
|
||||
for (int line = spot->startLine() ; line <= spot->endLine() ; line++)
|
||||
{
|
||||
_hotspots.insert(line,spot);
|
||||
}
|
||||
}
|
||||
}
|
||||
QList<Filter::HotSpot*> Filter::hotSpots() const
|
||||
{
|
||||
@ -266,12 +266,12 @@ Filter::HotSpot* Filter::hotSpotAt(int line , int column) const
|
||||
while (spotIter.hasNext())
|
||||
{
|
||||
HotSpot* spot = spotIter.next();
|
||||
|
||||
|
||||
if ( spot->startLine() == line && spot->startColumn() > column )
|
||||
continue;
|
||||
if ( spot->endLine() == line && spot->endColumn() < column )
|
||||
continue;
|
||||
|
||||
|
||||
return spot;
|
||||
}
|
||||
|
||||
@ -342,7 +342,7 @@ QStringList RegExpFilter::HotSpot::capturedTexts() const
|
||||
return _capturedTexts;
|
||||
}
|
||||
|
||||
void RegExpFilter::setRegExp(const QRegExp& regExp)
|
||||
void RegExpFilter::setRegExp(const QRegExp& regExp)
|
||||
{
|
||||
_searchText = regExp;
|
||||
}
|
||||
@ -385,14 +385,14 @@ void RegExpFilter::process()
|
||||
endLine,endColumn);
|
||||
spot->setCapturedTexts(_searchText.capturedTexts());
|
||||
|
||||
addHotSpot( spot );
|
||||
addHotSpot( spot );
|
||||
pos += _searchText.matchedLength();
|
||||
|
||||
// if matchedLength == 0, the program will get stuck in an infinite loop
|
||||
if ( _searchText.matchedLength() == 0 )
|
||||
pos = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RegExpFilter::HotSpot* RegExpFilter::newHotSpot(int startLine,int startColumn,
|
||||
@ -420,16 +420,16 @@ QString UrlFilter::HotSpot::tooltip() const
|
||||
const UrlType kind = urlType();
|
||||
|
||||
if ( kind == StandardUrl )
|
||||
return QString();
|
||||
return QString();
|
||||
else if ( kind == Email )
|
||||
return QString();
|
||||
return QString();
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
UrlFilter::HotSpot::UrlType UrlFilter::HotSpot::urlType() const
|
||||
{
|
||||
QString url = capturedTexts().first();
|
||||
|
||||
|
||||
if ( FullUrlRegExp.exactMatch(url) )
|
||||
return StandardUrl;
|
||||
else if ( EmailAddressRegExp.exactMatch(url) )
|
||||
@ -462,24 +462,24 @@ void UrlFilter::HotSpot::activate(QObject* object)
|
||||
{
|
||||
url.prepend("http://");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( kind == Email )
|
||||
{
|
||||
url.prepend("mailto:");
|
||||
}
|
||||
|
||||
|
||||
QDesktopServices::openUrl(QUrl(url));
|
||||
//new KRun(url,QApplication::activeWindow());
|
||||
}
|
||||
}
|
||||
|
||||
// Note: Altering these regular expressions can have a major effect on the performance of the filters
|
||||
// Note: Altering these regular expressions can have a major effect on the performance of the filters
|
||||
// used for finding URLs in the text, especially if they are very general and could match very long
|
||||
// pieces of text.
|
||||
// Please be careful when altering them.
|
||||
|
||||
//regexp matches:
|
||||
// full url:
|
||||
// full url:
|
||||
// protocolname:// or www. followed by anything other than whitespaces, <, >, ' or ", and ends before whitespaces, <, >, ', ", ], !, comma and dot
|
||||
const QRegExp UrlFilter::FullUrlRegExp("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]]");
|
||||
// email address:
|
||||
@ -536,7 +536,7 @@ QList<QAction*> UrlFilter::HotSpot::actions()
|
||||
list << openAction;
|
||||
list << copyAction;
|
||||
|
||||
return list;
|
||||
return list;
|
||||
}
|
||||
|
||||
//#include "Filter.moc"
|
||||
|
@ -42,7 +42,7 @@
|
||||
* activate() method should be called. Depending on the type of hotspot this will trigger a suitable response.
|
||||
*
|
||||
* For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser.
|
||||
* Hotspots may have more than one action, in which case the list of actions can be obtained using the
|
||||
* Hotspots may have more than one action, in which case the list of actions can be obtained using the
|
||||
* actions() method.
|
||||
*
|
||||
* Different subclasses of filter will return different types of hotspot.
|
||||
@ -62,13 +62,13 @@ public:
|
||||
* activate() method should be called. Depending on the type of hotspot this will trigger a suitable response.
|
||||
*
|
||||
* For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser.
|
||||
* Hotspots may have more than one action, in which case the list of actions can be obtained using the
|
||||
* actions() method. These actions may then be displayed in a popup menu or toolbar for example.
|
||||
* Hotspots may have more than one action, in which case the list of actions can be obtained using the
|
||||
* actions() method. These actions may then be displayed in a popup menu or toolbar for example.
|
||||
*/
|
||||
class HotSpot
|
||||
{
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* Constructs a new hotspot which covers the area from (@p startLine,@p startColumn) to (@p endLine,@p endColumn)
|
||||
* in a block of text.
|
||||
*/
|
||||
@ -83,7 +83,7 @@ public:
|
||||
Link,
|
||||
// this hotspot represents a marker
|
||||
Marker
|
||||
};
|
||||
};
|
||||
|
||||
/** Returns the line when the hotspot area starts */
|
||||
int startLine() const;
|
||||
@ -93,31 +93,31 @@ public:
|
||||
int startColumn() const;
|
||||
/** Returns the column on endLine() where the hotspot area ends */
|
||||
int endColumn() const;
|
||||
/**
|
||||
/**
|
||||
* Returns the type of the hotspot. This is usually used as a hint for views on how to represent
|
||||
* the hotspot graphically. eg. Link hotspots are typically underlined when the user mouses over them
|
||||
*/
|
||||
Type type() const;
|
||||
/**
|
||||
* Causes the an action associated with a hotspot to be triggered.
|
||||
/**
|
||||
* Causes the an action associated with a hotspot to be triggered.
|
||||
*
|
||||
* @param object The object which caused the hotspot to be triggered. This is
|
||||
* typically null ( in which case the default action should be performed ) or
|
||||
* one of the objects from the actions() list. In which case the associated
|
||||
* action should be performed.
|
||||
* action should be performed.
|
||||
*/
|
||||
virtual void activate(QObject* object = 0) = 0;
|
||||
/**
|
||||
* Returns a list of actions associated with the hotspot which can be used in a
|
||||
* menu or toolbar
|
||||
virtual void activate(QObject* object = 0) = 0;
|
||||
/**
|
||||
* Returns a list of actions associated with the hotspot which can be used in a
|
||||
* menu or toolbar
|
||||
*/
|
||||
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.
|
||||
* The default implementation returns an empty string.
|
||||
*/
|
||||
virtual QString tooltip() const;
|
||||
|
||||
@ -131,7 +131,7 @@ public:
|
||||
int _endLine;
|
||||
int _endColumn;
|
||||
Type _type;
|
||||
|
||||
|
||||
};
|
||||
|
||||
/** Constructs a new filter. */
|
||||
@ -141,9 +141,9 @@ public:
|
||||
/** Causes the filter to process the block of text currently in its internal buffer */
|
||||
virtual void process() = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Empties the filters internal buffer and resets the line count back to 0.
|
||||
* All hotspots are deleted.
|
||||
* All hotspots are deleted.
|
||||
*/
|
||||
void reset();
|
||||
|
||||
@ -159,7 +159,7 @@ public:
|
||||
/** Returns the list of hotspots identified by the filter which occur on a given line */
|
||||
QList<HotSpot*> hotSpotsAtLine(int line) const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* TODO: Document me
|
||||
*/
|
||||
void setBuffer(const QString* buffer , const QList<int>* linePositions);
|
||||
@ -175,22 +175,22 @@ protected:
|
||||
private:
|
||||
QMultiHash<int,HotSpot*> _hotspots;
|
||||
QList<HotSpot*> _hotspotList;
|
||||
|
||||
|
||||
const QList<int>* _linePositions;
|
||||
const QString* _buffer;
|
||||
};
|
||||
|
||||
/**
|
||||
* A filter which searches for sections of text matching a regular expression and creates a new RegExpFilter::HotSpot
|
||||
/**
|
||||
* A filter which searches for sections of text matching a regular expression and creates a new RegExpFilter::HotSpot
|
||||
* instance for them.
|
||||
*
|
||||
* Subclasses can reimplement newHotSpot() to return custom hotspot types when matches for the regular expression
|
||||
* are found.
|
||||
* are found.
|
||||
*/
|
||||
class RegExpFilter : public Filter
|
||||
{
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* Type of hotspot created by RegExpFilter. The capturedTexts() method can be used to find the text
|
||||
* matched by the filter's regular expression.
|
||||
*/
|
||||
@ -211,26 +211,26 @@ public:
|
||||
/** Constructs a new regular expression filter */
|
||||
RegExpFilter();
|
||||
|
||||
/**
|
||||
* Sets the regular expression which the filter searches for in blocks of text.
|
||||
/**
|
||||
* Sets the regular expression which the filter searches for in blocks of text.
|
||||
*
|
||||
* Regular expressions which match the empty string are treated as not matching
|
||||
* anything.
|
||||
* anything.
|
||||
*/
|
||||
void setRegExp(const QRegExp& text);
|
||||
/** Returns the regular expression which the filter searches for in blocks of text */
|
||||
QRegExp regExp() const;
|
||||
|
||||
/**
|
||||
* Reimplemented to search the filter's text buffer for text matching regExp()
|
||||
/**
|
||||
* Reimplemented to search the filter's text buffer for text matching regExp()
|
||||
*
|
||||
* If regexp matches the empty string, then process() will return immediately
|
||||
* without finding results.
|
||||
* without finding results.
|
||||
*/
|
||||
virtual void process();
|
||||
|
||||
protected:
|
||||
/**
|
||||
/**
|
||||
* Called when a match for the regular expression is encountered. Subclasses should reimplement this
|
||||
* to return custom hotspot types
|
||||
*/
|
||||
@ -244,14 +244,14 @@ private:
|
||||
class FilterObject;
|
||||
|
||||
/** A filter which matches URLs in blocks of text */
|
||||
class UrlFilter : public RegExpFilter
|
||||
class UrlFilter : public RegExpFilter
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Hotspot type created by UrlFilter instances. The activate() method opens a web browser
|
||||
/**
|
||||
* Hotspot type created by UrlFilter instances. The activate() method opens a web browser
|
||||
* at the given URL when called.
|
||||
*/
|
||||
class HotSpot : public RegExpFilter::HotSpot
|
||||
class HotSpot : public RegExpFilter::HotSpot
|
||||
{
|
||||
public:
|
||||
HotSpot(int startLine,int startColumn,int endLine,int endColumn);
|
||||
@ -259,7 +259,7 @@ public:
|
||||
|
||||
virtual QList<QAction*> actions();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Open a web browser at the current URL. The url itself can be determined using
|
||||
* the capturedTexts() method.
|
||||
*/
|
||||
@ -284,12 +284,12 @@ protected:
|
||||
virtual RegExpFilter::HotSpot* newHotSpot(int,int,int,int);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
static const QRegExp FullUrlRegExp;
|
||||
static const QRegExp EmailAddressRegExp;
|
||||
|
||||
// combined OR of FullUrlRegExp and EmailAddressRegExp
|
||||
static const QRegExp CompleteUrlRegExp;
|
||||
static const QRegExp CompleteUrlRegExp;
|
||||
};
|
||||
|
||||
class FilterObject : public QObject
|
||||
@ -303,11 +303,11 @@ private:
|
||||
Filter::HotSpot* _filter;
|
||||
};
|
||||
|
||||
/**
|
||||
* A chain which allows a group of filters to be processed as one.
|
||||
/**
|
||||
* A chain which allows a group of filters to be processed as one.
|
||||
* The chain owns the filters added to it and deletes them when the chain itself is destroyed.
|
||||
*
|
||||
* Use addFilter() to add a new filter to the chain.
|
||||
* Use addFilter() to add a new filter to the chain.
|
||||
* When new text to be filtered arrives, use addLine() to add each additional
|
||||
* line of text which needs to be processed and then after adding the last line, use
|
||||
* process() to cause each filter in the chain to process the text.
|
||||
@ -337,12 +337,12 @@ public:
|
||||
/** Resets each filter in the chain */
|
||||
void reset();
|
||||
/**
|
||||
* Processes each filter in the chain
|
||||
* Processes each filter in the chain
|
||||
*/
|
||||
void process();
|
||||
|
||||
/** Sets the buffer for each filter in the chain to process. */
|
||||
void setBuffer(const QString* buffer , const QList<int>* linePositions);
|
||||
void setBuffer(const QString* buffer , const QList<int>* linePositions);
|
||||
|
||||
/** Returns the first hotspot which occurs at @p line, @p column or 0 if no hotspot was found */
|
||||
Filter::HotSpot* hotSpotAt(int line , int column) const;
|
||||
@ -369,7 +369,7 @@ public:
|
||||
* @param lineProperties The line properties to set for image
|
||||
*/
|
||||
void setImage(const Character* const image , int lines , int columns,
|
||||
const QVector<LineProperty>& lineProperties);
|
||||
const QVector<LineProperty>& lineProperties);
|
||||
|
||||
private:
|
||||
QString* _buffer;
|
||||
|
@ -92,7 +92,7 @@ HistoryFile::HistoryFile()
|
||||
fileMap(0)
|
||||
{
|
||||
if (tmpFile.open())
|
||||
{
|
||||
{
|
||||
tmpFile.setAutoRemove(true);
|
||||
ion = tmpFile.handle();
|
||||
}
|
||||
@ -116,7 +116,7 @@ void HistoryFile::map()
|
||||
//if mmap'ing fails, fall back to the read-lseek combination
|
||||
if ( fileMap == MAP_FAILED )
|
||||
{
|
||||
readWriteBalance = 0;
|
||||
readWriteBalance = 0;
|
||||
fileMap = 0;
|
||||
qDebug() << __FILE__ << __LINE__ << ": mmap'ing history failed. errno = " << errno;
|
||||
}
|
||||
@ -139,7 +139,7 @@ void HistoryFile::add(const unsigned char* bytes, int len)
|
||||
{
|
||||
if ( fileMap )
|
||||
unmap();
|
||||
|
||||
|
||||
readWriteBalance++;
|
||||
|
||||
int rc = 0;
|
||||
@ -151,8 +151,8 @@ void HistoryFile::add(const unsigned char* bytes, int len)
|
||||
|
||||
void HistoryFile::get(unsigned char* bytes, int len, int loc)
|
||||
{
|
||||
//count number of get() calls vs. number of add() calls.
|
||||
//If there are many more get() calls compared with add()
|
||||
//count number of get() calls vs. number of add() calls.
|
||||
//If there are many more get() calls compared with add()
|
||||
//calls (decided by using MAP_THRESHOLD) then mmap the log
|
||||
//file to improve performance.
|
||||
readWriteBalance--;
|
||||
@ -165,7 +165,7 @@ void HistoryFile::get(unsigned char* bytes, int len, int loc)
|
||||
bytes[i]=fileMap[loc+i];
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (loc < 0 || len < 0 || loc + len > length)
|
||||
@ -201,7 +201,7 @@ bool HistoryScroll::hasScroll()
|
||||
|
||||
// History Scroll File //////////////////////////////////////
|
||||
|
||||
/*
|
||||
/*
|
||||
The history scroll makes a Row(Row(Cell)) from
|
||||
two history buffers. The index buffer contains
|
||||
start of line positions which refere to the cells
|
||||
@ -221,7 +221,7 @@ HistoryScrollFile::HistoryScrollFile(const QString &logFileName)
|
||||
HistoryScrollFile::~HistoryScrollFile()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int HistoryScrollFile::getLines()
|
||||
{
|
||||
return index.len() / sizeof(int);
|
||||
@ -246,11 +246,11 @@ int HistoryScrollFile::startOfLine(int lineno)
|
||||
{
|
||||
if (lineno <= 0) return 0;
|
||||
if (lineno <= getLines())
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
if (!index.isMapped())
|
||||
index.map();
|
||||
|
||||
|
||||
int res;
|
||||
index.get((unsigned char*)&res,sizeof(int),(lineno-1)*sizeof(int));
|
||||
return res;
|
||||
@ -345,7 +345,7 @@ int HistoryScrollBuffer::getLineLen(int lineNumber)
|
||||
bool HistoryScrollBuffer::isWrappedLine(int lineNumber)
|
||||
{
|
||||
Q_ASSERT( lineNumber >= 0 && lineNumber < _maxLineCount );
|
||||
|
||||
|
||||
if (lineNumber < _usedLines)
|
||||
{
|
||||
//kDebug() << "Line" << lineNumber << "wrapped is" << _wrappedLine[bufferIndex(lineNumber)];
|
||||
@ -361,12 +361,12 @@ void HistoryScrollBuffer::getCells(int lineNumber, int startColumn, int count, C
|
||||
|
||||
Q_ASSERT( lineNumber < _maxLineCount );
|
||||
|
||||
if (lineNumber >= _usedLines)
|
||||
if (lineNumber >= _usedLines)
|
||||
{
|
||||
memset(buffer, 0, count * sizeof(Character));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const HistoryLine& line = _historyBuffer[bufferIndex(lineNumber)];
|
||||
|
||||
//kDebug() << "startCol " << startColumn;
|
||||
@ -374,7 +374,7 @@ void HistoryScrollBuffer::getCells(int lineNumber, int startColumn, int count, C
|
||||
//kDebug() << "count " << count;
|
||||
|
||||
Q_ASSERT( startColumn <= line.size() - count );
|
||||
|
||||
|
||||
memcpy(buffer, line.constData() + startColumn , count * sizeof(Character));
|
||||
}
|
||||
|
||||
@ -382,12 +382,12 @@ void HistoryScrollBuffer::setMaxNbLines(unsigned int lineCount)
|
||||
{
|
||||
HistoryLine* oldBuffer = _historyBuffer;
|
||||
HistoryLine* newBuffer = new HistoryLine[lineCount];
|
||||
|
||||
|
||||
for ( int i = 0 ; i < qMin(_usedLines,(int)lineCount) ; i++ )
|
||||
{
|
||||
newBuffer[i] = oldBuffer[bufferIndex(i)];
|
||||
}
|
||||
|
||||
|
||||
_usedLines = qMin(_usedLines,(int)lineCount);
|
||||
_maxLineCount = lineCount;
|
||||
_head = ( _usedLines == _maxLineCount ) ? 0 : _usedLines-1;
|
||||
@ -410,7 +410,7 @@ int HistoryScrollBuffer::bufferIndex(int lineNumber)
|
||||
return (_head+lineNumber+1) % _maxLineCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
return lineNumber;
|
||||
}
|
||||
}
|
||||
@ -508,7 +508,7 @@ void HistoryScrollBlockArray::getCells(int lineno, int colno,
|
||||
void HistoryScrollBlockArray::addCells(const Character a[], int count)
|
||||
{
|
||||
Block *b = m_blockArray.lastBlock();
|
||||
|
||||
|
||||
if (!b) return;
|
||||
|
||||
// put cells in block's data
|
||||
@ -572,17 +572,17 @@ void* CompactHistoryBlockList::allocate(size_t size)
|
||||
void CompactHistoryBlockList::deallocate(void* ptr)
|
||||
{
|
||||
Q_ASSERT( !list.isEmpty());
|
||||
|
||||
int i=0;
|
||||
|
||||
int i=0;
|
||||
CompactHistoryBlock *block = list.at(i);
|
||||
while ( i<list.size() && !block->contains(ptr) )
|
||||
{
|
||||
{
|
||||
i++;
|
||||
block=list.at(i);
|
||||
}
|
||||
|
||||
Q_ASSERT( i<list.size() );
|
||||
|
||||
|
||||
block->deallocate();
|
||||
|
||||
if (!block->isInUse())
|
||||
@ -604,16 +604,16 @@ void* CompactHistoryLine::operator new (size_t size, CompactHistoryBlockList& bl
|
||||
return blockList.allocate(size);
|
||||
}
|
||||
|
||||
CompactHistoryLine::CompactHistoryLine ( const TextLine& line, CompactHistoryBlockList& bList )
|
||||
CompactHistoryLine::CompactHistoryLine ( const TextLine& line, CompactHistoryBlockList& bList )
|
||||
: blockList(bList),
|
||||
formatLength(0)
|
||||
{
|
||||
length=line.size();
|
||||
|
||||
|
||||
if (line.size() > 0) {
|
||||
formatLength=1;
|
||||
int k=1;
|
||||
|
||||
|
||||
// count number of different formats in this text line
|
||||
Character c = line[0];
|
||||
while ( k<length )
|
||||
@ -625,22 +625,22 @@ CompactHistoryLine::CompactHistoryLine ( const TextLine& line, CompactHistoryBlo
|
||||
}
|
||||
k++;
|
||||
}
|
||||
|
||||
|
||||
//kDebug() << "number of different formats in string: " << formatLength;
|
||||
formatArray = (CharacterFormat*) blockList.allocate(sizeof(CharacterFormat)*formatLength);
|
||||
Q_ASSERT (formatArray!=NULL);
|
||||
text = (quint16*) blockList.allocate(sizeof(quint16)*line.size());
|
||||
Q_ASSERT (text!=NULL);
|
||||
|
||||
|
||||
length=line.size();
|
||||
formatLength=formatLength;
|
||||
wrapped=false;
|
||||
|
||||
|
||||
// record formats and their positions in the format array
|
||||
c=line[0];
|
||||
formatArray[0].setFormat ( c );
|
||||
formatArray[0].startPos=0; // there's always at least 1 format (for the entire line, unless a change happens)
|
||||
|
||||
|
||||
k=1; // look for possible format changes
|
||||
int j=1;
|
||||
while ( k<length && j<formatLength )
|
||||
@ -655,7 +655,7 @@ CompactHistoryLine::CompactHistoryLine ( const TextLine& line, CompactHistoryBlo
|
||||
}
|
||||
k++;
|
||||
}
|
||||
|
||||
|
||||
// copy character values
|
||||
for ( int i=0; i<line.size(); i++ )
|
||||
{
|
||||
@ -673,7 +673,7 @@ CompactHistoryLine::~CompactHistoryLine()
|
||||
blockList.deallocate(text);
|
||||
blockList.deallocate(formatArray);
|
||||
}
|
||||
blockList.deallocate(this);
|
||||
blockList.deallocate(this);
|
||||
}
|
||||
|
||||
void CompactHistoryLine::getCharacter ( int index, Character &r )
|
||||
@ -918,7 +918,7 @@ const QString& HistoryTypeFile::getFileName() const
|
||||
|
||||
HistoryScroll* HistoryTypeFile::scroll(HistoryScroll *old) const
|
||||
{
|
||||
if (dynamic_cast<HistoryFile *>(old))
|
||||
if (dynamic_cast<HistoryFile *>(old))
|
||||
return old; // Unchanged.
|
||||
|
||||
HistoryScroll *newScroll = new HistoryScrollFile(m_fileName);
|
||||
@ -945,7 +945,7 @@ HistoryScroll* HistoryTypeFile::scroll(HistoryScroll *old) const
|
||||
}
|
||||
|
||||
delete old;
|
||||
return newScroll;
|
||||
return newScroll;
|
||||
}
|
||||
|
||||
int HistoryTypeFile::maximumLineCount() const
|
||||
|
@ -68,7 +68,7 @@ private:
|
||||
|
||||
//pointer to start of mmap'ed file data, or 0 if the file is not mmap'ed
|
||||
char* fileMap;
|
||||
|
||||
|
||||
//incremented whenver 'add' is called and decremented whenever
|
||||
//'get' is called.
|
||||
//this is used to detect when a large number of lines are being read and processed from the history
|
||||
@ -179,7 +179,7 @@ public:
|
||||
|
||||
void setMaxNbLines(unsigned int nbLines);
|
||||
unsigned int maxNbLines() { return _maxLineCount; }
|
||||
|
||||
|
||||
|
||||
private:
|
||||
int bufferIndex(int lineNumber);
|
||||
@ -187,9 +187,9 @@ private:
|
||||
HistoryLine* _historyBuffer;
|
||||
QBitArray _wrappedLine;
|
||||
int _maxLineCount;
|
||||
int _usedLines;
|
||||
int _usedLines;
|
||||
int _head;
|
||||
|
||||
|
||||
//QVector<histline*> m_histBuffer;
|
||||
//QBitArray m_wrappedLine;
|
||||
//unsigned int m_maxNbLines;
|
||||
@ -288,7 +288,7 @@ public:
|
||||
class CompactHistoryBlock
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
CompactHistoryBlock(){
|
||||
blockLength = 4096*64; // 256kb
|
||||
head = (quint8*) mmap(0, blockLength, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
|
||||
@ -297,12 +297,12 @@ public:
|
||||
tail = blockStart = head;
|
||||
allocCount=0;
|
||||
}
|
||||
|
||||
|
||||
virtual ~CompactHistoryBlock(){
|
||||
//free(blockStart);
|
||||
munmap(blockStart, blockLength);
|
||||
}
|
||||
|
||||
|
||||
virtual unsigned int remaining(){ return blockStart+blockLength-tail;}
|
||||
virtual unsigned length() { return blockLength; }
|
||||
virtual void* allocate(size_t length);
|
||||
@ -379,7 +379,7 @@ private:
|
||||
bool hasDifferentColors(const TextLine& line) const;
|
||||
HistoryArray lines;
|
||||
CompactHistoryBlockList blockList;
|
||||
|
||||
|
||||
unsigned int _maxLineCount;
|
||||
};
|
||||
|
||||
@ -395,7 +395,7 @@ public:
|
||||
|
||||
/**
|
||||
* Returns true if the history is enabled ( can store lines of output )
|
||||
* or false otherwise.
|
||||
* or false otherwise.
|
||||
*/
|
||||
virtual bool isEnabled() const = 0;
|
||||
/**
|
||||
@ -426,7 +426,7 @@ class HistoryTypeBlockArray : public HistoryType
|
||||
{
|
||||
public:
|
||||
HistoryTypeBlockArray(size_t size);
|
||||
|
||||
|
||||
virtual bool isEnabled() const;
|
||||
virtual int maximumLineCount() const;
|
||||
|
||||
@ -436,7 +436,7 @@ protected:
|
||||
size_t m_size;
|
||||
};
|
||||
|
||||
#if 1
|
||||
#if 1
|
||||
class HistoryTypeFile : public HistoryType
|
||||
{
|
||||
public:
|
||||
@ -459,10 +459,10 @@ class HistoryTypeBuffer : public HistoryType
|
||||
|
||||
public:
|
||||
HistoryTypeBuffer(unsigned int nbLines);
|
||||
|
||||
|
||||
virtual bool isEnabled() const;
|
||||
virtual int maximumLineCount() const;
|
||||
|
||||
|
||||
virtual HistoryScroll* scroll(HistoryScroll *) const;
|
||||
|
||||
protected:
|
||||
@ -473,7 +473,7 @@ class CompactHistoryType : public HistoryType
|
||||
{
|
||||
public:
|
||||
CompactHistoryType(unsigned int size);
|
||||
|
||||
|
||||
virtual bool isEnabled() const;
|
||||
virtual int maximumLineCount() const;
|
||||
|
||||
|
@ -83,8 +83,8 @@ void KeyboardTranslatorManager::findTranslators()
|
||||
QString translatorPath = listIter.next();
|
||||
|
||||
QString name = QFileInfo(translatorPath).baseName();
|
||||
|
||||
if ( !_translators.contains(name) )
|
||||
|
||||
if ( !_translators.contains(name) )
|
||||
_translators.insert(name,0);
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ Q_UNUSED(translator);
|
||||
QFile destination(path);
|
||||
if (!destination.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug() << "Unable to save keyboard translation:"
|
||||
qDebug() << "Unable to save keyboard translation:"
|
||||
<< destination.errorString();
|
||||
return false;
|
||||
}
|
||||
@ -130,7 +130,7 @@ Q_UNUSED(translator);
|
||||
{
|
||||
KeyboardTranslatorWriter writer(&destination);
|
||||
writer.writeHeader(translator->description());
|
||||
|
||||
|
||||
QListIterator<KeyboardTranslator::Entry> iter(translator->entries());
|
||||
while ( iter.hasNext() )
|
||||
writer.writeEntry(iter.next());
|
||||
@ -145,7 +145,7 @@ KeyboardTranslator* KeyboardTranslatorManager::loadTranslator(const QString& nam
|
||||
{
|
||||
const QString& path = findTranslatorPath(name);
|
||||
|
||||
QFile source(path);
|
||||
QFile source(path);
|
||||
if (name.isEmpty() || !source.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
return 0;
|
||||
|
||||
@ -224,7 +224,7 @@ void KeyboardTranslatorWriter::writeEntry( const KeyboardTranslator::Entry& entr
|
||||
// KeySequence begins with the name of the key ( taken from the Qt::Key enum )
|
||||
// and is followed by the keyboard modifiers and state flags ( with + or - in front
|
||||
// of each modifier or flag to indicate whether it is required ). All keyboard modifiers
|
||||
// and flags are optional, if a particular modifier or state is not specified it is
|
||||
// and flags are optional, if a particular modifier or state is not specified it is
|
||||
// assumed not to be a part of the sequence. The key sequence may contain whitespace
|
||||
//
|
||||
// eg: "key Up+Shift : scrollLineUp"
|
||||
@ -248,7 +248,7 @@ KeyboardTranslatorReader::KeyboardTranslatorReader( QIODevice* source )
|
||||
// read first entry (if any)
|
||||
readNext();
|
||||
}
|
||||
void KeyboardTranslatorReader::readNext()
|
||||
void KeyboardTranslatorReader::readNext()
|
||||
{
|
||||
// find next entry
|
||||
while ( !_source->atEnd() )
|
||||
@ -268,7 +268,7 @@ void KeyboardTranslatorReader::readNext()
|
||||
modifiers,
|
||||
modifierMask,
|
||||
flags,
|
||||
flagMask);
|
||||
flagMask);
|
||||
|
||||
KeyboardTranslator::Command command = KeyboardTranslator::NoCommand;
|
||||
QByteArray text;
|
||||
@ -300,12 +300,12 @@ void KeyboardTranslatorReader::readNext()
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_hasNext = false;
|
||||
}
|
||||
|
||||
bool KeyboardTranslatorReader::parseAsCommand(const QString& text,KeyboardTranslator::Command& command)
|
||||
bool KeyboardTranslatorReader::parseAsCommand(const QString& text,KeyboardTranslator::Command& command)
|
||||
{
|
||||
if ( text.compare("erase",Qt::CaseInsensitive) == 0 )
|
||||
command = KeyboardTranslator::EraseCommand;
|
||||
@ -332,7 +332,7 @@ bool KeyboardTranslatorReader::decodeSequence(const QString& text,
|
||||
KeyboardTranslator::States& flags,
|
||||
KeyboardTranslator::States& flagMask)
|
||||
{
|
||||
bool isWanted = true;
|
||||
bool isWanted = true;
|
||||
bool endOfItem = false;
|
||||
QString buffer;
|
||||
|
||||
@ -384,13 +384,13 @@ bool KeyboardTranslatorReader::decodeSequence(const QString& text,
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
// check if this is a wanted / not-wanted flag and update the
|
||||
// check if this is a wanted / not-wanted flag and update the
|
||||
// state ready for the next item
|
||||
if ( ch == '+' )
|
||||
isWanted = true;
|
||||
else if ( ch == '-' )
|
||||
isWanted = false;
|
||||
}
|
||||
isWanted = false;
|
||||
}
|
||||
|
||||
modifiers = tempModifiers;
|
||||
modifierMask = tempModifierMask;
|
||||
@ -467,7 +467,7 @@ bool KeyboardTranslatorReader::hasNextEntry()
|
||||
{
|
||||
return _hasNext;
|
||||
}
|
||||
KeyboardTranslator::Entry KeyboardTranslatorReader::createEntry( const QString& condition ,
|
||||
KeyboardTranslator::Entry KeyboardTranslatorReader::createEntry( const QString& condition ,
|
||||
const QString& result )
|
||||
{
|
||||
QString entryString("keyboard \"temporary\"\nkey ");
|
||||
@ -495,7 +495,7 @@ KeyboardTranslator::Entry KeyboardTranslatorReader::createEntry( const QString&
|
||||
return entry;
|
||||
}
|
||||
|
||||
KeyboardTranslator::Entry KeyboardTranslatorReader::nextEntry()
|
||||
KeyboardTranslator::Entry KeyboardTranslatorReader::nextEntry()
|
||||
{
|
||||
Q_ASSERT( _hasNext );
|
||||
KeyboardTranslator::Entry entry = _nextEntry;
|
||||
@ -510,7 +510,7 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const
|
||||
{
|
||||
QString text = line;
|
||||
|
||||
// remove comments
|
||||
// remove comments
|
||||
bool inQuotes = false;
|
||||
int commentPos = -1;
|
||||
for (int i=text.length()-1;i>=0;i--)
|
||||
@ -525,7 +525,7 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const
|
||||
text.remove(commentPos,text.length());
|
||||
|
||||
text = text.simplified();
|
||||
|
||||
|
||||
// title line: keyboard "title"
|
||||
static QRegExp title("keyboard\\s+\"(.*)\"");
|
||||
// key line: key KeySequence : "output"
|
||||
@ -533,7 +533,7 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const
|
||||
static QRegExp key("key\\s+([\\w\\+\\s\\-\\*\\.]+)\\s*:\\s*(\"(.*)\"|\\w+)");
|
||||
|
||||
QList<Token> list;
|
||||
if ( text.isEmpty() )
|
||||
if ( text.isEmpty() )
|
||||
{
|
||||
return list;
|
||||
}
|
||||
@ -542,7 +542,7 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const
|
||||
{
|
||||
Token titleToken = { Token::TitleKeyword , QString() };
|
||||
Token textToken = { Token::TitleText , title.capturedTexts()[1] };
|
||||
|
||||
|
||||
list << titleToken << textToken;
|
||||
}
|
||||
else if ( key.exactMatch(text) )
|
||||
@ -556,14 +556,14 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const
|
||||
{
|
||||
// capturedTexts()[2] is a command
|
||||
Token commandToken = { Token::Command , key.capturedTexts()[2] };
|
||||
list << commandToken;
|
||||
}
|
||||
list << commandToken;
|
||||
}
|
||||
else
|
||||
{
|
||||
// capturedTexts()[3] is the output string
|
||||
Token outputToken = { Token::OutputText , key.capturedTexts()[3] };
|
||||
list << outputToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -573,7 +573,7 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const
|
||||
return list;
|
||||
}
|
||||
|
||||
QList<QString> KeyboardTranslatorManager::allTranslators()
|
||||
QList<QString> KeyboardTranslatorManager::allTranslators()
|
||||
{
|
||||
if ( !_haveLoadedAll )
|
||||
{
|
||||
@ -604,14 +604,14 @@ bool KeyboardTranslator::Entry::operator==(const Entry& rhs) const
|
||||
_text == rhs._text;
|
||||
}
|
||||
|
||||
bool KeyboardTranslator::Entry::matches(int keyCode ,
|
||||
bool KeyboardTranslator::Entry::matches(int keyCode ,
|
||||
Qt::KeyboardModifiers modifiers,
|
||||
States testState) const
|
||||
{
|
||||
if ( _keyCode != keyCode )
|
||||
return false;
|
||||
|
||||
if ( (modifiers & _modifierMask) != (_modifiers & _modifierMask) )
|
||||
if ( (modifiers & _modifierMask) != (_modifiers & _modifierMask) )
|
||||
return false;
|
||||
|
||||
// if modifiers is non-zero, the 'any modifier' state is implicit
|
||||
@ -621,7 +621,7 @@ bool KeyboardTranslator::Entry::matches(int keyCode ,
|
||||
if ( (testState & _stateMask) != (_state & _stateMask) )
|
||||
return false;
|
||||
|
||||
// special handling for the 'Any Modifier' state, which checks for the presence of
|
||||
// special handling for the 'Any Modifier' state, which checks for the presence of
|
||||
// any or no modifiers. In this context, the 'keypad' modifier does not count.
|
||||
bool anyModifiersSet = modifiers != 0 && modifiers != Qt::KeypadModifier;
|
||||
bool wantAnyModifier = _state & KeyboardTranslator::AnyModifierState;
|
||||
@ -630,7 +630,7 @@ bool KeyboardTranslator::Entry::matches(int keyCode ,
|
||||
if ( wantAnyModifier != anyModifiersSet )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
QByteArray KeyboardTranslator::Entry::escapedText(bool expandWildCards,Qt::KeyboardModifiers modifiers) const
|
||||
@ -659,7 +659,7 @@ QByteArray KeyboardTranslator::Entry::escapedText(bool expandWildCards,Qt::Keybo
|
||||
|
||||
if ( replacement == 'x' )
|
||||
{
|
||||
result.replace(i,1,"\\x"+QByteArray(1,ch).toHex());
|
||||
result.replace(i,1,"\\x"+QByteArray(1,ch).toHex());
|
||||
} else if ( replacement != 0 )
|
||||
{
|
||||
result.remove(i,1);
|
||||
@ -707,7 +707,7 @@ QByteArray KeyboardTranslator::Entry::unescape(const QByteArray& input) const
|
||||
unsigned charValue = 0;
|
||||
sscanf(hexDigits,"%x",&charValue);
|
||||
|
||||
replacement[0] = (char)charValue;
|
||||
replacement[0] = (char)charValue;
|
||||
charsToRemove = 2 + strlen(hexDigits);
|
||||
}
|
||||
break;
|
||||
@ -811,7 +811,7 @@ KeyboardTranslator::KeyboardTranslator(const QString& name)
|
||||
{
|
||||
}
|
||||
|
||||
void KeyboardTranslator::setDescription(const QString& description)
|
||||
void KeyboardTranslator::setDescription(const QString& description)
|
||||
{
|
||||
_description = description;
|
||||
}
|
||||
@ -874,7 +874,7 @@ bool KeyboardTranslatorManager::deleteTranslator(const QString& name)
|
||||
if ( QFile::remove(path) )
|
||||
{
|
||||
_translators.remove(name);
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ class QIODevice;
|
||||
class QTextStream;
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* A convertor which maps between key sequences pressed by the user and the
|
||||
* character strings which should be sent to the terminal and commands
|
||||
* which should be invoked when those character sequences are pressed.
|
||||
@ -53,7 +53,7 @@ class QTextStream;
|
||||
class KeyboardTranslator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* The meaning of a particular key sequence may depend upon the state which
|
||||
* the terminal emulation is in. Therefore findEntry() may return a different
|
||||
* Entry depending upon the state flags supplied.
|
||||
@ -69,7 +69,7 @@ public:
|
||||
* TODO More documentation
|
||||
*/
|
||||
NewLineState = 1,
|
||||
/**
|
||||
/**
|
||||
* Indicates that the terminal is in 'Ansi' mode.
|
||||
* TODO: More documentation
|
||||
*/
|
||||
@ -80,10 +80,10 @@ public:
|
||||
CursorKeysState = 4,
|
||||
/**
|
||||
* Indicates that the alternate screen ( typically used by interactive programs
|
||||
* such as screen or vim ) is active
|
||||
* such as screen or vim ) is active
|
||||
*/
|
||||
AlternateScreenState = 8,
|
||||
/** Indicates that any of the modifier keys is active. */
|
||||
/** Indicates that any of the modifier keys is active. */
|
||||
AnyModifierState = 16,
|
||||
/** Indicates that the numpad is in application mode. */
|
||||
ApplicationKeypadState = 32
|
||||
@ -122,14 +122,14 @@ public:
|
||||
class Entry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* Constructs a new entry for a keyboard translator.
|
||||
*/
|
||||
Entry();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns true if this entry is null.
|
||||
* This is true for newly constructed entries which have no properties set.
|
||||
* This is true for newly constructed entries which have no properties set.
|
||||
*/
|
||||
bool isNull() const;
|
||||
|
||||
@ -138,15 +138,15 @@ public:
|
||||
/** Sets the command associated with this entry. */
|
||||
void setCommand(Command command);
|
||||
|
||||
/**
|
||||
* Returns the character sequence associated with this entry, optionally replacing
|
||||
/**
|
||||
* Returns the character sequence associated with this entry, optionally replacing
|
||||
* wildcard '*' characters with numbers to indicate the keyboard modifiers being pressed.
|
||||
*
|
||||
* TODO: The numbers used to replace '*' characters are taken from the Konsole/KDE 3 code.
|
||||
* Document them.
|
||||
* Document them.
|
||||
*
|
||||
* @param expandWildCards Specifies whether wild cards (occurrences of the '*' character) in
|
||||
* the entry should be replaced with a number to indicate the modifier keys being pressed.
|
||||
* the entry should be replaced with a number to indicate the modifier keys being pressed.
|
||||
*
|
||||
* @param modifiers The keyboard modifiers being pressed.
|
||||
*/
|
||||
@ -156,7 +156,7 @@ public:
|
||||
/** Sets the character sequence associated with this entry */
|
||||
void setText(const QByteArray& text);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the character sequence associated with this entry,
|
||||
* with any non-printable characters replaced with escape sequences.
|
||||
*
|
||||
@ -173,13 +173,13 @@ public:
|
||||
/** Sets the character code associated with this entry */
|
||||
void setKeyCode(int keyCode);
|
||||
|
||||
/**
|
||||
* Returns a bitwise-OR of the enabled keyboard modifiers associated with this entry.
|
||||
/**
|
||||
* Returns a bitwise-OR of the enabled keyboard modifiers associated with this entry.
|
||||
* If a modifier is set in modifierMask() but not in modifiers(), this means that the entry
|
||||
* only matches when that modifier is NOT pressed.
|
||||
*
|
||||
* If a modifier is not set in modifierMask() then the entry matches whether the modifier
|
||||
* is pressed or not.
|
||||
* is pressed or not.
|
||||
*/
|
||||
Qt::KeyboardModifiers modifiers() const;
|
||||
|
||||
@ -191,13 +191,13 @@ public:
|
||||
/** See modifierMask() and modifiers() */
|
||||
void setModifierMask( Qt::KeyboardModifiers modifiers );
|
||||
|
||||
/**
|
||||
* Returns a bitwise-OR of the enabled state flags associated with this entry.
|
||||
* If flag is set in stateMask() but not in state(), this means that the entry only
|
||||
/**
|
||||
* Returns a bitwise-OR of the enabled state flags associated with this entry.
|
||||
* If flag is set in stateMask() but not in state(), this means that the entry only
|
||||
* matches when the terminal is NOT in that state.
|
||||
*
|
||||
* If a state is not set in stateMask() then the entry matches whether the terminal
|
||||
* is in that state or not.
|
||||
* is in that state or not.
|
||||
*/
|
||||
States state() const;
|
||||
|
||||
@ -209,13 +209,13 @@ public:
|
||||
/** See stateMask() */
|
||||
void setStateMask( States mask );
|
||||
|
||||
/**
|
||||
* Returns the key code and modifiers associated with this entry
|
||||
/**
|
||||
* Returns the key code and modifiers associated with this entry
|
||||
* as a QKeySequence
|
||||
*/
|
||||
//QKeySequence keySequence() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns this entry's conditions ( ie. its key code, modifier and state criteria )
|
||||
* as a string.
|
||||
*/
|
||||
@ -231,16 +231,16 @@ public:
|
||||
QString resultToString(bool expandWildCards = false,
|
||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier) const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns true if this entry matches the given key sequence, specified
|
||||
* as a combination of @p keyCode , @p modifiers and @p state.
|
||||
*/
|
||||
bool matches( int keyCode ,
|
||||
Qt::KeyboardModifiers modifiers ,
|
||||
bool matches( int keyCode ,
|
||||
Qt::KeyboardModifiers modifiers ,
|
||||
States flags ) const;
|
||||
|
||||
bool operator==(const Entry& rhs) const;
|
||||
|
||||
|
||||
private:
|
||||
void insertModifier( QString& item , int modifier ) const;
|
||||
void insertState( QString& item , int state ) const;
|
||||
@ -258,7 +258,7 @@ public:
|
||||
|
||||
/** Constructs a new keyboard translator with the given @p name */
|
||||
KeyboardTranslator(const QString& name);
|
||||
|
||||
|
||||
//KeyboardTranslator(const KeyboardTranslator& other);
|
||||
|
||||
/** Returns the name of this keyboard translator */
|
||||
@ -276,7 +276,7 @@ public:
|
||||
/**
|
||||
* Looks for an entry in this keyboard translator which matches the given
|
||||
* key code, keyboard modifiers and state flags.
|
||||
*
|
||||
*
|
||||
* Returns the matching entry if found or a null Entry otherwise ( ie.
|
||||
* entry.isNull() will return true )
|
||||
*
|
||||
@ -284,11 +284,11 @@ public:
|
||||
* @param modifiers A combination of modifiers
|
||||
* @param state Optional flags which specify the current state of the terminal
|
||||
*/
|
||||
Entry findEntry(int keyCode ,
|
||||
Qt::KeyboardModifiers modifiers ,
|
||||
Entry findEntry(int keyCode ,
|
||||
Qt::KeyboardModifiers modifiers ,
|
||||
States state = NoState) const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Adds an entry to this keyboard translator's table. Entries can be looked up according
|
||||
* to their key sequence using findEntry()
|
||||
*/
|
||||
@ -319,8 +319,8 @@ private:
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(KeyboardTranslator::States)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(KeyboardTranslator::Commands)
|
||||
|
||||
/**
|
||||
* Parses the contents of a Keyboard Translator (.keytab) file and
|
||||
/**
|
||||
* Parses the contents of a Keyboard Translator (.keytab) file and
|
||||
* returns the entries found in it.
|
||||
*
|
||||
* Usage example:
|
||||
@ -340,7 +340,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(KeyboardTranslator::Commands)
|
||||
* if ( !reader.parseError() )
|
||||
* {
|
||||
* // parsing succeeded, do something with the translator
|
||||
* }
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // parsing failed
|
||||
@ -353,18 +353,18 @@ public:
|
||||
/** Constructs a new reader which parses the given @p source */
|
||||
KeyboardTranslatorReader( QIODevice* source );
|
||||
|
||||
/**
|
||||
* Returns the description text.
|
||||
* TODO: More documentation
|
||||
/**
|
||||
* Returns the description text.
|
||||
* TODO: More documentation
|
||||
*/
|
||||
QString description() const;
|
||||
|
||||
/** Returns true if there is another entry in the source stream */
|
||||
bool hasNextEntry();
|
||||
/** Returns the next entry found in the source stream */
|
||||
KeyboardTranslator::Entry nextEntry();
|
||||
KeyboardTranslator::Entry nextEntry();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns true if an error occurred whilst parsing the input or
|
||||
* false if no error occurred.
|
||||
*/
|
||||
@ -374,7 +374,7 @@ public:
|
||||
* Parses a condition and result string for a translator entry
|
||||
* and produces a keyboard translator entry.
|
||||
*
|
||||
* The condition and result strings are in the same format as in
|
||||
* The condition and result strings are in the same format as in
|
||||
*/
|
||||
static KeyboardTranslator::Entry createEntry( const QString& condition ,
|
||||
const QString& result );
|
||||
@ -395,7 +395,7 @@ private:
|
||||
};
|
||||
QList<Token> tokenize(const QString&);
|
||||
void readNext();
|
||||
bool decodeSequence(const QString& ,
|
||||
bool decodeSequence(const QString& ,
|
||||
int& keyCode,
|
||||
Qt::KeyboardModifiers& modifiers,
|
||||
Qt::KeyboardModifiers& modifierMask,
|
||||
@ -417,23 +417,23 @@ private:
|
||||
class KeyboardTranslatorWriter
|
||||
{
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* Constructs a new writer which saves data into @p destination.
|
||||
* The caller is responsible for closing the device when writing is complete.
|
||||
*/
|
||||
KeyboardTranslatorWriter(QIODevice* destination);
|
||||
~KeyboardTranslatorWriter();
|
||||
|
||||
/**
|
||||
* Writes the header for the keyboard translator.
|
||||
* @param description Description of the keyboard translator.
|
||||
/**
|
||||
* Writes the header for the keyboard translator.
|
||||
* @param description Description of the keyboard translator.
|
||||
*/
|
||||
void writeHeader( const QString& description );
|
||||
/** Writes a translator entry. */
|
||||
void writeEntry( const KeyboardTranslator::Entry& entry );
|
||||
void writeEntry( const KeyboardTranslator::Entry& entry );
|
||||
|
||||
private:
|
||||
QIODevice* _destination;
|
||||
QIODevice* _destination;
|
||||
QTextStream* _writer;
|
||||
};
|
||||
|
||||
@ -444,7 +444,7 @@ private:
|
||||
class KONSOLEPRIVATE_EXPORT KeyboardTranslatorManager
|
||||
{
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* Constructs a new KeyboardTranslatorManager and loads the list of
|
||||
* available keyboard translations.
|
||||
*
|
||||
@ -455,7 +455,7 @@ public:
|
||||
~KeyboardTranslatorManager();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* TODO: More documentation.
|
||||
@ -472,18 +472,18 @@ public:
|
||||
/** Returns the default translator for Konsole. */
|
||||
const KeyboardTranslator* defaultTranslator();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the keyboard translator with the given name or 0 if no translator
|
||||
* with that name exists.
|
||||
*
|
||||
* The first time that a translator with a particular name is requested,
|
||||
* the on-disk .keyboard file is loaded and parsed.
|
||||
* the on-disk .keyboard file is loaded and parsed.
|
||||
*/
|
||||
const KeyboardTranslator* findTranslator(const QString& name);
|
||||
/**
|
||||
* Returns a list of the names of available keyboard translators.
|
||||
*
|
||||
* The first time this is called, a search for available
|
||||
* The first time this is called, a search for available
|
||||
* translators is started.
|
||||
*/
|
||||
QList<QString> allTranslators();
|
||||
@ -493,15 +493,15 @@ public:
|
||||
|
||||
private:
|
||||
static const QByteArray defaultTranslatorText;
|
||||
|
||||
|
||||
void findTranslators(); // locate the available translators
|
||||
KeyboardTranslator* loadTranslator(const QString& name); // loads the translator
|
||||
KeyboardTranslator* loadTranslator(const QString& name); // loads the translator
|
||||
// with the given name
|
||||
KeyboardTranslator* loadTranslator(QIODevice* device,const QString& name);
|
||||
|
||||
bool saveTranslator(const KeyboardTranslator* translator);
|
||||
QString findTranslatorPath(const QString& name);
|
||||
|
||||
|
||||
QHash<QString,KeyboardTranslator*> _translators; // maps translator-name -> KeyboardTranslator
|
||||
// instance
|
||||
bool _haveLoadedAll;
|
||||
@ -512,15 +512,15 @@ private:
|
||||
inline int KeyboardTranslator::Entry::keyCode() const { return _keyCode; }
|
||||
inline void KeyboardTranslator::Entry::setKeyCode(int keyCode) { _keyCode = keyCode; }
|
||||
|
||||
inline void KeyboardTranslator::Entry::setModifiers( Qt::KeyboardModifiers modifier )
|
||||
{
|
||||
inline void KeyboardTranslator::Entry::setModifiers( Qt::KeyboardModifiers modifier )
|
||||
{
|
||||
_modifiers = modifier;
|
||||
}
|
||||
inline Qt::KeyboardModifiers KeyboardTranslator::Entry::modifiers() const { return _modifiers; }
|
||||
|
||||
inline void KeyboardTranslator::Entry::setModifierMask( Qt::KeyboardModifiers mask )
|
||||
{
|
||||
_modifierMask = mask;
|
||||
inline void KeyboardTranslator::Entry::setModifierMask( Qt::KeyboardModifiers mask )
|
||||
{
|
||||
_modifierMask = mask;
|
||||
}
|
||||
inline Qt::KeyboardModifiers KeyboardTranslator::Entry::modifierMask() const { return _modifierMask; }
|
||||
|
||||
@ -530,23 +530,23 @@ inline bool KeyboardTranslator::Entry::isNull() const
|
||||
}
|
||||
|
||||
inline void KeyboardTranslator::Entry::setCommand( Command command )
|
||||
{
|
||||
_command = command;
|
||||
{
|
||||
_command = command;
|
||||
}
|
||||
inline KeyboardTranslator::Command KeyboardTranslator::Entry::command() const { return _command; }
|
||||
|
||||
inline void KeyboardTranslator::Entry::setText( const QByteArray& text )
|
||||
{
|
||||
{
|
||||
_text = unescape(text);
|
||||
}
|
||||
inline int oneOrZero(int value)
|
||||
{
|
||||
return value ? 1 : 0;
|
||||
}
|
||||
inline QByteArray KeyboardTranslator::Entry::text(bool expandWildCards,Qt::KeyboardModifiers modifiers) const
|
||||
inline QByteArray KeyboardTranslator::Entry::text(bool expandWildCards,Qt::KeyboardModifiers modifiers) const
|
||||
{
|
||||
QByteArray expandedText = _text;
|
||||
|
||||
|
||||
if (expandWildCards)
|
||||
{
|
||||
int modifierValue = 1;
|
||||
@ -554,25 +554,25 @@ inline QByteArray KeyboardTranslator::Entry::text(bool expandWildCards,Qt::Keybo
|
||||
modifierValue += oneOrZero(modifiers & Qt::AltModifier) << 1;
|
||||
modifierValue += oneOrZero(modifiers & Qt::ControlModifier) << 2;
|
||||
|
||||
for (int i=0;i<_text.length();i++)
|
||||
for (int i=0;i<_text.length();i++)
|
||||
{
|
||||
if (expandedText[i] == '*')
|
||||
expandedText[i] = '0' + modifierValue;
|
||||
}
|
||||
}
|
||||
|
||||
return expandedText;
|
||||
return expandedText;
|
||||
}
|
||||
|
||||
inline void KeyboardTranslator::Entry::setState( States state )
|
||||
{
|
||||
_state = state;
|
||||
{
|
||||
_state = state;
|
||||
}
|
||||
inline KeyboardTranslator::States KeyboardTranslator::Entry::state() const { return _state; }
|
||||
|
||||
inline void KeyboardTranslator::Entry::setStateMask( States stateMask )
|
||||
{
|
||||
_stateMask = stateMask;
|
||||
{
|
||||
_stateMask = stateMask;
|
||||
}
|
||||
inline KeyboardTranslator::States KeyboardTranslator::Entry::stateMask() const { return _stateMask; }
|
||||
|
||||
|
@ -81,7 +81,7 @@ bool Pty::flowControlEnabled() const
|
||||
pty()->tcGetAttr(&ttmode);
|
||||
return ttmode.c_iflag & IXOFF &&
|
||||
ttmode.c_iflag & IXON;
|
||||
}
|
||||
}
|
||||
qWarning() << "Unable to get flow control status, terminal not connected.";
|
||||
return false;
|
||||
}
|
||||
@ -108,7 +108,7 @@ void Pty::setUtf8Mode(bool enable)
|
||||
void Pty::setErase(char erase)
|
||||
{
|
||||
_eraseChar = erase;
|
||||
|
||||
|
||||
if (pty()->masterFd() >= 0)
|
||||
{
|
||||
struct ::termios ttmode;
|
||||
@ -140,7 +140,7 @@ void Pty::addEnvironmentVariables(const QStringList& environment)
|
||||
|
||||
// split on the first '=' character
|
||||
int pos = pair.indexOf('=');
|
||||
|
||||
|
||||
if ( pos >= 0 )
|
||||
{
|
||||
QString variable = pair.left(pos);
|
||||
@ -151,10 +151,10 @@ void Pty::addEnvironmentVariables(const QStringList& environment)
|
||||
}
|
||||
}
|
||||
|
||||
int Pty::start(const QString& program,
|
||||
const QStringList& programArguments,
|
||||
const QStringList& environment,
|
||||
ulong winid,
|
||||
int Pty::start(const QString& program,
|
||||
const QStringList& programArguments,
|
||||
const QStringList& environment,
|
||||
ulong winid,
|
||||
bool addToUtmp
|
||||
//const QString& dbusService,
|
||||
//const QString& dbusSession
|
||||
@ -162,7 +162,7 @@ int Pty::start(const QString& program,
|
||||
{
|
||||
clearProgram();
|
||||
|
||||
// For historical reasons, the first argument in programArguments is the
|
||||
// For historical reasons, the first argument in programArguments is the
|
||||
// name of the program to execute, so create a list consisting of all
|
||||
// but the first argument to pass to setProgram()
|
||||
Q_ASSERT(programArguments.count() >= 1);
|
||||
@ -202,10 +202,10 @@ int Pty::start(const QString& program,
|
||||
|
||||
if (_eraseChar != 0)
|
||||
ttmode.c_cc[VERASE] = _eraseChar;
|
||||
|
||||
|
||||
if (!pty()->tcSetAttr(&ttmode))
|
||||
qWarning() << "Unable to set terminal attributes.";
|
||||
|
||||
|
||||
pty()->setWinSize(_windowLines, _windowColumns);
|
||||
|
||||
KProcess::start();
|
||||
@ -256,15 +256,15 @@ void Pty::sendData(const char* data, int length)
|
||||
{
|
||||
if (!length)
|
||||
return;
|
||||
|
||||
if (!pty()->write(data,length))
|
||||
|
||||
if (!pty()->write(data,length))
|
||||
{
|
||||
qWarning() << "Pty::doSendJobs - Could not send input data to terminal process.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Pty::dataReceived()
|
||||
void Pty::dataReceived()
|
||||
{
|
||||
QByteArray data = pty()->readAll();
|
||||
emit receivedData(data.constData(),data.count());
|
||||
@ -288,7 +288,7 @@ int Pty::foregroundProcessGroup() const
|
||||
if ( pid != -1 )
|
||||
{
|
||||
return pid;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -296,9 +296,9 @@ int Pty::foregroundProcessGroup() const
|
||||
void Pty::setupChildProcess()
|
||||
{
|
||||
KPtyProcess::setupChildProcess();
|
||||
|
||||
|
||||
// reset all signal handlers
|
||||
// this ensures that terminal applications respond to
|
||||
// this ensures that terminal applications respond to
|
||||
// signals generated via key sequences such as Ctrl+C
|
||||
// (which sends SIGINT)
|
||||
struct sigaction action;
|
||||
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
This file is part of Konsole, KDE's terminal emulator.
|
||||
|
||||
This file is part of Konsole, KDE's terminal emulator.
|
||||
|
||||
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
|
||||
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||
|
||||
@ -42,8 +42,8 @@
|
||||
|
||||
|
||||
/**
|
||||
* The Pty class is used to start the terminal process,
|
||||
* send data to it, receive data from it and manipulate
|
||||
* The Pty class is used to start the terminal process,
|
||||
* send data to it, receive data from it and manipulate
|
||||
* various properties of the pseudo-teletype interface
|
||||
* used to communicate with the process.
|
||||
*
|
||||
@ -52,26 +52,26 @@
|
||||
* send data to or receive data from the process.
|
||||
*
|
||||
* To start the terminal process, call the start() method
|
||||
* with the program name and appropriate arguments.
|
||||
* with the program name and appropriate arguments.
|
||||
*/
|
||||
class Pty: public KPtyProcess
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Constructs a new Pty.
|
||||
*
|
||||
*
|
||||
* Connect to the sendData() slot and receivedData() signal to prepare
|
||||
* for sending and receiving data from the terminal process.
|
||||
*
|
||||
* To start the terminal process, call the run() method with the
|
||||
* To start the terminal process, call the run() method with the
|
||||
* name of the program to start and appropriate arguments.
|
||||
*/
|
||||
explicit Pty(QObject* parent = 0);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Construct a process using an open pty master.
|
||||
* See KPtyProcess::KPtyProcess()
|
||||
*/
|
||||
@ -80,7 +80,7 @@ Q_OBJECT
|
||||
~Pty();
|
||||
|
||||
/**
|
||||
* Starts the terminal process.
|
||||
* Starts the terminal process.
|
||||
*
|
||||
* Returns 0 if the process was started successfully or non-zero
|
||||
* otherwise.
|
||||
@ -93,23 +93,23 @@ Q_OBJECT
|
||||
* @param winid Specifies the value of the WINDOWID environment variable
|
||||
* in the process's environment.
|
||||
* @param addToUtmp Specifies whether a utmp entry should be created for
|
||||
* the pty used. See K3Process::setUsePty()
|
||||
* @param dbusService Specifies the value of the KONSOLE_DBUS_SERVICE
|
||||
* the pty used. See K3Process::setUsePty()
|
||||
* @param dbusService Specifies the value of the KONSOLE_DBUS_SERVICE
|
||||
* environment variable in the process's environment.
|
||||
* @param dbusSession Specifies the value of the KONSOLE_DBUS_SESSION
|
||||
* environment variable in the process's environment.
|
||||
* environment variable in the process's environment.
|
||||
*/
|
||||
int start( const QString& program,
|
||||
const QStringList& arguments,
|
||||
const QStringList& environment,
|
||||
ulong winid,
|
||||
int start( const QString& program,
|
||||
const QStringList& arguments,
|
||||
const QStringList& environment,
|
||||
ulong winid,
|
||||
bool addToUtmp
|
||||
);
|
||||
|
||||
/** TODO: Document me */
|
||||
void setWriteable(bool writeable);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Enables or disables Xon/Xoff flow control. The flow control setting
|
||||
* may be changed later by a terminal application, so flowControlEnabled()
|
||||
* may not equal the value of @p on in the previous call to setFlowControlEnabled()
|
||||
@ -119,12 +119,12 @@ Q_OBJECT
|
||||
/** Queries the terminal state and returns true if Xon/Xoff flow control is enabled. */
|
||||
bool flowControlEnabled() const;
|
||||
|
||||
/**
|
||||
* Sets the size of the window (in lines and columns of characters)
|
||||
/**
|
||||
* Sets the size of the window (in lines and columns of characters)
|
||||
* used by this teletype.
|
||||
*/
|
||||
void setWindowSize(int lines, int cols);
|
||||
|
||||
|
||||
/** Returns the size of the window used by this teletype. See setWindowSize() */
|
||||
QSize windowSize() const;
|
||||
|
||||
@ -143,7 +143,7 @@ Q_OBJECT
|
||||
* 0 will be returned.
|
||||
*/
|
||||
int foregroundProcessGroup() const;
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
@ -152,7 +152,7 @@ Q_OBJECT
|
||||
void setUtf8Mode(bool on);
|
||||
|
||||
/**
|
||||
* Suspend or resume processing of data from the standard
|
||||
* Suspend or resume processing of data from the standard
|
||||
* output of the terminal process.
|
||||
*
|
||||
* See K3Process::suspend() and K3Process::resume()
|
||||
@ -161,9 +161,9 @@ Q_OBJECT
|
||||
* otherwise processing is resumed.
|
||||
*/
|
||||
void lockPty(bool lock);
|
||||
|
||||
/**
|
||||
* Sends data to the process currently controlling the
|
||||
|
||||
/**
|
||||
* Sends data to the process currently controlling the
|
||||
* teletype ( whose id is returned by foregroundProcessGroup() )
|
||||
*
|
||||
* @param buffer Pointer to the data to send.
|
||||
@ -181,14 +181,14 @@ Q_OBJECT
|
||||
* @param length Length of @p buffer
|
||||
*/
|
||||
void receivedData(const char* buffer, int length);
|
||||
|
||||
|
||||
protected:
|
||||
void setupChildProcess();
|
||||
|
||||
private slots:
|
||||
// called when data is received from the terminal process
|
||||
void dataReceived();
|
||||
|
||||
// called when data is received from the terminal process
|
||||
void dataReceived();
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
@ -196,7 +196,7 @@ Q_OBJECT
|
||||
// to the environment for the process
|
||||
void addEnvironmentVariables(const QStringList& environment);
|
||||
|
||||
int _windowColumns;
|
||||
int _windowColumns;
|
||||
int _windowLines;
|
||||
char _eraseChar;
|
||||
bool _xonXoff;
|
||||
|
@ -50,10 +50,10 @@
|
||||
|
||||
//Macro to convert x,y position on screen to position within an image.
|
||||
//
|
||||
//Originally the image was stored as one large contiguous block of
|
||||
//Originally the image was stored as one large contiguous block of
|
||||
//memory, so a position within the image could be represented as an
|
||||
//offset from the beginning of the block. For efficiency reasons this
|
||||
//is no longer the case.
|
||||
//is no longer the case.
|
||||
//Many internal parts of this class still use this representation for parameters and so on,
|
||||
//notably moveImage() and clearImage().
|
||||
//This macro converts from an X,Y position into an image offset.
|
||||
@ -198,14 +198,14 @@ void Screen::deleteChars(int n)
|
||||
Q_ASSERT( n >= 0 );
|
||||
|
||||
// always delete at least one char
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
|
||||
// if cursor is beyond the end of the line there is nothing to do
|
||||
if ( cuX >= screenLines[cuY].count() )
|
||||
return;
|
||||
|
||||
if ( cuX+n > screenLines[cuY].count() )
|
||||
if ( cuX+n > screenLines[cuY].count() )
|
||||
n = screenLines[cuY].count() - cuX;
|
||||
|
||||
Q_ASSERT( n >= 0 );
|
||||
@ -285,7 +285,7 @@ void Screen::restoreCursor()
|
||||
{
|
||||
cuX = qMin(savedState.cursorColumn,columns-1);
|
||||
cuY = qMin(savedState.cursorLine,lines-1);
|
||||
currentRendition = savedState.rendition;
|
||||
currentRendition = savedState.rendition;
|
||||
currentForeground = savedState.foreground;
|
||||
currentBackground = savedState.background;
|
||||
updateEffectiveRendition();
|
||||
@ -318,7 +318,7 @@ void Screen::resizeImage(int new_lines, int new_columns)
|
||||
|
||||
clearSelection();
|
||||
|
||||
delete[] screenLines;
|
||||
delete[] screenLines;
|
||||
screenLines = newScreenLines;
|
||||
|
||||
lines = new_lines;
|
||||
@ -375,11 +375,11 @@ void Screen::setDefaultMargins()
|
||||
*/
|
||||
|
||||
void Screen::reverseRendition(Character& p) const
|
||||
{
|
||||
CharacterColor f = p.foregroundColor;
|
||||
{
|
||||
CharacterColor f = p.foregroundColor;
|
||||
CharacterColor b = p.backgroundColor;
|
||||
|
||||
p.foregroundColor = b;
|
||||
p.foregroundColor = b;
|
||||
p.backgroundColor = f; //p->r &= ~RE_TRANSPARENT;
|
||||
}
|
||||
|
||||
@ -405,14 +405,14 @@ void Screen::copyFromHistory(Character* dest, int startLine, int count) const
|
||||
{
|
||||
Q_ASSERT( startLine >= 0 && count > 0 && startLine + count <= history->getLines() );
|
||||
|
||||
for (int line = startLine; line < startLine + count; line++)
|
||||
for (int line = startLine; line < startLine + count; line++)
|
||||
{
|
||||
const int length = qMin(columns,history->getLineLen(line));
|
||||
const int destLineOffset = (line-startLine)*columns;
|
||||
|
||||
history->getCells(line,0,length,dest + destLineOffset);
|
||||
|
||||
for (int column = length; column < columns; column++)
|
||||
for (int column = length; column < columns; column++)
|
||||
dest[destLineOffset+column] = defaultChar;
|
||||
|
||||
// invert selected text
|
||||
@ -420,9 +420,9 @@ void Screen::copyFromHistory(Character* dest, int startLine, int count) const
|
||||
{
|
||||
for (int column = 0; column < columns; column++)
|
||||
{
|
||||
if (isSelected(column,line))
|
||||
if (isSelected(column,line))
|
||||
{
|
||||
reverseRendition(dest[destLineOffset + column]);
|
||||
reverseRendition(dest[destLineOffset + column]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -439,15 +439,15 @@ void Screen::copyFromScreen(Character* dest , int startLine , int count) const
|
||||
int destLineStartIndex = (line-startLine)*columns;
|
||||
|
||||
for (int column = 0; column < columns; column++)
|
||||
{
|
||||
int srcIndex = srcLineStartIndex + column;
|
||||
{
|
||||
int srcIndex = srcLineStartIndex + column;
|
||||
int destIndex = destLineStartIndex + column;
|
||||
|
||||
dest[destIndex] = screenLines[srcIndex/columns].value(srcIndex%columns,defaultChar);
|
||||
|
||||
// invert selected text
|
||||
if (selBegin != -1 && isSelected(column,line + history->getLines()))
|
||||
reverseRendition(dest[destIndex]);
|
||||
reverseRendition(dest[destIndex]);
|
||||
}
|
||||
|
||||
}
|
||||
@ -460,7 +460,7 @@ void Screen::getImage( Character* dest, int size, int startLine, int endLine ) c
|
||||
|
||||
const int mergedLines = endLine - startLine + 1;
|
||||
|
||||
Q_ASSERT( size >= mergedLines * columns );
|
||||
Q_ASSERT( size >= mergedLines * columns );
|
||||
Q_UNUSED( size );
|
||||
|
||||
const int linesInHistoryBuffer = qBound(0,history->getLines()-startLine,mergedLines);
|
||||
@ -468,7 +468,7 @@ void Screen::getImage( Character* dest, int size, int startLine, int endLine ) c
|
||||
|
||||
// copy lines from history buffer
|
||||
if (linesInHistoryBuffer > 0)
|
||||
copyFromHistory(dest,startLine,linesInHistoryBuffer);
|
||||
copyFromHistory(dest,startLine,linesInHistoryBuffer);
|
||||
|
||||
// copy lines from screen buffer
|
||||
if (linesInScreenBuffer > 0)
|
||||
@ -491,7 +491,7 @@ void Screen::getImage( Character* dest, int size, int startLine, int endLine ) c
|
||||
|
||||
QVector<LineProperty> Screen::getLineProperties( int startLine , int endLine ) const
|
||||
{
|
||||
Q_ASSERT( startLine >= 0 );
|
||||
Q_ASSERT( startLine >= 0 );
|
||||
Q_ASSERT( endLine >= startLine && endLine < history->getLines() + lines );
|
||||
|
||||
const int mergedLines = endLine-startLine+1;
|
||||
@ -502,7 +502,7 @@ QVector<LineProperty> Screen::getLineProperties( int startLine , int endLine ) c
|
||||
int index = 0;
|
||||
|
||||
// copy properties for lines in history
|
||||
for (int line = startLine; line < startLine + linesInHistory; line++)
|
||||
for (int line = startLine; line < startLine + linesInHistory; line++)
|
||||
{
|
||||
//TODO Support for line properties other than wrapped lines
|
||||
if (history->isWrappedLine(line))
|
||||
@ -556,7 +556,7 @@ void Screen::backspace()
|
||||
if (screenLines[cuY].size() < cuX+1)
|
||||
screenLines[cuY].resize(cuX+1);
|
||||
|
||||
if (BS_CLEARS)
|
||||
if (BS_CLEARS)
|
||||
screenLines[cuY][cuX].character = ' ';
|
||||
}
|
||||
|
||||
@ -566,8 +566,8 @@ void Screen::tab(int n)
|
||||
if (n == 0) n = 1;
|
||||
while((n > 0) && (cuX < columns-1))
|
||||
{
|
||||
cursorRight(1);
|
||||
while((cuX < columns-1) && !tabStops[cuX])
|
||||
cursorRight(1);
|
||||
while((cuX < columns-1) && !tabStops[cuX])
|
||||
cursorRight(1);
|
||||
n--;
|
||||
}
|
||||
@ -602,20 +602,20 @@ void Screen::initTabStops()
|
||||
// Arrg! The 1st tabstop has to be one longer than the other.
|
||||
// i.e. the kids start counting from 0 instead of 1.
|
||||
// Other programs might behave correctly. Be aware.
|
||||
for (int i = 0; i < columns; i++)
|
||||
for (int i = 0; i < columns; i++)
|
||||
tabStops[i] = (i%8 == 0 && i != 0);
|
||||
}
|
||||
|
||||
void Screen::newLine()
|
||||
{
|
||||
if (getMode(MODE_NewLine))
|
||||
if (getMode(MODE_NewLine))
|
||||
toStartOfLine();
|
||||
index();
|
||||
}
|
||||
|
||||
void Screen::checkSelection(int from, int to)
|
||||
{
|
||||
if (selBegin == -1)
|
||||
if (selBegin == -1)
|
||||
return;
|
||||
int scr_TL = loc(0, history->getLines());
|
||||
//Clear entire selection if it overlaps region [from, to]
|
||||
@ -749,11 +749,11 @@ void Screen::scrollDown(int from, int n)
|
||||
_scrolledLines += n;
|
||||
|
||||
//FIXME: make sure `topMargin', `bottomMargin', `from', `n' is in bounds.
|
||||
if (n <= 0)
|
||||
if (n <= 0)
|
||||
return;
|
||||
if (from > _bottomMargin)
|
||||
if (from > _bottomMargin)
|
||||
return;
|
||||
if (from + n > _bottomMargin)
|
||||
if (from + n > _bottomMargin)
|
||||
n = _bottomMargin - from;
|
||||
moveImage(loc(0,from+n),loc(0,from),loc(columns-1,_bottomMargin-n));
|
||||
clearImage(loc(0,from),loc(columns-1,from+n-1),' ');
|
||||
@ -800,7 +800,7 @@ int Screen::getCursorY() const
|
||||
}
|
||||
|
||||
void Screen::clearImage(int loca, int loce, char c)
|
||||
{
|
||||
{
|
||||
int scr_TL=loc(0,history->getLines());
|
||||
//FIXME: check positions
|
||||
|
||||
@ -851,8 +851,8 @@ void Screen::moveImage(int dest, int sourceBegin, int sourceEnd)
|
||||
int lines=(sourceEnd-sourceBegin)/columns;
|
||||
|
||||
//move screen image and line properties:
|
||||
//the source and destination areas of the image may overlap,
|
||||
//so it matters that we do the copy in the right order -
|
||||
//the source and destination areas of the image may overlap,
|
||||
//so it matters that we do the copy in the right order -
|
||||
//forwards if dest < sourceBegin or backwards otherwise.
|
||||
//(search the web for 'memmove implementation' for details)
|
||||
if (dest < sourceBegin)
|
||||
@ -987,9 +987,9 @@ void Screen::setForeColor(int space, int color)
|
||||
{
|
||||
currentForeground = CharacterColor(space, color);
|
||||
|
||||
if ( currentForeground.isValid() )
|
||||
if ( currentForeground.isValid() )
|
||||
updateEffectiveRendition();
|
||||
else
|
||||
else
|
||||
setForeColor(COLOR_SPACE_DEFAULT,DEFAULT_FORE_COLOR);
|
||||
}
|
||||
|
||||
@ -997,13 +997,13 @@ void Screen::setBackColor(int space, int color)
|
||||
{
|
||||
currentBackground = CharacterColor(space, color);
|
||||
|
||||
if ( currentBackground.isValid() )
|
||||
if ( currentBackground.isValid() )
|
||||
updateEffectiveRendition();
|
||||
else
|
||||
setBackColor(COLOR_SPACE_DEFAULT,DEFAULT_BACK_COLOR);
|
||||
}
|
||||
|
||||
void Screen::clearSelection()
|
||||
void Screen::clearSelection()
|
||||
{
|
||||
selBottomRight = -1;
|
||||
selTopLeft = -1;
|
||||
@ -1015,7 +1015,7 @@ void Screen::getSelectionStart(int& column , int& line) const
|
||||
if ( selTopLeft != -1 )
|
||||
{
|
||||
column = selTopLeft % columns;
|
||||
line = selTopLeft / columns;
|
||||
line = selTopLeft / columns;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1034,11 +1034,11 @@ void Screen::getSelectionEnd(int& column , int& line) const
|
||||
{
|
||||
column = cuX + getHistLines();
|
||||
line = cuY + getHistLines();
|
||||
}
|
||||
}
|
||||
}
|
||||
void Screen::setSelectionStart(const int x, const int y, const bool mode)
|
||||
{
|
||||
selBegin = loc(x,y);
|
||||
selBegin = loc(x,y);
|
||||
/* FIXME, HACK to correct for x too far to the right... */
|
||||
if (x == columns) selBegin--;
|
||||
|
||||
@ -1049,10 +1049,10 @@ void Screen::setSelectionStart(const int x, const int y, const bool mode)
|
||||
|
||||
void Screen::setSelectionEnd( const int x, const int y)
|
||||
{
|
||||
if (selBegin == -1)
|
||||
if (selBegin == -1)
|
||||
return;
|
||||
|
||||
int endPos = loc(x,y);
|
||||
int endPos = loc(x,y);
|
||||
|
||||
if (endPos < selBegin)
|
||||
{
|
||||
@ -1062,7 +1062,7 @@ void Screen::setSelectionEnd( const int x, const int y)
|
||||
else
|
||||
{
|
||||
/* FIXME, HACK to correct for x too far to the right... */
|
||||
if (x == columns)
|
||||
if (x == columns)
|
||||
endPos--;
|
||||
|
||||
selTopLeft = selBegin;
|
||||
@ -1113,7 +1113,7 @@ bool Screen::isSelectionValid() const
|
||||
return selTopLeft >= 0 && selBottomRight >= 0;
|
||||
}
|
||||
|
||||
void Screen::writeSelectionToStream(TerminalCharacterDecoder* decoder ,
|
||||
void Screen::writeSelectionToStream(TerminalCharacterDecoder* decoder ,
|
||||
bool preserveLineBreaks) const
|
||||
{
|
||||
if (!isSelectionValid())
|
||||
@ -1121,11 +1121,11 @@ void Screen::writeSelectionToStream(TerminalCharacterDecoder* decoder ,
|
||||
writeToStream(decoder,selTopLeft,selBottomRight,preserveLineBreaks);
|
||||
}
|
||||
|
||||
void Screen::writeToStream(TerminalCharacterDecoder* decoder,
|
||||
void Screen::writeToStream(TerminalCharacterDecoder* decoder,
|
||||
int startIndex, int endIndex,
|
||||
bool preserveLineBreaks) const
|
||||
{
|
||||
int top = startIndex / columns;
|
||||
int top = startIndex / columns;
|
||||
int left = startIndex % columns;
|
||||
|
||||
int bottom = endIndex / columns;
|
||||
@ -1145,7 +1145,7 @@ void Screen::writeToStream(TerminalCharacterDecoder* decoder,
|
||||
int copied = copyLineToStream( y,
|
||||
start,
|
||||
count,
|
||||
decoder,
|
||||
decoder,
|
||||
appendNewLine,
|
||||
preserveLineBreaks );
|
||||
|
||||
@ -1153,25 +1153,25 @@ void Screen::writeToStream(TerminalCharacterDecoder* decoder,
|
||||
// append a new line character.
|
||||
//
|
||||
// this makes it possible to 'select' a trailing new line character after
|
||||
// the text on a line.
|
||||
if ( y == bottom &&
|
||||
// the text on a line.
|
||||
if ( y == bottom &&
|
||||
copied < count )
|
||||
{
|
||||
Character newLineChar('\n');
|
||||
decoder->decodeLine(&newLineChar,1,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Screen::copyLineToStream(int line ,
|
||||
int start,
|
||||
int Screen::copyLineToStream(int line ,
|
||||
int start,
|
||||
int count,
|
||||
TerminalCharacterDecoder* decoder,
|
||||
bool appendNewLine,
|
||||
bool preserveLineBreaks) const
|
||||
{
|
||||
//buffer to hold characters for decoding
|
||||
//the buffer is static to avoid initialising every
|
||||
//the buffer is static to avoid initialising every
|
||||
//element on each call to copyLineToStream
|
||||
//(which is unnecessary since all elements will be overwritten anyway)
|
||||
static const int MAX_CHARS = 1024;
|
||||
@ -1191,7 +1191,7 @@ int Screen::copyLineToStream(int line ,
|
||||
|
||||
// retrieve line from history buffer. It is assumed
|
||||
// that the history buffer does not store trailing white space
|
||||
// at the end of the line, so it does not need to be trimmed here
|
||||
// at the end of the line, so it does not need to be trimmed here
|
||||
if (count == -1)
|
||||
{
|
||||
count = lineLength-start;
|
||||
@ -1203,7 +1203,7 @@ int Screen::copyLineToStream(int line ,
|
||||
|
||||
// safety checks
|
||||
assert( start >= 0 );
|
||||
assert( count >= 0 );
|
||||
assert( count >= 0 );
|
||||
assert( (start+count) <= history->getLineLen(line) );
|
||||
|
||||
history->getCells(line,start,count,characterBuffer);
|
||||
@ -1233,7 +1233,7 @@ int Screen::copyLineToStream(int line ,
|
||||
count = qBound(0,count,length-start);
|
||||
|
||||
Q_ASSERT( screenLine < lineProperties.count() );
|
||||
currentLineProperties |= lineProperties[screenLine];
|
||||
currentLineProperties |= lineProperties[screenLine];
|
||||
}
|
||||
|
||||
// add new line character at end
|
||||
@ -1246,8 +1246,8 @@ int Screen::copyLineToStream(int line ,
|
||||
count++;
|
||||
}
|
||||
|
||||
//decode line and write to text stream
|
||||
decoder->decodeLine( (Character*) characterBuffer ,
|
||||
//decode line and write to text stream
|
||||
decoder->decodeLine( (Character*) characterBuffer ,
|
||||
count, currentLineProperties );
|
||||
|
||||
return count;
|
||||
|
@ -50,21 +50,21 @@ class TerminalCharacterDecoder;
|
||||
characters from the program currently running in the terminal.
|
||||
From this stream it creates an image of characters which is ultimately
|
||||
rendered by the display widget ( TerminalDisplay ). Some types of emulation
|
||||
may have more than one screen image.
|
||||
may have more than one screen image.
|
||||
|
||||
getImage() is used to retrieve the currently visible image
|
||||
which is then used by the display widget to draw the output from the
|
||||
terminal.
|
||||
terminal.
|
||||
|
||||
The number of lines of output history which are kept in addition to the current
|
||||
screen image depends on the history scroll being used to store the output.
|
||||
screen image depends on the history scroll being used to store the output.
|
||||
The scroll is specified using setScroll()
|
||||
The output history can be retrieved using writeToStream()
|
||||
|
||||
The screen image has a selection associated with it, specified using
|
||||
The screen image has a selection associated with it, specified using
|
||||
setSelectionStart() and setSelectionEnd(). The selected text can be retrieved
|
||||
using selectedText(). When getImage() is used to retrieve the visible image,
|
||||
characters which are part of the selection have their colours inverted.
|
||||
characters which are part of the selection have their colours inverted.
|
||||
*/
|
||||
class Screen
|
||||
{
|
||||
@ -73,25 +73,25 @@ public:
|
||||
Screen(int lines, int columns);
|
||||
~Screen();
|
||||
|
||||
// VT100/2 Operations
|
||||
// VT100/2 Operations
|
||||
// Cursor Movement
|
||||
|
||||
/**
|
||||
* Move the cursor up by @p n lines. The cursor will stop at the
|
||||
|
||||
/**
|
||||
* Move the cursor up by @p n lines. The cursor will stop at the
|
||||
* top margin.
|
||||
*/
|
||||
void cursorUp(int n);
|
||||
/**
|
||||
/**
|
||||
* Move the cursor down by @p n lines. The cursor will stop at the
|
||||
* bottom margin.
|
||||
*/
|
||||
void cursorDown(int n);
|
||||
/**
|
||||
/**
|
||||
* Move the cursor to the left by @p n columns.
|
||||
* The cursor will stop at the first column.
|
||||
*/
|
||||
void cursorLeft(int n);
|
||||
/**
|
||||
/**
|
||||
* Move the cursor to the right by @p n columns.
|
||||
* The cursor will stop at the right-most column.
|
||||
*/
|
||||
@ -105,28 +105,28 @@ public:
|
||||
/**
|
||||
* Sets the margins for scrolling the screen.
|
||||
*
|
||||
* @param topLine The top line of the new scrolling margin.
|
||||
* @param bottomLine The bottom line of the new scrolling margin.
|
||||
* @param topLine The top line of the new scrolling margin.
|
||||
* @param bottomLine The bottom line of the new scrolling margin.
|
||||
*/
|
||||
void setMargins(int topLine , int bottomLine);
|
||||
/** Returns the top line of the scrolling region. */
|
||||
/** Returns the top line of the scrolling region. */
|
||||
int topMargin() const;
|
||||
/** Returns the bottom line of the scrolling region. */
|
||||
int bottomMargin() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Resets the scrolling margins back to the top and bottom lines
|
||||
* of the screen.
|
||||
*/
|
||||
void setDefaultMargins();
|
||||
|
||||
/**
|
||||
* Moves the cursor down one line, if the MODE_NewLine mode
|
||||
|
||||
/**
|
||||
* Moves the cursor down one line, if the MODE_NewLine mode
|
||||
* flag is enabled then the cursor is returned to the leftmost
|
||||
* column first.
|
||||
*
|
||||
* Equivalent to NextLine() if the MODE_NewLine flag is set
|
||||
* or index() otherwise.
|
||||
* or index() otherwise.
|
||||
*/
|
||||
void newLine();
|
||||
/**
|
||||
@ -135,7 +135,7 @@ public:
|
||||
*/
|
||||
void nextLine();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Move the cursor down one line. If the cursor is on the bottom
|
||||
* line of the scrolling region (as returned by bottomMargin()) the
|
||||
* scrolling region is scrolled up by one line instead.
|
||||
@ -147,12 +147,12 @@ public:
|
||||
* region is scrolled down by one line instead.
|
||||
*/
|
||||
void reverseIndex();
|
||||
|
||||
/**
|
||||
* Scroll the scrolling region of the screen up by @p n lines.
|
||||
* The scrolling region is initially the whole screen, but can be changed
|
||||
|
||||
/**
|
||||
* Scroll the scrolling region of the screen up by @p n lines.
|
||||
* The scrolling region is initially the whole screen, but can be changed
|
||||
* using setMargins()
|
||||
*/
|
||||
*/
|
||||
void scrollUp(int n);
|
||||
/**
|
||||
* Scroll the scrolling region of the screen down by @p n lines.
|
||||
@ -160,12 +160,12 @@ public:
|
||||
* using setMargins()
|
||||
*/
|
||||
void scrollDown(int n);
|
||||
/**
|
||||
* Moves the cursor to the beginning of the current line.
|
||||
/**
|
||||
* Moves the cursor to the beginning of the current line.
|
||||
* Equivalent to setCursorX(0)
|
||||
*/
|
||||
void toStartOfLine();
|
||||
/**
|
||||
/**
|
||||
* Moves the cursor one column to the left and erases the character
|
||||
* at the new cursor position.
|
||||
*/
|
||||
@ -174,28 +174,28 @@ public:
|
||||
void tab(int n = 1);
|
||||
/** Moves the cursor @p n tab-stops to the left. */
|
||||
void backtab(int n);
|
||||
|
||||
|
||||
// Editing
|
||||
|
||||
/**
|
||||
* Erase @p n characters beginning from the current cursor position.
|
||||
|
||||
/**
|
||||
* Erase @p n characters beginning from the current cursor position.
|
||||
* This is equivalent to over-writing @p n characters starting with the current
|
||||
* cursor position with spaces.
|
||||
* If @p n is 0 then one character is erased.
|
||||
* If @p n is 0 then one character is erased.
|
||||
*/
|
||||
void eraseChars(int n);
|
||||
/**
|
||||
* Delete @p n characters beginning from the current cursor position.
|
||||
* If @p n is 0 then one character is deleted.
|
||||
/**
|
||||
* Delete @p n characters beginning from the current cursor position.
|
||||
* If @p n is 0 then one character is deleted.
|
||||
*/
|
||||
void deleteChars(int n);
|
||||
/**
|
||||
* Insert @p n blank characters beginning from the current cursor position.
|
||||
* The position of the cursor is not altered.
|
||||
* The position of the cursor is not altered.
|
||||
* If @p n is 0 then one character is inserted.
|
||||
*/
|
||||
void insertChars(int n);
|
||||
/**
|
||||
/**
|
||||
* Removes @p n lines beginning from the current cursor position.
|
||||
* The position of the cursor is not altered.
|
||||
* If @p n is 0 then one line is removed.
|
||||
@ -209,14 +209,14 @@ public:
|
||||
void insertLines(int n);
|
||||
/** Clears all the tab stops. */
|
||||
void clearTabStops();
|
||||
/** Sets or removes a tab stop at the cursor's current column. */
|
||||
/** Sets or removes a tab stop at the cursor's current column. */
|
||||
void changeTabStop(bool set);
|
||||
|
||||
|
||||
/** Resets (clears) the specified screen @p mode. */
|
||||
void resetMode(int mode);
|
||||
/** Sets (enables) the specified screen @p mode. */
|
||||
void setMode(int mode);
|
||||
/**
|
||||
/**
|
||||
* Saves the state of the specified screen @p mode. It can be restored
|
||||
* using restoreMode()
|
||||
*/
|
||||
@ -225,19 +225,19 @@ public:
|
||||
void restoreMode(int mode);
|
||||
/** Returns whether the specified screen @p mode is enabled or not .*/
|
||||
bool getMode(int mode) const;
|
||||
|
||||
/**
|
||||
* Saves the current position and appearance (text color and style) of the cursor.
|
||||
* It can be restored by calling restoreCursor()
|
||||
*/
|
||||
|
||||
/**
|
||||
* Saves the current position and appearance (text color and style) of the cursor.
|
||||
* It can be restored by calling restoreCursor()
|
||||
*/
|
||||
void saveCursor();
|
||||
/** Restores the position and appearance of the cursor. See saveCursor() */
|
||||
void restoreCursor();
|
||||
|
||||
/** Clear the whole screen, moving the current screen contents into the history first. */
|
||||
|
||||
/** Clear the whole screen, moving the current screen contents into the history first. */
|
||||
void clearEntireScreen();
|
||||
/**
|
||||
* Clear the area of the screen from the current cursor position to the end of
|
||||
/**
|
||||
* Clear the area of the screen from the current cursor position to the end of
|
||||
* the screen.
|
||||
*/
|
||||
void clearToEndOfScreen();
|
||||
@ -252,16 +252,16 @@ public:
|
||||
void clearToEndOfLine();
|
||||
/** Clears from the current cursor position to the beginning of the line. */
|
||||
void clearToBeginOfLine();
|
||||
|
||||
|
||||
/** Fills the entire screen with the letter 'E' */
|
||||
void helpAlign();
|
||||
|
||||
/**
|
||||
* Enables the given @p rendition flag. Rendition flags control the appearance
|
||||
|
||||
/**
|
||||
* Enables the given @p rendition flag. Rendition flags control the appearance
|
||||
* of characters on the screen.
|
||||
*
|
||||
* @see Character::rendition
|
||||
*/
|
||||
*/
|
||||
void setRendition(int rendition);
|
||||
/**
|
||||
* Disables the given @p rendition flag. Rendition flags control the appearance
|
||||
@ -270,8 +270,8 @@ public:
|
||||
* @see Character::rendition
|
||||
*/
|
||||
void resetRendition(int rendition);
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Sets the cursor's foreground color.
|
||||
* @param space The color space used by the @p color argument
|
||||
* @param color The new foreground color. The meaning of this depends on
|
||||
@ -289,24 +289,24 @@ public:
|
||||
* @see CharacterColor
|
||||
*/
|
||||
void setBackColor(int space, int color);
|
||||
/**
|
||||
* Resets the cursor's color back to the default and sets the
|
||||
/**
|
||||
* Resets the cursor's color back to the default and sets the
|
||||
* character's rendition flags back to the default settings.
|
||||
*/
|
||||
void setDefaultRendition();
|
||||
|
||||
|
||||
/** Returns the column which the cursor is positioned at. */
|
||||
int getCursorX() const;
|
||||
/** Returns the line which the cursor is positioned on. */
|
||||
int getCursorY() const;
|
||||
|
||||
|
||||
/** Clear the entire screen and move the cursor to the home position.
|
||||
* Equivalent to calling clearEntireScreen() followed by home().
|
||||
*/
|
||||
void clear();
|
||||
/**
|
||||
/**
|
||||
* Sets the position of the cursor to the 'home' position at the top-left
|
||||
* corner of the screen (0,0)
|
||||
* corner of the screen (0,0)
|
||||
*/
|
||||
void home();
|
||||
/**
|
||||
@ -323,41 +323,41 @@ public:
|
||||
* <li>New line mode is disabled. TODO Document me</li>
|
||||
* </ul>
|
||||
*
|
||||
* If @p clearScreen is true then the screen contents are erased entirely,
|
||||
* If @p clearScreen is true then the screen contents are erased entirely,
|
||||
* otherwise they are unaltered.
|
||||
*/
|
||||
void reset(bool clearScreen = true);
|
||||
|
||||
/**
|
||||
* Displays a new character at the current cursor position.
|
||||
*
|
||||
|
||||
/**
|
||||
* Displays a new character at the current cursor position.
|
||||
*
|
||||
* If the cursor is currently positioned at the right-edge of the screen and
|
||||
* line wrapping is enabled then the character is added at the start of a new
|
||||
* line wrapping is enabled then the character is added at the start of a new
|
||||
* line below the current one.
|
||||
*
|
||||
* If the MODE_Insert screen mode is currently enabled then the character
|
||||
* is inserted at the current cursor position, otherwise it will replace the
|
||||
* character already at the current cursor position.
|
||||
*/
|
||||
* If the MODE_Insert screen mode is currently enabled then the character
|
||||
* is inserted at the current cursor position, otherwise it will replace the
|
||||
* character already at the current cursor position.
|
||||
*/
|
||||
void displayCharacter(unsigned short c);
|
||||
|
||||
|
||||
// Do composition with last shown character FIXME: Not implemented yet for KDE 4
|
||||
void compose(const QString& compose);
|
||||
|
||||
/**
|
||||
* Resizes the image to a new fixed size of @p new_lines by @p new_columns.
|
||||
|
||||
/**
|
||||
* Resizes the image to a new fixed size of @p new_lines by @p new_columns.
|
||||
* In the case that @p new_columns is smaller than the current number of columns,
|
||||
* existing lines are not truncated. This prevents characters from being lost
|
||||
* if the terminal display is resized smaller and then larger again.
|
||||
*
|
||||
* The top and bottom margins are reset to the top and bottom of the new
|
||||
* The top and bottom margins are reset to the top and bottom of the new
|
||||
* screen size. Tab stops are also reset and the current selection is
|
||||
* cleared.
|
||||
*/
|
||||
void resizeImage(int new_lines, int new_columns);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current screen image.
|
||||
* Returns the current screen image.
|
||||
* The result is an array of Characters of size [getLines()][getColumns()] which
|
||||
* must be freed by the caller after use.
|
||||
*
|
||||
@ -368,38 +368,38 @@ public:
|
||||
*/
|
||||
void getImage( Character* dest , int size , int startLine , int endLine ) const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the additional attributes associated with lines in the image.
|
||||
* The most important attribute is LINE_WRAPPED which specifies that the
|
||||
* The most important attribute is LINE_WRAPPED which specifies that the
|
||||
* line is wrapped,
|
||||
* other attributes control the size of characters in the line.
|
||||
*/
|
||||
QVector<LineProperty> getLineProperties( int startLine , int endLine ) const;
|
||||
|
||||
|
||||
|
||||
/** Return the number of lines. */
|
||||
int getLines() const
|
||||
int getLines() const
|
||||
{ return lines; }
|
||||
/** Return the number of columns. */
|
||||
int getColumns() const
|
||||
int getColumns() const
|
||||
{ return columns; }
|
||||
/** Return the number of lines in the history buffer. */
|
||||
int getHistLines() const;
|
||||
/**
|
||||
* Sets the type of storage used to keep lines in the history.
|
||||
* If @p copyPreviousScroll is true then the contents of the previous
|
||||
/**
|
||||
* Sets the type of storage used to keep lines in the history.
|
||||
* If @p copyPreviousScroll is true then the contents of the previous
|
||||
* history buffer are copied into the new scroll.
|
||||
*/
|
||||
void setScroll(const HistoryType& , bool copyPreviousScroll = true);
|
||||
/** Returns the type of storage used to keep lines in the history. */
|
||||
const HistoryType& getScroll() const;
|
||||
/**
|
||||
/**
|
||||
* Returns true if this screen keeps lines that are scrolled off the screen
|
||||
* in a history buffer.
|
||||
*/
|
||||
bool hasScroll() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the start of the selection.
|
||||
*
|
||||
* @param column The column index of the first character in the selection.
|
||||
@ -407,21 +407,21 @@ public:
|
||||
* @param blockSelectionMode True if the selection is in column mode.
|
||||
*/
|
||||
void setSelectionStart(const int column, const int line, const bool blockSelectionMode);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the end of the current selection.
|
||||
*
|
||||
* @param column The column index of the last character in the selection.
|
||||
* @param line The line index of the last character in the selection.
|
||||
*/
|
||||
* @param line The line index of the last character in the selection.
|
||||
*/
|
||||
void setSelectionEnd(const int column, const int line);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the start of the selection or the cursor position if there
|
||||
* is no selection.
|
||||
*/
|
||||
void getSelectionStart(int& column , int& line) const;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the end of the selection or the cursor position if there
|
||||
* is no selection.
|
||||
@ -431,19 +431,19 @@ public:
|
||||
/** Clears the current selection */
|
||||
void clearSelection();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns true if the character at (@p column, @p line) is part of the
|
||||
* current selection.
|
||||
*/
|
||||
* current selection.
|
||||
*/
|
||||
bool isSelected(const int column,const int line) const;
|
||||
|
||||
/**
|
||||
* Convenience method. Returns the currently selected text.
|
||||
* @param preserveLineBreaks Specifies whether new line characters should
|
||||
/**
|
||||
* Convenience method. Returns the currently selected text.
|
||||
* @param preserveLineBreaks Specifies whether new line characters should
|
||||
* be inserted into the returned text at the end of each terminal line.
|
||||
*/
|
||||
QString selectedText(bool preserveLineBreaks) const;
|
||||
|
||||
|
||||
/**
|
||||
* Copies part of the output to a stream.
|
||||
*
|
||||
@ -457,11 +457,11 @@ public:
|
||||
* Copies the selected characters, set using @see setSelBeginXY and @see setSelExtentXY
|
||||
* into a stream.
|
||||
*
|
||||
* @param decoder A decoder which converts terminal characters into text.
|
||||
* PlainTextDecoder is the most commonly used decoder which converts characters
|
||||
* @param decoder A decoder which converts terminal characters into text.
|
||||
* PlainTextDecoder is the most commonly used decoder which converts characters
|
||||
* into plain text with no formatting.
|
||||
* @param preserveLineBreaks Specifies whether new line characters should
|
||||
* be inserted into the returned text at the end of each terminal line.
|
||||
* @param preserveLineBreaks Specifies whether new line characters should
|
||||
* be inserted into the returned text at the end of each terminal line.
|
||||
*/
|
||||
void writeSelectionToStream(TerminalCharacterDecoder* decoder , bool
|
||||
preserveLineBreaks = true) const;
|
||||
@ -478,15 +478,15 @@ public:
|
||||
*/
|
||||
void checkSelection(int from, int to);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets or clears an attribute of the current line.
|
||||
*
|
||||
*
|
||||
* @param property The attribute to set or clear
|
||||
* Possible properties are:
|
||||
* LINE_WRAPPED: Specifies that the line is wrapped.
|
||||
* LINE_DOUBLEWIDTH: Specifies that the characters in the current line
|
||||
* should be double the normal width.
|
||||
* LINE_DOUBLEHEIGHT:Specifies that the characters in the current line
|
||||
* LINE_DOUBLEHEIGHT:Specifies that the characters in the current line
|
||||
* should be double the normal height.
|
||||
* Double-height lines are formed of two lines containing the same characters,
|
||||
* with both having the LINE_DOUBLEHEIGHT attribute.
|
||||
@ -497,24 +497,24 @@ public:
|
||||
*/
|
||||
void setLineProperty(LineProperty property , bool enable);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the number of lines that the image has been scrolled up or down by,
|
||||
* since the last call to resetScrolledLines().
|
||||
*
|
||||
* a positive return value indicates that the image has been scrolled up,
|
||||
* a negative return value indicates that the image has been scrolled down.
|
||||
* a negative return value indicates that the image has been scrolled down.
|
||||
*/
|
||||
int scrolledLines() const;
|
||||
|
||||
/**
|
||||
* Returns the region of the image which was last scrolled.
|
||||
*
|
||||
* This is the area of the image from the top margin to the
|
||||
* This is the area of the image from the top margin to the
|
||||
* bottom margin when the last scroll occurred.
|
||||
*/
|
||||
QRect lastScrolledRegion() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Resets the count of the number of lines that the image has been scrolled up or down by,
|
||||
* see scrolledLines()
|
||||
*/
|
||||
@ -527,7 +527,7 @@ public:
|
||||
*
|
||||
* If the history is not unlimited then it will drop
|
||||
* the oldest lines of output if new lines are added when
|
||||
* it is full.
|
||||
* it is full.
|
||||
*/
|
||||
int droppedLines() const;
|
||||
|
||||
@ -537,32 +537,32 @@ public:
|
||||
*/
|
||||
void resetDroppedLines();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Fills the buffer @p dest with @p count instances of the default (ie. blank)
|
||||
* Character style.
|
||||
*/
|
||||
static void fillWithDefaultChar(Character* dest, int count);
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//copies a line of text from the screen or history into a stream using a
|
||||
//copies a line of text from the screen or history into a stream using a
|
||||
//specified character decoder. Returns the number of lines actually copied,
|
||||
//which may be less than 'count' if (start+count) is more than the number of characters on
|
||||
//the line
|
||||
//the line
|
||||
//
|
||||
//line - the line number to copy, from 0 (the earliest line in the history) up to
|
||||
//line - the line number to copy, from 0 (the earliest line in the history) up to
|
||||
// history->getLines() + lines - 1
|
||||
//start - the first column on the line to copy
|
||||
//count - the number of characters on the line to copy
|
||||
//decoder - a decoder which converts terminal characters (an Character array) into text
|
||||
//appendNewLine - if true a new line character (\n) is appended to the end of the line
|
||||
int copyLineToStream(int line,
|
||||
int start,
|
||||
int count,
|
||||
int copyLineToStream(int line,
|
||||
int start,
|
||||
int count,
|
||||
TerminalCharacterDecoder* decoder,
|
||||
bool appendNewLine,
|
||||
bool preserveLineBreaks) const;
|
||||
|
||||
|
||||
//fills a section of the screen image with the character 'c'
|
||||
//the parameters are specified as offsets from the start of the screen image.
|
||||
//the loc(x,y) macro can be used to generate these values from a column,line pair.
|
||||
@ -574,7 +574,7 @@ private:
|
||||
//
|
||||
//NOTE: moveImage() can only move whole lines
|
||||
void moveImage(int dest, int sourceBegin, int sourceEnd);
|
||||
// scroll up 'i' lines in current region, clearing the bottom 'i' lines
|
||||
// scroll up 'i' lines in current region, clearing the bottom 'i' lines
|
||||
void scrollUp(int from, int i);
|
||||
// scroll down 'i' lines in current region, clearing the top 'i' lines
|
||||
void scrollDown(int from, int i);
|
||||
@ -589,7 +589,7 @@ private:
|
||||
bool isSelectionValid() const;
|
||||
// copies text from 'startIndex' to 'endIndex' to a stream
|
||||
// startIndex and endIndex are positions generated using the loc(x,y) macro
|
||||
void writeToStream(TerminalCharacterDecoder* decoder, int startIndex,
|
||||
void writeToStream(TerminalCharacterDecoder* decoder, int startIndex,
|
||||
int endIndex, bool preserveLineBreaks = true) const;
|
||||
// copies 'count' lines from the screen buffer into 'dest',
|
||||
// starting from 'startLine', where 0 is the first line in the screen buffer
|
||||
@ -611,11 +611,11 @@ private:
|
||||
|
||||
int _droppedLines;
|
||||
|
||||
QVarLengthArray<LineProperty,64> lineProperties;
|
||||
|
||||
QVarLengthArray<LineProperty,64> lineProperties;
|
||||
|
||||
// history buffer ---------------
|
||||
HistoryScroll* history;
|
||||
|
||||
|
||||
// cursor location
|
||||
int cuX;
|
||||
int cuY;
|
||||
@ -623,7 +623,7 @@ private:
|
||||
// cursor color and rendition info
|
||||
CharacterColor currentForeground;
|
||||
CharacterColor currentBackground;
|
||||
quint8 currentRendition;
|
||||
quint8 currentRendition;
|
||||
|
||||
// margins ----------------
|
||||
int _topMargin;
|
||||
@ -648,7 +648,7 @@ private:
|
||||
CharacterColor effectiveBackground; // the cu_* variables above
|
||||
quint8 effectiveRendition; // to speed up operation
|
||||
|
||||
class SavedState
|
||||
class SavedState
|
||||
{
|
||||
public:
|
||||
SavedState()
|
||||
@ -661,7 +661,7 @@ private:
|
||||
CharacterColor background;
|
||||
};
|
||||
SavedState savedState;
|
||||
|
||||
|
||||
// last position where we added a character
|
||||
int lastPos;
|
||||
|
||||
|
@ -57,7 +57,7 @@ Character* ScreenWindow::getImage()
|
||||
{
|
||||
// reallocate internal buffer if the window size has changed
|
||||
int size = windowLines() * windowColumns();
|
||||
if (_windowBuffer == 0 || _windowBufferSize != size)
|
||||
if (_windowBuffer == 0 || _windowBufferSize != size)
|
||||
{
|
||||
delete[] _windowBuffer;
|
||||
_windowBufferSize = size;
|
||||
@ -67,11 +67,11 @@ Character* ScreenWindow::getImage()
|
||||
|
||||
if (!_bufferNeedsUpdate)
|
||||
return _windowBuffer;
|
||||
|
||||
|
||||
_screen->getImage(_windowBuffer,size,
|
||||
currentLine(),endWindowLine());
|
||||
|
||||
// this window may look beyond the end of the screen, in which
|
||||
// this window may look beyond the end of the screen, in which
|
||||
// case there will be an unused area which needs to be filled
|
||||
// with blank characters
|
||||
fillUnusedArea();
|
||||
@ -88,10 +88,10 @@ void ScreenWindow::fillUnusedArea()
|
||||
int unusedLines = windowEndLine - screenEndLine;
|
||||
int charsToFill = unusedLines * windowColumns();
|
||||
|
||||
Screen::fillWithDefaultChar(_windowBuffer + _windowBufferSize - charsToFill,charsToFill);
|
||||
Screen::fillWithDefaultChar(_windowBuffer + _windowBufferSize - charsToFill,charsToFill);
|
||||
}
|
||||
|
||||
// return the index of the line at the end of this window, or if this window
|
||||
// return the index of the line at the end of this window, or if this window
|
||||
// goes beyond the end of the screen, the index of the line at the end
|
||||
// of the screen.
|
||||
//
|
||||
@ -106,7 +106,7 @@ int ScreenWindow::endWindowLine() const
|
||||
QVector<LineProperty> ScreenWindow::getLineProperties()
|
||||
{
|
||||
QVector<LineProperty> result = _screen->getLineProperties(currentLine(),endWindowLine());
|
||||
|
||||
|
||||
if (result.count() != windowLines())
|
||||
result.resize(windowLines());
|
||||
|
||||
@ -131,7 +131,7 @@ void ScreenWindow::getSelectionEnd( int& column , int& line )
|
||||
void ScreenWindow::setSelectionStart( int column , int line , bool columnMode )
|
||||
{
|
||||
_screen->setSelectionStart( column , qMin(line + currentLine(),endWindowLine()) , columnMode);
|
||||
|
||||
|
||||
_bufferNeedsUpdate = true;
|
||||
emit selectionChanged();
|
||||
}
|
||||
@ -163,7 +163,7 @@ void ScreenWindow::setWindowLines(int lines)
|
||||
}
|
||||
int ScreenWindow::windowLines() const
|
||||
{
|
||||
return _windowLines;
|
||||
return _windowLines;
|
||||
}
|
||||
|
||||
int ScreenWindow::windowColumns() const
|
||||
@ -184,11 +184,11 @@ int ScreenWindow::columnCount() const
|
||||
QPoint ScreenWindow::cursorPosition() const
|
||||
{
|
||||
QPoint position;
|
||||
|
||||
|
||||
position.setX( _screen->getCursorX() );
|
||||
position.setY( _screen->getCursorY() );
|
||||
|
||||
return position;
|
||||
return position;
|
||||
}
|
||||
|
||||
int ScreenWindow::currentLine() const
|
||||
@ -204,7 +204,7 @@ void ScreenWindow::scrollBy( RelativeScrollMode mode , int amount )
|
||||
}
|
||||
else if ( mode == ScrollPages )
|
||||
{
|
||||
scrollTo( currentLine() + amount * ( windowLines() / 2 ) );
|
||||
scrollTo( currentLine() + amount * ( windowLines() / 2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ int ScreenWindow::scrollCount() const
|
||||
return _scrollCount;
|
||||
}
|
||||
|
||||
void ScreenWindow::resetScrollCount()
|
||||
void ScreenWindow::resetScrollCount()
|
||||
{
|
||||
_scrollCount = 0;
|
||||
}
|
||||
@ -265,18 +265,18 @@ void ScreenWindow::notifyOutputChanged()
|
||||
// move window to the bottom of the screen and update scroll count
|
||||
// if this window is currently tracking the bottom of the screen
|
||||
if ( _trackOutput )
|
||||
{
|
||||
{
|
||||
_scrollCount -= _screen->scrolledLines();
|
||||
_currentLine = qMax(0,_screen->getHistLines() - (windowLines()-_screen->getLines()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// if the history is not unlimited then it may
|
||||
// if the history is not unlimited then it may
|
||||
// have run out of space and dropped the oldest
|
||||
// lines of output - in this case the screen
|
||||
// window's current line number will need to
|
||||
// window's current line number will need to
|
||||
// be adjusted - otherwise the output will scroll
|
||||
_currentLine = qMax(0,_currentLine -
|
||||
_currentLine = qMax(0,_currentLine -
|
||||
_screen->droppedLines());
|
||||
|
||||
// ensure that the screen window's current position does
|
||||
@ -286,7 +286,7 @@ void ScreenWindow::notifyOutputChanged()
|
||||
|
||||
_bufferNeedsUpdate = true;
|
||||
|
||||
emit outputChanged();
|
||||
emit outputChanged();
|
||||
}
|
||||
|
||||
//#include "ScreenWindow.moc"
|
||||
|
@ -33,7 +33,7 @@ class Screen;
|
||||
|
||||
/**
|
||||
* Provides a window onto a section of a terminal screen. A terminal widget can then render
|
||||
* the contents of the window and use the window to change the terminal screen's selection
|
||||
* the contents of the window and use the window to change the terminal screen's selection
|
||||
* in response to mouse or keyboard input.
|
||||
*
|
||||
* A new ScreenWindow for a terminal session can be created by calling Emulation::createWindow()
|
||||
@ -53,7 +53,7 @@ class ScreenWindow : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* Constructs a new screen window with the given parent.
|
||||
* A screen must be specified by calling setScreen() before calling getImage() or getLineProperties().
|
||||
*
|
||||
@ -70,7 +70,7 @@ public:
|
||||
/** Returns the screen which this window looks onto */
|
||||
Screen* screen() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the image of characters which are currently visible through this window
|
||||
* onto the screen.
|
||||
*
|
||||
@ -87,14 +87,14 @@ public:
|
||||
|
||||
/**
|
||||
* Returns the number of lines which the region of the window
|
||||
* specified by scrollRegion() has been scrolled by since the last call
|
||||
* to resetScrollCount(). scrollRegion() is in most cases the
|
||||
* specified by scrollRegion() has been scrolled by since the last call
|
||||
* to resetScrollCount(). scrollRegion() is in most cases the
|
||||
* whole window, but will be a smaller area in, for example, applications
|
||||
* which provide split-screen facilities.
|
||||
*
|
||||
* This is not guaranteed to be accurate, but allows views to optimize
|
||||
* rendering by reducing the amount of costly text rendering that
|
||||
* needs to be done when the output is scrolled.
|
||||
* needs to be done when the output is scrolled.
|
||||
*/
|
||||
int scrollCount() const;
|
||||
|
||||
@ -104,7 +104,7 @@ public:
|
||||
void resetScrollCount();
|
||||
|
||||
/**
|
||||
* Returns the area of the window which was last scrolled, this is
|
||||
* Returns the area of the window which was last scrolled, this is
|
||||
* usually the whole window area.
|
||||
*
|
||||
* Like scrollCount(), this is not guaranteed to be accurate,
|
||||
@ -112,8 +112,8 @@ public:
|
||||
*/
|
||||
QRect scrollRegion() const;
|
||||
|
||||
/**
|
||||
* Sets the start of the selection to the given @p line and @p column within
|
||||
/**
|
||||
* Sets the start of the selection to the given @p line and @p column within
|
||||
* the window.
|
||||
*/
|
||||
void setSelectionStart( int column , int line , bool columnMode );
|
||||
@ -121,7 +121,7 @@ public:
|
||||
* Sets the end of the selection to the given @p line and @p column within
|
||||
* the window.
|
||||
*/
|
||||
void setSelectionEnd( int column , int line );
|
||||
void setSelectionEnd( int column , int line );
|
||||
/**
|
||||
* Retrieves the start of the selection within the window.
|
||||
*/
|
||||
@ -134,7 +134,7 @@ public:
|
||||
* Returns true if the character at @p line , @p column is part of the selection.
|
||||
*/
|
||||
bool isSelected( int column , int line );
|
||||
/**
|
||||
/**
|
||||
* Clears the current selection
|
||||
*/
|
||||
void clearSelection();
|
||||
@ -145,7 +145,7 @@ public:
|
||||
int windowLines() const;
|
||||
/** Returns the number of columns in the window */
|
||||
int windowColumns() const;
|
||||
|
||||
|
||||
/** Returns the total number of lines in the screen */
|
||||
int lineCount() const;
|
||||
/** Returns the total number of columns in the screen */
|
||||
@ -154,13 +154,13 @@ public:
|
||||
/** Returns the index of the line which is currently at the top of this window */
|
||||
int currentLine() const;
|
||||
|
||||
/**
|
||||
* Returns the position of the cursor
|
||||
/**
|
||||
* Returns the position of the cursor
|
||||
* within the window.
|
||||
*/
|
||||
QPoint cursorPosition() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Convenience method. Returns true if the window is currently at the bottom
|
||||
* of the screen.
|
||||
*/
|
||||
@ -174,33 +174,33 @@ public:
|
||||
{
|
||||
/** Scroll the window down by a given number of lines. */
|
||||
ScrollLines,
|
||||
/**
|
||||
/**
|
||||
* Scroll the window down by a given number of pages, where
|
||||
* one page is windowLines() lines
|
||||
*/
|
||||
ScrollPages
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* Scrolls the window relative to its current position on the screen.
|
||||
*
|
||||
* @param mode Specifies whether @p amount refers to the number of lines or the number
|
||||
* of pages to scroll.
|
||||
* of pages to scroll.
|
||||
* @param amount The number of lines or pages ( depending on @p mode ) to scroll by. If
|
||||
* this number is positive, the view is scrolled down. If this number is negative, the view
|
||||
* is scrolled up.
|
||||
*/
|
||||
void scrollBy( RelativeScrollMode mode , int amount );
|
||||
|
||||
/**
|
||||
/**
|
||||
* Specifies whether the window should automatically move to the bottom
|
||||
* of the screen when new output is added.
|
||||
*
|
||||
* If this is set to true, the window will be moved to the bottom of the associated screen ( see
|
||||
* If this is set to true, the window will be moved to the bottom of the associated screen ( see
|
||||
* screen() ) when the notifyOutputChanged() method is called.
|
||||
*/
|
||||
void setTrackOutput(bool trackOutput);
|
||||
/**
|
||||
/**
|
||||
* Returns whether the window automatically moves to the bottom of the screen as
|
||||
* new output is added. See setTrackOutput()
|
||||
*/
|
||||
@ -214,7 +214,7 @@ public:
|
||||
QString selectedText( bool preserveLineBreaks ) const;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
/**
|
||||
* Notifies the window that the contents of the associated terminal screen have changed.
|
||||
* This moves the window to the bottom of the screen if trackOutput() is true and causes
|
||||
* the outputChanged() signal to be emitted.
|
||||
@ -223,13 +223,13 @@ public slots:
|
||||
|
||||
signals:
|
||||
/**
|
||||
* Emitted when the contents of the associated terminal screen (see screen()) changes.
|
||||
* Emitted when the contents of the associated terminal screen (see screen()) changes.
|
||||
*/
|
||||
void outputChanged();
|
||||
|
||||
/**
|
||||
* Emitted when the screen window is scrolled to a different position.
|
||||
*
|
||||
*
|
||||
* @param line The line which is now at the top of the window.
|
||||
*/
|
||||
void scrolled(int line);
|
||||
@ -248,7 +248,7 @@ private:
|
||||
|
||||
int _windowLines;
|
||||
int _currentLine; // see scrollTo() , currentLine()
|
||||
bool _trackOutput; // see setTrackOutput() , trackOutput()
|
||||
bool _trackOutput; // see setTrackOutput() , trackOutput()
|
||||
int _scrollCount; // count of lines which the window has been scrolled by since
|
||||
// the last call to resetScrollCount()
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
This file is part of Konsole, an X terminal.
|
||||
|
||||
|
||||
Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>
|
||||
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
@ -84,7 +84,7 @@ void PlainTextDecoder::decodeLine(const Character* const characters, int count,
|
||||
//(since QTextStream always deals with QStrings internally anyway)
|
||||
QString plainText;
|
||||
plainText.reserve(count);
|
||||
|
||||
|
||||
int outputCount = count;
|
||||
|
||||
// if inclusion of trailing whitespace is disabled then find the end of the
|
||||
@ -99,7 +99,7 @@ void PlainTextDecoder::decodeLine(const Character* const characters, int count,
|
||||
outputCount--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i=0;i<outputCount;)
|
||||
{
|
||||
plainText.append( QChar(characters[i].character) );
|
||||
@ -114,7 +114,7 @@ HTMLDecoder::HTMLDecoder() :
|
||||
,_innerSpanOpen(false)
|
||||
,_lastRendition(DEFAULT_RENDITION)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void HTMLDecoder::begin(QTextStream* output)
|
||||
@ -152,7 +152,7 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP
|
||||
QString text;
|
||||
|
||||
int spaceCount = 0;
|
||||
|
||||
|
||||
for (int i=0;i<count;i++)
|
||||
{
|
||||
QChar ch(characters[i].character);
|
||||
@ -168,7 +168,7 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP
|
||||
_lastRendition = characters[i].rendition;
|
||||
_lastForeColor = characters[i].foregroundColor;
|
||||
_lastBackColor = characters[i].backgroundColor;
|
||||
|
||||
|
||||
//build up style string
|
||||
QString style;
|
||||
|
||||
@ -178,15 +178,15 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP
|
||||
useBold = _lastRendition & RE_BOLD;
|
||||
else
|
||||
useBold = weight == ColorEntry::Bold;
|
||||
|
||||
|
||||
if (useBold)
|
||||
style.append("font-weight:bold;");
|
||||
|
||||
if ( _lastRendition & RE_UNDERLINE )
|
||||
style.append("font-decoration:underline;");
|
||||
|
||||
|
||||
//colours - a colour table must have been defined first
|
||||
if ( _colorTable )
|
||||
if ( _colorTable )
|
||||
{
|
||||
style.append( QString("color:%1;").arg(_lastForeColor.color(_colorTable).name() ) );
|
||||
|
||||
@ -195,8 +195,8 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP
|
||||
style.append( QString("background-color:%1;").arg(_lastBackColor.color(_colorTable).name() ) );
|
||||
}
|
||||
}
|
||||
|
||||
//open the span with the current style
|
||||
|
||||
//open the span with the current style
|
||||
openSpan(text,style);
|
||||
_innerSpanOpen = true;
|
||||
}
|
||||
@ -206,7 +206,7 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP
|
||||
spaceCount++;
|
||||
else
|
||||
spaceCount = 0;
|
||||
|
||||
|
||||
|
||||
//output current character
|
||||
if (spaceCount < 2)
|
||||
@ -216,14 +216,14 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP
|
||||
text.append("<");
|
||||
else if (ch == '>')
|
||||
text.append(">");
|
||||
else
|
||||
else
|
||||
text.append(ch);
|
||||
}
|
||||
else
|
||||
{
|
||||
text.append(" "); //HTML truncates multiple spaces, so use a space marker instead
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//close any remaining open inner spans
|
||||
@ -232,7 +232,7 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP
|
||||
|
||||
//start new line
|
||||
text.append("<br>");
|
||||
|
||||
|
||||
*_output << text;
|
||||
}
|
||||
void HTMLDecoder::openSpan(QString& text , const QString& style)
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
This file is part of Konsole, an X terminal.
|
||||
|
||||
|
||||
Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>
|
||||
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
@ -37,7 +37,7 @@ class QTextStream;
|
||||
* and background colours and other appearance-related properties into text strings.
|
||||
*
|
||||
* Derived classes may produce either plain text with no other colour or appearance information, or
|
||||
* they may produce text which incorporates these additional properties.
|
||||
* they may produce text which incorporates these additional properties.
|
||||
*/
|
||||
class TerminalCharacterDecoder
|
||||
{
|
||||
@ -57,9 +57,9 @@ public:
|
||||
* @param count The number of characters
|
||||
* @param properties Additional properties which affect all characters in the line
|
||||
*/
|
||||
virtual void decodeLine(const Character* const characters,
|
||||
virtual void decodeLine(const Character* const characters,
|
||||
int count,
|
||||
LineProperty properties) = 0;
|
||||
LineProperty properties) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -69,10 +69,10 @@ public:
|
||||
class PlainTextDecoder : public TerminalCharacterDecoder
|
||||
{
|
||||
public:
|
||||
PlainTextDecoder();
|
||||
PlainTextDecoder();
|
||||
|
||||
/**
|
||||
* Set whether trailing whitespace at the end of lines should be included
|
||||
/**
|
||||
* Set whether trailing whitespace at the end of lines should be included
|
||||
* in the output.
|
||||
* Defaults to true.
|
||||
*/
|
||||
@ -82,9 +82,9 @@ public:
|
||||
* in the output.
|
||||
*/
|
||||
bool trailingWhitespace() const;
|
||||
/**
|
||||
/**
|
||||
* Returns of character positions in the output stream
|
||||
* at which new lines where added. Returns an empty if setTrackLinePositions() is false or if
|
||||
* at which new lines where added. Returns an empty if setTrackLinePositions() is false or if
|
||||
* the output device is not a string.
|
||||
*/
|
||||
QList<int> linePositions() const;
|
||||
@ -96,9 +96,9 @@ public:
|
||||
|
||||
virtual void decodeLine(const Character* const characters,
|
||||
int count,
|
||||
LineProperty properties);
|
||||
LineProperty properties);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
QTextStream* _output;
|
||||
bool _includeTrailingWhitespace;
|
||||
@ -113,7 +113,7 @@ private:
|
||||
class HTMLDecoder : public TerminalCharacterDecoder
|
||||
{
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* Constructs an HTML decoder using a default black-on-white color scheme.
|
||||
*/
|
||||
HTMLDecoder();
|
||||
@ -123,7 +123,7 @@ public:
|
||||
* output
|
||||
*/
|
||||
void setColorTable( const ColorEntry* table );
|
||||
|
||||
|
||||
virtual void decodeLine(const Character* const characters,
|
||||
int count,
|
||||
LineProperty properties);
|
||||
@ -137,7 +137,7 @@ private:
|
||||
|
||||
QTextStream* _output;
|
||||
const ColorEntry* _colorTable;
|
||||
bool _innerSpanOpen;
|
||||
bool _innerSpanOpen;
|
||||
quint8 _lastRendition;
|
||||
CharacterColor _lastForeColor;
|
||||
CharacterColor _lastBackColor;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of Konsole, an X terminal.
|
||||
|
||||
|
||||
Copyright 2007-2008 by Robert Knight <robert.knight@gmail.com>
|
||||
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
void scrolllock_set_on();
|
||||
#endif
|
||||
|
||||
// Standard
|
||||
// Standard
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
@ -55,7 +55,7 @@
|
||||
#include "KeyboardTranslator.h"
|
||||
#include "Screen.h"
|
||||
|
||||
Vt102Emulation::Vt102Emulation()
|
||||
Vt102Emulation::Vt102Emulation()
|
||||
: Emulation(),
|
||||
_titleUpdateTimer(new QTimer(this))
|
||||
{
|
||||
@ -72,7 +72,7 @@ Vt102Emulation::~Vt102Emulation()
|
||||
void Vt102Emulation::clearEntireScreen()
|
||||
{
|
||||
_currentScreen->clearEntireScreen();
|
||||
bufferedUpdate();
|
||||
bufferedUpdate();
|
||||
}
|
||||
|
||||
void Vt102Emulation::reset()
|
||||
@ -84,7 +84,7 @@ void Vt102Emulation::reset()
|
||||
resetCharset(1);
|
||||
_screen[1]->reset();
|
||||
setCodec(LocaleCodec);
|
||||
|
||||
|
||||
bufferedUpdate();
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ void Vt102Emulation::reset()
|
||||
- VT52 - VT52 escape codes
|
||||
- <ESC><Chr>
|
||||
- <ESC>'Y'{Pc}{Pc}
|
||||
- XTE_HA - Xterm window/terminal attribute commands
|
||||
- XTE_HA - Xterm window/terminal attribute commands
|
||||
of the form <ESC>`]' {Pn} `;' {Text} <BEL>
|
||||
(Note that these are handled differently to the other formats)
|
||||
|
||||
@ -175,9 +175,9 @@ void Vt102Emulation::reset()
|
||||
|
||||
void Vt102Emulation::resetTokenizer()
|
||||
{
|
||||
tokenBufferPos = 0;
|
||||
argc = 0;
|
||||
argv[0] = 0;
|
||||
tokenBufferPos = 0;
|
||||
argc = 0;
|
||||
argv[0] = 0;
|
||||
argv[1] = 0;
|
||||
}
|
||||
|
||||
@ -203,33 +203,33 @@ void Vt102Emulation::addToCurrentToken(int cc)
|
||||
|
||||
#define CTL 1 // Control character
|
||||
#define CHR 2 // Printable character
|
||||
#define CPN 4 // TODO: Document me
|
||||
#define CPN 4 // TODO: Document me
|
||||
#define DIG 8 // Digit
|
||||
#define SCS 16 // TODO: Document me
|
||||
#define SCS 16 // TODO: Document me
|
||||
#define GRP 32 // TODO: Document me
|
||||
#define CPS 64 // Character which indicates end of window resize
|
||||
// escape sequence '\e[8;<row>;<col>t'
|
||||
|
||||
void Vt102Emulation::initTokenizer()
|
||||
{
|
||||
int i;
|
||||
{
|
||||
int i;
|
||||
quint8* s;
|
||||
for(i = 0;i < 256; ++i)
|
||||
for(i = 0;i < 256; ++i)
|
||||
charClass[i] = 0;
|
||||
for(i = 0;i < 32; ++i)
|
||||
for(i = 0;i < 32; ++i)
|
||||
charClass[i] |= CTL;
|
||||
for(i = 32;i < 256; ++i)
|
||||
for(i = 32;i < 256; ++i)
|
||||
charClass[i] |= CHR;
|
||||
for(s = (quint8*)"@ABCDGHILMPSTXZcdfry"; *s; ++s)
|
||||
for(s = (quint8*)"@ABCDGHILMPSTXZcdfry"; *s; ++s)
|
||||
charClass[*s] |= CPN;
|
||||
// resize = \e[8;<row>;<col>t
|
||||
for(s = (quint8*)"t"; *s; ++s)
|
||||
for(s = (quint8*)"t"; *s; ++s)
|
||||
charClass[*s] |= CPS;
|
||||
for(s = (quint8*)"0123456789"; *s; ++s)
|
||||
for(s = (quint8*)"0123456789"; *s; ++s)
|
||||
charClass[*s] |= DIG;
|
||||
for(s = (quint8*)"()+*%"; *s; ++s)
|
||||
for(s = (quint8*)"()+*%"; *s; ++s)
|
||||
charClass[*s] |= SCS;
|
||||
for(s = (quint8*)"()+*#[]%"; *s; ++s)
|
||||
for(s = (quint8*)"()+*#[]%"; *s; ++s)
|
||||
charClass[*s] |= GRP;
|
||||
|
||||
resetTokenizer();
|
||||
@ -246,10 +246,10 @@ void Vt102Emulation::initTokenizer()
|
||||
- P is the length of the token scanned so far.
|
||||
- L (often P-1) is the position on which contents we base a decision.
|
||||
- C is a character or a group of characters (taken from 'charClass').
|
||||
|
||||
|
||||
- 'cc' is the current character
|
||||
- 's' is a pointer to the start of the token buffer
|
||||
- 'p' is the current position within the token buffer
|
||||
- 'p' is the current position within the token buffer
|
||||
|
||||
Note that they need to applied in proper order.
|
||||
*/
|
||||
@ -272,31 +272,31 @@ void Vt102Emulation::initTokenizer()
|
||||
|
||||
// process an incoming unicode character
|
||||
void Vt102Emulation::receiveChar(int cc)
|
||||
{
|
||||
if (cc == 127)
|
||||
{
|
||||
if (cc == 127)
|
||||
return; //VT100: ignore.
|
||||
|
||||
if (ces(CTL))
|
||||
{
|
||||
{
|
||||
// DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100
|
||||
// This means, they do neither a resetTokenizer() nor a pushToToken(). Some of them, do
|
||||
// of course. Guess this originates from a weakly layered handling of the X-on
|
||||
// X-off protocol, which comes really below this level.
|
||||
if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC)
|
||||
if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC)
|
||||
resetTokenizer(); //VT100: CAN or SUB
|
||||
if (cc != ESC)
|
||||
{
|
||||
processToken(TY_CTL(cc+'@' ),0,0);
|
||||
return;
|
||||
if (cc != ESC)
|
||||
{
|
||||
processToken(TY_CTL(cc+'@' ),0,0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// advance the state
|
||||
addToCurrentToken(cc);
|
||||
addToCurrentToken(cc);
|
||||
|
||||
int* s = tokenBuffer;
|
||||
int p = tokenBufferPos;
|
||||
|
||||
if (getMode(MODE_Ansi))
|
||||
if (getMode(MODE_Ansi))
|
||||
{
|
||||
if (lec(1,0,ESC)) { return; }
|
||||
if (lec(1,0,ESC+128)) { s[0] = ESC; receiveChar('['); return; }
|
||||
@ -313,11 +313,11 @@ void Vt102Emulation::receiveChar(int cc)
|
||||
if (eps( CPN)) { processToken( TY_CSI_PN(cc), argv[0],argv[1]); resetTokenizer(); return; }
|
||||
|
||||
// resize = \e[8;<row>;<col>t
|
||||
if (eps(CPS))
|
||||
{
|
||||
processToken( TY_CSI_PS(cc, argv[0]), argv[1], argv[2]);
|
||||
resetTokenizer();
|
||||
return;
|
||||
if (eps(CPS))
|
||||
{
|
||||
processToken( TY_CSI_PS(cc, argv[0]), argv[1], argv[2]);
|
||||
resetTokenizer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (epe( )) { processToken( TY_CSI_PE(cc), 0, 0); resetTokenizer(); return; }
|
||||
@ -325,19 +325,19 @@ void Vt102Emulation::receiveChar(int cc)
|
||||
if (eec(';')) { addArgument(); return; }
|
||||
for (int i=0;i<=argc;i++)
|
||||
{
|
||||
if (epp())
|
||||
if (epp())
|
||||
processToken( TY_CSI_PR(cc,argv[i]), 0, 0);
|
||||
else if (egt())
|
||||
else if (egt())
|
||||
processToken( TY_CSI_PG(cc), 0, 0); // spec. case for ESC]>0c or ESC]>c
|
||||
else if (cc == 'm' && argc - i >= 4 && (argv[i] == 38 || argv[i] == 48) && argv[i+1] == 2)
|
||||
{
|
||||
{
|
||||
// ESC[ ... 48;2;<red>;<green>;<blue> ... m -or- ESC[ ... 38;2;<red>;<green>;<blue> ... m
|
||||
i += 2;
|
||||
processToken( TY_CSI_PS(cc, argv[i-2]), COLOR_SPACE_RGB, (argv[i] << 16) | (argv[i+1] << 8) | argv[i+2]);
|
||||
i += 2;
|
||||
}
|
||||
else if (cc == 'm' && argc - i >= 2 && (argv[i] == 38 || argv[i] == 48) && argv[i+1] == 5)
|
||||
{
|
||||
{
|
||||
// ESC[ ... 48;5;<index> ... m -or- ESC[ ... 38;5;<index> ... m
|
||||
i += 2;
|
||||
processToken( TY_CSI_PS(cc, argv[i-2]), COLOR_SPACE_256, argv[i]);
|
||||
@ -347,29 +347,29 @@ void Vt102Emulation::receiveChar(int cc)
|
||||
}
|
||||
resetTokenizer();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// VT52 Mode
|
||||
if (lec(1,0,ESC))
|
||||
if (lec(1,0,ESC))
|
||||
return;
|
||||
if (les(1,0,CHR))
|
||||
{
|
||||
processToken( TY_CHR(), s[0], 0);
|
||||
resetTokenizer();
|
||||
return;
|
||||
if (les(1,0,CHR))
|
||||
{
|
||||
processToken( TY_CHR(), s[0], 0);
|
||||
resetTokenizer();
|
||||
return;
|
||||
}
|
||||
if (lec(2,1,'Y'))
|
||||
if (lec(2,1,'Y'))
|
||||
return;
|
||||
if (lec(3,1,'Y'))
|
||||
if (lec(3,1,'Y'))
|
||||
return;
|
||||
if (p < 4)
|
||||
{
|
||||
processToken( TY_VT52(s[1] ), 0, 0);
|
||||
resetTokenizer();
|
||||
return;
|
||||
if (p < 4)
|
||||
{
|
||||
processToken( TY_VT52(s[1] ), 0, 0);
|
||||
resetTokenizer();
|
||||
return;
|
||||
}
|
||||
processToken( TY_VT52(s[1]), s[2], s[3]);
|
||||
resetTokenizer();
|
||||
processToken( TY_VT52(s[1]), s[2], s[3]);
|
||||
resetTokenizer();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -379,24 +379,24 @@ void Vt102Emulation::processWindowAttributeChange()
|
||||
// See Session::UserTitleChange for possible values
|
||||
int attributeToChange = 0;
|
||||
int i;
|
||||
for (i = 2; i < tokenBufferPos &&
|
||||
tokenBuffer[i] >= '0' &&
|
||||
for (i = 2; i < tokenBufferPos &&
|
||||
tokenBuffer[i] >= '0' &&
|
||||
tokenBuffer[i] <= '9'; i++)
|
||||
{
|
||||
attributeToChange = 10 * attributeToChange + (tokenBuffer[i]-'0');
|
||||
}
|
||||
|
||||
if (tokenBuffer[i] != ';')
|
||||
{
|
||||
reportDecodingError();
|
||||
return;
|
||||
if (tokenBuffer[i] != ';')
|
||||
{
|
||||
reportDecodingError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QString newValue;
|
||||
newValue.reserve(tokenBufferPos-i-2);
|
||||
for (int j = 0; j < tokenBufferPos-i-2; j++)
|
||||
newValue[j] = tokenBuffer[i+1+j];
|
||||
|
||||
|
||||
_pendingTitleUpdates[attributeToChange] = newValue;
|
||||
_titleUpdateTimer->start(20);
|
||||
}
|
||||
@ -406,9 +406,9 @@ void Vt102Emulation::updateTitle()
|
||||
QListIterator<int> iter( _pendingTitleUpdates.keys() );
|
||||
while (iter.hasNext()) {
|
||||
int arg = iter.next();
|
||||
emit titleChanged( arg , _pendingTitleUpdates[arg] );
|
||||
emit titleChanged( arg , _pendingTitleUpdates[arg] );
|
||||
}
|
||||
_pendingTitleUpdates.clear();
|
||||
_pendingTitleUpdates.clear();
|
||||
}
|
||||
|
||||
// Interpreting Codes ---------------------------------------------------------
|
||||
@ -509,11 +509,11 @@ void Vt102Emulation::processToken(int token, int p, int q)
|
||||
case TY_ESC_CS('%', 'G') : setCodec (Utf8Codec ); break; //LINUX
|
||||
case TY_ESC_CS('%', '@') : setCodec (LocaleCodec ); break; //LINUX
|
||||
|
||||
case TY_ESC_DE('3' ) : /* Double height line, top half */
|
||||
case TY_ESC_DE('3' ) : /* Double height line, top half */
|
||||
_currentScreen->setLineProperty( LINE_DOUBLEWIDTH , true );
|
||||
_currentScreen->setLineProperty( LINE_DOUBLEHEIGHT , true );
|
||||
break;
|
||||
case TY_ESC_DE('4' ) : /* Double height line, bottom half */
|
||||
case TY_ESC_DE('4' ) : /* Double height line, bottom half */
|
||||
_currentScreen->setLineProperty( LINE_DOUBLEWIDTH , true );
|
||||
_currentScreen->setLineProperty( LINE_DOUBLEHEIGHT , true );
|
||||
break;
|
||||
@ -521,8 +521,8 @@ void Vt102Emulation::processToken(int token, int p, int q)
|
||||
_currentScreen->setLineProperty( LINE_DOUBLEWIDTH , false);
|
||||
_currentScreen->setLineProperty( LINE_DOUBLEHEIGHT , false);
|
||||
break;
|
||||
case TY_ESC_DE('6' ) : /* Double width, single height line*/
|
||||
_currentScreen->setLineProperty( LINE_DOUBLEWIDTH , true);
|
||||
case TY_ESC_DE('6' ) : /* Double width, single height line*/
|
||||
_currentScreen->setLineProperty( LINE_DOUBLEWIDTH , true);
|
||||
_currentScreen->setLineProperty( LINE_DOUBLEHEIGHT , false);
|
||||
break;
|
||||
case TY_ESC_DE('8' ) : _currentScreen->helpAlign ( ); break;
|
||||
@ -708,14 +708,14 @@ void Vt102Emulation::processToken(int token, int p, int q)
|
||||
// SET_BTN_EVENT_MOUSE 1002
|
||||
// SET_ANY_EVENT_MOUSE 1003
|
||||
//
|
||||
|
||||
|
||||
//Note about mouse modes:
|
||||
//There are four mouse modes which xterm-compatible terminals can support - 1000,1001,1002,1003
|
||||
//Konsole currently supports mode 1000 (basic mouse press and release) and mode 1002 (dragging the mouse).
|
||||
//TODO: Implementation of mouse modes 1001 (something called hilight tracking) and
|
||||
//TODO: Implementation of mouse modes 1001 (something called hilight tracking) and
|
||||
//1003 (a slight variation on dragging the mouse)
|
||||
//
|
||||
|
||||
|
||||
case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM
|
||||
case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM
|
||||
case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM
|
||||
@ -778,17 +778,17 @@ void Vt102Emulation::processToken(int token, int p, int q)
|
||||
|
||||
case TY_CSI_PG('c' ) : reportSecondaryAttributes( ); break; //VT100
|
||||
|
||||
default:
|
||||
reportDecodingError();
|
||||
default:
|
||||
reportDecodingError();
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
void Vt102Emulation::clearScreenAndSetColumns(int columnCount)
|
||||
{
|
||||
setImageSize(_currentScreen->getLines(),columnCount);
|
||||
setImageSize(_currentScreen->getLines(),columnCount);
|
||||
clearEntireScreen();
|
||||
setDefaultMargins();
|
||||
setDefaultMargins();
|
||||
_currentScreen->setCursorYX(0,0);
|
||||
}
|
||||
|
||||
@ -801,7 +801,7 @@ void Vt102Emulation::sendString(const char* s , int length)
|
||||
}
|
||||
|
||||
void Vt102Emulation::reportCursorPosition()
|
||||
{
|
||||
{
|
||||
char tmp[20];
|
||||
sprintf(tmp,"\033[%d;%dR",_currentScreen->getCursorY()+1,_currentScreen->getCursorX()+1);
|
||||
sendString(tmp);
|
||||
@ -832,7 +832,7 @@ void Vt102Emulation::reportSecondaryAttributes()
|
||||
|
||||
void Vt102Emulation::reportTerminalParms(int p)
|
||||
// DECREPTPARM
|
||||
{
|
||||
{
|
||||
char tmp[100];
|
||||
sprintf(tmp,"\033[%d;1;1;112;112;1;0x",p); // not really true.
|
||||
sendString(tmp);
|
||||
@ -882,11 +882,11 @@ void Vt102Emulation::sendMouseEvent( int cb, int cx, int cy , int eventType )
|
||||
|
||||
void Vt102Emulation::sendText( const QString& text )
|
||||
{
|
||||
if (!text.isEmpty())
|
||||
if (!text.isEmpty())
|
||||
{
|
||||
QKeyEvent event(QEvent::KeyPress,
|
||||
0,
|
||||
Qt::NoModifier,
|
||||
QKeyEvent event(QEvent::KeyPress,
|
||||
0,
|
||||
Qt::NoModifier,
|
||||
text);
|
||||
sendKeyEvent(&event); // expose as a big fat keypress event
|
||||
}
|
||||
@ -901,7 +901,7 @@ void Vt102Emulation::sendKeyEvent( QKeyEvent* event )
|
||||
if (getMode(MODE_Ansi) ) states |= KeyboardTranslator::AnsiState;
|
||||
if (getMode(MODE_AppCuKeys)) states |= KeyboardTranslator::CursorKeysState;
|
||||
if (getMode(MODE_AppScreen)) states |= KeyboardTranslator::AlternateScreenState;
|
||||
if (getMode(MODE_AppKeyPad) && (modifiers & Qt::KeypadModifier))
|
||||
if (getMode(MODE_AppKeyPad) && (modifiers & Qt::KeypadModifier))
|
||||
states |= KeyboardTranslator::ApplicationKeypadState;
|
||||
|
||||
// check flow control state
|
||||
@ -916,8 +916,8 @@ void Vt102Emulation::sendKeyEvent( QKeyEvent* event )
|
||||
// lookup key binding
|
||||
if ( _keyTranslator )
|
||||
{
|
||||
KeyboardTranslator::Entry entry = _keyTranslator->findEntry(
|
||||
event->key() ,
|
||||
KeyboardTranslator::Entry entry = _keyTranslator->findEntry(
|
||||
event->key() ,
|
||||
modifiers,
|
||||
states );
|
||||
|
||||
@ -929,10 +929,10 @@ void Vt102Emulation::sendKeyEvent( QKeyEvent* event )
|
||||
// (unless there is an entry defined for this particular combination
|
||||
// in the keyboard modifier)
|
||||
bool wantsAltModifier = entry.modifiers() & entry.modifierMask() & Qt::AltModifier;
|
||||
bool wantsAnyModifier = entry.state() &
|
||||
bool wantsAnyModifier = entry.state() &
|
||||
entry.stateMask() & KeyboardTranslator::AnyModifierState;
|
||||
|
||||
if ( modifiers & Qt::AltModifier && !(wantsAltModifier || wantsAnyModifier)
|
||||
if ( modifiers & Qt::AltModifier && !(wantsAltModifier || wantsAnyModifier)
|
||||
&& !event->text().isEmpty() )
|
||||
{
|
||||
textToSend.prepend("\033");
|
||||
@ -945,7 +945,7 @@ void Vt102Emulation::sendKeyEvent( QKeyEvent* event )
|
||||
|
||||
// TODO command handling
|
||||
}
|
||||
else if ( !entry.text().isEmpty() )
|
||||
else if ( !entry.text().isEmpty() )
|
||||
{
|
||||
textToSend += _codec->fromUnicode(entry.text(true,modifiers));
|
||||
}
|
||||
@ -960,7 +960,7 @@ void Vt102Emulation::sendKeyEvent( QKeyEvent* event )
|
||||
// set
|
||||
QString translatorError = tr("No keyboard translator available. "
|
||||
"The information needed to convert key presses "
|
||||
"into characters to send to the terminal "
|
||||
"into characters to send to the terminal "
|
||||
"is missing.");
|
||||
reset();
|
||||
receiveData( translatorError.toLatin1().constData() , translatorError.count() );
|
||||
@ -975,7 +975,7 @@ void Vt102Emulation::sendKeyEvent( QKeyEvent* event )
|
||||
|
||||
// Character Set Conversion ------------------------------------------------ --
|
||||
|
||||
/*
|
||||
/*
|
||||
The processing contains a VT100 specific code translation layer.
|
||||
It's still in use and mainly responsible for the line drawing graphics.
|
||||
|
||||
@ -986,7 +986,7 @@ void Vt102Emulation::sendKeyEvent( QKeyEvent* event )
|
||||
in the pipeline. It only applies to tokens, which represent
|
||||
plain characters.
|
||||
|
||||
This conversion it eventually continued in TerminalDisplay.C, since
|
||||
This conversion it eventually continued in TerminalDisplay.C, since
|
||||
it might involve VT100 enhanced fonts, which have these
|
||||
particular glyphs allocated in (0x00-0x1f) in their code page.
|
||||
*/
|
||||
@ -1121,7 +1121,7 @@ void Vt102Emulation::setMode(int m)
|
||||
case MODE_Mouse1001:
|
||||
case MODE_Mouse1002:
|
||||
case MODE_Mouse1003:
|
||||
emit programUsesMouseChanged(false);
|
||||
emit programUsesMouseChanged(false);
|
||||
break;
|
||||
|
||||
case MODE_AppScreen : _screen[1]->clearSelection();
|
||||
@ -1144,14 +1144,14 @@ void Vt102Emulation::resetMode(int m)
|
||||
if (getMode(MODE_Allow132Columns))
|
||||
clearScreenAndSetColumns(80);
|
||||
break;
|
||||
case MODE_Mouse1000 :
|
||||
case MODE_Mouse1000 :
|
||||
case MODE_Mouse1001 :
|
||||
case MODE_Mouse1002 :
|
||||
case MODE_Mouse1003 :
|
||||
emit programUsesMouseChanged(true);
|
||||
emit programUsesMouseChanged(true);
|
||||
break;
|
||||
|
||||
case MODE_AppScreen :
|
||||
case MODE_AppScreen :
|
||||
_screen[0]->clearSelection();
|
||||
setScreen(0);
|
||||
break;
|
||||
@ -1170,9 +1170,9 @@ void Vt102Emulation::saveMode(int m)
|
||||
|
||||
void Vt102Emulation::restoreMode(int m)
|
||||
{
|
||||
if (_savedModes.mode[m])
|
||||
setMode(m);
|
||||
else
|
||||
if (_savedModes.mode[m])
|
||||
setMode(m);
|
||||
else
|
||||
resetMode(m);
|
||||
}
|
||||
|
||||
@ -1210,10 +1210,10 @@ static void hexdump(int* s, int len)
|
||||
|
||||
void Vt102Emulation::reportDecodingError()
|
||||
{
|
||||
if (tokenBufferPos == 0 || ( tokenBufferPos == 1 && (tokenBuffer[0] & 0xff) >= 32) )
|
||||
if (tokenBufferPos == 0 || ( tokenBufferPos == 1 && (tokenBuffer[0] & 0xff) >= 32) )
|
||||
return;
|
||||
printf("Undecodable sequence: ");
|
||||
hexdump(tokenBuffer,tokenBufferPos);
|
||||
printf("Undecodable sequence: ");
|
||||
hexdump(tokenBuffer,tokenBufferPos);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of Konsole, an X terminal.
|
||||
|
||||
|
||||
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
|
||||
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
// Standard Library
|
||||
#include <stdio.h>
|
||||
|
||||
// Qt
|
||||
// Qt
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QTimer>
|
||||
@ -37,12 +37,12 @@
|
||||
|
||||
#define MODE_AppScreen (MODES_SCREEN+0) // Mode #1
|
||||
#define MODE_AppCuKeys (MODES_SCREEN+1) // Application cursor keys (DECCKM)
|
||||
#define MODE_AppKeyPad (MODES_SCREEN+2) //
|
||||
#define MODE_AppKeyPad (MODES_SCREEN+2) //
|
||||
#define MODE_Mouse1000 (MODES_SCREEN+3) // Send mouse X,Y position on press and release
|
||||
#define MODE_Mouse1001 (MODES_SCREEN+4) // Use Hilight mouse tracking
|
||||
#define MODE_Mouse1002 (MODES_SCREEN+5) // Use cell motion mouse tracking
|
||||
#define MODE_Mouse1003 (MODES_SCREEN+6) // Use all motion mouse tracking
|
||||
#define MODE_Ansi (MODES_SCREEN+7) // Use US Ascii for character sets G0-G3 (DECANM)
|
||||
#define MODE_Mouse1003 (MODES_SCREEN+6) // Use all motion mouse tracking
|
||||
#define MODE_Ansi (MODES_SCREEN+7) // Use US Ascii for character sets G0-G3 (DECANM)
|
||||
#define MODE_132Columns (MODES_SCREEN+8) // 80 <-> 132 column mode switch (DECCOLM)
|
||||
#define MODE_Allow132Columns (MODES_SCREEN+9) // Allow DECCOLM mode
|
||||
#define MODE_total (MODES_SCREEN+10)
|
||||
@ -62,40 +62,40 @@ struct CharCodes
|
||||
/**
|
||||
* Provides an xterm compatible terminal emulation based on the DEC VT102 terminal.
|
||||
* A full description of this terminal can be found at http://vt100.net/docs/vt102-ug/
|
||||
*
|
||||
* In addition, various additional xterm escape sequences are supported to provide
|
||||
*
|
||||
* In addition, various additional xterm escape sequences are supported to provide
|
||||
* features such as mouse input handling.
|
||||
* See http://rtfm.etla.org/xterm/ctlseq.html for a description of xterm's escape
|
||||
* sequences.
|
||||
* sequences.
|
||||
*
|
||||
*/
|
||||
class Vt102Emulation : public Emulation
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Constructs a new emulation */
|
||||
Vt102Emulation();
|
||||
~Vt102Emulation();
|
||||
|
||||
|
||||
// reimplemented from Emulation
|
||||
virtual void clearEntireScreen();
|
||||
virtual void reset();
|
||||
virtual char eraseChar() const;
|
||||
|
||||
public slots:
|
||||
// reimplemented from Emulation
|
||||
|
||||
public slots:
|
||||
// reimplemented from Emulation
|
||||
virtual void sendString(const char*,int length = -1);
|
||||
virtual void sendText(const QString& text);
|
||||
virtual void sendKeyEvent(QKeyEvent*);
|
||||
virtual void sendMouseEvent(int buttons, int column, int line, int eventType);
|
||||
|
||||
|
||||
protected:
|
||||
// reimplemented from Emulation
|
||||
virtual void setMode(int mode);
|
||||
virtual void resetMode(int mode);
|
||||
virtual void receiveChar(int cc);
|
||||
|
||||
|
||||
private slots:
|
||||
//causes changeTitle() to be emitted for each (int,QString) pair in pendingTitleUpdates
|
||||
//used to buffer multiple title updates
|
||||
@ -118,7 +118,7 @@ private:
|
||||
bool getMode (int mode);
|
||||
// saves the current boolean value of 'mode'
|
||||
void saveMode (int mode);
|
||||
// restores the boolean value of 'mode'
|
||||
// restores the boolean value of 'mode'
|
||||
void restoreMode(int mode);
|
||||
// resets all modes
|
||||
// (except MODE_Allow132Columns)
|
||||
@ -141,7 +141,7 @@ private:
|
||||
// for the purposes of decoding terminal output
|
||||
int charClass[256];
|
||||
|
||||
void reportDecodingError();
|
||||
void reportDecodingError();
|
||||
|
||||
void processToken(int code, int p, int q);
|
||||
void processWindowAttributeChange();
|
||||
@ -175,10 +175,10 @@ private:
|
||||
TerminalState _currentModes;
|
||||
TerminalState _savedModes;
|
||||
|
||||
//hash table and timer for buffering calls to the session instance
|
||||
//hash table and timer for buffering calls to the session instance
|
||||
//to update the name of the session
|
||||
//or window title.
|
||||
//these calls occur when certain escape sequences are seen in the
|
||||
//these calls occur when certain escape sequences are seen in the
|
||||
//output from the terminal
|
||||
QHash<int,QString> _pendingTitleUpdates;
|
||||
QTimer* _titleUpdateTimer;
|
||||
|
@ -38,7 +38,7 @@ class KProcessPrivate;
|
||||
|
||||
/**
|
||||
* \class KProcess kprocess.h <KProcess>
|
||||
*
|
||||
*
|
||||
* Child process invocation, monitoring and control.
|
||||
*
|
||||
* This class extends QProcess by some useful functionality, overrides
|
||||
|
@ -38,7 +38,7 @@ class KSession : public QObject
|
||||
public:
|
||||
KSession(QObject *parent = 0);
|
||||
~KSession();
|
||||
|
||||
|
||||
public:
|
||||
//bool setup();
|
||||
void addView(KTerminalDisplay *displa);
|
||||
|
Loading…
x
Reference in New Issue
Block a user