Merge lp:~g-bluehut/ubuntu-terminal-app/whitespacefix into lp:ubuntu-terminal-app

Proposed by Michael Vetter
Status: Merged
Approved by: Alan Pope 🍺🐧🐱 🦄
Approved revision: 102
Merged at revision: 103
Proposed branch: lp:~g-bluehut/ubuntu-terminal-app/whitespacefix
Merge into: lp:ubuntu-terminal-app
Diff against target: 5534 lines (+928/-928)
24 files modified
src/plugin/konsole/Character.h (+23/-23)
src/plugin/konsole/CharacterColor.h (+49/-49)
src/plugin/konsole/ColorScheme.cpp (+46/-46)
src/plugin/konsole/ColorScheme.h (+32/-32)
src/plugin/konsole/Emulation.cpp (+23/-23)
src/plugin/konsole/Emulation.h (+93/-93)
src/plugin/konsole/Filter.cpp (+19/-19)
src/plugin/konsole/Filter.h (+44/-44)
src/plugin/konsole/History.cpp (+34/-34)
src/plugin/konsole/History.h (+14/-14)
src/plugin/konsole/KeyboardTranslator.cpp (+32/-32)
src/plugin/konsole/KeyboardTranslator.h (+72/-72)
src/plugin/konsole/Pty.cpp (+16/-16)
src/plugin/konsole/Pty.h (+32/-32)
src/plugin/konsole/Screen.cpp (+60/-60)
src/plugin/konsole/Screen.h (+132/-132)
src/plugin/konsole/ScreenWindow.cpp (+17/-17)
src/plugin/konsole/ScreenWindow.h (+25/-25)
src/plugin/konsole/TerminalCharacterDecoder.cpp (+16/-16)
src/plugin/konsole/TerminalCharacterDecoder.h (+16/-16)
src/plugin/konsole/Vt102Emulation.cpp (+112/-112)
src/plugin/konsole/Vt102Emulation.h (+19/-19)
src/plugin/konsole/kprocess.h (+1/-1)
src/plugin/konsole/ksession.h (+1/-1)
To merge this branch: bzr merge lp:~g-bluehut/ubuntu-terminal-app/whitespacefix
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
David Planella Approve
Review via email: mp+228807@code.launchpad.net

Commit message

Fix superfluous trailing whitespace

To post a comment you must log in.
Revision history for this message
David Planella (dpm) wrote :

Looks good to me, thanks!

On future merge proposals, would you mind:

- Setting the commit message
- Setting the description

Have you gone through the development guide [1] and signed the contributor agreement?

Thank you!

