| 1 | /* |
| 2 | Copyright 2007-2008 Robert Knight <[email protected]> |
| 3 | Copyright 1997,1998 by Lars Doelle <[email protected]> |
| 4 | Copyright 1996 by Matthias Ettrich <[email protected]> |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 19 | 02110-1301 USA. |
| 20 | */ |
| 21 | |
| 22 | // Own |
| 23 | #include "Emulation.h"cxx . . $ `<file>/lib/Emulation.h`/ |
| 24 | |
| 25 | // System |
| 26 | #include <cstdio> |
| 27 | #include <cstdlib> |
| 28 | #include <unistd.h> |
| 29 | #include <string> |
| 30 | |
| 31 | // Qt |
| 32 | #include <QApplication> |
| 33 | #include <QClipboard> |
| 34 | #include <QHash> |
| 35 | #include <QKeyEvent> |
| 36 | #include <QRegExp> |
| 37 | #include <QTextStream> |
| 38 | #include <QThread> |
| 39 | |
| 40 | #include <QTime> |
| 41 | |
| 42 | // KDE |
| 43 | //#include <kdebug.h> |
| 44 | |
| 45 | // Konsole |
| 46 | #include "KeyboardTranslator.h"cxx . . $ `<file>/lib/KeyboardTranslator.h`/ |
| 47 | #include "Screen.h"cxx . . $ `<file>/lib/Screen.h`/ |
| 48 | #include "TerminalCharacterDecoder.h"cxx . . $ `<file>/lib/TerminalCharacterDecoder.h`/ |
| 49 | #include "ScreenWindow.h"cxx . . $ `<file>/lib/ScreenWindow.h`/ |
| 50 | |
| 51 | using namespace Konsole; |
| 52 | |
| 53 | Emulationcxx . . $ Konsole/Emulation#::Emulationcxx . . $ Konsole/Emulation#Emulation(49f6e7a06ebc5aa8).() : |
| 54 | _currentScreencxx . . $ Konsole/Emulation#_currentScreen.(nullptr), |
| 55 | _codeccxx . . $ Konsole/Emulation#_codec.(nullptr), |
| 56 | _decodercxx . . $ Konsole/Emulation#_decoder.(nullptr), |
| 57 | _keyTranslatorcxx . . $ Konsole/Emulation#_keyTranslator.(nullptr), |
| 58 | _usesMousecxx . . $ Konsole/Emulation#_usesMouse.(false), |
| 59 | _bracketedPasteModecxx . . $ Konsole/Emulation#_bracketedPasteMode.(false) |
| 60 | { |
| 61 | // create screens with a default size |
| 62 | _screencxx . . $ Konsole/Emulation#_screen.[0] = new Screencxx . . $ Konsole/Screen#Screen(3e454b8ccf442868).(40,80); |
| 63 | _screencxx . . $ Konsole/Emulation#_screen.[1] = new Screencxx . . $ Konsole/Screen#Screen(3e454b8ccf442868).(40,80); |
| 64 | _currentScreencxx . . $ Konsole/Emulation#_currentScreen. = _screencxx . . $ Konsole/Emulation#_screen.[0]; |
| 65 | |
| 66 | QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(158df1d9a01a3410).(&_bulkTimer1cxx . . $ Konsole/Emulation#_bulkTimer1., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(timeout()), this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(showBulk()) ); |
| 67 | QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(158df1d9a01a3410).(&_bulkTimer2cxx . . $ Konsole/Emulation#_bulkTimer2., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(timeout()), this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(showBulk()) ); |
| 68 | |
| 69 | // listen for mouse status changes |
| 70 | connectcxx . . $ QObject#connect(f4332061c7e4ca89).(this , SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(programUsesMouseChanged(bool)) , |
| 71 | SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(usesMouseChanged(bool))); |
| 72 | connectcxx . . $ QObject#connect(f4332061c7e4ca89).(this , SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(programBracketedPasteModeChanged(bool)) , |
| 73 | SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(bracketedPasteModeChanged(bool))); |
| 74 | |
| 75 | connectcxx . . $ QObject#connect(799f219bacec96aa).(this, &Emulationcxx . . $ Konsole/Emulation#::cursorChangedcxx . . $ Konsole/Emulation#cursorChanged(e433759c0c286c4c)., [this] (KeyboardCursorShapecxx . . $ Konsole/Emulation#KeyboardCursorShape# cursorShape, bool blinkingCursorEnabled) { |
| 76 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! titleChangedcxx . . $ Konsole/Emulation#titleChanged(4b11a7293b4ed91c).( 50, QStringcxx . . $ QString#QString(4641beeb24e75d60).(QLatin1Stringcxx . . $ QLatin1String#QLatin1String(aac1607cfe1c1740).("CursorShape=%1;BlinkingCursorEnabled=%2")) |
| 77 | .argcxx . . $ QString#arg(64ab2ed17cc11715).(static_cast<int>(cursorShape)).argcxx . . $ QString#arg(64ab2ed17cc11715).(blinkingCursorEnabled) ); |
| 78 | }); |
| 79 | } |
| 80 | |
| 81 | bool Emulationcxx . . $ Konsole/Emulation#::programUsesMousecxx . . $ Konsole/Emulation#programUsesMouse(50ce9a9e25b4a850).() const |
| 82 | { |
| 83 | return _usesMousecxx . . $ Konsole/Emulation#_usesMouse.; |
| 84 | } |
| 85 | |
| 86 | void Emulationcxx . . $ Konsole/Emulation#::usesMouseChangedcxx . . $ Konsole/Emulation#usesMouseChanged(b45ddcbc8423892c).(bool usesMouse) |
| 87 | { |
| 88 | _usesMousecxx . . $ Konsole/Emulation#_usesMouse. = usesMouse; |
| 89 | } |
| 90 | |
| 91 | bool Emulationcxx . . $ Konsole/Emulation#::programBracketedPasteModecxx . . $ Konsole/Emulation#programBracketedPasteMode(50ce9a9e25b4a850).() const |
| 92 | { |
| 93 | return _bracketedPasteModecxx . . $ Konsole/Emulation#_bracketedPasteMode.; |
| 94 | } |
| 95 | |
| 96 | void Emulationcxx . . $ Konsole/Emulation#::bracketedPasteModeChangedcxx . . $ Konsole/Emulation#bracketedPasteModeChanged(b45ddcbc8423892c).(bool bracketedPasteMode) |
| 97 | { |
| 98 | _bracketedPasteModecxx . . $ Konsole/Emulation#_bracketedPasteMode. = bracketedPasteMode; |
| 99 | } |
| 100 | |
| 101 | ScreenWindowcxx . . $ Konsole/ScreenWindow#* Emulationcxx . . $ Konsole/Emulation#::createWindowcxx . . $ Konsole/Emulation#createWindow(402b4ab612c457df).() |
| 102 | { |
| 103 | ScreenWindowcxx . . $ Konsole/ScreenWindow#* window = new ScreenWindowcxx . . $ Konsole/ScreenWindow#ScreenWindow(749de1b6ae65bddd).(); |
| 104 | window->setScreencxx . . $ Konsole/ScreenWindow#setScreen(102c82049da634ab).(_currentScreencxx . . $ Konsole/Emulation#_currentScreen.); |
| 105 | _windowscxx . . $ Konsole/Emulation#_windows. <<cxx . . $ QList#`operator<<`(309d1580d8f5dc58). window; |
| 106 | |
| 107 | connectcxx . . $ QObject#connect(158df1d9a01a3410).(window , SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(selectionChanged()), |
| 108 | this , SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(bufferedUpdate())); |
| 109 | |
| 110 | connectcxx . . $ QObject#connect(158df1d9a01a3410).(this , SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(outputChanged()), |
| 111 | window , SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(notifyOutputChanged()) ); |
| 112 | |
| 113 | connectcxx . . $ QObject#connect(835f87066c895669).(this, &Emulationcxx . . $ Konsole/Emulation#::handleCommandFromKeyboardcxx . . $ Konsole/Emulation#handleCommandFromKeyboard(16cb6c07cd6749eb)., |
| 114 | window, &ScreenWindowcxx . . $ Konsole/ScreenWindow#::handleCommandFromKeyboardcxx . . $ Konsole/ScreenWindow#handleCommandFromKeyboard(16cb6c07cd6749eb).); |
| 115 | connectcxx . . $ QObject#connect(835f87066c895669).(this, &Emulationcxx . . $ Konsole/Emulation#::outputFromKeypressEventcxx . . $ Konsole/Emulation#outputFromKeypressEvent(49f6e7a06ebc5aa8)., |
| 116 | window, &ScreenWindowcxx . . $ Konsole/ScreenWindow#::scrollToEndcxx . . $ Konsole/ScreenWindow#scrollToEnd(49f6e7a06ebc5aa8).); |
| 117 | |
| 118 | return window; |
| 119 | } |
| 120 | |
| 121 | Emulationcxx . . $ Konsole/Emulation#::~cxx . . $ Konsole/Emulation#`~Emulation`(ced63f7c635d850d).Emulationcxx . . $ Konsole/Emulation#() |
| 122 | { |
| 123 | QListIteratorcxx . . $ QListIterator#<ScreenWindowcxx . . $ Konsole/ScreenWindow#*> windowItercxx . . $ QListIterator#QListIterator(742a15f66a895bc5).(_windowscxx . . $ Konsole/Emulation#_windows.); |
| 124 | |
| 125 | while (windowIter.hasNextcxx . . $ QListIterator#hasNext(50ce9a9e25b4a850).()) |
| 126 | { |
| 127 | delete windowIter.nextcxx . . $ QListIterator#next(1306adbac230aeaa).(); |
| 128 | } |
| 129 | |
| 130 | delete _screencxx . . $ Konsole/Emulation#_screen.[0]; |
| 131 | delete _screencxx . . $ Konsole/Emulation#_screen.[1]; |
| 132 | delete _decodercxx . . $ Konsole/Emulation#_decoder.; |
| 133 | } |
| 134 | |
| 135 | void Emulationcxx . . $ Konsole/Emulation#::setScreencxx . . $ Konsole/Emulation#setScreen(d4f767463ce0a6b3).(int n) |
| 136 | { |
| 137 | Screencxx . . $ Konsole/Screen# *old = _currentScreencxx . . $ Konsole/Emulation#_currentScreen.; |
| 138 | _currentScreencxx . . $ Konsole/Emulation#_currentScreen. = _screencxx . . $ Konsole/Emulation#_screen.[n & 1]; |
| 139 | if (_currentScreencxx . . $ Konsole/Emulation#_currentScreen. != old) |
| 140 | { |
| 141 | // tell all windows onto this emulation to switch to the newly active screen |
| 142 | for(ScreenWindowcxx . . $ Konsole/ScreenWindow#* window : qAsConstcxx . . $ qAsConst(1dc117cbefefc300).(_windowscxx . . $ Konsole/Emulation#_windows.)) |
| 143 | window->setScreencxx . . $ Konsole/ScreenWindow#setScreen(102c82049da634ab).(_currentScreencxx . . $ Konsole/Emulation#_currentScreen.); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | void Emulationcxx . . $ Konsole/Emulation#::clearHistorycxx . . $ Konsole/Emulation#clearHistory(49f6e7a06ebc5aa8).() |
| 148 | { |
| 149 | _screencxx . . $ Konsole/Emulation#_screen.[0]->setScrollcxx . . $ Konsole/Screen#setScroll(629d541fe2e7ef47).( _screencxx . . $ Konsole/Emulation#_screen.[0]->getScrollcxx . . $ Konsole/Screen#getScroll(4823a4bab87d8bdc).() , false ); |
| 150 | } |
| 151 | void Emulationcxx . . $ Konsole/Emulation#::setHistorycxx . . $ Konsole/Emulation#setHistory(8cdb70a5e6e0950).(const HistoryTypecxx . . $ Konsole/HistoryType#& t) |
| 152 | { |
| 153 | _screencxx . . $ Konsole/Emulation#_screen.[0]->setScrollcxx . . $ Konsole/Screen#setScroll(629d541fe2e7ef47).(t); |
| 154 | |
| 155 | showBulkcxx . . $ Konsole/Emulation#showBulk(49f6e7a06ebc5aa8).(); |
| 156 | } |
| 157 | |
| 158 | const HistoryTypecxx . . $ Konsole/HistoryType#& Emulationcxx . . $ Konsole/Emulation#::historycxx . . $ Konsole/Emulation#history(4823a4bab87d8bdc).() const |
| 159 | { |
| 160 | return _screencxx . . $ Konsole/Emulation#_screen.[0]->getScrollcxx . . $ Konsole/Screen#getScroll(4823a4bab87d8bdc).(); |
| 161 | } |
| 162 | |
| 163 | void Emulationcxx . . $ Konsole/Emulation#::setCodeccxx . . $ Konsole/Emulation#setCodec(dba08ac82884e446).(const QTextCodeccxx . . $ QTextCodec# * qtc) |
| 164 | { |
| 165 | if (qtc) |
| 166 | _codeccxx . . $ Konsole/Emulation#_codec. = qtc; |
| 167 | else |
| 168 | setCodeccxx . . $ Konsole/Emulation#setCodec(4b213728ebae3f25).(LocaleCodeccxx . . $ Konsole/Emulation#LocaleCodec.); |
| 169 | |
| 170 | delete _decodercxx . . $ Konsole/Emulation#_decoder.; |
| 171 | _decodercxx . . $ Konsole/Emulation#_decoder. = _codeccxx . . $ Konsole/Emulation#_codec.->makeDecodercxx . . $ QTextCodec#makeDecoder(969f31547039bdf1).(); |
| 172 | |
| 173 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! useUtf8Requestcxx . . $ Konsole/Emulation#useUtf8Request(b45ddcbc8423892c).(utf8cxx . . $ Konsole/Emulation#utf8(50ce9a9e25b4a850).()); |
| 174 | } |
| 175 | |
| 176 | void Emulationcxx . . $ Konsole/Emulation#::setCodeccxx . . $ Konsole/Emulation#setCodec(4b213728ebae3f25).(EmulationCodeccxx . . $ Konsole/Emulation#EmulationCodec# codec) |
| 177 | { |
| 178 | if ( codec == Utf8Codeccxx . . $ Konsole/Emulation#Utf8Codec. ) |
| 179 | setCodeccxx . . $ Konsole/Emulation#setCodec(dba08ac82884e446).( QTextCodeccxx . . $ QTextCodec#::codecForNamecxx . . $ QTextCodec#codecForName(914382192c9ca379).("utf8") ); |
| 180 | else if ( codec == LocaleCodeccxx . . $ Konsole/Emulation#LocaleCodec. ) |
| 181 | setCodeccxx . . $ Konsole/Emulation#setCodec(dba08ac82884e446).( QTextCodeccxx . . $ QTextCodec#::codecForLocalecxx . . $ QTextCodec#codecForLocale(6599407a1b23811).() ); |
| 182 | } |
| 183 | |
| 184 | void Emulationcxx . . $ Konsole/Emulation#::setKeyBindingscxx . . $ Konsole/Emulation#setKeyBindings(3520e46b33348bf6).(const QStringcxx . . $ QString#& name) |
| 185 | { |
| 186 | _keyTranslatorcxx . . $ Konsole/Emulation#_keyTranslator. = KeyboardTranslatorManagercxx . . $ Konsole/KeyboardTranslatorManager#::instancecxx . . $ Konsole/KeyboardTranslatorManager#instance(c68e8ff900e8f73d).()->findTranslatorcxx . . $ Konsole/KeyboardTranslatorManager#findTranslator(beb4fd75b5211f9).(name); |
| 187 | if (!_keyTranslatorcxx . . $ Konsole/Emulation#_keyTranslator.) |
| 188 | { |
| 189 | _keyTranslatorcxx . . $ Konsole/Emulation#_keyTranslator. = KeyboardTranslatorManagercxx . . $ Konsole/KeyboardTranslatorManager#::instancecxx . . $ Konsole/KeyboardTranslatorManager#instance(c68e8ff900e8f73d).()->defaultTranslatorcxx . . $ Konsole/KeyboardTranslatorManager#defaultTranslator(2f3bd4063c9915c6).(); |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | QStringcxx . . $ QString# Emulationcxx . . $ Konsole/Emulation#::keyBindingscxx . . $ Konsole/Emulation#keyBindings(6ef7b6c27b00b43d).() const |
| 194 | { |
| 195 | return _keyTranslatorcxx . . $ Konsole/Emulation#_keyTranslator.->namecxx . . $ Konsole/KeyboardTranslator#name(6ef7b6c27b00b43d).(); |
| 196 | } |
| 197 | |
| 198 | void Emulationcxx . . $ Konsole/Emulation#::receiveCharcxx . . $ Konsole/Emulation#receiveChar(d461ae26ddb24b42).(wchar_t c) |
| 199 | // process application unicode input to terminal |
| 200 | // this is a trivial scanner |
| 201 | { |
| 202 | c &= 0xff; |
| 203 | switch (c) |
| 204 | { |
| 205 | case '\b' : _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->backspacecxx . . $ Konsole/Screen#backspace(49f6e7a06ebc5aa8).(); break; |
| 206 | case '\t' : _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->tabcxx . . $ Konsole/Screen#tab(d4f767463ce0a6b3).(); break; |
| 207 | case '\n' : _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->newLinecxx . . $ Konsole/Screen#newLine(49f6e7a06ebc5aa8).(); break; |
| 208 | case '\r' : _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->toStartOfLinecxx . . $ Konsole/Screen#toStartOfLine(49f6e7a06ebc5aa8).(); break; |
| 209 | case 0x07 : emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! stateSetcxx . . $ Konsole/Emulation#stateSet(d4f767463ce0a6b3).(NOTIFYBELLcxx . . $ Konsole/NOTIFYBELL.); |
| 210 | break; |
| 211 | default : _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->displayCharactercxx . . $ Konsole/Screen#displayCharacter(d461ae26ddb24b42).(c); break; |
| 212 | }; |
| 213 | } |
| 214 | |
| 215 | void Emulationcxx . . $ Konsole/Emulation#::sendKeyEventcxx . . $ Konsole/Emulation#sendKeyEvent(4ced653b20f45578).(QKeyEventcxx . . $ QKeyEvent#* ev, bool) |
| 216 | { |
| 217 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! stateSetcxx . . $ Konsole/Emulation#stateSet(d4f767463ce0a6b3).(NOTIFYNORMALcxx . . $ Konsole/NOTIFYNORMAL.); |
| 218 | |
| 219 | if (!ev->textcxx . . $ QKeyEvent#text(6ef7b6c27b00b43d).().isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 220 | { // A block of text |
| 221 | // Note that the text is proper unicode. |
| 222 | // We should do a conversion here |
| 223 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! sendDatacxx . . $ Konsole/Emulation#sendData(34d26762b42c433a).(ev->textcxx . . $ QKeyEvent#text(6ef7b6c27b00b43d).().toUtf8cxx . . $ QString#toUtf8(7c2073558a834e49).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(),ev->textcxx . . $ QKeyEvent#text(6ef7b6c27b00b43d).().lengthcxx . . $ QString#length(455f465bc33b4cdf).()); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | void Emulationcxx . . $ Konsole/Emulation#::sendStringcxx . . $ Konsole/Emulation#sendString(34d26762b42c433a).(const char*,int) |
| 228 | { |
| 229 | // default implementation does nothing |
| 230 | } |
| 231 | |
| 232 | void Emulationcxx . . $ Konsole/Emulation#::sendMouseEventcxx . . $ Konsole/Emulation#sendMouseEvent(748afa4755bc9595).(int /*buttons*/, int /*column*/, int /*row*/, int /*eventType*/) |
| 233 | { |
| 234 | // default implementation does nothing |
| 235 | } |
| 236 | |
| 237 | /* |
| 238 | We are doing code conversion from locale to unicode first. |
| 239 | TODO: Character composition from the old code. See #96536 |
| 240 | */ |
| 241 | |
| 242 | void Emulationcxx . . $ Konsole/Emulation#::receiveDatacxx . . $ Konsole/Emulation#receiveData(34d26762b42c433a).(const char* text, int length) |
| 243 | { |
| 244 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! stateSetcxx . . $ Konsole/Emulation#stateSet(d4f767463ce0a6b3).(NOTIFYACTIVITYcxx . . $ Konsole/NOTIFYACTIVITY.); |
| 245 | |
| 246 | bufferedUpdatecxx . . $ Konsole/Emulation#bufferedUpdate(49f6e7a06ebc5aa8).(); |
| 247 | |
| 248 | /* XXX: the following code involves encoding & decoding of "UTF-16 |
| 249 | * surrogate pairs", which does not work with characters higher than |
| 250 | * U+10FFFF |
| 251 | * https://unicodebook.readthedocs.io/unicode_encodings.html#surrogates |
| 252 | */ |
| 253 | QStringcxx . . $ QString# utf16Text = _decodercxx . . $ Konsole/Emulation#_decoder.->toUnicodecxx . . $ QTextDecoder#toUnicode(5ac70cc0fa2a874e).(text,length); |
| 254 | stdcxx . . $ std/::wstringcxx . . $ std/wstring# unicodeText = utf16Text.toStdWStringcxx . . $ QString#toStdWString(d07e96ea086800fd).(); |
| 255 | |
| 256 | //send characters to terminal emulator |
| 257 | for (size_t i=0;i<unicodeText.lengthcxx . . $ std/__cxx11/basic_string#length(6f8bd5c0ea8fb29a).();i++) |
| 258 | receiveCharcxx . . $ Konsole/Emulation#receiveChar(d461ae26ddb24b42).(unicodeText[cxx . . $ std/__cxx11/basic_string#`operator[]`(7b73c3179b3cb3ad).i]); |
| 259 | |
| 260 | //look for z-modem indicator |
| 261 | //-- someone who understands more about z-modems that I do may be able to move |
| 262 | //this check into the above for loop? |
| 263 | for (int i=0;i<length;i++) |
| 264 | { |
| 265 | if (text[i] == '\030') |
| 266 | { |
| 267 | if ((length-i-1 > 3) && (strncmp(text+i+1, "B00", 3) == 0)) |
| 268 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! zmodemDetectedcxx . . $ Konsole/Emulation#zmodemDetected(49f6e7a06ebc5aa8).(); |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | //OLDER VERSION |
| 274 | //This version of onRcvBlock was commented out because |
| 275 | // a) It decoded incoming characters one-by-one, which is slow in the current version of Qt (4.2 tech preview) |
| 276 | // b) It messed up decoding of non-ASCII characters, with the result that (for example) chinese characters |
| 277 | // were not printed properly. |
| 278 | // |
| 279 | //There is something about stopping the _decoder if "we get a control code halfway a multi-byte sequence" (see below) |
| 280 | //which hasn't been ported into the newer function (above). Hopefully someone who understands this better |
| 281 | //can find an alternative way of handling the check. |
| 282 | |
| 283 | |
| 284 | /*void Emulation::onRcvBlock(const char *s, int len) |
| 285 | { |
| 286 | emit notifySessionState(NOTIFYACTIVITY); |
| 287 | |
| 288 | bufferedUpdate(); |
| 289 | for (int i = 0; i < len; i++) |
| 290 | { |
| 291 | |
| 292 | QString result = _decoder->toUnicode(&s[i],1); |
| 293 | int reslen = result.length(); |
| 294 | |
| 295 | // If we get a control code halfway a multi-byte sequence |
| 296 | // we flush the _decoder and continue with the control code. |
| 297 | if ((s[i] < 32) && (s[i] > 0)) |
| 298 | { |
| 299 | // Flush _decoder |
| 300 | while(!result.length()) |
| 301 | result = _decoder->toUnicode(&s[i],1); |
| 302 | reslen = 1; |
| 303 | result.resize(reslen); |
| 304 | result[0] = QChar(s[i]); |
| 305 | } |
| 306 | |
| 307 | for (int j = 0; j < reslen; j++) |
| 308 | { |
| 309 | if (result[j].characterategory() == QChar::Mark_NonSpacing) |
| 310 | _currentScreen->compose(result.mid(j,1)); |
| 311 | else |
| 312 | onRcvChar(result[j].unicode()); |
| 313 | } |
| 314 | if (s[i] == '\030') |
| 315 | { |
| 316 | if ((len-i-1 > 3) && (strncmp(s+i+1, "B00", 3) == 0)) |
| 317 | emit zmodemDetected(); |
| 318 | } |
| 319 | } |
| 320 | }*/ |
| 321 | |
| 322 | void Emulationcxx . . $ Konsole/Emulation#::writeToStreamcxx . . $ Konsole/Emulation#writeToStream(af4856893d912e4e).( TerminalCharacterDecodercxx . . $ Konsole/TerminalCharacterDecoder#* _decoder , |
| 323 | int startLine , |
| 324 | int endLine) |
| 325 | { |
| 326 | _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->writeLinesToStreamcxx . . $ Konsole/Screen#writeLinesToStream(7780994359c8fe18).(_decoder,startLine,endLine); |
| 327 | } |
| 328 | |
| 329 | void Emulationcxx . . $ Konsole/Emulation#::writeToStreamcxx . . $ Konsole/Emulation#writeToStream(fdbc605265f4e834).( TerminalCharacterDecodercxx . . $ Konsole/TerminalCharacterDecoder#* _decoder) |
| 330 | { |
| 331 | _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->writeLinesToStreamcxx . . $ Konsole/Screen#writeLinesToStream(7780994359c8fe18).(_decoder, 0, _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->getHistLinescxx . . $ Konsole/Screen#getHistLines(455f465bc33b4cdf).()); |
| 332 | } |
| 333 | |
| 334 | int Emulationcxx . . $ Konsole/Emulation#::lineCountcxx . . $ Konsole/Emulation#lineCount(455f465bc33b4cdf).() const |
| 335 | { |
| 336 | // sum number of lines currently on _screen plus number of lines in history |
| 337 | return _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->getLinescxx . . $ Konsole/Screen#getLines(455f465bc33b4cdf).() + _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->getHistLinescxx . . $ Konsole/Screen#getHistLines(455f465bc33b4cdf).(); |
| 338 | } |
| 339 | |
| 340 | #define BULK_TIMEOUT1cxx . . $ `lib/Emulation.cpp:340:9`! 10 |
| 341 | #define BULK_TIMEOUT2cxx . . $ `lib/Emulation.cpp:341:9`! 40 |
| 342 | |
| 343 | void Emulationcxx . . $ Konsole/Emulation#::showBulkcxx . . $ Konsole/Emulation#showBulk(49f6e7a06ebc5aa8).() |
| 344 | { |
| 345 | _bulkTimer1cxx . . $ Konsole/Emulation#_bulkTimer1..stopcxx . . $ QTimer#stop(49f6e7a06ebc5aa8).(); |
| 346 | _bulkTimer2cxx . . $ Konsole/Emulation#_bulkTimer2..stopcxx . . $ QTimer#stop(49f6e7a06ebc5aa8).(); |
| 347 | |
| 348 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! outputChangedcxx . . $ Konsole/Emulation#outputChanged(49f6e7a06ebc5aa8).(); |
| 349 | |
| 350 | _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->resetScrolledLinescxx . . $ Konsole/Screen#resetScrolledLines(49f6e7a06ebc5aa8).(); |
| 351 | _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->resetDroppedLinescxx . . $ Konsole/Screen#resetDroppedLines(49f6e7a06ebc5aa8).(); |
| 352 | } |
| 353 | |
| 354 | void Emulationcxx . . $ Konsole/Emulation#::bufferedUpdatecxx . . $ Konsole/Emulation#bufferedUpdate(49f6e7a06ebc5aa8).() |
| 355 | { |
| 356 | _bulkTimer1cxx . . $ Konsole/Emulation#_bulkTimer1..setSingleShotcxx . . $ QTimer#setSingleShot(b45ddcbc8423892c).(true); |
| 357 | _bulkTimer1cxx . . $ Konsole/Emulation#_bulkTimer1..startcxx . . $ QTimer#start(d4f767463ce0a6b3).(BULK_TIMEOUT1cxx . . $ `lib/Emulation.cpp:340:9`!); |
| 358 | if (!_bulkTimer2cxx . . $ Konsole/Emulation#_bulkTimer2..isActivecxx . . $ QTimer#isActive(50ce9a9e25b4a850).()) |
| 359 | { |
| 360 | _bulkTimer2cxx . . $ Konsole/Emulation#_bulkTimer2..setSingleShotcxx . . $ QTimer#setSingleShot(b45ddcbc8423892c).(true); |
| 361 | _bulkTimer2cxx . . $ Konsole/Emulation#_bulkTimer2..startcxx . . $ QTimer#start(d4f767463ce0a6b3).(BULK_TIMEOUT2cxx . . $ `lib/Emulation.cpp:341:9`!); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | char Emulationcxx . . $ Konsole/Emulation#::eraseCharcxx . . $ Konsole/Emulation#eraseChar(1b8b762cbef9c2c9).() const |
| 366 | { |
| 367 | return '\b'; |
| 368 | } |
| 369 | |
| 370 | void Emulationcxx . . $ Konsole/Emulation#::setImageSizecxx . . $ Konsole/Emulation#setImageSize(3e454b8ccf442868).(int lines, int columns) |
| 371 | { |
| 372 | if ((lines < 1) || (columns < 1)) |
| 373 | return; |
| 374 | |
| 375 | QSizecxx . . $ QSize# screenSize[2] = { QSizecxx . . $ QSize#QSize(c0d38f4800714fae).(_screencxx . . $ Konsole/Emulation#_screen.[0]->getColumnscxx . . $ Konsole/Screen#getColumns(455f465bc33b4cdf).(), |
| 376 | _screencxx . . $ Konsole/Emulation#_screen.[0]->getLinescxx . . $ Konsole/Screen#getLines(455f465bc33b4cdf).()), |
| 377 | QSizecxx . . $ QSize#QSize(c0d38f4800714fae).(_screencxx . . $ Konsole/Emulation#_screen.[1]->getColumnscxx . . $ Konsole/Screen#getColumns(455f465bc33b4cdf).(), |
| 378 | _screencxx . . $ Konsole/Emulation#_screen.[1]->getLinescxx . . $ Konsole/Screen#getLines(455f465bc33b4cdf).()) }; |
| 379 | QSizecxx . . $ QSize# newSizecxx . . $ QSize#QSize(c0d38f4800714fae).(columns,lines); |
| 380 | |
| 381 | if (newSize ==cxx . . $ `operator==`(1de60fa97ecbf80a). screenSize[0] && newSize ==cxx . . $ `operator==`(1de60fa97ecbf80a). screenSize[1]) |
| 382 | return; |
| 383 | |
| 384 | _screencxx . . $ Konsole/Emulation#_screen.[0]->resizeImagecxx . . $ Konsole/Screen#resizeImage(3e454b8ccf442868).(lines,columns); |
| 385 | _screencxx . . $ Konsole/Emulation#_screen.[1]->resizeImagecxx . . $ Konsole/Screen#resizeImage(3e454b8ccf442868).(lines,columns); |
| 386 | |
| 387 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! imageSizeChangedcxx . . $ Konsole/Emulation#imageSizeChanged(3e454b8ccf442868).(lines,columns); |
| 388 | |
| 389 | bufferedUpdatecxx . . $ Konsole/Emulation#bufferedUpdate(49f6e7a06ebc5aa8).(); |
| 390 | } |
| 391 | |
| 392 | QSizecxx . . $ QSize# Emulationcxx . . $ Konsole/Emulation#::imageSizecxx . . $ Konsole/Emulation#imageSize(4b3b776e5ee2b367).() const |
| 393 | { |
| 394 | return {cxx . . $ QSize#QSize(c0d38f4800714fae)._currentScreencxx . . $ Konsole/Emulation#_currentScreen.->getColumnscxx . . $ Konsole/Screen#getColumns(455f465bc33b4cdf).(), _currentScreencxx . . $ Konsole/Emulation#_currentScreen.->getLinescxx . . $ Konsole/Screen#getLines(455f465bc33b4cdf).()}; |
| 395 | } |
| 396 | |
| 397 | ushortcxx . . $ ushort# ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable#::extendedCharHashcxx . . $ Konsole/ExtendedCharTable#extendedCharHash(5bb79e050fa8f5ae).(ushortcxx . . $ ushort#* unicodePoints , ushortcxx . . $ ushort# length) const |
| 398 | { |
| 399 | ushortcxx . . $ ushort# hash = 0; |
| 400 | for ( ushortcxx . . $ ushort# i = 0 ; i < length ; i++ ) |
| 401 | { |
| 402 | hash = 31*hash + unicodePoints[i]; |
| 403 | } |
| 404 | return hash; |
| 405 | } |
| 406 | bool ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable#::extendedCharMatchcxx . . $ Konsole/ExtendedCharTable#extendedCharMatch(ef6734a0bf559b46).(ushortcxx . . $ ushort# hash , ushortcxx . . $ ushort#* unicodePoints , ushortcxx . . $ ushort# length) const |
| 407 | { |
| 408 | ushortcxx . . $ ushort#* entry = extendedCharTablecxx . . $ Konsole/ExtendedCharTable#extendedCharTable.[cxx . . $ QHash#`operator[]`(bfda1f1f965926d4).hash]; |
| 409 | |
| 410 | // compare given length with stored sequence length ( given as the first ushort in the |
| 411 | // stored buffer ) |
| 412 | if ( entry == nullptr || entry[0] != length ) |
| 413 | return false; |
| 414 | // if the lengths match, each character must be checked. the stored buffer starts at |
| 415 | // entry[1] |
| 416 | for ( int i = 0 ; i < length ; i++ ) |
| 417 | { |
| 418 | if ( entry[i+1] != unicodePoints[i] ) |
| 419 | return false; |
| 420 | } |
| 421 | return true; |
| 422 | } |
| 423 | ushortcxx . . $ ushort# ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable#::createExtendedCharcxx . . $ Konsole/ExtendedCharTable#createExtendedChar(5d258c7a68607401).(ushortcxx . . $ ushort#* unicodePoints , ushortcxx . . $ ushort# length) |
| 424 | { |
| 425 | // look for this sequence of points in the table |
| 426 | ushortcxx . . $ ushort# hash = extendedCharHashcxx . . $ Konsole/ExtendedCharTable#extendedCharHash(5bb79e050fa8f5ae).(unicodePoints,length); |
| 427 | |
| 428 | // check existing entry for match |
| 429 | while ( extendedCharTablecxx . . $ Konsole/ExtendedCharTable#extendedCharTable..containscxx . . $ QHash#contains(8877ebe272b9620d).(hash) ) |
| 430 | { |
| 431 | if ( extendedCharMatchcxx . . $ Konsole/ExtendedCharTable#extendedCharMatch(ef6734a0bf559b46).(hash,unicodePoints,length) ) |
| 432 | { |
| 433 | // this sequence already has an entry in the table, |
| 434 | // return its hash |
| 435 | return hash; |
| 436 | } |
| 437 | else |
| 438 | { |
| 439 | // if hash is already used by another, different sequence of unicode character |
| 440 | // points then try next hash |
| 441 | hash++; |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | |
| 446 | // add the new sequence to the table and |
| 447 | // return that index |
| 448 | ushortcxx . . $ ushort#* buffer = new ushortcxx . . $ ushort#[length+1]; |
| 449 | buffer[0] = length; |
| 450 | for ( int i = 0 ; i < length ; i++ ) |
| 451 | buffer[i+1] = unicodePoints[i]; |
| 452 | |
| 453 | extendedCharTablecxx . . $ Konsole/ExtendedCharTable#extendedCharTable..insertcxx . . $ QHash#insert(d77b19c31d2eb147).(hash,buffer); |
| 454 | |
| 455 | return hash; |
| 456 | } |
| 457 | |
| 458 | ushortcxx . . $ ushort#* ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable#::lookupExtendedCharcxx . . $ Konsole/ExtendedCharTable#lookupExtendedChar(9d4345af5ccf9989).(ushortcxx . . $ ushort# hash , ushortcxx . . $ ushort#& length) const |
| 459 | { |
| 460 | // lookup index in table and if found, set the length |
| 461 | // argument and return a pointer to the character sequence |
| 462 | |
| 463 | ushortcxx . . $ ushort#* buffer = extendedCharTablecxx . . $ Konsole/ExtendedCharTable#extendedCharTable.[cxx . . $ QHash#`operator[]`(bfda1f1f965926d4).hash]; |
| 464 | if ( buffer ) |
| 465 | { |
| 466 | length = buffer[0]; |
| 467 | return buffer+1; |
| 468 | } |
| 469 | else |
| 470 | { |
| 471 | length = 0; |
| 472 | return nullptr; |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable#::ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable#ExtendedCharTable(49f6e7a06ebc5aa8).() |
| 477 | { |
| 478 | } |
| 479 | ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable#::~cxx . . $ Konsole/ExtendedCharTable#`~ExtendedCharTable`(ced63f7c635d850d).ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable#() |
| 480 | { |
| 481 | // free all allocated character buffers |
| 482 | QHashIteratorcxx . . $ QHashIterator#<ushortcxx . . $ ushort#,ushortcxx . . $ ushort#*> itercxx . . $ QHashIterator#QHashIterator(b49801d1bb7ffe09).(extendedCharTablecxx . . $ Konsole/ExtendedCharTable#extendedCharTable.); |
| 483 | while ( iter.hasNextcxx . . $ QHashIterator#hasNext(50ce9a9e25b4a850).() ) |
| 484 | { |
| 485 | iter.nextcxx . . $ QHashIterator#next(502dc262f89e6c2c).(); |
| 486 | delete[] iter.valuecxx . . $ QHashIterator#value(bdbd05d619d62250).(); |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | // global instance |
| 491 | ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable# ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable#::instancecxx . . $ Konsole/ExtendedCharTable#instance.; |
| 492 | |
| 493 | |
| 494 | //#include "Emulation.moc" |
| 495 |