diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8351056
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+CMakeLists.txt.user*
+out
+build
+build2
+.vscode
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..2c43366
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.16)
+project(Browser)
+
+
+set_property(GLOBAL PROPERTY CMAKE_CXX_STANDARD 17)
+set_property(GLOBAL PROPERTY CMAKE_CXX_STANDARD_REQUIRED ON)
+
+add_subdirectory(qtermwidget)
+add_subdirectory(digitalclock)
+add_subdirectory(src)
diff --git a/CMakePresets.json b/CMakePresets.json
new file mode 100644
index 0000000..f5371d5
--- /dev/null
+++ b/CMakePresets.json
@@ -0,0 +1,17 @@
+{
+ "version": 2,
+ "configurePresets": [
+ {
+ "name": "Default",
+ "displayName": "Configure preset using toolchain file",
+ "description": "Sets Ninja generator, build and install directory",
+ "generator": "Ninja",
+ "binaryDir": "${sourceDir}/out/build/${presetName}",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Debug",
+ "CMAKE_TOOLCHAIN_FILE": "",
+ "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4f67d5b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,55 @@
+# OG Browser
+
+El OpenGnsys Browser es un navegador limitado de tipo quiosco, basado en Qt6/Chrome.
+
+## Compilacion
+
+El sistema esta basado en CMake. Para compilar:
+
+
+ git clone https://ognproject.evlt.uma.es/gitea/unizar/ogbrowser.git
+ cd ogbrowser
+ mkdir build
+ cd build
+ cmake ..
+ make -j8 # 8 cores -- cambiar según hardware
+
+
+## Uso
+
+ src/OGBrowser URL
+
+Por ejemplo:
+
+ src/OGBrowser http://example.com
+
+
+## URLs especiales:
+
+El navegador reconoce URLs especiales dentro de los documentos, que pueden usarse
+para ejecutar comandos locales.
+
+* command - Ejecuta un comando
+* command+output - Ejecuta un comando y muestra la salida
+* command+confirm - Pregunta antes de ejecutar un comando
+* command+confirm+output - Pregunta antes de ejecutar un comando y muestra la salida
+* command+output+confirm - Idéntico al anterior
+
+
+Ejemplo:
+
+ Ejecutar
+
+Esto crea un enlace que al hacerse click, ejecuta el comando ping y muestra el resultado en una ventana.
+
+
+## Proxy
+
+Usa el proxy del sistema, incluyendo las variables de entorno: HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY
+
+## Modo administrativo
+
+El administrador dispone de una consola y mas información sobre la ejecución de comandos.
+
+Se activa estableciendo la variable de entorno `ogactiveadmin=true`
+
diff --git a/browser.pro b/browser.pro
deleted file mode 100644
index 01978c7..0000000
--- a/browser.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = qtermwidget digitalclock src
-
-OPTIONS += ordered
-CONFIG += qt warn_on release
diff --git a/digitalclock/CMakeLists.txt b/digitalclock/CMakeLists.txt
new file mode 100644
index 0000000..58bd30c
--- /dev/null
+++ b/digitalclock/CMakeLists.txt
@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 3.16)
+
+project(DigitalClock LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+
+find_package(QT NAMES Qt6 dirCOMPONENTS Widgets LinguistTools Network REQUIRED)
+find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets LinguistTools Network REQUIRED)
+
+message(STATUS "Building DigitalClock with Qt ${QT_VERSION}")
+
+
+set(SOURCES
+ digitalclock.cpp
+ )
+
+
+add_library(DigitalClock ${SOURCES} )
+
+set_property(TARGET DigitalClock PROPERTY CXX_STANDARD 17)
+set_property(TARGET DigitalClock PROPERTY CXX_STANDARD_REQUIRED ON)
+
+target_link_libraries(DigitalClock PRIVATE Qt${QT_VERSION_MAJOR}::Widgets )
+
+
+
+# We export this information so that other projects can use it
+set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR} CACHE INTERNAL "${PROJECT_NAME}: Include directories" FORCE)
+set(${PROJECT_NAME}_LIB_DIRS ${PROJECT_BINARY_DIR} CACHE INTERNAL "${PROJECT_NAME}: Library directories" FORCE)
diff --git a/digitalclock/digitalclock.cpp b/digitalclock/digitalclock.cpp
index 4b65b6b..2b130ec 100644
--- a/digitalclock/digitalclock.cpp
+++ b/digitalclock/digitalclock.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -38,10 +48,11 @@
**
****************************************************************************/
-#include
-
#include "digitalclock.h"
+#include
+#include
+
//! [0]
DigitalClock::DigitalClock(QWidget *parent)
: QLCDNumber(parent)
@@ -49,7 +60,7 @@ DigitalClock::DigitalClock(QWidget *parent)
setSegmentStyle(Filled);
QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(showTime()));
+ connect(timer, &QTimer::timeout, this, &DigitalClock::showTime);
timer->start(1000);
showTime();
diff --git a/digitalclock/digitalclock.h b/digitalclock/digitalclock.h
index f891335..31c12f3 100644
--- a/digitalclock/digitalclock.h
+++ b/digitalclock/digitalclock.h
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -49,7 +59,7 @@ class DigitalClock : public QLCDNumber
Q_OBJECT
public:
- DigitalClock(QWidget *parent = 0);
+ DigitalClock(QWidget *parent = nullptr);
private slots:
void showTime();
diff --git a/digitalclock/digitalclock.pro b/digitalclock/digitalclock.pro
index 6d2d283..4e4bc0f 100644
--- a/digitalclock/digitalclock.pro
+++ b/digitalclock/digitalclock.pro
@@ -1,23 +1,9 @@
-TEMPLATE = lib
-DESTDIR = ..
-
-TARGET = digitalclock
-
-CONFIG += qt release warn_on build_all staticlib
-
-QT += core gui
-
-MOC_DIR = ../.moc
-
-OBJECTS_DIR = ../.objs
-TARGET = digitalclock
-
-DEFINES += HAVE_POSIX_OPENPT
-#or DEFINES += HAVE_GETPT
-
-HEADERS = digitalclock.h
-
-SOURCES = digitalclock.cpp
-
+QT += widgets
+HEADERS = digitalclock.h
+SOURCES = digitalclock.cpp \
+ main.cpp
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/digitalclock
+INSTALLS += target
diff --git a/digitalclock/main.cpp b/digitalclock/main.cpp
new file mode 100644
index 0000000..9440a81
--- /dev/null
+++ b/digitalclock/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include
+
+#include "digitalclock.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ DigitalClock clock;
+ clock.show();
+ return app.exec();
+}
diff --git a/qndtest b/qndtest
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/qndtest
@@ -0,0 +1 @@
+test
diff --git a/qtermwidget/.translation-update b/qtermwidget/.translation-update
new file mode 100644
index 0000000..8b818c9
--- /dev/null
+++ b/qtermwidget/.translation-update
@@ -0,0 +1 @@
+translations='./lib'
diff --git a/qtermwidget/AUTHORS b/qtermwidget/AUTHORS
index bfa5fa3..0540a6a 100644
--- a/qtermwidget/AUTHORS
+++ b/qtermwidget/AUTHORS
@@ -1 +1,15 @@
-e_k@users.sourceforge.net
\ No newline at end of file
+Originally forked from Konsole by
+
+Revived by Petr Vanek
+
+Contributors:
+
+Adam Treat
+Chris Mueller
+Christian Surlykke
+Daniel O'Neill
+Francisco Ballina
+Georg Rudoy <0xd34df00d@gmail.com>
+Jerome Leclanche
+Petr Vanek
+@kulti
diff --git a/qtermwidget/CHANGELOG b/qtermwidget/CHANGELOG
new file mode 100644
index 0000000..bacffc0
--- /dev/null
+++ b/qtermwidget/CHANGELOG
@@ -0,0 +1,427 @@
+qtermwidget-1.4.0 / unreleased
+===============================
+ * TERM env variable set to xterm-256color when not set with QTermWidget::setEnvironment().
+
+qtermwidget-1.3.0 / 2023-04-15
+===============================
+ * Fixed a problem in switching the color scheme between dark and light.
+ * Prevented a crash on splitting the terminal under `kwin_wayland`
+
+qtermwidget-1.2.0 / 2022-11-05
+===============================
+ * Enabled Bidi rendering by default.
+ * Made text DND follow the settings for newline trimming and multiline prompt.
+ * Allow `QTermWidget` to be used as a Qt Plugin.
+
+qtermwidget-1.1.0 / 2022-04-15
+===============================
+ * Handled the zero history size.
+ * Removed an unused variable.
+ * Corrected some code indentations.
+ * Added API documentation and followed naming convention.
+ * Return focus to terminal on closing search bar.
+ * Moved to SIP 5.x wth PyQt.
+ * Added contexts to some lambda connections.
+
+qtermwidget-1.0.0 / 2021-11-04
+===============================
+ * Bumped minimum required Qt version to 5.15.
+ * Fixed crash under (Plasma) Wayland on opening tab and splitting.
+ * Use "empty()" to check for container emptiness.
+ * Made some member functions const.
+ * Quote drag-and-drop file names.
+ * Backported CNL and CPL support from Konsole.
+ * Use QRandomGenerator instead of qrand().
+ * Silenced some compilation warnings.
+ * Basic EditorConfig definition.
+
+qtermwidget-0.17.0 / 2021-04-15
+===============================
+ * Drop support for KDE3 color scheme formats.
+ * Some code cleanup and modernization.
+ * Added a method to disable bracketed paste mode.
+ * Added an example for PyQt5.
+ * Improve "Undecodable sequence" warnings.
+ * Properly implement the "Action after paste" feature.
+ * Fix execution after paste when Ctrl is hold.
+ * Workaround an issue with glibc 2.33 on old Docker engines.
+ * Added modes for background image. How background images are drawn is changed and manual reconfiguration is needed. See docs/configuration.md for more details.
+
+qtermwidget-0.16.1 / 2020-11-14
+===============================
+ * Bumped version to 0.16.1, for a point release of qterminal.
+
+qtermwidget-0.16.0 / 2020-11-01
+===============================
+
+ * Use qAsConst.
+ * Don't search application dir for keyboard and scheme data.
+ * Use Q_EMIT to call signals, instead of the emit keyword.
+ * Dropped the deprecated class QLinkedList.
+ * Don't use 0/nullptr to initialize QFlags.
+ * Fixed ColorEntry copy operator.
+ * Disabled the use of copy constructors and assignment operators.
+ * Check for successful ioctl() calls by testing that the call did not return -1.
+ * Fix find_package() developer warning in cmake.
+ * Use const references wherever possible.
+ * Handle keyboard commands properly.
+
+qtermwidget-0.15.0 / 2020-04-24
+===============================
+
+ * Bumped version to 0.15.0.
+ * Replaced Q_WS_MAC with Q_OS_MACOS for Qt5 compatibility.
+ * KPty: Don't conditionalize chownpty existence on HAVE_OPENPTY.
+ * cmake: set CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON for macOS.
+ * Fixed the default font on macOS.
+ * pyqt: Fixes deprecation warning (CMP0002).
+ * Fixed the PyQt5 binding with Qt ≥ 5.11.
+ * Swap Qt's ControlModifier and MetaModifier on macOS.
+ * C++11 code updates.
+ * Use braced initializer list in returns.
+ * Fixed the memory access violation in TerminalDisplay's method `getCharacterPosition`.
+ * Completed the support for transient scrollbars.
+ * Added `saveHistory` to QTermWidget.
+ * Use vanilla Qt instead of patched one.
+ * Don't set the selection clipboard if it's unsupported.
+ * Announce truecolor support via COLORTERM.
+ * Fixed numpad handling and added entries for numpad 5.
+ * Allow to disable drawing line chars.
+ * Use QRectF for cursor drawing and fix artifacts in hidpi.
+ * Fixed compilation on NetBSD.
+ * Added sendKeyEvent() API.
+ * Fixed flickering on font change.
+ * Select all text when opening search bar.
+ * Removed some debug outputs.
+ * Removed (duplicated) string casts definitions.
+ * Removed obsolete qCopy.
+ * Fix SearchBar light text over white background with dark themes.
+ * pyqt: also check for sip 5.x path.
+ * Prevented a c++11 range-loop might detach Qt container.
+ * Dropped the deprecated QString method `sprintf()`.
+ * Avoid buffer overflows exploits.
+ * Fixed build with LLVM/clang.
+ * Explicitly mark exported classes.
+ * Fixed QCharRef's deprecated behavior.
+ * Correctly initialize sigsets.
+
+qtermwidget-0.14.1 / 2019-02-25
+===============================
+
+ * Bumped version to 0.14.1
+ * Only translations was changed.
+
+qtermwidget-0.14.0 / 2019-01-25
+===============================
+
+ * Bumped version to 0.14.0
+ The big bump was needed to prevent conflicts with translations
+ that were former built out of lxqt-l10n and have version 0.13.0
+ * Clarify the licenses used in qtermwidget and added the missed root licenses
+ * Implementation fixes:
+ - kpty: use openpty() on mac
+ - kpty: make it work on OpenBSD
+ - kptyprocess: ensure .bash_history is correctly written out
+ - kb-layouts: Make Backspace behaves the same as xterm
+ - tools: Drop the ability to bundle kb-layouts and colorschemes
+ - SearchBar: Fix visual glitches in search-bar
+ - TerminalDisplay: Fixed link mouseover after recent changes
+ - TerminalDisplay: Redraw cursor after cursor type changed
+ - Vt102Emulation: Fix handling of ST (String Terminator) for OSC (Operating System Commands)
+ - qterminal: Correct deleting of HotSpot list items
+ - qterminal: Removed unnecessary checks
+ - ColorScheme: Fixed local variable will be copied despite being returned by name
+ - ColorScheme: Fixed error return-std-move
+ - Removed unnecessary checks
+ - Suppressed compilation warnings
+ - Don't use automatic string conversions
+ - Marked some functions const
+ - Implemented terminal margins
+ * Improved cmake scripting
+ - Set cmake_minimum_required to 3.1.0
+ - Removed locale compile definitions
+ - Removed QUIET from find_package
+ * Moved translations from lxqt-l10n back to qtermwidget
+ - Removed obsolete translation functionality
+ - Added translation promo in README.md
+ * Translation updates
+
+qtermwidget-0.9.0 / 2018-05-21
+==============================
+
+ * Bumped minor version to 9
+ * Take transient scrollbars into account
+ * CMake: Prevent in-source builds
+ * Refactor and fixes Python binding
+ * kptyprocess: Try to terminate the shell process
+ * New color scheme: Ubuntu inspired
+ * Fixed some github paths in uris
+ * Add a comment for potential future breakage
+ * Use wstring in TerminalCharacterDecoder for UCS-4 compatibility
+ * Support UTF-32 characters correctly
+ * Fix "bold and intensive" colors
+ * New color scheme: Tango (#167)
+ * Finish SGR mouse protocol (1006)
+ * Fix build of example with latest lxqt-build-tools
+ * Expose bracket text function
+ * Drop Qt foreach.
+ * Revert deletions in .sip file
+ * fix python bindings
+ * Expose terminal size hint API
+ * Remove class name
+ * Return something
+ * Expose bidi option
+ * Add an example for remote terminal
+ * Makes the use of libutempter optional
+ * Fix behavior of scroll up (SU)
+ * Install cmake files in LIBDIR as they are architecture dependent
+ * Check if utempter.h header exists (mainly for FreeBSD)
+ * Need lxqt-build-tools 0.4.0
+
+qtermwidget-0.8.0 / 2017-10-21
+==================
+
+ * Release 0.8.0: Update changelog
+ * FIX: #46 fix vertical font truncation
+ * bump versions
+ * Really fallback to /bin/sh when $SHELL is missing or invalid
+ * README: don't recommend building from source
+ * Improve README
+ * Don't export github templates
+ * Support REP escape sequence defined in ECMA-48, section 8.3.103
+ * Fix build issue related to utmpx in Mac OSX Sierra
+ * Remove the deprecation notice
+ * Handle DECSCUSR signals
+ * Copied issue template
+ * Update building instructions
+ * Require Qt 5.6+
+ * This commit allows the consumer of qtermwidget to capture the (#111)
+ * Allow the terminal display to be smaller than the size hint (#123)
+ * Backport Vt102 emulation fixes (#113)
+ * Backport the default.keytab from Konsole
+ * Fixes (#122)
+ * Updated README, Added support for PyQT 5.7
+ * Fix memory leak in hotspot (URLs & emails) detection
+ * Adds superbuild support
+ * Use target_compile_definitions() instead of add_definitions()
+ * Update find_package() documentation
+ * Use the lxqt_create_pkgconfig_file
+ * Improve lxqt_translate_ts() use
+ * Adds COMPONENT to the install files
+ * Renames test app to example. Make it work
+ * Drop include_directories() for in tree dirs
+ * Use the CMake Targets way
+ * Pack Utf8Proc stuff
+ * Adds export header
+ * Use LXQtCompilerSettings
+ * Packs compile definitions
+ * Adds package version file
+ * Removes Qt4 stuff
+ * Add translation mechanism
+ * Use const iterators when possible.
+ * Enable strict iterators for debug builds
+ * TerminalDisplay: Make resizing "Size" translatable
+ * Exposes receivedData signal to users of QTermWidget
+ * Exposes sessions autoClose property to QTermWidget
+
+qtermwidget-0.7.1 / 2016-12-21
+==================
+
+ * Release 0.7.1: Update changelog
+ * Bump patch version (#105)
+ * Added a modified Breeze color scheme (#104)
+ * Accept hex color strings as well (#101)
+ * Remove the stale lib/README (#102)
+ * Implement background images (#95)
+ * Implement other BOX DRAWING characters (#98)
+ * Preparations for context menu actions on URLs (#97)
+ * Drop the ancient wcwidth impl. and use utf8proc if possible (#99)
+ * Remove widget size checks in setVTFont() (#86)
+ * Delete unused tooltip code (#81)
+ * Fix size of the array passed to memset() (#79)
+ * Remove cpack (#93)
+
+qtermwidget-0.7.0 / 2016-09-24
+==================
+
+ * Release 0.7.0: Add changelog
+ * Bump version to 0.7.0 (#92)
+ * Add Solarized Color Schemes
+ * Update README.md
+ * qtermwidget: Unify title & icon propagation
+ * lib: Fix FTBFS (struct vs. class mismatch)
+ * Add 'const' decorators
+ * Expose titleChanged() signal
+ * Fix building instructions
+ * cmake support changes
+ * Make addCustomColorSchemeDir() static and check for duplicates
+ * Address review comments
+ * Allow app to add custom color scheme locations
+ * Avoid enums duplication
+ * Add support for setting keyboard cursor shape
+ * Remove assignment to self
+ * Backport konsole changes to fix memory leaks
+ * Remove __FILE__ macros
+ * Replace assert() with Q_ASSERT()
+ * Fix ASan error about delete size mismatch
+ * Add support for GNU/Hurd to kpty.cpp.
+ * fixes kfreebsd builds on debian and derivatives
+ * Fix indenations (misleading-indentation warning)
+ * Remove Q_DECL_OVERRIDE macros
+ * typo Higlight
+ * Remove noisy qDebugs
+ * Bracketed paste mode implementation
+ * Use function setWorldTranfer for Qpainter instead of setWorldMatrix
+ * Modify treatment drawing double width character
+ * pyqt5 bindings
+ * pyqt5 bindings
+ * Avoid checking uninitialized member + simplify condition
+ * Use markdown for README and improve it a bit
+ * Remove support for Qt <= 5.4
+ * Remove Designer plugin
+ * Fix LICENSE text and name
+ * Remove Changelog
+ * Remove empty TODO file
+ * Remove PyQt4 bindings
+ * Sort out terminal resizing
+ * Rebase Vt102Emulation to Konsole
+ * Enable terminal resizing from the emulator
+ * Clean up trailing whitespaces
+ * implemented start TTY for external recipient;
+ * Fix: typo in TerminalDisplay
+ * add method for get pty slave fd;
+ * add method for get pty slave fd;
+ * Use GNUInstallDirs in CMakeLists.txt to stop hardcoding paths
+ * Set the '_notifiedActivity' flag early
+ * Also expose signals and slots to pyqt
+ * Get/set selection end in python bindings
+ * Avoid calling winId() on Qt5.
+ * Fix TerminalDisplay::getCharacterPosition for proportional fonts
+ * Handle proportional fonts a bit better
+ * Expose more functionality through the python bindings (#23)
+ * Allow stopping test.py with ctrl-C
+ * Fix 'getSelectionEnd'
+ * Make whitespace consistent (tabs->spaces)
+ * Fix python binding compile errors #23
+ * Add event to notify the application that the shell application uses mouse.
+ * Change mouseMarks only when needed. This might be useful if an application wants to be notified of the event.
+ * Prevents deleting the last line when resizing.
+
+qtermwidget-0.6.0 / 2014-10-21
+==================
+
+ * Release 0.6.0
+ * Update AUTHORS
+ * Update INSTALL instructions
+ * CMakeLists.txt cleanup
+ * osx: link fixes
+ * fixed #57 Linux emulation does not seem to support Ctrl+Arrows (warning: I have no clue what I did...)
+ * Fix Qt4 compilation
+ * qterminal #64 No drag & drop support
+ * fixed qterminal #71 qt5 version ignoring page up / down
+ * Fixed a typo in CMakeLists.txt.
+
+qtermwidget-0.5.1 / 2014-07-14
+==================
+
+ * fixed 'make dist'; version bump
+ * Url activation & filters #21
+ * Proxy activity/silence methods to Session in QTermWidget.
+ * Emit activity() and silence() signals instead of KNotification.
+ * Support bells.
+ * Support bells.
+ * Added QTermWidget::urlActivated(QUrl) signal.
+ * Emit UrlFilter::activated() instead of QDesktopServices::openUrl().
+ * Derive Filter from QObject.
+ * Add UrlFilter.
+ * Activate link filters on ctrl+click.
+ * Update filters on resize and screen events.
+ * Const-correctness for QTermWidget API.
+ * Load arbitrary schemes by path via setColorScheme().
+ * ColorSchemeManager::loadCustomColorScheme(const QString& path).
+ * Unified schemeName() usage.
+ * fixed #17 lib/ShellCommand.cpp:66: possible =/== mixup
+ * Delete CMakeLists.txt.user
+ * new API selectedText()
+ * new API methods (thanks to William Brumley)
+ * fixed #11 compile against Qt 5 (Qt4 and Qt5 supported and waguely tested)
+ * build simplified: qtermwidget is versioned (libqtermwidget4 for Qt4, 5 for Qt5...). Better cmake support.
+ * fixed broken API for sendText() - const missing
+ * mail address change
+ * Current Working Directory for linux. Part of #8. More implementations welcomed...
+ * Add a method for get working directory in class QTermWidget
+ * Fix missing cleanup for temporary history files
+ * a potential improvement for #9 font fractional pixels causes spacing errors
+ * fix #2 update various documentations for debian packaging
+ * fix #10 Update FSF address
+
+qtermwidget-0.4.0 / 2013-04-16
+==================
+
+ * readme updated
+ * Added pasteSelection-slot and corrected two nonsense comments
+ * qt/embedded doesn't ship with a Monospace font (and it won't use system fonts even if they exist). Using 'fixed' instead works fine
+ * Without this, the terminal display area will permanently lose focus when consoleq's Find dialog is called up.
+ * This is only needed when using Qt/E built for DirectFB display. DirectFB blocks SIGINT and some other signals, so any terminal app (be it Qt or otherwise) must call sigprocmask() to unblock them. Without this, ^C doesn't work.
+ * The control and tab keys don't work in Qt/E. This fixes it, but maybe not in the most elegant way. The trouble seems to be that _codec->fromUnicode(event->text()) doesn't handle control characters in qt-embedded.
+ * Fix resize label
+ * Search code cleanup
+ * Change searchbar background color to red(ish) when no match found
+ * Fix search, find-next when selection is one character long
+ * Hotkeys for search: Return->find-next, Shift-Return->find-previous, Escape->hide searchbar
+ * Added search functionality
+ * Add zoom. Add choice action after paste clipboard
+ * Add zoom. Add choice action after paste clipboard
+ * Add zoom. Add choice action after paste clipboard
+ * Add zoom. Add choice action after paste clipboard
+ * Add zoom. Add choice action after paste clipboard
+ * Add zoom. Add choice action after paste clipboard
+ * Add zoom. Add choice action after paste clipboard
+ * Add zoom. Add choice action after paste clipboard
+ * Add zoom. Add choice action after paste clipboard
+ * Fix logical error
+ * Add zoom. Add choice action after paste clipboard
+ * Add zoom. Add choice action after paste clipboard
+ * Add Shift+KeyEnd and Shift+KeyHome to go line 0 and line end. No move screenwindow when copy and paste with keyboard
+ * fix for text drawing in qt>=4.8,x
+ * constructor for Qt Designer
+ * test commit
+ * clear() slot implemented
+ * fix the scroll at the end again
+ * The escape key is always needed for terminal programs like vim.
+ * Add resource files and the appropriate paths to enable bundling of color schemes and keyboard layouts into the actual executable.
+ * Add a define which will be used to bundle the color schemes and keyboard layouts as resource files with the executable itself instead of putting them on disk.
+ * scrollToEnd() method provided to trigger 'snapping' the terminal to cursor tracked position (typically the extreme value of the scrollbar, or the 'end') Some signal-fu particular to keyPressEvent(QKeyEvent *) done to make the above usable, no existing dependent implementations should be disturbed by this.
+ * revert workaround for key on end
+ * scroll to bottom on input
+ * scrollToEnd() method provided to trigger 'snapping' the terminal to cursor tracked position (typically the extreme value of the scrollbar, or the 'end') Some signal-fu particular to keyPressEvent(QKeyEvent *) done to make the above usable, no existing dependent implementations should be disturbed by this.
+ * improved sample app for testing
+ * macosx compile fix
+ * arguments work correctly for custom shells too
+ * lib has to be built first in any case
+ * merge changes from the experimental "bundle" repository
+ * fix for kb-layout location on mac (mainly)
+ * rpm builds
+ * mac universal build helper
+ * build cleanup; make dist; various readmes updated
+ * make availableKeyBindings static
+ * transparency support
+ * font display fix on mac (widths in int)
+ * qt designer plugin
+ * correct lib ID for mac
+ * remove the KDE legacy code
+ * code reformatted after resync
+ * display stuff synced from konsole again to improve color scheme handling
+ * focus in/out signals
+ * correct shell detection (BSD, Christopher VdoP)
+ * library location on BSD
+ * patches to build on BSD by Christopher VdoP
+ * K&R formatting
+ * K&R formatting
+ * merge with qscite
+ * fixed KB finding + sort
+ * key layouts can be read and provided to widget
+ * install keyboard bindings; handle KB in src code; allow to get and set KB
+ * fix for includes and 64bit builds
+ * port to macosx
+ * initial import
diff --git a/qtermwidget/CMakeLists.txt b/qtermwidget/CMakeLists.txt
new file mode 100644
index 0000000..880911a
--- /dev/null
+++ b/qtermwidget/CMakeLists.txt
@@ -0,0 +1,375 @@
+cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
+# CMP0000: Call the cmake_minimum_required() command at the beginning of the top-level
+# CMakeLists.txt file even before calling the project() command.
+# The cmake_minimum_required(VERSION) command implicitly invokes the cmake_policy(VERSION)
+# command to specify that the current project code is written for the given range of CMake
+# versions.
+project(qtermwidget)
+
+include(GNUInstallDirs)
+include(GenerateExportHeader)
+include(CMakePackageConfigHelpers)
+include(CheckFunctionExists)
+include(CheckIncludeFile)
+
+option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
+option(BUILD_EXAMPLE "Build example application. Default OFF." OFF)
+option(QTERMWIDGET_USE_UTEMPTER "Uses libutempter on Linux or libulog on FreeBSD for login records." OFF)
+option(QTERMWIDGET_BUILD_PYTHON_BINDING "Build python binding" OFF)
+option(USE_UTF8PROC "Use libutf8proc for better Unicode support. Default OFF" OFF)
+option(USE_QT5 "Use Qt 5 instead of Qt6 (if available). Default OFF" OFF)
+
+# just change version for releases
+# keep this in sync with the version in pyqt/pyproject.toml
+set(QTERMWIDGET_VERSION_MAJOR "1")
+set(QTERMWIDGET_VERSION_MINOR "3")
+set(QTERMWIDGET_VERSION_PATCH "0")
+
+set(QTERMWIDGET_VERSION "${QTERMWIDGET_VERSION_MAJOR}.${QTERMWIDGET_VERSION_MINOR}.${QTERMWIDGET_VERSION_PATCH}")
+
+# additional cmake files
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+# Minimum Versions
+set(QT_MINIMUM_VERSION "5.15.0")
+set(QT6_MINIMUM_VERSION "6.1.0")
+set(LXQTBT_MINIMUM_VERSION "0.10.0")
+
+if (NOT USE_QT5)
+ find_package(Qt6 COMPONENTS Widgets)
+ if (NOT Qt6_FOUND)
+ find_package(Qt5Widgets "${QT_MINIMUM_VERSION}" REQUIRED)
+ find_package(Qt5LinguistTools "${QT_MINIMUM_VERSION}" REQUIRED)
+ endif()
+
+ if (Qt6_FOUND)
+ find_package(Qt6Widgets "${QT6_MINIMUM_VERSION}" REQUIRED)
+ find_package(Qt6LinguistTools "${QT6_MINIMUM_VERSION}" REQUIRED)
+ find_package(Qt6Core5Compat "${QT6_MINIMUM_VERSION}" REQUIRED)
+ endif()
+else()
+ find_package(Qt5Widgets "${QT_MINIMUM_VERSION}" REQUIRED)
+ find_package(Qt5LinguistTools "${QT_MINIMUM_VERSION}" REQUIRED)
+endif()
+
+find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
+
+if(USE_UTF8PROC)
+ find_package(Utf8Proc REQUIRED)
+endif()
+
+include(LXQtPreventInSourceBuilds)
+include(LXQtTranslateTs)
+include(LXQtCompilerSettings NO_POLICY_SCOPE)
+include(LXQtCreatePkgConfigFile)
+
+if(APPLE)
+ if(CMAKE_VERSION VERSION_GREATER 3.9)
+ cmake_policy(SET CMP0068 NEW)
+ set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
+ endif()
+endif()
+
+if (NOT Qt6_FOUND)
+ set(QTERMWIDGET_LIBRARY_NAME qtermwidget5)
+else()
+ set(QTERMWIDGET_LIBRARY_NAME qtermwidget6)
+endif()
+
+# main library
+
+set(SRCS
+ lib/BlockArray.cpp
+ lib/ColorScheme.cpp
+ lib/Emulation.cpp
+ lib/Filter.cpp
+ lib/History.cpp
+ lib/HistorySearch.cpp
+ lib/KeyboardTranslator.cpp
+ lib/konsole_wcwidth.cpp
+ lib/kprocess.cpp
+ lib/kpty.cpp
+ lib/kptydevice.cpp
+ lib/kptyprocess.cpp
+ lib/Pty.cpp
+ lib/qtermwidget.cpp
+ lib/Screen.cpp
+ lib/ScreenWindow.cpp
+ lib/SearchBar.cpp
+ lib/Session.cpp
+ lib/ShellCommand.cpp
+ lib/TerminalCharacterDecoder.cpp
+ lib/TerminalDisplay.cpp
+ lib/tools.cpp
+ lib/Vt102Emulation.cpp
+)
+
+# Only the Headers that need to be moc'd go here
+set(HDRS
+ lib/Emulation.h
+ lib/Filter.h
+ lib/HistorySearch.h
+ lib/kprocess.h
+ lib/kptydevice.h
+ lib/kptyprocess.h
+ lib/Pty.h
+ lib/qtermwidget.h
+ lib/ScreenWindow.h
+ lib/SearchBar.h
+ lib/Session.h
+ lib/TerminalDisplay.h
+ lib/Vt102Emulation.h
+)
+
+set(UI
+ lib/SearchBar.ui
+)
+
+# for distribution
+set(HDRS_DISTRIB
+ lib/qtermwidget.h
+ lib/Emulation.h
+ lib/KeyboardTranslator.h
+ lib/Filter.h
+ lib/qtermwidget_interface.h
+)
+
+# dirs
+set(KB_LAYOUT_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${QTERMWIDGET_LIBRARY_NAME}/kb-layouts")
+message(STATUS "Keyboard layouts will be installed in: ${KB_LAYOUT_DIR}")
+
+set(COLORSCHEMES_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${QTERMWIDGET_LIBRARY_NAME}/color-schemes")
+message(STATUS "Color schemes will be installed in: ${COLORSCHEMES_DIR}" )
+
+set(TRANSLATIONS_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${QTERMWIDGET_LIBRARY_NAME}/translations")
+message(STATUS "Translations will be installed in: ${TRANSLATIONS_DIR}")
+
+set(QTERMWIDGET_INCLUDE_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}/${QTERMWIDGET_LIBRARY_NAME}")
+
+CHECK_FUNCTION_EXISTS(updwtmpx HAVE_UPDWTMPX)
+
+if (NOT USE_QT5)
+ if (NOT Qt6_FOUND)
+ qt5_wrap_cpp(MOCS ${HDRS})
+ qt5_wrap_ui(UI_SRCS ${UI})
+ set(PKG_CONFIG_REQ "Qt5Widgets")
+ else()
+ qt6_wrap_cpp(MOCS ${HDRS})
+ qt6_wrap_ui(UI_SRCS ${UI})
+ set(PKG_CONFIG_REQ "Qt6Widgets")
+ endif()
+else()
+ qt5_wrap_cpp(MOCS ${HDRS})
+ qt5_wrap_ui(UI_SRCS ${UI})
+ set(PKG_CONFIG_REQ "Qt5Widgets")
+endif()
+
+lxqt_translate_ts(QTERMWIDGET_QM
+ TRANSLATION_DIR "lib/translations"
+ UPDATE_TRANSLATIONS
+ ${UPDATE_TRANSLATIONS}
+ SOURCES
+ ${SRCS} ${HDRS} ${UI}
+ INSTALL_DIR
+ ${TRANSLATIONS_DIR}
+ COMPONENT
+ Runtime
+)
+
+add_library(${QTERMWIDGET_LIBRARY_NAME} SHARED ${SRCS} ${MOCS} ${UI_SRCS} ${QTERMWIDGET_QM})
+if (NOT USE_QT5)
+ if (NOT Qt6_FOUND)
+ target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} Qt5::Widgets)
+ else()
+ target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} Qt6::Widgets)
+ target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} Qt6::Core5Compat)
+ endif()
+else()
+ target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} Qt5::Widgets)
+endif()
+
+set_target_properties( ${QTERMWIDGET_LIBRARY_NAME} PROPERTIES
+ SOVERSION ${QTERMWIDGET_VERSION_MAJOR}
+ VERSION ${QTERMWIDGET_VERSION}
+ )
+
+
+if(APPLE)
+ target_compile_definitions(${QTERMWIDGET_LIBRARY_NAME}
+ PRIVATE
+ "HAVE_UTMPX"
+ "UTMPX_COMPAT"
+ )
+endif()
+
+if(HAVE_UPDWTMPX)
+ target_compile_definitions(${QTERMWIDGET_LIBRARY_NAME}
+ PRIVATE
+ "HAVE_UPDWTMPX"
+ )
+endif()
+
+if (QTERMWIDGET_USE_UTEMPTER)
+ CHECK_INCLUDE_FILE(utempter.h HAVE_UTEMPTER)
+ if (HAVE_UTEMPTER)
+ target_compile_definitions(${QTERMWIDGET_LIBRARY_NAME} PRIVATE
+ "HAVE_UTEMPTER"
+ )
+ find_library(UTEMPTER_LIB NAMES utempter ulog REQUIRED)
+ target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} ${UTEMPTER_LIB})
+ endif()
+endif()
+
+if (UTF8PROC_FOUND)
+ target_compile_definitions(${QTERMWIDGET_LIBRARY_NAME}
+ PRIVATE
+ "HAVE_UTF8PROC"
+ )
+ target_include_directories(${QTERMWIDGET_LIBRARY_NAME}
+ INTERFACE
+ ${UTF8PROC_INCLUDE_DIRS}
+ )
+ target_link_libraries(${QTERMWIDGET_LIBRARY_NAME}
+ ${UTF8PROC_LIBRARIES}
+ )
+ string(APPEND PKG_CONFIG_REQ ", libutf8proc")
+endif()
+
+if(APPLE)
+ set (CMAKE_SKIP_RPATH 1)
+ # this is a must to load the lib correctly
+ set_target_properties(${QTERMWIDGET_LIBRARY_NAME} PROPERTIES INSTALL_NAME_DIR ${CMAKE_INSTALL_FULL_LIBDIR})
+endif()
+
+target_compile_definitions(${QTERMWIDGET_LIBRARY_NAME}
+ PRIVATE
+ "KB_LAYOUT_DIR=\"${KB_LAYOUT_DIR}\""
+ "COLORSCHEMES_DIR=\"${COLORSCHEMES_DIR}\""
+ "TRANSLATIONS_DIR=\"${TRANSLATIONS_DIR}\""
+ "HAVE_POSIX_OPENPT"
+ "HAVE_SYS_TIME_H"
+)
+
+
+generate_export_header(${QTERMWIDGET_LIBRARY_NAME}
+ EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/lib/qtermwidget_export.h"
+ BASE_NAME QTERMWIDGET
+)
+
+target_include_directories(${QTERMWIDGET_LIBRARY_NAME}
+ PUBLIC
+ "$"
+ "$"
+ "$"
+ INTERFACE
+ "$"
+ "$"
+)
+
+write_basic_package_version_file(
+ "${CMAKE_BINARY_DIR}/${QTERMWIDGET_LIBRARY_NAME}-config-version.cmake"
+ VERSION ${QTERMWIDGET_VERSION}
+ COMPATIBILITY AnyNewerVersion
+)
+
+install(FILES
+ "${CMAKE_BINARY_DIR}/${QTERMWIDGET_LIBRARY_NAME}-config-version.cmake"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${QTERMWIDGET_LIBRARY_NAME}"
+ COMPONENT Devel
+)
+
+install(EXPORT
+ "${QTERMWIDGET_LIBRARY_NAME}-targets"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${QTERMWIDGET_LIBRARY_NAME}"
+ COMPONENT Devel
+)
+
+install(FILES
+ ${HDRS_DISTRIB} "${CMAKE_CURRENT_BINARY_DIR}/lib/qtermwidget_export.h" "${CMAKE_CURRENT_BINARY_DIR}/lib/qtermwidget_version.h"
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${QTERMWIDGET_LIBRARY_NAME}"
+ COMPONENT Devel
+)
+# keyboard layouts
+install(DIRECTORY
+ lib/kb-layouts/
+ DESTINATION "${KB_LAYOUT_DIR}"
+ COMPONENT Runtime
+ FILES_MATCHING PATTERN "*.keytab"
+)
+# color schemes
+install(DIRECTORY
+ lib/color-schemes/
+ DESTINATION "${COLORSCHEMES_DIR}"
+ COMPONENT Runtime
+ FILES_MATCHING PATTERN "*.*schem*"
+)
+
+lxqt_create_pkgconfig_file(
+ PACKAGE_NAME ${QTERMWIDGET_LIBRARY_NAME}
+ DESCRIPTIVE_NAME ${QTERMWIDGET_LIBRARY_NAME}
+ DESCRIPTION "QTermWidget library for Qt ${QTERMWIDGET_VERSION_MAJOR}.x"
+ INCLUDEDIRS ${QTERMWIDGET_LIBRARY_NAME}
+ LIBS ${QTERMWIDGET_LIBRARY_NAME}
+ REQUIRES ${PKG_CONFIG_REQ}
+ VERSION ${QTERMWIDGET_VERSION}
+ INSTALL
+ COMPONENT Devel
+)
+
+configure_file(
+ "${PROJECT_SOURCE_DIR}/cmake/${QTERMWIDGET_LIBRARY_NAME}-config.cmake.in"
+ "${CMAKE_BINARY_DIR}/${QTERMWIDGET_LIBRARY_NAME}-config.cmake"
+ @ONLY
+)
+
+configure_file(
+ "${PROJECT_SOURCE_DIR}/lib/qtermwidget_version.h.in"
+ "${CMAKE_BINARY_DIR}/lib/qtermwidget_version.h"
+ @ONLY
+)
+
+install(FILES
+ "${CMAKE_BINARY_DIR}/${QTERMWIDGET_LIBRARY_NAME}-config.cmake"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${QTERMWIDGET_LIBRARY_NAME}"
+ COMPONENT Devel
+)
+
+install(TARGETS ${QTERMWIDGET_LIBRARY_NAME}
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ EXPORT "${QTERMWIDGET_LIBRARY_NAME}-targets"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ PUBLIC_HEADER
+ COMPONENT Runtime
+)
+
+export(TARGETS ${QTERMWIDGET_LIBRARY_NAME}
+ FILE "${CMAKE_BINARY_DIR}/${QTERMWIDGET_LIBRARY_NAME}-targets.cmake"
+ EXPORT_LINK_INTERFACE_LIBRARIES
+)
+# end of main library
+
+
+# example application
+if(BUILD_EXAMPLE)
+ set(EXAMPLE_SRC examples/cpp/main.cpp)
+ add_executable(example ${EXAMPLE_SRC})
+ target_link_libraries(example ${QTERMWIDGET_LIBRARY_NAME})
+endif()
+# end of example application
+
+# python binding
+if (QTERMWIDGET_BUILD_PYTHON_BINDING)
+ message(SEND_ERROR "QTERMWIDGET_BUILD_PYTHON_BINDING is no longer supported. Check README.md for how to build PyQt bindings.")
+endif()
+# end of python binding
+
+
+CONFIGURE_FILE(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ IMMEDIATE @ONLY
+)
+ADD_CUSTOM_TARGET(uninstall
+ "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+)
diff --git a/qtermwidget/CMakePresets.json b/qtermwidget/CMakePresets.json
new file mode 100644
index 0000000..f5371d5
--- /dev/null
+++ b/qtermwidget/CMakePresets.json
@@ -0,0 +1,17 @@
+{
+ "version": 2,
+ "configurePresets": [
+ {
+ "name": "Default",
+ "displayName": "Configure preset using toolchain file",
+ "description": "Sets Ninja generator, build and install directory",
+ "generator": "Ninja",
+ "binaryDir": "${sourceDir}/out/build/${presetName}",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Debug",
+ "CMAKE_TOOLCHAIN_FILE": "",
+ "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/qtermwidget/COPYING-CMAKE-SCRIPTS b/qtermwidget/COPYING-CMAKE-SCRIPTS
new file mode 120000
index 0000000..37e4ca8
--- /dev/null
+++ b/qtermwidget/COPYING-CMAKE-SCRIPTS
@@ -0,0 +1 @@
+LICENSE.BSD-3-clause
\ No newline at end of file
diff --git a/qtermwidget/Changelog b/qtermwidget/Changelog
deleted file mode 100644
index 291a3ff..0000000
--- a/qtermwidget/Changelog
+++ /dev/null
@@ -1,19 +0,0 @@
-31.07.2008
-Interface class from c-style conversions rewritten with pimpl support.
-
-
-16.07.2008
-Added optional scrollbar
-
-
-06.06.2008
-Some artefacts were removed, some added...
-Also added support for color schemes, and 3 color schemes provided (classical - white on black, green on black, black on light yellow). Is it enough or not?
-
-
-26.05.2008
-Added file release as an archive with source code. But preferrable way is still getting code from CVS, cause file release can be outdated.
-
-
-11.05.2008
-Initial CVS import - first version comes with number 0.0.1
\ No newline at end of file
diff --git a/qtermwidget/COPYING b/qtermwidget/LICENSE
similarity index 82%
rename from qtermwidget/COPYING
rename to qtermwidget/LICENSE
index 5b6e7c6..d8cf7d4 100644
--- a/qtermwidget/COPYING
+++ b/qtermwidget/LICENSE
@@ -1,12 +1,12 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
- Preamble
+ Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
+the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
-
- GNU GENERAL PUBLIC LICENSE
+
+ GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
-
+
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
-
+
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
@@ -225,7 +225,7 @@ impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
-
+
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
- NO WARRANTY
+ NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@@ -277,64 +277,4 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- , 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
+ END OF TERMS AND CONDITIONS
diff --git a/qtermwidget/LICENSE.BSD-3-clause b/qtermwidget/LICENSE.BSD-3-clause
new file mode 100644
index 0000000..c7a0aa4
--- /dev/null
+++ b/qtermwidget/LICENSE.BSD-3-clause
@@ -0,0 +1,26 @@
+Copyright (c) The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
diff --git a/qtermwidget/LICENSE.LGPL2+ b/qtermwidget/LICENSE.LGPL2+
new file mode 100644
index 0000000..5bc8fb2
--- /dev/null
+++ b/qtermwidget/LICENSE.LGPL2+
@@ -0,0 +1,481 @@
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL. It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it. You can use it for
+your libraries, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library. If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software. To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+ Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs. This
+license, the GNU Library General Public License, applies to certain
+designated libraries. This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+ The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it. Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program. However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+ Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries. We
+concluded that weaker conditions might promote sharing better.
+
+ However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves. This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them. (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.) The hope is that this
+will lead to faster development of free libraries.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+ Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License"). Each licensee is
+addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ c) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ d) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ , 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/qtermwidget/README b/qtermwidget/README
deleted file mode 100644
index 0d3228f..0000000
--- a/qtermwidget/README
+++ /dev/null
@@ -1,26 +0,0 @@
-This is a external source gotten from:
-
-http://www.qt-apps.org/content/show.php/QTermWidget?content=82832
-
-*************************************************************************************
-QTermWidget
-version 0.1.0
-
-QTermWidget is an opensource project based on KDE4 Konsole application.
-The main goal of this project is to provide unicode-enabled, embeddable
-QT widget for using as a built-in console (or terminal emulation widget).
-
-Of course I`m aware about embedding abilities of original Konsole,
-but once I had Qt without KDE, and it was a serious obstacle.
-I decided not to rely on a chance. I cannot find any interesting related project,
-so I had to write it.
-
-The original Konsole`s code was rewritten entirely with QT4 only; also I have to
-include in the project some parts of code from kde core library. All code dealing
-with user interface parts and session managers was removed (maybe later I bring it
-back somehow), and the result is quite useful, I suppose.
-
-This library was compiled and tested on three linux systems,
-based on 2.4.32, 2.6.20, 2.6.23 kernels, x86 and amd64.
-Please inform about its behaviour on other systems.
-
diff --git a/qtermwidget/README.md b/qtermwidget/README.md
new file mode 100644
index 0000000..6cbeb17
--- /dev/null
+++ b/qtermwidget/README.md
@@ -0,0 +1,346 @@
+# QTermWidget
+
+## Overview
+
+A terminal emulator widget for Qt 5.
+
+QTermWidget is an open-source project originally based on the KDE4 Konsole application, but it took its own direction later on.
+The main goal of this project is to provide a Unicode-enabled, embeddable Qt widget for using as a built-in console (or terminal emulation widget).
+
+It is compatible with BSD, Linux and OS X.
+
+This project is licensed under the terms of the [GPLv2](https://www.gnu.org/licenses/gpl-2.0.en.html) or any later version. See the LICENSE file for the full text of the license. Some files are published under compatible licenses:
+```
+Files: example/main.cpp
+ lib/TerminalCharacterDecoder.cpp
+ lib/TerminalCharacterDecoder.h
+ lib/kprocess.cpp
+ lib/kprocess.h
+ lib/kpty.cpp
+ lib/kpty.h
+ lib/kpty_p.h
+ lib/kptydevice.cpp
+ lib/kptydevice.h
+ lib/kptyprocess.cpp
+ lib/kptyprocess.h
+ lib/qtermwidget.cpp
+ lib/qtermwidget.h
+ lib/qtermwidget_interface.h
+Copyright: Author Adriaan de Groot
+ 2010, KDE e.V
+ 2002-2007, Oswald Buddenhagen
+ 2006-2008, Robert Knight
+ 2002, Waldo Bastian
+ 2008, e_k
+ 2022, Francesc Martinez
+License: LGPL-2+
+
+Files: cmake/FindUtf8Proc.cmake
+Copyright: 2009-2011, Kitware, Inc
+ 2009-2011, Philip Lowman
+License: BSD-3-clause
+```
+
+## Installation
+
+### Compiling sources
+
+The only runtime dependency is qtbase ≥ 5.12.0.
+Build dependencies are as follows:
+- CMake ≥ 3.1.0 serves as the build system and therefore needs to be present to compile.
+- The latest [lxqt-build-tools](https://github.com/lxqt/lxqt-build-tools/) is also needed for compilation.
+- Git is needed to optionally pull latest VCS checkouts.
+
+Code configuration is handled by CMake. CMake variable `CMAKE_INSTALL_PREFIX` will normally have to be set to `/usr`, depending on the way library paths are dealt with on 64bit systems. Variables like `CMAKE_INSTALL_LIBDIR` may have to be set as well.
+
+To build, run `make`. To install, run `make install` which accepts variable `DESTDIR` as usual.
+
+To build PyQt bindings, build this library first, and then invoke `sip-wheel` in pyqt/ directory. Environment variables `CXXFLAGS` and `LDFLAGS` can be used to specify non-installed or non-standard directories for headers and shared libraries, and the built Python wheel can be installed by standard tools like `pip`. See [the CI script](.ci/build.sh) for a complete example.
+
+### Binary packages
+
+The library is provided by all major Linux distributions. This includes Arch Linux, Debian, Fedora, openSUSE and all of their children, given they use the same package repositories.
+Just use the distributions' package managers to search for string `qtermwidget`.
+
+
+### Translation
+
+Translations can be done in [LXQt-Weblate](https://translate.lxqt-project.org/projects/lxqt-desktop/qtermwidget/)
+
+
+
+
+
+## API
+### Public Types
+Type | Variable
+| ---: | :---
+enum | ScrollBarPosition { NoScrollBar, ScrollBarLeft, ScrollBarRight }
+enum | KeyboardCursorShape { BlockCursor, UnderlineCursor, IBeamCursor }
+
+### Properties
+* flowControlEnabled : bool
+* getPtySlaveFd : const int
+* getShellPID : int
+* getForegroundProcessId : int
+* getTerminalFont : QFont
+* historyLinesCount : int
+* icon : const QString
+* keyBindings : QString
+* screenColumnsCount : int
+* selectedText(bool _preserveLineBreaks_ = true) : QString
+* sizeHint : const QSize
+* terminalSizeHint : bool
+* title : const QString
+* workingDirectory : QString
+
+### Public Functions
+Type | Function
+| ---: | :---
+| | QTermWidget(int _startnow_ = 1, QWidget *_parent_ = 0)
+virtual | ~QTermWidget()
+void | changeDir(const QString _&dir_)
+void | getSelectionEnd(int &_row_, int &_column_)
+void | getSelectionStart(int &_row_, int &_column_)
+void | scrollToEnd()
+void | sendText(QString &_text_)
+void | setArgs(QStringList &_args_)
+void | setAutoClose(bool _enabled_)
+void | setColorScheme(const QString &_name_)
+void | setEnvironment(const QStringList &_environment_)
+void | setFlowControlEnabled(bool _enabled_)
+void | setFlowControlWarningEnabled(bool _enabled_)
+void | setHistorySize(int _lines_)
+void | setKeyboardCursorShape(QTermWidget::KeyboardCursorShape _shape_)
+void | setMonitorActivity(bool _enabled_)
+void | setMonitorSilence(bool _enabled_)
+void | setMotionAfterPasting(int _action_)
+void | setScrollBarPosition(QTermWidget::ScrollBarPosition _pos_)
+void | setSelectionEnd(int _row_, int _column_)
+void | setSelectionStart(int _row_, int _column_)
+void | setShellProgram(const QString &_program_)
+void | setSilenceTimeout(int _seconds_)
+void | setTerminalFont(QFont &_font_)
+void | setTerminalOpacity(qreal _level_)
+void | setTerminalSizeHint(bool _enabled_)
+void | setTextCodec(QTextCodec *_codec_)
+void | setWorkingDirectory(const QString &_dir_)
+void | startShellProgram()
+void | startTerminalTeletype()
+QStringList | availableColorSchemes()
+
+### Public Slots
+Type | Function
+| ---: | :---
+void | copyClipboard()
+void | pasteClipboard()
+void | pasteSelection()
+void | zoomIn()
+void | zoomOut()
+void | setSize(_const QSize &_)
+void | setKeyBindings(const QString &_kb_)
+void | clear()
+void | toggleShowSearchBar()
+
+### Signals
+Type | Function
+| ---: | :---
+void | activity()
+void | bell(const QString &_message_)
+void | copyAvailable(bool)
+void | finished()
+void | profileChanged(const QString &_profile_)
+void | receivedData(const QString &_text_)
+void | sendData(const char*, int)
+void | silence()
+void | termGetFocus()
+void | termKeyPressed(QKeyEvent*)
+void | termLostFocus()
+void | titleChanged()
+void | urlActivated(const QUrl &, bool _fromContextMenu_)
+
+### Static Public Members
+Type | Function
+| ---: | :---
+static QStringList | availableColorSchemes()
+static QStringList | availableKeyBindings()
+static void | addCustomColorSchemeDir(const QString &*custom_dir*)
+
+### Protected Functions
+Type | Function
+| ---: | :---
+virtual void | resizeEvent(_QResizeEvent_*)
+
+### Protected Slots
+Type | Function
+| ---: | :---
+void | sessionFinished()
+void | selectionChanged(bool _textSelected_)
+
+### Member Type Documentation
+**enum QTermWidget::ScrollBarPosition**\
+This enum describes the location where the scroll bar is positioned in the display widget when calling QTermWidget::setScrollBarPosition().
+
+Constant | Value | Description
+| --- | :---: | --- |
+QTermWidget::NoScrollBar | 0x0 | Do not show the scroll bar.
+QTermWidget::ScrollBarLeft | 0x1 | Show the scroll bar on the left side of the display.
+QTermWidget::ScrollBarRight | 0x2 | Show the scroll bar on the right side of the display.
+
+\
+**enum QTermWidget::KeyboardCursorShape**\
+This enum describes the available shapes for the keyboard cursor when calling QTermWidget::setKeyboardCursorShape().
+
+Constant | Value | Description
+| --- | :---: | --- |
+QTermWidget::BlockCursor | 0x0 | A rectangular block which covers the entire area of the cursor character.
+QTermWidget::UnderlineCursor | 0x1 | A single flat line which occupies the space at the bottom of the cursor character's area.
+QTermWidget::IBeamCursor | 0x2 | A cursor shaped like the capital letter 'I', similar to the IBeam cursor used in Qt/KDE text editors.
+
+### Property Documentation
+**flowControlEnabled : bool**\
+Returns whether flow control is enabled.
+
+**getPtySlaveFd : const int**\
+Returns a pty slave file descriptor. This can be used for display and control a remote terminal.
+
+
+**getForegroundProcessId : int**\
+Returns the PID of the foreground process. This is initially the same as processId() but can change
+as the user starts other programs inside the terminal. If there is a problem reading the foreground
+process id, 0 will be returned.
+
+
+
+**historyLinesCount : int**\
+Returns the number of lines in the history buffer.
+
+
+
+**keyBindings : QString**\
+Returns current key bindings.
+
+
+
+**selectedText(bool _preserveLineBreaks_ = true) : QString**\
+Returns the currently selected text.
+
+
+
+
+
+
+### Member Function Documentation
+
+
+
+__void changeDir(const QString _&dir_)__\
+Attempt to change shell directory (Linux only).
+
+__void clear()__\
+Clear the terminal content and move to home position.
+
+
+
+__void copyClipboard()__\
+Copy selection to clipboard.
+
+
+
+
+
+__void pasteClipboard()__\
+Paste clipboard to terminal.
+
+__void pasteSelection()__\
+Paste selection to terminal.
+
+
+
+__void receivedData(const QString &_text_)__\
+Signals that we received new data from the process running in the terminal emulator.
+
+__void scrollToEnd()__\
+Wrapped, scroll to end of text.
+
+__void sendData(const char*, int)__\
+Emitted when emulator send data to the terminal process (redirected for external recipient). It can be used for control and display the remote terminal.
+
+__void sendText(QString &_text_)__\
+Send text to terminal.
+
+__void setArgs(QStringList &_args_)__\
+Sets the shell program arguments, default is none.
+
+__void setAutoClose(bool _enabled_)__\
+Automatically close the terminal session after the shell process exits or keep it running.
+
+__void setColorScheme(const QString &_name_)__\
+Sets the color scheme, default is white on black.
+
+__void setEnvironment(const QStringList &_environment_)__\
+Sets environment variables.
+
+__void setFlowControlEnabled(bool _enabled_)__\
+Sets whether flow control is enabled.
+
+__void setFlowControlWarningEnabled(bool _enabled_)__\
+Sets whether the flow control warning box should be shown when the flow control stop key (Ctrl+S) is pressed.
+
+__void setHistorySize(int _lines_)__\
+History size for scrolling.
+
+__void setKeyBindings(const QString &_kb_)__\
+Set named key binding for given widget.
+
+__void setKeyboardCursorShape(QTermWidget::KeyboardCursorShape _shape_)__\
+Sets the shape of the keyboard cursor. This is the cursor drawn at the position in the terminal where keyboard input will appear.
+
+
+
+
+
+__void setScrollBarPosition(QTermWidget::ScrollBarPosition _pos_)__\
+Sets presence and position of scrollbar.
+
+
+
+
+__void setShellProgram(const QString &_program_)__\
+Sets the shell program, default is /bin/bash.
+
+
+
+
+__void setTerminalFont(QFont &_font_)__\
+Sets terminal font. Default is application font with family Monospace, size 10. Beware of a performance penalty and display/alignment issues when using a proportional font.
+
+
+
+__void setTerminalSizeHint(bool _enabled_)__\
+Exposes TerminalDisplay::TerminalSizeHint.
+
+__void setTextCodec(QTextCodec *_codec_)__\
+Sets text codec, default is UTF-8.
+
+
+
+
+__void startShellProgram()__\
+Starts shell program if it was not started in constructor.
+
+__void startTerminalTeletype()__\
+Starts terminal teletype as is and redirect data for external recipient. It can be used for display and control a remote terminal.
+
+
+
+
+
+
+
+
+__void zoomIn()__\
+Zooms in on the text.
+
+__void zoomOut()__\
+Zooms out in on the text.
diff --git a/qtermwidget/TODO b/qtermwidget/TODO
deleted file mode 100644
index c3cb62c..0000000
--- a/qtermwidget/TODO
+++ /dev/null
@@ -1,10 +0,0 @@
-Global
- - provide more compatibility for vttest
-
-Package
- - migrate to autotools if needed
-
-Source
- - provide more options for customization
- - clean unused code
- - add some QT3 support features if needed
diff --git a/qtermwidget/cmake/FindUtf8Proc.cmake b/qtermwidget/cmake/FindUtf8Proc.cmake
new file mode 100644
index 0000000..8e0d1af
--- /dev/null
+++ b/qtermwidget/cmake/FindUtf8Proc.cmake
@@ -0,0 +1,60 @@
+#.rst:
+# FindUtf8Proc
+# --------
+#
+# Find utf8proc
+#
+# Find the UTF-8 processing library
+#
+# ::
+#
+# This module defines the following variables:
+# UTF8PROC_FOUND - True if UTF8PROC_INCLUDE_DIR & UTF8PROC_LIBRARY are found
+# UTF8PROC_LIBRARIES - Set when UTF8PROC_LIBRARY is found
+# UTF8PROC_INCLUDE_DIRS - Set when UTF8PROC_INCLUDE_DIR is found
+#
+#
+#
+# ::
+#
+# UTF8PROC_INCLUDE_DIR - where to find utf8proc.h
+# UTF8PROC_LIBRARY - the utf8proc library
+
+#=============================================================================
+# This module is adapted from FindALSA.cmake. Below are the original license
+# header.
+#=============================================================================
+# Copyright 2009-2011 Kitware, Inc.
+# Copyright 2009-2011 Philip Lowman
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+find_path(
+ UTF8PROC_INCLUDE_DIR NAMES utf8proc.h DOC "The utf8proc include directory"
+)
+
+find_library(
+ UTF8PROC_LIBRARY NAMES utf8proc DOC "The utf8proc library"
+)
+
+# handle the QUIETLY and REQUIRED arguments and set UTF8PROC_FOUND to TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+ Utf8Proc
+ FOUND_VAR Utf8Proc_FOUND
+ REQUIRED_VARS UTF8PROC_LIBRARY UTF8PROC_INCLUDE_DIR
+)
+
+if(Utf8Proc_FOUND)
+ set( UTF8PROC_LIBRARIES ${UTF8PROC_LIBRARY} )
+ set( UTF8PROC_INCLUDE_DIRS ${UTF8PROC_INCLUDE_DIR} )
+endif()
+
+mark_as_advanced(UTF8PROC_INCLUDE_DIR UTF8PROC_LIBRARY)
diff --git a/qtermwidget/cmake/cmake_uninstall.cmake.in b/qtermwidget/cmake/cmake_uninstall.cmake.in
new file mode 100644
index 0000000..02cb12d
--- /dev/null
+++ b/qtermwidget/cmake/cmake_uninstall.cmake.in
@@ -0,0 +1,23 @@
+IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
+ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+# this works on Linux, but not on mac.
+#FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+#STRING(REGEX REPLACE "\n" ";" files "${files}")
+#FOREACH(file ${files})
+# MESSAGE(STATUS "Uninstalling \"${file}\"")
+# IF(NOT EXISTS "${file}")
+# MESSAGE(FATAL_ERROR "File \"${file}\" does not exists.")
+# ENDIF(NOT EXISTS "${file}")
+# EXEC_PROGRAM("@CMAKE_COMMAND@" ARGS "-E remove \"${file}\""
+# OUTPUT_VARIABLE rm_out
+# RETURN_VARIABLE rm_retval)
+# IF("${rm_retval}" GREATER 0)
+# MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"")
+# ENDIF("${rm_retval}" GREATER 0)
+#ENDFOREACH(file)
+
+EXEC_PROGRAM("xargs rm < @CMAKE_BINARY_DIR@/install_manifest.txt"
+ OUTPUT_VARIABLE rm_out
+ RETURN_VARIABLE rm_ret)
diff --git a/qtermwidget/cmake/qtermwidget5-config.cmake.in b/qtermwidget/cmake/qtermwidget5-config.cmake.in
new file mode 100644
index 0000000..db62356
--- /dev/null
+++ b/qtermwidget/cmake/qtermwidget5-config.cmake.in
@@ -0,0 +1,20 @@
+# - Find the QTermWidget include and library
+#
+# Typical usage:
+# find_package(QTermWidget5 REQUIRED)
+#
+# add_executable(foo main.cpp)
+# target_link_libraries(foo qtermwidget5)
+
+@PACKAGE_INIT@
+
+if (CMAKE_VERSION VERSION_LESS 3.0.2)
+ message(FATAL_ERROR \"qtermwidget requires at least CMake version 3.0.2\")
+endif()
+
+if (NOT TARGET @QTERMWIDGET_LIBRARY_NAME@)
+ if (POLICY CMP0024)
+ cmake_policy(SET CMP0024 NEW)
+ endif()
+ include("${CMAKE_CURRENT_LIST_DIR}/@QTERMWIDGET_LIBRARY_NAME@-targets.cmake")
+endif()
diff --git a/qtermwidget/cmake/qtermwidget6-config.cmake.in b/qtermwidget/cmake/qtermwidget6-config.cmake.in
new file mode 100644
index 0000000..db62356
--- /dev/null
+++ b/qtermwidget/cmake/qtermwidget6-config.cmake.in
@@ -0,0 +1,20 @@
+# - Find the QTermWidget include and library
+#
+# Typical usage:
+# find_package(QTermWidget5 REQUIRED)
+#
+# add_executable(foo main.cpp)
+# target_link_libraries(foo qtermwidget5)
+
+@PACKAGE_INIT@
+
+if (CMAKE_VERSION VERSION_LESS 3.0.2)
+ message(FATAL_ERROR \"qtermwidget requires at least CMake version 3.0.2\")
+endif()
+
+if (NOT TARGET @QTERMWIDGET_LIBRARY_NAME@)
+ if (POLICY CMP0024)
+ cmake_policy(SET CMP0024 NEW)
+ endif()
+ include("${CMAKE_CURRENT_LIST_DIR}/@QTERMWIDGET_LIBRARY_NAME@-targets.cmake")
+endif()
diff --git a/qtermwidget/docs/configuration.md b/qtermwidget/docs/configuration.md
new file mode 100644
index 0000000..4950009
--- /dev/null
+++ b/qtermwidget/docs/configuration.md
@@ -0,0 +1,20 @@
+# Migration for background images
+
+How the background image is drawn has been changed since version 0.17.
+Intuitively, the background image is now drawn above the background color instead of below it.
+Technically, the background image is no longer blended with the background color.
+
+Any background image can be used but, of course, it should be chosen so that the terminal text can be easily read on it.
+Since an image may not be totally dark or light, you might want to use a translucent image as the background.
+As a result, the background image is mixed with the background color to improve readability.
+Opaque images can also be converted to translucent ones with a few steps.
+
+A common usage is an effect similar to previous qtermwidget versions or other terminal emulators.
+To achieve that, you can convert the background image to a translucent one with the transparency level matching the original terminal transparency.
+For example, if the original terminal transparency of qtermwidget was 25% (or 75% in some other terminal emulators), a converted image with transparency 25% will work as usual.
+The conversion can be done via ImageMagick, GraphicsMagick, GIMP or Krita.
+Here is an example command using ImageMagick:
+
+ $ convert original_image.jpg -matte -channel A +level 0,25% +channel translucent_image.png
+
+You may also want to change the terminal transparency to 0% if you do not want to see another window or the desktop below the terminal.
diff --git a/qtermwidget/examples/README b/qtermwidget/examples/README
new file mode 100644
index 0000000..a985b57
--- /dev/null
+++ b/qtermwidget/examples/README
@@ -0,0 +1 @@
+Here are two sample programs which use QTermWidget for displaying a terminal
diff --git a/qtermwidget/examples/cpp/RemoteTerm/README.md b/qtermwidget/examples/cpp/RemoteTerm/README.md
new file mode 100644
index 0000000..065ee8c
--- /dev/null
+++ b/qtermwidget/examples/cpp/RemoteTerm/README.md
@@ -0,0 +1,8 @@
+A simple example showing how to use QTermWidget to control and display a remote terminal.
+
+To run this example, you should:
+1. Build client-side program. In my PC, I use 'apt-get' to install the QTermWidget library.
+2. Start the shell-srv.py with specific parameters.This will expose a shell via socket.
+3. Start the client-side program from commandline with specific parameters.
+
+Now you will get your own remote terminal work with QTermWidget.
\ No newline at end of file
diff --git a/qtermwidget/examples/cpp/RemoteTerm/RemoteTerm.pro b/qtermwidget/examples/cpp/RemoteTerm/RemoteTerm.pro
new file mode 100644
index 0000000..21c36f7
--- /dev/null
+++ b/qtermwidget/examples/cpp/RemoteTerm/RemoteTerm.pro
@@ -0,0 +1,34 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2017-10-31T00:37:59
+#
+#-------------------------------------------------
+
+QT += core gui network
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = RemoteTerm
+TEMPLATE = app
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as been marked as deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+CONFIG += c++11
+
+SOURCES += \
+ main.cpp \
+ remoteterm.cpp
+
+HEADERS += \
+ remoteterm.h
+
+unix:!macx: LIBS += -lqtermwidget5
diff --git a/qtermwidget/examples/cpp/RemoteTerm/main.cpp b/qtermwidget/examples/cpp/RemoteTerm/main.cpp
new file mode 100644
index 0000000..f51df3a
--- /dev/null
+++ b/qtermwidget/examples/cpp/RemoteTerm/main.cpp
@@ -0,0 +1,19 @@
+#include "remoteterm.h"
+#include
+#include
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ if(a.arguments().size() != 3){
+ qDebug() << "Example(client-side) for remote terminal of QTermWidget.";
+ qDebug() << QString("Usage: %1 ipaddr port").arg(a.arguments()[0]);
+ return 1;
+ }
+ QString ipaddr = a.arguments().at(1);
+ quint16 port = a.arguments().at(2).toUShort();
+ RemoteTerm w(ipaddr,port);
+ w.show();
+
+ return a.exec();
+}
diff --git a/qtermwidget/examples/cpp/RemoteTerm/remoteterm.cpp b/qtermwidget/examples/cpp/RemoteTerm/remoteterm.cpp
new file mode 100644
index 0000000..551ac25
--- /dev/null
+++ b/qtermwidget/examples/cpp/RemoteTerm/remoteterm.cpp
@@ -0,0 +1,32 @@
+#include "remoteterm.h"
+#include
+#include
+#include
+
+RemoteTerm::RemoteTerm(const QString &ipaddr, quint16 port, QWidget *parent)
+ : QTermWidget(0,parent)
+{
+ socket = new QTcpSocket(this);
+
+ // Write what we input to remote terminal via socket
+ connect(this, &RemoteTerm::sendData,[this](const char *data, int size){
+ this->socket->write(data, size);
+ });
+
+ // Read anything from remote terminal via socket and show it on widget.
+ connect(socket,&QTcpSocket::readyRead,[this](){
+ QByteArray data = socket->readAll();
+ write(this->getPtySlaveFd(), data.data(), data.size());
+ });
+ connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(atError()));
+
+ // Here we start an empty pty.
+ this->startTerminalTeletype();
+
+ socket->connectToHost(ipaddr, port);
+}
+
+void RemoteTerm::atError()
+{
+ qDebug() << socket->errorString();
+}
diff --git a/qtermwidget/examples/cpp/RemoteTerm/remoteterm.h b/qtermwidget/examples/cpp/RemoteTerm/remoteterm.h
new file mode 100644
index 0000000..c591ec4
--- /dev/null
+++ b/qtermwidget/examples/cpp/RemoteTerm/remoteterm.h
@@ -0,0 +1,19 @@
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include
+
+class QTcpSocket;
+
+class RemoteTerm : public QTermWidget
+{
+ Q_OBJECT
+public:
+ RemoteTerm(const QString &ipaddr, quint16 port, QWidget *parent = 0);
+public slots:
+ void atError();
+private:
+ QTcpSocket *socket;
+};
+
+#endif // WIDGET_H
diff --git a/qtermwidget/examples/cpp/RemoteTerm/shell-srv.py b/qtermwidget/examples/cpp/RemoteTerm/shell-srv.py
new file mode 100644
index 0000000..dc0cb62
--- /dev/null
+++ b/qtermwidget/examples/cpp/RemoteTerm/shell-srv.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+import sys
+import os
+import socket
+import pty
+
+def usage(program):
+ print "Example(server-side) for remote terminal of QTermWidget."
+ print "Usage: %s ipaddr port" %program
+
+
+def main():
+ if len(sys.argv) != 3:
+ usage(sys.argv[0])
+ sys.exit(1)
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ try:
+ s.bind((sys.argv[1], int(sys.argv[2])))
+ s.listen(0)
+ print "[+]Start Server."
+ except Exception as e:
+ print "[-]Error Happened: %s" %e.message
+ sys.exit(2)
+
+ while True:
+ c = s.accept()
+ os.dup2(c[0].fileno(), 0)
+ os.dup2(c[0].fileno(), 1)
+ os.dup2(c[0].fileno(), 2)
+
+ # It's important to use pty to spawn the shell.
+ pty.spawn("/bin/sh")
+ c[0].close()
+
+if __name__ == "__main__":
+ main()
diff --git a/qtermwidget/examples/cpp/main.cpp b/qtermwidget/examples/cpp/main.cpp
new file mode 100644
index 0000000..dc1b8d2
--- /dev/null
+++ b/qtermwidget/examples/cpp/main.cpp
@@ -0,0 +1,87 @@
+/* Copyright (C) 2008 e_k (e_k@users.sourceforge.net)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+
+#include
+#include
+#include
+#include
+#include
+
+#include "qtermwidget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QIcon::setThemeName(QStringLiteral("oxygen"));
+ QMainWindow *mainWindow = new QMainWindow();
+
+ QTermWidget *console = new QTermWidget();
+
+ QMenuBar *menuBar = new QMenuBar(mainWindow);
+ QMenu *actionsMenu = new QMenu(QStringLiteral("Actions"), menuBar);
+ menuBar->addMenu(actionsMenu);
+ actionsMenu->addAction(QStringLiteral("Find..."), console, &QTermWidget::toggleShowSearchBar,
+ QKeySequence(QLatin1String("Ctrl+Shift+F")));
+ actionsMenu->addAction(QStringLiteral("Copy"), console, &QTermWidget::copyClipboard,
+ QKeySequence(QLatin1String("Ctrl+Shift+C")));
+ actionsMenu->addAction(QStringLiteral("Paste"), console, &QTermWidget::pasteClipboard,
+ QKeySequence(QLatin1String("Ctrl+Shift+V")));
+ actionsMenu->addAction(QStringLiteral("About Qt"), &app, &QApplication::aboutQt);
+ mainWindow->setMenuBar(menuBar);
+
+ QFont font = QApplication::font();
+#ifdef Q_OS_MACOS
+ font.setFamily(QStringLiteral("Monaco"));
+#elif defined(Q_WS_QWS)
+ font.setFamily(QStringLiteral("fixed"));
+#else
+ font.setFamily(QStringLiteral("Monospace"));
+#endif
+ font.setPointSize(12);
+
+ console->setTerminalFont(font);
+
+ // console->setColorScheme(COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW);
+ console->setScrollBarPosition(QTermWidget::ScrollBarRight);
+
+ const auto arguments = QApplication::arguments();
+ for (const QString& arg : arguments)
+ {
+ if (console->availableColorSchemes().contains(arg))
+ console->setColorScheme(arg);
+ if (console->availableKeyBindings().contains(arg))
+ console->setKeyBindings(arg);
+ }
+
+ mainWindow->setCentralWidget(console);
+ mainWindow->resize(600, 400);
+
+ // info output
+ qDebug() << "* INFO *************************";
+ qDebug() << " availableKeyBindings:" << console->availableKeyBindings();
+ qDebug() << " keyBindings:" << console->keyBindings();
+ qDebug() << " availableColorSchemes:" << console->availableColorSchemes();
+ qDebug() << "* INFO END *********************";
+
+ // real startup
+ QObject::connect(console, &QTermWidget::finished, mainWindow, &QMainWindow::close);
+
+ mainWindow->show();
+ return app.exec();
+}
diff --git a/qtermwidget/examples/pyqt/main.py b/qtermwidget/examples/pyqt/main.py
new file mode 100755
index 0000000..5d5a8ef
--- /dev/null
+++ b/qtermwidget/examples/pyqt/main.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python3
+from PyQt5 import QtWidgets
+from QTermWidget import QTermWidget
+
+
+class Terminal(QTermWidget):
+ def __init__(self, process: str, args: list):
+ super().__init__(0)
+ self.finished.connect(self.close)
+ self.setTerminalSizeHint(False)
+ self.setColorScheme("DarkPastels")
+ self.setShellProgram(process)
+ self.setArgs(args)
+ self.startShellProgram()
+ self.show()
+
+
+if __name__ == "__main__":
+ app = QtWidgets.QApplication([])
+ args = ["--clean", "--noplugin"]
+ term = Terminal("vim", args)
+ app.exec()
diff --git a/qtermwidget/src/BlockArray.cpp b/qtermwidget/lib/BlockArray.cpp
similarity index 67%
rename from qtermwidget/src/BlockArray.cpp
rename to qtermwidget/lib/BlockArray.cpp
index 39ef499..db9e645 100644
--- a/qtermwidget/src/BlockArray.cpp
+++ b/qtermwidget/lib/BlockArray.cpp
@@ -21,17 +21,16 @@
*/
+#include
+
// Own
#include "BlockArray.h"
-#include
-
// System
-#include
#include
#include
#include
-#include
+#include
using namespace Konsole;
@@ -39,40 +38,56 @@ using namespace Konsole;
static int blocksize = 0;
BlockArray::BlockArray()
- : size(0),
- current(size_t(-1)),
- index(size_t(-1)),
- lastmap(0),
- lastmap_index(size_t(-1)),
- lastblock(0), ion(-1),
- length(0)
+ : size(0),
+ current(size_t(-1)),
+ index(size_t(-1)),
+ lastmap(nullptr),
+ lastmap_index(size_t(-1)),
+ lastblock(nullptr), ion(-1),
+ length(0)
{
// lastmap_index = index = current = size_t(-1);
- if (blocksize == 0)
+ if (blocksize == 0) {
blocksize = ((sizeof(Block) / getpagesize()) + 1) * getpagesize();
+ }
}
BlockArray::~BlockArray()
{
setHistorySize(0);
- assert(!lastblock);
+ Q_ASSERT(!lastblock);
}
-size_t BlockArray::append(Block *block)
+size_t BlockArray::append(Block * block)
{
- if (!size)
+ if (!size) {
return size_t(-1);
+ }
++current;
- if (current >= size) current = 0;
+ if (current >= size) {
+ current = 0;
+ }
int rc;
- rc = lseek(ion, current * blocksize, SEEK_SET); if (rc < 0) { perror("HistoryBuffer::add.seek"); setHistorySize(0); return size_t(-1); }
- rc = write(ion, block, blocksize); if (rc < 0) { perror("HistoryBuffer::add.write"); setHistorySize(0); return size_t(-1); }
+ rc = lseek(ion, current * blocksize, SEEK_SET);
+ if (rc < 0) {
+ perror("HistoryBuffer::add.seek");
+ setHistorySize(0);
+ return size_t(-1);
+ }
+ rc = write(ion, block, blocksize);
+ if (rc < 0) {
+ perror("HistoryBuffer::add.write");
+ setHistorySize(0);
+ return size_t(-1);
+ }
length++;
- if (length > size) length = size;
+ if (length > size) {
+ length = size;
+ }
++index;
@@ -82,44 +97,50 @@ size_t BlockArray::append(Block *block)
size_t BlockArray::newBlock()
{
- if (!size)
+ if (!size) {
return size_t(-1);
+ }
append(lastblock);
lastblock = new Block();
return index + 1;
}
-Block *BlockArray::lastBlock() const
+Block * BlockArray::lastBlock() const
{
return lastblock;
}
bool BlockArray::has(size_t i) const
{
- if (i == index + 1)
+ if (i == index + 1) {
return true;
+ }
- if (i > index)
+ if (i > index) {
return false;
- if (index - i >= length)
+ }
+ if (index - i >= length) {
return false;
+ }
return true;
}
-const Block* BlockArray::at(size_t i)
+const Block * BlockArray::at(size_t i)
{
- if (i == index + 1)
+ if (i == index + 1) {
return lastblock;
+ }
- if (i == lastmap_index)
+ if (i == lastmap_index) {
return lastmap;
+ }
if (i > index) {
qDebug() << "BlockArray::at() i > index\n";
- return 0;
+ return nullptr;
}
-
+
// if (index - i >= length) {
// kDebug(1211) << "BlockArray::at() index - i >= length\n";
// return 0;
@@ -127,12 +148,15 @@ const Block* BlockArray::at(size_t i)
size_t j = i; // (current - (index - i) + (index/size+1)*size) % size ;
- assert(j < size);
+ Q_ASSERT(j < size);
unmap();
- Block *block = (Block*)mmap(0, blocksize, PROT_READ, MAP_PRIVATE, ion, j * blocksize);
+ Block * block = (Block *)mmap(nullptr, blocksize, PROT_READ, MAP_PRIVATE, ion, j * blocksize);
- if (block == (Block*)-1) { perror("mmap"); return 0; }
+ if (block == (Block *)-1) {
+ perror("mmap");
+ return nullptr;
+ }
lastmap = block;
lastmap_index = i;
@@ -143,10 +167,12 @@ const Block* BlockArray::at(size_t i)
void BlockArray::unmap()
{
if (lastmap) {
- int res = munmap((char*)lastmap, blocksize);
- if (res < 0) perror("munmap");
+ int res = munmap((char *)lastmap, blocksize);
+ if (res < 0) {
+ perror("munmap");
+ }
}
- lastmap = 0;
+ lastmap = nullptr;
lastmap_index = size_t(-1);
}
@@ -159,22 +185,25 @@ bool BlockArray::setHistorySize(size_t newsize)
{
// kDebug(1211) << "setHistorySize " << size << " " << newsize;
- if (size == newsize)
+ if (size == newsize) {
return false;
+ }
unmap();
if (!newsize) {
delete lastblock;
- lastblock = 0;
- if (ion >= 0) close(ion);
+ lastblock = nullptr;
+ if (ion >= 0) {
+ close(ion);
+ }
ion = -1;
current = size_t(-1);
return true;
}
if (!size) {
- FILE* tmp = tmpfile();
+ FILE * tmp = tmpfile();
if (!tmp) {
perror("konsole: cannot open temp file.\n");
} else {
@@ -184,10 +213,11 @@ bool BlockArray::setHistorySize(size_t newsize)
fclose(tmp);
}
}
- if (ion < 0)
+ if (ion < 0) {
return false;
+ }
- assert(!lastblock);
+ Q_ASSERT(!lastblock);
lastblock = new Block();
size = newsize;
@@ -207,38 +237,44 @@ bool BlockArray::setHistorySize(size_t newsize)
}
}
-void moveBlock(FILE *fion, int cursor, int newpos, char *buffer2)
+void moveBlock(FILE * fion, int cursor, int newpos, char * buffer2)
{
int res = fseek(fion, cursor * blocksize, SEEK_SET);
- if (res)
+ if (res) {
perror("fseek");
+ }
res = fread(buffer2, blocksize, 1, fion);
- if (res != 1)
+ if (res != 1) {
perror("fread");
+ }
res = fseek(fion, newpos * blocksize, SEEK_SET);
- if (res)
+ if (res) {
perror("fseek");
+ }
res = fwrite(buffer2, blocksize, 1, fion);
- if (res != 1)
+ if (res != 1) {
perror("fwrite");
+ }
// printf("moving block %d to %d\n", cursor, newpos);
}
void BlockArray::decreaseBuffer(size_t newsize)
{
- if (index < newsize) // still fits in whole
+ if (index < newsize) { // still fits in whole
return;
+ }
int offset = (current - (newsize - 1) + size) % size;
- if (!offset)
+ if (!offset) {
return;
+ }
- // The Block constructor could do somthing in future...
- char *buffer1 = new char[blocksize];
+ // The Block constructor could do something in future...
+ char * buffer1 = new char[blocksize];
- FILE *fion = fdopen(dup(ion), "w+b");
+ FILE * fion = fdopen(dup(ion), "w+b");
if (!fion) {
delete [] buffer1;
perror("fdopen/dup");
@@ -258,8 +294,9 @@ void BlockArray::decreaseBuffer(size_t newsize)
moveBlock(fion, oldpos, cursor, buffer1);
if (oldpos < newsize) {
cursor = oldpos;
- } else
+ } else {
cursor++;
+ }
}
current = newsize - 1;
@@ -273,16 +310,18 @@ void BlockArray::decreaseBuffer(size_t newsize)
void BlockArray::increaseBuffer()
{
- if (index < size) // not even wrapped once
+ if (index < size) { // not even wrapped once
return;
+ }
int offset = (current + size + 1) % size;
- if (!offset) // no moving needed
+ if (!offset) { // no moving needed
return;
+ }
- // The Block constructor could do somthing in future...
- char *buffer1 = new char[blocksize];
- char *buffer2 = new char[blocksize];
+ // The Block constructor could do something in future...
+ char * buffer1 = new char[blocksize];
+ char * buffer2 = new char[blocksize];
int runs = 1;
int bpr = size; // blocks per run
@@ -292,38 +331,40 @@ void BlockArray::increaseBuffer()
runs = offset;
}
- FILE *fion = fdopen(dup(ion), "w+b");
+ FILE * fion = fdopen(dup(ion), "w+b");
if (!fion) {
perror("fdopen/dup");
- delete [] buffer1;
- delete [] buffer2;
+ delete [] buffer1;
+ delete [] buffer2;
return;
}
int res;
- for (int i = 0; i < runs; i++)
- {
+ for (int i = 0; i < runs; i++) {
// free one block in chain
int firstblock = (offset + i) % size;
res = fseek(fion, firstblock * blocksize, SEEK_SET);
- if (res)
+ if (res) {
perror("fseek");
+ }
res = fread(buffer1, blocksize, 1, fion);
- if (res != 1)
+ if (res != 1) {
perror("fread");
+ }
int newpos = 0;
- for (int j = 1, cursor=firstblock; j < bpr; j++)
- {
+ for (int j = 1, cursor=firstblock; j < bpr; j++) {
cursor = (cursor + offset) % size;
newpos = (cursor - offset + size) % size;
moveBlock(fion, cursor, newpos, buffer2);
}
res = fseek(fion, i * blocksize, SEEK_SET);
- if (res)
+ if (res) {
perror("fseek");
+ }
res = fwrite(buffer1, blocksize, 1, fion);
- if (res != 1)
+ if (res != 1) {
perror("fwrite");
+ }
}
current = size - 1;
length = size;
diff --git a/qtermwidget/src/BlockArray.h b/qtermwidget/lib/BlockArray.h
similarity index 82%
rename from qtermwidget/src/BlockArray.h
rename to qtermwidget/lib/BlockArray.h
index ca47388..09158bd 100644
--- a/qtermwidget/src/BlockArray.h
+++ b/qtermwidget/lib/BlockArray.h
@@ -1,7 +1,7 @@
/*
This file is part of Konsole, an X terminal.
Copyright (C) 2000 by Stephan Kulow
-
+
Rewritten for QT4 by e_k , Copyright (C)2008
This program is free software; you can redistribute it and/or modify
@@ -27,14 +27,15 @@
//#error Do not use in KDE 2.1
-#define BlockSize (1 << 12)
-#define ENTRIES ((BlockSize - sizeof(size_t) ) / sizeof(unsigned char))
+#define QTERMWIDGET_BLOCKSIZE (1 << 12)
+#define ENTRIES ((QTERMWIDGET_BLOCKSIZE - sizeof(size_t) ) / sizeof(unsigned char))
-namespace Konsole
-{
+namespace Konsole {
struct Block {
- Block() { size = 0; }
+ Block() {
+ size = 0;
+ }
unsigned char data[ENTRIES];
size_t size;
};
@@ -58,24 +59,24 @@ public:
* adds the Block at the end of history.
* This may drop other blocks.
*
- * The ownership on the block is transfered.
+ * The ownership on the block is transferred.
* An unique index number is returned for accessing
* it later (if not yet dropped then)
*
* Note, that the block may be dropped completely
* if history is turned off.
*/
- size_t append(Block *block);
+ size_t append(Block * block);
/**
* gets the block at the index. Function may return
* 0 if the block isn't available any more.
*
* The returned block is strictly readonly as only
- * maped in memory - and will be invalid on the next
+ * mapped in memory - and will be invalid on the next
* operation on this class.
*/
- const Block *at(size_t index);
+ const Block * at(size_t index);
/**
* reorders blocks as needed. If newsize is null,
@@ -87,7 +88,7 @@ public:
size_t newBlock();
- Block *lastBlock() const;
+ Block * lastBlock() const;
/**
* Convenient function to set the size in KBytes
@@ -95,11 +96,15 @@ public:
*/
bool setSize(size_t newsize);
- size_t len() const { return length; }
+ size_t len() const {
+ return length;
+ }
bool has(size_t index) const;
- size_t getCurrent() const { return current; }
+ size_t getCurrent() const {
+ return current;
+ }
private:
void unmap();
@@ -111,9 +116,9 @@ private:
size_t current;
size_t index;
- Block *lastmap;
+ Block * lastmap;
size_t lastmap_index;
- Block *lastblock;
+ Block * lastblock;
int ion;
size_t length;
diff --git a/qtermwidget/src/Character.h b/qtermwidget/lib/Character.h
similarity index 74%
rename from qtermwidget/src/Character.h
rename to qtermwidget/lib/Character.h
index 0978ce5..c6e8362 100644
--- a/qtermwidget/src/Character.h
+++ b/qtermwidget/lib/Character.h
@@ -1,10 +1,8 @@
/*
This file is part of Konsole, KDE's terminal.
-
- Copyright (C) 2007 by Robert Knight
- Copyright (C) 1997,1998 by Lars Doelle
- Rewritten for QT4 by e_k , Copyright (C)2008
+ Copyright 2007-2008 by Robert Knight
+ Copyright 1997,1998 by Lars Doelle
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,7 +24,7 @@
#define CHARACTER_H
// Qt
-#include
+#include
// Local
#include "CharacterColor.h"
@@ -36,10 +34,10 @@ namespace Konsole
typedef unsigned char LineProperty;
-static const int LINE_DEFAULT = 0;
-static const int LINE_WRAPPED = (1 << 0);
-static const int LINE_DOUBLEWIDTH = (1 << 1);
-static const int LINE_DOUBLEHEIGHT = (1 << 2);
+static const int LINE_DEFAULT = 0;
+static const int LINE_WRAPPED = (1 << 0);
+static const int LINE_DOUBLEWIDTH = (1 << 1);
+static const int LINE_DOUBLEHEIGHT = (1 << 2);
#define DEFAULT_RENDITION 0
#define RE_BOLD (1 << 0)
@@ -47,8 +45,13 @@ static const int LINE_DOUBLEHEIGHT = (1 << 2);
#define RE_UNDERLINE (1 << 2)
#define RE_REVERSE (1 << 3) // Screen only
#define RE_INTENSIVE (1 << 3) // Widget only
-#define RE_CURSOR (1 << 4)
-#define RE_EXTENDED_CHAR (1 << 5)
+#define RE_ITALIC (1 << 4)
+#define RE_CURSOR (1 << 5)
+#define RE_EXTENDED_CHAR (1 << 6)
+#define RE_FAINT (1 << 7)
+#define RE_STRIKEOUT (1 << 8)
+#define RE_CONCEAL (1 << 9)
+#define RE_OVERLINE (1 << 10)
/**
* A single character in the terminal which consists of a unicode character
@@ -58,7 +61,7 @@ static const int LINE_DOUBLEHEIGHT = (1 << 2);
class Character
{
public:
- /**
+ /**
* Constructs a new character.
*
* @param _c The unicode character value of this character.
@@ -75,26 +78,30 @@ public:
union
{
/** The unicode character value for this character. */
- quint16 character;
- /**
+#if QT_VERSION >= 0x060000
+ char16_t character;
+#else
+ wchar_t character;
+#endif
+ /**
* Experimental addition which allows a single Character instance to contain more than
* one unicode character.
*
* charSequence is a hash code which can be used to look up the unicode
* character sequence in the ExtendedCharTable used to create the sequence.
*/
- quint16 charSequence;
+ quint16 charSequence;
};
/** A combination of RENDITION flags which specify options for drawing the character. */
quint8 rendition;
/** The foreground color used to draw this character. */
- CharacterColor foregroundColor;
+ CharacterColor foregroundColor;
/** The color used to draw this character's background. */
CharacterColor backgroundColor;
- /**
+ /**
* Returns true if this character has a transparent background when
* it is drawn with the specified @p palette.
*/
@@ -102,11 +109,16 @@ public:
/**
* Returns true if this character should always be drawn in bold when
* it is drawn with the specified @p palette, independent of whether
- * or not the character has the RE_BOLD rendition flag.
+ * or not the character has the RE_BOLD rendition flag.
*/
- bool isBold(const ColorEntry* base) const;
-
- /**
+ ColorEntry::FontWeight fontWeight(const ColorEntry* base) const;
+
+ /**
+ * returns true if the format (color, rendition flag) of the compared characters is equal
+ */
+ bool equalsFormat(const Character &other) const;
+
+ /**
* Compares two characters and returns true if they have the same unicode character value,
* rendition and colors.
*/
@@ -119,35 +131,45 @@ public:
};
inline bool operator == (const Character& a, const Character& b)
-{
- return a.character == b.character &&
- a.rendition == b.rendition &&
- a.foregroundColor == b.foregroundColor &&
+{
+ return a.character == b.character &&
+ a.rendition == b.rendition &&
+ a.foregroundColor == b.foregroundColor &&
a.backgroundColor == b.backgroundColor;
}
inline bool operator != (const Character& a, const Character& b)
{
- return a.character != b.character ||
- a.rendition != b.rendition ||
- a.foregroundColor != b.foregroundColor ||
+ return a.character != b.character ||
+ a.rendition != b.rendition ||
+ a.foregroundColor != b.foregroundColor ||
a.backgroundColor != b.backgroundColor;
}
inline bool Character::isTransparent(const ColorEntry* base) const
{
- return ((backgroundColor._colorSpace == COLOR_SPACE_DEFAULT) &&
+ return ((backgroundColor._colorSpace == COLOR_SPACE_DEFAULT) &&
base[backgroundColor._u+0+(backgroundColor._v?BASE_COLORS:0)].transparent)
- || ((backgroundColor._colorSpace == COLOR_SPACE_SYSTEM) &&
+ || ((backgroundColor._colorSpace == COLOR_SPACE_SYSTEM) &&
base[backgroundColor._u+2+(backgroundColor._v?BASE_COLORS:0)].transparent);
}
-inline bool Character::isBold(const ColorEntry* base) const
+inline bool Character::equalsFormat(const Character& other) const
{
- return ((backgroundColor._colorSpace == COLOR_SPACE_DEFAULT) &&
- base[backgroundColor._u+0+(backgroundColor._v?BASE_COLORS:0)].bold)
- || ((backgroundColor._colorSpace == COLOR_SPACE_SYSTEM) &&
- base[backgroundColor._u+2+(backgroundColor._v?BASE_COLORS:0)].bold);
+ return
+ backgroundColor==other.backgroundColor &&
+ foregroundColor==other.foregroundColor &&
+ rendition==other.rendition;
+}
+
+inline ColorEntry::FontWeight Character::fontWeight(const ColorEntry* base) const
+{
+ if (backgroundColor._colorSpace == COLOR_SPACE_DEFAULT)
+ return base[backgroundColor._u+0+(backgroundColor._v?BASE_COLORS:0)].fontWeight;
+ else if (backgroundColor._colorSpace == COLOR_SPACE_SYSTEM)
+ return base[backgroundColor._u+2+(backgroundColor._v?BASE_COLORS:0)].fontWeight;
+ else
+ return ColorEntry::UseCurrentFormat;
}
extern unsigned short vt100_graphics[32];
@@ -183,7 +205,7 @@ public:
* which was added to the table using createExtendedChar().
*
* @param hash The hash key returned by createExtendedChar()
- * @param length This variable is set to the length of the
+ * @param length This variable is set to the length of the
* character sequence.
*
* @return A unicode character sequence of size @p length.
@@ -195,7 +217,7 @@ public:
private:
// calculates the hash key of a sequence of unicode points of size 'length'
ushort extendedCharHash(ushort* unicodePoints , ushort length) const;
- // tests whether the entry in the table specified by 'hash' matches the
+ // tests whether the entry in the table specified by 'hash' matches the
// character sequence 'unicodePoints' of size 'length'
bool extendedCharMatch(ushort hash , ushort* unicodePoints , ushort length) const;
// internal, maps hash keys to character sequence buffers. The first ushort
@@ -205,6 +227,7 @@ private:
};
}
+Q_DECLARE_TYPEINFO(Konsole::Character, Q_MOVABLE_TYPE);
#endif // CHARACTER_H
diff --git a/qtermwidget/src/CharacterColor.h b/qtermwidget/lib/CharacterColor.h
similarity index 61%
rename from qtermwidget/src/CharacterColor.h
rename to qtermwidget/lib/CharacterColor.h
index 1b86674..25bbb0e 100644
--- a/qtermwidget/src/CharacterColor.h
+++ b/qtermwidget/lib/CharacterColor.h
@@ -1,10 +1,8 @@
/*
This file is part of Konsole, KDE's terminal.
-
- Copyright (C) 2007 by Robert Knight
- Copyright (C) 1997,1998 by Lars Doelle
- Rewritten for QT4 by e_k , Copyright (C)2008
+ Copyright 2007-2008 by Robert Knight
+ Copyright 1997,1998 by Lars Doelle
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,19 +24,22 @@
#define CHARACTERCOLOR_H
// Qt
-#include
+#include
+
+//#include
+#define KDE_NO_EXPORT
namespace Konsole
{
-/**
- * An entry in a terminal display's color palette.
+/**
+ * An entry in a terminal display's color palette.
*
* A color palette is an array of 16 ColorEntry instances which map
* system color indexes (from 0 to 15) into actual colors.
*
* Each entry can be set as bold, in which case any text
- * drawn using the color should be drawn in bold.
+ * drawn using the color should be drawn in bold.
*
* Each entry can also be transparent, in which case the terminal
* display should avoid drawing the background for any characters
@@ -47,44 +48,49 @@ namespace Konsole
class ColorEntry
{
public:
- /**
+ /** Specifies the weight to use when drawing text with this color. */
+ enum FontWeight
+ {
+ /** Always draw text in this color with a bold weight. */
+ Bold,
+ /** Always draw text in this color with a normal weight. */
+ Normal,
+ /**
+ * Use the current font weight set by the terminal application.
+ * This is the default behavior.
+ */
+ UseCurrentFormat
+ };
+
+ /**
* Constructs a new color palette entry.
*
* @param c The color value for this entry.
* @param tr Specifies that the color should be transparent when used as a background color.
- * @param b Specifies that text drawn with this color should be bold.
+ * @param weight Specifies the font weight to use when drawing text with this color.
*/
- ColorEntry(QColor c, bool tr, bool b) : color(c), transparent(tr), bold(b) {}
+ ColorEntry(QColor c, bool tr, FontWeight weight = UseCurrentFormat)
+ : color(c), transparent(tr), fontWeight(weight) {}
/**
* Constructs a new color palette entry with an undefined color, and
* with the transparent and bold flags set to false.
- */
- ColorEntry() : transparent(false), bold(false) {}
-
- /**
- * Sets the color, transparency and boldness of this color to those of @p rhs.
- */
- void operator=(const ColorEntry& rhs)
- {
- color = rhs.color;
- transparent = rhs.transparent;
- bold = rhs.bold;
- }
+ */
+ ColorEntry() : transparent(false), fontWeight(UseCurrentFormat) {}
/** The color value of this entry for display. */
QColor color;
- /**
- * If true character backgrounds using this color should be transparent.
+ /**
+ * If true character backgrounds using this color should be transparent.
* This is not applicable when the color is used to render text.
*/
bool transparent;
/**
- * If true characters drawn using this color should be bold.
+ * Specifies the font weight to use when drawing text with this color.
* This is not applicable when the color is used to draw a character's background.
*/
- bool bold;
+ FontWeight fontWeight;
};
@@ -102,25 +108,7 @@ public:
//a standard set of colors using black text on a white background.
//defined in TerminalDisplay.cpp
-static const ColorEntry base_color_table[TABLE_COLORS] =
-// The following are almost IBM standard color codes, with some slight
-// gamma correction for the dim colors to compensate for bright X screens.
-// It contains the 8 ansiterm/xterm colors in 2 intensities.
-{
- // Fixme: could add faint colors here, also.
- // normal
- ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
- ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
- ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
- ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
- ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
- // intensiv
- ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
- ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
- ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
- ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0xFF), 0, 0 ),
- ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
-};
+extern const ColorEntry base_color_table[TABLE_COLORS] KDE_NO_EXPORT;
/* CharacterColor is a union of the various color spaces.
@@ -152,16 +140,16 @@ class CharacterColor
friend class Character;
public:
- /** Constructs a new CharacterColor whoose color and color space are undefined. */
- CharacterColor()
- : _colorSpace(COLOR_SPACE_UNDEFINED),
- _u(0),
- _v(0),
- _w(0)
+ /** Constructs a new CharacterColor whose color and color space are undefined. */
+ CharacterColor()
+ : _colorSpace(COLOR_SPACE_UNDEFINED),
+ _u(0),
+ _v(0),
+ _w(0)
{}
- /**
- * Constructs a new CharacterColor using the specified @p colorSpace and with
+ /**
+ * Constructs a new CharacterColor using the specified @p colorSpace and with
* color value @p co
*
* The meaning of @p co depends on the @p colorSpace used.
@@ -170,10 +158,10 @@ public:
*
* TODO : Add documentation about available color spaces.
*/
- CharacterColor(quint8 colorSpace, int co)
- : _colorSpace(colorSpace),
- _u(0),
- _v(0),
+ CharacterColor(quint8 colorSpace, int co)
+ : _colorSpace(colorSpace),
+ _u(0),
+ _v(0),
_w(0)
{
switch (colorSpace)
@@ -185,7 +173,7 @@ public:
_u = co & 7;
_v = (co >> 3) & 1;
break;
- case COLOR_SPACE_256:
+ case COLOR_SPACE_256:
_u = co & 255;
break;
case COLOR_SPACE_RGB:
@@ -198,32 +186,32 @@ public:
}
}
- /**
+ /**
* Returns true if this character color entry is valid.
*/
- bool isValid()
+ bool isValid() const
{
return _colorSpace != COLOR_SPACE_UNDEFINED;
}
-
- /**
- * Toggles the value of this color between a normal system color and the corresponding intensive
- * system color.
- *
+
+ /**
+ * Set the value of this color from a normal system color to the corresponding intensive
+ * system color if it's not already an intensive system color.
+ *
* This is only applicable if the color is using the COLOR_SPACE_DEFAULT or COLOR_SPACE_SYSTEM
* color spaces.
*/
- void toggleIntensive();
+ void setIntensive();
- /**
- * Returns the color within the specified color @palette
+ /**
+ * Returns the color within the specified color @p palette
*
* The @p palette is only used if this color is one of the 16 system colors, otherwise
* it is ignored.
*/
QColor color(const ColorEntry* palette) const;
-
- /**
+
+ /**
* Compares two colors and returns true if they represent the same color value and
* use the same color space.
*/
@@ -237,35 +225,38 @@ public:
private:
quint8 _colorSpace;
- // bytes storing the character color
- quint8 _u;
- quint8 _v;
- quint8 _w;
+ // bytes storing the character color
+ quint8 _u;
+ quint8 _v;
+ quint8 _w;
};
inline bool operator == (const CharacterColor& a, const CharacterColor& b)
-{
- return *reinterpret_cast(&a._colorSpace) ==
- *reinterpret_cast(&b._colorSpace);
+{
+ return a._colorSpace == b._colorSpace &&
+ a._u == b._u &&
+ a._v == b._v &&
+ a._w == b._w;
}
-
inline bool operator != (const CharacterColor& a, const CharacterColor& b)
{
- return *reinterpret_cast(&a._colorSpace) !=
- *reinterpret_cast(&b._colorSpace);
+ return !operator==(a,b);
}
inline const QColor color256(quint8 u, const ColorEntry* base)
{
// 0.. 16: system colors
- if (u < 8) return base[u+2 ].color; u -= 8;
- if (u < 8) return base[u+2+BASE_COLORS].color; u -= 8;
+ if (u < 8) return base[u+2 ].color;
+ u -= 8;
+ if (u < 8) return base[u+2+BASE_COLORS].color;
+ u -= 8;
// 16..231: 6x6x6 rgb color cube
- if (u < 216) return QColor(255*((u/36)%6)/5,
- 255*((u/ 6)%6)/5,
- 255*((u/ 1)%6)/5); u -= 216;
-
+ if (u < 216) return QColor(((u/36)%6) ? (40*((u/36)%6)+55) : 0,
+ ((u/ 6)%6) ? (40*((u/ 6)%6)+55) : 0,
+ ((u/ 1)%6) ? (40*((u/ 1)%6)+55) : 0);
+ u -= 216;
+
// 232..255: gray, leaving out black and white
int gray = u*10+8; return QColor(gray,gray,gray);
}
@@ -277,7 +268,7 @@ inline QColor CharacterColor::color(const ColorEntry* base) const
case COLOR_SPACE_DEFAULT: return base[_u+0+(_v?BASE_COLORS:0)].color;
case COLOR_SPACE_SYSTEM: return base[_u+2+(_v?BASE_COLORS:0)].color;
case COLOR_SPACE_256: return color256(_u,base);
- case COLOR_SPACE_RGB: return QColor(_u,_v,_w);
+ case COLOR_SPACE_RGB: return {_u,_v,_w};
case COLOR_SPACE_UNDEFINED: return QColor();
}
@@ -286,11 +277,11 @@ inline QColor CharacterColor::color(const ColorEntry* base) const
return QColor();
}
-inline void CharacterColor::toggleIntensive()
+inline void CharacterColor::setIntensive()
{
if (_colorSpace == COLOR_SPACE_SYSTEM || _colorSpace == COLOR_SPACE_DEFAULT)
{
- _v = !_v;
+ _v = 1;
}
}
diff --git a/qtermwidget/lib/ColorScheme.cpp b/qtermwidget/lib/ColorScheme.cpp
new file mode 100644
index 0000000..032e931
--- /dev/null
+++ b/qtermwidget/lib/ColorScheme.cpp
@@ -0,0 +1,686 @@
+/*
+ This source file is part of Konsole, a terminal emulator.
+
+ Copyright 2007-2008 by Robert Knight
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+*/
+
+// Own
+#include "ColorScheme.h"
+#include "tools.h"
+
+// Qt
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#if QT_VERSION >= 0x060000
+#include
+#endif
+
+// KDE
+//#include
+//#include
+//#include
+//#include
+//#include
+//#include
+
+using namespace Konsole;
+
+const ColorEntry ColorScheme::defaultTable[TABLE_COLORS] =
+ // The following are almost IBM standard color codes, with some slight
+ // gamma correction for the dim colors to compensate for bright X screens.
+ // It contains the 8 ansiterm/xterm colors in 2 intensities.
+{
+ ColorEntry( QColor(0x00,0x00,0x00), false), ColorEntry(
+QColor(0xFF,0xFF,0xFF), true), // Dfore, Dback
+ ColorEntry( QColor(0x00,0x00,0x00), false), ColorEntry(
+QColor(0xB2,0x18,0x18), false), // Black, Red
+ ColorEntry( QColor(0x18,0xB2,0x18), false), ColorEntry(
+QColor(0xB2,0x68,0x18), false), // Green, Yellow
+ ColorEntry( QColor(0x18,0x18,0xB2), false), ColorEntry(
+QColor(0xB2,0x18,0xB2), false), // Blue, Magenta
+ ColorEntry( QColor(0x18,0xB2,0xB2), false), ColorEntry(
+QColor(0xB2,0xB2,0xB2), false), // Cyan, White
+ // intensive
+ ColorEntry( QColor(0x00,0x00,0x00), false), ColorEntry(
+QColor(0xFF,0xFF,0xFF), true),
+ ColorEntry( QColor(0x68,0x68,0x68), false), ColorEntry(
+QColor(0xFF,0x54,0x54), false),
+ ColorEntry( QColor(0x54,0xFF,0x54), false), ColorEntry(
+QColor(0xFF,0xFF,0x54), false),
+ ColorEntry( QColor(0x54,0x54,0xFF), false), ColorEntry(
+QColor(0xFF,0x54,0xFF), false),
+ ColorEntry( QColor(0x54,0xFF,0xFF), false), ColorEntry(
+QColor(0xFF,0xFF,0xFF), false)
+};
+
+const char* const ColorScheme::colorNames[TABLE_COLORS] =
+{
+ "Foreground",
+ "Background",
+ "Color0",
+ "Color1",
+ "Color2",
+ "Color3",
+ "Color4",
+ "Color5",
+ "Color6",
+ "Color7",
+ "ForegroundIntense",
+ "BackgroundIntense",
+ "Color0Intense",
+ "Color1Intense",
+ "Color2Intense",
+ "Color3Intense",
+ "Color4Intense",
+ "Color5Intense",
+ "Color6Intense",
+ "Color7Intense"
+};
+// dummy silently comment out the tr_NOOP
+#define tr_NOOP
+const char* const ColorScheme::translatedColorNames[TABLE_COLORS] =
+{
+ tr_NOOP("Foreground"),
+ tr_NOOP("Background"),
+ tr_NOOP("Color 1"),
+ tr_NOOP("Color 2"),
+ tr_NOOP("Color 3"),
+ tr_NOOP("Color 4"),
+ tr_NOOP("Color 5"),
+ tr_NOOP("Color 6"),
+ tr_NOOP("Color 7"),
+ tr_NOOP("Color 8"),
+ tr_NOOP("Foreground (Intense)"),
+ tr_NOOP("Background (Intense)"),
+ tr_NOOP("Color 1 (Intense)"),
+ tr_NOOP("Color 2 (Intense)"),
+ tr_NOOP("Color 3 (Intense)"),
+ tr_NOOP("Color 4 (Intense)"),
+ tr_NOOP("Color 5 (Intense)"),
+ tr_NOOP("Color 6 (Intense)"),
+ tr_NOOP("Color 7 (Intense)"),
+ tr_NOOP("Color 8 (Intense)")
+};
+
+ColorScheme::ColorScheme()
+{
+ _table = nullptr;
+ _randomTable = nullptr;
+ _opacity = 1.0;
+}
+ColorScheme::ColorScheme(const ColorScheme& other)
+ : _opacity(other._opacity)
+ ,_table(nullptr)
+ ,_randomTable(nullptr)
+{
+ setName(other.name());
+ setDescription(other.description());
+
+ if ( other._table != nullptr )
+ {
+ for ( int i = 0 ; i < TABLE_COLORS ; i++ )
+ setColorTableEntry(i,other._table[i]);
+ }
+
+ if ( other._randomTable != nullptr )
+ {
+ for ( int i = 0 ; i < TABLE_COLORS ; i++ )
+ {
+ const RandomizationRange& range = other._randomTable[i];
+ setRandomizationRange(i,range.hue,range.saturation,range.value);
+ }
+ }
+}
+ColorScheme::~ColorScheme()
+{
+ delete[] _table;
+ delete[] _randomTable;
+}
+
+void ColorScheme::setDescription(const QString& description) { _description = description; }
+QString ColorScheme::description() const { return _description; }
+
+void ColorScheme::setName(const QString& name) { _name = name; }
+QString ColorScheme::name() const { return _name; }
+
+void ColorScheme::setColorTableEntry(int index , const ColorEntry& entry)
+{
+ Q_ASSERT( index >= 0 && index < TABLE_COLORS );
+
+ if ( !_table )
+ {
+ _table = new ColorEntry[TABLE_COLORS];
+
+ for (int i=0;i= 0 && index < TABLE_COLORS );
+
+ ColorEntry entry = colorTable()[index];
+
+ if ( _randomTable != nullptr &&
+ !_randomTable[index].isNull() )
+ {
+ const RandomizationRange& range = _randomTable[index];
+
+
+ int hueDifference = range.hue ? QRandomGenerator::global()->bounded(range.hue) - range.hue/2 : 0;
+ int saturationDifference = range.saturation ? QRandomGenerator::global()->bounded(range.saturation) - range.saturation/2 : 0;
+ int valueDifference = range.value ? QRandomGenerator::global()->bounded(range.value) - range.value/2 : 0;
+
+ QColor& color = entry.color;
+
+ int newHue = qAbs( (color.hue() + hueDifference) % MAX_HUE );
+ int newValue = qMin( qAbs(color.value() + valueDifference) , 255 );
+ int newSaturation = qMin( qAbs(color.saturation() + saturationDifference) , 255 );
+
+ color.setHsv(newHue,newSaturation,newValue);
+ }
+
+ return entry;
+}
+void ColorScheme::getColorTable(ColorEntry* table) const
+{
+ for ( int i = 0 ; i < TABLE_COLORS ; i++ )
+ table[i] = colorEntry(i);
+}
+bool ColorScheme::randomizedBackgroundColor() const
+{
+ return _randomTable == nullptr ? false : !_randomTable[1].isNull();
+}
+void ColorScheme::setRandomizedBackgroundColor(bool randomize)
+{
+ // the hue of the background colour is allowed to be randomly
+ // adjusted as much as possible.
+ //
+ // the value and saturation are left alone to maintain read-ability
+ if ( randomize )
+ {
+ setRandomizationRange( 1 /* background color index */ , MAX_HUE , 255 , 0 );
+ }
+ else
+ {
+ if ( _randomTable )
+ setRandomizationRange( 1 /* background color index */ , 0 , 0 , 0 );
+ }
+}
+
+void ColorScheme::setRandomizationRange( int index , quint16 hue , quint8 saturation ,
+ quint8 value )
+{
+ Q_ASSERT( hue <= MAX_HUE );
+ Q_ASSERT( index >= 0 && index < TABLE_COLORS );
+
+ if ( _randomTable == nullptr )
+ _randomTable = new RandomizationRange[TABLE_COLORS];
+
+ _randomTable[index].hue = hue;
+ _randomTable[index].value = value;
+ _randomTable[index].saturation = saturation;
+}
+
+const ColorEntry* ColorScheme::colorTable() const
+{
+ if ( _table )
+ return _table;
+ else
+ return defaultTable;
+}
+QColor ColorScheme::foregroundColor() const
+{
+ return colorTable()[0].color;
+}
+QColor ColorScheme::backgroundColor() const
+{
+ return colorTable()[1].color;
+}
+bool ColorScheme::hasDarkBackground() const
+{
+ // value can range from 0 - 255, with larger values indicating higher brightness.
+ // so 127 is in the middle, anything less is deemed 'dark'
+ return backgroundColor().value() < 127;
+}
+void ColorScheme::setOpacity(qreal opacity) { _opacity = opacity; }
+qreal ColorScheme::opacity() const { return _opacity; }
+
+void ColorScheme::read(const QString & fileName)
+{
+ QSettings s(fileName, QSettings::IniFormat);
+ s.beginGroup(QLatin1String("General"));
+
+ _description = s.value(QLatin1String("Description"), QObject::tr("Un-named Color Scheme")).toString();
+ _opacity = s.value(QLatin1String("Opacity"),qreal(1.0)).toDouble();
+ s.endGroup();
+
+ for (int i=0 ; i < TABLE_COLORS ; i++)
+ {
+ readColorEntry(&s, i);
+ }
+}
+#if 0
+// implemented upstream - user apps
+void ColorScheme::read(KConfig& config)
+{
+ KConfigGroup configGroup = config.group("General");
+
+ QString description = configGroup.readEntry("Description", QObject::tr("Un-named Color Scheme"));
+
+ _description = tr(description.toUtf8());
+ _opacity = configGroup.readEntry("Opacity",qreal(1.0));
+
+ for (int i=0 ; i < TABLE_COLORS ; i++)
+ {
+ readColorEntry(config,i);
+ }
+}
+void ColorScheme::write(KConfig& config) const
+{
+ KConfigGroup configGroup = config.group("General");
+
+ configGroup.writeEntry("Description",_description);
+ configGroup.writeEntry("Opacity",_opacity);
+
+ for (int i=0 ; i < TABLE_COLORS ; i++)
+ {
+ RandomizationRange random = _randomTable != 0 ? _randomTable[i] : RandomizationRange();
+ writeColorEntry(config,colorNameForIndex(i),colorTable()[i],random);
+ }
+}
+#endif
+
+QString ColorScheme::colorNameForIndex(int index)
+{
+ Q_ASSERT( index >= 0 && index < TABLE_COLORS );
+
+ return QString::fromLatin1(colorNames[index]);
+}
+QString ColorScheme::translatedColorNameForIndex(int index)
+{
+ Q_ASSERT( index >= 0 && index < TABLE_COLORS );
+
+ return QString::fromLatin1(translatedColorNames[index]);
+}
+
+void ColorScheme::readColorEntry(QSettings * s , int index)
+{
+ QString colorName = colorNameForIndex(index);
+
+ s->beginGroup(colorName);
+
+ ColorEntry entry;
+
+ QVariant colorValue = s->value(QLatin1String("Color"));
+ QString colorStr;
+ int r, g, b;
+ bool ok = false;
+ // XXX: Undocumented(?) QSettings behavior: values with commas are parsed
+ // as QStringList and others QString
+#if QT_VERSION >= 0x060000
+ if (colorValue.typeId() == QMetaType::QStringList)
+#else
+ if (colorValue.type() == QVariant::StringList)
+#endif
+ {
+ QStringList rgbList = colorValue.toStringList();
+ colorStr = rgbList.join(QLatin1Char(','));
+ if (rgbList.count() == 3)
+ {
+ bool parse_ok;
+
+ ok = true;
+ r = rgbList[0].toInt(&parse_ok);
+ ok = ok && parse_ok && (r >= 0 && r <= 0xff);
+ g = rgbList[1].toInt(&parse_ok);
+ ok = ok && parse_ok && (g >= 0 && g <= 0xff);
+ b = rgbList[2].toInt(&parse_ok);
+ ok = ok && parse_ok && (b >= 0 && b <= 0xff);
+ }
+ }
+ else
+ {
+ colorStr = colorValue.toString();
+ QRegularExpression hexColorPattern(QLatin1String("^#[0-9a-f]{6}$"),
+ QRegularExpression::CaseInsensitiveOption);
+ if (hexColorPattern.match(colorStr).hasMatch())
+ {
+ // Parsing is always ok as already matched by the regexp
+#if QT_VERSION >= 0x060000
+ r = QStringView{colorStr}.mid(1, 2).toInt(nullptr, 16);
+ g = QStringView{colorStr}.mid(3, 2).toInt(nullptr, 16);
+ b = QStringView{colorStr}.mid(5, 2).toInt(nullptr, 16);
+#else
+ r = colorStr.midRef(1, 2).toInt(nullptr, 16);
+ g = colorStr.midRef(3, 2).toInt(nullptr, 16);
+ b = colorStr.midRef(5, 2).toInt(nullptr, 16);
+#endif
+ ok = true;
+ }
+ }
+ if (!ok)
+ {
+ qWarning().nospace() << "Invalid color value " << colorStr
+ << " for " << colorName << ". Fallback to black.";
+ r = g = b = 0;
+ }
+ entry.color = QColor(r, g, b);
+
+ entry.transparent = s->value(QLatin1String("Transparent"),false).toBool();
+
+ // Deprecated key from KDE 4.0 which set 'Bold' to true to force
+ // a color to be bold or false to use the current format
+ //
+ // TODO - Add a new tri-state key which allows for bold, normal or
+ // current format
+ if (s->contains(QLatin1String("Bold")))
+ entry.fontWeight = s->value(QLatin1String("Bold"),false).toBool() ? ColorEntry::Bold :
+ ColorEntry::UseCurrentFormat;
+
+ quint16 hue = s->value(QLatin1String("MaxRandomHue"),0).toInt();
+ quint8 value = s->value(QLatin1String("MaxRandomValue"),0).toInt();
+ quint8 saturation = s->value(QLatin1String("MaxRandomSaturation"),0).toInt();
+
+ setColorTableEntry( index , entry );
+
+ if ( hue != 0 || value != 0 || saturation != 0 )
+ setRandomizationRange( index , hue , saturation , value );
+
+ s->endGroup();
+}
+#if 0
+// implemented upstream - user apps
+void ColorScheme::writeColorEntry(KConfig& config , const QString& colorName, const ColorEntry& entry , const RandomizationRange& random) const
+{
+ KConfigGroup configGroup(&config,colorName);
+
+ configGroup.writeEntry("Color",entry.color);
+ configGroup.writeEntry("Transparency",(bool)entry.transparent);
+ if (entry.fontWeight != ColorEntry::UseCurrentFormat)
+ {
+ configGroup.writeEntry("Bold",entry.fontWeight == ColorEntry::Bold);
+ }
+
+ // record randomization if this color has randomization or
+ // if one of the keys already exists
+ if ( !random.isNull() || configGroup.hasKey("MaxRandomHue") )
+ {
+ configGroup.writeEntry("MaxRandomHue",(int)random.hue);
+ configGroup.writeEntry("MaxRandomValue",(int)random.value);
+ configGroup.writeEntry("MaxRandomSaturation",(int)random.saturation);
+ }
+}
+#endif
+
+//
+// Work In Progress - A color scheme for use on KDE setups for users
+// with visual disabilities which means that they may have trouble
+// reading text with the supplied color schemes.
+//
+// This color scheme uses only the 'safe' colors defined by the
+// KColorScheme class.
+//
+// A complication this introduces is that each color provided by
+// KColorScheme is defined as a 'background' or 'foreground' color.
+// Only foreground colors are allowed to be used to render text and
+// only background colors are allowed to be used for backgrounds.
+//
+// The ColorEntry and TerminalDisplay classes do not currently
+// support this restriction.
+//
+// Requirements:
+// - A color scheme which uses only colors from the KColorScheme class
+// - Ability to restrict which colors the TerminalDisplay widget
+// uses as foreground and background color
+// - Make use of KGlobalSettings::allowDefaultBackgroundImages() as
+// a hint to determine whether this accessible color scheme should
+// be used by default.
+//
+//
+// -- Robert Knight 21/07/2007
+//
+AccessibleColorScheme::AccessibleColorScheme()
+ : ColorScheme()
+{
+#if 0
+// It's not finished in konsole and it breaks Qt4 compilation as well
+ // basic attributes
+ setName("accessible");
+ setDescription(QObject::tr("Accessible Color Scheme"));
+
+ // setup colors
+ const int ColorRoleCount = 8;
+
+ const KColorScheme colorScheme(QPalette::Active);
+
+ QBrush colors[ColorRoleCount] =
+ {
+ colorScheme.foreground( colorScheme.NormalText ),
+ colorScheme.background( colorScheme.NormalBackground ),
+
+ colorScheme.foreground( colorScheme.InactiveText ),
+ colorScheme.foreground( colorScheme.ActiveText ),
+ colorScheme.foreground( colorScheme.LinkText ),
+ colorScheme.foreground( colorScheme.VisitedText ),
+ colorScheme.foreground( colorScheme.NegativeText ),
+ colorScheme.foreground( colorScheme.NeutralText )
+ };
+
+ for ( int i = 0 ; i < TABLE_COLORS ; i++ )
+ {
+ ColorEntry entry;
+ entry.color = colors[ i % ColorRoleCount ].color();
+
+ setColorTableEntry( i , entry );
+ }
+#endif
+}
+
+ColorSchemeManager::ColorSchemeManager()
+ : _haveLoadedAll(false)
+{
+}
+ColorSchemeManager::~ColorSchemeManager()
+{
+ QHashIterator iter(_colorSchemes);
+ while (iter.hasNext())
+ {
+ iter.next();
+ delete iter.value();
+ }
+}
+void ColorSchemeManager::loadAllColorSchemes()
+{
+ //qDebug() << "loadAllColorSchemes";
+ int failed = 0;
+
+ QList nativeColorSchemes = listColorSchemes();
+ QListIterator nativeIter(nativeColorSchemes);
+ while ( nativeIter.hasNext() )
+ {
+ if ( !loadColorScheme( nativeIter.next() ) )
+ failed++;
+ }
+
+ /*if ( failed > 0 )
+ qDebug() << "failed to load " << failed << " color schemes.";*/
+
+ _haveLoadedAll = true;
+}
+QList ColorSchemeManager::allColorSchemes()
+{
+ if ( !_haveLoadedAll )
+ {
+ loadAllColorSchemes();
+ }
+
+ return _colorSchemes.values();
+}
+#if 0
+void ColorSchemeManager::addColorScheme(ColorScheme* scheme)
+{
+ _colorSchemes.insert(scheme->name(),scheme);
+
+ // save changes to disk
+ QString path = KGlobal::dirs()->saveLocation("data","konsole/") + scheme->name() + ".colorscheme";
+ KConfig config(path , KConfig::NoGlobals);
+
+ scheme->write(config);
+}
+#endif
+
+bool ColorSchemeManager::loadCustomColorScheme(const QString& path)
+{
+ if (path.endsWith(QLatin1String(".colorscheme")))
+ return loadColorScheme(path);
+
+ return false;
+}
+
+void ColorSchemeManager::addCustomColorSchemeDir(const QString& custom_dir)
+{
+ add_custom_color_scheme_dir(custom_dir);
+}
+
+bool ColorSchemeManager::loadColorScheme(const QString& filePath)
+{
+ if ( !filePath.endsWith(QLatin1String(".colorscheme")) || !QFile::exists(filePath) )
+ return false;
+
+ QFileInfo info(filePath);
+
+ const QString& schemeName = info.baseName();
+
+ ColorScheme* scheme = new ColorScheme();
+ scheme->setName(schemeName);
+ scheme->read(filePath);
+
+ if (scheme->name().isEmpty())
+ {
+ //qDebug() << "Color scheme in" << filePath << "does not have a valid name and was not loaded.";
+ delete scheme;
+ return false;
+ }
+
+ if ( !_colorSchemes.contains(schemeName) )
+ {
+ _colorSchemes.insert(schemeName,scheme);
+ }
+ else
+ {
+ /*qDebug() << "color scheme with name" << schemeName << "has already been" <<
+ "found, ignoring.";*/
+
+ delete scheme;
+ }
+
+ return true;
+}
+QList ColorSchemeManager::listColorSchemes()
+{
+ QList ret;
+ for (const QString &scheme_dir : get_color_schemes_dirs())
+ {
+ const QString dname(scheme_dir);
+ QDir dir(dname);
+ QStringList filters;
+ filters << QLatin1String("*.colorscheme");
+ dir.setNameFilters(filters);
+ const QStringList list = dir.entryList(filters);
+ for (const QString &i : list)
+ ret << dname + QLatin1Char('/') + i;
+ }
+ return ret;
+// return KGlobal::dirs()->findAllResources("data",
+// "konsole/*.colorscheme",
+// KStandardDirs::NoDuplicates);
+}
+const ColorScheme ColorSchemeManager::_defaultColorScheme;
+const ColorScheme* ColorSchemeManager::defaultColorScheme() const
+{
+ return &_defaultColorScheme;
+}
+bool ColorSchemeManager::deleteColorScheme(const QString& name)
+{
+ Q_ASSERT( _colorSchemes.contains(name) );
+
+ // lookup the path and delete
+ QString path = findColorSchemePath(name);
+ if ( QFile::remove(path) )
+ {
+ _colorSchemes.remove(name);
+ return true;
+ }
+ else
+ {
+ //qDebug() << "Failed to remove color scheme -" << path;
+ return false;
+ }
+}
+QString ColorSchemeManager::findColorSchemePath(const QString& name) const
+{
+// QString path = KStandardDirs::locate("data","konsole/"+name+".colorscheme");
+ const QStringList dirs = get_color_schemes_dirs();
+ if ( dirs.isEmpty() )
+ return QString();
+
+ const QString dir = dirs.first();
+ QString path(dir + QLatin1Char('/')+ name + QLatin1String(".colorscheme"));
+ if ( !path.isEmpty() )
+ return path;
+
+ //path = KStandardDirs::locate("data","konsole/"+name+".schema");
+ path = dir + QLatin1Char('/')+ name + QLatin1String(".schema");
+
+ return path;
+}
+const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
+{
+ if ( name.isEmpty() )
+ return defaultColorScheme();
+
+ if ( _colorSchemes.contains(name) )
+ return _colorSchemes[name];
+ else
+ {
+ // look for this color scheme
+ QString path = findColorSchemePath(name);
+ if ( !path.isEmpty() && loadColorScheme(path) )
+ {
+ return findColorScheme(name);
+ }
+
+ //qDebug() << "Could not find color scheme - " << name;
+
+ return nullptr;
+ }
+}
+Q_GLOBAL_STATIC(ColorSchemeManager, theColorSchemeManager)
+ColorSchemeManager* ColorSchemeManager::instance()
+{
+ return theColorSchemeManager;
+}
diff --git a/qtermwidget/lib/ColorScheme.h b/qtermwidget/lib/ColorScheme.h
new file mode 100644
index 0000000..15ceb4d
--- /dev/null
+++ b/qtermwidget/lib/ColorScheme.h
@@ -0,0 +1,325 @@
+/*
+ This source file is part of Konsole, a terminal emulator.
+
+ Copyright 2007-2008 by Robert Knight
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+*/
+
+#ifndef COLORSCHEME_H
+#define COLORSCHEME_H
+
+// Qt
+#include
+#include
+#include
+#include
+#include
+#include
+
+// Konsole
+#include "CharacterColor.h"
+
+class QIODevice;
+//class KConfig;
+
+namespace Konsole
+{
+
+/**
+ * Represents a color scheme for a terminal display.
+ *
+ * The color scheme includes the palette of colors used to draw the text and character backgrounds
+ * in the display and the opacity level of the display background.
+ */
+class ColorScheme
+{
+public:
+ /**
+ * Constructs a new color scheme which is initialised to the default color set
+ * for Konsole.
+ */
+ ColorScheme();
+ ColorScheme(const ColorScheme& other);
+ ~ColorScheme();
+
+ /** Sets the descriptive name of the color scheme. */
+ void setDescription(const QString& description);
+ /** Returns the descriptive name of the color scheme. */
+ QString description() const;
+
+ /** Sets the name of the color scheme */
+ void setName(const QString& name);
+ /** Returns the name of the color scheme */
+ QString name() const;
+
+#if 0
+// Implemented upstream - in user apps
+ /** Reads the color scheme from the specified configuration source */
+ void read(KConfig& config);
+ /** Writes the color scheme to the specified configuration source */
+ void write(KConfig& config) const;
+#endif
+ void read(const QString & filename);
+
+ /** Sets a single entry within the color palette. */
+ void setColorTableEntry(int index , const ColorEntry& entry);
+
+ /**
+ * Copies the color entries which form the palette for this color scheme
+ * into @p table. @p table should be an array with TABLE_COLORS entries.
+ *
+ * @param table Array into which the color entries for this color scheme
+ * are copied.
+ * @param randomSeed Color schemes may allow certain colors in their
+ * palette to be randomized. The seed is used to pick the random color.
+ */
+ void getColorTable(ColorEntry* table) const;
+
+ /**
+ * Retrieves a single color entry from the table.
+ *
+ * See getColorTable()
+ */
+ ColorEntry colorEntry(int index) const;
+
+ /**
+ * Convenience method. Returns the
+ * foreground color for this scheme,
+ * this is the primary color used to draw the
+ * text in this scheme.
+ */
+ QColor foregroundColor() const;
+ /**
+ * Convenience method. Returns the background color for
+ * this scheme, this is the primary color used to
+ * draw the terminal background in this scheme.
+ */
+ QColor backgroundColor() const;
+
+ /**
+ * Returns true if this color scheme has a dark background.
+ * The background color is said to be dark if it has a value of less than 127
+ * in the HSV color space.
+ */
+ bool hasDarkBackground() const;
+
+ /**
+ * Sets the opacity level of the display background. @p opacity ranges
+ * between 0 (completely transparent background) and 1 (completely
+ * opaque background).
+ *
+ * Defaults to 1.
+ *
+ * TODO: More documentation
+ */
+ void setOpacity(qreal opacity);
+ /**
+ * Returns the opacity level for this color scheme, see setOpacity()
+ * TODO: More documentation
+ */
+ qreal opacity() const;
+
+ /**
+ * Enables randomization of the background color. This will cause
+ * the palette returned by getColorTable() and colorEntry() to
+ * be adjusted depending on the value of the random seed argument
+ * to them.
+ */
+ void setRandomizedBackgroundColor(bool randomize);
+
+ /** Returns true if the background color is randomized. */
+ bool randomizedBackgroundColor() const;
+
+ static QString colorNameForIndex(int index);
+ static QString translatedColorNameForIndex(int index);
+
+private:
+ // specifies how much a particular color can be randomized by
+ class RandomizationRange
+ {
+ public:
+ RandomizationRange() : hue(0) , saturation(0) , value(0) {}
+
+ bool isNull() const
+ {
+ return ( hue == 0 && saturation == 0 && value == 0 );
+ }
+
+ quint16 hue;
+ quint8 saturation;
+ quint8 value;
+ };
+
+ // returns the active color table. if none has been set specifically,
+ // this is the default color table.
+ const ColorEntry* colorTable() const;
+
+#if 0
+// implemented upstream - user apps
+ // reads a single colour entry from a KConfig source
+ // and sets the palette entry at 'index' to the entry read.
+ void readColorEntry(KConfig& config , int index);
+ // writes a single colour entry to a KConfig source
+ void writeColorEntry(KConfig& config , const QString& colorName, const ColorEntry& entry,const RandomizationRange& range) const;
+#endif
+ void readColorEntry(QSettings *s, int index);
+
+ // sets the amount of randomization allowed for a particular color
+ // in the palette. creates the randomization table if
+ // it does not already exist
+ void setRandomizationRange( int index , quint16 hue , quint8 saturation , quint8 value );
+
+ QString _description;
+ QString _name;
+ qreal _opacity;
+ ColorEntry* _table; // pointer to custom color table or 0 if the default
+ // color scheme is being used
+
+
+ static const quint16 MAX_HUE = 340;
+
+ RandomizationRange* _randomTable; // pointer to randomization table or 0
+ // if no colors in the color scheme support
+ // randomization
+
+ static const char* const colorNames[TABLE_COLORS];
+ static const char* const translatedColorNames[TABLE_COLORS];
+
+ static const ColorEntry defaultTable[]; // table of default color entries
+};
+
+/**
+ * A color scheme which uses colors from the standard KDE color palette.
+ *
+ * This is designed primarily for the benefit of users who are using specially
+ * designed colors.
+ *
+ * TODO Implement and make it the default on systems with specialized KDE
+ * color schemes.
+ */
+class AccessibleColorScheme : public ColorScheme
+{
+public:
+ AccessibleColorScheme();
+};
+
+/**
+ * Manages the color schemes available for use by terminal displays.
+ * See ColorScheme
+ */
+class ColorSchemeManager
+{
+public:
+
+ /**
+ * Constructs a new ColorSchemeManager and loads the list
+ * of available color schemes.
+ *
+ * The color schemes themselves are not loaded until they are first
+ * requested via a call to findColorScheme()
+ */
+ ColorSchemeManager();
+ /**
+ * Destroys the ColorSchemeManager and saves any modified color schemes to disk.
+ */
+ ~ColorSchemeManager();
+
+ /**
+ * Returns the default color scheme for Konsole
+ */
+ const ColorScheme* defaultColorScheme() const;
+
+ /**
+ * Returns the color scheme with the given name or 0 if no
+ * scheme with that name exists. If @p name is empty, the
+ * default color scheme is returned.
+ *
+ * The first time that a color scheme with a particular name is
+ * requested, the configuration information is loaded from disk.
+ */
+ const ColorScheme* findColorScheme(const QString& name);
+
+#if 0
+ /**
+ * Adds a new color scheme to the manager. If @p scheme has the same name as
+ * an existing color scheme, it replaces the existing scheme.
+ *
+ * TODO - Ensure the old color scheme gets deleted
+ */
+ void addColorScheme(ColorScheme* scheme);
+#endif
+ /**
+ * Deletes a color scheme. Returns true on successful deletion or false otherwise.
+ */
+ bool deleteColorScheme(const QString& name);
+
+ /**
+ * Returns a list of the all the available color schemes.
+ * This may be slow when first called because all of the color
+ * scheme resources on disk must be located, read and parsed.
+ *
+ * Subsequent calls will be inexpensive.
+ */
+ QList allColorSchemes();
+
+ /** Returns the global color scheme manager instance. */
+ static ColorSchemeManager* instance();
+
+ /** @brief Loads a custom color scheme under given \em path.
+ *
+ * The \em path may refer to either KDE 4 .colorscheme or KDE 3
+ * .schema file
+ *
+ * The loaded color scheme is available under the name equal to
+ * the base name of the \em path via the allColorSchemes() and
+ * findColorScheme() methods after this call if loaded successfully.
+ *
+ * @param[in] path The path to KDE 4 .colorscheme or KDE 3 .schema.
+ * @return Whether the color scheme is loaded successfully.
+ */
+ bool loadCustomColorScheme(const QString& path);
+
+ /**
+ * @brief Allows to add a custom location of color schemes.
+ *
+ * @param[in] custom_dir Custom location of color schemes (must end with /).
+ */
+ void addCustomColorSchemeDir(const QString& custom_dir);
+
+private:
+ // loads a color scheme from a KDE 4+ .colorscheme file
+ bool loadColorScheme(const QString& path);
+ // returns a list of paths of color schemes in the KDE 4+ .colorscheme file format
+ QList listColorSchemes();
+ // loads all of the color schemes
+ void loadAllColorSchemes();
+ // finds the path of a color scheme
+ QString findColorSchemePath(const QString& name) const;
+
+ QHash _colorSchemes;
+ QSet _modifiedSchemes;
+
+ bool _haveLoadedAll;
+
+ static const ColorScheme _defaultColorScheme;
+};
+
+}
+
+Q_DECLARE_METATYPE(const Konsole::ColorScheme*)
+
+#endif //COLORSCHEME_H
diff --git a/qtermwidget/lib/ColorTables.h b/qtermwidget/lib/ColorTables.h
new file mode 100644
index 0000000..57b0bd1
--- /dev/null
+++ b/qtermwidget/lib/ColorTables.h
@@ -0,0 +1,55 @@
+#ifndef _COLOR_TABLE_H
+#define _COLOR_TABLE_H
+
+#include "CharacterColor.h"
+
+//using namespace Konsole;
+#if 0
+static const ColorEntry whiteonblack_color_table[TABLE_COLORS] = {
+ // normal
+ ColorEntry(QColor(0xFF,0xFF,0xFF), false ), ColorEntry( QColor(0x00,0x00,0x00), true ), // Dfore, Dback
+ ColorEntry(QColor(0x00,0x00,0x00), false ), ColorEntry( QColor(0xB2,0x18,0x18), false ), // Black, Red
+ ColorEntry(QColor(0x18,0xB2,0x18), false ), ColorEntry( QColor(0xB2,0x68,0x18), false ), // Green, Yellow
+ ColorEntry(QColor(0x18,0x18,0xB2), false ), ColorEntry( QColor(0xB2,0x18,0xB2), false ), // Blue, Magenta
+ ColorEntry(QColor(0x18,0xB2,0xB2), false ), ColorEntry( QColor(0xB2,0xB2,0xB2), false ), // Cyan, White
+ // intensiv
+ ColorEntry(QColor(0x00,0x00,0x00), false ), ColorEntry( QColor(0xFF,0xFF,0xFF), true ),
+ ColorEntry(QColor(0x68,0x68,0x68), false ), ColorEntry( QColor(0xFF,0x54,0x54), false ),
+ ColorEntry(QColor(0x54,0xFF,0x54), false ), ColorEntry( QColor(0xFF,0xFF,0x54), false ),
+ ColorEntry(QColor(0x54,0x54,0xFF), false ), ColorEntry( QColor(0xFF,0x54,0xFF), false ),
+ ColorEntry(QColor(0x54,0xFF,0xFF), false ), ColorEntry( QColor(0xFF,0xFF,0xFF), false )
+};
+
+static const ColorEntry greenonblack_color_table[TABLE_COLORS] = {
+ ColorEntry(QColor( 24, 240, 24), false), ColorEntry(QColor( 0, 0, 0), true),
+ ColorEntry(QColor( 0, 0, 0), false), ColorEntry(QColor( 178, 24, 24), false),
+ ColorEntry(QColor( 24, 178, 24), false), ColorEntry(QColor( 178, 104, 24), false),
+ ColorEntry(QColor( 24, 24, 178), false), ColorEntry(QColor( 178, 24, 178), false),
+ ColorEntry(QColor( 24, 178, 178), false), ColorEntry(QColor( 178, 178, 178), false),
+ // intensive colors
+ ColorEntry(QColor( 24, 240, 24), false ), ColorEntry(QColor( 0, 0, 0), true ),
+ ColorEntry(QColor( 104, 104, 104), false ), ColorEntry(QColor( 255, 84, 84), false ),
+ ColorEntry(QColor( 84, 255, 84), false ), ColorEntry(QColor( 255, 255, 84), false ),
+ ColorEntry(QColor( 84, 84, 255), false ), ColorEntry(QColor( 255, 84, 255), false ),
+ ColorEntry(QColor( 84, 255, 255), false ), ColorEntry(QColor( 255, 255, 255), false )
+};
+
+static const ColorEntry blackonlightyellow_color_table[TABLE_COLORS] = {
+ ColorEntry(QColor( 0, 0, 0), false), ColorEntry(QColor( 255, 255, 221), true),
+ ColorEntry(QColor( 0, 0, 0), false), ColorEntry(QColor( 178, 24, 24), false),
+ ColorEntry(QColor( 24, 178, 24), false), ColorEntry(QColor( 178, 104, 24), false),
+ ColorEntry(QColor( 24, 24, 178), false), ColorEntry(QColor( 178, 24, 178), false),
+ ColorEntry(QColor( 24, 178, 178), false), ColorEntry(QColor( 178, 178, 178), false),
+ ColorEntry(QColor( 0, 0, 0), false), ColorEntry(QColor( 255, 255, 221), true),
+ ColorEntry(QColor(104, 104, 104), false), ColorEntry(QColor( 255, 84, 84), false),
+ ColorEntry(QColor( 84, 255, 84), false), ColorEntry(QColor( 255, 255, 84), false),
+ ColorEntry(QColor( 84, 84, 255), false), ColorEntry(QColor( 255, 84, 255), false),
+ ColorEntry(QColor( 84, 255, 255), false), ColorEntry(QColor( 255, 255, 255), false)
+};
+
+
+#endif
+
+
+#endif
+
diff --git a/qtermwidget/src/DefaultTranslatorText.h b/qtermwidget/lib/DefaultTranslatorText.h
similarity index 100%
rename from qtermwidget/src/DefaultTranslatorText.h
rename to qtermwidget/lib/DefaultTranslatorText.h
diff --git a/qtermwidget/src/Emulation.cpp b/qtermwidget/lib/Emulation.cpp
similarity index 58%
rename from qtermwidget/src/Emulation.cpp
rename to qtermwidget/lib/Emulation.cpp
index e767a42..0b3082f 100644
--- a/qtermwidget/src/Emulation.cpp
+++ b/qtermwidget/lib/Emulation.cpp
@@ -1,11 +1,7 @@
/*
- This file is part of Konsole, an X terminal.
-
- Copyright (C) 2007 Robert Knight
- Copyright (C) 1997,1998 by Lars Doelle
- Copyright (C) 1996 by Matthias Ettrich
-
- Rewritten for QT4 by e_k , Copyright (C)2008
+ Copyright 2007-2008 Robert Knight
+ Copyright 1997,1998 by Lars Doelle
+ Copyright 1996 by Matthias Ettrich
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -27,21 +23,31 @@
#include "Emulation.h"
// System
-#include
-#include
-#include
+#include
+#include
#include
+#include
// Qt
-#include
-#include
-#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
+#include
+#if QT_VERSION >= 0x060000
+#include
+#include
+#else
+#include
+#endif
+#include
+#include
-#include
+#include
+//TODO REMOVE THIS
+#include
+
+// KDE
+//#include
// Konsole
#include "KeyboardTranslator.h"
@@ -51,25 +57,14 @@
using namespace Konsole;
-/* ------------------------------------------------------------------------- */
-/* */
-/* Emulation */
-/* */
-/* ------------------------------------------------------------------------- */
-
-//#define CNTL(c) ((c)-'@')
-
-/*!
-*/
-
Emulation::Emulation() :
- _currentScreen(0),
- _codec(0),
- _decoder(0),
- _keyTranslator(0),
- _usesMouse(false)
+ _currentScreen(nullptr),
+ _codec(nullptr),
+ _decoder(nullptr),
+ _keyTranslator(nullptr),
+ _usesMouse(false),
+ _bracketedPasteMode(false)
{
-
// create screens with a default size
_screen[0] = new Screen(40,80);
_screen[1] = new Screen(40,80);
@@ -77,10 +72,17 @@ Emulation::Emulation() :
QObject::connect(&_bulkTimer1, SIGNAL(timeout()), this, SLOT(showBulk()) );
QObject::connect(&_bulkTimer2, SIGNAL(timeout()), this, SLOT(showBulk()) );
-
+
// listen for mouse status changes
- connect( this , SIGNAL(programUsesMouseChanged(bool)) ,
- SLOT(usesMouseChanged(bool)) );
+ connect(this , SIGNAL(programUsesMouseChanged(bool)) ,
+ SLOT(usesMouseChanged(bool)));
+ connect(this , SIGNAL(programBracketedPasteModeChanged(bool)) ,
+ SLOT(bracketedPasteModeChanged(bool)));
+
+ connect(this, &Emulation::cursorChanged, this, [this] (KeyboardCursorShape cursorShape, bool blinkingCursorEnabled) {
+ emit titleChanged( 50, QString(QLatin1String("CursorShape=%1;BlinkingCursorEnabled=%2"))
+ .arg(static_cast(cursorShape)).arg(blinkingCursorEnabled) );
+ });
}
bool Emulation::programUsesMouse() const
@@ -93,6 +95,16 @@ void Emulation::usesMouseChanged(bool usesMouse)
_usesMouse = usesMouse;
}
+bool Emulation::programBracketedPasteMode() const
+{
+ return _bracketedPasteMode;
+}
+
+void Emulation::bracketedPasteModeChanged(bool bracketedPasteMode)
+{
+ _bracketedPasteMode = bracketedPasteMode;
+}
+
ScreenWindow* Emulation::createWindow()
{
ScreenWindow* window = new ScreenWindow();
@@ -104,12 +116,15 @@ ScreenWindow* Emulation::createWindow()
connect(this , SIGNAL(outputChanged()),
window , SLOT(notifyOutputChanged()) );
+
+ connect(this, &Emulation::handleCommandFromKeyboard,
+ window, &ScreenWindow::handleCommandFromKeyboard);
+ connect(this, &Emulation::outputFromKeypressEvent,
+ window, &ScreenWindow::scrollToEnd);
+
return window;
}
-/*!
-*/
-
Emulation::~Emulation()
{
QListIterator windowIter(_windows);
@@ -124,23 +139,15 @@ Emulation::~Emulation()
delete _decoder;
}
-/*! change between primary and alternate _screen
-*/
-
void Emulation::setScreen(int n)
{
Screen *old = _currentScreen;
- _currentScreen = _screen[n&1];
- if (_currentScreen != old)
+ _currentScreen = _screen[n & 1];
+ if (_currentScreen != old)
{
- old->setBusySelecting(false);
-
- // tell all windows onto this emulation to switch to the newly active _screen
- QListIterator windowIter(_windows);
- while ( windowIter.hasNext() )
- {
- windowIter.next()->setScreen(_currentScreen);
- }
+ // tell all windows onto this emulation to switch to the newly active screen
+ for(ScreenWindow* window : qAsConst(_windows))
+ window->setScreen(_currentScreen);
}
}
@@ -155,16 +162,18 @@ void Emulation::setHistory(const HistoryType& t)
showBulk();
}
-const HistoryType& Emulation::history()
+const HistoryType& Emulation::history() const
{
return _screen[0]->getScroll();
}
void Emulation::setCodec(const QTextCodec * qtc)
{
- Q_ASSERT( qtc );
+ if (qtc)
+ _codec = qtc;
+ else
+ setCodec(LocaleCodec);
- _codec = qtc;
delete _decoder;
_decoder = _codec->makeDecoder();
@@ -182,63 +191,45 @@ void Emulation::setCodec(EmulationCodec codec)
void Emulation::setKeyBindings(const QString& name)
{
_keyTranslator = KeyboardTranslatorManager::instance()->findTranslator(name);
+ if (!_keyTranslator)
+ {
+ _keyTranslator = KeyboardTranslatorManager::instance()->defaultTranslator();
+ }
}
-QString Emulation::keyBindings()
+QString Emulation::keyBindings() const
{
return _keyTranslator->name();
}
-
-// Interpreting Codes ---------------------------------------------------------
-
-/*
- This section deals with decoding the incoming character stream.
- Decoding means here, that the stream is first separated into `tokens'
- which are then mapped to a `meaning' provided as operations by the
- `Screen' class.
-*/
-
-/*!
-*/
-
-void Emulation::receiveChar(int c)
+void Emulation::receiveChar(wchar_t c)
// process application unicode input to terminal
// this is a trivial scanner
{
+ qDebug() << "Emulation::receiveChar: character " << c;
c &= 0xff;
+ qDebug() << "Emulation::receiveChar (after &=): character " << c;
switch (c)
{
- case '\b' : _currentScreen->BackSpace(); break;
- case '\t' : _currentScreen->Tabulate(); break;
- case '\n' : _currentScreen->NewLine(); break;
- case '\r' : _currentScreen->Return(); break;
+ case '\b' : _currentScreen->backspace(); break;
+ case '\t' : _currentScreen->tab(); break;
+ case '\n' : _currentScreen->newLine(); break;
+ case '\r' : _currentScreen->toStartOfLine(); break;
case 0x07 : emit stateSet(NOTIFYBELL);
break;
- default : _currentScreen->ShowCharacter(c); break;
+ default : _currentScreen->displayCharacter(c); break;
};
}
-/* ------------------------------------------------------------------------- */
-/* */
-/* Keyboard Handling */
-/* */
-/* ------------------------------------------------------------------------- */
-
-/*!
-*/
-
-void Emulation::sendKeyEvent( QKeyEvent* ev )
+void Emulation::sendKeyEvent(QKeyEvent* ev, bool)
{
emit stateSet(NOTIFYNORMAL);
-
+
if (!ev->text().isEmpty())
{ // A block of text
// Note that the text is proper unicode.
- // We should do a conversion here, but since this
- // routine will never be used, we simply emit plain ascii.
- //emit sendBlock(ev->text().toAscii(),ev->text().length());
- emit sendData(ev->text().toUtf8(),ev->text().length());
+ // We should do a conversion here
+ emit sendData(ev->text().toUtf8().constData(),ev->text().length());
}
}
@@ -252,8 +243,6 @@ void Emulation::sendMouseEvent(int /*buttons*/, int /*column*/, int /*row*/, int
// default implementation does nothing
}
-// Unblocking, Byte to Unicode translation --------------------------------- --
-
/*
We are doing code conversion from locale to unicode first.
TODO: Character composition from the old code. See #96536
@@ -261,46 +250,50 @@ TODO: Character composition from the old code. See #96536
void Emulation::receiveData(const char* text, int length)
{
- emit stateSet(NOTIFYACTIVITY);
+ emit stateSet(NOTIFYACTIVITY);
- bufferedUpdate();
-
- QString unicodeText = _decoder->toUnicode(text,length);
+ bufferedUpdate();
- //send characters to terminal emulator
- for (int i=0;itoUnicode(text,length);
+ std::wstring unicodeText = utf16Text.toStdWString();
- //look for z-modem indicator
- //-- someone who understands more about z-modems that I do may be able to move
- //this check into the above for loop?
- for (int i=0;i 3) && (strncmp(text+i+1, "B00", 3) == 0))
- emit zmodemDetected();
- }
- }
+ //send characters to terminal emulator
+ for (size_t i=0;i 3) && (strncmp(text+i+1, "B00", 3) == 0))
+ emit zmodemDetected();
+ }
+ }
}
//OLDER VERSION
//This version of onRcvBlock was commented out because
-// a) It decoded incoming characters one-by-one, which is slow in the current version of Qt (4.2 tech preview)
-// b) It messed up decoding of non-ASCII characters, with the result that (for example) chinese characters
-// were not printed properly.
+// a) It decoded incoming characters one-by-one, which is slow in the current version of Qt (4.2 tech preview)
+// b) It messed up decoding of non-ASCII characters, with the result that (for example) chinese characters
+// were not printed properly.
//
//There is something about stopping the _decoder if "we get a control code halfway a multi-byte sequence" (see below)
//which hasn't been ported into the newer function (above). Hopefully someone who understands this better
-//can find an alternative way of handling the check.
+//can find an alternative way of handling the check.
/*void Emulation::onRcvBlock(const char *s, int len)
{
emit notifySessionState(NOTIFYACTIVITY);
-
+
bufferedUpdate();
for (int i = 0; i < len; i++)
{
@@ -330,72 +323,27 @@ void Emulation::receiveData(const char* text, int length)
if (s[i] == '\030')
{
if ((len-i-1 > 3) && (strncmp(s+i+1, "B00", 3) == 0))
- emit zmodemDetected();
+ emit zmodemDetected();
}
}
}*/
-// Selection --------------------------------------------------------------- --
-
-#if 0
-void Emulation::onSelectionBegin(const int x, const int y, const bool columnmode) {
- if (!connected) return;
- _currentScreen->setSelectionStart( x,y,columnmode);
- showBulk();
-}
-
-void Emulation::onSelectionExtend(const int x, const int y) {
- if (!connected) return;
- _currentScreen->setSelectionEnd(x,y);
- showBulk();
-}
-
-void Emulation::setSelection(const bool preserve_line_breaks) {
- if (!connected) return;
- QString t = _currentScreen->selectedText(preserve_line_breaks);
- if (!t.isNull())
- {
- QListIterator< TerminalDisplay* > viewIter(_views);
-
- while (viewIter.hasNext())
- viewIter.next()->setSelection(t);
- }
-}
-
-void Emulation::testIsSelected(const int x, const int y, bool &selected)
-{
- if (!connected) return;
- selected=_currentScreen->isSelected(x,y);
-}
-
-void Emulation::clearSelection() {
- if (!connected) return;
- _currentScreen->clearSelection();
- showBulk();
-}
-
-#endif
-
-void Emulation::writeToStream( TerminalCharacterDecoder* _decoder ,
+void Emulation::writeToStream( TerminalCharacterDecoder* _decoder ,
int startLine ,
- int endLine)
+ int endLine)
{
- _currentScreen->writeToStream(_decoder,startLine,endLine);
+ _currentScreen->writeLinesToStream(_decoder,startLine,endLine);
}
-int Emulation::lineCount()
+int Emulation::lineCount() const
{
// sum number of lines currently on _screen plus number of lines in history
return _currentScreen->getLines() + _currentScreen->getHistLines();
}
-// Refreshing -------------------------------------------------------------- --
-
#define BULK_TIMEOUT1 10
#define BULK_TIMEOUT2 40
-/*!
-*/
void Emulation::showBulk()
{
_bulkTimer1.stop();
@@ -418,16 +366,24 @@ void Emulation::bufferedUpdate()
}
}
-char Emulation::getErase() const
+char Emulation::eraseChar() const
{
return '\b';
}
void Emulation::setImageSize(int lines, int columns)
{
- //kDebug() << "Resizing image to: " << lines << "by" << columns << QTime::currentTime().msec();
- Q_ASSERT( lines > 0 );
- Q_ASSERT( columns > 0 );
+ if ((lines < 1) || (columns < 1))
+ return;
+
+ QSize screenSize[2] = { QSize(_screen[0]->getColumns(),
+ _screen[0]->getLines()),
+ QSize(_screen[1]->getColumns(),
+ _screen[1]->getLines()) };
+ QSize newSize(columns,lines);
+
+ if (newSize == screenSize[0] && newSize == screenSize[1])
+ return;
_screen[0]->resizeImage(lines,columns);
_screen[1]->resizeImage(lines,columns);
@@ -437,9 +393,9 @@ void Emulation::setImageSize(int lines, int columns)
bufferedUpdate();
}
-QSize Emulation::imageSize()
+QSize Emulation::imageSize() const
{
- return QSize(_currentScreen->getColumns(), _currentScreen->getLines());
+ return {_currentScreen->getColumns(), _currentScreen->getLines()};
}
ushort ExtendedCharTable::extendedCharHash(ushort* unicodePoints , ushort length) const
@@ -455,17 +411,17 @@ bool ExtendedCharTable::extendedCharMatch(ushort hash , ushort* unicodePoints ,
{
ushort* entry = extendedCharTable[hash];
- // compare given length with stored sequence length ( given as the first ushort in the
- // stored buffer )
- if ( entry == 0 || entry[0] != length )
+ // compare given length with stored sequence length ( given as the first ushort in the
+ // stored buffer )
+ if ( entry == nullptr || entry[0] != length )
return false;
// if the lengths match, each character must be checked. the stored buffer starts at
// entry[1]
for ( int i = 0 ; i < length ; i++ )
{
if ( entry[i+1] != unicodePoints[i] )
- return false;
- }
+ return false;
+ }
return true;
}
ushort ExtendedCharTable::createExtendedChar(ushort* unicodePoints , ushort length)
@@ -478,7 +434,7 @@ ushort ExtendedCharTable::createExtendedChar(ushort* unicodePoints , ushort leng
{
if ( extendedCharMatch(hash,unicodePoints,length) )
{
- // this sequence already has an entry in the table,
+ // this sequence already has an entry in the table,
// return its hash
return hash;
}
@@ -488,16 +444,16 @@ ushort ExtendedCharTable::createExtendedChar(ushort* unicodePoints , ushort leng
// points then try next hash
hash++;
}
- }
+ }
+
-
// add the new sequence to the table and
// return that index
ushort* buffer = new ushort[length+1];
buffer[0] = length;
for ( int i = 0 ; i < length ; i++ )
- buffer[i+1] = unicodePoints[i];
-
+ buffer[i+1] = unicodePoints[i];
+
extendedCharTable.insert(hash,buffer);
return hash;
@@ -517,7 +473,7 @@ ushort* ExtendedCharTable::lookupExtendedChar(ushort hash , ushort& length) cons
else
{
length = 0;
- return 0;
+ return nullptr;
}
}
@@ -539,5 +495,5 @@ ExtendedCharTable::~ExtendedCharTable()
ExtendedCharTable ExtendedCharTable::instance;
-//#include "moc_Emulation.cpp"
+//#include "Emulation.moc"
diff --git a/qtermwidget/src/Emulation.h b/qtermwidget/lib/Emulation.h
similarity index 74%
rename from qtermwidget/src/Emulation.h
rename to qtermwidget/lib/Emulation.h
index 2782df7..7109e69 100644
--- a/qtermwidget/src/Emulation.h
+++ b/qtermwidget/lib/Emulation.h
@@ -1,10 +1,8 @@
/*
This file is part of Konsole, an X terminal.
-
- Copyright (C) 2007 by Robert Knight
- Copyright (C) 1997,1998 by Lars Doelle
- Rewritten for QT4 by e_k , Copyright (C)2008
+ Copyright 2007-2008 by Robert Knight
+ Copyright 1997,1998 by Lars Doelle
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,75 +24,80 @@
#define EMULATION_H
// System
-#include
+#include
-// Qt
-#include
+// Qt
+#include
//#include
-#include
-#include
-#include
+#if QT_VERSION >= 0x060000
+#include
+#else
+#include
+#endif
+#include
+#include
+#include "qtermwidget_export.h"
+#include "KeyboardTranslator.h"
namespace Konsole
{
-class KeyboardTranslator;
class HistoryType;
class Screen;
class ScreenWindow;
class TerminalCharacterDecoder;
-/**
- * This enum describes the available states which
+/**
+ * This enum describes the available states which
* the terminal emulation may be set to.
*
- * These are the values used by Emulation::stateChanged()
+ * These are the values used by Emulation::stateChanged()
*/
-enum
-{
+enum
+{
/** The emulation is currently receiving user input. */
- NOTIFYNORMAL=0,
- /**
+ NOTIFYNORMAL=0,
+ /**
* The terminal program has triggered a bell event
* to get the user's attention.
*/
- NOTIFYBELL=1,
- /**
- * The emulation is currently receiving data from its
+ NOTIFYBELL=1,
+ /**
+ * The emulation is currently receiving data from its
* terminal input.
*/
NOTIFYACTIVITY=2,
- // unused here?
- NOTIFYSILENCE=3
+ // unused here?
+ NOTIFYSILENCE=3
};
/**
* Base class for terminal emulation back-ends.
*
- * The back-end is responsible for decoding an incoming character stream and
+ * The back-end is responsible for decoding an incoming character stream and
* producing an output image of characters.
*
* When input from the terminal is received, the receiveData() slot should be called with
- * the data which has arrived. The emulation will process the data and update the
+ * the data which has arrived. The emulation will process the data and update the
* screen image accordingly. The codec used to decode the incoming character stream
- * into the unicode characters used internally can be specified using setCodec()
+ * into the unicode characters used internally can be specified using setCodec()
*
- * The size of the screen image can be specified by calling setImageSize() with the
+ * The size of the screen image can be specified by calling setImageSize() with the
* desired number of lines and columns. When new lines are added, old content
- * is moved into a history store, which can be set by calling setHistory().
+ * is moved into a history store, which can be set by calling setHistory().
*
- * The screen image can be accessed by creating a ScreenWindow onto this emulation
- * by calling createWindow(). Screen windows provide access to a section of the
- * output. Each screen window covers the same number of lines and columns as the
+ * The screen image can be accessed by creating a ScreenWindow onto this emulation
+ * by calling createWindow(). Screen windows provide access to a section of the
+ * output. Each screen window covers the same number of lines and columns as the
* image size returned by imageSize(). The screen window can be moved up and down
- * and provides transparent access to both the current on-screen image and the
+ * and provides transparent access to both the current on-screen image and the
* previous output. The screen windows emit an outputChanged signal
* when the section of the image they are looking at changes.
* Graphical views can then render the contents of a screen window, listening for notifications
- * of output changes from the screen window which they are associated with and updating
- * accordingly.
+ * of output changes from the screen window which they are associated with and updating
+ * accordingly.
*
* The emulation also is also responsible for converting input from the connected views such
* as keypresses and mouse activity into a character string which can be sent
@@ -107,9 +110,9 @@ enum
* character sequences. The name of the key bindings set used can be specified using
* setKeyBindings()
*
- * The emulation maintains certain state information which changes depending on the
- * input received. The emulation can be reset back to its starting state by calling
- * reset().
+ * The emulation maintains certain state information which changes depending on the
+ * input received. The emulation can be reset back to its starting state by calling
+ * reset().
*
* The emulation also maintains an activity state, which specifies whether
* terminal is currently active ( when data is received ), normal
@@ -119,15 +122,35 @@ enum
* how long the emulation has been active/idle for and also respond to
* a 'bell' event in different ways.
*/
-class Emulation : public QObject
-{
+class QTERMWIDGET_EXPORT Emulation : public QObject
+{
Q_OBJECT
public:
-
- /** Constructs a new terminal emulation */
+
+ /**
+ * This enum describes the available shapes for the keyboard cursor.
+ * See setKeyboardCursorShape()
+ */
+ enum class KeyboardCursorShape {
+ /** A rectangular block which covers the entire area of the cursor character. */
+ BlockCursor = 0,
+ /**
+ * A single flat line which occupies the space at the bottom of the cursor
+ * character's area.
+ */
+ UnderlineCursor = 1,
+ /**
+ * An cursor shaped like the capital letter 'I', similar to the IBeam
+ * cursor used in Qt/KDE text editors.
+ */
+ IBeamCursor = 2
+ };
+
+
+ /** Constructs a new terminal emulation */
Emulation();
- ~Emulation();
+ ~Emulation() override;
/**
* Creates a new window onto the output from this emulation. The contents
@@ -137,70 +160,70 @@ public:
ScreenWindow* createWindow();
/** Returns the size of the screen image which the emulation produces */
- QSize imageSize();
+ QSize imageSize() const;
/**
* Returns the total number of lines, including those stored in the history.
- */
- int lineCount();
+ */
+ int lineCount() const;
-
- /**
+ /**
* Sets the history store used by this emulation. When new lines
* are added to the output, older lines at the top of the screen are transferred to a history
- * store.
+ * store.
*
- * The number of lines which are kept and the storage location depend on the
+ * The number of lines which are kept and the storage location depend on the
* type of store.
*/
void setHistory(const HistoryType&);
/** Returns the history store used by this emulation. See setHistory() */
- const HistoryType& history();
+ const HistoryType& history() const;
/** Clears the history scroll. */
void clearHistory();
- /**
- * Copies the output history from @p startLine to @p endLine
+ /**
+ * Copies the output history from @p startLine to @p endLine
* into @p stream, using @p decoder to convert the terminal
- * characters into text.
+ * characters into text.
*
- * @param decoder A decoder which converts lines of terminal characters with
+ * @param decoder A decoder which converts lines of terminal characters with
* appearance attributes into output text. PlainTextDecoder is the most commonly
* used decoder.
- * @param startLine The first
+ * @param startLine Index of first line to copy
+ * @param endLine Index of last line to copy
*/
virtual void writeToStream(TerminalCharacterDecoder* decoder,int startLine,int endLine);
-
-
+
/** Returns the codec used to decode incoming characters. See setCodec() */
- const QTextCodec* codec() { return _codec; }
+ const QTextCodec* codec() const { return _codec; }
/** Sets the codec used to decode incoming characters. */
void setCodec(const QTextCodec*);
- /**
- * Convenience method.
+ /**
+ * Convenience method.
* Returns true if the current codec used to decode incoming
* characters is UTF-8
*/
- bool utf8() { Q_ASSERT(_codec); return _codec->mibEnum() == 106; }
-
+ bool utf8() const
+ { Q_ASSERT(_codec); return _codec->mibEnum() == 106; }
+
/** TODO Document me */
- virtual char getErase() const;
+ virtual char eraseChar() const;
- /**
+ /**
* Sets the key bindings used to key events
* ( received through sendKeyEvent() ) into character
* streams to send to the terminal.
*/
void setKeyBindings(const QString& name);
- /**
+ /**
* Returns the name of the emulation's current key bindings.
* See setKeyBindings()
*/
- QString keyBindings();
+ QString keyBindings() const;
- /**
+ /**
* Copies the current image into the history and clears the screen.
*/
virtual void clearEntireScreen() =0;
@@ -208,7 +231,7 @@ public:
/** Resets the state of the terminal. */
virtual void reset() =0;
- /**
+ /**
* Returns true if the active terminal program wants
* mouse input events.
*
@@ -217,42 +240,44 @@ public:
*/
bool programUsesMouse() const;
-public slots:
+ bool programBracketedPasteMode() const;
+
+public slots:
/** Change the size of the emulation's image */
virtual void setImageSize(int lines, int columns);
-
- /**
+
+ /**
* Interprets a sequence of characters and sends the result to the terminal.
* This is equivalent to calling sendKeyEvent() for each character in @p text in succession.
*/
virtual void sendText(const QString& text) = 0;
- /**
+ /**
* Interprets a key press event and emits the sendData() signal with
- * the resulting character stream.
+ * the resulting character stream.
*/
- virtual void sendKeyEvent(QKeyEvent*);
-
- /**
+ virtual void sendKeyEvent(QKeyEvent*, bool fromPaste);
+
+ /**
* Converts information about a mouse event into an xterm-compatible escape
* sequence and emits the character sequence via sendData()
*/
virtual void sendMouseEvent(int buttons, int column, int line, int eventType);
-
+
/**
- * Sends a string of characters to the foreground terminal process.
+ * Sends a string of characters to the foreground terminal process.
*
- * @param string The characters to send.
+ * @param string The characters to send.
* @param length Length of @p string or if set to a negative value, @p string will
* be treated as a null-terminated string and its length will be determined automatically.
*/
virtual void sendString(const char* string, int length = -1) = 0;
- /**
+ /**
* Processes an incoming stream of characters. receiveData() decodes the incoming
* character buffer using the current codec(), and then calls receiveChar() for
- * each unicode character in the resulting buffer.
+ * each unicode character in the resulting buffer.
*
* receiveData() also starts a timer which causes the outputChanged() signal
* to be emitted when it expires. The timer allows multiple updates in quick
@@ -265,29 +290,29 @@ public slots:
signals:
- /**
- * Emitted when a buffer of data is ready to send to the
+ /**
+ * Emitted when a buffer of data is ready to send to the
* standard input of the terminal.
*
* @param data The buffer of data ready to be sent
- * @paran len The length of @p data in bytes
+ * @param len The length of @p data in bytes
*/
void sendData(const char* data,int len);
- /**
+ /**
* Requests that sending of input to the emulation
* from the terminal process be suspended or resumed.
*
- * @param suspend If true, requests that sending of
- * input from the terminal process' stdout be
+ * @param suspend If true, requests that sending of
+ * input from the terminal process' stdout be
* suspended. Otherwise requests that sending of
- * input be resumed.
+ * input be resumed.
*/
void lockPtyRequest(bool suspend);
/**
* Requests that the pty used by the terminal process
- * be set to UTF 8 mode.
+ * be set to UTF 8 mode.
*
* TODO: More documentation
*/
@@ -315,7 +340,7 @@ signals:
*/
void changeTabTextColorRequest(int color);
- /**
+ /**
* This is emitted when the program running in the shell indicates whether or
* not it is interested in mouse events.
*
@@ -324,7 +349,9 @@ signals:
*/
void programUsesMouseChanged(bool usesMouse);
- /**
+ void programBracketedPasteModeChanged(bool bracketedPasteMode);
+
+ /**
* Emitted when the contents of the screen image change.
* The emulation buffers the updates from successive image changes,
* and only emits outputChanged() at sensible intervals when
@@ -334,14 +361,14 @@ signals:
* created with createWindow() to listen for this signal.
*
* ScreenWindow objects created using createWindow() will emit their
- * own outputChanged() signal in response to this signal.
+ * own outputChanged() signal in response to this signal.
*/
void outputChanged();
/**
- * Emitted when the program running in the terminal wishes to update the
+ * Emitted when the program running in the terminal wishes to update the
* session's title. This also allows terminal programs to customize other
- * aspects of the terminal emulation display.
+ * aspects of the terminal emulation display.
*
* This signal is emitted when the escape sequence "\033]ARG;VALUE\007"
* is received in the input string, where ARG is a number specifying what
@@ -349,7 +376,7 @@ signals:
*
* TODO: The name of this method is not very accurate since this method
* is used to perform a whole range of tasks besides just setting
- * the user-title of the session.
+ * the user-title of the session.
*
* @param title Specifies what to change.
*
@@ -357,17 +384,17 @@ signals:
* - 1 - Set window icon text to @p newTitle
* - 2 - Set session title to @p newTitle
* - 11 - Set the session's default background color to @p newTitle,
- * where @p newTitle can be an HTML-style string (#RRGGBB) or a named
- * color (eg 'red', 'blue').
+ * where @p newTitle can be an HTML-style string ("#RRGGBB") or a named
+ * color (eg 'red', 'blue').
* See http://doc.trolltech.com/4.2/qcolor.html#setNamedColor for more
* details.
*
* - 31 - Supposedly treats @p newTitle as a URL and opens it (NOT IMPLEMENTED)
- * - 32 - Sets the icon associated with the session. @p newTitle is the name
+ *
- 32 - Sets the icon associated with the session. @p newTitle is the name
* of the icon to use, which can be the name of any icon in the current KDE icon
* theme (eg: 'konsole', 'kate', 'folder_home')
*
- * @param newTitle Specifies the new title
+ * @param newTitle Specifies the new title
*/
void titleChanged(int title,const QString& newTitle);
@@ -378,9 +405,21 @@ signals:
*/
void imageSizeChanged(int lineCount , int columnCount);
- /**
+ /**
+ * Emitted when the setImageSize() is called on this emulation for
+ * the first time.
+ */
+ void imageSizeInitialized();
+
+ /**
+ * Emitted after receiving the escape sequence which asks to change
+ * the terminal emulator's size
+ */
+ void imageResizeRequest(const QSize& sizz);
+
+ /**
* Emitted when the terminal program requests to change various properties
- * of the terminal display.
+ * of the terminal display.
*
* A profile change command occurs when a special escape sequence, followed
* by a string containing a series of name and value pairs is received.
@@ -391,24 +430,43 @@ signals:
*/
void profileChangeCommandReceived(const QString& text);
-protected:
- virtual void setMode (int mode) = 0;
- virtual void resetMode(int mode) = 0;
-
- /**
- * Processes an incoming character. See receiveData()
- * @p ch A unicode character code.
+ /**
+ * Emitted when a flow control key combination ( Ctrl+S or Ctrl+Q ) is pressed.
+ * @param suspendKeyPressed True if Ctrl+S was pressed to suspend output or Ctrl+Q to
+ * resume output.
*/
- virtual void receiveChar(int ch);
+ void flowControlKeyPressed(bool suspendKeyPressed);
- /**
+ /**
+ * Emitted when the cursor shape or its blinking state is changed via
+ * DECSCUSR sequences.
+ *
+ * @param cursorShape One of 3 possible values in KeyboardCursorShape enum
+ * @param blinkingCursorEnabled Whether to enable blinking or not
+ */
+ void cursorChanged(KeyboardCursorShape cursorShape, bool blinkingCursorEnabled);
+
+ void handleCommandFromKeyboard(KeyboardTranslator::Command command);
+ void outputFromKeypressEvent(void);
+
+protected:
+ virtual void setMode(int mode) = 0;
+ virtual void resetMode(int mode) = 0;
+
+ /**
+ * Processes an incoming character. See receiveData()
+ * @p ch A unicode character code.
+ */
+ virtual void receiveChar(wchar_t ch);
+
+ /**
* Sets the active screen. The terminal has two screens, primary and alternate.
* The primary screen is used by default. When certain interactive programs such
* as Vim are run, they trigger a switch to the alternate screen.
*
* @param index 0 to switch to the primary screen, or 1 to switch to the alternate screen
*/
- void setScreen(int index);
+ void setScreen(int index);
enum EmulationCodec
{
@@ -419,45 +477,46 @@ protected:
QList _windows;
-
- Screen* _currentScreen; // pointer to the screen which is currently active,
+
+ Screen* _currentScreen; // pointer to the screen which is currently active,
// this is one of the elements in the screen[] array
Screen* _screen[2]; // 0 = primary screen ( used by most programs, including the shell
// scrollbars are enabled in this mode )
// 1 = alternate ( used by vi , emacs etc.
// scrollbars are not enabled in this mode )
-
-
- //decodes an incoming C-style character stream into a unicode QString using
+
+
+ //decodes an incoming C-style character stream into a unicode QString using
//the current text codec. (this allows for rendering of non-ASCII characters in text files etc.)
const QTextCodec* _codec;
QTextDecoder* _decoder;
-
const KeyboardTranslator* _keyTranslator; // the keyboard layout
protected slots:
- /**
+ /**
* Schedules an update of attached views.
* Repeated calls to bufferedUpdate() in close succession will result in only a single update,
- * much like the Qt buffered update of widgets.
+ * much like the Qt buffered update of widgets.
*/
void bufferedUpdate();
-private slots:
+private slots:
// triggered by timer, causes the emulation to send an updated screen image to each
// view
- void showBulk();
+ void showBulk();
void usesMouseChanged(bool usesMouse);
-private:
+ void bracketedPasteModeChanged(bool bracketedPasteMode);
+private:
bool _usesMouse;
+ bool _bracketedPasteMode;
QTimer _bulkTimer1;
QTimer _bulkTimer2;
-
+
};
}
diff --git a/qtermwidget/src/ExtendedDefaultTranslator.h b/qtermwidget/lib/ExtendedDefaultTranslator.h
similarity index 100%
rename from qtermwidget/src/ExtendedDefaultTranslator.h
rename to qtermwidget/lib/ExtendedDefaultTranslator.h
diff --git a/qtermwidget/src/Filter.cpp b/qtermwidget/lib/Filter.cpp
similarity index 75%
rename from qtermwidget/src/Filter.cpp
rename to qtermwidget/lib/Filter.cpp
index b20f500..f219292 100644
--- a/qtermwidget/src/Filter.cpp
+++ b/qtermwidget/lib/Filter.cpp
@@ -1,7 +1,5 @@
/*
- Copyright (C) 2007 by Robert Knight
-
- Rewritten for QT4 by e_k , Copyright (C)2008
+ Copyright 2007-2008 by Robert Knight
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -22,18 +20,20 @@
// Own
#include "Filter.h"
-
// System
#include
// Qt
-#include
-#include
-#include
-#include
-
-#include
-#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
// KDE
//#include
@@ -41,13 +41,14 @@
// Konsole
#include "TerminalCharacterDecoder.h"
+#include "konsole_wcwidth.h"
using namespace Konsole;
FilterChain::~FilterChain()
{
QMutableListIterator iter(*this);
-
+
while ( iter.hasNext() )
{
Filter* filter = iter.next();
@@ -97,13 +98,13 @@ Filter::HotSpot* FilterChain::hotSpotAt(int line , int column) const
{
Filter* filter = iter.next();
Filter::HotSpot* spot = filter->hotSpotAt(line,column);
- if ( spot != 0 )
+ if ( spot != nullptr )
{
return spot;
}
}
- return 0;
+ return nullptr;
}
QList FilterChain::hotSpots() const
@@ -120,8 +121,8 @@ QList FilterChain::hotSpots() const
//QList FilterChain::hotSpotsAtLine(int line) const;
TerminalImageFilterChain::TerminalImageFilterChain()
-: _buffer(0)
-, _linePositions(0)
+: _buffer(nullptr)
+, _linePositions(nullptr)
{
}
@@ -133,19 +134,15 @@ TerminalImageFilterChain::~TerminalImageFilterChain()
void TerminalImageFilterChain::setImage(const Character* const image , int lines , int columns, const QVector& lineProperties)
{
-//qDebug("%s %d", __FILE__, __LINE__);
if (empty())
return;
-//qDebug("%s %d", __FILE__, __LINE__);
// reset all filters and hotspots
reset();
-//qDebug("%s %d", __FILE__, __LINE__);
PlainTextDecoder decoder;
decoder.setTrailingWhitespace(false);
-
-//qDebug("%s %d", __FILE__, __LINE__);
+
// setup new shared buffers for the filters to process on
QString* newBuffer = new QString();
QList* newLinePositions = new QList();
@@ -171,34 +168,31 @@ void TerminalImageFilterChain::setImage(const Character* const image , int lines
// being treated as part of a link that occurs at the start of the next line
//
// the downside is that links which are spread over more than one line are not
- // highlighted.
+ // highlighted.
//
// TODO - Use the "line wrapped" attribute associated with lines in a
// terminal image to avoid adding this imaginary character for wrapped
// lines
if ( !(lineProperties.value(i,LINE_DEFAULT) & LINE_WRAPPED) )
- lineStream << QChar('\n');
+ lineStream << QLatin1Char('\n');
}
decoder.end();
-// qDebug("%s %d", __FILE__, __LINE__);
}
Filter::Filter() :
-_linePositions(0),
-_buffer(0)
+_linePositions(nullptr),
+_buffer(nullptr)
{
}
Filter::~Filter()
{
- QListIterator iter(_hotspotList);
- while (iter.hasNext())
- {
- delete iter.next();
- }
+ qDeleteAll(_hotspotList);
+ _hotspotList.clear();
}
void Filter::reset()
{
+ qDeleteAll(_hotspotList);
_hotspots.clear();
_hotspotList.clear();
}
@@ -217,30 +211,22 @@ void Filter::getLineColumn(int position , int& startLine , int& startColumn)
for (int i = 0 ; i < _linePositions->count() ; i++)
{
- //kDebug() << "line position at " << i << " = " << _linePositions[i];
int nextLine = 0;
if ( i == _linePositions->count()-1 )
- {
nextLine = _buffer->length() + 1;
- }
else
- {
nextLine = _linePositions->value(i+1);
- }
- // kDebug() << "pos - " << position << " line pos(" << i<< ") " << _linePositions->value(i) <<
- // " next = " << nextLine << " buffer len = " << _buffer->length();
-
- if ( _linePositions->value(i) <= position && position < nextLine )
+ if ( _linePositions->value(i) <= position && position < nextLine )
{
startLine = i;
- startColumn = position - _linePositions->value(i);
+ startColumn = string_width(buffer()->mid(_linePositions->value(i),position - _linePositions->value(i)).toStdWString());
return;
}
}
}
-
+
/*void Filter::addLine(const QString& text)
{
@@ -262,7 +248,7 @@ void Filter::addHotSpot(HotSpot* spot)
for (int line = spot->startLine() ; line <= spot->endLine() ; line++)
{
_hotspots.insert(line,spot);
- }
+ }
}
QList Filter::hotSpots() const
{
@@ -280,16 +266,16 @@ Filter::HotSpot* Filter::hotSpotAt(int line , int column) const
while (spotIter.hasNext())
{
HotSpot* spot = spotIter.next();
-
+
if ( spot->startLine() == line && spot->startColumn() > column )
continue;
if ( spot->endLine() == line && spot->endColumn() < column )
continue;
-
+
return spot;
}
- return 0;
+ return nullptr;
}
Filter::HotSpot::HotSpot(int startLine , int startColumn , int endLine , int endColumn)
@@ -300,10 +286,6 @@ Filter::HotSpot::HotSpot(int startLine , int startColumn , int endLine , int end
, _type(NotSpecified)
{
}
-QString Filter::HotSpot::tooltip() const
-{
- return QString();
-}
QList Filter::HotSpot::actions()
{
return QList();
@@ -343,7 +325,7 @@ RegExpFilter::HotSpot::HotSpot(int startLine,int startColumn,int endLine,int end
setType(Marker);
}
-void RegExpFilter::HotSpot::activate(QObject*)
+void RegExpFilter::HotSpot::activate(const QString&)
{
}
@@ -356,7 +338,7 @@ QStringList RegExpFilter::HotSpot::capturedTexts() const
return _capturedTexts;
}
-void RegExpFilter::setRegExp(const QRegExp& regExp)
+void RegExpFilter::setRegExp(const QRegExp& regExp)
{
_searchText = regExp;
}
@@ -377,7 +359,7 @@ void RegExpFilter::process()
// ignore any regular expressions which match an empty string.
// otherwise the while loop below will run indefinitely
- static const QString emptyString("");
+ static const QString emptyString;
if ( _searchText.exactMatch(emptyString) )
return;
@@ -387,32 +369,26 @@ void RegExpFilter::process()
if ( pos >= 0 )
{
-
int startLine = 0;
int endLine = 0;
int startColumn = 0;
int endColumn = 0;
-
- //kDebug() << "pos from " << pos << " to " << pos + _searchText.matchedLength();
-
getLineColumn(pos,startLine,startColumn);
getLineColumn(pos + _searchText.matchedLength(),endLine,endColumn);
- //kDebug() << "start " << startLine << " / " << startColumn;
- //kDebug() << "end " << endLine << " / " << endColumn;
-
RegExpFilter::HotSpot* spot = newHotSpot(startLine,startColumn,
endLine,endColumn);
spot->setCapturedTexts(_searchText.capturedTexts());
- addHotSpot( spot );
+ addHotSpot( spot );
pos += _searchText.matchedLength();
// if matchedLength == 0, the program will get stuck in an infinite loop
- Q_ASSERT( _searchText.matchedLength() > 0 );
+ if ( _searchText.matchedLength() == 0 )
+ pos = -1;
}
- }
+ }
}
RegExpFilter::HotSpot* RegExpFilter::newHotSpot(int startLine,int startColumn,
@@ -424,32 +400,23 @@ RegExpFilter::HotSpot* RegExpFilter::newHotSpot(int startLine,int startColumn,
RegExpFilter::HotSpot* UrlFilter::newHotSpot(int startLine,int startColumn,int endLine,
int endColumn)
{
- return new UrlFilter::HotSpot(startLine,startColumn,
+ HotSpot *spot = new UrlFilter::HotSpot(startLine,startColumn,
endLine,endColumn);
+ connect(spot->getUrlObject(), &FilterObject::activated, this, &UrlFilter::activated);
+ return spot;
}
+
UrlFilter::HotSpot::HotSpot(int startLine,int startColumn,int endLine,int endColumn)
: RegExpFilter::HotSpot(startLine,startColumn,endLine,endColumn)
, _urlObject(new FilterObject(this))
{
setType(Link);
}
-QString UrlFilter::HotSpot::tooltip() const
-{
- QString url = capturedTexts().first();
- const UrlType kind = urlType();
-
- if ( kind == StandardUrl )
- return QString();
- else if ( kind == Email )
- return QString();
- else
- return QString();
-}
UrlFilter::HotSpot::UrlType UrlFilter::HotSpot::urlType() const
{
- QString url = capturedTexts().first();
-
+ QString url = capturedTexts().constFirst();
+
if ( FullUrlRegExp.exactMatch(url) )
return StandardUrl;
else if ( EmailAddressRegExp.exactMatch(url) )
@@ -458,71 +425,80 @@ UrlFilter::HotSpot::UrlType UrlFilter::HotSpot::urlType() const
return Unknown;
}
-void UrlFilter::HotSpot::activate(QObject* object)
+void UrlFilter::HotSpot::activate(const QString& actionName)
{
- QString url = capturedTexts().first();
+ QString url = capturedTexts().constFirst();
const UrlType kind = urlType();
- const QString& actionName = object ? object->objectName() : QString();
-
- if ( actionName == "copy-action" )
+ if ( actionName == QLatin1String("copy-action") )
{
- //kDebug() << "Copying url to clipboard:" << url;
-
QApplication::clipboard()->setText(url);
return;
}
- if ( !object || actionName == "open-action" )
+ if ( actionName.isEmpty() || actionName == QLatin1String("open-action") || actionName == QLatin1String("click-action") )
{
if ( kind == StandardUrl )
{
// if the URL path does not include the protocol ( eg. "www.kde.org" ) then
// prepend http:// ( eg. "www.kde.org" --> "http://www.kde.org" )
- if (!url.contains("://"))
+ if (!url.contains(QLatin1String("://")))
{
- url.prepend("http://");
+ url.prepend(QLatin1String("http://"));
}
- }
+ }
else if ( kind == Email )
{
- url.prepend("mailto:");
+ url.prepend(QLatin1String("mailto:"));
}
-
-// new KRun(url,QApplication::activeWindow());
+
+ _urlObject->emitActivated(QUrl(url, QUrl::StrictMode), actionName != QLatin1String("click-action"));
}
}
-// Note: Altering these regular expressions can have a major effect on the performance of the filters
+// Note: Altering these regular expressions can have a major effect on the performance of the filters
// used for finding URLs in the text, especially if they are very general and could match very long
// pieces of text.
// Please be careful when altering them.
//regexp matches:
-// full url:
+// full url:
// protocolname:// or www. followed by anything other than whitespaces, <, >, ' or ", and ends before whitespaces, <, >, ', ", ], !, comma and dot
-const QRegExp UrlFilter::FullUrlRegExp("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]]");
+const QRegExp UrlFilter::FullUrlRegExp(QLatin1String("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]]"));
// email address:
// [word chars, dots or dashes]@[word chars, dots or dashes].[word chars]
-const QRegExp UrlFilter::EmailAddressRegExp("\\b(\\w|\\.|-)+@(\\w|\\.|-)+\\.\\w+\\b");
+const QRegExp UrlFilter::EmailAddressRegExp(QLatin1String("\\b(\\w|\\.|-)+@(\\w|\\.|-)+\\.\\w+\\b"));
// matches full url or email address
-const QRegExp UrlFilter::CompleteUrlRegExp('('+FullUrlRegExp.pattern()+'|'+
- EmailAddressRegExp.pattern()+')');
+const QRegExp UrlFilter::CompleteUrlRegExp(QLatin1Char('(')+FullUrlRegExp.pattern()+QLatin1Char('|')+
+ EmailAddressRegExp.pattern()+QLatin1Char(')'));
UrlFilter::UrlFilter()
{
setRegExp( CompleteUrlRegExp );
}
+
UrlFilter::HotSpot::~HotSpot()
{
delete _urlObject;
}
-void FilterObject::activated()
+
+void FilterObject::emitActivated(const QUrl& url, bool fromContextMenu)
{
- _filter->activate(sender());
+ emit activated(url, fromContextMenu);
}
+
+void FilterObject::activate()
+{
+ _filter->activate(sender()->objectName());
+}
+
+FilterObject* UrlFilter::HotSpot::getUrlObject() const
+{
+ return _urlObject;
+}
+
QList UrlFilter::HotSpot::actions()
{
QList list;
@@ -536,28 +512,28 @@ QList UrlFilter::HotSpot::actions()
if ( kind == StandardUrl )
{
- openAction->setText(("Open Link"));
- copyAction->setText(("Copy Link Address"));
+ openAction->setText(QObject::tr("Open Link"));
+ copyAction->setText(QObject::tr("Copy Link Address"));
}
else if ( kind == Email )
{
- openAction->setText(("Send Email To..."));
- copyAction->setText(("Copy Email Address"));
+ openAction->setText(QObject::tr("Send Email To..."));
+ copyAction->setText(QObject::tr("Copy Email Address"));
}
// object names are set here so that the hotspot performs the
// correct action when activated() is called with the triggered
// action passed as a parameter.
- openAction->setObjectName("open-action");
- copyAction->setObjectName("copy-action");
+ openAction->setObjectName( QLatin1String("open-action" ));
+ copyAction->setObjectName( QLatin1String("copy-action" ));
- QObject::connect( openAction , SIGNAL(triggered()) , _urlObject , SLOT(activated()) );
- QObject::connect( copyAction , SIGNAL(triggered()) , _urlObject , SLOT(activated()) );
+ QObject::connect( openAction , &QAction::triggered , _urlObject , &FilterObject::activate );
+ QObject::connect( copyAction , &QAction::triggered , _urlObject , &FilterObject::activate );
list << openAction;
list << copyAction;
- return list;
+ return list;
}
-//#include "moc_Filter.cpp"
+//#include "Filter.moc"
diff --git a/qtermwidget/src/Filter.h b/qtermwidget/lib/Filter.h
similarity index 80%
rename from qtermwidget/src/Filter.h
rename to qtermwidget/lib/Filter.h
index 06ea5e3..64cb36f 100644
--- a/qtermwidget/src/Filter.h
+++ b/qtermwidget/lib/Filter.h
@@ -1,7 +1,5 @@
/*
- Copyright (C) 2007 by Robert Knight
-
- Rewritten for QT4 by e_k , Copyright (C)2008
+ Copyright 2007-2008 by Robert Knight
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,19 +21,26 @@
#define FILTER_H
// Qt
-#include
-#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
+#include
+#include
+#if QT_VERSION >= 0x060000
+#include
+#else
+#include
+#endif
// Local
-#include "Character.h"
+#include "qtermwidget_export.h"
namespace Konsole
{
+typedef unsigned char LineProperty;
+class Character;
+
/**
* A filter processes blocks of text looking for certain patterns (such as URLs or keywords from a list)
* and marks the areas which match the filter's patterns as 'hotspots'.
@@ -46,7 +51,7 @@ namespace Konsole
* activate() method should be called. Depending on the type of hotspot this will trigger a suitable response.
*
* For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser.
- * Hotspots may have more than one action, in which case the list of actions can be obtained using the
+ * Hotspots may have more than one action, in which case the list of actions can be obtained using the
* actions() method.
*
* Different subclasses of filter will return different types of hotspot.
@@ -54,7 +59,7 @@ namespace Konsole
* When processing the text they should create instances of Filter::HotSpot subclasses for sections of interest
* and add them to the filter's list of hotspots using addHotSpot()
*/
-class Filter
+class QTERMWIDGET_EXPORT Filter : public QObject
{
public:
/**
@@ -66,13 +71,13 @@ public:
* activate() method should be called. Depending on the type of hotspot this will trigger a suitable response.
*
* For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser.
- * Hotspots may have more than one action, in which case the list of actions can be obtained using the
- * actions() method. These actions may then be displayed in a popup menu or toolbar for example.
+ * Hotspots may have more than one action, in which case the list of actions can be obtained using the
+ * actions() method. These actions may then be displayed in a popup menu or toolbar for example.
*/
class HotSpot
{
public:
- /**
+ /**
* Constructs a new hotspot which covers the area from (@p startLine,@p startColumn) to (@p endLine,@p endColumn)
* in a block of text.
*/
@@ -87,7 +92,7 @@ public:
Link,
// this hotspot represents a marker
Marker
- };
+ };
/** Returns the line when the hotspot area starts */
int startLine() const;
@@ -97,34 +102,26 @@ public:
int startColumn() const;
/** Returns the column on endLine() where the hotspot area ends */
int endColumn() const;
- /**
+ /**
* Returns the type of the hotspot. This is usually used as a hint for views on how to represent
* the hotspot graphically. eg. Link hotspots are typically underlined when the user mouses over them
*/
Type type() const;
- /**
- * Causes the an action associated with a hotspot to be triggered.
+ /**
+ * Causes the an action associated with a hotspot to be triggered.
*
- * @param object The object which caused the hotspot to be triggered. This is
- * typically null ( in which case the default action should be performed ) or
- * one of the objects from the actions() list. In which case the associated
- * action should be performed.
+ * @param action The action to trigger. This is
+ * typically empty ( in which case the default action should be performed ) or
+ * one of the object names from the actions() list. In which case the associated
+ * action should be performed.
*/
- virtual void activate(QObject* object = 0) = 0;
- /**
- * Returns a list of actions associated with the hotspot which can be used in a
- * menu or toolbar
+ virtual void activate(const QString& action = QString()) = 0;
+ /**
+ * Returns a list of actions associated with the hotspot which can be used in a
+ * menu or toolbar
*/
virtual QList actions();
- /**
- * Returns the text of a tooltip to be shown when the mouse moves over the hotspot, or
- * an empty string if there is no tooltip associated with this hotspot.
- *
- * The default implementation returns an empty string.
- */
- virtual QString tooltip() const;
-
protected:
/** Sets the type of a hotspot. This should only be set once */
void setType(Type type);
@@ -135,19 +132,19 @@ public:
int _endLine;
int _endColumn;
Type _type;
-
+
};
/** Constructs a new filter. */
Filter();
- virtual ~Filter();
+ ~Filter() override;
/** Causes the filter to process the block of text currently in its internal buffer */
virtual void process() = 0;
- /**
+ /**
* Empties the filters internal buffer and resets the line count back to 0.
- * All hotspots are deleted.
+ * All hotspots are deleted.
*/
void reset();
@@ -163,7 +160,7 @@ public:
/** Returns the list of hotspots identified by the filter which occur on a given line */
QList hotSpotsAtLine(int line) const;
- /**
+ /**
* TODO: Document me
*/
void setBuffer(const QString* buffer , const QList* linePositions);
@@ -179,22 +176,22 @@ protected:
private:
QMultiHash _hotspots;
QList _hotspotList;
-
+
const QList* _linePositions;
const QString* _buffer;
};
-/**
- * A filter which searches for sections of text matching a regular expression and creates a new RegExpFilter::HotSpot
+/**
+ * A filter which searches for sections of text matching a regular expression and creates a new RegExpFilter::HotSpot
* instance for them.
*
* Subclasses can reimplement newHotSpot() to return custom hotspot types when matches for the regular expression
- * are found.
+ * are found.
*/
-class RegExpFilter : public Filter
+class QTERMWIDGET_EXPORT RegExpFilter : public Filter
{
public:
- /**
+ /**
* Type of hotspot created by RegExpFilter. The capturedTexts() method can be used to find the text
* matched by the filter's regular expression.
*/
@@ -202,7 +199,7 @@ public:
{
public:
HotSpot(int startLine, int startColumn, int endLine , int endColumn);
- virtual void activate(QObject* object = 0);
+ void activate(const QString& action = QString()) override;
/** Sets the captured texts associated with this hotspot */
void setCapturedTexts(const QStringList& texts);
@@ -215,26 +212,26 @@ public:
/** Constructs a new regular expression filter */
RegExpFilter();
- /**
- * Sets the regular expression which the filter searches for in blocks of text.
+ /**
+ * Sets the regular expression which the filter searches for in blocks of text.
*
* Regular expressions which match the empty string are treated as not matching
- * anything.
+ * anything.
*/
void setRegExp(const QRegExp& text);
/** Returns the regular expression which the filter searches for in blocks of text */
QRegExp regExp() const;
- /**
- * Reimplemented to search the filter's text buffer for text matching regExp()
+ /**
+ * Reimplemented to search the filter's text buffer for text matching regExp()
*
* If regexp matches the empty string, then process() will return immediately
- * without finding results.
+ * without finding results.
*/
- virtual void process();
+ void process() override;
protected:
- /**
+ /**
* Called when a match for the regular expression is encountered. Subclasses should reimplement this
* to return custom hotspot types
*/
@@ -248,28 +245,30 @@ private:
class FilterObject;
/** A filter which matches URLs in blocks of text */
-class UrlFilter : public RegExpFilter
+class QTERMWIDGET_EXPORT UrlFilter : public RegExpFilter
{
+ Q_OBJECT
public:
- /**
- * Hotspot type created by UrlFilter instances. The activate() method opens a web browser
+ /**
+ * Hotspot type created by UrlFilter instances. The activate() method opens a web browser
* at the given URL when called.
*/
- class HotSpot : public RegExpFilter::HotSpot
+ class HotSpot : public RegExpFilter::HotSpot
{
public:
HotSpot(int startLine,int startColumn,int endLine,int endColumn);
- virtual ~HotSpot();
+ ~HotSpot() override;
- virtual QList actions();
+ FilterObject* getUrlObject() const;
- /**
+ QList actions() override;
+
+ /**
* Open a web browser at the current URL. The url itself can be determined using
* the capturedTexts() method.
*/
- virtual void activate(QObject* object = 0);
+ void activate(const QString& action = QString()) override;
- virtual QString tooltip() const;
private:
enum UrlType
{
@@ -285,33 +284,39 @@ public:
UrlFilter();
protected:
- virtual RegExpFilter::HotSpot* newHotSpot(int,int,int,int);
+ RegExpFilter::HotSpot* newHotSpot(int,int,int,int) override;
private:
-
+
static const QRegExp FullUrlRegExp;
static const QRegExp EmailAddressRegExp;
// combined OR of FullUrlRegExp and EmailAddressRegExp
- static const QRegExp CompleteUrlRegExp;
+ static const QRegExp CompleteUrlRegExp;
+signals:
+ void activated(const QUrl& url, bool fromContextMenu);
};
-class FilterObject : public QObject
+class QTERMWIDGET_NO_EXPORT FilterObject : public QObject
{
-Q_OBJECT
+ Q_OBJECT
public:
FilterObject(Filter::HotSpot* filter) : _filter(filter) {}
-private slots:
- void activated();
+
+ void emitActivated(const QUrl& url, bool fromContextMenu);
+public slots:
+ void activate();
private:
Filter::HotSpot* _filter;
+signals:
+ void activated(const QUrl& url, bool fromContextMenu);
};
-/**
- * A chain which allows a group of filters to be processed as one.
+/**
+ * A chain which allows a group of filters to be processed as one.
* The chain owns the filters added to it and deletes them when the chain itself is destroyed.
*
- * Use addFilter() to add a new filter to the chain.
+ * Use addFilter() to add a new filter to the chain.
* When new text to be filtered arrives, use addLine() to add each additional
* line of text which needs to be processed and then after adding the last line, use
* process() to cause each filter in the chain to process the text.
@@ -324,7 +329,7 @@ private:
* The hotSpots() and hotSpotsAtLine() method return all of the hotspots in the text and on
* a given line respectively.
*/
-class FilterChain : protected QList
+class QTERMWIDGET_EXPORT FilterChain : protected QList
{
public:
virtual ~FilterChain();
@@ -341,12 +346,12 @@ public:
/** Resets each filter in the chain */
void reset();
/**
- * Processes each filter in the chain
+ * Processes each filter in the chain
*/
void process();
/** Sets the buffer for each filter in the chain to process. */
- void setBuffer(const QString* buffer , const QList* linePositions);
+ void setBuffer(const QString* buffer , const QList* linePositions);
/** Returns the first hotspot which occurs at @p line, @p column or 0 if no hotspot was found */
Filter::HotSpot* hotSpotAt(int line , int column) const;
@@ -358,11 +363,11 @@ public:
};
/** A filter chain which processes character images from terminal displays */
-class TerminalImageFilterChain : public FilterChain
+class QTERMWIDGET_NO_EXPORT TerminalImageFilterChain : public FilterChain
{
public:
TerminalImageFilterChain();
- virtual ~TerminalImageFilterChain();
+ ~TerminalImageFilterChain() override;
/**
* Set the current terminal image to @p image.
@@ -370,9 +375,10 @@ public:
* @param image The terminal image
* @param lines The number of lines in the terminal image
* @param columns The number of columns in the terminal image
+ * @param lineProperties The line properties to set for image
*/
void setImage(const Character* const image , int lines , int columns,
- const QVector& lineProperties);
+ const QVector& lineProperties);
private:
QString* _buffer;
@@ -380,4 +386,7 @@ private:
};
}
+
+typedef Konsole::Filter Filter;
+
#endif //FILTER_H
diff --git a/qtermwidget/src/History.cpp b/qtermwidget/lib/History.cpp
similarity index 58%
rename from qtermwidget/src/History.cpp
rename to qtermwidget/lib/History.cpp
index 1e3d721..d8220da 100644
--- a/qtermwidget/src/History.cpp
+++ b/qtermwidget/lib/History.cpp
@@ -1,8 +1,6 @@
/*
This file is part of Konsole, an X terminal.
- Copyright (C) 1997,1998 by Lars Doelle
-
- Rewritten for QT4 by e_k , Copyright (C)2008
+ Copyright 1997,1998 by Lars Doelle
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,18 +22,24 @@
#include "History.h"
// System
+#include
#include
-#include
-#include
-#include
+#include
+#include
#include
#include
#include
-#include
+#include
+#include
+
+// KDE
+//#include
+//#include
// Reasonable line size
-#define LINE_SIZE 1024
+#define LINE_SIZE 1024
+#define KDE_lseek lseek
using namespace Konsole;
@@ -55,7 +59,7 @@ using namespace Konsole;
KDE4: Can we use QTemporaryFile here, instead of KTempFile?
-FIXME: some complain about the history buffer comsuming the
+FIXME: some complain about the history buffer consuming the
memory of their machines. This problem is critical
since the history does not behave gracefully in cases
where the memory is used up completely.
@@ -72,7 +76,7 @@ FIXME: There is noticeable decrease in speed, also. Perhaps,
scheme with wrap around would be it's complexity.
*/
-//FIXME: tempory replacement for tmpfile
+//FIXME: temporary replacement for tmpfile
// this is here one for debugging purpose.
//#define tmpfile xTmpFile
@@ -86,10 +90,11 @@ FIXME: There is noticeable decrease in speed, also. Perhaps,
HistoryFile::HistoryFile()
: ion(-1),
length(0),
- fileMap(0)
+ fileMap(nullptr),
+ readWriteBalance(0)
{
if (tmpFile.open())
- {
+ {
tmpFile.setAutoRemove(true);
ion = tmpFile.handle();
}
@@ -97,8 +102,8 @@ HistoryFile::HistoryFile()
HistoryFile::~HistoryFile()
{
- if (fileMap)
- unmap();
+ if (fileMap)
+ unmap();
}
//TODO: Mapping the entire file in will cause problems if the history file becomes exceedingly large,
@@ -106,69 +111,69 @@ HistoryFile::~HistoryFile()
//to avoid this.
void HistoryFile::map()
{
- assert( fileMap == 0 );
+ Q_ASSERT( fileMap == nullptr );
- fileMap = (char*)mmap( 0 , length , PROT_READ , MAP_PRIVATE , ion , 0 );
+ fileMap = (char*)mmap( nullptr , length , PROT_READ , MAP_PRIVATE , ion , 0 );
//if mmap'ing fails, fall back to the read-lseek combination
if ( fileMap == MAP_FAILED )
{
- readWriteBalance = 0;
- fileMap = 0;
- qDebug() << ": mmap'ing history failed. errno = " << errno;
+ readWriteBalance = 0;
+ fileMap = nullptr;
+ //qDebug() << __FILE__ << __LINE__ << ": mmap'ing history failed. errno = " << errno;
}
}
void HistoryFile::unmap()
{
- int result = munmap( fileMap , length );
- assert( result == 0 );
+ int result = munmap( fileMap , length );
+ Q_ASSERT( result == 0 ); Q_UNUSED( result );
- fileMap = 0;
+ fileMap = nullptr;
}
-bool HistoryFile::isMapped()
+bool HistoryFile::isMapped() const
{
- return (fileMap != 0);
+ return (fileMap != nullptr);
}
void HistoryFile::add(const unsigned char* bytes, int len)
{
if ( fileMap )
- unmap();
-
+ unmap();
+
readWriteBalance++;
int rc = 0;
- rc = lseek(ion,length,SEEK_SET); if (rc < 0) { perror("HistoryFile::add.seek"); return; }
+ rc = KDE_lseek(ion,length,SEEK_SET); if (rc < 0) { perror("HistoryFile::add.seek"); return; }
rc = write(ion,bytes,len); if (rc < 0) { perror("HistoryFile::add.write"); return; }
length += rc;
}
void HistoryFile::get(unsigned char* bytes, int len, int loc)
{
- //count number of get() calls vs. number of add() calls.
- //If there are many more get() calls compared with add()
+ //count number of get() calls vs. number of add() calls.
+ //If there are many more get() calls compared with add()
//calls (decided by using MAP_THRESHOLD) then mmap the log
//file to improve performance.
readWriteBalance--;
if ( !fileMap && readWriteBalance < MAP_THRESHOLD )
- map();
+ map();
if ( fileMap )
{
- for (int i=0;i length)
- fprintf(stderr,"getHist(...,%d,%d): invalid args.\n",len,loc);
- rc = lseek(ion,loc,SEEK_SET); if (rc < 0) { perror("HistoryFile::get.seek"); return; }
- rc = read(ion,bytes,len); if (rc < 0) { perror("HistoryFile::get.read"); return; }
+ if (loc < 0 || len < 0 || loc + len > length)
+ fprintf(stderr,"getHist(...,%d,%d): invalid args.\n",len,loc);
+ rc = KDE_lseek(ion,loc,SEEK_SET); if (rc < 0) { perror("HistoryFile::get.seek"); return; }
+ rc = read(ion,bytes,len); if (rc < 0) { perror("HistoryFile::get.read"); return; }
}
}
@@ -198,10 +203,10 @@ bool HistoryScroll::hasScroll()
// History Scroll File //////////////////////////////////////
-/*
+/*
The history scroll makes a Row(Row(Cell)) from
two history buffers. The index buffer contains
- start of line positions which refere to the cells
+ start of line positions which refers to the cells
buffer.
Note that index[0] addresses the second line
@@ -218,7 +223,7 @@ HistoryScrollFile::HistoryScrollFile(const QString &logFileName)
HistoryScrollFile::~HistoryScrollFile()
{
}
-
+
int HistoryScrollFile::getLines()
{
return index.len() / sizeof(int);
@@ -243,12 +248,12 @@ int HistoryScrollFile::startOfLine(int lineno)
{
if (lineno <= 0) return 0;
if (lineno <= getLines())
- {
-
- if (!index.isMapped())
- index.map();
-
- int res;
+ {
+
+ if (!index.isMapped())
+ index.map();
+
+ int res = 0;
index.get((unsigned char*)&res,sizeof(int),(lineno-1)*sizeof(int));
return res;
}
@@ -268,7 +273,7 @@ void HistoryScrollFile::addCells(const Character text[], int count)
void HistoryScrollFile::addLine(bool previousWrapped)
{
if (index.isMapped())
- index.unmap();
+ index.unmap();
int locn = cells.len();
index.add((unsigned char*)&locn,sizeof(int));
@@ -310,7 +315,7 @@ void HistoryScrollBuffer::addCellsVector(const QVector& cells)
void HistoryScrollBuffer::addCells(const Character a[], int count)
{
HistoryLine newLine(count);
- qCopy(a,a+count,newLine.begin());
+ std::copy(a,a+count,newLine.begin());
addCellsVector(newLine);
}
@@ -342,7 +347,7 @@ int HistoryScrollBuffer::getLineLen(int lineNumber)
bool HistoryScrollBuffer::isWrappedLine(int lineNumber)
{
Q_ASSERT( lineNumber >= 0 && lineNumber < _maxLineCount );
-
+
if (lineNumber < _usedLines)
{
//kDebug() << "Line" << lineNumber << "wrapped is" << _wrappedLine[bufferIndex(lineNumber)];
@@ -352,18 +357,18 @@ bool HistoryScrollBuffer::isWrappedLine(int lineNumber)
return false;
}
-void HistoryScrollBuffer::getCells(int lineNumber, int startColumn, int count, Character* buffer)
+void HistoryScrollBuffer::getCells(int lineNumber, int startColumn, int count, Character buffer[])
{
if ( count == 0 ) return;
Q_ASSERT( lineNumber < _maxLineCount );
- if (lineNumber >= _usedLines)
+ if (lineNumber >= _usedLines)
{
- memset(buffer, 0, count * sizeof(Character));
+ memset(static_cast