[1] https://wiki.ubuntu.com/Touch/CoreApps/DevelopmentGuide

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/plugin/konsole/Character.h'
--- src/plugin/konsole/Character.h 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/Character.h 2014-07-30 09:50:10 +0000
@@ -1,6 +1,6 @@
1/*1/*
2 This file is part of Konsole, KDE's terminal.2 This file is part of Konsole, KDE's terminal.
3 3
4 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>4 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
5 Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>5 Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
66
@@ -53,7 +53,7 @@
53class Character53class Character
54{54{
55public:55public:
56 /** 56 /**
57 * Constructs a new character.57 * Constructs a new character.
58 *58 *
59 * @param _c The unicode character value of this character.59 * @param _c The unicode character value of this character.
@@ -71,25 +71,25 @@
71 {71 {
72 /** The unicode character value for this character. */72 /** The unicode character value for this character. */
73 quint16 character;73 quint16 character;
74 /** 74 /**
75 * Experimental addition which allows a single Character instance to contain more than75 * Experimental addition which allows a single Character instance to contain more than
76 * one unicode character.76 * one unicode character.
77 *77 *
78 * charSequence is a hash code which can be used to look up the unicode78 * charSequence is a hash code which can be used to look up the unicode
79 * character sequence in the ExtendedCharTable used to create the sequence.79 * character sequence in the ExtendedCharTable used to create the sequence.
80 */80 */
81 quint16 charSequence; 81 quint16 charSequence;
82 };82 };
8383
84 /** A combination of RENDITION flags which specify options for drawing the character. */84 /** A combination of RENDITION flags which specify options for drawing the character. */
85 quint8 rendition;85 quint8 rendition;
8686
87 /** The foreground color used to draw this character. */87 /** The foreground color used to draw this character. */
88 CharacterColor foregroundColor; 88 CharacterColor foregroundColor;
89 /** The color used to draw this character's background. */89 /** The color used to draw this character's background. */
90 CharacterColor backgroundColor;90 CharacterColor backgroundColor;
9191
92 /** 92 /**
93 * Returns true if this character has a transparent background when93 * Returns true if this character has a transparent background when
94 * it is drawn with the specified @p palette.94 * it is drawn with the specified @p palette.
95 */95 */
@@ -97,16 +97,16 @@
97 /**97 /**
98 * Returns true if this character should always be drawn in bold when98 * Returns true if this character should always be drawn in bold when
99 * it is drawn with the specified @p palette, independent of whether99 * it is drawn with the specified @p palette, independent of whether
100 * or not the character has the RE_BOLD rendition flag. 100 * or not the character has the RE_BOLD rendition flag.
101 */101 */
102 ColorEntry::FontWeight fontWeight(const ColorEntry* base) const;102 ColorEntry::FontWeight fontWeight(const ColorEntry* base) const;
103 103
104 /** 104 /**
105 * returns true if the format (color, rendition flag) of the compared characters is equal105 * returns true if the format (color, rendition flag) of the compared characters is equal
106 */106 */
107 bool equalsFormat(const Character &other) const;107 bool equalsFormat(const Character &other) const;
108108
109 /** 109 /**
110 * Compares two characters and returns true if they have the same unicode character value,110 * Compares two characters and returns true if they have the same unicode character value,
111 * rendition and colors.111 * rendition and colors.
112 */112 */
@@ -119,36 +119,36 @@
119};119};
120120
121inline bool operator == (const Character& a, const Character& b)121inline bool operator == (const Character& a, const Character& b)
122{ 122{
123 return a.character == b.character && 123 return a.character == b.character &&
124 a.rendition == b.rendition && 124 a.rendition == b.rendition &&
125 a.foregroundColor == b.foregroundColor && 125 a.foregroundColor == b.foregroundColor &&
126 a.backgroundColor == b.backgroundColor;126 a.backgroundColor == b.backgroundColor;
127}127}
128128
129inline bool operator != (const Character& a, const Character& b)129inline bool operator != (const Character& a, const Character& b)
130{130{
131 return a.character != b.character || 131 return a.character != b.character ||
132 a.rendition != b.rendition || 132 a.rendition != b.rendition ||
133 a.foregroundColor != b.foregroundColor || 133 a.foregroundColor != b.foregroundColor ||
134 a.backgroundColor != b.backgroundColor;134 a.backgroundColor != b.backgroundColor;
135}135}
136136
137inline bool Character::isTransparent(const ColorEntry* base) const137inline bool Character::isTransparent(const ColorEntry* base) const
138{138{
139 return ((backgroundColor._colorSpace == COLOR_SPACE_DEFAULT) && 139 return ((backgroundColor._colorSpace == COLOR_SPACE_DEFAULT) &&
140 base[backgroundColor._u+0+(backgroundColor._v?BASE_COLORS:0)].transparent)140 base[backgroundColor._u+0+(backgroundColor._v?BASE_COLORS:0)].transparent)
141 || ((backgroundColor._colorSpace == COLOR_SPACE_SYSTEM) && 141 || ((backgroundColor._colorSpace == COLOR_SPACE_SYSTEM) &&
142 base[backgroundColor._u+2+(backgroundColor._v?BASE_COLORS:0)].transparent);142 base[backgroundColor._u+2+(backgroundColor._v?BASE_COLORS:0)].transparent);
143}143}
144144
145inline bool Character::equalsFormat(const Character& other) const145inline bool Character::equalsFormat(const Character& other) const
146{146{
147 return 147 return
148 backgroundColor==other.backgroundColor &&148 backgroundColor==other.backgroundColor &&
149 foregroundColor==other.foregroundColor &&149 foregroundColor==other.foregroundColor &&
150 rendition==other.rendition;150 rendition==other.rendition;
151} 151}
152152
153inline ColorEntry::FontWeight Character::fontWeight(const ColorEntry* base) const153inline ColorEntry::FontWeight Character::fontWeight(const ColorEntry* base) const
154{154{
@@ -193,7 +193,7 @@
193 * which was added to the table using createExtendedChar().193 * which was added to the table using createExtendedChar().
194 *194 *
195 * @param hash The hash key returned by createExtendedChar()195 * @param hash The hash key returned by createExtendedChar()
196 * @param length This variable is set to the length of the 196 * @param length This variable is set to the length of the
197 * character sequence.197 * character sequence.
198 *198 *
199 * @return A unicode character sequence of size @p length.199 * @return A unicode character sequence of size @p length.
@@ -205,7 +205,7 @@
205private:205private:
206 // calculates the hash key of a sequence of unicode points of size 'length'206 // calculates the hash key of a sequence of unicode points of size 'length'
207 ushort extendedCharHash(ushort* unicodePoints , ushort length) const;207 ushort extendedCharHash(ushort* unicodePoints , ushort length) const;
208 // tests whether the entry in the table specified by 'hash' matches the 208 // tests whether the entry in the table specified by 'hash' matches the
209 // character sequence 'unicodePoints' of size 'length'209 // character sequence 'unicodePoints' of size 'length'
210 bool extendedCharMatch(ushort hash , ushort* unicodePoints , ushort length) const;210 bool extendedCharMatch(ushort hash , ushort* unicodePoints , ushort length) const;
211 // internal, maps hash keys to character sequence buffers. The first ushort211 // internal, maps hash keys to character sequence buffers. The first ushort
212212
=== modified file 'src/plugin/konsole/CharacterColor.h'
--- src/plugin/konsole/CharacterColor.h 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/CharacterColor.h 2014-07-30 09:50:10 +0000
@@ -1,6 +1,6 @@
1/*1/*
2 This file is part of Konsole, KDE's terminal.2 This file is part of Konsole, KDE's terminal.
3 3
4 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>4 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
5 Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>5 Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
66
@@ -29,14 +29,14 @@
29//#include <kdemacros.h>29//#include <kdemacros.h>
30#define KDE_NO_EXPORT30#define KDE_NO_EXPORT
3131
32/** 32/**
33 * An entry in a terminal display's color palette. 33 * An entry in a terminal display's color palette.
34 *34 *
35 * A color palette is an array of 16 ColorEntry instances which map35 * A color palette is an array of 16 ColorEntry instances which map
36 * system color indexes (from 0 to 15) into actual colors.36 * system color indexes (from 0 to 15) into actual colors.
37 *37 *
38 * Each entry can be set as bold, in which case any text38 * Each entry can be set as bold, in which case any text
39 * drawn using the color should be drawn in bold. 39 * drawn using the color should be drawn in bold.
40 *40 *
41 * Each entry can also be transparent, in which case the terminal41 * Each entry can also be transparent, in which case the terminal
42 * display should avoid drawing the background for any characters42 * display should avoid drawing the background for any characters
@@ -46,58 +46,58 @@
46{46{
47public:47public:
48 /** Specifies the weight to use when drawing text with this color. */48 /** Specifies the weight to use when drawing text with this color. */
49 enum FontWeight 49 enum FontWeight
50 {50 {
51 /** Always draw text in this color with a bold weight. */51 /** Always draw text in this color with a bold weight. */
52 Bold,52 Bold,
53 /** Always draw text in this color with a normal weight. */53 /** Always draw text in this color with a normal weight. */
54 Normal,54 Normal,
55 /** 55 /**
56 * Use the current font weight set by the terminal application. 56 * Use the current font weight set by the terminal application.
57 * This is the default behavior.57 * This is the default behavior.
58 */58 */
59 UseCurrentFormat59 UseCurrentFormat
60 };60 };
6161
62 /** 62 /**
63 * Constructs a new color palette entry.63 * Constructs a new color palette entry.
64 *64 *
65 * @param c The color value for this entry.65 * @param c The color value for this entry.
66 * @param tr Specifies that the color should be transparent when used as a background color.66 * @param tr Specifies that the color should be transparent when used as a background color.
67 * @param weight Specifies the font weight to use when drawing text with this color. 67 * @param weight Specifies the font weight to use when drawing text with this color.
68 */68 */
69 ColorEntry(QColor c, bool tr, FontWeight weight = UseCurrentFormat) 69 ColorEntry(QColor c, bool tr, FontWeight weight = UseCurrentFormat)
70 : color(c), transparent(tr), fontWeight(weight) {}70 : color(c), transparent(tr), fontWeight(weight) {}
7171
72 /**72 /**
73 * Constructs a new color palette entry with an undefined color, and73 * Constructs a new color palette entry with an undefined color, and
74 * with the transparent and bold flags set to false.74 * with the transparent and bold flags set to false.
75 */ 75 */
76 ColorEntry() : transparent(false), fontWeight(UseCurrentFormat) {} 76 ColorEntry() : transparent(false), fontWeight(UseCurrentFormat) {}
77 77
78 /**78 /**
79 * Sets the color, transparency and boldness of this color to those of @p rhs.79 * Sets the color, transparency and boldness of this color to those of @p rhs.
80 */ 80 */
81 void operator=(const ColorEntry& rhs) 81 void operator=(const ColorEntry& rhs)
82 { 82 {
83 color = rhs.color; 83 color = rhs.color;
84 transparent = rhs.transparent; 84 transparent = rhs.transparent;
85 fontWeight = rhs.fontWeight; 85 fontWeight = rhs.fontWeight;
86 }86 }
8787
88 /** The color value of this entry for display. */88 /** The color value of this entry for display. */
89 QColor color;89 QColor color;
9090
91 /** 91 /**
92 * If true character backgrounds using this color should be transparent. 92 * If true character backgrounds using this color should be transparent.
93 * This is not applicable when the color is used to render text.93 * This is not applicable when the color is used to render text.
94 */94 */
95 bool transparent;95 bool transparent;
96 /**96 /**
97 * Specifies the font weight to use when drawing text with this color. 97 * Specifies the font weight to use when drawing text with this color.
98 * This is not applicable when the color is used to draw a character's background.98 * This is not applicable when the color is used to draw a character's background.
99 */99 */
100 FontWeight fontWeight; 100 FontWeight fontWeight;
101};101};
102102
103103
@@ -148,15 +148,15 @@
148148
149public:149public:
150 /** Constructs a new CharacterColor whoose color and color space are undefined. */150 /** Constructs a new CharacterColor whoose color and color space are undefined. */
151 CharacterColor() 151 CharacterColor()
152 : _colorSpace(COLOR_SPACE_UNDEFINED), 152 : _colorSpace(COLOR_SPACE_UNDEFINED),
153 _u(0), 153 _u(0),
154 _v(0), 154 _v(0),
155 _w(0) 155 _w(0)
156 {}156 {}
157157
158 /** 158 /**
159 * Constructs a new CharacterColor using the specified @p colorSpace and with 159 * Constructs a new CharacterColor using the specified @p colorSpace and with
160 * color value @p co160 * color value @p co
161 *161 *
162 * The meaning of @p co depends on the @p colorSpace used.162 * The meaning of @p co depends on the @p colorSpace used.
@@ -165,10 +165,10 @@
165 *165 *
166 * TODO : Add documentation about available color spaces.166 * TODO : Add documentation about available color spaces.
167 */167 */
168 CharacterColor(quint8 colorSpace, int co) 168 CharacterColor(quint8 colorSpace, int co)
169 : _colorSpace(colorSpace), 169 : _colorSpace(colorSpace),
170 _u(0), 170 _u(0),
171 _v(0), 171 _v(0),
172 _w(0)172 _w(0)
173 {173 {
174 switch (colorSpace)174 switch (colorSpace)
@@ -180,7 +180,7 @@
180 _u = co & 7;180 _u = co & 7;
181 _v = (co >> 3) & 1;181 _v = (co >> 3) & 1;
182 break;182 break;
183 case COLOR_SPACE_256: 183 case COLOR_SPACE_256:
184 _u = co & 255;184 _u = co & 255;
185 break;185 break;
186 case COLOR_SPACE_RGB:186 case COLOR_SPACE_RGB:
@@ -193,32 +193,32 @@
193 }193 }
194 }194 }
195195
196 /** 196 /**
197 * Returns true if this character color entry is valid.197 * Returns true if this character color entry is valid.
198 */198 */
199 bool isValid() 199 bool isValid()
200 {200 {
201 return _colorSpace != COLOR_SPACE_UNDEFINED;201 return _colorSpace != COLOR_SPACE_UNDEFINED;
202 }202 }
203 203
204 /** 204 /**
205 * Toggles the value of this color between a normal system color and the corresponding intensive205 * Toggles the value of this color between a normal system color and the corresponding intensive
206 * system color.206 * system color.
207 * 207 *
208 * This is only applicable if the color is using the COLOR_SPACE_DEFAULT or COLOR_SPACE_SYSTEM208 * This is only applicable if the color is using the COLOR_SPACE_DEFAULT or COLOR_SPACE_SYSTEM
209 * color spaces.209 * color spaces.
210 */210 */
211 void toggleIntensive();211 void toggleIntensive();
212212
213 /** 213 /**
214 * Returns the color within the specified color @p palette214 * Returns the color within the specified color @p palette
215 *215 *
216 * The @p palette is only used if this color is one of the 16 system colors, otherwise216 * The @p palette is only used if this color is one of the 16 system colors, otherwise
217 * it is ignored.217 * it is ignored.
218 */218 */
219 QColor color(const ColorEntry* palette) const;219 QColor color(const ColorEntry* palette) const;
220 220
221 /** 221 /**
222 * Compares two colors and returns true if they represent the same color value and222 * Compares two colors and returns true if they represent the same color value and
223 * use the same color space.223 * use the same color space.
224 */224 */
@@ -232,14 +232,14 @@
232private:232private:
233 quint8 _colorSpace;233 quint8 _colorSpace;
234234
235 // bytes storing the character color 235 // bytes storing the character color
236 quint8 _u; 236 quint8 _u;
237 quint8 _v; 237 quint8 _v;
238 quint8 _w; 238 quint8 _w;
239};239};
240240
241inline bool operator == (const CharacterColor& a, const CharacterColor& b)241inline bool operator == (const CharacterColor& a, const CharacterColor& b)
242{ 242{
243 return a._colorSpace == b._colorSpace &&243 return a._colorSpace == b._colorSpace &&
244 a._u == b._u &&244 a._u == b._u &&
245 a._v == b._v &&245 a._v == b._v &&
@@ -260,7 +260,7 @@
260 if (u < 216) return QColor(((u/36)%6) ? (40*((u/36)%6)+55) : 0,260 if (u < 216) return QColor(((u/36)%6) ? (40*((u/36)%6)+55) : 0,
261 ((u/ 6)%6) ? (40*((u/ 6)%6)+55) : 0,261 ((u/ 6)%6) ? (40*((u/ 6)%6)+55) : 0,
262 ((u/ 1)%6) ? (40*((u/ 1)%6)+55) : 0); u -= 216;262 ((u/ 1)%6) ? (40*((u/ 1)%6)+55) : 0); u -= 216;
263 263
264 // 232..255: gray, leaving out black and white264 // 232..255: gray, leaving out black and white
265 int gray = u*10+8; return QColor(gray,gray,gray);265 int gray = u*10+8; return QColor(gray,gray,gray);
266}266}
267267
=== modified file 'src/plugin/konsole/ColorScheme.cpp'
--- src/plugin/konsole/ColorScheme.cpp 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/ColorScheme.cpp 2014-07-30 09:50:10 +0000
@@ -163,15 +163,15 @@
163{163{
164 Q_ASSERT( index >= 0 && index < TABLE_COLORS );164 Q_ASSERT( index >= 0 && index < TABLE_COLORS );
165165
166 if ( !_table ) 166 if ( !_table )
167 {167 {
168 _table = new ColorEntry[TABLE_COLORS];168 _table = new ColorEntry[TABLE_COLORS];
169169
170 for (int i=0;i<TABLE_COLORS;i++)170 for (int i=0;i<TABLE_COLORS;i++)
171 _table[i] = defaultTable[i];171 _table[i] = defaultTable[i];
172 }172 }
173 173
174 _table[index] = entry; 174 _table[index] = entry;
175}175}
176ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const176ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const
177{177{
@@ -182,19 +182,19 @@
182182
183 ColorEntry entry = colorTable()[index];183 ColorEntry entry = colorTable()[index];
184184
185 if ( randomSeed != 0 && 185 if ( randomSeed != 0 &&
186 _randomTable != 0 && 186 _randomTable != 0 &&
187 !_randomTable[index].isNull() )187 !_randomTable[index].isNull() )
188 {188 {
189 const RandomizationRange& range = _randomTable[index];189 const RandomizationRange& range = _randomTable[index];
190 190
191191
192 int hueDifference = range.hue ? (qrand() % range.hue) - range.hue/2 : 0;192 int hueDifference = range.hue ? (qrand() % range.hue) - range.hue/2 : 0;
193 int saturationDifference = range.saturation ? (qrand() % range.saturation) - range.saturation/2 : 0;193 int saturationDifference = range.saturation ? (qrand() % range.saturation) - range.saturation/2 : 0;
194 int valueDifference = range.value ? (qrand() % range.value) - range.value/2 : 0;194 int valueDifference = range.value ? (qrand() % range.value) - range.value/2 : 0;
195195
196 QColor& color = entry.color;196 QColor& color = entry.color;
197 197
198 int newHue = qAbs( (color.hue() + hueDifference) % MAX_HUE );198 int newHue = qAbs( (color.hue() + hueDifference) % MAX_HUE );
199 int newValue = qMin( qAbs(color.value() + valueDifference) , 255 );199 int newValue = qMin( qAbs(color.value() + valueDifference) , 255 );
200 int newSaturation = qMin( qAbs(color.saturation() + saturationDifference) , 255 );200 int newSaturation = qMin( qAbs(color.saturation() + saturationDifference) , 255 );
@@ -215,13 +215,13 @@
215}215}
216void ColorScheme::setRandomizedBackgroundColor(bool randomize)216void ColorScheme::setRandomizedBackgroundColor(bool randomize)
217{217{
218 // the hue of the background colour is allowed to be randomly 218 // the hue of the background colour is allowed to be randomly
219 // adjusted as much as possible.219 // adjusted as much as possible.
220 //220 //
221 // the value and saturation are left alone to maintain read-ability221 // the value and saturation are left alone to maintain read-ability
222 if ( randomize )222 if ( randomize )
223 {223 {
224 setRandomizationRange( 1 /* background color index */ , MAX_HUE , 255 , 0 ); 224 setRandomizationRange( 1 /* background color index */ , MAX_HUE , 255 , 0 );
225 }225 }
226 else226 else
227 {227 {
@@ -304,7 +304,7 @@
304304
305 configGroup.writeEntry("Description",_description);305 configGroup.writeEntry("Description",_description);
306 configGroup.writeEntry("Opacity",_opacity);306 configGroup.writeEntry("Opacity",_opacity);
307 307
308 for (int i=0 ; i < TABLE_COLORS ; i++)308 for (int i=0 ; i < TABLE_COLORS ; i++)
309 {309 {
310 RandomizationRange random = _randomTable != 0 ? _randomTable[i] : RandomizationRange();310 RandomizationRange random = _randomTable != 0 ? _randomTable[i] : RandomizationRange();
@@ -313,13 +313,13 @@
313}313}
314#endif314#endif
315315
316QString ColorScheme::colorNameForIndex(int index) 316QString ColorScheme::colorNameForIndex(int index)
317{317{
318 Q_ASSERT( index >= 0 && index < TABLE_COLORS );318 Q_ASSERT( index >= 0 && index < TABLE_COLORS );
319319
320 return QString(colorNames[index]);320 return QString(colorNames[index]);
321}321}
322QString ColorScheme::translatedColorNameForIndex(int index) 322QString ColorScheme::translatedColorNameForIndex(int index)
323{323{
324 Q_ASSERT( index >= 0 && index < TABLE_COLORS );324 Q_ASSERT( index >= 0 && index < TABLE_COLORS );
325325
@@ -329,7 +329,7 @@
329void ColorScheme::readColorEntry(QSettings * s , int index)329void ColorScheme::readColorEntry(QSettings * s , int index)
330{330{
331 s->beginGroup(colorNameForIndex(index));331 s->beginGroup(colorNameForIndex(index));
332 332
333 ColorEntry entry;333 ColorEntry entry;
334334
335 QStringList rgbList = s->value("Color", QStringList()).toStringList();335 QStringList rgbList = s->value("Color", QStringList()).toStringList();
@@ -342,7 +342,7 @@
342 g = rgbList[1].toInt();342 g = rgbList[1].toInt();
343 b = rgbList[2].toInt();343 b = rgbList[2].toInt();
344 entry.color = QColor(r, g, b);344 entry.color = QColor(r, g, b);
345 345
346 entry.transparent = s->value("Transparent",false).toBool();346 entry.transparent = s->value("Transparent",false).toBool();
347347
348 // Deprecated key from KDE 4.0 which set 'Bold' to true to force348 // Deprecated key from KDE 4.0 which set 'Bold' to true to force
@@ -361,7 +361,7 @@
361 setColorTableEntry( index , entry );361 setColorTableEntry( index , entry );
362362
363 if ( hue != 0 || value != 0 || saturation != 0 )363 if ( hue != 0 || value != 0 || saturation != 0 )
364 setRandomizationRange( index , hue , saturation , value ); 364 setRandomizationRange( index , hue , saturation , value );
365365
366 s->endGroup();366 s->endGroup();
367}367}
@@ -378,8 +378,8 @@
378 configGroup.writeEntry("Bold",entry.fontWeight == ColorEntry::Bold);378 configGroup.writeEntry("Bold",entry.fontWeight == ColorEntry::Bold);
379 }379 }
380380
381 // record randomization if this color has randomization or 381 // record randomization if this color has randomization or
382 // if one of the keys already exists 382 // if one of the keys already exists
383 if ( !random.isNull() || configGroup.hasKey("MaxRandomHue") )383 if ( !random.isNull() || configGroup.hasKey("MaxRandomHue") )
384 {384 {
385 configGroup.writeEntry("MaxRandomHue",(int)random.hue);385 configGroup.writeEntry("MaxRandomHue",(int)random.hue);
@@ -389,28 +389,28 @@
389}389}
390#endif390#endif
391391
392// 392//
393// Work In Progress - A color scheme for use on KDE setups for users393// Work In Progress - A color scheme for use on KDE setups for users
394// with visual disabilities which means that they may have trouble394// with visual disabilities which means that they may have trouble
395// reading text with the supplied color schemes.395// reading text with the supplied color schemes.
396//396//
397// This color scheme uses only the 'safe' colors defined by the397// This color scheme uses only the 'safe' colors defined by the
398// KColorScheme class. 398// KColorScheme class.
399//399//
400// A complication this introduces is that each color provided by 400// A complication this introduces is that each color provided by
401// KColorScheme is defined as a 'background' or 'foreground' color.401// KColorScheme is defined as a 'background' or 'foreground' color.
402// Only foreground colors are allowed to be used to render text and 402// Only foreground colors are allowed to be used to render text and
403// only background colors are allowed to be used for backgrounds.403// only background colors are allowed to be used for backgrounds.
404//404//
405// The ColorEntry and TerminalDisplay classes do not currently405// The ColorEntry and TerminalDisplay classes do not currently
406// support this restriction. 406// support this restriction.
407//407//
408// Requirements:408// Requirements:
409// - A color scheme which uses only colors from the KColorScheme class409// - A color scheme which uses only colors from the KColorScheme class
410// - Ability to restrict which colors the TerminalDisplay widget 410// - Ability to restrict which colors the TerminalDisplay widget
411// uses as foreground and background color411// uses as foreground and background color
412// - Make use of KGlobalSettings::allowDefaultBackgroundImages() as412// - Make use of KGlobalSettings::allowDefaultBackgroundImages() as
413// a hint to determine whether this accessible color scheme should 413// a hint to determine whether this accessible color scheme should
414// be used by default.414// be used by default.
415//415//
416//416//
@@ -443,13 +443,13 @@
443 colorScheme.foreground( colorScheme.NeutralText )443 colorScheme.foreground( colorScheme.NeutralText )
444 };444 };
445445
446 for ( int i = 0 ; i < TABLE_COLORS ; i++ ) 446 for ( int i = 0 ; i < TABLE_COLORS ; i++ )
447 {447 {
448 ColorEntry entry;448 ColorEntry entry;
449 entry.color = colors[ i % ColorRoleCount ].color();449 entry.color = colors[ i % ColorRoleCount ].color();
450450
451 setColorTableEntry( i , entry ); 451 setColorTableEntry( i , entry );
452 } 452 }
453#endif453#endif
454}454}
455455
@@ -457,7 +457,7 @@
457 _device(device)457 _device(device)
458{458{
459}459}
460ColorScheme* KDE3ColorSchemeReader::read() 460ColorScheme* KDE3ColorSchemeReader::read()
461{461{
462 Q_ASSERT( _device->openMode() == QIODevice::ReadOnly ||462 Q_ASSERT( _device->openMode() == QIODevice::ReadOnly ||
463 _device->openMode() == QIODevice::ReadWrite );463 _device->openMode() == QIODevice::ReadWrite );
@@ -488,7 +488,7 @@
488 {488 {
489 qDebug() << "KDE 3 color scheme contains an unsupported feature, '" <<489 qDebug() << "KDE 3 color scheme contains an unsupported feature, '" <<
490 line << "'";490 line << "'";
491 } 491 }
492 }492 }
493493
494 return scheme;494 return scheme;
@@ -501,7 +501,7 @@
501 return false;501 return false;
502 if (list.first() != "color")502 if (list.first() != "color")
503 return false;503 return false;
504 504
505 int index = list[1].toInt();505 int index = list[1].toInt();
506 int red = list[2].toInt();506 int red = list[2].toInt();
507 int green = list[3].toInt();507 int green = list[3].toInt();
@@ -612,7 +612,7 @@
612 delete scheme;612 delete scheme;
613 return false;613 return false;
614 }614 }
615 615
616 QFileInfo info(filePath);616 QFileInfo info(filePath);
617617
618 if ( !_colorSchemes.contains(info.baseName()) )618 if ( !_colorSchemes.contains(info.baseName()) )
@@ -627,7 +627,7 @@
627 return true;627 return true;
628}628}
629#if 0629#if 0
630void ColorSchemeManager::addColorScheme(ColorScheme* scheme) 630void ColorSchemeManager::addColorScheme(ColorScheme* scheme)
631{631{
632 _colorSchemes.insert(scheme->name(),scheme);632 _colorSchemes.insert(scheme->name(),scheme);
633633
@@ -644,17 +644,17 @@
644 return false;644 return false;
645645
646 QFileInfo info(filePath);646 QFileInfo info(filePath);
647 647
648 ColorScheme* scheme = new ColorScheme();648 ColorScheme* scheme = new ColorScheme();
649 scheme->setName(info.baseName());649 scheme->setName(info.baseName());
650 scheme->read(filePath);650 scheme->read(filePath);
651651
652 if (scheme->name().isEmpty()) 652 if (scheme->name().isEmpty())
653 {653 {
654 qDebug() << "Color scheme in" << filePath << "does not have a valid name and was not loaded.";654 qDebug() << "Color scheme in" << filePath << "does not have a valid name and was not loaded.";
655 delete scheme;655 delete scheme;
656 return false;656 return false;
657 } 657 }
658658
659 if ( !_colorSchemes.contains(info.baseName()) )659 if ( !_colorSchemes.contains(info.baseName()) )
660 {660 {
@@ -664,11 +664,11 @@
664 {664 {
665 qDebug() << "color scheme with name" << scheme->name() << "has already been" <<665 qDebug() << "color scheme with name" << scheme->name() << "has already been" <<
666 "found, ignoring.";666 "found, ignoring.";
667 667
668 delete scheme;668 delete scheme;
669 }669 }
670670
671 return true; 671 return true;
672}672}
673QList<QString> ColorSchemeManager::listKDE3ColorSchemes()673QList<QString> ColorSchemeManager::listKDE3ColorSchemes()
674{674{
@@ -677,7 +677,7 @@
677 QStringList filters;677 QStringList filters;
678 filters << "*.schema";678 filters << "*.schema";
679 dir.setNameFilters(filters);679 dir.setNameFilters(filters);
680 QStringList list = dir.entryList(filters); 680 QStringList list = dir.entryList(filters);
681 QStringList ret;681 QStringList ret;
682 foreach(QString i, list)682 foreach(QString i, list)
683 ret << dname + "/" + i;683 ret << dname + "/" + i;
@@ -712,7 +712,7 @@
712{712{
713 Q_ASSERT( _colorSchemes.contains(name) );713 Q_ASSERT( _colorSchemes.contains(name) );
714714
715 // lookup the path and delete 715 // lookup the path and delete
716 QString path = findColorSchemePath(name);716 QString path = findColorSchemePath(name);
717 if ( QFile::remove(path) )717 if ( QFile::remove(path) )
718 {718 {
@@ -730,14 +730,14 @@
730// QString path = KStandardDirs::locate("data","konsole/"+name+".colorscheme");730// QString path = KStandardDirs::locate("data","konsole/"+name+".colorscheme");
731 QString path(get_color_schemes_dir() + "/"+ name + ".colorscheme");731 QString path(get_color_schemes_dir() + "/"+ name + ".colorscheme");
732 if ( !path.isEmpty() )732 if ( !path.isEmpty() )
733 return path; 733 return path;
734734
735 //path = KStandardDirs::locate("data","konsole/"+name+".schema");735 //path = KStandardDirs::locate("data","konsole/"+name+".schema");
736 path = get_color_schemes_dir() + "/"+ name + ".schema";736 path = get_color_schemes_dir() + "/"+ name + ".schema";
737737
738 return path;738 return path;
739}739}
740const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name) 740const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
741{741{
742 if ( name.isEmpty() )742 if ( name.isEmpty() )
743 return defaultColorScheme();743 return defaultColorScheme();
@@ -747,12 +747,12 @@
747 else747 else
748 {748 {
749 // look for this color scheme749 // look for this color scheme
750 QString path = findColorSchemePath(name); 750 QString path = findColorSchemePath(name);
751 if ( !path.isEmpty() && loadColorScheme(path) )751 if ( !path.isEmpty() && loadColorScheme(path) )
752 {752 {
753 return findColorScheme(name); 753 return findColorScheme(name);
754 } 754 }
755 else 755 else
756 {756 {
757 if (!path.isEmpty() && loadKDE3ColorScheme(path))757 if (!path.isEmpty() && loadKDE3ColorScheme(path))
758 return findColorScheme(name);758 return findColorScheme(name);
@@ -760,7 +760,7 @@
760760
761 qDebug() << "Could not find color scheme - " << name;761 qDebug() << "Could not find color scheme - " << name;
762762
763 return 0; 763 return 0;
764 }764 }
765}765}
766766
767767
=== modified file 'src/plugin/konsole/ColorScheme.h'
--- src/plugin/konsole/ColorScheme.h 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/ColorScheme.h 2014-07-30 09:50:10 +0000
@@ -38,16 +38,16 @@
3838
3939
40/**40/**
41 * Represents a color scheme for a terminal display. 41 * Represents a color scheme for a terminal display.
42 *42 *
43 * The color scheme includes the palette of colors used to draw the text and character backgrounds43 * The color scheme includes the palette of colors used to draw the text and character backgrounds
44 * in the display and the opacity level of the display background. 44 * in the display and the opacity level of the display background.
45 */45 */
46class ColorScheme46class ColorScheme
47{47{
48public:48public:
49 /** 49 /**
50 * Constructs a new color scheme which is initialised to the default color set 50 * Constructs a new color scheme which is initialised to the default color set
51 * for Konsole.51 * for Konsole.
52 */52 */
53 ColorScheme();53 ColorScheme();
@@ -76,7 +76,7 @@
76 /** Sets a single entry within the color palette. */76 /** Sets a single entry within the color palette. */
77 void setColorTableEntry(int index , const ColorEntry& entry);77 void setColorTableEntry(int index , const ColorEntry& entry);
7878
79 /** 79 /**
80 * Copies the color entries which form the palette for this color scheme80 * Copies the color entries which form the palette for this color scheme
81 * into @p table. @p table should be an array with TABLE_COLORS entries.81 * into @p table. @p table should be an array with TABLE_COLORS entries.
82 *82 *
@@ -86,7 +86,7 @@
86 * palette to be randomized. The seed is used to pick the random color.86 * palette to be randomized. The seed is used to pick the random color.
87 */87 */
88 void getColorTable(ColorEntry* table, uint randomSeed = 0) const;88 void getColorTable(ColorEntry* table, uint randomSeed = 0) const;
89 89
90 /**90 /**
91 * Retrieves a single color entry from the table.91 * Retrieves a single color entry from the table.
92 *92 *
@@ -94,28 +94,28 @@
94 */94 */
95 ColorEntry colorEntry(int index , uint randomSeed = 0) const;95 ColorEntry colorEntry(int index , uint randomSeed = 0) const;
9696
97 /** 97 /**
98 * Convenience method. Returns the 98 * Convenience method. Returns the
99 * foreground color for this scheme, 99 * foreground color for this scheme,
100 * this is the primary color used to draw the 100 * this is the primary color used to draw the
101 * text in this scheme.101 * text in this scheme.
102 */102 */
103 QColor foregroundColor() const;103 QColor foregroundColor() const;
104 /**104 /**
105 * Convenience method. Returns the background color for 105 * Convenience method. Returns the background color for
106 * this scheme, this is the primary color used to 106 * this scheme, this is the primary color used to
107 * draw the terminal background in this scheme.107 * draw the terminal background in this scheme.
108 */108 */
109 QColor backgroundColor() const;109 QColor backgroundColor() const;
110110
111 /** 111 /**
112 * Returns true if this color scheme has a dark background.112 * Returns true if this color scheme has a dark background.
113 * The background color is said to be dark if it has a value of less than 127113 * The background color is said to be dark if it has a value of less than 127
114 * in the HSV color space.114 * in the HSV color space.
115 */115 */
116 bool hasDarkBackground() const;116 bool hasDarkBackground() const;
117117
118 /** 118 /**
119 * Sets the opacity level of the display background. @p opacity ranges119 * Sets the opacity level of the display background. @p opacity ranges
120 * between 0 (completely transparent background) and 1 (completely120 * between 0 (completely transparent background) and 1 (completely
121 * opaque background).121 * opaque background).
@@ -125,18 +125,18 @@
125 * TODO: More documentation125 * TODO: More documentation
126 */126 */
127 void setOpacity(qreal opacity);127 void setOpacity(qreal opacity);
128 /** 128 /**
129 * Returns the opacity level for this color scheme, see setOpacity()129 * Returns the opacity level for this color scheme, see setOpacity()
130 * TODO: More documentation130 * TODO: More documentation
131 */131 */
132 qreal opacity() const;132 qreal opacity() const;
133133
134 /** 134 /**
135 * Enables randomization of the background color. This will cause135 * Enables randomization of the background color. This will cause
136 * the palette returned by getColorTable() and colorEntry() to136 * the palette returned by getColorTable() and colorEntry() to
137 * be adjusted depending on the value of the random seed argument137 * be adjusted depending on the value of the random seed argument
138 * to them.138 * to them.
139 */ 139 */
140 void setRandomizedBackgroundColor(bool randomize);140 void setRandomizedBackgroundColor(bool randomize);
141141
142 /** Returns true if the background color is randomized. */142 /** Returns true if the background color is randomized. */
@@ -152,7 +152,7 @@
152 public:152 public:
153 RandomizationRange() : hue(0) , saturation(0) , value(0) {}153 RandomizationRange() : hue(0) , saturation(0) , value(0) {}
154154
155 bool isNull() const 155 bool isNull() const
156 {156 {
157 return ( hue == 0 && saturation == 0 && value == 0 );157 return ( hue == 0 && saturation == 0 && value == 0 );
158 }158 }
@@ -170,14 +170,14 @@
170// implemented upstream - user apps170// implemented upstream - user apps
171 // reads a single colour entry from a KConfig source171 // reads a single colour entry from a KConfig source
172 // and sets the palette entry at 'index' to the entry read.172 // and sets the palette entry at 'index' to the entry read.
173 void readColorEntry(KConfig& config , int index); 173 void readColorEntry(KConfig& config , int index);
174 // writes a single colour entry to a KConfig source174 // writes a single colour entry to a KConfig source
175 void writeColorEntry(KConfig& config , const QString& colorName, const ColorEntry& entry,const RandomizationRange& range) const;175 void writeColorEntry(KConfig& config , const QString& colorName, const ColorEntry& entry,const RandomizationRange& range) const;
176#endif176#endif
177 void readColorEntry(QSettings *s, int index);177 void readColorEntry(QSettings *s, int index);
178178
179 // sets the amount of randomization allowed for a particular color 179 // sets the amount of randomization allowed for a particular color
180 // in the palette. creates the randomization table if 180 // in the palette. creates the randomization table if
181 // it does not already exist181 // it does not already exist
182 void setRandomizationRange( int index , quint16 hue , quint8 saturation , quint8 value );182 void setRandomizationRange( int index , quint16 hue , quint8 saturation , quint8 value );
183183
@@ -200,7 +200,7 @@
200 static const ColorEntry defaultTable[]; // table of default color entries200 static const ColorEntry defaultTable[]; // table of default color entries
201};201};
202202
203/** 203/**
204 * A color scheme which uses colors from the standard KDE color palette.204 * A color scheme which uses colors from the standard KDE color palette.
205 *205 *
206 * This is designed primarily for the benefit of users who are using specially206 * This is designed primarily for the benefit of users who are using specially
@@ -226,13 +226,13 @@
226class KDE3ColorSchemeReader226class KDE3ColorSchemeReader
227{227{
228public:228public:
229 /** 229 /**
230 * Constructs a new reader which reads from the specified device. 230 * Constructs a new reader which reads from the specified device.
231 * The device should be open in read-only mode. 231 * The device should be open in read-only mode.
232 */232 */
233 KDE3ColorSchemeReader( QIODevice* device );233 KDE3ColorSchemeReader( QIODevice* device );
234234
235 /** 235 /**
236 * Reads and parses the contents of the .schema file from the input236 * Reads and parses the contents of the .schema file from the input
237 * device and returns the ColorScheme defined within it.237 * device and returns the ColorScheme defined within it.
238 *238 *
@@ -275,7 +275,7 @@
275 * Returns the default color scheme for Konsole275 * Returns the default color scheme for Konsole
276 */276 */
277 const ColorScheme* defaultColorScheme() const;277 const ColorScheme* defaultColorScheme() const;
278 278
279 /**279 /**
280 * Returns the color scheme with the given name or 0 if no280 * Returns the color scheme with the given name or 0 if no
281 * scheme with that name exists. If @p name is empty, the281 * scheme with that name exists. If @p name is empty, the
@@ -296,18 +296,18 @@
296 void addColorScheme(ColorScheme* scheme);296 void addColorScheme(ColorScheme* scheme);
297#endif297#endif
298 /**298 /**
299 * Deletes a color scheme. Returns true on successful deletion or false otherwise. 299 * Deletes a color scheme. Returns true on successful deletion or false otherwise.
300 */300 */
301 bool deleteColorScheme(const QString& name);301 bool deleteColorScheme(const QString& name);
302302
303 /** 303 /**
304 * Returns a list of the all the available color schemes. 304 * Returns a list of the all the available color schemes.
305 * This may be slow when first called because all of the color305 * This may be slow when first called because all of the color
306 * scheme resources on disk must be located, read and parsed.306 * scheme resources on disk must be located, read and parsed.
307 *307 *
308 * Subsequent calls will be inexpensive. 308 * Subsequent calls will be inexpensive.
309 */309 */
310 QList<const ColorScheme*> allColorSchemes(); 310 QList<const ColorScheme*> allColorSchemes();
311311
312 /** Returns the global color scheme manager instance. */312 /** Returns the global color scheme manager instance. */
313 static ColorSchemeManager* instance();313 static ColorSchemeManager* instance();
314314
=== modified file 'src/plugin/konsole/Emulation.cpp'
--- src/plugin/konsole/Emulation.cpp 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/Emulation.cpp 2014-07-30 09:50:10 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 Copyright 2007-2008 Robert Knight <robertknight@gmail.com> 2 Copyright 2007-2008 Robert Knight <robertknight@gmail.com>
3 Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>3 Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
4 Copyright 1996 by Matthias Ettrich <ettrich@kde.org>4 Copyright 1996 by Matthias Ettrich <ettrich@kde.org>
55
@@ -62,9 +62,9 @@
6262
63 QObject::connect(&_bulkTimer1, SIGNAL(timeout()), this, SLOT(showBulk()) );63 QObject::connect(&_bulkTimer1, SIGNAL(timeout()), this, SLOT(showBulk()) );
64 QObject::connect(&_bulkTimer2, SIGNAL(timeout()), this, SLOT(showBulk()) );64 QObject::connect(&_bulkTimer2, SIGNAL(timeout()), this, SLOT(showBulk()) );
65 65
66 // listen for mouse status changes66 // listen for mouse status changes
67 connect( this , SIGNAL(programUsesMouseChanged(bool)) , 67 connect( this , SIGNAL(programUsesMouseChanged(bool)) ,
68 SLOT(usesMouseChanged(bool)) );68 SLOT(usesMouseChanged(bool)) );
69}69}
7070
@@ -110,7 +110,7 @@
110{110{
111 Screen *old = _currentScreen;111 Screen *old = _currentScreen;
112 _currentScreen = _screen[n & 1];112 _currentScreen = _screen[n & 1];
113 if (_currentScreen != old) 113 if (_currentScreen != old)
114 {114 {
115 // tell all windows onto this emulation to switch to the newly active screen115 // tell all windows onto this emulation to switch to the newly active screen
116 foreach(ScreenWindow* window,_windows)116 foreach(ScreenWindow* window,_windows)
@@ -189,7 +189,7 @@
189void Emulation::sendKeyEvent( QKeyEvent* ev )189void Emulation::sendKeyEvent( QKeyEvent* ev )
190{190{
191 emit stateSet(NOTIFYNORMAL);191 emit stateSet(NOTIFYNORMAL);
192 192
193 if (!ev->text().isEmpty())193 if (!ev->text().isEmpty())
194 { // A block of text194 { // A block of text
195 // Note that the text is proper unicode.195 // Note that the text is proper unicode.
@@ -218,7 +218,7 @@
218 emit stateSet(NOTIFYACTIVITY);218 emit stateSet(NOTIFYACTIVITY);
219219
220 bufferedUpdate();220 bufferedUpdate();
221 221
222 QString unicodeText = _decoder->toUnicode(text,length);222 QString unicodeText = _decoder->toUnicode(text,length);
223223
224 //send characters to terminal emulator224 //send characters to terminal emulator
@@ -246,13 +246,13 @@
246//246//
247//There is something about stopping the _decoder if "we get a control code halfway a multi-byte sequence" (see below)247//There is something about stopping the _decoder if "we get a control code halfway a multi-byte sequence" (see below)
248//which hasn't been ported into the newer function (above). Hopefully someone who understands this better248//which hasn't been ported into the newer function (above). Hopefully someone who understands this better
249//can find an alternative way of handling the check. 249//can find an alternative way of handling the check.
250250
251251
252/*void Emulation::onRcvBlock(const char *s, int len)252/*void Emulation::onRcvBlock(const char *s, int len)
253{253{
254 emit notifySessionState(NOTIFYACTIVITY);254 emit notifySessionState(NOTIFYACTIVITY);
255 255
256 bufferedUpdate();256 bufferedUpdate();
257 for (int i = 0; i < len; i++)257 for (int i = 0; i < len; i++)
258 {258 {
@@ -287,9 +287,9 @@
287 }287 }
288}*/288}*/
289289
290void Emulation::writeToStream( TerminalCharacterDecoder* _decoder , 290void Emulation::writeToStream( TerminalCharacterDecoder* _decoder ,
291 int startLine ,291 int startLine ,
292 int endLine) 292 int endLine)
293{293{
294 _currentScreen->writeLinesToStream(_decoder,startLine,endLine);294 _currentScreen->writeLinesToStream(_decoder,startLine,endLine);
295}295}
@@ -332,7 +332,7 @@
332332
333void Emulation::setImageSize(int lines, int columns)333void Emulation::setImageSize(int lines, int columns)
334{334{
335 if ((lines < 1) || (columns < 1)) 335 if ((lines < 1) || (columns < 1))
336 return;336 return;
337337
338 QSize screenSize[2] = { QSize(_screen[0]->getColumns(),338 QSize screenSize[2] = { QSize(_screen[0]->getColumns(),
@@ -342,7 +342,7 @@
342 QSize newSize(columns,lines);342 QSize newSize(columns,lines);
343343
344 if (newSize == screenSize[0] && newSize == screenSize[1])344 if (newSize == screenSize[0] && newSize == screenSize[1])
345 return; 345 return;
346346
347 _screen[0]->resizeImage(lines,columns);347 _screen[0]->resizeImage(lines,columns);
348 _screen[1]->resizeImage(lines,columns);348 _screen[1]->resizeImage(lines,columns);
@@ -370,17 +370,17 @@
370{370{
371 ushort* entry = extendedCharTable[hash];371 ushort* entry = extendedCharTable[hash];
372372
373 // compare given length with stored sequence length ( given as the first ushort in the 373 // compare given length with stored sequence length ( given as the first ushort in the
374 // stored buffer ) 374 // stored buffer )
375 if ( entry == 0 || entry[0] != length ) 375 if ( entry == 0 || entry[0] != length )
376 return false;376 return false;
377 // if the lengths match, each character must be checked. the stored buffer starts at377 // if the lengths match, each character must be checked. the stored buffer starts at
378 // entry[1]378 // entry[1]
379 for ( int i = 0 ; i < length ; i++ )379 for ( int i = 0 ; i < length ; i++ )
380 {380 {
381 if ( entry[i+1] != unicodePoints[i] )381 if ( entry[i+1] != unicodePoints[i] )
382 return false; 382 return false;
383 } 383 }
384 return true;384 return true;
385}385}
386ushort ExtendedCharTable::createExtendedChar(ushort* unicodePoints , ushort length)386ushort ExtendedCharTable::createExtendedChar(ushort* unicodePoints , ushort length)
@@ -393,7 +393,7 @@
393 {393 {
394 if ( extendedCharMatch(hash,unicodePoints,length) )394 if ( extendedCharMatch(hash,unicodePoints,length) )
395 {395 {
396 // this sequence already has an entry in the table, 396 // this sequence already has an entry in the table,
397 // return its hash397 // return its hash
398 return hash;398 return hash;
399 }399 }
@@ -403,16 +403,16 @@
403 // points then try next hash403 // points then try next hash
404 hash++;404 hash++;
405 }405 }
406 } 406 }
407407
408 408
409 // add the new sequence to the table and409 // add the new sequence to the table and
410 // return that index410 // return that index
411 ushort* buffer = new ushort[length+1];411 ushort* buffer = new ushort[length+1];
412 buffer[0] = length;412 buffer[0] = length;
413 for ( int i = 0 ; i < length ; i++ )413 for ( int i = 0 ; i < length ; i++ )
414 buffer[i+1] = unicodePoints[i]; 414 buffer[i+1] = unicodePoints[i];
415 415
416 extendedCharTable.insert(hash,buffer);416 extendedCharTable.insert(hash,buffer);
417417
418 return hash;418 return hash;
419419
=== modified file 'src/plugin/konsole/Emulation.h'
--- src/plugin/konsole/Emulation.h 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/Emulation.h 2014-07-30 09:50:10 +0000
@@ -1,6 +1,6 @@
1/*1/*
2 This file is part of Konsole, an X terminal.2 This file is part of Konsole, an X terminal.
3 3
4 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>4 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
5 Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>5 Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
66
@@ -26,7 +26,7 @@
26// System26// System
27#include <stdio.h>27#include <stdio.h>
2828
29// Qt 29// Qt
30#include <QtGui/QKeyEvent>30#include <QtGui/QKeyEvent>
31//#include <QPointer>31//#include <QPointer>
32#include <QtCore/QTextCodec>32#include <QtCore/QTextCodec>
@@ -43,56 +43,56 @@
43class ScreenWindow;43class ScreenWindow;
44class TerminalCharacterDecoder;44class TerminalCharacterDecoder;
4545
46/** 46/**
47 * This enum describes the available states which 47 * This enum describes the available states which
48 * the terminal emulation may be set to.48 * the terminal emulation may be set to.
49 *49 *
50 * These are the values used by Emulation::stateChanged() 50 * These are the values used by Emulation::stateChanged()
51 */51 */
52enum 52enum
53{ 53{
54 /** The emulation is currently receiving user input. */54 /** The emulation is currently receiving user input. */
55 NOTIFYNORMAL=0, 55 NOTIFYNORMAL=0,
56 /** 56 /**
57 * The terminal program has triggered a bell event57 * The terminal program has triggered a bell event
58 * to get the user's attention.58 * to get the user's attention.
59 */59 */
60 NOTIFYBELL=1, 60 NOTIFYBELL=1,
61 /** 61 /**
62 * The emulation is currently receiving data from its 62 * The emulation is currently receiving data from its
63 * terminal input.63 * terminal input.
64 */64 */
65 NOTIFYACTIVITY=2,65 NOTIFYACTIVITY=2,
6666
67 // unused here? 67 // unused here?
68 NOTIFYSILENCE=3 68 NOTIFYSILENCE=3
69};69};
7070
71/**71/**
72 * Base class for terminal emulation back-ends.72 * Base class for terminal emulation back-ends.
73 *73 *
74 * The back-end is responsible for decoding an incoming character stream and 74 * The back-end is responsible for decoding an incoming character stream and
75 * producing an output image of characters.75 * producing an output image of characters.
76 *76 *
77 * When input from the terminal is received, the receiveData() slot should be called with77 * When input from the terminal is received, the receiveData() slot should be called with
78 * the data which has arrived. The emulation will process the data and update the 78 * the data which has arrived. The emulation will process the data and update the
79 * screen image accordingly. The codec used to decode the incoming character stream79 * screen image accordingly. The codec used to decode the incoming character stream
80 * into the unicode characters used internally can be specified using setCodec() 80 * into the unicode characters used internally can be specified using setCodec()
81 *81 *
82 * The size of the screen image can be specified by calling setImageSize() with the 82 * The size of the screen image can be specified by calling setImageSize() with the
83 * desired number of lines and columns. When new lines are added, old content83 * desired number of lines and columns. When new lines are added, old content
84 * is moved into a history store, which can be set by calling setHistory(). 84 * is moved into a history store, which can be set by calling setHistory().
85 *85 *
86 * The screen image can be accessed by creating a ScreenWindow onto this emulation 86 * The screen image can be accessed by creating a ScreenWindow onto this emulation
87 * by calling createWindow(). Screen windows provide access to a section of the 87 * by calling createWindow(). Screen windows provide access to a section of the
88 * output. Each screen window covers the same number of lines and columns as the 88 * output. Each screen window covers the same number of lines and columns as the
89 * image size returned by imageSize(). The screen window can be moved up and down89 * image size returned by imageSize(). The screen window can be moved up and down
90 * and provides transparent access to both the current on-screen image and the 90 * and provides transparent access to both the current on-screen image and the
91 * previous output. The screen windows emit an outputChanged signal91 * previous output. The screen windows emit an outputChanged signal
92 * when the section of the image they are looking at changes.92 * when the section of the image they are looking at changes.
93 * Graphical views can then render the contents of a screen window, listening for notifications93 * Graphical views can then render the contents of a screen window, listening for notifications
94 * of output changes from the screen window which they are associated with and updating 94 * of output changes from the screen window which they are associated with and updating
95 * accordingly. 95 * accordingly.
96 *96 *
97 * The emulation also is also responsible for converting input from the connected views such97 * The emulation also is also responsible for converting input from the connected views such
98 * as keypresses and mouse activity into a character string which can be sent98 * as keypresses and mouse activity into a character string which can be sent
@@ -105,9 +105,9 @@
105 * character sequences. The name of the key bindings set used can be specified using105 * character sequences. The name of the key bindings set used can be specified using
106 * setKeyBindings()106 * setKeyBindings()
107 *107 *
108 * The emulation maintains certain state information which changes depending on the 108 * The emulation maintains certain state information which changes depending on the
109 * input received. The emulation can be reset back to its starting state by calling 109 * input received. The emulation can be reset back to its starting state by calling
110 * reset(). 110 * reset().
111 *111 *
112 * The emulation also maintains an activity state, which specifies whether112 * The emulation also maintains an activity state, which specifies whether
113 * terminal is currently active ( when data is received ), normal113 * terminal is currently active ( when data is received ), normal
@@ -118,12 +118,12 @@
118 * a 'bell' event in different ways.118 * a 'bell' event in different ways.
119 */119 */
120class KONSOLEPRIVATE_EXPORT Emulation : public QObject120class KONSOLEPRIVATE_EXPORT Emulation : public QObject
121{ 121{
122Q_OBJECT122Q_OBJECT
123123
124public:124public:
125 125
126 /** Constructs a new terminal emulation */ 126 /** Constructs a new terminal emulation */
127 Emulation();127 Emulation();
128 ~Emulation();128 ~Emulation();
129129
@@ -139,15 +139,15 @@
139139
140 /**140 /**
141 * Returns the total number of lines, including those stored in the history.141 * Returns the total number of lines, including those stored in the history.
142 */ 142 */
143 int lineCount() const;143 int lineCount() const;
144144
145 /** 145 /**
146 * Sets the history store used by this emulation. When new lines146 * Sets the history store used by this emulation. When new lines
147 * are added to the output, older lines at the top of the screen are transferred to a history147 * are added to the output, older lines at the top of the screen are transferred to a history
148 * store. 148 * store.
149 *149 *
150 * The number of lines which are kept and the storage location depend on the 150 * The number of lines which are kept and the storage location depend on the
151 * type of store.151 * type of store.
152 */152 */
153 void setHistory(const HistoryType&);153 void setHistory(const HistoryType&);
@@ -156,49 +156,49 @@
156 /** Clears the history scroll. */156 /** Clears the history scroll. */
157 void clearHistory();157 void clearHistory();
158158
159 /** 159 /**
160 * Copies the output history from @p startLine to @p endLine 160 * Copies the output history from @p startLine to @p endLine
161 * into @p stream, using @p decoder to convert the terminal161 * into @p stream, using @p decoder to convert the terminal
162 * characters into text. 162 * characters into text.
163 *163 *
164 * @param decoder A decoder which converts lines of terminal characters with 164 * @param decoder A decoder which converts lines of terminal characters with
165 * appearance attributes into output text. PlainTextDecoder is the most commonly165 * appearance attributes into output text. PlainTextDecoder is the most commonly
166 * used decoder.166 * used decoder.
167 * @param startLine Index of first line to copy167 * @param startLine Index of first line to copy
168 * @param endLine Index of last line to copy168 * @param endLine Index of last line to copy
169 */169 */
170 virtual void writeToStream(TerminalCharacterDecoder* decoder,int startLine,int endLine);170 virtual void writeToStream(TerminalCharacterDecoder* decoder,int startLine,int endLine);
171 171
172 /** Returns the codec used to decode incoming characters. See setCodec() */172 /** Returns the codec used to decode incoming characters. See setCodec() */
173 const QTextCodec* codec() const { return _codec; }173 const QTextCodec* codec() const { return _codec; }
174 /** Sets the codec used to decode incoming characters. */174 /** Sets the codec used to decode incoming characters. */
175 void setCodec(const QTextCodec*);175 void setCodec(const QTextCodec*);
176176
177 /** 177 /**
178 * Convenience method. 178 * Convenience method.
179 * Returns true if the current codec used to decode incoming179 * Returns true if the current codec used to decode incoming
180 * characters is UTF-8180 * characters is UTF-8
181 */181 */
182 bool utf8() const182 bool utf8() const
183 { Q_ASSERT(_codec); return _codec->mibEnum() == 106; }183 { Q_ASSERT(_codec); return _codec->mibEnum() == 106; }
184 184
185185
186 /** TODO Document me */186 /** TODO Document me */
187 virtual char eraseChar() const;187 virtual char eraseChar() const;
188188
189 /** 189 /**
190 * Sets the key bindings used to key events190 * Sets the key bindings used to key events
191 * ( received through sendKeyEvent() ) into character191 * ( received through sendKeyEvent() ) into character
192 * streams to send to the terminal.192 * streams to send to the terminal.
193 */193 */
194 void setKeyBindings(const QString& name);194 void setKeyBindings(const QString& name);
195 /** 195 /**
196 * Returns the name of the emulation's current key bindings.196 * Returns the name of the emulation's current key bindings.
197 * See setKeyBindings()197 * See setKeyBindings()
198 */198 */
199 QString keyBindings() const;199 QString keyBindings() const;
200200
201 /** 201 /**
202 * Copies the current image into the history and clears the screen.202 * Copies the current image into the history and clears the screen.
203 */203 */
204 virtual void clearEntireScreen() =0;204 virtual void clearEntireScreen() =0;
@@ -206,7 +206,7 @@
206 /** Resets the state of the terminal. */206 /** Resets the state of the terminal. */
207 virtual void reset() =0;207 virtual void reset() =0;
208208
209 /** 209 /**
210 * Returns true if the active terminal program wants210 * Returns true if the active terminal program wants
211 * mouse input events.211 * mouse input events.
212 *212 *
@@ -215,42 +215,42 @@
215 */215 */
216 bool programUsesMouse() const;216 bool programUsesMouse() const;
217217
218public slots: 218public slots:
219219
220 /** Change the size of the emulation's image */220 /** Change the size of the emulation's image */
221 virtual void setImageSize(int lines, int columns);221 virtual void setImageSize(int lines, int columns);
222 222
223 /** 223 /**
224 * Interprets a sequence of characters and sends the result to the terminal.224 * Interprets a sequence of characters and sends the result to the terminal.
225 * This is equivalent to calling sendKeyEvent() for each character in @p text in succession.225 * This is equivalent to calling sendKeyEvent() for each character in @p text in succession.
226 */226 */
227 virtual void sendText(const QString& text) = 0;227 virtual void sendText(const QString& text) = 0;
228228
229 /** 229 /**
230 * Interprets a key press event and emits the sendData() signal with230 * Interprets a key press event and emits the sendData() signal with
231 * the resulting character stream. 231 * the resulting character stream.
232 */232 */
233 virtual void sendKeyEvent(QKeyEvent*);233 virtual void sendKeyEvent(QKeyEvent*);
234 234
235 /** 235 /**
236 * Converts information about a mouse event into an xterm-compatible escape236 * Converts information about a mouse event into an xterm-compatible escape
237 * sequence and emits the character sequence via sendData()237 * sequence and emits the character sequence via sendData()
238 */238 */
239 virtual void sendMouseEvent(int buttons, int column, int line, int eventType);239 virtual void sendMouseEvent(int buttons, int column, int line, int eventType);
240 240
241 /**241 /**
242 * Sends a string of characters to the foreground terminal process. 242 * Sends a string of characters to the foreground terminal process.
243 *243 *
244 * @param string The characters to send. 244 * @param string The characters to send.
245 * @param length Length of @p string or if set to a negative value, @p string will245 * @param length Length of @p string or if set to a negative value, @p string will
246 * be treated as a null-terminated string and its length will be determined automatically.246 * be treated as a null-terminated string and its length will be determined automatically.
247 */247 */
248 virtual void sendString(const char* string, int length = -1) = 0;248 virtual void sendString(const char* string, int length = -1) = 0;
249249
250 /** 250 /**
251 * Processes an incoming stream of characters. receiveData() decodes the incoming251 * Processes an incoming stream of characters. receiveData() decodes the incoming
252 * character buffer using the current codec(), and then calls receiveChar() for252 * character buffer using the current codec(), and then calls receiveChar() for
253 * each unicode character in the resulting buffer. 253 * each unicode character in the resulting buffer.
254 *254 *
255 * receiveData() also starts a timer which causes the outputChanged() signal255 * receiveData() also starts a timer which causes the outputChanged() signal
256 * to be emitted when it expires. The timer allows multiple updates in quick256 * to be emitted when it expires. The timer allows multiple updates in quick
@@ -263,8 +263,8 @@
263263
264signals:264signals:
265265
266 /** 266 /**
267 * Emitted when a buffer of data is ready to send to the 267 * Emitted when a buffer of data is ready to send to the
268 * standard input of the terminal.268 * standard input of the terminal.
269 *269 *
270 * @param data The buffer of data ready to be sent270 * @param data The buffer of data ready to be sent
@@ -272,20 +272,20 @@
272 */272 */
273 void sendData(const char* data,int len);273 void sendData(const char* data,int len);
274274
275 /** 275 /**
276 * Requests that sending of input to the emulation276 * Requests that sending of input to the emulation
277 * from the terminal process be suspended or resumed.277 * from the terminal process be suspended or resumed.
278 *278 *
279 * @param suspend If true, requests that sending of 279 * @param suspend If true, requests that sending of
280 * input from the terminal process' stdout be 280 * input from the terminal process' stdout be
281 * suspended. Otherwise requests that sending of281 * suspended. Otherwise requests that sending of
282 * input be resumed. 282 * input be resumed.
283 */283 */
284 void lockPtyRequest(bool suspend);284 void lockPtyRequest(bool suspend);
285285
286 /**286 /**
287 * Requests that the pty used by the terminal process287 * Requests that the pty used by the terminal process
288 * be set to UTF 8 mode. 288 * be set to UTF 8 mode.
289 *289 *
290 * TODO: More documentation290 * TODO: More documentation
291 */291 */
@@ -313,7 +313,7 @@
313 */313 */
314 void changeTabTextColorRequest(int color);314 void changeTabTextColorRequest(int color);
315315
316 /** 316 /**
317 * This is emitted when the program running in the shell indicates whether or317 * This is emitted when the program running in the shell indicates whether or
318 * not it is interested in mouse events.318 * not it is interested in mouse events.
319 *319 *
@@ -322,7 +322,7 @@
322 */322 */
323 void programUsesMouseChanged(bool usesMouse);323 void programUsesMouseChanged(bool usesMouse);
324324
325 /** 325 /**
326 * Emitted when the contents of the screen image change.326 * Emitted when the contents of the screen image change.
327 * The emulation buffers the updates from successive image changes,327 * The emulation buffers the updates from successive image changes,
328 * and only emits outputChanged() at sensible intervals when328 * and only emits outputChanged() at sensible intervals when
@@ -332,14 +332,14 @@
332 * created with createWindow() to listen for this signal.332 * created with createWindow() to listen for this signal.
333 *333 *
334 * ScreenWindow objects created using createWindow() will emit their334 * ScreenWindow objects created using createWindow() will emit their
335 * own outputChanged() signal in response to this signal. 335 * own outputChanged() signal in response to this signal.
336 */336 */
337 void outputChanged();337 void outputChanged();
338338
339 /**339 /**
340 * Emitted when the program running in the terminal wishes to update the 340 * Emitted when the program running in the terminal wishes to update the
341 * session's title. This also allows terminal programs to customize other341 * session's title. This also allows terminal programs to customize other
342 * aspects of the terminal emulation display. 342 * aspects of the terminal emulation display.
343 *343 *
344 * This signal is emitted when the escape sequence "\033]ARG;VALUE\007"344 * This signal is emitted when the escape sequence "\033]ARG;VALUE\007"
345 * is received in the input string, where ARG is a number specifying what345 * is received in the input string, where ARG is a number specifying what
@@ -347,7 +347,7 @@
347 *347 *
348 * TODO: The name of this method is not very accurate since this method348 * TODO: The name of this method is not very accurate since this method
349 * is used to perform a whole range of tasks besides just setting349 * is used to perform a whole range of tasks besides just setting
350 * the user-title of the session. 350 * the user-title of the session.
351 *351 *
352 * @param title Specifies what to change.352 * @param title Specifies what to change.
353 * <ul>353 * <ul>
@@ -356,16 +356,16 @@
356 * <li>2 - Set session title to @p newTitle</li>356 * <li>2 - Set session title to @p newTitle</li>
357 * <li>11 - Set the session's default background color to @p newTitle,357 * <li>11 - Set the session's default background color to @p newTitle,
358 * where @p newTitle can be an HTML-style string ("#RRGGBB") or a named358 * where @p newTitle can be an HTML-style string ("#RRGGBB") or a named
359 * color (eg 'red', 'blue'). 359 * color (eg 'red', 'blue').
360 * See http://doc.trolltech.com/4.2/qcolor.html#setNamedColor for more360 * See http://doc.trolltech.com/4.2/qcolor.html#setNamedColor for more
361 * details.361 * details.
362 * </li>362 * </li>
363 * <li>31 - Supposedly treats @p newTitle as a URL and opens it (NOT IMPLEMENTED)</li>363 * <li>31 - Supposedly treats @p newTitle as a URL and opens it (NOT IMPLEMENTED)</li>
364 * <li>32 - Sets the icon associated with the session. @p newTitle is the name 364 * <li>32 - Sets the icon associated with the session. @p newTitle is the name
365 * of the icon to use, which can be the name of any icon in the current KDE icon365 * of the icon to use, which can be the name of any icon in the current KDE icon
366 * theme (eg: 'konsole', 'kate', 'folder_home')</li>366 * theme (eg: 'konsole', 'kate', 'folder_home')</li>
367 * </ul>367 * </ul>
368 * @param newTitle Specifies the new title 368 * @param newTitle Specifies the new title
369 */369 */
370370
371 void titleChanged(int title,const QString& newTitle);371 void titleChanged(int title,const QString& newTitle);
@@ -376,9 +376,9 @@
376 */376 */
377 void imageSizeChanged(int lineCount , int columnCount);377 void imageSizeChanged(int lineCount , int columnCount);
378378
379 /** 379 /**
380 * Emitted when the terminal program requests to change various properties380 * Emitted when the terminal program requests to change various properties
381 * of the terminal display. 381 * of the terminal display.
382 *382 *
383 * A profile change command occurs when a special escape sequence, followed383 * A profile change command occurs when a special escape sequence, followed
384 * by a string containing a series of name and value pairs is received.384 * by a string containing a series of name and value pairs is received.
@@ -389,7 +389,7 @@
389 */389 */
390 void profileChangeCommandReceived(const QString& text);390 void profileChangeCommandReceived(const QString& text);
391391
392 /** 392 /**
393 * Emitted when a flow control key combination ( Ctrl+S or Ctrl+Q ) is pressed.393 * Emitted when a flow control key combination ( Ctrl+S or Ctrl+Q ) is pressed.
394 * @param suspendKeyPressed True if Ctrl+S was pressed to suspend output or Ctrl+Q to394 * @param suspendKeyPressed True if Ctrl+S was pressed to suspend output or Ctrl+Q to
395 * resume output.395 * resume output.
@@ -399,21 +399,21 @@
399protected:399protected:
400 virtual void setMode(int mode) = 0;400 virtual void setMode(int mode) = 0;
401 virtual void resetMode(int mode) = 0;401 virtual void resetMode(int mode) = 0;
402 402
403 /** 403 /**
404 * Processes an incoming character. See receiveData()404 * Processes an incoming character. See receiveData()
405 * @p ch A unicode character code. 405 * @p ch A unicode character code.
406 */406 */
407 virtual void receiveChar(int ch);407 virtual void receiveChar(int ch);
408408
409 /** 409 /**
410 * Sets the active screen. The terminal has two screens, primary and alternate.410 * Sets the active screen. The terminal has two screens, primary and alternate.
411 * The primary screen is used by default. When certain interactive programs such411 * The primary screen is used by default. When certain interactive programs such
412 * as Vim are run, they trigger a switch to the alternate screen.412 * as Vim are run, they trigger a switch to the alternate screen.
413 *413 *
414 * @param index 0 to switch to the primary screen, or 1 to switch to the alternate screen414 * @param index 0 to switch to the primary screen, or 1 to switch to the alternate screen
415 */415 */
416 void setScreen(int index); 416 void setScreen(int index);
417417
418 enum EmulationCodec418 enum EmulationCodec
419 {419 {
@@ -424,35 +424,35 @@
424424
425425
426 QList<ScreenWindow*> _windows;426 QList<ScreenWindow*> _windows;
427 427
428 Screen* _currentScreen; // pointer to the screen which is currently active, 428 Screen* _currentScreen; // pointer to the screen which is currently active,
429 // this is one of the elements in the screen[] array429 // this is one of the elements in the screen[] array
430430
431 Screen* _screen[2]; // 0 = primary screen ( used by most programs, including the shell431 Screen* _screen[2]; // 0 = primary screen ( used by most programs, including the shell
432 // scrollbars are enabled in this mode )432 // scrollbars are enabled in this mode )
433 // 1 = alternate ( used by vi , emacs etc.433 // 1 = alternate ( used by vi , emacs etc.
434 // scrollbars are not enabled in this mode )434 // scrollbars are not enabled in this mode )
435 435
436 436
437 //decodes an incoming C-style character stream into a unicode QString using 437 //decodes an incoming C-style character stream into a unicode QString using
438 //the current text codec. (this allows for rendering of non-ASCII characters in text files etc.)438 //the current text codec. (this allows for rendering of non-ASCII characters in text files etc.)
439 const QTextCodec* _codec;439 const QTextCodec* _codec;
440 QTextDecoder* _decoder;440 QTextDecoder* _decoder;
441 const KeyboardTranslator* _keyTranslator; // the keyboard layout441 const KeyboardTranslator* _keyTranslator; // the keyboard layout
442442
443protected slots:443protected slots:
444 /** 444 /**
445 * Schedules an update of attached views.445 * Schedules an update of attached views.
446 * Repeated calls to bufferedUpdate() in close succession will result in only a single update,446 * Repeated calls to bufferedUpdate() in close succession will result in only a single update,
447 * much like the Qt buffered update of widgets. 447 * much like the Qt buffered update of widgets.
448 */448 */
449 void bufferedUpdate();449 void bufferedUpdate();
450450
451private slots: 451private slots:
452452
453 // triggered by timer, causes the emulation to send an updated screen image to each453 // triggered by timer, causes the emulation to send an updated screen image to each
454 // view454 // view
455 void showBulk(); 455 void showBulk();
456456
457 void usesMouseChanged(bool usesMouse);457 void usesMouseChanged(bool usesMouse);
458458
@@ -460,7 +460,7 @@
460 bool _usesMouse;460 bool _usesMouse;
461 QTimer _bulkTimer1;461 QTimer _bulkTimer1;
462 QTimer _bulkTimer2;462 QTimer _bulkTimer2;
463 463
464};464};
465465
466466
467467
=== modified file 'src/plugin/konsole/Filter.cpp'
--- src/plugin/konsole/Filter.cpp 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/Filter.cpp 2014-07-30 09:50:10 +0000
@@ -46,7 +46,7 @@
46FilterChain::~FilterChain()46FilterChain::~FilterChain()
47{47{
48 QMutableListIterator<Filter*> iter(*this);48 QMutableListIterator<Filter*> iter(*this);
49 49
50 while ( iter.hasNext() )50 while ( iter.hasNext() )
51 {51 {
52 Filter* filter = iter.next();52 Filter* filter = iter.next();
@@ -140,7 +140,7 @@
140140
141 PlainTextDecoder decoder;141 PlainTextDecoder decoder;
142 decoder.setTrailingWhitespace(false);142 decoder.setTrailingWhitespace(false);
143 143
144 // setup new shared buffers for the filters to process on144 // setup new shared buffers for the filters to process on
145 QString* newBuffer = new QString();145 QString* newBuffer = new QString();
146 QList<int>* newLinePositions = new QList<int>();146 QList<int>* newLinePositions = new QList<int>();
@@ -166,7 +166,7 @@
166 // being treated as part of a link that occurs at the start of the next line166 // being treated as part of a link that occurs at the start of the next line
167 //167 //
168 // the downside is that links which are spread over more than one line are not168 // the downside is that links which are spread over more than one line are not
169 // highlighted. 169 // highlighted.
170 //170 //
171 // TODO - Use the "line wrapped" attribute associated with lines in a171 // TODO - Use the "line wrapped" attribute associated with lines in a
172 // terminal image to avoid adding this imaginary character for wrapped172 // terminal image to avoid adding this imaginary character for wrapped
@@ -218,7 +218,7 @@
218 else218 else
219 nextLine = _linePositions->value(i+1);219 nextLine = _linePositions->value(i+1);
220220
221 if ( _linePositions->value(i) <= position && position < nextLine ) 221 if ( _linePositions->value(i) <= position && position < nextLine )
222 {222 {
223 startLine = i;223 startLine = i;
224 startColumn = string_width(buffer()->mid(_linePositions->value(i),position - _linePositions->value(i)));224 startColumn = string_width(buffer()->mid(_linePositions->value(i),position - _linePositions->value(i)));
@@ -226,7 +226,7 @@
226 }226 }
227 }227 }
228}228}
229 229
230230
231/*void Filter::addLine(const QString& text)231/*void Filter::addLine(const QString& text)
232{232{
@@ -248,7 +248,7 @@
248 for (int line = spot->startLine() ; line <= spot->endLine() ; line++)248 for (int line = spot->startLine() ; line <= spot->endLine() ; line++)
249 {249 {
250 _hotspots.insert(line,spot);250 _hotspots.insert(line,spot);
251 } 251 }
252}252}
253QList<Filter::HotSpot*> Filter::hotSpots() const253QList<Filter::HotSpot*> Filter::hotSpots() const
254{254{
@@ -266,12 +266,12 @@
266 while (spotIter.hasNext())266 while (spotIter.hasNext())
267 {267 {
268 HotSpot* spot = spotIter.next();268 HotSpot* spot = spotIter.next();
269 269
270 if ( spot->startLine() == line && spot->startColumn() > column )270 if ( spot->startLine() == line && spot->startColumn() > column )
271 continue;271 continue;
272 if ( spot->endLine() == line && spot->endColumn() < column )272 if ( spot->endLine() == line && spot->endColumn() < column )
273 continue;273 continue;
274 274
275 return spot;275 return spot;
276 }276 }
277277
@@ -342,7 +342,7 @@
342 return _capturedTexts;342 return _capturedTexts;
343}343}
344344
345void RegExpFilter::setRegExp(const QRegExp& regExp) 345void RegExpFilter::setRegExp(const QRegExp& regExp)
346{346{
347 _searchText = regExp;347 _searchText = regExp;
348}348}
@@ -385,14 +385,14 @@
385 endLine,endColumn);385 endLine,endColumn);
386 spot->setCapturedTexts(_searchText.capturedTexts());386 spot->setCapturedTexts(_searchText.capturedTexts());
387387
388 addHotSpot( spot ); 388 addHotSpot( spot );
389 pos += _searchText.matchedLength();389 pos += _searchText.matchedLength();
390390
391 // if matchedLength == 0, the program will get stuck in an infinite loop391 // if matchedLength == 0, the program will get stuck in an infinite loop
392 if ( _searchText.matchedLength() == 0 )392 if ( _searchText.matchedLength() == 0 )
393 pos = -1;393 pos = -1;
394 }394 }
395 } 395 }
396}396}
397397
398RegExpFilter::HotSpot* RegExpFilter::newHotSpot(int startLine,int startColumn,398RegExpFilter::HotSpot* RegExpFilter::newHotSpot(int startLine,int startColumn,
@@ -420,16 +420,16 @@
420 const UrlType kind = urlType();420 const UrlType kind = urlType();
421421
422 if ( kind == StandardUrl )422 if ( kind == StandardUrl )
423 return QString(); 423 return QString();
424 else if ( kind == Email )424 else if ( kind == Email )
425 return QString(); 425 return QString();
426 else426 else
427 return QString();427 return QString();
428}428}
429UrlFilter::HotSpot::UrlType UrlFilter::HotSpot::urlType() const429UrlFilter::HotSpot::UrlType UrlFilter::HotSpot::urlType() const
430{430{
431 QString url = capturedTexts().first();431 QString url = capturedTexts().first();
432 432
433 if ( FullUrlRegExp.exactMatch(url) )433 if ( FullUrlRegExp.exactMatch(url) )
434 return StandardUrl;434 return StandardUrl;
435 else if ( EmailAddressRegExp.exactMatch(url) )435 else if ( EmailAddressRegExp.exactMatch(url) )
@@ -462,24 +462,24 @@
462 {462 {
463 url.prepend("http://");463 url.prepend("http://");
464 }464 }
465 } 465 }
466 else if ( kind == Email )466 else if ( kind == Email )
467 {467 {
468 url.prepend("mailto:");468 url.prepend("mailto:");
469 }469 }
470 470
471 QDesktopServices::openUrl(QUrl(url));471 QDesktopServices::openUrl(QUrl(url));
472 //new KRun(url,QApplication::activeWindow());472 //new KRun(url,QApplication::activeWindow());
473 }473 }
474}474}
475475
476// Note: Altering these regular expressions can have a major effect on the performance of the filters 476// Note: Altering these regular expressions can have a major effect on the performance of the filters
477// used for finding URLs in the text, especially if they are very general and could match very long477// used for finding URLs in the text, especially if they are very general and could match very long
478// pieces of text.478// pieces of text.
479// Please be careful when altering them.479// Please be careful when altering them.
480480
481//regexp matches:481//regexp matches:
482// full url: 482// full url:
483// protocolname:// or www. followed by anything other than whitespaces, <, >, ' or ", and ends before whitespaces, <, >, ', ", ], !, comma and dot483// protocolname:// or www. followed by anything other than whitespaces, <, >, ' or ", and ends before whitespaces, <, >, ', ", ], !, comma and dot
484const QRegExp UrlFilter::FullUrlRegExp("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]]");484const QRegExp UrlFilter::FullUrlRegExp("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]]");
485// email address:485// email address:
@@ -536,7 +536,7 @@
536 list << openAction;536 list << openAction;
537 list << copyAction;537 list << copyAction;
538538
539 return list; 539 return list;
540}540}
541541
542//#include "Filter.moc"542//#include "Filter.moc"
543543
=== modified file 'src/plugin/konsole/Filter.h'
--- src/plugin/konsole/Filter.h 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/Filter.h 2014-07-30 09:50:10 +0000
@@ -42,7 +42,7 @@
42 * activate() method should be called. Depending on the type of hotspot this will trigger a suitable response.42 * activate() method should be called. Depending on the type of hotspot this will trigger a suitable response.
43 *43 *
44 * For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser.44 * For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser.
45 * Hotspots may have more than one action, in which case the list of actions can be obtained using the 45 * Hotspots may have more than one action, in which case the list of actions can be obtained using the
46 * actions() method.46 * actions() method.
47 *47 *
48 * Different subclasses of filter will return different types of hotspot.48 * Different subclasses of filter will return different types of hotspot.
@@ -62,13 +62,13 @@
62 * activate() method should be called. Depending on the type of hotspot this will trigger a suitable response.62 * activate() method should be called. Depending on the type of hotspot this will trigger a suitable response.
63 *63 *
64 * For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser.64 * For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser.
65 * Hotspots may have more than one action, in which case the list of actions can be obtained using the 65 * Hotspots may have more than one action, in which case the list of actions can be obtained using the
66 * actions() method. These actions may then be displayed in a popup menu or toolbar for example. 66 * actions() method. These actions may then be displayed in a popup menu or toolbar for example.
67 */67 */
68 class HotSpot68 class HotSpot
69 {69 {
70 public:70 public:
71 /** 71 /**
72 * Constructs a new hotspot which covers the area from (@p startLine,@p startColumn) to (@p endLine,@p endColumn)72 * Constructs a new hotspot which covers the area from (@p startLine,@p startColumn) to (@p endLine,@p endColumn)
73 * in a block of text.73 * in a block of text.
74 */74 */
@@ -83,7 +83,7 @@
83 Link,83 Link,
84 // this hotspot represents a marker84 // this hotspot represents a marker
85 Marker85 Marker
86 }; 86 };
8787
88 /** Returns the line when the hotspot area starts */88 /** Returns the line when the hotspot area starts */
89 int startLine() const;89 int startLine() const;
@@ -93,31 +93,31 @@
93 int startColumn() const;93 int startColumn() const;
94 /** Returns the column on endLine() where the hotspot area ends */94 /** Returns the column on endLine() where the hotspot area ends */
95 int endColumn() const;95 int endColumn() const;
96 /** 96 /**
97 * Returns the type of the hotspot. This is usually used as a hint for views on how to represent97 * Returns the type of the hotspot. This is usually used as a hint for views on how to represent
98 * the hotspot graphically. eg. Link hotspots are typically underlined when the user mouses over them98 * the hotspot graphically. eg. Link hotspots are typically underlined when the user mouses over them
99 */99 */
100 Type type() const;100 Type type() const;
101 /** 101 /**
102 * Causes the an action associated with a hotspot to be triggered. 102 * Causes the an action associated with a hotspot to be triggered.
103 *103 *
104 * @param object The object which caused the hotspot to be triggered. This is104 * @param object The object which caused the hotspot to be triggered. This is
105 * typically null ( in which case the default action should be performed ) or105 * typically null ( in which case the default action should be performed ) or
106 * one of the objects from the actions() list. In which case the associated106 * one of the objects from the actions() list. In which case the associated
107 * action should be performed. 107 * action should be performed.
108 */108 */
109 virtual void activate(QObject* object = 0) = 0; 109 virtual void activate(QObject* object = 0) = 0;
110 /** 110 /**
111 * Returns a list of actions associated with the hotspot which can be used in a 111 * Returns a list of actions associated with the hotspot which can be used in a
112 * menu or toolbar 112 * menu or toolbar
113 */113 */
114 virtual QList<QAction*> actions();114 virtual QList<QAction*> actions();
115115
116 /** 116 /**
117 * Returns the text of a tooltip to be shown when the mouse moves over the hotspot, or117 * Returns the text of a tooltip to be shown when the mouse moves over the hotspot, or
118 * an empty string if there is no tooltip associated with this hotspot.118 * an empty string if there is no tooltip associated with this hotspot.
119 *119 *
120 * The default implementation returns an empty string. 120 * The default implementation returns an empty string.
121 */121 */
122 virtual QString tooltip() const;122 virtual QString tooltip() const;
123123
@@ -131,7 +131,7 @@
131 int _endLine;131 int _endLine;
132 int _endColumn;132 int _endColumn;
133 Type _type;133 Type _type;
134 134
135 };135 };
136136
137 /** Constructs a new filter. */137 /** Constructs a new filter. */
@@ -141,9 +141,9 @@
141 /** Causes the filter to process the block of text currently in its internal buffer */141 /** Causes the filter to process the block of text currently in its internal buffer */
142 virtual void process() = 0;142 virtual void process() = 0;
143143
144 /** 144 /**
145 * Empties the filters internal buffer and resets the line count back to 0.145 * Empties the filters internal buffer and resets the line count back to 0.
146 * All hotspots are deleted. 146 * All hotspots are deleted.
147 */147 */
148 void reset();148 void reset();
149149
@@ -159,7 +159,7 @@
159 /** Returns the list of hotspots identified by the filter which occur on a given line */159 /** Returns the list of hotspots identified by the filter which occur on a given line */
160 QList<HotSpot*> hotSpotsAtLine(int line) const;160 QList<HotSpot*> hotSpotsAtLine(int line) const;
161161
162 /** 162 /**
163 * TODO: Document me163 * TODO: Document me
164 */164 */
165 void setBuffer(const QString* buffer , const QList<int>* linePositions);165 void setBuffer(const QString* buffer , const QList<int>* linePositions);
@@ -175,22 +175,22 @@
175private:175private:
176 QMultiHash<int,HotSpot*> _hotspots;176 QMultiHash<int,HotSpot*> _hotspots;
177 QList<HotSpot*> _hotspotList;177 QList<HotSpot*> _hotspotList;
178 178
179 const QList<int>* _linePositions;179 const QList<int>* _linePositions;
180 const QString* _buffer;180 const QString* _buffer;
181};181};
182182
183/** 183/**
184 * A filter which searches for sections of text matching a regular expression and creates a new RegExpFilter::HotSpot 184 * A filter which searches for sections of text matching a regular expression and creates a new RegExpFilter::HotSpot
185 * instance for them.185 * instance for them.
186 *186 *
187 * Subclasses can reimplement newHotSpot() to return custom hotspot types when matches for the regular expression187 * Subclasses can reimplement newHotSpot() to return custom hotspot types when matches for the regular expression
188 * are found. 188 * are found.
189 */189 */
190class RegExpFilter : public Filter190class RegExpFilter : public Filter
191{191{
192public:192public:
193 /** 193 /**
194 * Type of hotspot created by RegExpFilter. The capturedTexts() method can be used to find the text194 * Type of hotspot created by RegExpFilter. The capturedTexts() method can be used to find the text
195 * matched by the filter's regular expression.195 * matched by the filter's regular expression.
196 */196 */
@@ -211,26 +211,26 @@
211 /** Constructs a new regular expression filter */211 /** Constructs a new regular expression filter */
212 RegExpFilter();212 RegExpFilter();
213213
214 /** 214 /**
215 * Sets the regular expression which the filter searches for in blocks of text. 215 * Sets the regular expression which the filter searches for in blocks of text.
216 *216 *
217 * Regular expressions which match the empty string are treated as not matching217 * Regular expressions which match the empty string are treated as not matching
218 * anything. 218 * anything.
219 */219 */
220 void setRegExp(const QRegExp& text);220 void setRegExp(const QRegExp& text);
221 /** Returns the regular expression which the filter searches for in blocks of text */221 /** Returns the regular expression which the filter searches for in blocks of text */
222 QRegExp regExp() const;222 QRegExp regExp() const;
223223
224 /** 224 /**
225 * Reimplemented to search the filter's text buffer for text matching regExp() 225 * Reimplemented to search the filter's text buffer for text matching regExp()
226 *226 *
227 * If regexp matches the empty string, then process() will return immediately227 * If regexp matches the empty string, then process() will return immediately
228 * without finding results. 228 * without finding results.
229 */229 */
230 virtual void process();230 virtual void process();
231231
232protected:232protected:
233 /** 233 /**
234 * Called when a match for the regular expression is encountered. Subclasses should reimplement this234 * Called when a match for the regular expression is encountered. Subclasses should reimplement this
235 * to return custom hotspot types235 * to return custom hotspot types
236 */236 */
@@ -244,14 +244,14 @@
244class FilterObject;244class FilterObject;
245245
246/** A filter which matches URLs in blocks of text */246/** A filter which matches URLs in blocks of text */
247class UrlFilter : public RegExpFilter 247class UrlFilter : public RegExpFilter
248{248{
249public:249public:
250 /** 250 /**
251 * Hotspot type created by UrlFilter instances. The activate() method opens a web browser 251 * Hotspot type created by UrlFilter instances. The activate() method opens a web browser
252 * at the given URL when called.252 * at the given URL when called.
253 */253 */
254 class HotSpot : public RegExpFilter::HotSpot 254 class HotSpot : public RegExpFilter::HotSpot
255 {255 {
256 public:256 public:
257 HotSpot(int startLine,int startColumn,int endLine,int endColumn);257 HotSpot(int startLine,int startColumn,int endLine,int endColumn);
@@ -259,7 +259,7 @@
259259
260 virtual QList<QAction*> actions();260 virtual QList<QAction*> actions();
261261
262 /** 262 /**
263 * Open a web browser at the current URL. The url itself can be determined using263 * Open a web browser at the current URL. The url itself can be determined using
264 * the capturedTexts() method.264 * the capturedTexts() method.
265 */265 */
@@ -284,12 +284,12 @@
284 virtual RegExpFilter::HotSpot* newHotSpot(int,int,int,int);284 virtual RegExpFilter::HotSpot* newHotSpot(int,int,int,int);
285285
286private:286private:
287 287
288 static const QRegExp FullUrlRegExp;288 static const QRegExp FullUrlRegExp;
289 static const QRegExp EmailAddressRegExp;289 static const QRegExp EmailAddressRegExp;
290290
291 // combined OR of FullUrlRegExp and EmailAddressRegExp291 // combined OR of FullUrlRegExp and EmailAddressRegExp
292 static const QRegExp CompleteUrlRegExp; 292 static const QRegExp CompleteUrlRegExp;
293};293};
294294
295class FilterObject : public QObject295class FilterObject : public QObject
@@ -303,11 +303,11 @@
303 Filter::HotSpot* _filter;303 Filter::HotSpot* _filter;
304};304};
305305
306/** 306/**
307 * A chain which allows a group of filters to be processed as one. 307 * A chain which allows a group of filters to be processed as one.
308 * The chain owns the filters added to it and deletes them when the chain itself is destroyed.308 * The chain owns the filters added to it and deletes them when the chain itself is destroyed.
309 *309 *
310 * Use addFilter() to add a new filter to the chain. 310 * Use addFilter() to add a new filter to the chain.
311 * When new text to be filtered arrives, use addLine() to add each additional311 * When new text to be filtered arrives, use addLine() to add each additional
312 * line of text which needs to be processed and then after adding the last line, use312 * line of text which needs to be processed and then after adding the last line, use
313 * process() to cause each filter in the chain to process the text.313 * process() to cause each filter in the chain to process the text.
@@ -337,12 +337,12 @@
337 /** Resets each filter in the chain */337 /** Resets each filter in the chain */
338 void reset();338 void reset();
339 /**339 /**
340 * Processes each filter in the chain 340 * Processes each filter in the chain
341 */341 */
342 void process();342 void process();
343343
344 /** Sets the buffer for each filter in the chain to process. */344 /** Sets the buffer for each filter in the chain to process. */
345 void setBuffer(const QString* buffer , const QList<int>* linePositions); 345 void setBuffer(const QString* buffer , const QList<int>* linePositions);
346346
347 /** Returns the first hotspot which occurs at @p line, @p column or 0 if no hotspot was found */347 /** Returns the first hotspot which occurs at @p line, @p column or 0 if no hotspot was found */
348 Filter::HotSpot* hotSpotAt(int line , int column) const;348 Filter::HotSpot* hotSpotAt(int line , int column) const;
@@ -369,7 +369,7 @@
369 * @param lineProperties The line properties to set for image369 * @param lineProperties The line properties to set for image
370 */370 */
371 void setImage(const Character* const image , int lines , int columns,371 void setImage(const Character* const image , int lines , int columns,
372 const QVector<LineProperty>& lineProperties); 372 const QVector<LineProperty>& lineProperties);
373373
374private:374private:
375 QString* _buffer;375 QString* _buffer;
376376
=== modified file 'src/plugin/konsole/History.cpp'
--- src/plugin/konsole/History.cpp 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/History.cpp 2014-07-30 09:50:10 +0000
@@ -92,7 +92,7 @@
92 fileMap(0)92 fileMap(0)
93{93{
94 if (tmpFile.open())94 if (tmpFile.open())
95 { 95 {
96 tmpFile.setAutoRemove(true);96 tmpFile.setAutoRemove(true);
97 ion = tmpFile.handle();97 ion = tmpFile.handle();
98 }98 }
@@ -116,7 +116,7 @@
116 //if mmap'ing fails, fall back to the read-lseek combination116 //if mmap'ing fails, fall back to the read-lseek combination
117 if ( fileMap == MAP_FAILED )117 if ( fileMap == MAP_FAILED )
118 {118 {
119 readWriteBalance = 0; 119 readWriteBalance = 0;
120 fileMap = 0;120 fileMap = 0;
121 qDebug() << __FILE__ << __LINE__ << ": mmap'ing history failed. errno = " << errno;121 qDebug() << __FILE__ << __LINE__ << ": mmap'ing history failed. errno = " << errno;
122 }122 }
@@ -139,7 +139,7 @@
139{139{
140 if ( fileMap )140 if ( fileMap )
141 unmap();141 unmap();
142 142
143 readWriteBalance++;143 readWriteBalance++;
144144
145 int rc = 0;145 int rc = 0;
@@ -151,8 +151,8 @@
151151
152void HistoryFile::get(unsigned char* bytes, int len, int loc)152void HistoryFile::get(unsigned char* bytes, int len, int loc)
153{153{
154 //count number of get() calls vs. number of add() calls. 154 //count number of get() calls vs. number of add() calls.
155 //If there are many more get() calls compared with add() 155 //If there are many more get() calls compared with add()
156 //calls (decided by using MAP_THRESHOLD) then mmap the log156 //calls (decided by using MAP_THRESHOLD) then mmap the log
157 //file to improve performance.157 //file to improve performance.
158 readWriteBalance--;158 readWriteBalance--;
@@ -165,7 +165,7 @@
165 bytes[i]=fileMap[loc+i];165 bytes[i]=fileMap[loc+i];
166 }166 }
167 else167 else
168 { 168 {
169 int rc = 0;169 int rc = 0;
170170
171 if (loc < 0 || len < 0 || loc + len > length)171 if (loc < 0 || len < 0 || loc + len > length)
@@ -201,7 +201,7 @@
201201
202// History Scroll File //////////////////////////////////////202// History Scroll File //////////////////////////////////////
203203
204/* 204/*
205 The history scroll makes a Row(Row(Cell)) from205 The history scroll makes a Row(Row(Cell)) from
206 two history buffers. The index buffer contains206 two history buffers. The index buffer contains
207 start of line positions which refere to the cells207 start of line positions which refere to the cells
@@ -221,7 +221,7 @@
221HistoryScrollFile::~HistoryScrollFile()221HistoryScrollFile::~HistoryScrollFile()
222{222{
223}223}
224 224
225int HistoryScrollFile::getLines()225int HistoryScrollFile::getLines()
226{226{
227 return index.len() / sizeof(int);227 return index.len() / sizeof(int);
@@ -246,11 +246,11 @@
246{246{
247 if (lineno <= 0) return 0;247 if (lineno <= 0) return 0;
248 if (lineno <= getLines())248 if (lineno <= getLines())
249 { 249 {
250 250
251 if (!index.isMapped())251 if (!index.isMapped())
252 index.map();252 index.map();
253 253
254 int res;254 int res;
255 index.get((unsigned char*)&res,sizeof(int),(lineno-1)*sizeof(int));255 index.get((unsigned char*)&res,sizeof(int),(lineno-1)*sizeof(int));
256 return res;256 return res;
@@ -345,7 +345,7 @@
345bool HistoryScrollBuffer::isWrappedLine(int lineNumber)345bool HistoryScrollBuffer::isWrappedLine(int lineNumber)
346{346{
347 Q_ASSERT( lineNumber >= 0 && lineNumber < _maxLineCount );347 Q_ASSERT( lineNumber >= 0 && lineNumber < _maxLineCount );
348 348
349 if (lineNumber < _usedLines)349 if (lineNumber < _usedLines)
350 {350 {
351 //kDebug() << "Line" << lineNumber << "wrapped is" << _wrappedLine[bufferIndex(lineNumber)];351 //kDebug() << "Line" << lineNumber << "wrapped is" << _wrappedLine[bufferIndex(lineNumber)];
@@ -361,12 +361,12 @@
361361
362 Q_ASSERT( lineNumber < _maxLineCount );362 Q_ASSERT( lineNumber < _maxLineCount );
363363
364 if (lineNumber >= _usedLines) 364 if (lineNumber >= _usedLines)
365 {365 {
366 memset(buffer, 0, count * sizeof(Character));366 memset(buffer, 0, count * sizeof(Character));
367 return;367 return;
368 }368 }
369 369
370 const HistoryLine& line = _historyBuffer[bufferIndex(lineNumber)];370 const HistoryLine& line = _historyBuffer[bufferIndex(lineNumber)];
371371
372 //kDebug() << "startCol " << startColumn;372 //kDebug() << "startCol " << startColumn;
@@ -374,7 +374,7 @@
374 //kDebug() << "count " << count;374 //kDebug() << "count " << count;
375375
376 Q_ASSERT( startColumn <= line.size() - count );376 Q_ASSERT( startColumn <= line.size() - count );
377 377
378 memcpy(buffer, line.constData() + startColumn , count * sizeof(Character));378 memcpy(buffer, line.constData() + startColumn , count * sizeof(Character));
379}379}
380380
@@ -382,12 +382,12 @@
382{382{
383 HistoryLine* oldBuffer = _historyBuffer;383 HistoryLine* oldBuffer = _historyBuffer;
384 HistoryLine* newBuffer = new HistoryLine[lineCount];384 HistoryLine* newBuffer = new HistoryLine[lineCount];
385 385
386 for ( int i = 0 ; i < qMin(_usedLines,(int)lineCount) ; i++ )386 for ( int i = 0 ; i < qMin(_usedLines,(int)lineCount) ; i++ )
387 {387 {
388 newBuffer[i] = oldBuffer[bufferIndex(i)];388 newBuffer[i] = oldBuffer[bufferIndex(i)];
389 }389 }
390 390
391 _usedLines = qMin(_usedLines,(int)lineCount);391 _usedLines = qMin(_usedLines,(int)lineCount);
392 _maxLineCount = lineCount;392 _maxLineCount = lineCount;
393 _head = ( _usedLines == _maxLineCount ) ? 0 : _usedLines-1;393 _head = ( _usedLines == _maxLineCount ) ? 0 : _usedLines-1;
@@ -410,7 +410,7 @@
410 return (_head+lineNumber+1) % _maxLineCount;410 return (_head+lineNumber+1) % _maxLineCount;
411 }411 }
412 else412 else
413 { 413 {
414 return lineNumber;414 return lineNumber;
415 }415 }
416}416}
@@ -508,7 +508,7 @@
508void HistoryScrollBlockArray::addCells(const Character a[], int count)508void HistoryScrollBlockArray::addCells(const Character a[], int count)
509{509{
510 Block *b = m_blockArray.lastBlock();510 Block *b = m_blockArray.lastBlock();
511 511
512 if (!b) return;512 if (!b) return;
513513
514 // put cells in block's data514 // put cells in block's data
@@ -572,17 +572,17 @@
572void CompactHistoryBlockList::deallocate(void* ptr)572void CompactHistoryBlockList::deallocate(void* ptr)
573{573{
574 Q_ASSERT( !list.isEmpty());574 Q_ASSERT( !list.isEmpty());
575 575
576 int i=0; 576 int i=0;
577 CompactHistoryBlock *block = list.at(i);577 CompactHistoryBlock *block = list.at(i);
578 while ( i<list.size() && !block->contains(ptr) )578 while ( i<list.size() && !block->contains(ptr) )
579 { 579 {
580 i++;580 i++;
581 block=list.at(i);581 block=list.at(i);
582 }582 }
583583
584 Q_ASSERT( i<list.size() );584 Q_ASSERT( i<list.size() );
585 585
586 block->deallocate();586 block->deallocate();
587587
588 if (!block->isInUse())588 if (!block->isInUse())
@@ -604,16 +604,16 @@
604 return blockList.allocate(size);604 return blockList.allocate(size);
605}605}
606606
607CompactHistoryLine::CompactHistoryLine ( const TextLine& line, CompactHistoryBlockList& bList ) 607CompactHistoryLine::CompactHistoryLine ( const TextLine& line, CompactHistoryBlockList& bList )
608 : blockList(bList),608 : blockList(bList),
609 formatLength(0)609 formatLength(0)
610{610{
611 length=line.size();611 length=line.size();
612 612
613 if (line.size() > 0) {613 if (line.size() > 0) {
614 formatLength=1;614 formatLength=1;
615 int k=1;615 int k=1;
616 616
617 // count number of different formats in this text line617 // count number of different formats in this text line
618 Character c = line[0];618 Character c = line[0];
619 while ( k<length )619 while ( k<length )
@@ -625,22 +625,22 @@
625 }625 }
626 k++;626 k++;
627 }627 }
628 628
629 //kDebug() << "number of different formats in string: " << formatLength;629 //kDebug() << "number of different formats in string: " << formatLength;
630 formatArray = (CharacterFormat*) blockList.allocate(sizeof(CharacterFormat)*formatLength);630 formatArray = (CharacterFormat*) blockList.allocate(sizeof(CharacterFormat)*formatLength);
631 Q_ASSERT (formatArray!=NULL);631 Q_ASSERT (formatArray!=NULL);
632 text = (quint16*) blockList.allocate(sizeof(quint16)*line.size());632 text = (quint16*) blockList.allocate(sizeof(quint16)*line.size());
633 Q_ASSERT (text!=NULL);633 Q_ASSERT (text!=NULL);
634 634
635 length=line.size();635 length=line.size();
636 formatLength=formatLength;636 formatLength=formatLength;
637 wrapped=false;637 wrapped=false;
638 638
639 // record formats and their positions in the format array639 // record formats and their positions in the format array
640 c=line[0];640 c=line[0];
641 formatArray[0].setFormat ( c );641 formatArray[0].setFormat ( c );
642 formatArray[0].startPos=0; // there's always at least 1 format (for the entire line, unless a change happens)642 formatArray[0].startPos=0; // there's always at least 1 format (for the entire line, unless a change happens)
643 643
644 k=1; // look for possible format changes644 k=1; // look for possible format changes
645 int j=1;645 int j=1;
646 while ( k<length && j<formatLength )646 while ( k<length && j<formatLength )
@@ -655,7 +655,7 @@
655 }655 }
656 k++;656 k++;
657 }657 }
658 658
659 // copy character values659 // copy character values
660 for ( int i=0; i<line.size(); i++ )660 for ( int i=0; i<line.size(); i++ )
661 {661 {
@@ -673,7 +673,7 @@
673 blockList.deallocate(text);673 blockList.deallocate(text);
674 blockList.deallocate(formatArray);674 blockList.deallocate(formatArray);
675 }675 }
676 blockList.deallocate(this); 676 blockList.deallocate(this);
677}677}
678678
679void CompactHistoryLine::getCharacter ( int index, Character &r )679void CompactHistoryLine::getCharacter ( int index, Character &r )
@@ -918,7 +918,7 @@
918918
919HistoryScroll* HistoryTypeFile::scroll(HistoryScroll *old) const919HistoryScroll* HistoryTypeFile::scroll(HistoryScroll *old) const
920{920{
921 if (dynamic_cast<HistoryFile *>(old)) 921 if (dynamic_cast<HistoryFile *>(old))
922 return old; // Unchanged.922 return old; // Unchanged.
923923
924 HistoryScroll *newScroll = new HistoryScrollFile(m_fileName);924 HistoryScroll *newScroll = new HistoryScrollFile(m_fileName);
@@ -945,7 +945,7 @@
945 }945 }
946946
947 delete old;947 delete old;
948 return newScroll; 948 return newScroll;
949}949}
950950
951int HistoryTypeFile::maximumLineCount() const951int HistoryTypeFile::maximumLineCount() const
952952
=== modified file 'src/plugin/konsole/History.h'
--- src/plugin/konsole/History.h 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/History.h 2014-07-30 09:50:10 +0000
@@ -68,7 +68,7 @@
6868
69 //pointer to start of mmap'ed file data, or 0 if the file is not mmap'ed69 //pointer to start of mmap'ed file data, or 0 if the file is not mmap'ed
70 char* fileMap;70 char* fileMap;
71 71
72 //incremented whenver 'add' is called and decremented whenever72 //incremented whenver 'add' is called and decremented whenever
73 //'get' is called.73 //'get' is called.
74 //this is used to detect when a large number of lines are being read and processed from the history74 //this is used to detect when a large number of lines are being read and processed from the history
@@ -179,7 +179,7 @@
179179
180 void setMaxNbLines(unsigned int nbLines);180 void setMaxNbLines(unsigned int nbLines);
181 unsigned int maxNbLines() { return _maxLineCount; }181 unsigned int maxNbLines() { return _maxLineCount; }
182 182
183183
184private:184private:
185 int bufferIndex(int lineNumber);185 int bufferIndex(int lineNumber);
@@ -187,9 +187,9 @@
187 HistoryLine* _historyBuffer;187 HistoryLine* _historyBuffer;
188 QBitArray _wrappedLine;188 QBitArray _wrappedLine;
189 int _maxLineCount;189 int _maxLineCount;
190 int _usedLines; 190 int _usedLines;
191 int _head;191 int _head;
192 192
193 //QVector<histline*> m_histBuffer;193 //QVector<histline*> m_histBuffer;
194 //QBitArray m_wrappedLine;194 //QBitArray m_wrappedLine;
195 //unsigned int m_maxNbLines;195 //unsigned int m_maxNbLines;
@@ -288,7 +288,7 @@
288class CompactHistoryBlock288class CompactHistoryBlock
289{289{
290public:290public:
291 291
292 CompactHistoryBlock(){292 CompactHistoryBlock(){
293 blockLength = 4096*64; // 256kb293 blockLength = 4096*64; // 256kb
294 head = (quint8*) mmap(0, blockLength, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);294 head = (quint8*) mmap(0, blockLength, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
@@ -297,12 +297,12 @@
297 tail = blockStart = head;297 tail = blockStart = head;
298 allocCount=0;298 allocCount=0;
299 }299 }
300 300
301 virtual ~CompactHistoryBlock(){301 virtual ~CompactHistoryBlock(){
302 //free(blockStart);302 //free(blockStart);
303 munmap(blockStart, blockLength);303 munmap(blockStart, blockLength);
304 }304 }
305 305
306 virtual unsigned int remaining(){ return blockStart+blockLength-tail;}306 virtual unsigned int remaining(){ return blockStart+blockLength-tail;}
307 virtual unsigned length() { return blockLength; }307 virtual unsigned length() { return blockLength; }
308 virtual void* allocate(size_t length);308 virtual void* allocate(size_t length);
@@ -379,7 +379,7 @@
379 bool hasDifferentColors(const TextLine& line) const;379 bool hasDifferentColors(const TextLine& line) const;
380 HistoryArray lines;380 HistoryArray lines;
381 CompactHistoryBlockList blockList;381 CompactHistoryBlockList blockList;
382 382
383 unsigned int _maxLineCount;383 unsigned int _maxLineCount;
384};384};
385385
@@ -395,7 +395,7 @@
395395
396 /**396 /**
397 * Returns true if the history is enabled ( can store lines of output )397 * Returns true if the history is enabled ( can store lines of output )
398 * or false otherwise. 398 * or false otherwise.
399 */399 */
400 virtual bool isEnabled() const = 0;400 virtual bool isEnabled() const = 0;
401 /**401 /**
@@ -426,7 +426,7 @@
426{426{
427public:427public:
428 HistoryTypeBlockArray(size_t size);428 HistoryTypeBlockArray(size_t size);
429 429
430 virtual bool isEnabled() const;430 virtual bool isEnabled() const;
431 virtual int maximumLineCount() const;431 virtual int maximumLineCount() const;
432432
@@ -436,7 +436,7 @@
436 size_t m_size;436 size_t m_size;
437};437};
438438
439#if 1 439#if 1
440class HistoryTypeFile : public HistoryType440class HistoryTypeFile : public HistoryType
441{441{
442public:442public:
@@ -459,10 +459,10 @@
459459
460public:460public:
461 HistoryTypeBuffer(unsigned int nbLines);461 HistoryTypeBuffer(unsigned int nbLines);
462 462
463 virtual bool isEnabled() const;463 virtual bool isEnabled() const;
464 virtual int maximumLineCount() const;464 virtual int maximumLineCount() const;
465 465
466 virtual HistoryScroll* scroll(HistoryScroll *) const;466 virtual HistoryScroll* scroll(HistoryScroll *) const;
467467
468protected:468protected:
@@ -473,7 +473,7 @@
473{473{
474public:474public:
475 CompactHistoryType(unsigned int size);475 CompactHistoryType(unsigned int size);
476 476
477 virtual bool isEnabled() const;477 virtual bool isEnabled() const;
478 virtual int maximumLineCount() const;478 virtual int maximumLineCount() const;
479479
480480
=== modified file 'src/plugin/konsole/KeyboardTranslator.cpp'
--- src/plugin/konsole/KeyboardTranslator.cpp 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/KeyboardTranslator.cpp 2014-07-30 09:50:10 +0000
@@ -83,8 +83,8 @@
83 QString translatorPath = listIter.next();83 QString translatorPath = listIter.next();
8484
85 QString name = QFileInfo(translatorPath).baseName();85 QString name = QFileInfo(translatorPath).baseName();
86 86
87 if ( !_translators.contains(name) ) 87 if ( !_translators.contains(name) )
88 _translators.insert(name,0);88 _translators.insert(name,0);
89 }89 }
9090
@@ -122,7 +122,7 @@
122 QFile destination(path);122 QFile destination(path);
123 if (!destination.open(QIODevice::WriteOnly | QIODevice::Text))123 if (!destination.open(QIODevice::WriteOnly | QIODevice::Text))
124 {124 {
125 qDebug() << "Unable to save keyboard translation:" 125 qDebug() << "Unable to save keyboard translation:"
126 << destination.errorString();126 << destination.errorString();
127 return false;127 return false;
128 }128 }
@@ -130,7 +130,7 @@
130 {130 {
131 KeyboardTranslatorWriter writer(&destination);131 KeyboardTranslatorWriter writer(&destination);
132 writer.writeHeader(translator->description());132 writer.writeHeader(translator->description());
133 133
134 QListIterator<KeyboardTranslator::Entry> iter(translator->entries());134 QListIterator<KeyboardTranslator::Entry> iter(translator->entries());
135 while ( iter.hasNext() )135 while ( iter.hasNext() )
136 writer.writeEntry(iter.next());136 writer.writeEntry(iter.next());
@@ -145,7 +145,7 @@
145{145{
146 const QString& path = findTranslatorPath(name);146 const QString& path = findTranslatorPath(name);
147147
148 QFile source(path); 148 QFile source(path);
149 if (name.isEmpty() || !source.open(QIODevice::ReadOnly | QIODevice::Text))149 if (name.isEmpty() || !source.open(QIODevice::ReadOnly | QIODevice::Text))
150 return 0;150 return 0;
151151
@@ -224,7 +224,7 @@
224// KeySequence begins with the name of the key ( taken from the Qt::Key enum )224// KeySequence begins with the name of the key ( taken from the Qt::Key enum )
225// and is followed by the keyboard modifiers and state flags ( with + or - in front225// and is followed by the keyboard modifiers and state flags ( with + or - in front
226// of each modifier or flag to indicate whether it is required ). All keyboard modifiers226// of each modifier or flag to indicate whether it is required ). All keyboard modifiers
227// and flags are optional, if a particular modifier or state is not specified it is 227// and flags are optional, if a particular modifier or state is not specified it is
228// assumed not to be a part of the sequence. The key sequence may contain whitespace228// assumed not to be a part of the sequence. The key sequence may contain whitespace
229//229//
230// eg: "key Up+Shift : scrollLineUp"230// eg: "key Up+Shift : scrollLineUp"
@@ -248,7 +248,7 @@
248 // read first entry (if any)248 // read first entry (if any)
249 readNext();249 readNext();
250}250}
251void KeyboardTranslatorReader::readNext() 251void KeyboardTranslatorReader::readNext()
252{252{
253 // find next entry253 // find next entry
254 while ( !_source->atEnd() )254 while ( !_source->atEnd() )
@@ -268,7 +268,7 @@
268 modifiers,268 modifiers,
269 modifierMask,269 modifierMask,
270 flags,270 flags,
271 flagMask); 271 flagMask);
272272
273 KeyboardTranslator::Command command = KeyboardTranslator::NoCommand;273 KeyboardTranslator::Command command = KeyboardTranslator::NoCommand;
274 QByteArray text;274 QByteArray text;
@@ -300,12 +300,12 @@
300300
301 return;301 return;
302 }302 }
303 } 303 }
304304
305 _hasNext = false;305 _hasNext = false;
306}306}
307307
308bool KeyboardTranslatorReader::parseAsCommand(const QString& text,KeyboardTranslator::Command& command) 308bool KeyboardTranslatorReader::parseAsCommand(const QString& text,KeyboardTranslator::Command& command)
309{309{
310 if ( text.compare("erase",Qt::CaseInsensitive) == 0 )310 if ( text.compare("erase",Qt::CaseInsensitive) == 0 )
311 command = KeyboardTranslator::EraseCommand;311 command = KeyboardTranslator::EraseCommand;
@@ -332,7 +332,7 @@
332 KeyboardTranslator::States& flags,332 KeyboardTranslator::States& flags,
333 KeyboardTranslator::States& flagMask)333 KeyboardTranslator::States& flagMask)
334{334{
335 bool isWanted = true; 335 bool isWanted = true;
336 bool endOfItem = false;336 bool endOfItem = false;
337 QString buffer;337 QString buffer;
338338
@@ -384,13 +384,13 @@
384 buffer.clear();384 buffer.clear();
385 }385 }
386386
387 // check if this is a wanted / not-wanted flag and update the 387 // check if this is a wanted / not-wanted flag and update the
388 // state ready for the next item388 // state ready for the next item
389 if ( ch == '+' )389 if ( ch == '+' )
390 isWanted = true;390 isWanted = true;
391 else if ( ch == '-' )391 else if ( ch == '-' )
392 isWanted = false; 392 isWanted = false;
393 } 393 }
394394
395 modifiers = tempModifiers;395 modifiers = tempModifiers;
396 modifierMask = tempModifierMask;396 modifierMask = tempModifierMask;
@@ -467,7 +467,7 @@
467{467{
468 return _hasNext;468 return _hasNext;
469}469}
470KeyboardTranslator::Entry KeyboardTranslatorReader::createEntry( const QString& condition , 470KeyboardTranslator::Entry KeyboardTranslatorReader::createEntry( const QString& condition ,
471 const QString& result )471 const QString& result )
472{472{
473 QString entryString("keyboard \"temporary\"\nkey ");473 QString entryString("keyboard \"temporary\"\nkey ");
@@ -495,7 +495,7 @@
495 return entry;495 return entry;
496}496}
497497
498KeyboardTranslator::Entry KeyboardTranslatorReader::nextEntry() 498KeyboardTranslator::Entry KeyboardTranslatorReader::nextEntry()
499{499{
500 Q_ASSERT( _hasNext );500 Q_ASSERT( _hasNext );
501 KeyboardTranslator::Entry entry = _nextEntry;501 KeyboardTranslator::Entry entry = _nextEntry;
@@ -510,7 +510,7 @@
510{510{
511 QString text = line;511 QString text = line;
512512
513 // remove comments 513 // remove comments
514 bool inQuotes = false;514 bool inQuotes = false;
515 int commentPos = -1;515 int commentPos = -1;
516 for (int i=text.length()-1;i>=0;i--)516 for (int i=text.length()-1;i>=0;i--)
@@ -525,7 +525,7 @@
525 text.remove(commentPos,text.length());525 text.remove(commentPos,text.length());
526526
527 text = text.simplified();527 text = text.simplified();
528 528
529 // title line: keyboard "title"529 // title line: keyboard "title"
530 static QRegExp title("keyboard\\s+\"(.*)\"");530 static QRegExp title("keyboard\\s+\"(.*)\"");
531 // key line: key KeySequence : "output"531 // key line: key KeySequence : "output"
@@ -533,7 +533,7 @@
533 static QRegExp key("key\\s+([\\w\\+\\s\\-\\*\\.]+)\\s*:\\s*(\"(.*)\"|\\w+)");533 static QRegExp key("key\\s+([\\w\\+\\s\\-\\*\\.]+)\\s*:\\s*(\"(.*)\"|\\w+)");
534534
535 QList<Token> list;535 QList<Token> list;
536 if ( text.isEmpty() ) 536 if ( text.isEmpty() )
537 {537 {
538 return list;538 return list;
539 }539 }
@@ -542,7 +542,7 @@
542 {542 {
543 Token titleToken = { Token::TitleKeyword , QString() };543 Token titleToken = { Token::TitleKeyword , QString() };
544 Token textToken = { Token::TitleText , title.capturedTexts()[1] };544 Token textToken = { Token::TitleText , title.capturedTexts()[1] };
545 545
546 list << titleToken << textToken;546 list << titleToken << textToken;
547 }547 }
548 else if ( key.exactMatch(text) )548 else if ( key.exactMatch(text) )
@@ -556,14 +556,14 @@
556 {556 {
557 // capturedTexts()[2] is a command557 // capturedTexts()[2] is a command
558 Token commandToken = { Token::Command , key.capturedTexts()[2] };558 Token commandToken = { Token::Command , key.capturedTexts()[2] };
559 list << commandToken; 559 list << commandToken;
560 } 560 }
561 else561 else
562 {562 {
563 // capturedTexts()[3] is the output string563 // capturedTexts()[3] is the output string
564 Token outputToken = { Token::OutputText , key.capturedTexts()[3] };564 Token outputToken = { Token::OutputText , key.capturedTexts()[3] };
565 list << outputToken;565 list << outputToken;
566 } 566 }
567 }567 }
568 else568 else
569 {569 {
@@ -573,7 +573,7 @@
573 return list;573 return list;
574}574}
575575
576QList<QString> KeyboardTranslatorManager::allTranslators() 576QList<QString> KeyboardTranslatorManager::allTranslators()
577{577{
578 if ( !_haveLoadedAll )578 if ( !_haveLoadedAll )
579 {579 {
@@ -604,14 +604,14 @@
604 _text == rhs._text;604 _text == rhs._text;
605}605}
606606
607bool KeyboardTranslator::Entry::matches(int keyCode , 607bool KeyboardTranslator::Entry::matches(int keyCode ,
608 Qt::KeyboardModifiers modifiers,608 Qt::KeyboardModifiers modifiers,
609 States testState) const609 States testState) const
610{610{
611 if ( _keyCode != keyCode )611 if ( _keyCode != keyCode )
612 return false;612 return false;
613613
614 if ( (modifiers & _modifierMask) != (_modifiers & _modifierMask) ) 614 if ( (modifiers & _modifierMask) != (_modifiers & _modifierMask) )
615 return false;615 return false;
616616
617 // if modifiers is non-zero, the 'any modifier' state is implicit617 // if modifiers is non-zero, the 'any modifier' state is implicit
@@ -621,7 +621,7 @@
621 if ( (testState & _stateMask) != (_state & _stateMask) )621 if ( (testState & _stateMask) != (_state & _stateMask) )
622 return false;622 return false;
623623
624 // special handling for the 'Any Modifier' state, which checks for the presence of 624 // special handling for the 'Any Modifier' state, which checks for the presence of
625 // any or no modifiers. In this context, the 'keypad' modifier does not count.625 // any or no modifiers. In this context, the 'keypad' modifier does not count.
626 bool anyModifiersSet = modifiers != 0 && modifiers != Qt::KeypadModifier;626 bool anyModifiersSet = modifiers != 0 && modifiers != Qt::KeypadModifier;
627 bool wantAnyModifier = _state & KeyboardTranslator::AnyModifierState;627 bool wantAnyModifier = _state & KeyboardTranslator::AnyModifierState;
@@ -630,7 +630,7 @@
630 if ( wantAnyModifier != anyModifiersSet )630 if ( wantAnyModifier != anyModifiersSet )
631 return false;631 return false;
632 }632 }
633 633
634 return true;634 return true;
635}635}
636QByteArray KeyboardTranslator::Entry::escapedText(bool expandWildCards,Qt::KeyboardModifiers modifiers) const636QByteArray KeyboardTranslator::Entry::escapedText(bool expandWildCards,Qt::KeyboardModifiers modifiers) const
@@ -659,7 +659,7 @@
659659
660 if ( replacement == 'x' )660 if ( replacement == 'x' )
661 {661 {
662 result.replace(i,1,"\\x"+QByteArray(1,ch).toHex()); 662 result.replace(i,1,"\\x"+QByteArray(1,ch).toHex());
663 } else if ( replacement != 0 )663 } else if ( replacement != 0 )
664 {664 {
665 result.remove(i,1);665 result.remove(i,1);
@@ -707,7 +707,7 @@
707 unsigned charValue = 0;707 unsigned charValue = 0;
708 sscanf(hexDigits,"%x",&charValue);708 sscanf(hexDigits,"%x",&charValue);
709709
710 replacement[0] = (char)charValue; 710 replacement[0] = (char)charValue;
711 charsToRemove = 2 + strlen(hexDigits);711 charsToRemove = 2 + strlen(hexDigits);
712 }712 }
713 break;713 break;
@@ -811,7 +811,7 @@
811{811{
812}812}
813813
814void KeyboardTranslator::setDescription(const QString& description) 814void KeyboardTranslator::setDescription(const QString& description)
815{815{
816 _description = description;816 _description = description;
817}817}
@@ -874,7 +874,7 @@
874 if ( QFile::remove(path) )874 if ( QFile::remove(path) )
875 {875 {
876 _translators.remove(name);876 _translators.remove(name);
877 return true; 877 return true;
878 }878 }
879 else879 else
880 {880 {
881881
=== modified file 'src/plugin/konsole/KeyboardTranslator.h'
--- src/plugin/konsole/KeyboardTranslator.h 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/KeyboardTranslator.h 2014-07-30 09:50:10 +0000
@@ -37,7 +37,7 @@
37class QTextStream;37class QTextStream;
3838
3939
40/** 40/**
41 * A convertor which maps between key sequences pressed by the user and the41 * A convertor which maps between key sequences pressed by the user and the
42 * character strings which should be sent to the terminal and commands42 * character strings which should be sent to the terminal and commands
43 * which should be invoked when those character sequences are pressed.43 * which should be invoked when those character sequences are pressed.
@@ -53,7 +53,7 @@
53class KeyboardTranslator53class KeyboardTranslator
54{54{
55public:55public:
56 /** 56 /**
57 * The meaning of a particular key sequence may depend upon the state which57 * The meaning of a particular key sequence may depend upon the state which
58 * the terminal emulation is in. Therefore findEntry() may return a different58 * the terminal emulation is in. Therefore findEntry() may return a different
59 * Entry depending upon the state flags supplied.59 * Entry depending upon the state flags supplied.
@@ -69,7 +69,7 @@
69 * TODO More documentation69 * TODO More documentation
70 */70 */
71 NewLineState = 1,71 NewLineState = 1,
72 /** 72 /**
73 * Indicates that the terminal is in 'Ansi' mode.73 * Indicates that the terminal is in 'Ansi' mode.
74 * TODO: More documentation74 * TODO: More documentation
75 */75 */
@@ -80,10 +80,10 @@
80 CursorKeysState = 4,80 CursorKeysState = 4,
81 /**81 /**
82 * Indicates that the alternate screen ( typically used by interactive programs82 * Indicates that the alternate screen ( typically used by interactive programs
83 * such as screen or vim ) is active 83 * such as screen or vim ) is active
84 */84 */
85 AlternateScreenState = 8,85 AlternateScreenState = 8,
86 /** Indicates that any of the modifier keys is active. */ 86 /** Indicates that any of the modifier keys is active. */
87 AnyModifierState = 16,87 AnyModifierState = 16,
88 /** Indicates that the numpad is in application mode. */88 /** Indicates that the numpad is in application mode. */
89 ApplicationKeypadState = 3289 ApplicationKeypadState = 32
@@ -122,14 +122,14 @@
122 class Entry122 class Entry
123 {123 {
124 public:124 public:
125 /** 125 /**
126 * Constructs a new entry for a keyboard translator.126 * Constructs a new entry for a keyboard translator.
127 */127 */
128 Entry();128 Entry();
129129
130 /** 130 /**
131 * Returns true if this entry is null.131 * Returns true if this entry is null.
132 * This is true for newly constructed entries which have no properties set. 132 * This is true for newly constructed entries which have no properties set.
133 */133 */
134 bool isNull() const;134 bool isNull() const;
135135
@@ -138,15 +138,15 @@
138 /** Sets the command associated with this entry. */138 /** Sets the command associated with this entry. */
139 void setCommand(Command command);139 void setCommand(Command command);
140140
141 /** 141 /**
142 * Returns the character sequence associated with this entry, optionally replacing 142 * Returns the character sequence associated with this entry, optionally replacing
143 * wildcard '*' characters with numbers to indicate the keyboard modifiers being pressed.143 * wildcard '*' characters with numbers to indicate the keyboard modifiers being pressed.
144 *144 *
145 * TODO: The numbers used to replace '*' characters are taken from the Konsole/KDE 3 code.145 * TODO: The numbers used to replace '*' characters are taken from the Konsole/KDE 3 code.
146 * Document them. 146 * Document them.
147 *147 *
148 * @param expandWildCards Specifies whether wild cards (occurrences of the '*' character) in148 * @param expandWildCards Specifies whether wild cards (occurrences of the '*' character) in
149 * the entry should be replaced with a number to indicate the modifier keys being pressed. 149 * the entry should be replaced with a number to indicate the modifier keys being pressed.
150 *150 *
151 * @param modifiers The keyboard modifiers being pressed.151 * @param modifiers The keyboard modifiers being pressed.
152 */152 */
@@ -156,7 +156,7 @@
156 /** Sets the character sequence associated with this entry */156 /** Sets the character sequence associated with this entry */
157 void setText(const QByteArray& text);157 void setText(const QByteArray& text);
158158
159 /** 159 /**
160 * Returns the character sequence associated with this entry,160 * Returns the character sequence associated with this entry,
161 * with any non-printable characters replaced with escape sequences.161 * with any non-printable characters replaced with escape sequences.
162 *162 *
@@ -173,13 +173,13 @@
173 /** Sets the character code associated with this entry */173 /** Sets the character code associated with this entry */
174 void setKeyCode(int keyCode);174 void setKeyCode(int keyCode);
175175
176 /** 176 /**
177 * Returns a bitwise-OR of the enabled keyboard modifiers associated with this entry. 177 * Returns a bitwise-OR of the enabled keyboard modifiers associated with this entry.
178 * If a modifier is set in modifierMask() but not in modifiers(), this means that the entry178 * If a modifier is set in modifierMask() but not in modifiers(), this means that the entry
179 * only matches when that modifier is NOT pressed.179 * only matches when that modifier is NOT pressed.
180 *180 *
181 * If a modifier is not set in modifierMask() then the entry matches whether the modifier181 * If a modifier is not set in modifierMask() then the entry matches whether the modifier
182 * is pressed or not. 182 * is pressed or not.
183 */183 */
184 Qt::KeyboardModifiers modifiers() const;184 Qt::KeyboardModifiers modifiers() const;
185185
@@ -191,13 +191,13 @@
191 /** See modifierMask() and modifiers() */191 /** See modifierMask() and modifiers() */
192 void setModifierMask( Qt::KeyboardModifiers modifiers );192 void setModifierMask( Qt::KeyboardModifiers modifiers );
193193
194 /** 194 /**
195 * Returns a bitwise-OR of the enabled state flags associated with this entry. 195 * Returns a bitwise-OR of the enabled state flags associated with this entry.
196 * If flag is set in stateMask() but not in state(), this means that the entry only 196 * If flag is set in stateMask() but not in state(), this means that the entry only
197 * matches when the terminal is NOT in that state.197 * matches when the terminal is NOT in that state.
198 *198 *
199 * If a state is not set in stateMask() then the entry matches whether the terminal199 * If a state is not set in stateMask() then the entry matches whether the terminal
200 * is in that state or not. 200 * is in that state or not.
201 */201 */
202 States state() const;202 States state() const;
203203
@@ -209,13 +209,13 @@
209 /** See stateMask() */209 /** See stateMask() */
210 void setStateMask( States mask );210 void setStateMask( States mask );
211211
212 /** 212 /**
213 * Returns the key code and modifiers associated with this entry 213 * Returns the key code and modifiers associated with this entry
214 * as a QKeySequence214 * as a QKeySequence
215 */215 */
216 //QKeySequence keySequence() const;216 //QKeySequence keySequence() const;
217217
218 /** 218 /**
219 * Returns this entry's conditions ( ie. its key code, modifier and state criteria )219 * Returns this entry's conditions ( ie. its key code, modifier and state criteria )
220 * as a string.220 * as a string.
221 */221 */
@@ -231,16 +231,16 @@
231 QString resultToString(bool expandWildCards = false,231 QString resultToString(bool expandWildCards = false,
232 Qt::KeyboardModifiers modifiers = Qt::NoModifier) const;232 Qt::KeyboardModifiers modifiers = Qt::NoModifier) const;
233233
234 /** 234 /**
235 * Returns true if this entry matches the given key sequence, specified235 * Returns true if this entry matches the given key sequence, specified
236 * as a combination of @p keyCode , @p modifiers and @p state.236 * as a combination of @p keyCode , @p modifiers and @p state.
237 */237 */
238 bool matches( int keyCode , 238 bool matches( int keyCode ,
239 Qt::KeyboardModifiers modifiers , 239 Qt::KeyboardModifiers modifiers ,
240 States flags ) const;240 States flags ) const;
241241
242 bool operator==(const Entry& rhs) const;242 bool operator==(const Entry& rhs) const;
243 243
244 private:244 private:
245 void insertModifier( QString& item , int modifier ) const;245 void insertModifier( QString& item , int modifier ) const;
246 void insertState( QString& item , int state ) const;246 void insertState( QString& item , int state ) const;
@@ -258,7 +258,7 @@
258258
259 /** Constructs a new keyboard translator with the given @p name */259 /** Constructs a new keyboard translator with the given @p name */
260 KeyboardTranslator(const QString& name);260 KeyboardTranslator(const QString& name);
261 261
262 //KeyboardTranslator(const KeyboardTranslator& other);262 //KeyboardTranslator(const KeyboardTranslator& other);
263263
264 /** Returns the name of this keyboard translator */264 /** Returns the name of this keyboard translator */
@@ -276,7 +276,7 @@
276 /**276 /**
277 * Looks for an entry in this keyboard translator which matches the given277 * Looks for an entry in this keyboard translator which matches the given
278 * key code, keyboard modifiers and state flags.278 * key code, keyboard modifiers and state flags.
279 * 279 *
280 * Returns the matching entry if found or a null Entry otherwise ( ie.280 * Returns the matching entry if found or a null Entry otherwise ( ie.
281 * entry.isNull() will return true )281 * entry.isNull() will return true )
282 *282 *
@@ -284,11 +284,11 @@
284 * @param modifiers A combination of modifiers284 * @param modifiers A combination of modifiers
285 * @param state Optional flags which specify the current state of the terminal285 * @param state Optional flags which specify the current state of the terminal
286 */286 */
287 Entry findEntry(int keyCode , 287 Entry findEntry(int keyCode ,
288 Qt::KeyboardModifiers modifiers , 288 Qt::KeyboardModifiers modifiers ,
289 States state = NoState) const;289 States state = NoState) const;
290290
291 /** 291 /**
292 * Adds an entry to this keyboard translator's table. Entries can be looked up according292 * Adds an entry to this keyboard translator's table. Entries can be looked up according
293 * to their key sequence using findEntry()293 * to their key sequence using findEntry()
294 */294 */
@@ -319,8 +319,8 @@
319Q_DECLARE_OPERATORS_FOR_FLAGS(KeyboardTranslator::States)319Q_DECLARE_OPERATORS_FOR_FLAGS(KeyboardTranslator::States)
320Q_DECLARE_OPERATORS_FOR_FLAGS(KeyboardTranslator::Commands)320Q_DECLARE_OPERATORS_FOR_FLAGS(KeyboardTranslator::Commands)
321321
322/** 322/**
323 * Parses the contents of a Keyboard Translator (.keytab) file and 323 * Parses the contents of a Keyboard Translator (.keytab) file and
324 * returns the entries found in it.324 * returns the entries found in it.
325 *325 *
326 * Usage example:326 * Usage example:
@@ -340,7 +340,7 @@
340 * if ( !reader.parseError() )340 * if ( !reader.parseError() )
341 * {341 * {
342 * // parsing succeeded, do something with the translator342 * // parsing succeeded, do something with the translator
343 * } 343 * }
344 * else344 * else
345 * {345 * {
346 * // parsing failed346 * // parsing failed
@@ -353,18 +353,18 @@
353 /** Constructs a new reader which parses the given @p source */353 /** Constructs a new reader which parses the given @p source */
354 KeyboardTranslatorReader( QIODevice* source );354 KeyboardTranslatorReader( QIODevice* source );
355355
356 /** 356 /**
357 * Returns the description text. 357 * Returns the description text.
358 * TODO: More documentation 358 * TODO: More documentation
359 */359 */
360 QString description() const;360 QString description() const;
361361
362 /** Returns true if there is another entry in the source stream */362 /** Returns true if there is another entry in the source stream */
363 bool hasNextEntry();363 bool hasNextEntry();
364 /** Returns the next entry found in the source stream */364 /** Returns the next entry found in the source stream */
365 KeyboardTranslator::Entry nextEntry(); 365 KeyboardTranslator::Entry nextEntry();
366366
367 /** 367 /**
368 * Returns true if an error occurred whilst parsing the input or368 * Returns true if an error occurred whilst parsing the input or
369 * false if no error occurred.369 * false if no error occurred.
370 */370 */
@@ -374,7 +374,7 @@
374 * Parses a condition and result string for a translator entry374 * Parses a condition and result string for a translator entry
375 * and produces a keyboard translator entry.375 * and produces a keyboard translator entry.
376 *376 *
377 * The condition and result strings are in the same format as in 377 * The condition and result strings are in the same format as in
378 */378 */
379 static KeyboardTranslator::Entry createEntry( const QString& condition ,379 static KeyboardTranslator::Entry createEntry( const QString& condition ,
380 const QString& result );380 const QString& result );
@@ -395,7 +395,7 @@
395 };395 };
396 QList<Token> tokenize(const QString&);396 QList<Token> tokenize(const QString&);
397 void readNext();397 void readNext();
398 bool decodeSequence(const QString& , 398 bool decodeSequence(const QString& ,
399 int& keyCode,399 int& keyCode,
400 Qt::KeyboardModifiers& modifiers,400 Qt::KeyboardModifiers& modifiers,
401 Qt::KeyboardModifiers& modifierMask,401 Qt::KeyboardModifiers& modifierMask,
@@ -417,23 +417,23 @@
417class KeyboardTranslatorWriter417class KeyboardTranslatorWriter
418{418{
419public:419public:
420 /** 420 /**
421 * Constructs a new writer which saves data into @p destination.421 * Constructs a new writer which saves data into @p destination.
422 * The caller is responsible for closing the device when writing is complete.422 * The caller is responsible for closing the device when writing is complete.
423 */423 */
424 KeyboardTranslatorWriter(QIODevice* destination);424 KeyboardTranslatorWriter(QIODevice* destination);
425 ~KeyboardTranslatorWriter();425 ~KeyboardTranslatorWriter();
426426
427 /** 427 /**
428 * Writes the header for the keyboard translator. 428 * Writes the header for the keyboard translator.
429 * @param description Description of the keyboard translator. 429 * @param description Description of the keyboard translator.
430 */430 */
431 void writeHeader( const QString& description );431 void writeHeader( const QString& description );
432 /** Writes a translator entry. */432 /** Writes a translator entry. */
433 void writeEntry( const KeyboardTranslator::Entry& entry ); 433 void writeEntry( const KeyboardTranslator::Entry& entry );
434434
435private:435private:
436 QIODevice* _destination; 436 QIODevice* _destination;
437 QTextStream* _writer;437 QTextStream* _writer;
438};438};
439439
@@ -444,7 +444,7 @@
444class KONSOLEPRIVATE_EXPORT KeyboardTranslatorManager444class KONSOLEPRIVATE_EXPORT KeyboardTranslatorManager
445{445{
446public:446public:
447 /** 447 /**
448 * Constructs a new KeyboardTranslatorManager and loads the list of448 * Constructs a new KeyboardTranslatorManager and loads the list of
449 * available keyboard translations.449 * available keyboard translations.
450 *450 *
@@ -455,7 +455,7 @@
455 ~KeyboardTranslatorManager();455 ~KeyboardTranslatorManager();
456456
457 /**457 /**
458 * Adds a new translator. If a translator with the same name 458 * Adds a new translator. If a translator with the same name
459 * already exists, it will be replaced by the new translator.459 * already exists, it will be replaced by the new translator.
460 *460 *
461 * TODO: More documentation.461 * TODO: More documentation.
@@ -472,18 +472,18 @@
472 /** Returns the default translator for Konsole. */472 /** Returns the default translator for Konsole. */
473 const KeyboardTranslator* defaultTranslator();473 const KeyboardTranslator* defaultTranslator();
474474
475 /** 475 /**
476 * Returns the keyboard translator with the given name or 0 if no translator476 * Returns the keyboard translator with the given name or 0 if no translator
477 * with that name exists.477 * with that name exists.
478 *478 *
479 * The first time that a translator with a particular name is requested,479 * The first time that a translator with a particular name is requested,
480 * the on-disk .keyboard file is loaded and parsed. 480 * the on-disk .keyboard file is loaded and parsed.
481 */481 */
482 const KeyboardTranslator* findTranslator(const QString& name);482 const KeyboardTranslator* findTranslator(const QString& name);
483 /**483 /**
484 * Returns a list of the names of available keyboard translators.484 * Returns a list of the names of available keyboard translators.
485 *485 *
486 * The first time this is called, a search for available 486 * The first time this is called, a search for available
487 * translators is started.487 * translators is started.
488 */488 */
489 QList<QString> allTranslators();489 QList<QString> allTranslators();
@@ -493,15 +493,15 @@
493493
494private:494private:
495 static const QByteArray defaultTranslatorText;495 static const QByteArray defaultTranslatorText;
496 496
497 void findTranslators(); // locate the available translators497 void findTranslators(); // locate the available translators
498 KeyboardTranslator* loadTranslator(const QString& name); // loads the translator 498 KeyboardTranslator* loadTranslator(const QString& name); // loads the translator
499 // with the given name499 // with the given name
500 KeyboardTranslator* loadTranslator(QIODevice* device,const QString& name);500 KeyboardTranslator* loadTranslator(QIODevice* device,const QString& name);
501501
502 bool saveTranslator(const KeyboardTranslator* translator);502 bool saveTranslator(const KeyboardTranslator* translator);
503 QString findTranslatorPath(const QString& name);503 QString findTranslatorPath(const QString& name);
504 504
505 QHash<QString,KeyboardTranslator*> _translators; // maps translator-name -> KeyboardTranslator505 QHash<QString,KeyboardTranslator*> _translators; // maps translator-name -> KeyboardTranslator
506 // instance506 // instance
507 bool _haveLoadedAll;507 bool _haveLoadedAll;
@@ -512,15 +512,15 @@
512inline int KeyboardTranslator::Entry::keyCode() const { return _keyCode; }512inline int KeyboardTranslator::Entry::keyCode() const { return _keyCode; }
513inline void KeyboardTranslator::Entry::setKeyCode(int keyCode) { _keyCode = keyCode; }513inline void KeyboardTranslator::Entry::setKeyCode(int keyCode) { _keyCode = keyCode; }
514514
515inline void KeyboardTranslator::Entry::setModifiers( Qt::KeyboardModifiers modifier ) 515inline void KeyboardTranslator::Entry::setModifiers( Qt::KeyboardModifiers modifier )
516{ 516{
517 _modifiers = modifier;517 _modifiers = modifier;
518}518}
519inline Qt::KeyboardModifiers KeyboardTranslator::Entry::modifiers() const { return _modifiers; }519inline Qt::KeyboardModifiers KeyboardTranslator::Entry::modifiers() const { return _modifiers; }
520520
521inline void KeyboardTranslator::Entry::setModifierMask( Qt::KeyboardModifiers mask ) 521inline void KeyboardTranslator::Entry::setModifierMask( Qt::KeyboardModifiers mask )
522{ 522{
523 _modifierMask = mask; 523 _modifierMask = mask;
524}524}
525inline Qt::KeyboardModifiers KeyboardTranslator::Entry::modifierMask() const { return _modifierMask; }525inline Qt::KeyboardModifiers KeyboardTranslator::Entry::modifierMask() const { return _modifierMask; }
526526
@@ -530,23 +530,23 @@
530}530}
531531
532inline void KeyboardTranslator::Entry::setCommand( Command command )532inline void KeyboardTranslator::Entry::setCommand( Command command )
533{ 533{
534 _command = command; 534 _command = command;
535}535}
536inline KeyboardTranslator::Command KeyboardTranslator::Entry::command() const { return _command; }536inline KeyboardTranslator::Command KeyboardTranslator::Entry::command() const { return _command; }
537537
538inline void KeyboardTranslator::Entry::setText( const QByteArray& text )538inline void KeyboardTranslator::Entry::setText( const QByteArray& text )
539{ 539{
540 _text = unescape(text);540 _text = unescape(text);
541}541}
542inline int oneOrZero(int value)542inline int oneOrZero(int value)
543{543{
544 return value ? 1 : 0;544 return value ? 1 : 0;
545}545}
546inline QByteArray KeyboardTranslator::Entry::text(bool expandWildCards,Qt::KeyboardModifiers modifiers) const 546inline QByteArray KeyboardTranslator::Entry::text(bool expandWildCards,Qt::KeyboardModifiers modifiers) const
547{547{
548 QByteArray expandedText = _text;548 QByteArray expandedText = _text;
549 549
550 if (expandWildCards)550 if (expandWildCards)
551 {551 {
552 int modifierValue = 1;552 int modifierValue = 1;
@@ -554,25 +554,25 @@
554 modifierValue += oneOrZero(modifiers & Qt::AltModifier) << 1;554 modifierValue += oneOrZero(modifiers & Qt::AltModifier) << 1;
555 modifierValue += oneOrZero(modifiers & Qt::ControlModifier) << 2;555 modifierValue += oneOrZero(modifiers & Qt::ControlModifier) << 2;
556556
557 for (int i=0;i<_text.length();i++) 557 for (int i=0;i<_text.length();i++)
558 {558 {
559 if (expandedText[i] == '*')559 if (expandedText[i] == '*')
560 expandedText[i] = '0' + modifierValue;560 expandedText[i] = '0' + modifierValue;
561 }561 }
562 }562 }
563563
564 return expandedText; 564 return expandedText;
565}565}
566566
567inline void KeyboardTranslator::Entry::setState( States state )567inline void KeyboardTranslator::Entry::setState( States state )
568{ 568{
569 _state = state; 569 _state = state;
570}570}
571inline KeyboardTranslator::States KeyboardTranslator::Entry::state() const { return _state; }571inline KeyboardTranslator::States KeyboardTranslator::Entry::state() const { return _state; }
572572
573inline void KeyboardTranslator::Entry::setStateMask( States stateMask )573inline void KeyboardTranslator::Entry::setStateMask( States stateMask )
574{ 574{
575 _stateMask = stateMask; 575 _stateMask = stateMask;
576}576}
577inline KeyboardTranslator::States KeyboardTranslator::Entry::stateMask() const { return _stateMask; }577inline KeyboardTranslator::States KeyboardTranslator::Entry::stateMask() const { return _stateMask; }
578578
579579
=== modified file 'src/plugin/konsole/Pty.cpp'
--- src/plugin/konsole/Pty.cpp 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/Pty.cpp 2014-07-30 09:50:10 +0000
@@ -81,7 +81,7 @@
81 pty()->tcGetAttr(&ttmode);81 pty()->tcGetAttr(&ttmode);
82 return ttmode.c_iflag & IXOFF &&82 return ttmode.c_iflag & IXOFF &&
83 ttmode.c_iflag & IXON;83 ttmode.c_iflag & IXON;
84 } 84 }
85 qWarning() << "Unable to get flow control status, terminal not connected.";85 qWarning() << "Unable to get flow control status, terminal not connected.";
86 return false;86 return false;
87}87}
@@ -108,7 +108,7 @@
108void Pty::setErase(char erase)108void Pty::setErase(char erase)
109{109{
110 _eraseChar = erase;110 _eraseChar = erase;
111 111
112 if (pty()->masterFd() >= 0)112 if (pty()->masterFd() >= 0)
113 {113 {
114 struct ::termios ttmode;114 struct ::termios ttmode;
@@ -140,7 +140,7 @@
140140
141 // split on the first '=' character141 // split on the first '=' character
142 int pos = pair.indexOf('=');142 int pos = pair.indexOf('=');
143 143
144 if ( pos >= 0 )144 if ( pos >= 0 )
145 {145 {
146 QString variable = pair.left(pos);146 QString variable = pair.left(pos);
@@ -151,10 +151,10 @@
151 }151 }
152}152}
153153
154int Pty::start(const QString& program, 154int Pty::start(const QString& program,
155 const QStringList& programArguments, 155 const QStringList& programArguments,
156 const QStringList& environment, 156 const QStringList& environment,
157 ulong winid, 157 ulong winid,
158 bool addToUtmp158 bool addToUtmp
159 //const QString& dbusService,159 //const QString& dbusService,
160 //const QString& dbusSession160 //const QString& dbusSession
@@ -162,7 +162,7 @@
162{162{
163 clearProgram();163 clearProgram();
164164
165 // For historical reasons, the first argument in programArguments is the 165 // For historical reasons, the first argument in programArguments is the
166 // name of the program to execute, so create a list consisting of all166 // name of the program to execute, so create a list consisting of all
167 // but the first argument to pass to setProgram()167 // but the first argument to pass to setProgram()
168 Q_ASSERT(programArguments.count() >= 1);168 Q_ASSERT(programArguments.count() >= 1);
@@ -202,10 +202,10 @@
202202
203 if (_eraseChar != 0)203 if (_eraseChar != 0)
204 ttmode.c_cc[VERASE] = _eraseChar;204 ttmode.c_cc[VERASE] = _eraseChar;
205 205
206 if (!pty()->tcSetAttr(&ttmode))206 if (!pty()->tcSetAttr(&ttmode))
207 qWarning() << "Unable to set terminal attributes.";207 qWarning() << "Unable to set terminal attributes.";
208 208
209 pty()->setWinSize(_windowLines, _windowColumns);209 pty()->setWinSize(_windowLines, _windowColumns);
210210
211 KProcess::start();211 KProcess::start();
@@ -256,15 +256,15 @@
256{256{
257 if (!length)257 if (!length)
258 return;258 return;
259 259
260 if (!pty()->write(data,length)) 260 if (!pty()->write(data,length))
261 {261 {
262 qWarning() << "Pty::doSendJobs - Could not send input data to terminal process.";262 qWarning() << "Pty::doSendJobs - Could not send input data to terminal process.";
263 return;263 return;
264 }264 }
265}265}
266266
267void Pty::dataReceived() 267void Pty::dataReceived()
268{268{
269 QByteArray data = pty()->readAll();269 QByteArray data = pty()->readAll();
270 emit receivedData(data.constData(),data.count());270 emit receivedData(data.constData(),data.count());
@@ -288,7 +288,7 @@
288 if ( pid != -1 )288 if ( pid != -1 )
289 {289 {
290 return pid;290 return pid;
291 } 291 }
292292
293 return 0;293 return 0;
294}294}
@@ -296,9 +296,9 @@
296void Pty::setupChildProcess()296void Pty::setupChildProcess()
297{297{
298 KPtyProcess::setupChildProcess();298 KPtyProcess::setupChildProcess();
299 299
300 // reset all signal handlers300 // reset all signal handlers
301 // this ensures that terminal applications respond to 301 // this ensures that terminal applications respond to
302 // signals generated via key sequences such as Ctrl+C302 // signals generated via key sequences such as Ctrl+C
303 // (which sends SIGINT)303 // (which sends SIGINT)
304 struct sigaction action;304 struct sigaction action;
305305
=== modified file 'src/plugin/konsole/Pty.h'
--- src/plugin/konsole/Pty.h 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/Pty.h 2014-07-30 09:50:10 +0000
@@ -7,8 +7,8 @@
7 */7 */
88
9/*9/*
10 This file is part of Konsole, KDE's terminal emulator. 10 This file is part of Konsole, KDE's terminal emulator.
11 11
12 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>12 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
13 Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>13 Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
1414
@@ -42,8 +42,8 @@
4242
4343
44/**44/**
45 * The Pty class is used to start the terminal process, 45 * The Pty class is used to start the terminal process,
46 * send data to it, receive data from it and manipulate 46 * send data to it, receive data from it and manipulate
47 * various properties of the pseudo-teletype interface47 * various properties of the pseudo-teletype interface
48 * used to communicate with the process.48 * used to communicate with the process.
49 *49 *
@@ -52,26 +52,26 @@
52 * send data to or receive data from the process.52 * send data to or receive data from the process.
53 *53 *
54 * To start the terminal process, call the start() method54 * To start the terminal process, call the start() method
55 * with the program name and appropriate arguments. 55 * with the program name and appropriate arguments.
56 */56 */
57class Pty: public KPtyProcess57class Pty: public KPtyProcess
58{58{
59Q_OBJECT59Q_OBJECT
6060
61 public:61 public:
62 62
63 /** 63 /**
64 * Constructs a new Pty.64 * Constructs a new Pty.
65 * 65 *
66 * Connect to the sendData() slot and receivedData() signal to prepare66 * Connect to the sendData() slot and receivedData() signal to prepare
67 * for sending and receiving data from the terminal process.67 * for sending and receiving data from the terminal process.
68 *68 *
69 * To start the terminal process, call the run() method with the 69 * To start the terminal process, call the run() method with the
70 * name of the program to start and appropriate arguments.70 * name of the program to start and appropriate arguments.
71 */71 */
72 explicit Pty(QObject* parent = 0);72 explicit Pty(QObject* parent = 0);
7373
74 /** 74 /**
75 * Construct a process using an open pty master.75 * Construct a process using an open pty master.
76 * See KPtyProcess::KPtyProcess()76 * See KPtyProcess::KPtyProcess()
77 */77 */
@@ -80,7 +80,7 @@
80 ~Pty();80 ~Pty();
8181
82 /**82 /**
83 * Starts the terminal process. 83 * Starts the terminal process.
84 *84 *
85 * Returns 0 if the process was started successfully or non-zero85 * Returns 0 if the process was started successfully or non-zero
86 * otherwise.86 * otherwise.
@@ -93,23 +93,23 @@
93 * @param winid Specifies the value of the WINDOWID environment variable93 * @param winid Specifies the value of the WINDOWID environment variable
94 * in the process's environment.94 * in the process's environment.
95 * @param addToUtmp Specifies whether a utmp entry should be created for95 * @param addToUtmp Specifies whether a utmp entry should be created for
96 * the pty used. See K3Process::setUsePty() 96 * the pty used. See K3Process::setUsePty()
97 * @param dbusService Specifies the value of the KONSOLE_DBUS_SERVICE 97 * @param dbusService Specifies the value of the KONSOLE_DBUS_SERVICE
98 * environment variable in the process's environment.98 * environment variable in the process's environment.
99 * @param dbusSession Specifies the value of the KONSOLE_DBUS_SESSION99 * @param dbusSession Specifies the value of the KONSOLE_DBUS_SESSION
100 * environment variable in the process's environment. 100 * environment variable in the process's environment.
101 */101 */
102 int start( const QString& program, 102 int start( const QString& program,
103 const QStringList& arguments, 103 const QStringList& arguments,
104 const QStringList& environment, 104 const QStringList& environment,
105 ulong winid, 105 ulong winid,
106 bool addToUtmp106 bool addToUtmp
107 );107 );
108108
109 /** TODO: Document me */109 /** TODO: Document me */
110 void setWriteable(bool writeable);110 void setWriteable(bool writeable);
111111
112 /** 112 /**
113 * Enables or disables Xon/Xoff flow control. The flow control setting113 * Enables or disables Xon/Xoff flow control. The flow control setting
114 * may be changed later by a terminal application, so flowControlEnabled()114 * may be changed later by a terminal application, so flowControlEnabled()
115 * may not equal the value of @p on in the previous call to setFlowControlEnabled()115 * may not equal the value of @p on in the previous call to setFlowControlEnabled()
@@ -119,12 +119,12 @@
119 /** Queries the terminal state and returns true if Xon/Xoff flow control is enabled. */119 /** Queries the terminal state and returns true if Xon/Xoff flow control is enabled. */
120 bool flowControlEnabled() const;120 bool flowControlEnabled() const;
121121
122 /** 122 /**
123 * Sets the size of the window (in lines and columns of characters) 123 * Sets the size of the window (in lines and columns of characters)
124 * used by this teletype.124 * used by this teletype.
125 */125 */
126 void setWindowSize(int lines, int cols);126 void setWindowSize(int lines, int cols);
127 127
128 /** Returns the size of the window used by this teletype. See setWindowSize() */128 /** Returns the size of the window used by this teletype. See setWindowSize() */
129 QSize windowSize() const;129 QSize windowSize() const;
130130
@@ -143,7 +143,7 @@
143 * 0 will be returned.143 * 0 will be returned.
144 */144 */
145 int foregroundProcessGroup() const;145 int foregroundProcessGroup() const;
146 146
147 public slots:147 public slots:
148148
149 /**149 /**
@@ -152,7 +152,7 @@
152 void setUtf8Mode(bool on);152 void setUtf8Mode(bool on);
153153
154 /**154 /**
155 * Suspend or resume processing of data from the standard 155 * Suspend or resume processing of data from the standard
156 * output of the terminal process.156 * output of the terminal process.
157 *157 *
158 * See K3Process::suspend() and K3Process::resume()158 * See K3Process::suspend() and K3Process::resume()
@@ -161,9 +161,9 @@
161 * otherwise processing is resumed.161 * otherwise processing is resumed.
162 */162 */
163 void lockPty(bool lock);163 void lockPty(bool lock);
164 164
165 /** 165 /**
166 * Sends data to the process currently controlling the 166 * Sends data to the process currently controlling the
167 * teletype ( whose id is returned by foregroundProcessGroup() )167 * teletype ( whose id is returned by foregroundProcessGroup() )
168 *168 *
169 * @param buffer Pointer to the data to send.169 * @param buffer Pointer to the data to send.
@@ -181,14 +181,14 @@
181 * @param length Length of @p buffer181 * @param length Length of @p buffer
182 */182 */
183 void receivedData(const char* buffer, int length);183 void receivedData(const char* buffer, int length);
184 184
185 protected:185 protected:
186 void setupChildProcess();186 void setupChildProcess();
187187
188 private slots:188 private slots:
189 // called when data is received from the terminal process 189 // called when data is received from the terminal process
190 void dataReceived(); 190 void dataReceived();
191 191
192 private:192 private:
193 void init();193 void init();
194194
@@ -196,7 +196,7 @@
196 // to the environment for the process196 // to the environment for the process
197 void addEnvironmentVariables(const QStringList& environment);197 void addEnvironmentVariables(const QStringList& environment);
198198
199 int _windowColumns; 199 int _windowColumns;
200 int _windowLines;200 int _windowLines;
201 char _eraseChar;201 char _eraseChar;
202 bool _xonXoff;202 bool _xonXoff;
203203
=== modified file 'src/plugin/konsole/Screen.cpp'
--- src/plugin/konsole/Screen.cpp 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/Screen.cpp 2014-07-30 09:50:10 +0000
@@ -50,10 +50,10 @@
5050
51//Macro to convert x,y position on screen to position within an image.51//Macro to convert x,y position on screen to position within an image.
52//52//
53//Originally the image was stored as one large contiguous block of 53//Originally the image was stored as one large contiguous block of
54//memory, so a position within the image could be represented as an54//memory, so a position within the image could be represented as an
55//offset from the beginning of the block. For efficiency reasons this55//offset from the beginning of the block. For efficiency reasons this
56//is no longer the case. 56//is no longer the case.
57//Many internal parts of this class still use this representation for parameters and so on,57//Many internal parts of this class still use this representation for parameters and so on,
58//notably moveImage() and clearImage().58//notably moveImage() and clearImage().
59//This macro converts from an X,Y position into an image offset.59//This macro converts from an X,Y position into an image offset.
@@ -198,14 +198,14 @@
198 Q_ASSERT( n >= 0 );198 Q_ASSERT( n >= 0 );
199199
200 // always delete at least one char200 // always delete at least one char
201 if (n == 0) 201 if (n == 0)
202 n = 1; 202 n = 1;
203203
204 // if cursor is beyond the end of the line there is nothing to do204 // if cursor is beyond the end of the line there is nothing to do
205 if ( cuX >= screenLines[cuY].count() )205 if ( cuX >= screenLines[cuY].count() )
206 return;206 return;
207207
208 if ( cuX+n > screenLines[cuY].count() ) 208 if ( cuX+n > screenLines[cuY].count() )
209 n = screenLines[cuY].count() - cuX;209 n = screenLines[cuY].count() - cuX;
210210
211 Q_ASSERT( n >= 0 );211 Q_ASSERT( n >= 0 );
@@ -285,7 +285,7 @@
285{285{
286 cuX = qMin(savedState.cursorColumn,columns-1);286 cuX = qMin(savedState.cursorColumn,columns-1);
287 cuY = qMin(savedState.cursorLine,lines-1);287 cuY = qMin(savedState.cursorLine,lines-1);
288 currentRendition = savedState.rendition; 288 currentRendition = savedState.rendition;
289 currentForeground = savedState.foreground;289 currentForeground = savedState.foreground;
290 currentBackground = savedState.background;290 currentBackground = savedState.background;
291 updateEffectiveRendition();291 updateEffectiveRendition();
@@ -318,7 +318,7 @@
318318
319 clearSelection();319 clearSelection();
320320
321 delete[] screenLines; 321 delete[] screenLines;
322 screenLines = newScreenLines;322 screenLines = newScreenLines;
323323
324 lines = new_lines;324 lines = new_lines;
@@ -375,11 +375,11 @@
375 */375 */
376376
377void Screen::reverseRendition(Character& p) const377void Screen::reverseRendition(Character& p) const
378{ 378{
379 CharacterColor f = p.foregroundColor; 379 CharacterColor f = p.foregroundColor;
380 CharacterColor b = p.backgroundColor;380 CharacterColor b = p.backgroundColor;
381381
382 p.foregroundColor = b; 382 p.foregroundColor = b;
383 p.backgroundColor = f; //p->r &= ~RE_TRANSPARENT;383 p.backgroundColor = f; //p->r &= ~RE_TRANSPARENT;
384}384}
385385
@@ -405,14 +405,14 @@
405{405{
406 Q_ASSERT( startLine >= 0 && count > 0 && startLine + count <= history->getLines() );406 Q_ASSERT( startLine >= 0 && count > 0 && startLine + count <= history->getLines() );
407407
408 for (int line = startLine; line < startLine + count; line++) 408 for (int line = startLine; line < startLine + count; line++)
409 {409 {
410 const int length = qMin(columns,history->getLineLen(line));410 const int length = qMin(columns,history->getLineLen(line));
411 const int destLineOffset = (line-startLine)*columns;411 const int destLineOffset = (line-startLine)*columns;
412412
413 history->getCells(line,0,length,dest + destLineOffset);413 history->getCells(line,0,length,dest + destLineOffset);
414414
415 for (int column = length; column < columns; column++) 415 for (int column = length; column < columns; column++)
416 dest[destLineOffset+column] = defaultChar;416 dest[destLineOffset+column] = defaultChar;
417417
418 // invert selected text418 // invert selected text
@@ -420,9 +420,9 @@
420 {420 {
421 for (int column = 0; column < columns; column++)421 for (int column = 0; column < columns; column++)
422 {422 {
423 if (isSelected(column,line)) 423 if (isSelected(column,line))
424 {424 {
425 reverseRendition(dest[destLineOffset + column]); 425 reverseRendition(dest[destLineOffset + column]);
426 }426 }
427 }427 }
428 }428 }
@@ -439,15 +439,15 @@
439 int destLineStartIndex = (line-startLine)*columns;439 int destLineStartIndex = (line-startLine)*columns;
440440
441 for (int column = 0; column < columns; column++)441 for (int column = 0; column < columns; column++)
442 { 442 {
443 int srcIndex = srcLineStartIndex + column; 443 int srcIndex = srcLineStartIndex + column;
444 int destIndex = destLineStartIndex + column;444 int destIndex = destLineStartIndex + column;
445445
446 dest[destIndex] = screenLines[srcIndex/columns].value(srcIndex%columns,defaultChar);446 dest[destIndex] = screenLines[srcIndex/columns].value(srcIndex%columns,defaultChar);
447447
448 // invert selected text448 // invert selected text
449 if (selBegin != -1 && isSelected(column,line + history->getLines()))449 if (selBegin != -1 && isSelected(column,line + history->getLines()))
450 reverseRendition(dest[destIndex]); 450 reverseRendition(dest[destIndex]);
451 }451 }
452452
453 }453 }
@@ -460,7 +460,7 @@
460460
461 const int mergedLines = endLine - startLine + 1;461 const int mergedLines = endLine - startLine + 1;
462462
463 Q_ASSERT( size >= mergedLines * columns ); 463 Q_ASSERT( size >= mergedLines * columns );
464 Q_UNUSED( size );464 Q_UNUSED( size );
465465
466 const int linesInHistoryBuffer = qBound(0,history->getLines()-startLine,mergedLines);466 const int linesInHistoryBuffer = qBound(0,history->getLines()-startLine,mergedLines);
@@ -468,7 +468,7 @@
468468
469 // copy lines from history buffer469 // copy lines from history buffer
470 if (linesInHistoryBuffer > 0)470 if (linesInHistoryBuffer > 0)
471 copyFromHistory(dest,startLine,linesInHistoryBuffer); 471 copyFromHistory(dest,startLine,linesInHistoryBuffer);
472472
473 // copy lines from screen buffer473 // copy lines from screen buffer
474 if (linesInScreenBuffer > 0)474 if (linesInScreenBuffer > 0)
@@ -491,7 +491,7 @@
491491
492QVector<LineProperty> Screen::getLineProperties( int startLine , int endLine ) const492QVector<LineProperty> Screen::getLineProperties( int startLine , int endLine ) const
493{493{
494 Q_ASSERT( startLine >= 0 ); 494 Q_ASSERT( startLine >= 0 );
495 Q_ASSERT( endLine >= startLine && endLine < history->getLines() + lines );495 Q_ASSERT( endLine >= startLine && endLine < history->getLines() + lines );
496496
497 const int mergedLines = endLine-startLine+1;497 const int mergedLines = endLine-startLine+1;
@@ -502,7 +502,7 @@
502 int index = 0;502 int index = 0;
503503
504 // copy properties for lines in history504 // copy properties for lines in history
505 for (int line = startLine; line < startLine + linesInHistory; line++) 505 for (int line = startLine; line < startLine + linesInHistory; line++)
506 {506 {
507 //TODO Support for line properties other than wrapped lines507 //TODO Support for line properties other than wrapped lines
508 if (history->isWrappedLine(line))508 if (history->isWrappedLine(line))
@@ -556,7 +556,7 @@
556 if (screenLines[cuY].size() < cuX+1)556 if (screenLines[cuY].size() < cuX+1)
557 screenLines[cuY].resize(cuX+1);557 screenLines[cuY].resize(cuX+1);
558558
559 if (BS_CLEARS) 559 if (BS_CLEARS)
560 screenLines[cuY][cuX].character = ' ';560 screenLines[cuY][cuX].character = ' ';
561}561}
562562
@@ -566,8 +566,8 @@
566 if (n == 0) n = 1;566 if (n == 0) n = 1;
567 while((n > 0) && (cuX < columns-1))567 while((n > 0) && (cuX < columns-1))
568 {568 {
569 cursorRight(1); 569 cursorRight(1);
570 while((cuX < columns-1) && !tabStops[cuX]) 570 while((cuX < columns-1) && !tabStops[cuX])
571 cursorRight(1);571 cursorRight(1);
572 n--;572 n--;
573 }573 }
@@ -602,20 +602,20 @@
602 // Arrg! The 1st tabstop has to be one longer than the other.602 // Arrg! The 1st tabstop has to be one longer than the other.
603 // i.e. the kids start counting from 0 instead of 1.603 // i.e. the kids start counting from 0 instead of 1.
604 // Other programs might behave correctly. Be aware.604 // Other programs might behave correctly. Be aware.
605 for (int i = 0; i < columns; i++) 605 for (int i = 0; i < columns; i++)
606 tabStops[i] = (i%8 == 0 && i != 0);606 tabStops[i] = (i%8 == 0 && i != 0);
607}607}
608608
609void Screen::newLine()609void Screen::newLine()
610{610{
611 if (getMode(MODE_NewLine)) 611 if (getMode(MODE_NewLine))
612 toStartOfLine();612 toStartOfLine();
613 index();613 index();
614}614}
615615
616void Screen::checkSelection(int from, int to)616void Screen::checkSelection(int from, int to)
617{617{
618 if (selBegin == -1) 618 if (selBegin == -1)
619 return;619 return;
620 int scr_TL = loc(0, history->getLines());620 int scr_TL = loc(0, history->getLines());
621 //Clear entire selection if it overlaps region [from, to]621 //Clear entire selection if it overlaps region [from, to]
@@ -749,11 +749,11 @@
749 _scrolledLines += n;749 _scrolledLines += n;
750750
751 //FIXME: make sure `topMargin', `bottomMargin', `from', `n' is in bounds.751 //FIXME: make sure `topMargin', `bottomMargin', `from', `n' is in bounds.
752 if (n <= 0) 752 if (n <= 0)
753 return;753 return;
754 if (from > _bottomMargin) 754 if (from > _bottomMargin)
755 return;755 return;
756 if (from + n > _bottomMargin) 756 if (from + n > _bottomMargin)
757 n = _bottomMargin - from;757 n = _bottomMargin - from;
758 moveImage(loc(0,from+n),loc(0,from),loc(columns-1,_bottomMargin-n));758 moveImage(loc(0,from+n),loc(0,from),loc(columns-1,_bottomMargin-n));
759 clearImage(loc(0,from),loc(columns-1,from+n-1),' ');759 clearImage(loc(0,from),loc(columns-1,from+n-1),' ');
@@ -800,7 +800,7 @@
800}800}
801801
802void Screen::clearImage(int loca, int loce, char c)802void Screen::clearImage(int loca, int loce, char c)
803{ 803{
804 int scr_TL=loc(0,history->getLines());804 int scr_TL=loc(0,history->getLines());
805 //FIXME: check positions805 //FIXME: check positions
806806
@@ -851,8 +851,8 @@
851 int lines=(sourceEnd-sourceBegin)/columns;851 int lines=(sourceEnd-sourceBegin)/columns;
852852
853 //move screen image and line properties:853 //move screen image and line properties:
854 //the source and destination areas of the image may overlap, 854 //the source and destination areas of the image may overlap,
855 //so it matters that we do the copy in the right order - 855 //so it matters that we do the copy in the right order -
856 //forwards if dest < sourceBegin or backwards otherwise.856 //forwards if dest < sourceBegin or backwards otherwise.
857 //(search the web for 'memmove implementation' for details)857 //(search the web for 'memmove implementation' for details)
858 if (dest < sourceBegin)858 if (dest < sourceBegin)
@@ -987,9 +987,9 @@
987{987{
988 currentForeground = CharacterColor(space, color);988 currentForeground = CharacterColor(space, color);
989989
990 if ( currentForeground.isValid() ) 990 if ( currentForeground.isValid() )
991 updateEffectiveRendition();991 updateEffectiveRendition();
992 else 992 else
993 setForeColor(COLOR_SPACE_DEFAULT,DEFAULT_FORE_COLOR);993 setForeColor(COLOR_SPACE_DEFAULT,DEFAULT_FORE_COLOR);
994}994}
995995
@@ -997,13 +997,13 @@
997{997{
998 currentBackground = CharacterColor(space, color);998 currentBackground = CharacterColor(space, color);
999999
1000 if ( currentBackground.isValid() ) 1000 if ( currentBackground.isValid() )
1001 updateEffectiveRendition();1001 updateEffectiveRendition();
1002 else1002 else
1003 setBackColor(COLOR_SPACE_DEFAULT,DEFAULT_BACK_COLOR);1003 setBackColor(COLOR_SPACE_DEFAULT,DEFAULT_BACK_COLOR);
1004}1004}
10051005
1006void Screen::clearSelection() 1006void Screen::clearSelection()
1007{1007{
1008 selBottomRight = -1;1008 selBottomRight = -1;
1009 selTopLeft = -1;1009 selTopLeft = -1;
@@ -1015,7 +1015,7 @@
1015 if ( selTopLeft != -1 )1015 if ( selTopLeft != -1 )
1016 {1016 {
1017 column = selTopLeft % columns;1017 column = selTopLeft % columns;
1018 line = selTopLeft / columns; 1018 line = selTopLeft / columns;
1019 }1019 }
1020 else1020 else
1021 {1021 {
@@ -1034,11 +1034,11 @@
1034 {1034 {
1035 column = cuX + getHistLines();1035 column = cuX + getHistLines();
1036 line = cuY + getHistLines();1036 line = cuY + getHistLines();
1037 } 1037 }
1038}1038}
1039void Screen::setSelectionStart(const int x, const int y, const bool mode)1039void Screen::setSelectionStart(const int x, const int y, const bool mode)
1040{1040{
1041 selBegin = loc(x,y); 1041 selBegin = loc(x,y);
1042 /* FIXME, HACK to correct for x too far to the right... */1042 /* FIXME, HACK to correct for x too far to the right... */
1043 if (x == columns) selBegin--;1043 if (x == columns) selBegin--;
10441044
@@ -1049,10 +1049,10 @@
10491049
1050void Screen::setSelectionEnd( const int x, const int y)1050void Screen::setSelectionEnd( const int x, const int y)
1051{1051{
1052 if (selBegin == -1) 1052 if (selBegin == -1)
1053 return;1053 return;
10541054
1055 int endPos = loc(x,y); 1055 int endPos = loc(x,y);
10561056
1057 if (endPos < selBegin)1057 if (endPos < selBegin)
1058 {1058 {
@@ -1062,7 +1062,7 @@
1062 else1062 else
1063 {1063 {
1064 /* FIXME, HACK to correct for x too far to the right... */1064 /* FIXME, HACK to correct for x too far to the right... */
1065 if (x == columns) 1065 if (x == columns)
1066 endPos--;1066 endPos--;
10671067
1068 selTopLeft = selBegin;1068 selTopLeft = selBegin;
@@ -1113,7 +1113,7 @@
1113 return selTopLeft >= 0 && selBottomRight >= 0;1113 return selTopLeft >= 0 && selBottomRight >= 0;
1114}1114}
11151115
1116void Screen::writeSelectionToStream(TerminalCharacterDecoder* decoder , 1116void Screen::writeSelectionToStream(TerminalCharacterDecoder* decoder ,
1117 bool preserveLineBreaks) const1117 bool preserveLineBreaks) const
1118{1118{
1119 if (!isSelectionValid())1119 if (!isSelectionValid())
@@ -1121,11 +1121,11 @@
1121 writeToStream(decoder,selTopLeft,selBottomRight,preserveLineBreaks);1121 writeToStream(decoder,selTopLeft,selBottomRight,preserveLineBreaks);
1122}1122}
11231123
1124void Screen::writeToStream(TerminalCharacterDecoder* decoder, 1124void Screen::writeToStream(TerminalCharacterDecoder* decoder,
1125 int startIndex, int endIndex,1125 int startIndex, int endIndex,
1126 bool preserveLineBreaks) const1126 bool preserveLineBreaks) const
1127{1127{
1128 int top = startIndex / columns; 1128 int top = startIndex / columns;
1129 int left = startIndex % columns;1129 int left = startIndex % columns;
11301130
1131 int bottom = endIndex / columns;1131 int bottom = endIndex / columns;
@@ -1145,7 +1145,7 @@
1145 int copied = copyLineToStream( y,1145 int copied = copyLineToStream( y,
1146 start,1146 start,
1147 count,1147 count,
1148 decoder, 1148 decoder,
1149 appendNewLine,1149 appendNewLine,
1150 preserveLineBreaks );1150 preserveLineBreaks );
11511151
@@ -1153,25 +1153,25 @@
1153 // append a new line character.1153 // append a new line character.
1154 //1154 //
1155 // this makes it possible to 'select' a trailing new line character after1155 // this makes it possible to 'select' a trailing new line character after
1156 // the text on a line. 1156 // the text on a line.
1157 if ( y == bottom && 1157 if ( y == bottom &&
1158 copied < count )1158 copied < count )
1159 {1159 {
1160 Character newLineChar('\n');1160 Character newLineChar('\n');
1161 decoder->decodeLine(&newLineChar,1,0);1161 decoder->decodeLine(&newLineChar,1,0);
1162 }1162 }
1163 } 1163 }
1164}1164}
11651165
1166int Screen::copyLineToStream(int line , 1166int Screen::copyLineToStream(int line ,
1167 int start, 1167 int start,
1168 int count,1168 int count,
1169 TerminalCharacterDecoder* decoder,1169 TerminalCharacterDecoder* decoder,
1170 bool appendNewLine,1170 bool appendNewLine,
1171 bool preserveLineBreaks) const1171 bool preserveLineBreaks) const
1172{1172{
1173 //buffer to hold characters for decoding1173 //buffer to hold characters for decoding
1174 //the buffer is static to avoid initialising every 1174 //the buffer is static to avoid initialising every
1175 //element on each call to copyLineToStream1175 //element on each call to copyLineToStream
1176 //(which is unnecessary since all elements will be overwritten anyway)1176 //(which is unnecessary since all elements will be overwritten anyway)
1177 static const int MAX_CHARS = 1024;1177 static const int MAX_CHARS = 1024;
@@ -1191,7 +1191,7 @@
11911191
1192 // retrieve line from history buffer. It is assumed1192 // retrieve line from history buffer. It is assumed
1193 // that the history buffer does not store trailing white space1193 // that the history buffer does not store trailing white space
1194 // at the end of the line, so it does not need to be trimmed here 1194 // at the end of the line, so it does not need to be trimmed here
1195 if (count == -1)1195 if (count == -1)
1196 {1196 {
1197 count = lineLength-start;1197 count = lineLength-start;
@@ -1203,7 +1203,7 @@
12031203
1204 // safety checks1204 // safety checks
1205 assert( start >= 0 );1205 assert( start >= 0 );
1206 assert( count >= 0 ); 1206 assert( count >= 0 );
1207 assert( (start+count) <= history->getLineLen(line) );1207 assert( (start+count) <= history->getLineLen(line) );
12081208
1209 history->getCells(line,start,count,characterBuffer);1209 history->getCells(line,start,count,characterBuffer);
@@ -1233,7 +1233,7 @@
1233 count = qBound(0,count,length-start);1233 count = qBound(0,count,length-start);
12341234
1235 Q_ASSERT( screenLine < lineProperties.count() );1235 Q_ASSERT( screenLine < lineProperties.count() );
1236 currentLineProperties |= lineProperties[screenLine]; 1236 currentLineProperties |= lineProperties[screenLine];
1237 }1237 }
12381238
1239 // add new line character at end1239 // add new line character at end
@@ -1246,8 +1246,8 @@
1246 count++;1246 count++;
1247 }1247 }
12481248
1249 //decode line and write to text stream 1249 //decode line and write to text stream
1250 decoder->decodeLine( (Character*) characterBuffer , 1250 decoder->decodeLine( (Character*) characterBuffer ,
1251 count, currentLineProperties );1251 count, currentLineProperties );
12521252
1253 return count;1253 return count;
12541254
=== modified file 'src/plugin/konsole/Screen.h'
--- src/plugin/konsole/Screen.h 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/Screen.h 2014-07-30 09:50:10 +0000
@@ -50,21 +50,21 @@
50 characters from the program currently running in the terminal.50 characters from the program currently running in the terminal.
51 From this stream it creates an image of characters which is ultimately51 From this stream it creates an image of characters which is ultimately
52 rendered by the display widget ( TerminalDisplay ). Some types of emulation52 rendered by the display widget ( TerminalDisplay ). Some types of emulation
53 may have more than one screen image. 53 may have more than one screen image.
5454
55 getImage() is used to retrieve the currently visible image55 getImage() is used to retrieve the currently visible image
56 which is then used by the display widget to draw the output from the56 which is then used by the display widget to draw the output from the
57 terminal. 57 terminal.
5858
59 The number of lines of output history which are kept in addition to the current59 The number of lines of output history which are kept in addition to the current
60 screen image depends on the history scroll being used to store the output. 60 screen image depends on the history scroll being used to store the output.
61 The scroll is specified using setScroll()61 The scroll is specified using setScroll()
62 The output history can be retrieved using writeToStream()62 The output history can be retrieved using writeToStream()
6363
64 The screen image has a selection associated with it, specified using 64 The screen image has a selection associated with it, specified using
65 setSelectionStart() and setSelectionEnd(). The selected text can be retrieved65 setSelectionStart() and setSelectionEnd(). The selected text can be retrieved
66 using selectedText(). When getImage() is used to retrieve the visible image,66 using selectedText(). When getImage() is used to retrieve the visible image,
67 characters which are part of the selection have their colours inverted. 67 characters which are part of the selection have their colours inverted.
68*/68*/
69class Screen69class Screen
70{70{
@@ -73,25 +73,25 @@
73 Screen(int lines, int columns);73 Screen(int lines, int columns);
74 ~Screen();74 ~Screen();
7575
76 // VT100/2 Operations 76 // VT100/2 Operations
77 // Cursor Movement77 // Cursor Movement
78 78
79 /** 79 /**
80 * Move the cursor up by @p n lines. The cursor will stop at the 80 * Move the cursor up by @p n lines. The cursor will stop at the
81 * top margin.81 * top margin.
82 */82 */
83 void cursorUp(int n);83 void cursorUp(int n);
84 /** 84 /**
85 * Move the cursor down by @p n lines. The cursor will stop at the85 * Move the cursor down by @p n lines. The cursor will stop at the
86 * bottom margin.86 * bottom margin.
87 */87 */
88 void cursorDown(int n);88 void cursorDown(int n);
89 /** 89 /**
90 * Move the cursor to the left by @p n columns.90 * Move the cursor to the left by @p n columns.
91 * The cursor will stop at the first column.91 * The cursor will stop at the first column.
92 */92 */
93 void cursorLeft(int n);93 void cursorLeft(int n);
94 /** 94 /**
95 * Move the cursor to the right by @p n columns.95 * Move the cursor to the right by @p n columns.
96 * The cursor will stop at the right-most column.96 * The cursor will stop at the right-most column.
97 */97 */
@@ -105,28 +105,28 @@
105 /**105 /**
106 * Sets the margins for scrolling the screen.106 * Sets the margins for scrolling the screen.
107 *107 *
108 * @param topLine The top line of the new scrolling margin. 108 * @param topLine The top line of the new scrolling margin.
109 * @param bottomLine The bottom line of the new scrolling margin. 109 * @param bottomLine The bottom line of the new scrolling margin.
110 */110 */
111 void setMargins(int topLine , int bottomLine);111 void setMargins(int topLine , int bottomLine);
112 /** Returns the top line of the scrolling region. */ 112 /** Returns the top line of the scrolling region. */
113 int topMargin() const;113 int topMargin() const;
114 /** Returns the bottom line of the scrolling region. */114 /** Returns the bottom line of the scrolling region. */
115 int bottomMargin() const;115 int bottomMargin() const;
116116
117 /** 117 /**
118 * Resets the scrolling margins back to the top and bottom lines118 * Resets the scrolling margins back to the top and bottom lines
119 * of the screen.119 * of the screen.
120 */120 */
121 void setDefaultMargins();121 void setDefaultMargins();
122 122
123 /** 123 /**
124 * Moves the cursor down one line, if the MODE_NewLine mode 124 * Moves the cursor down one line, if the MODE_NewLine mode
125 * flag is enabled then the cursor is returned to the leftmost125 * flag is enabled then the cursor is returned to the leftmost
126 * column first.126 * column first.
127 *127 *
128 * Equivalent to NextLine() if the MODE_NewLine flag is set128 * Equivalent to NextLine() if the MODE_NewLine flag is set
129 * or index() otherwise. 129 * or index() otherwise.
130 */130 */
131 void newLine();131 void newLine();
132 /**132 /**
@@ -135,7 +135,7 @@
135 */135 */
136 void nextLine();136 void nextLine();
137137
138 /** 138 /**
139 * Move the cursor down one line. If the cursor is on the bottom139 * Move the cursor down one line. If the cursor is on the bottom
140 * line of the scrolling region (as returned by bottomMargin()) the140 * line of the scrolling region (as returned by bottomMargin()) the
141 * scrolling region is scrolled up by one line instead.141 * scrolling region is scrolled up by one line instead.
@@ -147,12 +147,12 @@
147 * region is scrolled down by one line instead.147 * region is scrolled down by one line instead.
148 */148 */
149 void reverseIndex();149 void reverseIndex();
150 150
151 /** 151 /**
152 * Scroll the scrolling region of the screen up by @p n lines. 152 * Scroll the scrolling region of the screen up by @p n lines.
153 * The scrolling region is initially the whole screen, but can be changed 153 * The scrolling region is initially the whole screen, but can be changed
154 * using setMargins()154 * using setMargins()
155 */ 155 */
156 void scrollUp(int n);156 void scrollUp(int n);
157 /**157 /**
158 * Scroll the scrolling region of the screen down by @p n lines.158 * Scroll the scrolling region of the screen down by @p n lines.
@@ -160,12 +160,12 @@
160 * using setMargins()160 * using setMargins()
161 */161 */
162 void scrollDown(int n);162 void scrollDown(int n);
163 /** 163 /**
164 * Moves the cursor to the beginning of the current line. 164 * Moves the cursor to the beginning of the current line.
165 * Equivalent to setCursorX(0)165 * Equivalent to setCursorX(0)
166 */166 */
167 void toStartOfLine();167 void toStartOfLine();
168 /** 168 /**
169 * Moves the cursor one column to the left and erases the character169 * Moves the cursor one column to the left and erases the character
170 * at the new cursor position.170 * at the new cursor position.
171 */171 */
@@ -174,28 +174,28 @@
174 void tab(int n = 1);174 void tab(int n = 1);
175 /** Moves the cursor @p n tab-stops to the left. */175 /** Moves the cursor @p n tab-stops to the left. */
176 void backtab(int n);176 void backtab(int n);
177 177
178 // Editing178 // Editing
179 179
180 /** 180 /**
181 * Erase @p n characters beginning from the current cursor position. 181 * Erase @p n characters beginning from the current cursor position.
182 * This is equivalent to over-writing @p n characters starting with the current182 * This is equivalent to over-writing @p n characters starting with the current
183 * cursor position with spaces.183 * cursor position with spaces.
184 * If @p n is 0 then one character is erased. 184 * If @p n is 0 then one character is erased.
185 */185 */
186 void eraseChars(int n);186 void eraseChars(int n);
187 /** 187 /**
188 * Delete @p n characters beginning from the current cursor position. 188 * Delete @p n characters beginning from the current cursor position.
189 * If @p n is 0 then one character is deleted. 189 * If @p n is 0 then one character is deleted.
190 */190 */
191 void deleteChars(int n);191 void deleteChars(int n);
192 /**192 /**
193 * Insert @p n blank characters beginning from the current cursor position.193 * Insert @p n blank characters beginning from the current cursor position.
194 * The position of the cursor is not altered. 194 * The position of the cursor is not altered.
195 * If @p n is 0 then one character is inserted.195 * If @p n is 0 then one character is inserted.
196 */196 */
197 void insertChars(int n);197 void insertChars(int n);
198 /** 198 /**
199 * Removes @p n lines beginning from the current cursor position.199 * Removes @p n lines beginning from the current cursor position.
200 * The position of the cursor is not altered.200 * The position of the cursor is not altered.
201 * If @p n is 0 then one line is removed.201 * If @p n is 0 then one line is removed.
@@ -209,14 +209,14 @@
209 void insertLines(int n);209 void insertLines(int n);
210 /** Clears all the tab stops. */210 /** Clears all the tab stops. */
211 void clearTabStops();211 void clearTabStops();
212 /** Sets or removes a tab stop at the cursor's current column. */ 212 /** Sets or removes a tab stop at the cursor's current column. */
213 void changeTabStop(bool set);213 void changeTabStop(bool set);
214 214
215 /** Resets (clears) the specified screen @p mode. */215 /** Resets (clears) the specified screen @p mode. */
216 void resetMode(int mode);216 void resetMode(int mode);
217 /** Sets (enables) the specified screen @p mode. */217 /** Sets (enables) the specified screen @p mode. */
218 void setMode(int mode);218 void setMode(int mode);
219 /** 219 /**
220 * Saves the state of the specified screen @p mode. It can be restored220 * Saves the state of the specified screen @p mode. It can be restored
221 * using restoreMode()221 * using restoreMode()
222 */222 */
@@ -225,19 +225,19 @@
225 void restoreMode(int mode);225 void restoreMode(int mode);
226 /** Returns whether the specified screen @p mode is enabled or not .*/226 /** Returns whether the specified screen @p mode is enabled or not .*/
227 bool getMode(int mode) const;227 bool getMode(int mode) const;
228 228
229 /** 229 /**
230 * Saves the current position and appearance (text color and style) of the cursor. 230 * Saves the current position and appearance (text color and style) of the cursor.
231 * It can be restored by calling restoreCursor() 231 * It can be restored by calling restoreCursor()
232 */ 232 */
233 void saveCursor();233 void saveCursor();
234 /** Restores the position and appearance of the cursor. See saveCursor() */234 /** Restores the position and appearance of the cursor. See saveCursor() */
235 void restoreCursor();235 void restoreCursor();
236 236
237 /** Clear the whole screen, moving the current screen contents into the history first. */ 237 /** Clear the whole screen, moving the current screen contents into the history first. */
238 void clearEntireScreen();238 void clearEntireScreen();
239 /** 239 /**
240 * Clear the area of the screen from the current cursor position to the end of 240 * Clear the area of the screen from the current cursor position to the end of
241 * the screen.241 * the screen.
242 */242 */
243 void clearToEndOfScreen();243 void clearToEndOfScreen();
@@ -252,16 +252,16 @@
252 void clearToEndOfLine();252 void clearToEndOfLine();
253 /** Clears from the current cursor position to the beginning of the line. */253 /** Clears from the current cursor position to the beginning of the line. */
254 void clearToBeginOfLine();254 void clearToBeginOfLine();
255 255
256 /** Fills the entire screen with the letter 'E' */256 /** Fills the entire screen with the letter 'E' */
257 void helpAlign();257 void helpAlign();
258 258
259 /** 259 /**
260 * Enables the given @p rendition flag. Rendition flags control the appearance 260 * Enables the given @p rendition flag. Rendition flags control the appearance
261 * of characters on the screen.261 * of characters on the screen.
262 *262 *
263 * @see Character::rendition263 * @see Character::rendition
264 */ 264 */
265 void setRendition(int rendition);265 void setRendition(int rendition);
266 /**266 /**
267 * Disables the given @p rendition flag. Rendition flags control the appearance267 * Disables the given @p rendition flag. Rendition flags control the appearance
@@ -270,8 +270,8 @@
270 * @see Character::rendition270 * @see Character::rendition
271 */271 */
272 void resetRendition(int rendition);272 void resetRendition(int rendition);
273 273
274 /** 274 /**
275 * Sets the cursor's foreground color.275 * Sets the cursor's foreground color.
276 * @param space The color space used by the @p color argument276 * @param space The color space used by the @p color argument
277 * @param color The new foreground color. The meaning of this depends on277 * @param color The new foreground color. The meaning of this depends on
@@ -289,24 +289,24 @@
289 * @see CharacterColor289 * @see CharacterColor
290 */290 */
291 void setBackColor(int space, int color);291 void setBackColor(int space, int color);
292 /** 292 /**
293 * Resets the cursor's color back to the default and sets the 293 * Resets the cursor's color back to the default and sets the
294 * character's rendition flags back to the default settings.294 * character's rendition flags back to the default settings.
295 */295 */
296 void setDefaultRendition();296 void setDefaultRendition();
297 297
298 /** Returns the column which the cursor is positioned at. */298 /** Returns the column which the cursor is positioned at. */
299 int getCursorX() const;299 int getCursorX() const;
300 /** Returns the line which the cursor is positioned on. */300 /** Returns the line which the cursor is positioned on. */
301 int getCursorY() const;301 int getCursorY() const;
302 302
303 /** Clear the entire screen and move the cursor to the home position.303 /** Clear the entire screen and move the cursor to the home position.
304 * Equivalent to calling clearEntireScreen() followed by home().304 * Equivalent to calling clearEntireScreen() followed by home().
305 */305 */
306 void clear();306 void clear();
307 /** 307 /**
308 * Sets the position of the cursor to the 'home' position at the top-left308 * Sets the position of the cursor to the 'home' position at the top-left
309 * corner of the screen (0,0) 309 * corner of the screen (0,0)
310 */310 */
311 void home();311 void home();
312 /**312 /**
@@ -323,41 +323,41 @@
323 * <li>New line mode is disabled. TODO Document me</li>323 * <li>New line mode is disabled. TODO Document me</li>
324 * </ul>324 * </ul>
325 *325 *
326 * If @p clearScreen is true then the screen contents are erased entirely, 326 * If @p clearScreen is true then the screen contents are erased entirely,
327 * otherwise they are unaltered.327 * otherwise they are unaltered.
328 */328 */
329 void reset(bool clearScreen = true);329 void reset(bool clearScreen = true);
330 330
331 /** 331 /**
332 * Displays a new character at the current cursor position. 332 * Displays a new character at the current cursor position.
333 * 333 *
334 * If the cursor is currently positioned at the right-edge of the screen and334 * If the cursor is currently positioned at the right-edge of the screen and
335 * line wrapping is enabled then the character is added at the start of a new 335 * line wrapping is enabled then the character is added at the start of a new
336 * line below the current one.336 * line below the current one.
337 *337 *
338 * If the MODE_Insert screen mode is currently enabled then the character 338 * If the MODE_Insert screen mode is currently enabled then the character
339 * is inserted at the current cursor position, otherwise it will replace the 339 * is inserted at the current cursor position, otherwise it will replace the
340 * character already at the current cursor position. 340 * character already at the current cursor position.
341 */ 341 */
342 void displayCharacter(unsigned short c);342 void displayCharacter(unsigned short c);
343 343
344 // Do composition with last shown character FIXME: Not implemented yet for KDE 4344 // Do composition with last shown character FIXME: Not implemented yet for KDE 4
345 void compose(const QString& compose);345 void compose(const QString& compose);
346 346
347 /** 347 /**
348 * Resizes the image to a new fixed size of @p new_lines by @p new_columns. 348 * Resizes the image to a new fixed size of @p new_lines by @p new_columns.
349 * In the case that @p new_columns is smaller than the current number of columns,349 * In the case that @p new_columns is smaller than the current number of columns,
350 * existing lines are not truncated. This prevents characters from being lost350 * existing lines are not truncated. This prevents characters from being lost
351 * if the terminal display is resized smaller and then larger again.351 * if the terminal display is resized smaller and then larger again.
352 *352 *
353 * The top and bottom margins are reset to the top and bottom of the new 353 * The top and bottom margins are reset to the top and bottom of the new
354 * screen size. Tab stops are also reset and the current selection is354 * screen size. Tab stops are also reset and the current selection is
355 * cleared.355 * cleared.
356 */356 */
357 void resizeImage(int new_lines, int new_columns);357 void resizeImage(int new_lines, int new_columns);
358 358
359 /**359 /**
360 * Returns the current screen image. 360 * Returns the current screen image.
361 * The result is an array of Characters of size [getLines()][getColumns()] which361 * The result is an array of Characters of size [getLines()][getColumns()] which
362 * must be freed by the caller after use.362 * must be freed by the caller after use.
363 *363 *
@@ -368,38 +368,38 @@
368 */368 */
369 void getImage( Character* dest , int size , int startLine , int endLine ) const;369 void getImage( Character* dest , int size , int startLine , int endLine ) const;
370370
371 /** 371 /**
372 * Returns the additional attributes associated with lines in the image.372 * Returns the additional attributes associated with lines in the image.
373 * The most important attribute is LINE_WRAPPED which specifies that the 373 * The most important attribute is LINE_WRAPPED which specifies that the
374 * line is wrapped,374 * line is wrapped,
375 * other attributes control the size of characters in the line.375 * other attributes control the size of characters in the line.
376 */376 */
377 QVector<LineProperty> getLineProperties( int startLine , int endLine ) const;377 QVector<LineProperty> getLineProperties( int startLine , int endLine ) const;
378 378
379379
380 /** Return the number of lines. */380 /** Return the number of lines. */
381 int getLines() const 381 int getLines() const
382 { return lines; }382 { return lines; }
383 /** Return the number of columns. */383 /** Return the number of columns. */
384 int getColumns() const 384 int getColumns() const
385 { return columns; }385 { return columns; }
386 /** Return the number of lines in the history buffer. */386 /** Return the number of lines in the history buffer. */
387 int getHistLines() const;387 int getHistLines() const;
388 /** 388 /**
389 * Sets the type of storage used to keep lines in the history. 389 * Sets the type of storage used to keep lines in the history.
390 * If @p copyPreviousScroll is true then the contents of the previous 390 * If @p copyPreviousScroll is true then the contents of the previous
391 * history buffer are copied into the new scroll.391 * history buffer are copied into the new scroll.
392 */392 */
393 void setScroll(const HistoryType& , bool copyPreviousScroll = true);393 void setScroll(const HistoryType& , bool copyPreviousScroll = true);
394 /** Returns the type of storage used to keep lines in the history. */394 /** Returns the type of storage used to keep lines in the history. */
395 const HistoryType& getScroll() const;395 const HistoryType& getScroll() const;
396 /** 396 /**
397 * Returns true if this screen keeps lines that are scrolled off the screen397 * Returns true if this screen keeps lines that are scrolled off the screen
398 * in a history buffer.398 * in a history buffer.
399 */399 */
400 bool hasScroll() const;400 bool hasScroll() const;
401401
402 /** 402 /**
403 * Sets the start of the selection.403 * Sets the start of the selection.
404 *404 *
405 * @param column The column index of the first character in the selection.405 * @param column The column index of the first character in the selection.
@@ -407,21 +407,21 @@
407 * @param blockSelectionMode True if the selection is in column mode.407 * @param blockSelectionMode True if the selection is in column mode.
408 */408 */
409 void setSelectionStart(const int column, const int line, const bool blockSelectionMode);409 void setSelectionStart(const int column, const int line, const bool blockSelectionMode);
410 410
411 /**411 /**
412 * Sets the end of the current selection.412 * Sets the end of the current selection.
413 *413 *
414 * @param column The column index of the last character in the selection.414 * @param column The column index of the last character in the selection.
415 * @param line The line index of the last character in the selection. 415 * @param line The line index of the last character in the selection.
416 */ 416 */
417 void setSelectionEnd(const int column, const int line);417 void setSelectionEnd(const int column, const int line);
418 418
419 /**419 /**
420 * Retrieves the start of the selection or the cursor position if there420 * Retrieves the start of the selection or the cursor position if there
421 * is no selection.421 * is no selection.
422 */422 */
423 void getSelectionStart(int& column , int& line) const;423 void getSelectionStart(int& column , int& line) const;
424 424
425 /**425 /**
426 * Retrieves the end of the selection or the cursor position if there426 * Retrieves the end of the selection or the cursor position if there
427 * is no selection.427 * is no selection.
@@ -431,19 +431,19 @@
431 /** Clears the current selection */431 /** Clears the current selection */
432 void clearSelection();432 void clearSelection();
433433
434 /** 434 /**
435 * Returns true if the character at (@p column, @p line) is part of the435 * Returns true if the character at (@p column, @p line) is part of the
436 * current selection. 436 * current selection.
437 */ 437 */
438 bool isSelected(const int column,const int line) const;438 bool isSelected(const int column,const int line) const;
439439
440 /** 440 /**
441 * Convenience method. Returns the currently selected text. 441 * Convenience method. Returns the currently selected text.
442 * @param preserveLineBreaks Specifies whether new line characters should 442 * @param preserveLineBreaks Specifies whether new line characters should
443 * be inserted into the returned text at the end of each terminal line.443 * be inserted into the returned text at the end of each terminal line.
444 */444 */
445 QString selectedText(bool preserveLineBreaks) const;445 QString selectedText(bool preserveLineBreaks) const;
446 446
447 /**447 /**
448 * Copies part of the output to a stream.448 * Copies part of the output to a stream.
449 *449 *
@@ -457,11 +457,11 @@
457 * Copies the selected characters, set using @see setSelBeginXY and @see setSelExtentXY457 * Copies the selected characters, set using @see setSelBeginXY and @see setSelExtentXY
458 * into a stream.458 * into a stream.
459 *459 *
460 * @param decoder A decoder which converts terminal characters into text. 460 * @param decoder A decoder which converts terminal characters into text.
461 * PlainTextDecoder is the most commonly used decoder which converts characters 461 * PlainTextDecoder is the most commonly used decoder which converts characters
462 * into plain text with no formatting.462 * into plain text with no formatting.
463 * @param preserveLineBreaks Specifies whether new line characters should 463 * @param preserveLineBreaks Specifies whether new line characters should
464 * be inserted into the returned text at the end of each terminal line. 464 * be inserted into the returned text at the end of each terminal line.
465 */465 */
466 void writeSelectionToStream(TerminalCharacterDecoder* decoder , bool466 void writeSelectionToStream(TerminalCharacterDecoder* decoder , bool
467 preserveLineBreaks = true) const;467 preserveLineBreaks = true) const;
@@ -478,15 +478,15 @@
478 */478 */
479 void checkSelection(int from, int to);479 void checkSelection(int from, int to);
480480
481 /** 481 /**
482 * Sets or clears an attribute of the current line.482 * Sets or clears an attribute of the current line.
483 * 483 *
484 * @param property The attribute to set or clear484 * @param property The attribute to set or clear
485 * Possible properties are:485 * Possible properties are:
486 * LINE_WRAPPED: Specifies that the line is wrapped.486 * LINE_WRAPPED: Specifies that the line is wrapped.
487 * LINE_DOUBLEWIDTH: Specifies that the characters in the current line487 * LINE_DOUBLEWIDTH: Specifies that the characters in the current line
488 * should be double the normal width.488 * should be double the normal width.
489 * LINE_DOUBLEHEIGHT:Specifies that the characters in the current line 489 * LINE_DOUBLEHEIGHT:Specifies that the characters in the current line
490 * should be double the normal height.490 * should be double the normal height.
491 * Double-height lines are formed of two lines containing the same characters,491 * Double-height lines are formed of two lines containing the same characters,
492 * with both having the LINE_DOUBLEHEIGHT attribute.492 * with both having the LINE_DOUBLEHEIGHT attribute.
@@ -497,24 +497,24 @@
497 */497 */
498 void setLineProperty(LineProperty property , bool enable);498 void setLineProperty(LineProperty property , bool enable);
499499
500 /** 500 /**
501 * Returns the number of lines that the image has been scrolled up or down by,501 * Returns the number of lines that the image has been scrolled up or down by,
502 * since the last call to resetScrolledLines().502 * since the last call to resetScrolledLines().
503 *503 *
504 * a positive return value indicates that the image has been scrolled up,504 * a positive return value indicates that the image has been scrolled up,
505 * a negative return value indicates that the image has been scrolled down. 505 * a negative return value indicates that the image has been scrolled down.
506 */506 */
507 int scrolledLines() const;507 int scrolledLines() const;
508508
509 /**509 /**
510 * Returns the region of the image which was last scrolled.510 * Returns the region of the image which was last scrolled.
511 *511 *
512 * This is the area of the image from the top margin to the 512 * This is the area of the image from the top margin to the
513 * bottom margin when the last scroll occurred.513 * bottom margin when the last scroll occurred.
514 */514 */
515 QRect lastScrolledRegion() const;515 QRect lastScrolledRegion() const;
516516
517 /** 517 /**
518 * Resets the count of the number of lines that the image has been scrolled up or down by,518 * Resets the count of the number of lines that the image has been scrolled up or down by,
519 * see scrolledLines()519 * see scrolledLines()
520 */520 */
@@ -527,7 +527,7 @@
527 *527 *
528 * If the history is not unlimited then it will drop528 * If the history is not unlimited then it will drop
529 * the oldest lines of output if new lines are added when529 * the oldest lines of output if new lines are added when
530 * it is full. 530 * it is full.
531 */531 */
532 int droppedLines() const;532 int droppedLines() const;
533533
@@ -537,32 +537,32 @@
537 */537 */
538 void resetDroppedLines();538 void resetDroppedLines();
539539
540 /** 540 /**
541 * Fills the buffer @p dest with @p count instances of the default (ie. blank)541 * Fills the buffer @p dest with @p count instances of the default (ie. blank)
542 * Character style.542 * Character style.
543 */543 */
544 static void fillWithDefaultChar(Character* dest, int count);544 static void fillWithDefaultChar(Character* dest, int count);
545545
546private: 546private:
547547
548 //copies a line of text from the screen or history into a stream using a 548 //copies a line of text from the screen or history into a stream using a
549 //specified character decoder. Returns the number of lines actually copied,549 //specified character decoder. Returns the number of lines actually copied,
550 //which may be less than 'count' if (start+count) is more than the number of characters on550 //which may be less than 'count' if (start+count) is more than the number of characters on
551 //the line 551 //the line
552 //552 //
553 //line - the line number to copy, from 0 (the earliest line in the history) up to 553 //line - the line number to copy, from 0 (the earliest line in the history) up to
554 // history->getLines() + lines - 1554 // history->getLines() + lines - 1
555 //start - the first column on the line to copy555 //start - the first column on the line to copy
556 //count - the number of characters on the line to copy556 //count - the number of characters on the line to copy
557 //decoder - a decoder which converts terminal characters (an Character array) into text557 //decoder - a decoder which converts terminal characters (an Character array) into text
558 //appendNewLine - if true a new line character (\n) is appended to the end of the line558 //appendNewLine - if true a new line character (\n) is appended to the end of the line
559 int copyLineToStream(int line, 559 int copyLineToStream(int line,
560 int start, 560 int start,
561 int count, 561 int count,
562 TerminalCharacterDecoder* decoder,562 TerminalCharacterDecoder* decoder,
563 bool appendNewLine,563 bool appendNewLine,
564 bool preserveLineBreaks) const;564 bool preserveLineBreaks) const;
565 565
566 //fills a section of the screen image with the character 'c'566 //fills a section of the screen image with the character 'c'
567 //the parameters are specified as offsets from the start of the screen image.567 //the parameters are specified as offsets from the start of the screen image.
568 //the loc(x,y) macro can be used to generate these values from a column,line pair.568 //the loc(x,y) macro can be used to generate these values from a column,line pair.
@@ -574,7 +574,7 @@
574 //574 //
575 //NOTE: moveImage() can only move whole lines575 //NOTE: moveImage() can only move whole lines
576 void moveImage(int dest, int sourceBegin, int sourceEnd);576 void moveImage(int dest, int sourceBegin, int sourceEnd);
577 // scroll up 'i' lines in current region, clearing the bottom 'i' lines 577 // scroll up 'i' lines in current region, clearing the bottom 'i' lines
578 void scrollUp(int from, int i);578 void scrollUp(int from, int i);
579 // scroll down 'i' lines in current region, clearing the top 'i' lines579 // scroll down 'i' lines in current region, clearing the top 'i' lines
580 void scrollDown(int from, int i);580 void scrollDown(int from, int i);
@@ -589,7 +589,7 @@
589 bool isSelectionValid() const;589 bool isSelectionValid() const;
590 // copies text from 'startIndex' to 'endIndex' to a stream590 // copies text from 'startIndex' to 'endIndex' to a stream
591 // startIndex and endIndex are positions generated using the loc(x,y) macro591 // startIndex and endIndex are positions generated using the loc(x,y) macro
592 void writeToStream(TerminalCharacterDecoder* decoder, int startIndex, 592 void writeToStream(TerminalCharacterDecoder* decoder, int startIndex,
593 int endIndex, bool preserveLineBreaks = true) const;593 int endIndex, bool preserveLineBreaks = true) const;
594 // copies 'count' lines from the screen buffer into 'dest',594 // copies 'count' lines from the screen buffer into 'dest',
595 // starting from 'startLine', where 0 is the first line in the screen buffer595 // starting from 'startLine', where 0 is the first line in the screen buffer
@@ -611,11 +611,11 @@
611611
612 int _droppedLines;612 int _droppedLines;
613613
614 QVarLengthArray<LineProperty,64> lineProperties; 614 QVarLengthArray<LineProperty,64> lineProperties;
615 615
616 // history buffer ---------------616 // history buffer ---------------
617 HistoryScroll* history;617 HistoryScroll* history;
618 618
619 // cursor location619 // cursor location
620 int cuX;620 int cuX;
621 int cuY;621 int cuY;
@@ -623,7 +623,7 @@
623 // cursor color and rendition info623 // cursor color and rendition info
624 CharacterColor currentForeground;624 CharacterColor currentForeground;
625 CharacterColor currentBackground;625 CharacterColor currentBackground;
626 quint8 currentRendition; 626 quint8 currentRendition;
627627
628 // margins ----------------628 // margins ----------------
629 int _topMargin;629 int _topMargin;
@@ -648,7 +648,7 @@
648 CharacterColor effectiveBackground; // the cu_* variables above648 CharacterColor effectiveBackground; // the cu_* variables above
649 quint8 effectiveRendition; // to speed up operation649 quint8 effectiveRendition; // to speed up operation
650650
651 class SavedState 651 class SavedState
652 {652 {
653 public:653 public:
654 SavedState()654 SavedState()
@@ -661,7 +661,7 @@
661 CharacterColor background;661 CharacterColor background;
662 };662 };
663 SavedState savedState;663 SavedState savedState;
664 664
665 // last position where we added a character665 // last position where we added a character
666 int lastPos;666 int lastPos;
667667
668668
=== modified file 'src/plugin/konsole/ScreenWindow.cpp'
--- src/plugin/konsole/ScreenWindow.cpp 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/ScreenWindow.cpp 2014-07-30 09:50:10 +0000
@@ -57,7 +57,7 @@
57{57{
58 // reallocate internal buffer if the window size has changed58 // reallocate internal buffer if the window size has changed
59 int size = windowLines() * windowColumns();59 int size = windowLines() * windowColumns();
60 if (_windowBuffer == 0 || _windowBufferSize != size) 60 if (_windowBuffer == 0 || _windowBufferSize != size)
61 {61 {
62 delete[] _windowBuffer;62 delete[] _windowBuffer;
63 _windowBufferSize = size;63 _windowBufferSize = size;
@@ -67,11 +67,11 @@
6767
68 if (!_bufferNeedsUpdate)68 if (!_bufferNeedsUpdate)
69 return _windowBuffer;69 return _windowBuffer;
70 70
71 _screen->getImage(_windowBuffer,size,71 _screen->getImage(_windowBuffer,size,
72 currentLine(),endWindowLine());72 currentLine(),endWindowLine());
7373
74 // this window may look beyond the end of the screen, in which 74 // this window may look beyond the end of the screen, in which
75 // case there will be an unused area which needs to be filled75 // case there will be an unused area which needs to be filled
76 // with blank characters76 // with blank characters
77 fillUnusedArea();77 fillUnusedArea();
@@ -88,10 +88,10 @@
88 int unusedLines = windowEndLine - screenEndLine;88 int unusedLines = windowEndLine - screenEndLine;
89 int charsToFill = unusedLines * windowColumns();89 int charsToFill = unusedLines * windowColumns();
9090
91 Screen::fillWithDefaultChar(_windowBuffer + _windowBufferSize - charsToFill,charsToFill); 91 Screen::fillWithDefaultChar(_windowBuffer + _windowBufferSize - charsToFill,charsToFill);
92}92}
9393
94// return the index of the line at the end of this window, or if this window 94// return the index of the line at the end of this window, or if this window
95// goes beyond the end of the screen, the index of the line at the end95// goes beyond the end of the screen, the index of the line at the end
96// of the screen.96// of the screen.
97//97//
@@ -106,7 +106,7 @@
106QVector<LineProperty> ScreenWindow::getLineProperties()106QVector<LineProperty> ScreenWindow::getLineProperties()
107{107{
108 QVector<LineProperty> result = _screen->getLineProperties(currentLine(),endWindowLine());108 QVector<LineProperty> result = _screen->getLineProperties(currentLine(),endWindowLine());
109 109
110 if (result.count() != windowLines())110 if (result.count() != windowLines())
111 result.resize(windowLines());111 result.resize(windowLines());
112112
@@ -131,7 +131,7 @@
131void ScreenWindow::setSelectionStart( int column , int line , bool columnMode )131void ScreenWindow::setSelectionStart( int column , int line , bool columnMode )
132{132{
133 _screen->setSelectionStart( column , qMin(line + currentLine(),endWindowLine()) , columnMode);133 _screen->setSelectionStart( column , qMin(line + currentLine(),endWindowLine()) , columnMode);
134 134
135 _bufferNeedsUpdate = true;135 _bufferNeedsUpdate = true;
136 emit selectionChanged();136 emit selectionChanged();
137}137}
@@ -163,7 +163,7 @@
163}163}
164int ScreenWindow::windowLines() const164int ScreenWindow::windowLines() const
165{165{
166 return _windowLines; 166 return _windowLines;
167}167}
168168
169int ScreenWindow::windowColumns() const169int ScreenWindow::windowColumns() const
@@ -184,11 +184,11 @@
184QPoint ScreenWindow::cursorPosition() const184QPoint ScreenWindow::cursorPosition() const
185{185{
186 QPoint position;186 QPoint position;
187 187
188 position.setX( _screen->getCursorX() );188 position.setX( _screen->getCursorX() );
189 position.setY( _screen->getCursorY() );189 position.setY( _screen->getCursorY() );
190190
191 return position; 191 return position;
192}192}
193193
194int ScreenWindow::currentLine() const194int ScreenWindow::currentLine() const
@@ -204,7 +204,7 @@
204 }204 }
205 else if ( mode == ScrollPages )205 else if ( mode == ScrollPages )
206 {206 {
207 scrollTo( currentLine() + amount * ( windowLines() / 2 ) ); 207 scrollTo( currentLine() + amount * ( windowLines() / 2 ) );
208 }208 }
209}209}
210210
@@ -245,7 +245,7 @@
245 return _scrollCount;245 return _scrollCount;
246}246}
247247
248void ScreenWindow::resetScrollCount() 248void ScreenWindow::resetScrollCount()
249{249{
250 _scrollCount = 0;250 _scrollCount = 0;
251}251}
@@ -265,18 +265,18 @@
265 // move window to the bottom of the screen and update scroll count265 // move window to the bottom of the screen and update scroll count
266 // if this window is currently tracking the bottom of the screen266 // if this window is currently tracking the bottom of the screen
267 if ( _trackOutput )267 if ( _trackOutput )
268 { 268 {
269 _scrollCount -= _screen->scrolledLines();269 _scrollCount -= _screen->scrolledLines();
270 _currentLine = qMax(0,_screen->getHistLines() - (windowLines()-_screen->getLines()));270 _currentLine = qMax(0,_screen->getHistLines() - (windowLines()-_screen->getLines()));
271 }271 }
272 else272 else
273 {273 {
274 // if the history is not unlimited then it may 274 // if the history is not unlimited then it may
275 // have run out of space and dropped the oldest275 // have run out of space and dropped the oldest
276 // lines of output - in this case the screen276 // lines of output - in this case the screen
277 // window's current line number will need to 277 // window's current line number will need to
278 // be adjusted - otherwise the output will scroll278 // be adjusted - otherwise the output will scroll
279 _currentLine = qMax(0,_currentLine - 279 _currentLine = qMax(0,_currentLine -
280 _screen->droppedLines());280 _screen->droppedLines());
281281
282 // ensure that the screen window's current position does282 // ensure that the screen window's current position does
@@ -286,7 +286,7 @@
286286
287 _bufferNeedsUpdate = true;287 _bufferNeedsUpdate = true;
288288
289 emit outputChanged(); 289 emit outputChanged();
290}290}
291291
292//#include "ScreenWindow.moc"292//#include "ScreenWindow.moc"
293293
=== modified file 'src/plugin/konsole/ScreenWindow.h'
--- src/plugin/konsole/ScreenWindow.h 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/ScreenWindow.h 2014-07-30 09:50:10 +0000
@@ -33,7 +33,7 @@
3333
34/**34/**
35 * Provides a window onto a section of a terminal screen. A terminal widget can then render35 * Provides a window onto a section of a terminal screen. A terminal widget can then render
36 * the contents of the window and use the window to change the terminal screen's selection 36 * the contents of the window and use the window to change the terminal screen's selection
37 * in response to mouse or keyboard input.37 * in response to mouse or keyboard input.
38 *38 *
39 * A new ScreenWindow for a terminal session can be created by calling Emulation::createWindow()39 * A new ScreenWindow for a terminal session can be created by calling Emulation::createWindow()
@@ -53,7 +53,7 @@
53Q_OBJECT53Q_OBJECT
5454
55public:55public:
56 /** 56 /**
57 * Constructs a new screen window with the given parent.57 * Constructs a new screen window with the given parent.
58 * A screen must be specified by calling setScreen() before calling getImage() or getLineProperties().58 * A screen must be specified by calling setScreen() before calling getImage() or getLineProperties().
59 *59 *
@@ -70,7 +70,7 @@
70 /** Returns the screen which this window looks onto */70 /** Returns the screen which this window looks onto */
71 Screen* screen() const;71 Screen* screen() const;
7272
73 /** 73 /**
74 * Returns the image of characters which are currently visible through this window74 * Returns the image of characters which are currently visible through this window
75 * onto the screen.75 * onto the screen.
76 *76 *
@@ -87,14 +87,14 @@
8787
88 /**88 /**
89 * Returns the number of lines which the region of the window89 * Returns the number of lines which the region of the window
90 * specified by scrollRegion() has been scrolled by since the last call 90 * specified by scrollRegion() has been scrolled by since the last call
91 * to resetScrollCount(). scrollRegion() is in most cases the 91 * to resetScrollCount(). scrollRegion() is in most cases the
92 * whole window, but will be a smaller area in, for example, applications92 * whole window, but will be a smaller area in, for example, applications
93 * which provide split-screen facilities.93 * which provide split-screen facilities.
94 *94 *
95 * This is not guaranteed to be accurate, but allows views to optimize95 * This is not guaranteed to be accurate, but allows views to optimize
96 * rendering by reducing the amount of costly text rendering that96 * rendering by reducing the amount of costly text rendering that
97 * needs to be done when the output is scrolled. 97 * needs to be done when the output is scrolled.
98 */98 */
99 int scrollCount() const;99 int scrollCount() const;
100100
@@ -104,7 +104,7 @@
104 void resetScrollCount();104 void resetScrollCount();
105105
106 /**106 /**
107 * Returns the area of the window which was last scrolled, this is 107 * Returns the area of the window which was last scrolled, this is
108 * usually the whole window area.108 * usually the whole window area.
109 *109 *
110 * Like scrollCount(), this is not guaranteed to be accurate,110 * Like scrollCount(), this is not guaranteed to be accurate,
@@ -112,8 +112,8 @@
112 */112 */
113 QRect scrollRegion() const;113 QRect scrollRegion() const;
114114
115 /** 115 /**
116 * Sets the start of the selection to the given @p line and @p column within 116 * Sets the start of the selection to the given @p line and @p column within
117 * the window.117 * the window.
118 */118 */
119 void setSelectionStart( int column , int line , bool columnMode );119 void setSelectionStart( int column , int line , bool columnMode );
@@ -121,7 +121,7 @@
121 * Sets the end of the selection to the given @p line and @p column within121 * Sets the end of the selection to the given @p line and @p column within
122 * the window.122 * the window.
123 */123 */
124 void setSelectionEnd( int column , int line ); 124 void setSelectionEnd( int column , int line );
125 /**125 /**
126 * Retrieves the start of the selection within the window.126 * Retrieves the start of the selection within the window.
127 */127 */
@@ -134,7 +134,7 @@
134 * Returns true if the character at @p line , @p column is part of the selection.134 * Returns true if the character at @p line , @p column is part of the selection.
135 */135 */
136 bool isSelected( int column , int line );136 bool isSelected( int column , int line );
137 /** 137 /**
138 * Clears the current selection138 * Clears the current selection
139 */139 */
140 void clearSelection();140 void clearSelection();
@@ -145,7 +145,7 @@
145 int windowLines() const;145 int windowLines() const;
146 /** Returns the number of columns in the window */146 /** Returns the number of columns in the window */
147 int windowColumns() const;147 int windowColumns() const;
148 148
149 /** Returns the total number of lines in the screen */149 /** Returns the total number of lines in the screen */
150 int lineCount() const;150 int lineCount() const;
151 /** Returns the total number of columns in the screen */151 /** Returns the total number of columns in the screen */
@@ -154,13 +154,13 @@
154 /** Returns the index of the line which is currently at the top of this window */154 /** Returns the index of the line which is currently at the top of this window */
155 int currentLine() const;155 int currentLine() const;
156156
157 /** 157 /**
158 * Returns the position of the cursor 158 * Returns the position of the cursor
159 * within the window.159 * within the window.
160 */160 */
161 QPoint cursorPosition() const;161 QPoint cursorPosition() const;
162162
163 /** 163 /**
164 * Convenience method. Returns true if the window is currently at the bottom164 * Convenience method. Returns true if the window is currently at the bottom
165 * of the screen.165 * of the screen.
166 */166 */
@@ -174,33 +174,33 @@
174 {174 {
175 /** Scroll the window down by a given number of lines. */175 /** Scroll the window down by a given number of lines. */
176 ScrollLines,176 ScrollLines,
177 /** 177 /**
178 * Scroll the window down by a given number of pages, where178 * Scroll the window down by a given number of pages, where
179 * one page is windowLines() lines179 * one page is windowLines() lines
180 */180 */
181 ScrollPages181 ScrollPages
182 };182 };
183183
184 /** 184 /**
185 * Scrolls the window relative to its current position on the screen.185 * Scrolls the window relative to its current position on the screen.
186 *186 *
187 * @param mode Specifies whether @p amount refers to the number of lines or the number187 * @param mode Specifies whether @p amount refers to the number of lines or the number
188 * of pages to scroll. 188 * of pages to scroll.
189 * @param amount The number of lines or pages ( depending on @p mode ) to scroll by. If189 * @param amount The number of lines or pages ( depending on @p mode ) to scroll by. If
190 * this number is positive, the view is scrolled down. If this number is negative, the view190 * this number is positive, the view is scrolled down. If this number is negative, the view
191 * is scrolled up.191 * is scrolled up.
192 */192 */
193 void scrollBy( RelativeScrollMode mode , int amount );193 void scrollBy( RelativeScrollMode mode , int amount );
194194
195 /** 195 /**
196 * Specifies whether the window should automatically move to the bottom196 * Specifies whether the window should automatically move to the bottom
197 * of the screen when new output is added.197 * of the screen when new output is added.
198 *198 *
199 * If this is set to true, the window will be moved to the bottom of the associated screen ( see 199 * If this is set to true, the window will be moved to the bottom of the associated screen ( see
200 * screen() ) when the notifyOutputChanged() method is called.200 * screen() ) when the notifyOutputChanged() method is called.
201 */201 */
202 void setTrackOutput(bool trackOutput);202 void setTrackOutput(bool trackOutput);
203 /** 203 /**
204 * Returns whether the window automatically moves to the bottom of the screen as204 * Returns whether the window automatically moves to the bottom of the screen as
205 * new output is added. See setTrackOutput()205 * new output is added. See setTrackOutput()
206 */206 */
@@ -214,7 +214,7 @@
214 QString selectedText( bool preserveLineBreaks ) const;214 QString selectedText( bool preserveLineBreaks ) const;
215215
216public slots:216public slots:
217 /** 217 /**
218 * Notifies the window that the contents of the associated terminal screen have changed.218 * Notifies the window that the contents of the associated terminal screen have changed.
219 * This moves the window to the bottom of the screen if trackOutput() is true and causes219 * This moves the window to the bottom of the screen if trackOutput() is true and causes
220 * the outputChanged() signal to be emitted.220 * the outputChanged() signal to be emitted.
@@ -223,13 +223,13 @@
223223
224signals:224signals:
225 /**225 /**
226 * Emitted when the contents of the associated terminal screen (see screen()) changes. 226 * Emitted when the contents of the associated terminal screen (see screen()) changes.
227 */227 */
228 void outputChanged();228 void outputChanged();
229229
230 /**230 /**
231 * Emitted when the screen window is scrolled to a different position.231 * Emitted when the screen window is scrolled to a different position.
232 * 232 *
233 * @param line The line which is now at the top of the window.233 * @param line The line which is now at the top of the window.
234 */234 */
235 void scrolled(int line);235 void scrolled(int line);
@@ -248,7 +248,7 @@
248248
249 int _windowLines;249 int _windowLines;
250 int _currentLine; // see scrollTo() , currentLine()250 int _currentLine; // see scrollTo() , currentLine()
251 bool _trackOutput; // see setTrackOutput() , trackOutput() 251 bool _trackOutput; // see setTrackOutput() , trackOutput()
252 int _scrollCount; // count of lines which the window has been scrolled by since252 int _scrollCount; // count of lines which the window has been scrolled by since
253 // the last call to resetScrollCount()253 // the last call to resetScrollCount()
254};254};
255255
=== modified file 'src/plugin/konsole/TerminalCharacterDecoder.cpp'
--- src/plugin/konsole/TerminalCharacterDecoder.cpp 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/TerminalCharacterDecoder.cpp 2014-07-30 09:50:10 +0000
@@ -1,8 +1,8 @@
1/*1/*
2 This file is part of Konsole, an X terminal.2 This file is part of Konsole, an X terminal.
3 3
4 Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>4 Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>
5 5
6 This program is free software; you can redistribute it and/or modify6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or8 the Free Software Foundation; either version 2 of the License, or
@@ -84,7 +84,7 @@
84 //(since QTextStream always deals with QStrings internally anyway)84 //(since QTextStream always deals with QStrings internally anyway)
85 QString plainText;85 QString plainText;
86 plainText.reserve(count);86 plainText.reserve(count);
87 87
88 int outputCount = count;88 int outputCount = count;
8989
90 // if inclusion of trailing whitespace is disabled then find the end of the90 // if inclusion of trailing whitespace is disabled then find the end of the
@@ -99,7 +99,7 @@
99 outputCount--;99 outputCount--;
100 }100 }
101 }101 }
102 102
103 for (int i=0;i<outputCount;)103 for (int i=0;i<outputCount;)
104 {104 {
105 plainText.append( QChar(characters[i].character) );105 plainText.append( QChar(characters[i].character) );
@@ -114,7 +114,7 @@
114 ,_innerSpanOpen(false)114 ,_innerSpanOpen(false)
115 ,_lastRendition(DEFAULT_RENDITION)115 ,_lastRendition(DEFAULT_RENDITION)
116{116{
117 117
118}118}
119119
120void HTMLDecoder::begin(QTextStream* output)120void HTMLDecoder::begin(QTextStream* output)
@@ -152,7 +152,7 @@
152 QString text;152 QString text;
153153
154 int spaceCount = 0;154 int spaceCount = 0;
155 155
156 for (int i=0;i<count;i++)156 for (int i=0;i<count;i++)
157 {157 {
158 QChar ch(characters[i].character);158 QChar ch(characters[i].character);
@@ -168,7 +168,7 @@
168 _lastRendition = characters[i].rendition;168 _lastRendition = characters[i].rendition;
169 _lastForeColor = characters[i].foregroundColor;169 _lastForeColor = characters[i].foregroundColor;
170 _lastBackColor = characters[i].backgroundColor;170 _lastBackColor = characters[i].backgroundColor;
171 171
172 //build up style string172 //build up style string
173 QString style;173 QString style;
174174
@@ -178,15 +178,15 @@
178 useBold = _lastRendition & RE_BOLD;178 useBold = _lastRendition & RE_BOLD;
179 else179 else
180 useBold = weight == ColorEntry::Bold;180 useBold = weight == ColorEntry::Bold;
181 181
182 if (useBold)182 if (useBold)
183 style.append("font-weight:bold;");183 style.append("font-weight:bold;");
184184
185 if ( _lastRendition & RE_UNDERLINE )185 if ( _lastRendition & RE_UNDERLINE )
186 style.append("font-decoration:underline;");186 style.append("font-decoration:underline;");
187 187
188 //colours - a colour table must have been defined first188 //colours - a colour table must have been defined first
189 if ( _colorTable ) 189 if ( _colorTable )
190 {190 {
191 style.append( QString("color:%1;").arg(_lastForeColor.color(_colorTable).name() ) );191 style.append( QString("color:%1;").arg(_lastForeColor.color(_colorTable).name() ) );
192192
@@ -195,8 +195,8 @@
195 style.append( QString("background-color:%1;").arg(_lastBackColor.color(_colorTable).name() ) );195 style.append( QString("background-color:%1;").arg(_lastBackColor.color(_colorTable).name() ) );
196 }196 }
197 }197 }
198 198
199 //open the span with the current style 199 //open the span with the current style
200 openSpan(text,style);200 openSpan(text,style);
201 _innerSpanOpen = true;201 _innerSpanOpen = true;
202 }202 }
@@ -206,7 +206,7 @@
206 spaceCount++;206 spaceCount++;
207 else207 else
208 spaceCount = 0;208 spaceCount = 0;
209 209
210210
211 //output current character211 //output current character
212 if (spaceCount < 2)212 if (spaceCount < 2)
@@ -216,14 +216,14 @@
216 text.append("&lt;");216 text.append("&lt;");
217 else if (ch == '>')217 else if (ch == '>')
218 text.append("&gt;");218 text.append("&gt;");
219 else 219 else
220 text.append(ch);220 text.append(ch);
221 }221 }
222 else222 else
223 {223 {
224 text.append("&nbsp;"); //HTML truncates multiple spaces, so use a space marker instead224 text.append("&nbsp;"); //HTML truncates multiple spaces, so use a space marker instead
225 }225 }
226 226
227 }227 }
228228
229 //close any remaining open inner spans229 //close any remaining open inner spans
@@ -232,7 +232,7 @@
232232
233 //start new line233 //start new line
234 text.append("<br>");234 text.append("<br>");
235 235
236 *_output << text;236 *_output << text;
237}237}
238void HTMLDecoder::openSpan(QString& text , const QString& style)238void HTMLDecoder::openSpan(QString& text , const QString& style)
239239
=== modified file 'src/plugin/konsole/TerminalCharacterDecoder.h'
--- src/plugin/konsole/TerminalCharacterDecoder.h 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/TerminalCharacterDecoder.h 2014-07-30 09:50:10 +0000
@@ -1,8 +1,8 @@
1/*1/*
2 This file is part of Konsole, an X terminal.2 This file is part of Konsole, an X terminal.
3 3
4 Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>4 Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>
5 5
6 This program is free software; you can redistribute it and/or modify6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or8 the Free Software Foundation; either version 2 of the License, or
@@ -37,7 +37,7 @@
37 * and background colours and other appearance-related properties into text strings.37 * and background colours and other appearance-related properties into text strings.
38 *38 *
39 * Derived classes may produce either plain text with no other colour or appearance information, or39 * Derived classes may produce either plain text with no other colour or appearance information, or
40 * they may produce text which incorporates these additional properties. 40 * they may produce text which incorporates these additional properties.
41 */41 */
42class TerminalCharacterDecoder42class TerminalCharacterDecoder
43{43{
@@ -57,9 +57,9 @@
57 * @param count The number of characters57 * @param count The number of characters
58 * @param properties Additional properties which affect all characters in the line58 * @param properties Additional properties which affect all characters in the line
59 */59 */
60 virtual void decodeLine(const Character* const characters, 60 virtual void decodeLine(const Character* const characters,
61 int count,61 int count,
62 LineProperty properties) = 0; 62 LineProperty properties) = 0;
63};63};
6464
65/**65/**
@@ -69,10 +69,10 @@
69class PlainTextDecoder : public TerminalCharacterDecoder69class PlainTextDecoder : public TerminalCharacterDecoder
70{70{
71public:71public:
72 PlainTextDecoder(); 72 PlainTextDecoder();
7373
74 /** 74 /**
75 * Set whether trailing whitespace at the end of lines should be included 75 * Set whether trailing whitespace at the end of lines should be included
76 * in the output.76 * in the output.
77 * Defaults to true.77 * Defaults to true.
78 */78 */
@@ -82,9 +82,9 @@
82 * in the output.82 * in the output.
83 */83 */
84 bool trailingWhitespace() const;84 bool trailingWhitespace() const;
85 /** 85 /**
86 * Returns of character positions in the output stream86 * Returns of character positions in the output stream
87 * at which new lines where added. Returns an empty if setTrackLinePositions() is false or if 87 * at which new lines where added. Returns an empty if setTrackLinePositions() is false or if
88 * the output device is not a string.88 * the output device is not a string.
89 */89 */
90 QList<int> linePositions() const;90 QList<int> linePositions() const;
@@ -96,9 +96,9 @@
9696
97 virtual void decodeLine(const Character* const characters,97 virtual void decodeLine(const Character* const characters,
98 int count,98 int count,
99 LineProperty properties); 99 LineProperty properties);
100100
101 101
102private:102private:
103 QTextStream* _output;103 QTextStream* _output;
104 bool _includeTrailingWhitespace;104 bool _includeTrailingWhitespace;
@@ -113,7 +113,7 @@
113class HTMLDecoder : public TerminalCharacterDecoder113class HTMLDecoder : public TerminalCharacterDecoder
114{114{
115public:115public:
116 /** 116 /**
117 * Constructs an HTML decoder using a default black-on-white color scheme.117 * Constructs an HTML decoder using a default black-on-white color scheme.
118 */118 */
119 HTMLDecoder();119 HTMLDecoder();
@@ -123,7 +123,7 @@
123 * output123 * output
124 */124 */
125 void setColorTable( const ColorEntry* table );125 void setColorTable( const ColorEntry* table );
126 126
127 virtual void decodeLine(const Character* const characters,127 virtual void decodeLine(const Character* const characters,
128 int count,128 int count,
129 LineProperty properties);129 LineProperty properties);
@@ -137,7 +137,7 @@
137137
138 QTextStream* _output;138 QTextStream* _output;
139 const ColorEntry* _colorTable;139 const ColorEntry* _colorTable;
140 bool _innerSpanOpen; 140 bool _innerSpanOpen;
141 quint8 _lastRendition;141 quint8 _lastRendition;
142 CharacterColor _lastForeColor;142 CharacterColor _lastForeColor;
143 CharacterColor _lastBackColor;143 CharacterColor _lastBackColor;
144144
=== modified file 'src/plugin/konsole/Vt102Emulation.cpp'
--- src/plugin/konsole/Vt102Emulation.cpp 2014-04-27 09:11:14 +0000
+++ src/plugin/konsole/Vt102Emulation.cpp 2014-07-30 09:50:10 +0000
@@ -1,6 +1,6 @@
1/*1/*
2 This file is part of Konsole, an X terminal.2 This file is part of Konsole, an X terminal.
3 3
4 Copyright 2007-2008 by Robert Knight <robert.knight@gmail.com>4 Copyright 2007-2008 by Robert Knight <robert.knight@gmail.com>
5 Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>5 Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
66
@@ -37,7 +37,7 @@
37 void scrolllock_set_on();37 void scrolllock_set_on();
38#endif38#endif
3939
40// Standard 40// Standard
41#include <stdio.h>41#include <stdio.h>
42#include <unistd.h>42#include <unistd.h>
43#include <assert.h>43#include <assert.h>
@@ -55,7 +55,7 @@
55#include "KeyboardTranslator.h"55#include "KeyboardTranslator.h"
56#include "Screen.h"56#include "Screen.h"
5757
58Vt102Emulation::Vt102Emulation() 58Vt102Emulation::Vt102Emulation()
59 : Emulation(),59 : Emulation(),
60 _titleUpdateTimer(new QTimer(this))60 _titleUpdateTimer(new QTimer(this))
61{61{
@@ -72,7 +72,7 @@
72void Vt102Emulation::clearEntireScreen()72void Vt102Emulation::clearEntireScreen()
73{73{
74 _currentScreen->clearEntireScreen();74 _currentScreen->clearEntireScreen();
75 bufferedUpdate(); 75 bufferedUpdate();
76}76}
7777
78void Vt102Emulation::reset()78void Vt102Emulation::reset()
@@ -84,7 +84,7 @@
84 resetCharset(1);84 resetCharset(1);
85 _screen[1]->reset();85 _screen[1]->reset();
86 setCodec(LocaleCodec);86 setCodec(LocaleCodec);
87 87
88 bufferedUpdate();88 bufferedUpdate();
89}89}
9090
@@ -135,7 +135,7 @@
135 - VT52 - VT52 escape codes135 - VT52 - VT52 escape codes
136 - <ESC><Chr>136 - <ESC><Chr>
137 - <ESC>'Y'{Pc}{Pc}137 - <ESC>'Y'{Pc}{Pc}
138 - XTE_HA - Xterm window/terminal attribute commands 138 - XTE_HA - Xterm window/terminal attribute commands
139 of the form <ESC>`]' {Pn} `;' {Text} <BEL>139 of the form <ESC>`]' {Pn} `;' {Text} <BEL>
140 (Note that these are handled differently to the other formats)140 (Note that these are handled differently to the other formats)
141141
@@ -175,9 +175,9 @@
175175
176void Vt102Emulation::resetTokenizer()176void Vt102Emulation::resetTokenizer()
177{177{
178 tokenBufferPos = 0; 178 tokenBufferPos = 0;
179 argc = 0; 179 argc = 0;
180 argv[0] = 0; 180 argv[0] = 0;
181 argv[1] = 0;181 argv[1] = 0;
182}182}
183183
@@ -203,33 +203,33 @@
203203
204#define CTL 1 // Control character204#define CTL 1 // Control character
205#define CHR 2 // Printable character205#define CHR 2 // Printable character
206#define CPN 4 // TODO: Document me 206#define CPN 4 // TODO: Document me
207#define DIG 8 // Digit207#define DIG 8 // Digit
208#define SCS 16 // TODO: Document me 208#define SCS 16 // TODO: Document me
209#define GRP 32 // TODO: Document me209#define GRP 32 // TODO: Document me
210#define CPS 64 // Character which indicates end of window resize210#define CPS 64 // Character which indicates end of window resize
211 // escape sequence '\e[8;<row>;<col>t'211 // escape sequence '\e[8;<row>;<col>t'
212212
213void Vt102Emulation::initTokenizer()213void Vt102Emulation::initTokenizer()
214{ 214{
215 int i; 215 int i;
216 quint8* s;216 quint8* s;
217 for(i = 0;i < 256; ++i) 217 for(i = 0;i < 256; ++i)
218 charClass[i] = 0;218 charClass[i] = 0;
219 for(i = 0;i < 32; ++i) 219 for(i = 0;i < 32; ++i)
220 charClass[i] |= CTL;220 charClass[i] |= CTL;
221 for(i = 32;i < 256; ++i) 221 for(i = 32;i < 256; ++i)
222 charClass[i] |= CHR;222 charClass[i] |= CHR;
223 for(s = (quint8*)"@ABCDGHILMPSTXZcdfry"; *s; ++s) 223 for(s = (quint8*)"@ABCDGHILMPSTXZcdfry"; *s; ++s)
224 charClass[*s] |= CPN;224 charClass[*s] |= CPN;
225 // resize = \e[8;<row>;<col>t225 // resize = \e[8;<row>;<col>t
226 for(s = (quint8*)"t"; *s; ++s) 226 for(s = (quint8*)"t"; *s; ++s)
227 charClass[*s] |= CPS;227 charClass[*s] |= CPS;
228 for(s = (quint8*)"0123456789"; *s; ++s) 228 for(s = (quint8*)"0123456789"; *s; ++s)
229 charClass[*s] |= DIG;229 charClass[*s] |= DIG;
230 for(s = (quint8*)"()+*%"; *s; ++s) 230 for(s = (quint8*)"()+*%"; *s; ++s)
231 charClass[*s] |= SCS;231 charClass[*s] |= SCS;
232 for(s = (quint8*)"()+*#[]%"; *s; ++s) 232 for(s = (quint8*)"()+*#[]%"; *s; ++s)
233 charClass[*s] |= GRP;233 charClass[*s] |= GRP;
234234
235 resetTokenizer();235 resetTokenizer();
@@ -246,10 +246,10 @@
246 - P is the length of the token scanned so far.246 - P is the length of the token scanned so far.
247 - L (often P-1) is the position on which contents we base a decision.247 - L (often P-1) is the position on which contents we base a decision.
248 - C is a character or a group of characters (taken from 'charClass').248 - C is a character or a group of characters (taken from 'charClass').
249 249
250 - 'cc' is the current character250 - 'cc' is the current character
251 - 's' is a pointer to the start of the token buffer251 - 's' is a pointer to the start of the token buffer
252 - 'p' is the current position within the token buffer 252 - 'p' is the current position within the token buffer
253253
254 Note that they need to applied in proper order.254 Note that they need to applied in proper order.
255*/255*/
@@ -272,31 +272,31 @@
272272
273// process an incoming unicode character273// process an incoming unicode character
274void Vt102Emulation::receiveChar(int cc)274void Vt102Emulation::receiveChar(int cc)
275{ 275{
276 if (cc == 127) 276 if (cc == 127)
277 return; //VT100: ignore.277 return; //VT100: ignore.
278278
279 if (ces(CTL))279 if (ces(CTL))
280 { 280 {
281 // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100281 // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100
282 // This means, they do neither a resetTokenizer() nor a pushToToken(). Some of them, do282 // This means, they do neither a resetTokenizer() nor a pushToToken(). Some of them, do
283 // of course. Guess this originates from a weakly layered handling of the X-on283 // of course. Guess this originates from a weakly layered handling of the X-on
284 // X-off protocol, which comes really below this level.284 // X-off protocol, which comes really below this level.
285 if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) 285 if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC)
286 resetTokenizer(); //VT100: CAN or SUB286 resetTokenizer(); //VT100: CAN or SUB
287 if (cc != ESC) 287 if (cc != ESC)
288 { 288 {
289 processToken(TY_CTL(cc+'@' ),0,0); 289 processToken(TY_CTL(cc+'@' ),0,0);
290 return; 290 return;
291 }291 }
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches