Moved engine from yat to konsole and refactored the project. Not everything works yet.
@ -1,14 +1,15 @@
|
|||||||
cool-old-term is a terminal emulator which tries to mimic the look and feel of the old cathode tube screens.
|
cool-old-term is a terminal emulator which tries to mimic the look and feel of the old cathode tube screens.
|
||||||
It has been designed to be eye-candy, customizable, and reasonably lightweight.
|
It has been designed to be eye-candy, customizable, and reasonably lightweight.
|
||||||
|
|
||||||
It is a fork of another qt5 terminal emulator: https://github.com/jorgen/yat
|
It now uses the konsole engine which is powerful and stable.
|
||||||
|
|
||||||
To build and launch it (Qt5.2 are required):
|
To build and launch it (Qt5.2 are required):
|
||||||
|
|
||||||
git clone https://github.com/Swordifish90/cool-old-term
|
git clone https://github.com/Swordifish90/cool-old-term.git
|
||||||
cd cool-old-term
|
cd cool-old-term
|
||||||
qmake
|
cd konsole-qml-plugin
|
||||||
make
|
qmake && make && make install
|
||||||
|
cd ..
|
||||||
./cool-old-term
|
./cool-old-term
|
||||||
|
|
||||||
This is still an eary release, but you are free to test it and tell me what do you think.
|
This is still an eary release, but you are free to test it and tell me what do you think.
|
||||||
|
@ -23,6 +23,7 @@ import QtQuick.Window 2.0
|
|||||||
import QtQuick.Controls 1.0
|
import QtQuick.Controls 1.0
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
|
import org.kde.konsole 0.1
|
||||||
|
|
||||||
ApplicationWindow{
|
ApplicationWindow{
|
||||||
id: terminalWindow
|
id: terminalWindow
|
||||||
@ -95,15 +96,29 @@ ApplicationWindow{
|
|||||||
source: shadersettings.frame_source
|
source: shadersettings.frame_source
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminalScreen {
|
KTerminal {
|
||||||
id: terminal
|
id: terminal
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
//FIXME: Ugly forced clear terminal at the beginning
|
font.pointSize: 15
|
||||||
|
font.family: "Pet Me"
|
||||||
|
|
||||||
|
colorScheme: "WhiteOnBlack"
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height
|
||||||
|
|
||||||
|
session: KSession {
|
||||||
|
id: ksession
|
||||||
|
kbScheme: "linux"
|
||||||
|
|
||||||
|
onFinished: {
|
||||||
|
Qt.quit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
terminal.screen.sendKey("l", 76, 67108864);
|
font.pointSize = 15;
|
||||||
terminal.setTerminalHeight();
|
font.family = "Pet Me";
|
||||||
terminal.setTerminalWidth();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
139
app/app.qmlproject.user
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE QtCreatorProject>
|
||||||
|
<!-- Written by QtCreator 3.0.0, 2014-01-19T22:57:55. -->
|
||||||
|
<qtcreator>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
|
<value type="int">0</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||||
|
<value type="QString" key="language">Cpp</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||||
|
<value type="QString" key="language">QmlJS</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||||
|
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||||
|
<valuemap type="QVariantMap"/>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.2.0 GCC 64bit</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.2.0 GCC 64bit</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.520.gcc_64.essentials_kit</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">-1</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">0</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||||
|
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||||
|
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||||
|
<value type="int">0</value>
|
||||||
|
<value type="int">1</value>
|
||||||
|
<value type="int">2</value>
|
||||||
|
<value type="int">3</value>
|
||||||
|
<value type="int">4</value>
|
||||||
|
<value type="int">5</value>
|
||||||
|
<value type="int">6</value>
|
||||||
|
<value type="int">7</value>
|
||||||
|
<value type="int">8</value>
|
||||||
|
<value type="int">9</value>
|
||||||
|
<value type="int">10</value>
|
||||||
|
<value type="int">11</value>
|
||||||
|
<value type="int">12</value>
|
||||||
|
<value type="int">13</value>
|
||||||
|
<value type="int">14</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">0</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">QML Scene</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QmlProjectManager.QmlRunConfiguration.QmlScene</value>
|
||||||
|
<value type="QString" key="QmlProjectManager.QmlRunConfiguration.MainScript">CurrentFile</value>
|
||||||
|
<value type="QString" key="QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments"></value>
|
||||||
|
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebugger">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||||
|
<value type="int">1</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
|
||||||
|
<value type="QByteArray">{76aa359f-2663-43c5-a318-565e5b679f49}</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||||
|
<value type="int">15</value>
|
||||||
|
</data>
|
||||||
|
</qtcreator>
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 646 KiB After Width: | Height: | Size: 646 KiB |
Before Width: | Height: | Size: 571 KiB After Width: | Height: | Size: 571 KiB |
@ -21,6 +21,9 @@
|
|||||||
import QtQuick 2.1
|
import QtQuick 2.1
|
||||||
import QtQuick.Window 2.0
|
import QtQuick.Window 2.0
|
||||||
import QtQuick.Controls 1.0
|
import QtQuick.Controls 1.0
|
||||||
|
|
||||||
|
import org.kde.konsole 0.1
|
||||||
|
|
||||||
Item{
|
Item{
|
||||||
ShaderSettings{
|
ShaderSettings{
|
||||||
id: shadersettings
|
id: shadersettings
|
2
cool-old-term
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
qmlscene -I imports app/main.qml
|
@ -1,52 +1,4 @@
|
|||||||
QT += widgets quick core-private gui-private qml-private quick quick-private
|
TEMPLATE =subdirs
|
||||||
|
CONFIG += ordered
|
||||||
include(yat/yat_declarative/yat_declarative.pro)
|
SUBDIRS= konsole-qml-plugin\
|
||||||
|
app
|
||||||
# If your application uses the Qt Mobility libraries, uncomment the following
|
|
||||||
# lines and add the respective components to the MOBILITY variable.
|
|
||||||
# CONFIG += mobility
|
|
||||||
# MOBILITY +=
|
|
||||||
|
|
||||||
# The .cpp file which was generated for your project. Feel free to hack it.
|
|
||||||
SOURCES += main.cpp
|
|
||||||
|
|
||||||
# Installation path
|
|
||||||
# target.path =
|
|
||||||
|
|
||||||
OTHER_FILES += \
|
|
||||||
$$PWD/qml/cool-old-term/main.qml \
|
|
||||||
$$PWD/qml/cool-old-term/TerminalLine.qml \
|
|
||||||
$$PWD/qml/cool-old-term/TerminalScreen.qml \
|
|
||||||
$$PWD/qml/cool-old-term/TerminalText.qml \
|
|
||||||
$$PWD/qml/cool-old-term/HighlightArea.qml \
|
|
||||||
$$PWD/qml/cool-old-term/ShaderSettings.qml \
|
|
||||||
$$PWD/qml/images/frame.png \
|
|
||||||
$$PWD/qml/cool-old-term/SettingsWindow.qml \
|
|
||||||
$$PWD/qml/cool-old-term/SettingComponent.qml \
|
|
||||||
$$PWD/qml/cool-old-term/ColorButton.qml \
|
|
||||||
$$PWD/qml/cool-old-term/TerminalFrame.qml \
|
|
||||||
$$PWD/qml/cool-old-term/WhiteFrameShader.qml \
|
|
||||||
$$PWD/qml/cool-old-term/NoFrameShader.qml \
|
|
||||||
$$PWD/qml/cool-old-term/WhiteSimpleFrame.qml \
|
|
||||||
qml/cool-old-term/BlackRoughFrame.qml \
|
|
||||||
qml/cool-old-term/Frames/BlackRoughFrame.qml \
|
|
||||||
qml/cool-old-term/Frames/NoFrameShader.qml \
|
|
||||||
qml/cool-old-term/Frames/WhiteFrameShader.qml \
|
|
||||||
qml/cool-old-term/Frames/WhiteSimpleFrame.qml \
|
|
||||||
qml/cool-old-term/Frames/TerminalFrame.qml \
|
|
||||||
qml/cool-old-term/Frames/utils/NoFrameShader.qml \
|
|
||||||
qml/cool-old-term/Frames/utils/TerminalFrame.qml \
|
|
||||||
qml/cool-old-term/Frames/utils/WhiteFrameShader.qml \
|
|
||||||
qml/cool-old-term/frames/WhiteSimpleFrame.qml \
|
|
||||||
qml/cool-old-term/frames/BlackRoughFrame.qml \
|
|
||||||
qml/cool-old-term/frames/utils/NoFrameShader.qml \
|
|
||||||
qml/cool-old-term/frames/utils/TerminalFrame.qml \
|
|
||||||
qml/cool-old-term/frames/utils/WhiteFrameShader.qml \
|
|
||||||
qml/cool-old-term/frames/images/screen-frame.png \
|
|
||||||
qml/cool-old-term/frames/images/screen-frame-normals.png \
|
|
||||||
qml/cool-old-term/frames/images/black-frame.png \
|
|
||||||
qml/cool-old-term/frames/images/black-frame-normals.png \
|
|
||||||
qml/cool-old-term/frames/NoFrame.qml \
|
|
||||||
qml/cool-old-term/TerminalWindow.qml \
|
|
||||||
qml/cool-old-term/Storage.qml \
|
|
||||||
qml/cool-old-term/ShaderManager.qml
|
|
||||||
|
5523
konsole-qml-plugin/Makefile
Normal file
15
konsole-qml-plugin/README
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
this is a repository for shared C++ QML plugin, offering access to
|
||||||
|
terminal sessions.
|
||||||
|
|
||||||
|
if you want to add something, please ask the maintainer of this library first to
|
||||||
|
make sure it's a good fit
|
||||||
|
|
||||||
|
the current maintainer is: Dmitry Zagnoyko <hiroshidi@gmail.com>
|
||||||
|
|
||||||
|
current plugin consist:
|
||||||
|
- KTerminal: offers access to terminal session from qml
|
||||||
|
- KSessions: offers access to pty(s) from C++ layer
|
||||||
|
|
||||||
|
Branched from:
|
||||||
|
https://code.launchpad.net/~ubuntu-terminal-dev/ubuntu-terminal-app/plugin
|
||||||
|
At revision 14
|
@ -0,0 +1,42 @@
|
|||||||
|
# example scheme for konsole
|
||||||
|
|
||||||
|
# the title is to appear in the menu.
|
||||||
|
|
||||||
|
title Black on Light Yellow
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 0 0 0 0 0 # regular foreground color (Black)
|
||||||
|
color 1 255 255 221 1 0 # regular background color (Light Yellow)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 0 0 0 0 1 # intensive foreground color
|
||||||
|
color 11 255 255 221 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,104 @@
|
|||||||
|
[Background]
|
||||||
|
Bold=false
|
||||||
|
Color=247,247,214
|
||||||
|
Transparency=true
|
||||||
|
MaxRandomHue=340
|
||||||
|
|
||||||
|
[BackgroundIntense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,255,221
|
||||||
|
Transparency=true
|
||||||
|
|
||||||
|
[Color0]
|
||||||
|
Bold=false
|
||||||
|
Color=0,0,0
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color0Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=104,104,104
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color1]
|
||||||
|
Bold=false
|
||||||
|
Color=178,24,24
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color1Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,84,84
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color2]
|
||||||
|
Bold=false
|
||||||
|
Color=24,178,24
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color2Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=84,255,84
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color3]
|
||||||
|
Bold=false
|
||||||
|
Color=178,104,24
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color3Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,255,84
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color4]
|
||||||
|
Bold=false
|
||||||
|
Color=24,24,178
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color4Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=84,84,255
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color5]
|
||||||
|
Bold=false
|
||||||
|
Color=178,24,178
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color5Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,84,255
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color6]
|
||||||
|
Bold=false
|
||||||
|
Color=24,178,178
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color6Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=84,255,255
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color7]
|
||||||
|
Bold=false
|
||||||
|
Color=178,178,178
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color7Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,255,255
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Foreground]
|
||||||
|
Bold=false
|
||||||
|
Color=0,0,0
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[ForegroundIntense]
|
||||||
|
Bold=true
|
||||||
|
Color=0,0,0
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[General]
|
||||||
|
Description=Black on Random Light
|
||||||
|
Opacity=1
|
42
konsole-qml-plugin/assets/color-schemes/BlackOnWhite.schema
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# example scheme for konsole
|
||||||
|
|
||||||
|
# the title is to appear in the menu.
|
||||||
|
|
||||||
|
title Black on White
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 0 0 0 0 0 # regular foreground color (Black)
|
||||||
|
color 1 255 255 255 1 0 # regular background color (White)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 0 0 0 0 1 # intensive foreground color
|
||||||
|
color 11 255 255 255 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
103
konsole-qml-plugin/assets/color-schemes/DarkPastels.colorscheme
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
[Background]
|
||||||
|
Bold=false
|
||||||
|
Color=44,44,44
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[BackgroundIntense]
|
||||||
|
Bold=true
|
||||||
|
Color=44,44,44
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color0]
|
||||||
|
Bold=false
|
||||||
|
Color=63,63,63
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color0Intense]
|
||||||
|
Bold=true
|
||||||
|
Color=112,144,128
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color1]
|
||||||
|
Bold=false
|
||||||
|
Color=112,80,80
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color1Intense]
|
||||||
|
Bold=true
|
||||||
|
Color=220,163,163
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color2]
|
||||||
|
Bold=false
|
||||||
|
Color=96,180,138
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color2Intense]
|
||||||
|
Bold=true
|
||||||
|
Color=114,213,163
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color3]
|
||||||
|
Bold=false
|
||||||
|
Color=223,175,143
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color3Intense]
|
||||||
|
Bold=true
|
||||||
|
Color=240,223,175
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color4]
|
||||||
|
Bold=false
|
||||||
|
Color=154,184,215
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color4Intense]
|
||||||
|
Bold=true
|
||||||
|
Color=148,191,243
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color5]
|
||||||
|
Bold=false
|
||||||
|
Color=220,140,195
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color5Intense]
|
||||||
|
Bold=true
|
||||||
|
Color=236,147,211
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color6]
|
||||||
|
Bold=false
|
||||||
|
Color=140,208,211
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color6Intense]
|
||||||
|
Bold=true
|
||||||
|
Color=147,224,227
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color7]
|
||||||
|
Bold=false
|
||||||
|
Color=220,220,204
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color7Intense]
|
||||||
|
Bold=true
|
||||||
|
Color=255,255,255
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Foreground]
|
||||||
|
Bold=false
|
||||||
|
Color=220,220,204
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[ForegroundIntense]
|
||||||
|
Bold=true
|
||||||
|
Color=220,220,204
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[General]
|
||||||
|
Description=Dark Pastels
|
||||||
|
Opacity=1
|
104
konsole-qml-plugin/assets/color-schemes/GreenOnBlack.colorscheme
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
|
||||||
|
[Background]
|
||||||
|
Bold=false
|
||||||
|
Color=0,0,0
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[BackgroundIntense]
|
||||||
|
Bold=false
|
||||||
|
Color=0,0,0
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color0]
|
||||||
|
Bold=false
|
||||||
|
Color=0,0,0
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color0Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=104,104,104
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color1]
|
||||||
|
Bold=false
|
||||||
|
Color=250,75,75
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color1Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,84,84
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color2]
|
||||||
|
Bold=false
|
||||||
|
Color=24,178,24
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color2Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=84,255,84
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color3]
|
||||||
|
Bold=false
|
||||||
|
Color=178,104,24
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color3Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,255,84
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color4]
|
||||||
|
Bold=false
|
||||||
|
Color=92,167,251
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color4Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=84,84,255
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color5]
|
||||||
|
Bold=false
|
||||||
|
Color=225,30,225
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color5Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,84,255
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color6]
|
||||||
|
Bold=false
|
||||||
|
Color=24,178,178
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color6Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=84,255,255
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color7]
|
||||||
|
Bold=false
|
||||||
|
Color=178,178,178
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Color7Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,255,255
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[Foreground]
|
||||||
|
Bold=false
|
||||||
|
Color=24,240,24
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[ForegroundIntense]
|
||||||
|
Bold=true
|
||||||
|
Color=24,240,24
|
||||||
|
Transparency=false
|
||||||
|
|
||||||
|
[General]
|
||||||
|
Description=Green on Black
|
||||||
|
Opacity=1
|
100
konsole-qml-plugin/assets/color-schemes/Linux.colorscheme
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
[Background]
|
||||||
|
Bold=false
|
||||||
|
Color=0,0,0
|
||||||
|
|
||||||
|
[BackgroundIntense]
|
||||||
|
Bold=false
|
||||||
|
Color=104,104,104
|
||||||
|
|
||||||
|
[Color0]
|
||||||
|
Bold=false
|
||||||
|
Color=0,0,0
|
||||||
|
|
||||||
|
|
||||||
|
[Color0Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=104,104,104
|
||||||
|
|
||||||
|
|
||||||
|
[Color1]
|
||||||
|
Bold=false
|
||||||
|
Color=178,24,24
|
||||||
|
|
||||||
|
|
||||||
|
[Color1Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,84,84
|
||||||
|
|
||||||
|
|
||||||
|
[Color2]
|
||||||
|
Bold=false
|
||||||
|
Color=24,178,24
|
||||||
|
|
||||||
|
|
||||||
|
[Color2Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=84,255,84
|
||||||
|
|
||||||
|
|
||||||
|
[Color3]
|
||||||
|
Bold=false
|
||||||
|
Color=178,104,24
|
||||||
|
|
||||||
|
|
||||||
|
[Color3Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,255,84
|
||||||
|
|
||||||
|
|
||||||
|
[Color4]
|
||||||
|
Bold=false
|
||||||
|
Color=24,24,178
|
||||||
|
|
||||||
|
|
||||||
|
[Color4Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=84,84,255
|
||||||
|
|
||||||
|
|
||||||
|
[Color5]
|
||||||
|
Bold=false
|
||||||
|
Color=178,24,178
|
||||||
|
|
||||||
|
|
||||||
|
[Color5Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,84,255
|
||||||
|
|
||||||
|
|
||||||
|
[Color6]
|
||||||
|
Bold=false
|
||||||
|
Color=24,178,178
|
||||||
|
|
||||||
|
|
||||||
|
[Color6Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=84,255,255
|
||||||
|
|
||||||
|
|
||||||
|
[Color7]
|
||||||
|
Bold=false
|
||||||
|
Color=178,178,178
|
||||||
|
|
||||||
|
|
||||||
|
[Color7Intense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,255,255
|
||||||
|
|
||||||
|
|
||||||
|
[Foreground]
|
||||||
|
Bold=false
|
||||||
|
Color=178,178,178
|
||||||
|
|
||||||
|
|
||||||
|
[ForegroundIntense]
|
||||||
|
Bold=false
|
||||||
|
Color=255,255,255
|
||||||
|
|
||||||
|
|
||||||
|
[General]
|
||||||
|
Description=Linux Colors
|
42
konsole-qml-plugin/assets/color-schemes/WhiteOnBlack.schema
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# example scheme for konsole
|
||||||
|
|
||||||
|
# the title is to appear in the menu.
|
||||||
|
|
||||||
|
title White on Black
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 255 255 255 0 0 # regular foreground color (White)
|
||||||
|
color 1 0 0 0 1 0 # regular background color (Black)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 255 255 255 0 1 # intensive foreground color
|
||||||
|
color 11 0 0 0 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,42 @@
|
|||||||
|
# example scheme for konsole
|
||||||
|
|
||||||
|
# the title is to appear in the menu.
|
||||||
|
|
||||||
|
title Black on Light Color
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 0 0 0 0 0 # regular foreground color (Black)
|
||||||
|
rcolor 1 30 255 1 0 # regular background color (Light Color)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 0 0 0 0 1 # intensive foreground color
|
||||||
|
color 11 255 255 221 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,44 @@
|
|||||||
|
# example scheme for konsole
|
||||||
|
|
||||||
|
# the title is to appear in the menu.
|
||||||
|
|
||||||
|
title Marble
|
||||||
|
|
||||||
|
image tile Blkmarble.jpg
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 255 255 255 0 0 # regular foreground color (White)
|
||||||
|
color 1 0 0 0 1 0 # regular background color (Black)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 255 255 255 0 1 # intensive foreground color
|
||||||
|
color 11 0 0 0 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,47 @@
|
|||||||
|
# example scheme for konsole
|
||||||
|
|
||||||
|
# the title is to appear in the menu.
|
||||||
|
|
||||||
|
title Ugly 1
|
||||||
|
|
||||||
|
# add a wallpaper, if you like. Second word one of { tile,center,full }
|
||||||
|
|
||||||
|
image tile /opt/kde/share/wallpapers/dancy_pants.jpg
|
||||||
|
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 0 0 0 0 0 # regular foreground color (Black)
|
||||||
|
color 1 255 255 255 1 0 # regular background color (White)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 255 0 0 0 0 # regular color 1 Red
|
||||||
|
color 4 0 255 0 0 0 # regular color 2 Green
|
||||||
|
color 5 255 255 0 0 0 # regular color 3 Yellow
|
||||||
|
color 6 0 0 255 0 0 # regular color 4 Blue
|
||||||
|
color 7 255 0 255 0 0 # regular color 5 Magenta
|
||||||
|
color 8 0 255 255 0 0 # regular color 6 Cyan
|
||||||
|
color 9 255 255 255 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 0 0 0 0 1 # intensive foreground color
|
||||||
|
color 11 255 255 255 1 1 # intensive background color
|
||||||
|
|
||||||
|
color 12 0 0 0 0 1 # intensive color 0
|
||||||
|
color 13 255 0 0 0 1 # intensive color 1
|
||||||
|
color 14 0 255 0 0 1 # intensive color 2
|
||||||
|
color 15 255 255 0 0 1 # intensive color 3
|
||||||
|
color 16 0 0 255 0 1 # intensive color 4
|
||||||
|
color 17 255 0 255 0 1 # intensive color 5
|
||||||
|
color 18 0 255 255 0 1 # intensive color 6
|
||||||
|
color 19 255 255 255 0 1 # intensive color 7
|
@ -0,0 +1,42 @@
|
|||||||
|
# example scheme for konsole
|
||||||
|
|
||||||
|
# the title is to appear in the menu.
|
||||||
|
|
||||||
|
title Green on Black
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 24 240 24 0 0 # regular foreground color (Green)
|
||||||
|
color 1 0 0 0 1 0 # regular background color (Black)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 24 240 24 0 1 # intensive foreground color
|
||||||
|
color 11 0 0 0 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,49 @@
|
|||||||
|
# linux color schema for konsole
|
||||||
|
|
||||||
|
title Green Tint
|
||||||
|
|
||||||
|
transparency 0.3 0 150 0
|
||||||
|
|
||||||
|
# FIXME
|
||||||
|
#
|
||||||
|
# The flaw in this schema is that "blick" comes out on the
|
||||||
|
# Linux console as intensive background, really.
|
||||||
|
# Since this is not used in clients you'll hardly notice
|
||||||
|
# it in practice.
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | red grn blu | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 178 178 178 0 0 # regular foreground color (White)
|
||||||
|
color 1 0 0 0 1 0 # regular background color (Black)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 255 255 255 0 0 # intensive foreground color
|
||||||
|
color 11 104 104 104 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,49 @@
|
|||||||
|
# linux color schema for konsole
|
||||||
|
|
||||||
|
title Green Tint with Transparent MC
|
||||||
|
|
||||||
|
transparency 0.3 0 150 0
|
||||||
|
|
||||||
|
# FIXME
|
||||||
|
#
|
||||||
|
# The flaw in this schema is that "blick" comes out on the
|
||||||
|
# Linux console as intensive background, really.
|
||||||
|
# Since this is not used in clients you'll hardly notice
|
||||||
|
# it in practice.
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | red grn blu | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 178 178 178 0 0 # regular foreground color (White)
|
||||||
|
color 1 0 0 0 1 0 # regular background color (Black)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 0 0 0 1 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 255 255 255 0 0 # intensive foreground color
|
||||||
|
color 11 104 104 104 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,44 @@
|
|||||||
|
# example scheme for konsole
|
||||||
|
|
||||||
|
# the title is to appear in the menu.
|
||||||
|
|
||||||
|
title Paper
|
||||||
|
|
||||||
|
image tile Paper01.jpg
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 0 0 0 0 0 # regular foreground color (Black)
|
||||||
|
color 1 255 255 255 1 0 # regular background color (White)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 0 0 0 0 1 # intensive foreground color
|
||||||
|
color 11 255 255 255 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,47 @@
|
|||||||
|
# linux color schema for konsole
|
||||||
|
|
||||||
|
title Linux Colors
|
||||||
|
|
||||||
|
# FIXME
|
||||||
|
#
|
||||||
|
# The flaw in this schema is that "blick" comes out on the
|
||||||
|
# Linux console as intensive background, really.
|
||||||
|
# Since this is not used in clients you'll hardly notice
|
||||||
|
# it in practice.
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | red grn blu | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 178 178 178 0 0 # regular foreground color (White)
|
||||||
|
color 1 0 0 0 1 0 # regular background color (Black)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 255 255 255 0 0 # intensive foreground color
|
||||||
|
color 11 104 104 104 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
132
konsole-qml-plugin/assets/color-schemes/historic/README.Schema
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
[README.Schema]
|
||||||
|
|
||||||
|
The schemata offered in the Options/Schema menu are
|
||||||
|
taken from from configurations files with a *.schema
|
||||||
|
pattern either located in $KDEDIR/share/apps/konsole
|
||||||
|
or ~/.kde/share/apps/konsole.
|
||||||
|
|
||||||
|
Schemata allow to configure the color set that konsole
|
||||||
|
uses, together with some more information on rendition
|
||||||
|
processing.
|
||||||
|
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
File
|
||||||
|
:: { [Line] ['#' Comment] '\n' }
|
||||||
|
|
||||||
|
Line
|
||||||
|
:: "title" Title
|
||||||
|
:: "image" Usage PathToPictureFile
|
||||||
|
:: "transparency" Fade Red Green Blue
|
||||||
|
:: "color" Slot Red Green Blue Transparent Bold
|
||||||
|
:: "rcolor" Slot Saturation Value Transparent Bold
|
||||||
|
:: "sysfg" Slot Transparent Bold
|
||||||
|
:: "sysbg" Slot Transparent Bold
|
||||||
|
|
||||||
|
Meaning
|
||||||
|
|
||||||
|
- Title is the text to appear in the Option/Schema menu.
|
||||||
|
It should be unique among all other schemata therefore.
|
||||||
|
|
||||||
|
- The "image" clause allows to place an image on the
|
||||||
|
konsole's background.
|
||||||
|
|
||||||
|
- Usage can be either
|
||||||
|
- "tile" - the image is tilewise replicated.
|
||||||
|
- "center" - the image is centered.
|
||||||
|
- "full" - the image is stretched to fit the window size.
|
||||||
|
|
||||||
|
- The Path of the picture can both be relative
|
||||||
|
(to kde wallpapers) or absolute.
|
||||||
|
|
||||||
|
When a schema uses a background image (or transparency)
|
||||||
|
one has to make at least one color slot transparent to
|
||||||
|
achive any visible effect. Please read below about the
|
||||||
|
"Transparent" field in color,sysbg,sysfg.
|
||||||
|
|
||||||
|
- The "transparency" clause picks and uses the background
|
||||||
|
of the desktop as if it where an image together with
|
||||||
|
a fade effect. This effect will fade the background
|
||||||
|
to the specified color.
|
||||||
|
|
||||||
|
The "Fade" is a real value between 0 and 1, indicating
|
||||||
|
the strength of the fade. A value of 0 will not change
|
||||||
|
the image, a value of 1 will make it the fade color
|
||||||
|
everywhere, and in between. This will make the "glas"
|
||||||
|
of the window be of the color given in the clause and
|
||||||
|
being more(1) or less(0) intransparent.
|
||||||
|
|
||||||
|
- The remaining clauses (color,sysbg,sysfg) are used
|
||||||
|
to setup konsoles rendition system.
|
||||||
|
|
||||||
|
To this end, konsole offers 20 color slots.
|
||||||
|
|
||||||
|
Slot Meaning
|
||||||
|
----- --------------------------
|
||||||
|
0 regular foreground color
|
||||||
|
1 regular background color
|
||||||
|
2-9 regular bgr color 0-7
|
||||||
|
10 intensive foreground color
|
||||||
|
11 intensive background color
|
||||||
|
12-19 intensive bgr color 0-7
|
||||||
|
|
||||||
|
The traditional meaning of the "bgr" color codes
|
||||||
|
has a bitwise interpretation of an additive three
|
||||||
|
primary color scheme inherited from early EGA
|
||||||
|
color terminals.
|
||||||
|
|
||||||
|
Color Bits Colors
|
||||||
|
----- ---- -------
|
||||||
|
0 000 Black
|
||||||
|
1 001 Red
|
||||||
|
2 010 Green
|
||||||
|
3 011 Yellow
|
||||||
|
4 100 Blue
|
||||||
|
5 101 Magenta
|
||||||
|
6 110 Cyan
|
||||||
|
7 111 White
|
||||||
|
|
||||||
|
One may or may not stick to this tradition.
|
||||||
|
Konsole allows to assign colors freely to slots.
|
||||||
|
|
||||||
|
The slots fall apart into two groups, regular
|
||||||
|
and intensive colors. The later are used when
|
||||||
|
BOLD rendition is used by the client.
|
||||||
|
|
||||||
|
Each of the groups have a default fore- and
|
||||||
|
background color and the said bgr colors.
|
||||||
|
Normal terminal processing will simply use
|
||||||
|
the default colors.
|
||||||
|
|
||||||
|
The color desired for a slot is indicated
|
||||||
|
in the Red Green Blue fields of the color
|
||||||
|
clause. Use the sysfg or the sysbg clause
|
||||||
|
to indicate the default fore and background
|
||||||
|
colors of the desktop.
|
||||||
|
|
||||||
|
To specify randomized color for a slot use
|
||||||
|
the clause rcolor. The two parameters to it
|
||||||
|
being Saturation - the amount of colour,
|
||||||
|
and Value, the darkness of the colour.
|
||||||
|
|
||||||
|
To use transparency/images and to simulate
|
||||||
|
the behavior of the xterm, one can supply
|
||||||
|
two additional tags to each slot:
|
||||||
|
- Transparent (0/1) meaning to show the
|
||||||
|
background picture, if any.
|
||||||
|
- Bold (0/1) to render characters bold.
|
||||||
|
|
||||||
|
|
||||||
|
If you know about the escape codes, you might have
|
||||||
|
noticed that intensive and bold rendition are sort
|
||||||
|
of confused. This is inherited by the xterm which
|
||||||
|
konsole is simulating.
|
||||||
|
|
||||||
|
One can use the colortest.sh script supplied
|
||||||
|
with the konsole source distribution to test
|
||||||
|
a schema.
|
||||||
|
|
||||||
|
The schema installed with konsole are more or
|
||||||
|
less demonstrations and not really beauty,
|
||||||
|
beside the Linux.schema, perhaps, which is
|
||||||
|
made after the VGA colors.
|
@ -0,0 +1,44 @@
|
|||||||
|
# default scheme for konsole (only here for documentation purposes)
|
||||||
|
|
||||||
|
# the title is to appear in the menu.
|
||||||
|
|
||||||
|
title Konsole Defaults
|
||||||
|
|
||||||
|
# image tile /opt/kde/share/wallpapers/gray2.jpg
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 0 0 0 0 0 # regular foreground color (Black)
|
||||||
|
color 1 255 255 255 1 0 # regular background color (White)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 0 0 0 0 1 # intensive foreground color
|
||||||
|
color 11 255 255 255 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,49 @@
|
|||||||
|
# linux color schema for konsole
|
||||||
|
|
||||||
|
title Transparent Konsole
|
||||||
|
|
||||||
|
transparency 0.35 0 0 0
|
||||||
|
|
||||||
|
# FIXME
|
||||||
|
#
|
||||||
|
# The flaw in this schema is that "blick" comes out on the
|
||||||
|
# Linux console as intensive background, really.
|
||||||
|
# Since this is not used in clients you'll hardly notice
|
||||||
|
# it in practice.
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | red grn blu | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 178 178 178 0 0 # regular foreground color (White)
|
||||||
|
color 1 0 0 0 1 0 # regular background color (Black)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 255 255 255 0 0 # intensive foreground color
|
||||||
|
color 11 104 104 104 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,51 @@
|
|||||||
|
# linux color schema for konsole
|
||||||
|
|
||||||
|
title Transparent for MC
|
||||||
|
|
||||||
|
transparency 0.35 0 0 0
|
||||||
|
|
||||||
|
# FIXME
|
||||||
|
#
|
||||||
|
# The flaw in this schema is that "blick" comes out on the
|
||||||
|
# Linux console as intensive background, really.
|
||||||
|
# Since this is not used in clients you'll hardly notice
|
||||||
|
# it in practice.
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | red grn blu | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 178 178 178 0 0 # regular foreground color (White)
|
||||||
|
color 1 0 0 0 1 0 # regular background color (Black)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
#color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 6 0 0 0 1 0 # regular color 4 Blue
|
||||||
|
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 255 255 255 0 0 # intensive foreground color
|
||||||
|
color 11 104 104 104 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,42 @@
|
|||||||
|
# linux color schema for konsole
|
||||||
|
|
||||||
|
title Transparent, Dark Background
|
||||||
|
|
||||||
|
transparency 0.75 0 0 0
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | red grn blu | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 255 255 255 0 0 # regular foreground color (White)
|
||||||
|
color 1 0 0 0 1 0 # regular background color (Black)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 255 255 255 0 0 # intensive foreground color
|
||||||
|
color 11 104 104 104 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,51 @@
|
|||||||
|
# linux color schema for konsole
|
||||||
|
|
||||||
|
title Transparent, Light Background
|
||||||
|
|
||||||
|
transparency 0.1 0 0 0
|
||||||
|
|
||||||
|
# This is a schema for very light backgrounds. It makes some
|
||||||
|
# hacks about the colors to make Midnight Commander transparent
|
||||||
|
# and with suitable colors.
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | red grn blu | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 50 50 50 0 0 # regular foreground color (DarkGray)
|
||||||
|
color 1 200 200 200 1 0 # regular background color (White)
|
||||||
|
|
||||||
|
# color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 2 200 200 200 1 0 # regular background color (White)
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
#color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 6 0 0 0 1 0 # regular color 4 Blue
|
||||||
|
# Blue is transparent, to make MC transparent
|
||||||
|
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
# color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
color 9 50 50 50 0 0 # regular foreground color (DarkGray)
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 0 0 0 0 0 # intensive foreground color
|
||||||
|
color 11 255 255 255 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
@ -0,0 +1,46 @@
|
|||||||
|
# xterm color schema for konsole
|
||||||
|
|
||||||
|
# xterm colors can be configured (almost) like
|
||||||
|
# konsole colors can. This is the uncustomized
|
||||||
|
# xterm schema.
|
||||||
|
# Please refere to your local xterm setup files
|
||||||
|
# if this schema differs.
|
||||||
|
|
||||||
|
title XTerm Colors
|
||||||
|
|
||||||
|
# foreground colors -------------------------------
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | red grn blu | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 0 0 0 0 0 # regular foreground color (Black)
|
||||||
|
color 1 255 255 255 1 0 # regular background color (White)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 205 0 0 0 0 # regular color 1 Red
|
||||||
|
color 4 0 205 0 0 0 # regular color 2 Green
|
||||||
|
color 5 205 205 0 0 0 # regular color 3 Yellow
|
||||||
|
color 6 0 0 205 0 0 # regular color 4 Blue
|
||||||
|
color 7 205 0 205 0 0 # regular color 5 Magenta
|
||||||
|
color 8 0 205 205 0 0 # regular color 6 Cyan
|
||||||
|
color 9 229 229 229 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors -------------------------------------------
|
||||||
|
|
||||||
|
# for some strange reason, intensive colors are bold, also.
|
||||||
|
|
||||||
|
color 10 77 77 77 0 1 # intensive foreground color
|
||||||
|
color 11 255 255 255 1 1 # intensive background color
|
||||||
|
|
||||||
|
color 12 77 77 77 0 1 # intensive color 0
|
||||||
|
color 13 255 0 0 0 1 # intensive color 1
|
||||||
|
color 14 0 255 0 0 1 # intensive color 2
|
||||||
|
color 15 255 255 0 0 1 # intensive color 3
|
||||||
|
color 16 0 0 255 0 1 # intensive color 4
|
||||||
|
color 17 255 0 255 0 1 # intensive color 5
|
||||||
|
color 18 0 255 255 0 1 # intensive color 6
|
||||||
|
color 19 255 255 255 0 1 # intensive color 7
|
@ -0,0 +1,44 @@
|
|||||||
|
# schema that uses system colors
|
||||||
|
|
||||||
|
# the title is to appear in the menu.
|
||||||
|
|
||||||
|
title System Colors
|
||||||
|
|
||||||
|
# image none
|
||||||
|
|
||||||
|
# foreground colors
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
sysfg 0 0 0 # regular foreground color (system)
|
||||||
|
sysbg 1 1 0 # regular background color (system)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 178 24 24 0 0 # regular color 1 Red
|
||||||
|
color 4 24 178 24 0 0 # regular color 2 Green
|
||||||
|
color 5 178 104 24 0 0 # regular color 3 Yellow
|
||||||
|
color 6 24 24 178 0 0 # regular color 4 Blue
|
||||||
|
color 7 178 24 178 0 0 # regular color 5 Magenta
|
||||||
|
color 8 24 178 178 0 0 # regular color 6 Cyan
|
||||||
|
color 9 178 178 178 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors
|
||||||
|
|
||||||
|
# instead of changing the colors, we've flaged the text to become bold
|
||||||
|
|
||||||
|
color 10 0 0 0 0 1 # intensive foreground color
|
||||||
|
color 11 255 255 255 1 0 # intensive background color
|
||||||
|
|
||||||
|
color 12 104 104 104 0 0 # intensive color 0
|
||||||
|
color 13 255 84 84 0 0 # intensive color 1
|
||||||
|
color 14 84 255 84 0 0 # intensive color 2
|
||||||
|
color 15 255 255 84 0 0 # intensive color 3
|
||||||
|
color 16 84 84 255 0 0 # intensive color 4
|
||||||
|
color 17 255 84 255 0 0 # intensive color 5
|
||||||
|
color 18 84 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
40
konsole-qml-plugin/assets/color-schemes/historic/vim.schema
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# VIM-recommended color schema for konsole
|
||||||
|
|
||||||
|
# VIM (VI improved) in "help xiterm" recommends these colors for xterm.
|
||||||
|
|
||||||
|
title VIM Colors
|
||||||
|
|
||||||
|
# foreground colors -------------------------------
|
||||||
|
|
||||||
|
# note that the default background color is flagged
|
||||||
|
# to become transparent when an image is present.
|
||||||
|
|
||||||
|
# slot transparent bold
|
||||||
|
# | red grn blu | |
|
||||||
|
# V V--color--V V V
|
||||||
|
|
||||||
|
color 0 0 0 0 0 0 # regular foreground color (Black)
|
||||||
|
color 1 255 255 255 1 0 # regular background color (White)
|
||||||
|
|
||||||
|
color 2 0 0 0 0 0 # regular color 0 Black
|
||||||
|
color 3 192 0 0 0 0 # regular color 1 Red
|
||||||
|
color 4 0 128 0 0 0 # regular color 2 Green
|
||||||
|
color 5 128 128 0 0 0 # regular color 3 Yellow
|
||||||
|
color 6 0 0 192 0 0 # regular color 4 Blue
|
||||||
|
color 7 192 0 192 0 0 # regular color 5 Magenta
|
||||||
|
color 8 0 128 128 0 0 # regular color 6 Cyan
|
||||||
|
color 9 192 192 192 0 0 # regular color 7 White
|
||||||
|
|
||||||
|
# intensive colors -------------------------------------------
|
||||||
|
|
||||||
|
color 10 77 77 77 0 1 # intensive foreground color
|
||||||
|
color 11 255 255 255 1 1 # intensive background color
|
||||||
|
|
||||||
|
color 12 128 128 128 0 0 # intensive color 0
|
||||||
|
color 13 255 96 96 0 0 # intensive color 1
|
||||||
|
color 14 0 255 0 0 0 # intensive color 2
|
||||||
|
color 15 255 255 0 0 0 # intensive color 3
|
||||||
|
color 16 128 128 255 0 0 # intensive color 4
|
||||||
|
color 17 255 64 255 0 0 # intensive color 5
|
||||||
|
color 18 0 255 255 0 0 # intensive color 6
|
||||||
|
color 19 255 255 255 0 0 # intensive color 7
|
72
konsole-qml-plugin/assets/kb-layouts/README
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
[README.KeyTab]
|
||||||
|
|
||||||
|
The keytabs offered in the Options/Keyboard menu are
|
||||||
|
taken from from configurations files with a *.keytab
|
||||||
|
pattern either located in $KDEDIR/share/apps/konsole
|
||||||
|
or ~/.kde/share/apps/konsole.
|
||||||
|
|
||||||
|
Keytabs allow to configure the behavior of konsole
|
||||||
|
on keyboard events, especially for functions keys.
|
||||||
|
Please have a look into the README.keyboard file, too.
|
||||||
|
|
||||||
|
The syntax is that each entry has the form :
|
||||||
|
|
||||||
|
"key" Keyname { ("+"|"-") Modename } ":" (String|Operation)
|
||||||
|
|
||||||
|
Keynames are those defined in <qnamespace.h> with the
|
||||||
|
"Qt::Key_" prefix removed.
|
||||||
|
|
||||||
|
Mode names are:
|
||||||
|
|
||||||
|
- Shift : Shift Key pressed
|
||||||
|
- Alt : Alt Key pressed
|
||||||
|
- Control : Control Key pressed
|
||||||
|
|
||||||
|
( The VT100 emulation has modes that can affect the
|
||||||
|
sequences emitted by certain keys. These modes are
|
||||||
|
under control of the client program.
|
||||||
|
|
||||||
|
- Newline : effects Return and Enter key.
|
||||||
|
- Application : effects Up and Down key.
|
||||||
|
- Ansi : effects Up and Down key (This is for VT52, really).
|
||||||
|
|
||||||
|
Since sending a state to a program that has set the state
|
||||||
|
itself is positivly wrong and obsolete design, better forget
|
||||||
|
about this nasty detail. I may well remove this "feature"
|
||||||
|
in a future clean up round. )
|
||||||
|
|
||||||
|
A "+" preceeding a Modename means the Key is pressed.
|
||||||
|
A "-" preceeding a Modename means the Key is not pressed.
|
||||||
|
If no mode is given it means don't care.
|
||||||
|
|
||||||
|
Note that the combination of Key and Modes (set/reset)
|
||||||
|
has to be unique. This means, that
|
||||||
|
|
||||||
|
key A + Shift : "A"
|
||||||
|
key A : "a"
|
||||||
|
|
||||||
|
will not accept the small letter "a" rule as expected,
|
||||||
|
one has to add a "- Shift" to the last clause. Use
|
||||||
|
the stdout/stderr dianostics of konsole when modifying
|
||||||
|
keytabs to find problems like this.
|
||||||
|
|
||||||
|
Operations are
|
||||||
|
|
||||||
|
- scrollUpLine : scroll up one line in the history log
|
||||||
|
- scrollUpPage : scroll up one page in the history log
|
||||||
|
- scrollDownLine : scroll down one line in the history log
|
||||||
|
- scrollDownPage : scroll down one page in the history log
|
||||||
|
- emitClipboard : "paste" the current clipboard
|
||||||
|
- emitSelection : "paste" the current selection
|
||||||
|
|
||||||
|
Strings have the syntax of C strings,
|
||||||
|
one may use the following escapes:
|
||||||
|
|
||||||
|
- \E - escape
|
||||||
|
- \\ - backslash
|
||||||
|
- \" - double quote
|
||||||
|
- \t - tab
|
||||||
|
- \r - return
|
||||||
|
- \n - newline
|
||||||
|
- \b - backspace
|
||||||
|
- \xHH - where HH are two hex digits
|
169
konsole-qml-plugin/assets/kb-layouts/default.keytab
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
# [README.default.Keytab] Default Keyboard Table
|
||||||
|
#
|
||||||
|
# To customize your keyboard, copy this file to something
|
||||||
|
# ending with .keytab and change it to meet you needs.
|
||||||
|
# Please read the README.KeyTab and the README.keyboard
|
||||||
|
# in this case.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
keyboard "Default (XFree 4)"
|
||||||
|
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Note that this particular table is a "risc" version made to
|
||||||
|
# ease customization without bothering with obsolete details.
|
||||||
|
# See VT100.keytab for the more hairy stuff.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
# common keys
|
||||||
|
|
||||||
|
key Escape : "\E"
|
||||||
|
|
||||||
|
key Tab -Shift : "\t"
|
||||||
|
key Tab +Shift+Ansi : "\E[Z"
|
||||||
|
key Tab +Shift-Ansi : "\t"
|
||||||
|
key Backtab +Ansi : "\E[Z"
|
||||||
|
key Backtab -Ansi : "\t"
|
||||||
|
|
||||||
|
key Return-Shift-NewLine : "\r"
|
||||||
|
key Return-Shift+NewLine : "\r\n"
|
||||||
|
|
||||||
|
key Return+Shift : "\EOM"
|
||||||
|
|
||||||
|
# Backspace and Delete codes are preserving CTRL-H.
|
||||||
|
|
||||||
|
key Backspace : "\x7f"
|
||||||
|
|
||||||
|
# Arrow keys in VT52 mode
|
||||||
|
# shift up/down are reserved for scrolling.
|
||||||
|
# shift left/right are reserved for switching between tabs (this is hardcoded).
|
||||||
|
|
||||||
|
key Up -Shift-Ansi : "\EA"
|
||||||
|
key Down -Shift-Ansi : "\EB"
|
||||||
|
key Right-Shift-Ansi : "\EC"
|
||||||
|
key Left -Shift-Ansi : "\ED"
|
||||||
|
|
||||||
|
# Arrow keys in ANSI mode with Application - and Normal Cursor Mode)
|
||||||
|
|
||||||
|
key Up -Shift-AnyMod+Ansi+AppCuKeys : "\EOA"
|
||||||
|
key Down -Shift-AnyMod+Ansi+AppCuKeys : "\EOB"
|
||||||
|
key Right -Shift-AnyMod+Ansi+AppCuKeys : "\EOC"
|
||||||
|
key Left -Shift-AnyMod+Ansi+AppCuKeys : "\EOD"
|
||||||
|
|
||||||
|
key Up -Shift-AnyMod+Ansi-AppCuKeys : "\E[A"
|
||||||
|
key Down -Shift-AnyMod+Ansi-AppCuKeys : "\E[B"
|
||||||
|
key Right -Shift-AnyMod+Ansi-AppCuKeys : "\E[C"
|
||||||
|
key Left -Shift-AnyMod+Ansi-AppCuKeys : "\E[D"
|
||||||
|
|
||||||
|
key Up -Shift+AnyMod+Ansi : "\E[1;*A"
|
||||||
|
key Down -Shift+AnyMod+Ansi : "\E[1;*B"
|
||||||
|
key Right -Shift+AnyMod+Ansi : "\E[1;*C"
|
||||||
|
key Left -Shift+AnyMod+Ansi : "\E[1;*D"
|
||||||
|
|
||||||
|
# Keypad keys with NumLock ON
|
||||||
|
# (see "Numeric Keypad" section at http://www.nw.com/nw/WWW/products/wizcon/vt100.html )
|
||||||
|
#
|
||||||
|
# Not enabled for now because it breaks the keypad in Vim.
|
||||||
|
#
|
||||||
|
#key 0 +KeyPad+AppKeyPad : "\EOp"
|
||||||
|
#key 1 +KeyPad+AppKeyPad : "\EOq"
|
||||||
|
#key 2 +KeyPad+AppKeyPad : "\EOr"
|
||||||
|
#key 3 +KeyPad+AppKeyPad : "\EOs"
|
||||||
|
#key 4 +KeyPad+AppKeyPad : "\EOt"
|
||||||
|
#key 5 +KeyPad+AppKeyPad : "\EOu"
|
||||||
|
#key 6 +KeyPad+AppKeyPad : "\EOv"
|
||||||
|
#key 7 +KeyPad+AppKeyPad : "\EOw"
|
||||||
|
#key 8 +KeyPad+AppKeyPad : "\EOx"
|
||||||
|
#key 9 +KeyPad+AppKeyPad : "\EOy"
|
||||||
|
#key + +KeyPad+AppKeyPad : "\EOl"
|
||||||
|
#key - +KeyPad+AppKeyPad : "\EOm"
|
||||||
|
#key . +KeyPad+AppKeyPad : "\EOn"
|
||||||
|
#key * +KeyPad+AppKeyPad : "\EOM"
|
||||||
|
#key Enter +KeyPad+AppKeyPad : "\r"
|
||||||
|
|
||||||
|
# Keypad keys with NumLock Off
|
||||||
|
key Up -Shift+Ansi+AppCuKeys+KeyPad : "\EOA"
|
||||||
|
key Down -Shift+Ansi+AppCuKeys+KeyPad : "\EOB"
|
||||||
|
key Right -Shift+Ansi+AppCuKeys+KeyPad : "\EOC"
|
||||||
|
key Left -Shift+Ansi+AppCuKeys+KeyPad : "\EOD"
|
||||||
|
|
||||||
|
key Up -Shift+Ansi-AppCuKeys+KeyPad : "\E[A"
|
||||||
|
key Down -Shift+Ansi-AppCuKeys+KeyPad : "\E[B"
|
||||||
|
key Right -Shift+Ansi-AppCuKeys+KeyPad : "\E[C"
|
||||||
|
key Left -Shift+Ansi-AppCuKeys+KeyPad : "\E[D"
|
||||||
|
|
||||||
|
key Home +AppCuKeys+KeyPad : "\EOH"
|
||||||
|
key End +AppCuKeys+KeyPad : "\EOF"
|
||||||
|
key Home -AppCuKeys+KeyPad : "\E[H"
|
||||||
|
key End -AppCuKeys+KeyPad : "\E[F"
|
||||||
|
|
||||||
|
key Insert +KeyPad : "\E[2~"
|
||||||
|
key Delete +KeyPad : "\E[3~"
|
||||||
|
key Prior -Shift+KeyPad : "\E[5~"
|
||||||
|
key Next -Shift+KeyPad : "\E[6~"
|
||||||
|
|
||||||
|
# other grey PC keys
|
||||||
|
|
||||||
|
key Enter+NewLine : "\r\n"
|
||||||
|
key Enter-NewLine : "\r"
|
||||||
|
|
||||||
|
key Home -AnyMod-AppCuKeys : "\E[H"
|
||||||
|
key End -AnyMod-AppCuKeys : "\E[F"
|
||||||
|
key Home -AnyMod+AppCuKeys : "\EOH"
|
||||||
|
key End -AnyMod+AppCuKeys : "\EOF"
|
||||||
|
key Home +AnyMod : "\E[1;*H"
|
||||||
|
key End +AnyMod : "\E[1;*F"
|
||||||
|
|
||||||
|
key Insert -AnyMod : "\E[2~"
|
||||||
|
key Delete -AnyMod : "\E[3~"
|
||||||
|
key Insert +AnyMod : "\E[2;*~"
|
||||||
|
key Delete +AnyMod : "\E[3;*~"
|
||||||
|
|
||||||
|
key Prior -Shift-AnyMod : "\E[5~"
|
||||||
|
key Next -Shift-AnyMod : "\E[6~"
|
||||||
|
key Prior -Shift+AnyMod : "\E[5;*~"
|
||||||
|
key Next -Shift+AnyMod : "\E[6;*~"
|
||||||
|
|
||||||
|
# Function keys
|
||||||
|
key F1 -AnyMod : "\EOP"
|
||||||
|
key F2 -AnyMod : "\EOQ"
|
||||||
|
key F3 -AnyMod : "\EOR"
|
||||||
|
key F4 -AnyMod : "\EOS"
|
||||||
|
key F5 -AnyMod : "\E[15~"
|
||||||
|
key F6 -AnyMod : "\E[17~"
|
||||||
|
key F7 -AnyMod : "\E[18~"
|
||||||
|
key F8 -AnyMod : "\E[19~"
|
||||||
|
key F9 -AnyMod : "\E[20~"
|
||||||
|
key F10 -AnyMod : "\E[21~"
|
||||||
|
key F11 -AnyMod : "\E[23~"
|
||||||
|
key F12 -AnyMod : "\E[24~"
|
||||||
|
|
||||||
|
key F1 +AnyMod : "\EO*P"
|
||||||
|
key F2 +AnyMod : "\EO*Q"
|
||||||
|
key F3 +AnyMod : "\EO*R"
|
||||||
|
key F4 +AnyMod : "\EO*S"
|
||||||
|
key F5 +AnyMod : "\E[15;*~"
|
||||||
|
key F6 +AnyMod : "\E[17;*~"
|
||||||
|
key F7 +AnyMod : "\E[18;*~"
|
||||||
|
key F8 +AnyMod : "\E[19;*~"
|
||||||
|
key F9 +AnyMod : "\E[20;*~"
|
||||||
|
key F10 +AnyMod : "\E[21;*~"
|
||||||
|
key F11 +AnyMod : "\E[23;*~"
|
||||||
|
key F12 +AnyMod : "\E[24;*~"
|
||||||
|
|
||||||
|
# Work around dead keys
|
||||||
|
|
||||||
|
key Space +Control : "\x00"
|
||||||
|
|
||||||
|
# Some keys are used by konsole to cause operations.
|
||||||
|
# The scroll* operations refer to the history buffer.
|
||||||
|
|
||||||
|
key Up +Shift-AppScreen : scrollLineUp
|
||||||
|
key Prior +Shift-AppScreen : scrollPageUp
|
||||||
|
key Down +Shift-AppScreen : scrollLineDown
|
||||||
|
key Next +Shift-AppScreen : scrollPageDown
|
||||||
|
|
||||||
|
key ScrollLock : scrollLock
|
||||||
|
|
133
konsole-qml-plugin/assets/kb-layouts/historic/vt100.keytab
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
# [vt100.keytab] Konsole Keyboard Table (VT100 keys)
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
keyboard "vt100 (historical)"
|
||||||
|
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# This configuration table allows to customize the
|
||||||
|
# meaning of the keys.
|
||||||
|
#
|
||||||
|
# The syntax is that each entry has the form :
|
||||||
|
#
|
||||||
|
# "key" Keyname { ("+"|"-") Modename } ":" (String|Operation)
|
||||||
|
#
|
||||||
|
# Keynames are those defined in <qnamespace.h> with the
|
||||||
|
# "Qt::Key_" removed. (We'd better insert the list here)
|
||||||
|
#
|
||||||
|
# Mode names are :
|
||||||
|
#
|
||||||
|
# - Shift
|
||||||
|
# - Alt
|
||||||
|
# - Control
|
||||||
|
#
|
||||||
|
# The VT100 emulation has two modes that can affect the
|
||||||
|
# sequences emitted by certain keys. These modes are
|
||||||
|
# under control of the client program.
|
||||||
|
#
|
||||||
|
# - Newline : effects Return and Enter key.
|
||||||
|
# - Application : effects Up and Down key.
|
||||||
|
#
|
||||||
|
# - Ansi : effects Up and Down key (This is for VT52, really).
|
||||||
|
#
|
||||||
|
# Operations are
|
||||||
|
#
|
||||||
|
# - scrollUpLine
|
||||||
|
# - scrollUpPage
|
||||||
|
# - scrollDownLine
|
||||||
|
# - scrollDownPage
|
||||||
|
#
|
||||||
|
# - emitSelection
|
||||||
|
#
|
||||||
|
# If the key is not found here, the text of the
|
||||||
|
# key event as provided by QT is emitted, possibly
|
||||||
|
# preceeded by ESC if the Alt key is pressed.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
key Escape : "\E"
|
||||||
|
key Tab : "\t"
|
||||||
|
|
||||||
|
# VT100 can add an extra \n after return.
|
||||||
|
# The NewLine mode is set by an escape sequence.
|
||||||
|
|
||||||
|
key Return-NewLine : "\r"
|
||||||
|
key Return+NewLine : "\r\n"
|
||||||
|
|
||||||
|
# Some desperately try to save the ^H.
|
||||||
|
|
||||||
|
key Backspace : "\x7f"
|
||||||
|
key Delete : "\E[3~"
|
||||||
|
|
||||||
|
# These codes are for the VT52 mode of VT100
|
||||||
|
# The Ansi mode (i.e. VT100 mode) is set by
|
||||||
|
# an escape sequence
|
||||||
|
|
||||||
|
key Up -Shift-Ansi : "\EA"
|
||||||
|
key Down -Shift-Ansi : "\EB"
|
||||||
|
key Right-Shift-Ansi : "\EC"
|
||||||
|
key Left -Shift-Ansi : "\ED"
|
||||||
|
|
||||||
|
# VT100 emits a mode bit together
|
||||||
|
# with the arrow keys.The AppCuKeys
|
||||||
|
# mode is set by an escape sequence.
|
||||||
|
|
||||||
|
key Up -Shift+Ansi+AppCuKeys : "\EOA"
|
||||||
|
key Down -Shift+Ansi+AppCuKeys : "\EOB"
|
||||||
|
key Right-Shift+Ansi+AppCuKeys : "\EOC"
|
||||||
|
key Left -Shift+Ansi+AppCuKeys : "\EOD"
|
||||||
|
|
||||||
|
key Up -Shift+Ansi-AppCuKeys : "\E[A"
|
||||||
|
key Down -Shift+Ansi-AppCuKeys : "\E[B"
|
||||||
|
key Right-Shift+Ansi-AppCuKeys : "\E[C"
|
||||||
|
key Left -Shift+Ansi-AppCuKeys : "\E[D"
|
||||||
|
|
||||||
|
# function keys (FIXME: make pf1-pf4)
|
||||||
|
|
||||||
|
key F1 : "\E[11~"
|
||||||
|
key F2 : "\E[12~"
|
||||||
|
key F3 : "\E[13~"
|
||||||
|
key F4 : "\E[14~"
|
||||||
|
key F5 : "\E[15~"
|
||||||
|
|
||||||
|
key F6 : "\E[17~"
|
||||||
|
key F7 : "\E[18~"
|
||||||
|
key F8 : "\E[19~"
|
||||||
|
key F9 : "\E[20~"
|
||||||
|
key F10 : "\E[21~"
|
||||||
|
key F11 : "\E[23~"
|
||||||
|
key F12 : "\E[24~"
|
||||||
|
|
||||||
|
key Home : "\E[H"
|
||||||
|
key End : "\E[F"
|
||||||
|
|
||||||
|
key Prior -Shift : "\E[5~"
|
||||||
|
key Next -Shift : "\E[6~"
|
||||||
|
key Insert-Shift : "\E[2~"
|
||||||
|
|
||||||
|
# Keypad-Enter. See comment on Return above.
|
||||||
|
|
||||||
|
key Enter+NewLine : "\r\n"
|
||||||
|
key Enter-NewLine : "\r"
|
||||||
|
|
||||||
|
key Space +Control : "\x00"
|
||||||
|
|
||||||
|
# some of keys are used by konsole.
|
||||||
|
|
||||||
|
key Up +Shift : scrollLineUp
|
||||||
|
key Prior +Shift : scrollPageUp
|
||||||
|
key Down +Shift : scrollLineDown
|
||||||
|
key Next +Shift : scrollPageDown
|
||||||
|
|
||||||
|
key ScrollLock : scrollLock
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------
|
||||||
|
|
||||||
|
# keypad characters as offered by Qt
|
||||||
|
# cannot be recognized as such.
|
||||||
|
|
||||||
|
#----------------------------------------------------------
|
||||||
|
|
||||||
|
# Following other strings as emitted by konsole.
|
71
konsole-qml-plugin/assets/kb-layouts/historic/x11r5.keytab
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# [x11r5.Keytab] Keyboard Table for X11 R5
|
||||||
|
|
||||||
|
keyboard "XTerm (XFree 3.x.x)"
|
||||||
|
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Note that this particular table is a "risc" version made to
|
||||||
|
# ease customization without bothering with obsolete details.
|
||||||
|
# See VT100.keytab for the more hairy stuff.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
# common keys
|
||||||
|
|
||||||
|
key Escape : "\E"
|
||||||
|
key Tab : "\t"
|
||||||
|
|
||||||
|
key Return : "\r"
|
||||||
|
|
||||||
|
# Backspace and Delete codes are preserving CTRL-H.
|
||||||
|
|
||||||
|
key Backspace : "\x7f"
|
||||||
|
|
||||||
|
# cursor keys
|
||||||
|
|
||||||
|
key Up -Shift : "\EOA"
|
||||||
|
key Down -Shift : "\EOB"
|
||||||
|
key Right -Shift : "\EOC"
|
||||||
|
key Left -Shift : "\EOD"
|
||||||
|
|
||||||
|
# other grey PC keys
|
||||||
|
|
||||||
|
key Enter : "\r"
|
||||||
|
|
||||||
|
key Home : "\E[1~"
|
||||||
|
key Insert-Shift : "\E[2~"
|
||||||
|
key Delete : "\E[3~"
|
||||||
|
key End : "\E[4~"
|
||||||
|
key Prior -Shift : "\E[5~"
|
||||||
|
key Next -Shift : "\E[6~"
|
||||||
|
|
||||||
|
# function keys
|
||||||
|
|
||||||
|
key F1 : "\E[11~"
|
||||||
|
key F2 : "\E[12~"
|
||||||
|
key F3 : "\E[13~"
|
||||||
|
key F4 : "\E[14~"
|
||||||
|
key F5 : "\E[15~"
|
||||||
|
key F6 : "\E[17~"
|
||||||
|
key F7 : "\E[18~"
|
||||||
|
key F8 : "\E[19~"
|
||||||
|
key F9 : "\E[20~"
|
||||||
|
key F10 : "\E[21~"
|
||||||
|
key F11 : "\E[23~"
|
||||||
|
key F12 : "\E[24~"
|
||||||
|
|
||||||
|
# Work around dead keys
|
||||||
|
|
||||||
|
key Space +Control : "\x00"
|
||||||
|
|
||||||
|
# Some keys are used by konsole to cause operations.
|
||||||
|
# The scroll* operations refer to the history buffer.
|
||||||
|
|
||||||
|
key Up +Shift : scrollLineUp
|
||||||
|
key Prior +Shift : scrollPageUp
|
||||||
|
key Down +Shift : scrollLineDown
|
||||||
|
key Next +Shift : scrollPageDown
|
||||||
|
|
||||||
|
key ScrollLock : scrollLock
|
||||||
|
|
||||||
|
# keypad characters are not offered differently by Qt.
|
164
konsole-qml-plugin/assets/kb-layouts/linux.keytab
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
# [linux.keytab] Konsole Keyboard Table (Linux console keys)
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
# NOT TESTED, MAY NEED SOME CLEANUPS
|
||||||
|
keyboard "Linux console"
|
||||||
|
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# This configuration table allows to customize the
|
||||||
|
# meaning of the keys.
|
||||||
|
#
|
||||||
|
# The syntax is that each entry has the form :
|
||||||
|
#
|
||||||
|
# "key" Keyname { ("+"|"-") Modename } ":" (String|Operation)
|
||||||
|
#
|
||||||
|
# Keynames are those defined in <qnamespace.h> with the
|
||||||
|
# "Qt::Key_" removed. (We'd better insert the list here)
|
||||||
|
#
|
||||||
|
# Mode names are :
|
||||||
|
#
|
||||||
|
# - Shift
|
||||||
|
# - Alt
|
||||||
|
# - Control
|
||||||
|
#
|
||||||
|
# The VT100 emulation has two modes that can affect the
|
||||||
|
# sequences emitted by certain keys. These modes are
|
||||||
|
# under control of the client program.
|
||||||
|
#
|
||||||
|
# - Newline : effects Return and Enter key.
|
||||||
|
# - Application : effects Up and Down key.
|
||||||
|
#
|
||||||
|
# - Ansi : effects Up and Down key (This is for VT52, really).
|
||||||
|
#
|
||||||
|
# Operations are
|
||||||
|
#
|
||||||
|
# - scrollUpLine
|
||||||
|
# - scrollUpPage
|
||||||
|
# - scrollDownLine
|
||||||
|
# - scrollDownPage
|
||||||
|
#
|
||||||
|
# - emitSelection
|
||||||
|
#
|
||||||
|
# If the key is not found here, the text of the
|
||||||
|
# key event as provided by QT is emitted, possibly
|
||||||
|
# preceeded by ESC if the Alt key is pressed.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
key Escape : "\E"
|
||||||
|
key Tab : "\t"
|
||||||
|
|
||||||
|
# VT100 can add an extra \n after return.
|
||||||
|
# The NewLine mode is set by an escape sequence.
|
||||||
|
|
||||||
|
key Return-NewLine : "\r"
|
||||||
|
key Return+NewLine : "\r\n"
|
||||||
|
|
||||||
|
# Some desperately try to save the ^H.
|
||||||
|
|
||||||
|
key Backspace : "\x7f"
|
||||||
|
key Delete : "\E[3~"
|
||||||
|
|
||||||
|
# These codes are for the VT52 mode of VT100
|
||||||
|
# The Ansi mode (i.e. VT100 mode) is set by
|
||||||
|
# an escape sequence
|
||||||
|
|
||||||
|
key Up -Shift-Ansi : "\EA"
|
||||||
|
key Down -Shift-Ansi : "\EB"
|
||||||
|
key Right-Shift-Ansi : "\EC"
|
||||||
|
key Left -Shift-Ansi : "\ED"
|
||||||
|
|
||||||
|
# VT100 emits a mode bit together
|
||||||
|
# with the arrow keys.The AppCuKeys
|
||||||
|
# mode is set by an escape sequence.
|
||||||
|
|
||||||
|
key Up -Shift+Ansi+AppCuKeys : "\EOA"
|
||||||
|
key Down -Shift+Ansi+AppCuKeys : "\EOB"
|
||||||
|
key Right-Shift+Ansi+AppCuKeys : "\EOC"
|
||||||
|
key Left -Shift+Ansi+AppCuKeys : "\EOD"
|
||||||
|
|
||||||
|
key Up -Shift+Ansi-AppCuKeys : "\E[A"
|
||||||
|
key Down -Shift+Ansi-AppCuKeys : "\E[B"
|
||||||
|
key Right-Shift+Ansi-AppCuKeys : "\E[C"
|
||||||
|
key Left -Shift+Ansi-AppCuKeys : "\E[D"
|
||||||
|
|
||||||
|
# linux functions keys F1-F5 differ from xterm
|
||||||
|
|
||||||
|
key F1 : "\E[[A"
|
||||||
|
key F2 : "\E[[B"
|
||||||
|
key F3 : "\E[[C"
|
||||||
|
key F4 : "\E[[D"
|
||||||
|
key F5 : "\E[[E"
|
||||||
|
|
||||||
|
key F6 : "\E[17~"
|
||||||
|
key F7 : "\E[18~"
|
||||||
|
key F8 : "\E[19~"
|
||||||
|
key F9 : "\E[20~"
|
||||||
|
key F10 : "\E[21~"
|
||||||
|
key F11 : "\E[23~"
|
||||||
|
key F12 : "\E[24~"
|
||||||
|
|
||||||
|
key Home : "\E[1~"
|
||||||
|
key End : "\E[4~"
|
||||||
|
|
||||||
|
key Prior -Shift : "\E[5~"
|
||||||
|
key Next -Shift : "\E[6~"
|
||||||
|
key Insert-Shift : "\E[2~"
|
||||||
|
|
||||||
|
# Keypad-Enter. See comment on Return above.
|
||||||
|
|
||||||
|
key Enter+NewLine : "\r\n"
|
||||||
|
key Enter-NewLine : "\r"
|
||||||
|
|
||||||
|
key Space +Control : "\x00"
|
||||||
|
|
||||||
|
# linux term ctrl seq
|
||||||
|
|
||||||
|
key A +Control : "\x01"
|
||||||
|
key B +Control : "\x02"
|
||||||
|
key C +Control : "\x03"
|
||||||
|
key D +Control : "\x04"
|
||||||
|
key E +Control : "\x05"
|
||||||
|
key F +Control : "\x06"
|
||||||
|
key G +Control : "\x07"
|
||||||
|
key H +Control : "\x08"
|
||||||
|
key I +Control : "\x09"
|
||||||
|
key J +Control : "\x0a"
|
||||||
|
key K +Control : "\x0b"
|
||||||
|
key L +Control : "\x0c"
|
||||||
|
key M +Control : "\x0d"
|
||||||
|
key N +Control : "\x0e"
|
||||||
|
key O +Control : "\x0f"
|
||||||
|
key P +Control : "\x10"
|
||||||
|
key Q +Control : "\x11"
|
||||||
|
key R +Control : "\x12"
|
||||||
|
key S +Control : "\x13"
|
||||||
|
key T +Control : "\x14"
|
||||||
|
key U +Control : "\x15"
|
||||||
|
key V +Control : "\x16"
|
||||||
|
key W +Control : "\x17"
|
||||||
|
key X +Control : "\x18"
|
||||||
|
key Y +Control : "\x19"
|
||||||
|
key Z +Control : "\x1a"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# some of keys are used by konsole.
|
||||||
|
|
||||||
|
key Up +Shift : scrollLineUp
|
||||||
|
key Prior +Shift : scrollPageUp
|
||||||
|
key Down +Shift : scrollLineDown
|
||||||
|
key Next +Shift : scrollPageDown
|
||||||
|
|
||||||
|
key ScrollLock : scrollLock
|
||||||
|
|
||||||
|
#----------------------------------------------------------
|
||||||
|
|
||||||
|
# keypad characters as offered by Qt
|
||||||
|
# cannot be recognized as such.
|
||||||
|
|
||||||
|
#----------------------------------------------------------
|
||||||
|
|
||||||
|
# Following other strings as emitted by konsole.
|
175
konsole-qml-plugin/assets/kb-layouts/macbook.keytab
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
# [README.default.Keytab] Buildin Keyboard Table
|
||||||
|
#
|
||||||
|
# To customize your keyboard, copy this file to something
|
||||||
|
# ending with .keytab and change it to meet you needs.
|
||||||
|
# Please read the README.KeyTab and the README.keyboard
|
||||||
|
# in this case.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
keyboard "Default (XFree 4)"
|
||||||
|
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Note that this particular table is a "risc" version made to
|
||||||
|
# ease customization without bothering with obsolete details.
|
||||||
|
# See VT100.keytab for the more hairy stuff.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
# common keys
|
||||||
|
|
||||||
|
key Escape : "\x1b"
|
||||||
|
|
||||||
|
#key Control : "^"
|
||||||
|
|
||||||
|
key Tab -Shift : "\t"
|
||||||
|
key Tab +Shift+Ansi : "\E[Z"
|
||||||
|
key Tab +Shift-Ansi : "\t"
|
||||||
|
key Backtab +Ansi : "\E[Z"
|
||||||
|
key Backtab -Ansi : "\t"
|
||||||
|
|
||||||
|
key Return-Shift-NewLine : "\r"
|
||||||
|
key Return-Shift+NewLine : "\r\n"
|
||||||
|
|
||||||
|
key Return+Shift : "\EOM"
|
||||||
|
|
||||||
|
# Backspace and Delete codes are preserving CTRL-H.
|
||||||
|
|
||||||
|
key Backspace : "\x7f"
|
||||||
|
|
||||||
|
# Arrow keys in VT52 mode
|
||||||
|
# shift up/down are reserved for scrolling.
|
||||||
|
# shift left/right are reserved for switching between tabs (this is hardcoded).
|
||||||
|
|
||||||
|
|
||||||
|
# Command + C
|
||||||
|
# on mac - Control=Command, Meta=Ctrl
|
||||||
|
# do not use Control+C for interrupt signal - it's used for "Copy to clipboard"
|
||||||
|
#key Control +C : "\x03"
|
||||||
|
key Meta +C: "\x03"
|
||||||
|
|
||||||
|
|
||||||
|
# Arrow keys in ANSI mode with Application - and Normal Cursor Mode)
|
||||||
|
|
||||||
|
key Up -Shift+Ansi-AppCuKeys : "\E[A"
|
||||||
|
key Down -Shift+Ansi-AppCuKeys : "\E[B"
|
||||||
|
key Right-Shift+Ansi-AppCuKeys : "\E[C"
|
||||||
|
key Left -Shift+Ansi-AppCuKeys : "\E[D"
|
||||||
|
|
||||||
|
key Up -Ansi : "\E[1;*A"
|
||||||
|
key Down -Ansi : "\E[1;*B"
|
||||||
|
key Right -Ansi : "\E[1;*C"
|
||||||
|
key Left -Ansi : "\E[1;*D"
|
||||||
|
|
||||||
|
#key Up -Shift-Ansi : "\EA"
|
||||||
|
#key Down -Shift-Ansi : "\EB"
|
||||||
|
#key Right-Shift-Ansi : "\EC"
|
||||||
|
#key Left -Shift-Ansi : "\ED"
|
||||||
|
|
||||||
|
#key Up -Shift-AnyMod+Ansi-AppCuKeys : "\E[A"
|
||||||
|
#key Down -Shift-AnyMod+Ansi-AppCuKeys : "\E[B"
|
||||||
|
#key Right -Shift-AnyMod+Ansi-AppCuKeys : "\E[C"
|
||||||
|
#key Left -Shift-AnyMod+Ansi-AppCuKeys : "\E[D"
|
||||||
|
|
||||||
|
#key Up -Shift-AnyMod+Ansi-AppCuKeys : "\EOA"
|
||||||
|
#key Down -Shift-AnyMod+Ansi-AppCuKeys : "\EOB"
|
||||||
|
#key Right -Shift-AnyMod+Ansi-AppCuKeys : "\EOC"
|
||||||
|
#key Left -Shift-AnyMod+Ansi-AppCuKeys : "\EOD"
|
||||||
|
|
||||||
|
#key Up -Shift-AnyMod+Ansi : "\E[1;*A"
|
||||||
|
#key Down -Shift-AnyMod+Ansi : "\E[1;*B"
|
||||||
|
#key Right -Shift-AnyMod+Ansi : "\E[1;*C"
|
||||||
|
#key Left -Shift-AnyMod+Ansi : "\E[1;*D"
|
||||||
|
|
||||||
|
# other grey PC keys
|
||||||
|
|
||||||
|
key Enter+NewLine : "\r\n"
|
||||||
|
key Enter-NewLine : "\r"
|
||||||
|
|
||||||
|
key Home -AnyMod -AppCuKeys : "\E[H"
|
||||||
|
key End -AnyMod -AppCuKeys : "\E[F"
|
||||||
|
key Home -AnyMod +AppCuKeys : "\EOH"
|
||||||
|
key End -AnyMod +AppCuKeys : "\EOF"
|
||||||
|
key Home +AnyMod : "\E[1;*H"
|
||||||
|
key End +AnyMod : "\E[1;*F"
|
||||||
|
|
||||||
|
key Insert -AnyMod : "\E[2~"
|
||||||
|
key Delete -AnyMod : "\E[3~"
|
||||||
|
key Insert +AnyMod : "\E[2;*~"
|
||||||
|
key Delete +AnyMod : "\E[3;*~"
|
||||||
|
|
||||||
|
key Prior -Shift-AnyMod : "\E[5~"
|
||||||
|
key Next -Shift-AnyMod : "\E[6~"
|
||||||
|
key Prior -Shift+AnyMod : "\E[5;*~"
|
||||||
|
key Next -Shift+AnyMod : "\E[6;*~"
|
||||||
|
|
||||||
|
# Function keys
|
||||||
|
#key F1 -AnyMod : "\EOP"
|
||||||
|
#key F2 -AnyMod : "\EOQ"
|
||||||
|
#key F3 -AnyMod : "\EOR"
|
||||||
|
#key F4 -AnyMod : "\EOS"
|
||||||
|
#define ALT_KP_0 "\033Op"
|
||||||
|
#define ALT_KP_1 "\033Oq"
|
||||||
|
#define ALT_KP_2 "\033Or"
|
||||||
|
#define ALT_KP_3 "\033Os"
|
||||||
|
#define ALT_KP_4 "\033Ot"
|
||||||
|
#define ALT_KP_5 "\033Ou"
|
||||||
|
#define ALT_KP_6 "\033Ov"
|
||||||
|
#define ALT_KP_7 "\033Ow"
|
||||||
|
#define ALT_KP_8 "\033Ox"
|
||||||
|
#define ALT_KP_9 "\033Oy"
|
||||||
|
|
||||||
|
key F1 -AnyMod : "\EOP"
|
||||||
|
key F2 -AnyMod : "\EOQ"
|
||||||
|
key F3 -AnyMod : "\EOR"
|
||||||
|
key F4 -AnyMod : "\EOS"
|
||||||
|
key F5 -AnyMod : "\EOT"
|
||||||
|
key F6 -AnyMod : "\EOU"
|
||||||
|
key F7 -AnyMod : "\EOV"
|
||||||
|
key F8 -AnyMod : "\EOW"
|
||||||
|
key F9 -AnyMod : "\EOX"
|
||||||
|
key F10 -AnyMod : "\EOY"
|
||||||
|
|
||||||
|
#key F5 -AnyMod : "\E[15~"
|
||||||
|
#key F6 -AnyMod : "\E[17~"
|
||||||
|
#key F7 -AnyMod : "\E[18~"
|
||||||
|
#key F8 -AnyMod : "\E[19~"
|
||||||
|
#key F9 -AnyMod : "\E[20~"
|
||||||
|
#key F10 -AnyMod : "\E[21~"
|
||||||
|
#key F11 -AnyMod : "\E[23~"
|
||||||
|
#key F12 -AnyMod : "\E[24~"
|
||||||
|
|
||||||
|
#key F1 +AnyMod : "\EO*P"
|
||||||
|
#key F2 +AnyMod : "\EO*Q"
|
||||||
|
#key F3 +AnyMod : "\EO*R"
|
||||||
|
#key F4 +AnyMod : "\EO*S"
|
||||||
|
#key F5 +AnyMod : "\E[15;*~"
|
||||||
|
#key F6 +AnyMod : "\E[17;*~"
|
||||||
|
#key F7 +AnyMod : "\E[18;*~"
|
||||||
|
#key F8 +AnyMod : "\E[19;*~"
|
||||||
|
#key F9 +AnyMod : "\E[20;*~"
|
||||||
|
#key F10 +AnyMod : "\E[21;*~"
|
||||||
|
#key F11 +AnyMod : "\E[23;*~"
|
||||||
|
#key F12 +AnyMod : "\E[24;*~"
|
||||||
|
|
||||||
|
# Work around dead keys
|
||||||
|
|
||||||
|
key Space +Control : "\x00"
|
||||||
|
|
||||||
|
# Some keys are used by konsole to cause operations.
|
||||||
|
# The scroll* operations refer to the history buffer.
|
||||||
|
|
||||||
|
key Up +Shift-AppScreen : scrollLineUp
|
||||||
|
key Prior +Shift-AppScreen : scrollPageUp
|
||||||
|
key Down +Shift-AppScreen : scrollLineDown
|
||||||
|
key Next +Shift-AppScreen : scrollPageDown
|
||||||
|
|
||||||
|
#key Up +Shift : scrollLineUp
|
||||||
|
#key Prior +Shift : scrollPageUp
|
||||||
|
#key Down +Shift : scrollLineDown
|
||||||
|
#key Next +Shift : scrollPageDown
|
||||||
|
|
||||||
|
key ScrollLock : scrollLock
|
||||||
|
|
||||||
|
# keypad characters are not offered differently by Qt.
|
108
konsole-qml-plugin/assets/kb-layouts/solaris.keytab
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
# [solaris.keytab] Konsole Keyboard Table
|
||||||
|
#
|
||||||
|
|
||||||
|
keyboard "Solaris console"
|
||||||
|
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# This configuration table allows to customize the
|
||||||
|
# meaning of the keys.
|
||||||
|
#
|
||||||
|
# The syntax is that each entry has the form :
|
||||||
|
#
|
||||||
|
# "key" Keyname { ("+"|"-") Modename } ":" (String|Operation)
|
||||||
|
#
|
||||||
|
# Keynames are those defined in <qnamespace.h> with the
|
||||||
|
# "Qt::Key_" removed. (We'd better insert the list here)
|
||||||
|
#
|
||||||
|
# Mode names are :
|
||||||
|
#
|
||||||
|
# - Shift
|
||||||
|
# - Alt
|
||||||
|
# - Control
|
||||||
|
#
|
||||||
|
# The VT100 emulation has two modes that can affect the
|
||||||
|
# sequences emitted by certain keys. These modes are
|
||||||
|
# under control of the client program.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# - Newline : effects Return and Enter key.
|
||||||
|
# - Application : effects Up and Down key.
|
||||||
|
#
|
||||||
|
# - Ansi : effects Up and Down key (This is for VT52, really).
|
||||||
|
#
|
||||||
|
# Operations are
|
||||||
|
#
|
||||||
|
# - scrollUpLine
|
||||||
|
# - scrollUpPage
|
||||||
|
# - scrollDownLine
|
||||||
|
# - scrollDownPage
|
||||||
|
#
|
||||||
|
# - emitSelection
|
||||||
|
#
|
||||||
|
# If the key is not found here, the text of the
|
||||||
|
# key event as provided by QT is emitted, possibly
|
||||||
|
# preceeded by ESC if the Alt key is pressed.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
key Escape : "\E"
|
||||||
|
key Tab : "\t"
|
||||||
|
|
||||||
|
key Return-Alt : "\r"
|
||||||
|
key Return+Alt : "\E\r"
|
||||||
|
|
||||||
|
# Backspace and Delete codes are preserving CTRL-H.
|
||||||
|
|
||||||
|
key Backspace : "\x08"
|
||||||
|
#key Delete : "\x7F"
|
||||||
|
|
||||||
|
# cursor keys
|
||||||
|
|
||||||
|
key Up -Shift : "\EOA"
|
||||||
|
key Down -Shift : "\EOB"
|
||||||
|
key Right -Shift : "\EOC"
|
||||||
|
key Left -Shift : "\EOD"
|
||||||
|
|
||||||
|
# other grey PC keys
|
||||||
|
|
||||||
|
key Enter : "\r"
|
||||||
|
|
||||||
|
key Home : "\E[1~"
|
||||||
|
key Insert-Shift : "\E[2~"
|
||||||
|
key Delete : "\E[3~"
|
||||||
|
key End : "\E[4~"
|
||||||
|
key Prior -Shift : "\E[5~"
|
||||||
|
key Next -Shift : "\E[6~"
|
||||||
|
|
||||||
|
# function keys
|
||||||
|
|
||||||
|
key F1 : "\E[11~"
|
||||||
|
key F2 : "\E[12~"
|
||||||
|
key F3 : "\E[13~"
|
||||||
|
key F4 : "\E[14~"
|
||||||
|
key F5 : "\E[15~"
|
||||||
|
key F6 : "\E[17~"
|
||||||
|
key F7 : "\E[18~"
|
||||||
|
key F8 : "\E[19~"
|
||||||
|
key F9 : "\E[20~"
|
||||||
|
key F10 : "\E[21~"
|
||||||
|
key F11 : "\E[23~"
|
||||||
|
key F12 : "\E[24~"
|
||||||
|
|
||||||
|
# Work around dead keys
|
||||||
|
|
||||||
|
key Space +Control : "\x00"
|
||||||
|
|
||||||
|
# Some keys are used by konsole to cause operations.
|
||||||
|
# The scroll* operations refer to the history buffer.
|
||||||
|
|
||||||
|
#key Left +Shift : prevSession
|
||||||
|
#key Right +Shift : nextSession
|
||||||
|
key Up +Shift : scrollLineUp
|
||||||
|
key Prior +Shift : scrollPageUp
|
||||||
|
key Down +Shift : scrollLineDown
|
||||||
|
key Next +Shift : scrollPageDown
|
||||||
|
#key Insert+Shift : emitSelection
|
||||||
|
|
||||||
|
# keypad characters are not offered differently by Qt.
|
168
konsole-qml-plugin/assets/kb-layouts/vt420pc.keytab
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
#
|
||||||
|
# NOTE: This keyboard binding is not installed because it
|
||||||
|
# apparently doesn't work with actual VT420 systems
|
||||||
|
# (see BUG:170220)
|
||||||
|
#
|
||||||
|
# [vt420pc.keytab] Konsole Keyboard Table (VT420pc keys)
|
||||||
|
# adapted by ferdinand gassauer f.gassauer@aon.at
|
||||||
|
# Nov 2000
|
||||||
|
#
|
||||||
|
################################################################
|
||||||
|
#
|
||||||
|
# The escape sequences emmited by the
|
||||||
|
# keys Shift+F1 to Shift+F12 might not fit your needs
|
||||||
|
#
|
||||||
|
################# IMPORTANT NOTICE #############################
|
||||||
|
# the key bindings (Kcontrol -> look and feel -> keybindgs)
|
||||||
|
# overrule the settings in this file. The key bindings might be
|
||||||
|
# changed by the user WITHOUT notification of the maintainer of
|
||||||
|
# the keytab file. Konsole will not work as expected by
|
||||||
|
# the maintainer of the keytab file.
|
||||||
|
################################################################
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
keyboard "DEC VT420 Terminal"
|
||||||
|
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# This configuration table allows to customize the
|
||||||
|
# meaning of the keys.
|
||||||
|
#
|
||||||
|
# The syntax is that each entry has the form :
|
||||||
|
#
|
||||||
|
# "key" Keyname { ("+"|"-") Modename } ":" (String|Operation)
|
||||||
|
#
|
||||||
|
# Keynames are those defined in <qnamespace.h> with the
|
||||||
|
# "Qt::Key_" removed. (We'd better insert the list here)
|
||||||
|
#
|
||||||
|
# Mode names are :
|
||||||
|
#
|
||||||
|
# - Shift
|
||||||
|
# - Alt
|
||||||
|
# - Control
|
||||||
|
#
|
||||||
|
# The VT100 emulation has two modes that can affect the
|
||||||
|
# sequences emitted by certain keys. These modes are
|
||||||
|
# under control of the client program.
|
||||||
|
#
|
||||||
|
# - Newline : effects Return and Enter key.
|
||||||
|
# - Application : effects Up and Down key.
|
||||||
|
#
|
||||||
|
# - Ansi : effects Up and Down key (This is for VT52, really).
|
||||||
|
#
|
||||||
|
# Operations are
|
||||||
|
#
|
||||||
|
# - scrollUpLine
|
||||||
|
# - scrollUpPage
|
||||||
|
# - scrollDownLine
|
||||||
|
# - scrollDownPage
|
||||||
|
#
|
||||||
|
# - emitSelection
|
||||||
|
#
|
||||||
|
# If the key is not found here, the text of the
|
||||||
|
# key event as provided by QT is emitted, possibly
|
||||||
|
# preceeded by ESC if the Alt key is pressed.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
key Escape : "\E"
|
||||||
|
key Tab : "\t"
|
||||||
|
key Backtab: "\E[Z"
|
||||||
|
|
||||||
|
# VT100 can add an extra \n after return.
|
||||||
|
# The NewLine mode is set by an escape sequence.
|
||||||
|
|
||||||
|
key Return-NewLine : "\r"
|
||||||
|
key Return+NewLine : "\r\n"
|
||||||
|
|
||||||
|
# Some desperately try to save the ^H.
|
||||||
|
# may be not everyone wants this
|
||||||
|
|
||||||
|
key Backspace : "\x08" # Control H
|
||||||
|
key Delete : "\x7f"
|
||||||
|
|
||||||
|
# These codes are for the VT420pc
|
||||||
|
# The Ansi mode (i.e. VT100 mode) is set by
|
||||||
|
# an escape sequence
|
||||||
|
|
||||||
|
key Up -Shift-Ansi : "\EA"
|
||||||
|
key Down -Shift-Ansi : "\EB"
|
||||||
|
key Right-Shift-Ansi : "\EC"
|
||||||
|
key Left -Shift-Ansi : "\ED"
|
||||||
|
|
||||||
|
# VT100 emits a mode bit together
|
||||||
|
# with the arrow keys.The AppCuKeys
|
||||||
|
# mode is set by an escape sequence.
|
||||||
|
|
||||||
|
key Up -Shift+Ansi+AppCuKeys : "\EOA"
|
||||||
|
key Down -Shift+Ansi+AppCuKeys : "\EOB"
|
||||||
|
key Right-Shift+Ansi+AppCuKeys : "\EOC"
|
||||||
|
key Left -Shift+Ansi+AppCuKeys : "\EOD"
|
||||||
|
|
||||||
|
key Up -Shift+Ansi-AppCuKeys : "\E[A"
|
||||||
|
key Down -Shift+Ansi-AppCuKeys : "\E[B"
|
||||||
|
key Right-Shift+Ansi-AppCuKeys : "\E[C"
|
||||||
|
key Left -Shift+Ansi-AppCuKeys : "\E[D"
|
||||||
|
|
||||||
|
# function keys
|
||||||
|
|
||||||
|
key F1 -Shift : "\E[11~"
|
||||||
|
key F2 -Shift : "\E[12~"
|
||||||
|
key F3 -Shift : "\E[13~"
|
||||||
|
key F4 -Shift : "\E[14~"
|
||||||
|
key F5 -Shift : "\E[15~"
|
||||||
|
key F6 -Shift : "\E[17~"
|
||||||
|
key F7 -Shift : "\E[18~"
|
||||||
|
key F8 -Shift : "\E[19~"
|
||||||
|
key F9 -Shift : "\E[20~"
|
||||||
|
key F10-Shift : "\E[21~"
|
||||||
|
key F11-Shift : "\E[23~"
|
||||||
|
key F12-Shift : "\E[24~"
|
||||||
|
#
|
||||||
|
# Shift F1-F12
|
||||||
|
#
|
||||||
|
key F1 +Shift : "\E[11;2~"
|
||||||
|
key F2 +Shift : "\E[12;2~"
|
||||||
|
key F3 +Shift : "\E[13;2~"
|
||||||
|
key F4 +Shift : "\E[14;2~"
|
||||||
|
key F5 +Shift : "\E[15;2~"
|
||||||
|
key F6 +Shift : "\E[17;2~"
|
||||||
|
key F7 +Shift : "\E[18;2~"
|
||||||
|
key F8 +Shift : "\E[19;2~"
|
||||||
|
key F9 +Shift : "\E[20;2~"
|
||||||
|
key F10+Shift : "\E[21;2~"
|
||||||
|
key F11+Shift : "\E[23;2~"
|
||||||
|
key F12+Shift : "\E[24;2~"
|
||||||
|
|
||||||
|
key Home : "\E[H"
|
||||||
|
key End : "\E[F"
|
||||||
|
|
||||||
|
key Prior -Shift : "\E[5~"
|
||||||
|
key Next -Shift : "\E[6~"
|
||||||
|
key Insert-Shift : "\E[2~"
|
||||||
|
|
||||||
|
# Keypad-Enter. See comment on Return above.
|
||||||
|
|
||||||
|
key Enter+NewLine : "\r\n"
|
||||||
|
key Enter-NewLine : "\r"
|
||||||
|
|
||||||
|
key Space +Control : "\x00"
|
||||||
|
|
||||||
|
# some of keys are used by konsole.
|
||||||
|
|
||||||
|
key Up +Shift : scrollLineUp
|
||||||
|
key Prior +Shift : scrollPageUp
|
||||||
|
key Down +Shift : scrollLineDown
|
||||||
|
key Next +Shift : scrollPageDown
|
||||||
|
|
||||||
|
key ScrollLock : scrollLock
|
||||||
|
|
||||||
|
#----------------------------------------------------------
|
||||||
|
|
||||||
|
# keypad characters as offered by Qt
|
||||||
|
# cannot be recognized as such.
|
||||||
|
|
||||||
|
#----------------------------------------------------------
|
||||||
|
|
||||||
|
# Following other strings as emitted by konsole.
|
29
konsole-qml-plugin/debian/changelog
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
konsole-qml-plugin (0.1.2) raring; urgency=low
|
||||||
|
|
||||||
|
* Fixed text display bug (LP:#1182503)
|
||||||
|
|
||||||
|
-- Dmitry Zagnoyko <hiroshidi@gmail.com> Mon, 10 Jun 2013 09:49:02 +0300
|
||||||
|
|
||||||
|
konsole-qml-plugin (0.1.1) raring; urgency=low
|
||||||
|
|
||||||
|
* Fixed issue with float values of widget size
|
||||||
|
* Added virtual key event for qml KSession component
|
||||||
|
|
||||||
|
-- Dmitry Zagnoyko <hiroshidi@gmail.com> Mon, 06 May 2013 20:11:10 +0300
|
||||||
|
|
||||||
|
konsole-qml-plugin (0.1.0ubuntu1~quantal1~test2) quantal; urgency=low
|
||||||
|
|
||||||
|
* Added qml properties for KTerminal
|
||||||
|
* Fixed visibility sope: removed konsole namespace
|
||||||
|
* Added qmltypes
|
||||||
|
* Fixed qml plugin path
|
||||||
|
* Added KSession class
|
||||||
|
|
||||||
|
-- Dmitry Zagnoyko <hiroshidi@gmail.com> Sat, 20 Apr 2013 21:44:26 +0300
|
||||||
|
|
||||||
|
konsole-qml-plugin (0.1.0ubuntu1~quantal1~test1) quantal; urgency=low
|
||||||
|
|
||||||
|
* Initial release
|
||||||
|
* Ported KDE Konsole
|
||||||
|
|
||||||
|
-- Dmitry Zagnoyko <hiroshidi@gmail.com> Fri, 19 Apr 2013 20:22:12 +0300
|
1
konsole-qml-plugin/debian/compat
Normal file
@ -0,0 +1 @@
|
|||||||
|
9
|
40
konsole-qml-plugin/debian/control
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
Source: konsole-qml-plugin
|
||||||
|
Section: libs
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
|
||||||
|
Build-Depends: debhelper (>= 9.0.0),
|
||||||
|
# libgl1-mesa-dev | libgl-dev,
|
||||||
|
# libgles2-mesa-dev
|
||||||
|
qtbase5-dev,
|
||||||
|
qtdeclarative5-dev,
|
||||||
|
qt5-default,
|
||||||
|
Standards-Version: 3.9.4
|
||||||
|
Homepage: http://konsole.kde.org/
|
||||||
|
|
||||||
|
Package: qtdeclarative5-konsole-qml-plugin
|
||||||
|
Architecture: any
|
||||||
|
Multi-Arch: same
|
||||||
|
Pre-Depends: ${misc:Pre-Depends}
|
||||||
|
Depends: ${misc:Depends}, ${shlibs:Depends},
|
||||||
|
Description: KDE Konsole QML plugin - qml terminal plugin
|
||||||
|
Originaly, Konsole is a terminal emulator from KDE. This is ported
|
||||||
|
version and do not require KDE.
|
||||||
|
.
|
||||||
|
This package contains the Konsole terminal emulator plugin
|
||||||
|
for Qt Qml, which offers access to terminal by KTerminal and
|
||||||
|
KSession elements. KTerminal is used for displaying information
|
||||||
|
given by KSession.
|
||||||
|
|
||||||
|
|
||||||
|
#Package: konsole-qml-plugin-dbg
|
||||||
|
#Priority: extra
|
||||||
|
#Architecture: any
|
||||||
|
#Section: debug
|
||||||
|
#Depends: ${misc:Depends}
|
||||||
|
#Description: KDE Konsole QML plugin debugging symbols
|
||||||
|
# Originaly, Konsole is a terminal emulator from KDE. This is ported
|
||||||
|
# version without KDE tails and do not require KDE.
|
||||||
|
# .
|
||||||
|
# This package contains the debugging symbols for the KDE Konsole
|
||||||
|
# QML plugin.
|
||||||
|
|
50
konsole-qml-plugin/debian/copyright
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/3.0/
|
||||||
|
Upstream-Name: konsole-qml-plugin
|
||||||
|
Source:
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: 2013 Dmitry Zagnoyko <hiroshidi@gmail.com>
|
||||||
|
2008 e_k <e_k@users.sourceforge.net>
|
||||||
|
2006-2008 Robert Knight <robertknight@gmail.com>
|
||||||
|
2003-2007 Oswald Buddenhagen <ossi@kde.org>
|
||||||
|
2000 Stephan Kulow <coolo@kde.org>
|
||||||
|
1997-1998 Lars Doelle <lars.doelle@on-line.de>
|
||||||
|
License: GPL-3
|
||||||
|
|
||||||
|
Files: debian/*
|
||||||
|
Copyright: 2013 Dmitry Zagnoyko <hiroshidi@gmail.com>
|
||||||
|
License: LGPL-3
|
||||||
|
|
||||||
|
License: GPL-3
|
||||||
|
This package is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 3 of the License.
|
||||||
|
.
|
||||||
|
This package is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
.
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
.
|
||||||
|
On Debian systems, the complete text of the GNU General
|
||||||
|
Public License can be found in "/usr/share/common-licenses/GPL-3".
|
||||||
|
|
||||||
|
License: LGPL-3
|
||||||
|
This package is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 3 of the License.
|
||||||
|
.
|
||||||
|
This package 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
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
.
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
.
|
||||||
|
On Debian systems, the complete text of the GNU Lesser General
|
||||||
|
Public License can be found in "/usr/share/common-licenses/LGPL-3".
|
21
konsole-qml-plugin/debian/rules
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
|
# Uncomment this to turn on verbose mode.
|
||||||
|
#export DH_VERBOSE=1
|
||||||
|
|
||||||
|
#export CFLAGS := $(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
|
||||||
|
#export CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
|
||||||
|
#export LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) -Wl,--as-needed
|
||||||
|
|
||||||
|
override_dh_auto_configure:
|
||||||
|
QT_SELECT=qt5 dh_auto_configure
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@ --list-missing --parallel
|
||||||
|
# WARN: currently, no pakgage
|
||||||
|
# --dbg-package=konsole-qml-plugin-dbg
|
||||||
|
|
||||||
|
|
||||||
|
#override_dh_builddeb:
|
||||||
|
# dh_builddeb -- -Zxz
|
||||||
|
|
1
konsole-qml-plugin/debian/source/format
Normal file
@ -0,0 +1 @@
|
|||||||
|
3.0 (native)
|
99
konsole-qml-plugin/konsole-qml-plugin.pro
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#########################################
|
||||||
|
## CONFIGS
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
TEMPLATE = lib
|
||||||
|
CONFIG += qt plugin hide_symbols
|
||||||
|
QT += qml quick widgets
|
||||||
|
|
||||||
|
DEFINES += HAVE_POSIX_OPENPT HAVE_SYS_TIME_H HAVE_UPDWTMPX
|
||||||
|
|
||||||
|
#MANUALY DEFINED PLATFORM
|
||||||
|
DEFINES += Q_WS_UBUNTU
|
||||||
|
|
||||||
|
TARGET = kdekonsole
|
||||||
|
PLUGIN_IMPORT_PATH = org/kde/konsole
|
||||||
|
PLUGIN_ASSETS = $$PWD/assets/*
|
||||||
|
|
||||||
|
INSTALL_DIR = ../imports
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
## SOURCES
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/src/plugin.cpp \
|
||||||
|
$$PWD/src/Pty.cpp \
|
||||||
|
$$PWD/src/kptyprocess.cpp \
|
||||||
|
$$PWD/src/kptydevice.cpp \
|
||||||
|
$$PWD/src/kpty.cpp \
|
||||||
|
$$PWD/src/kprocess.cpp \
|
||||||
|
$$PWD/src/ShellCommand.cpp \
|
||||||
|
$$PWD/src/Vt102Emulation.cpp \
|
||||||
|
$$PWD/src/tools.cpp \
|
||||||
|
$$PWD/src/Session.cpp \
|
||||||
|
$$PWD/src/Screen.cpp \
|
||||||
|
$$PWD/src/KeyboardTranslator.cpp \
|
||||||
|
$$PWD/src/Emulation.cpp \
|
||||||
|
$$PWD/src/History.cpp \
|
||||||
|
$$PWD/src/BlockArray.cpp \
|
||||||
|
$$PWD/src/TerminalCharacterDecoder.cpp \
|
||||||
|
$$PWD/src/konsole_wcwidth.cpp \
|
||||||
|
$$PWD/src/ScreenWindow.cpp \
|
||||||
|
$$PWD/src/Filter.cpp \
|
||||||
|
$$PWD/src/ColorScheme.cpp \
|
||||||
|
$$PWD/src/TerminalDisplay.cpp \
|
||||||
|
$$PWD/src/ksession.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/src/plugin.h \
|
||||||
|
$$PWD/src/Pty.h \
|
||||||
|
$$PWD/src/kptyprocess.h \
|
||||||
|
$$PWD/src/kptydevice.h \
|
||||||
|
$$PWD/src/kpty.h \
|
||||||
|
$$PWD/src/kpty_p.h \
|
||||||
|
$$PWD/src/kprocess.h \
|
||||||
|
$$PWD/src/ShellCommand.h \
|
||||||
|
$$PWD/src/Vt102Emulation.h \
|
||||||
|
$$PWD/src/tools.h \
|
||||||
|
$$PWD/src/Session.h \
|
||||||
|
$$PWD/src/Screen.h \
|
||||||
|
$$PWD/src/KeyboardTranslator.h \
|
||||||
|
$$PWD/src/Emulation.h \
|
||||||
|
$$PWD/src/Character.h \
|
||||||
|
$$PWD/src/History.h \
|
||||||
|
$$PWD/src/CharacterColor.h \
|
||||||
|
$$PWD/src/BlockArray.h \
|
||||||
|
$$PWD/src/TerminalCharacterDecoder.h \
|
||||||
|
$$PWD/src/konsole_wcwidth.h \
|
||||||
|
$$PWD/src/ScreenWindow.h \
|
||||||
|
$$PWD/src/DefaultTranslatorText.h \
|
||||||
|
$$PWD/src/LineFont.h \
|
||||||
|
$$PWD/src/Filter.h \
|
||||||
|
$$PWD/src/ExtendedDefaultTranslator.h \
|
||||||
|
$$PWD/src/ColorTables.h \
|
||||||
|
$$PWD/src/ColorScheme.h \
|
||||||
|
$$PWD/src/TerminalDisplay.h \
|
||||||
|
$$PWD/src/ksession.h
|
||||||
|
|
||||||
|
OTHER_FILES += \
|
||||||
|
$$PWD/src/qmldir \
|
||||||
|
$$PWD/src/plugins.qmltypes
|
||||||
|
|
||||||
|
MOC_DIR = $$PWD/.moc
|
||||||
|
OBJECTS_DIR = $$PWD/.obj
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
## INTALLS
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
target.path = $$INSTALL_DIR/$$PLUGIN_IMPORT_PATH
|
||||||
|
|
||||||
|
assets.files += $$PLUGIN_ASSETS
|
||||||
|
assets.path += $$INSTALL_DIR/$$PLUGIN_IMPORT_PATH
|
||||||
|
|
||||||
|
qmldir.files += $$PWD/src/qmldir \
|
||||||
|
$$PWD/src/plugins.qmltypes
|
||||||
|
qmldir.path += $$INSTALL_DIR/$$PLUGIN_IMPORT_PATH
|
||||||
|
|
||||||
|
INSTALLS += target qmldir assets
|
377
konsole-qml-plugin/src/BlockArray.cpp
Normal file
@ -0,0 +1,377 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Konsole, an X terminal.
|
||||||
|
Copyright (C) 2000 by Stephan Kulow <coolo@kde.org>
|
||||||
|
|
||||||
|
Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008
|
||||||
|
|
||||||
|
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 "BlockArray.h"
|
||||||
|
|
||||||
|
#include <QtCore>
|
||||||
|
|
||||||
|
// System
|
||||||
|
#include <assert.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
// lastmap_index = index = current = size_t(-1);
|
||||||
|
if (blocksize == 0) {
|
||||||
|
blocksize = ((sizeof(Block) / getpagesize()) + 1) * getpagesize();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockArray::~BlockArray()
|
||||||
|
{
|
||||||
|
setHistorySize(0);
|
||||||
|
assert(!lastblock);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t BlockArray::append(Block * block)
|
||||||
|
{
|
||||||
|
if (!size) {
|
||||||
|
return size_t(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
++current;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
length++;
|
||||||
|
if (length > size) {
|
||||||
|
length = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
++index;
|
||||||
|
|
||||||
|
delete block;
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t BlockArray::newBlock()
|
||||||
|
{
|
||||||
|
if (!size) {
|
||||||
|
return size_t(-1);
|
||||||
|
}
|
||||||
|
append(lastblock);
|
||||||
|
|
||||||
|
lastblock = new Block();
|
||||||
|
return index + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Block * BlockArray::lastBlock() const
|
||||||
|
{
|
||||||
|
return lastblock;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BlockArray::has(size_t i) const
|
||||||
|
{
|
||||||
|
if (i == index + 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i > index) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (index - i >= length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Block * BlockArray::at(size_t i)
|
||||||
|
{
|
||||||
|
if (i == index + 1) {
|
||||||
|
return lastblock;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == lastmap_index) {
|
||||||
|
return lastmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i > index) {
|
||||||
|
qDebug() << "BlockArray::at() i > index\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (index - i >= length) {
|
||||||
|
// kDebug(1211) << "BlockArray::at() index - i >= length\n";
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
size_t j = i; // (current - (index - i) + (index/size+1)*size) % size ;
|
||||||
|
|
||||||
|
assert(j < size);
|
||||||
|
unmap();
|
||||||
|
|
||||||
|
Block * block = (Block *)mmap(0, blocksize, PROT_READ, MAP_PRIVATE, ion, j * blocksize);
|
||||||
|
|
||||||
|
if (block == (Block *)-1) {
|
||||||
|
perror("mmap");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastmap = block;
|
||||||
|
lastmap_index = i;
|
||||||
|
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlockArray::unmap()
|
||||||
|
{
|
||||||
|
if (lastmap) {
|
||||||
|
int res = munmap((char *)lastmap, blocksize);
|
||||||
|
if (res < 0) {
|
||||||
|
perror("munmap");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastmap = 0;
|
||||||
|
lastmap_index = size_t(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BlockArray::setSize(size_t newsize)
|
||||||
|
{
|
||||||
|
return setHistorySize(newsize * 1024 / blocksize);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BlockArray::setHistorySize(size_t newsize)
|
||||||
|
{
|
||||||
|
// kDebug(1211) << "setHistorySize " << size << " " << newsize;
|
||||||
|
|
||||||
|
if (size == newsize) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unmap();
|
||||||
|
|
||||||
|
if (!newsize) {
|
||||||
|
delete lastblock;
|
||||||
|
lastblock = 0;
|
||||||
|
if (ion >= 0) {
|
||||||
|
close(ion);
|
||||||
|
}
|
||||||
|
ion = -1;
|
||||||
|
current = size_t(-1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!size) {
|
||||||
|
FILE * tmp = tmpfile();
|
||||||
|
if (!tmp) {
|
||||||
|
perror("konsole: cannot open temp file.\n");
|
||||||
|
} else {
|
||||||
|
ion = dup(fileno(tmp));
|
||||||
|
if (ion<0) {
|
||||||
|
perror("konsole: cannot dup temp file.\n");
|
||||||
|
fclose(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ion < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(!lastblock);
|
||||||
|
|
||||||
|
lastblock = new Block();
|
||||||
|
size = newsize;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newsize > size) {
|
||||||
|
increaseBuffer();
|
||||||
|
size = newsize;
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
decreaseBuffer(newsize);
|
||||||
|
ftruncate(ion, length*blocksize);
|
||||||
|
size = newsize;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void moveBlock(FILE * fion, int cursor, int newpos, char * buffer2)
|
||||||
|
{
|
||||||
|
int res = fseek(fion, cursor * blocksize, SEEK_SET);
|
||||||
|
if (res) {
|
||||||
|
perror("fseek");
|
||||||
|
}
|
||||||
|
res = fread(buffer2, blocksize, 1, fion);
|
||||||
|
if (res != 1) {
|
||||||
|
perror("fread");
|
||||||
|
}
|
||||||
|
|
||||||
|
res = fseek(fion, newpos * blocksize, SEEK_SET);
|
||||||
|
if (res) {
|
||||||
|
perror("fseek");
|
||||||
|
}
|
||||||
|
res = fwrite(buffer2, blocksize, 1, fion);
|
||||||
|
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
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int offset = (current - (newsize - 1) + size) % size;
|
||||||
|
|
||||||
|
if (!offset) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The Block constructor could do somthing in future...
|
||||||
|
char * buffer1 = new char[blocksize];
|
||||||
|
|
||||||
|
FILE * fion = fdopen(dup(ion), "w+b");
|
||||||
|
if (!fion) {
|
||||||
|
delete [] buffer1;
|
||||||
|
perror("fdopen/dup");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int firstblock;
|
||||||
|
if (current <= newsize) {
|
||||||
|
firstblock = current + 1;
|
||||||
|
} else {
|
||||||
|
firstblock = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t oldpos;
|
||||||
|
for (size_t i = 0, cursor=firstblock; i < newsize; i++) {
|
||||||
|
oldpos = (size + cursor + offset) % size;
|
||||||
|
moveBlock(fion, oldpos, cursor, buffer1);
|
||||||
|
if (oldpos < newsize) {
|
||||||
|
cursor = oldpos;
|
||||||
|
} else {
|
||||||
|
cursor++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
current = newsize - 1;
|
||||||
|
length = newsize;
|
||||||
|
|
||||||
|
delete [] buffer1;
|
||||||
|
|
||||||
|
fclose(fion);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlockArray::increaseBuffer()
|
||||||
|
{
|
||||||
|
if (index < size) { // not even wrapped once
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int offset = (current + size + 1) % size;
|
||||||
|
if (!offset) { // no moving needed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The Block constructor could do somthing in future...
|
||||||
|
char * buffer1 = new char[blocksize];
|
||||||
|
char * buffer2 = new char[blocksize];
|
||||||
|
|
||||||
|
int runs = 1;
|
||||||
|
int bpr = size; // blocks per run
|
||||||
|
|
||||||
|
if (size % offset == 0) {
|
||||||
|
bpr = size / offset;
|
||||||
|
runs = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE * fion = fdopen(dup(ion), "w+b");
|
||||||
|
if (!fion) {
|
||||||
|
perror("fdopen/dup");
|
||||||
|
delete [] buffer1;
|
||||||
|
delete [] buffer2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int res;
|
||||||
|
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) {
|
||||||
|
perror("fseek");
|
||||||
|
}
|
||||||
|
res = fread(buffer1, blocksize, 1, fion);
|
||||||
|
if (res != 1) {
|
||||||
|
perror("fread");
|
||||||
|
}
|
||||||
|
int newpos = 0;
|
||||||
|
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) {
|
||||||
|
perror("fseek");
|
||||||
|
}
|
||||||
|
res = fwrite(buffer1, blocksize, 1, fion);
|
||||||
|
if (res != 1) {
|
||||||
|
perror("fwrite");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
current = size - 1;
|
||||||
|
length = size;
|
||||||
|
|
||||||
|
delete [] buffer1;
|
||||||
|
delete [] buffer2;
|
||||||
|
|
||||||
|
fclose(fion);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
126
konsole-qml-plugin/src/BlockArray.h
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Konsole, an X terminal.
|
||||||
|
Copyright (C) 2000 by Stephan Kulow <coolo@kde.org>
|
||||||
|
|
||||||
|
Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008
|
||||||
|
|
||||||
|
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 BLOCKARRAY_H
|
||||||
|
#define BLOCKARRAY_H
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
//#error Do not use in KDE 2.1
|
||||||
|
|
||||||
|
#define BlockSize (1 << 12)
|
||||||
|
#define ENTRIES ((BlockSize - sizeof(size_t) ) / sizeof(unsigned char))
|
||||||
|
|
||||||
|
struct Block {
|
||||||
|
Block() {
|
||||||
|
size = 0;
|
||||||
|
}
|
||||||
|
unsigned char data[ENTRIES];
|
||||||
|
size_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class BlockArray {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Creates a history file for holding
|
||||||
|
* maximal size blocks. If more blocks
|
||||||
|
* are requested, then it drops earlier
|
||||||
|
* added ones.
|
||||||
|
*/
|
||||||
|
BlockArray();
|
||||||
|
|
||||||
|
/// destructor
|
||||||
|
~BlockArray();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds the Block at the end of history.
|
||||||
|
* This may drop other blocks.
|
||||||
|
*
|
||||||
|
* The ownership on the block is transfered.
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* operation on this class.
|
||||||
|
*/
|
||||||
|
const Block * at(size_t index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reorders blocks as needed. If newsize is null,
|
||||||
|
* the history is emptied completely. The indices
|
||||||
|
* returned on append won't change their semantic,
|
||||||
|
* but they may not be valid after this call.
|
||||||
|
*/
|
||||||
|
bool setHistorySize(size_t newsize);
|
||||||
|
|
||||||
|
size_t newBlock();
|
||||||
|
|
||||||
|
Block * lastBlock() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenient function to set the size in KBytes
|
||||||
|
* instead of blocks
|
||||||
|
*/
|
||||||
|
bool setSize(size_t newsize);
|
||||||
|
|
||||||
|
size_t len() const {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool has(size_t index) const;
|
||||||
|
|
||||||
|
size_t getCurrent() const {
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void unmap();
|
||||||
|
void increaseBuffer();
|
||||||
|
void decreaseBuffer(size_t newsize);
|
||||||
|
|
||||||
|
size_t size;
|
||||||
|
// current always shows to the last inserted block
|
||||||
|
size_t current;
|
||||||
|
size_t index;
|
||||||
|
|
||||||
|
Block * lastmap;
|
||||||
|
size_t lastmap_index;
|
||||||
|
Block * lastblock;
|
||||||
|
|
||||||
|
int ion;
|
||||||
|
size_t length;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
221
konsole-qml-plugin/src/Character.h
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Konsole, KDE's terminal.
|
||||||
|
|
||||||
|
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
|
||||||
|
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||||
|
|
||||||
|
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 CHARACTER_H
|
||||||
|
#define CHARACTER_H
|
||||||
|
|
||||||
|
// Qt
|
||||||
|
#include <QtCore/QHash>
|
||||||
|
|
||||||
|
// Local
|
||||||
|
#include "CharacterColor.h"
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
#define DEFAULT_RENDITION 0
|
||||||
|
#define RE_BOLD (1 << 0)
|
||||||
|
#define RE_BLINK (1 << 1)
|
||||||
|
#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)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A single character in the terminal which consists of a unicode character
|
||||||
|
* value, foreground and background colors and a set of rendition attributes
|
||||||
|
* which specify how it should be drawn.
|
||||||
|
*/
|
||||||
|
class Character
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructs a new character.
|
||||||
|
*
|
||||||
|
* @param _c The unicode character value of this character.
|
||||||
|
* @param _f The foreground color used to draw the character.
|
||||||
|
* @param _b The color used to draw the character's background.
|
||||||
|
* @param _r A set of rendition flags which specify how this character is to be drawn.
|
||||||
|
*/
|
||||||
|
inline Character(quint16 _c = ' ',
|
||||||
|
CharacterColor _f = CharacterColor(COLOR_SPACE_DEFAULT,DEFAULT_FORE_COLOR),
|
||||||
|
CharacterColor _b = CharacterColor(COLOR_SPACE_DEFAULT,DEFAULT_BACK_COLOR),
|
||||||
|
quint8 _r = DEFAULT_RENDITION)
|
||||||
|
: character(_c), rendition(_r), foregroundColor(_f), backgroundColor(_b) {}
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
/** The unicode character value for this character. */
|
||||||
|
quint16 character;
|
||||||
|
/**
|
||||||
|
* Experimental addition which allows a single Character instance to contain more than
|
||||||
|
* one unicode character.
|
||||||
|
*
|
||||||
|
* charSequence is a hash code which can be used to look up the unicode
|
||||||
|
* character sequence in the ExtendedCharTable used to create the sequence.
|
||||||
|
*/
|
||||||
|
quint16 charSequence;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** A combination of RENDITION flags which specify options for drawing the character. */
|
||||||
|
quint8 rendition;
|
||||||
|
|
||||||
|
/** The foreground color used to draw this character. */
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
bool isTransparent(const ColorEntry* palette) const;
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
friend bool operator == (const Character& a, const Character& b);
|
||||||
|
/**
|
||||||
|
* Compares two characters and returns true if they have different unicode character values,
|
||||||
|
* renditions or colors.
|
||||||
|
*/
|
||||||
|
friend bool operator != (const Character& a, const Character& b);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool operator == (const Character& a, const Character& b)
|
||||||
|
{
|
||||||
|
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 ||
|
||||||
|
a.backgroundColor != b.backgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Character::isTransparent(const ColorEntry* base) const
|
||||||
|
{
|
||||||
|
return ((backgroundColor._colorSpace == COLOR_SPACE_DEFAULT) &&
|
||||||
|
base[backgroundColor._u+0+(backgroundColor._v?BASE_COLORS:0)].transparent)
|
||||||
|
|| ((backgroundColor._colorSpace == COLOR_SPACE_SYSTEM) &&
|
||||||
|
base[backgroundColor._u+2+(backgroundColor._v?BASE_COLORS:0)].transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Character::equalsFormat(const Character& other) const
|
||||||
|
{
|
||||||
|
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];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A table which stores sequences of unicode characters, referenced
|
||||||
|
* by hash keys. The hash key itself is the same size as a unicode
|
||||||
|
* character ( ushort ) so that it can occupy the same space in
|
||||||
|
* a structure.
|
||||||
|
*/
|
||||||
|
class ExtendedCharTable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** Constructs a new character table. */
|
||||||
|
ExtendedCharTable();
|
||||||
|
~ExtendedCharTable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a sequences of unicode characters to the table and returns
|
||||||
|
* a hash code which can be used later to look up the sequence
|
||||||
|
* using lookupExtendedChar()
|
||||||
|
*
|
||||||
|
* If the same sequence already exists in the table, the hash
|
||||||
|
* of the existing sequence will be returned.
|
||||||
|
*
|
||||||
|
* @param unicodePoints An array of unicode character points
|
||||||
|
* @param length Length of @p unicodePoints
|
||||||
|
*/
|
||||||
|
ushort createExtendedChar(ushort* unicodePoints , ushort length);
|
||||||
|
/**
|
||||||
|
* Looks up and returns a pointer to a sequence of unicode characters
|
||||||
|
* 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
|
||||||
|
* character sequence.
|
||||||
|
*
|
||||||
|
* @return A unicode character sequence of size @p length.
|
||||||
|
*/
|
||||||
|
ushort* lookupExtendedChar(ushort hash , ushort& length) const;
|
||||||
|
|
||||||
|
/** The global ExtendedCharTable instance. */
|
||||||
|
static ExtendedCharTable instance;
|
||||||
|
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
|
||||||
|
// 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
|
||||||
|
// in each value is the length of the buffer, followed by the ushorts in the buffer
|
||||||
|
// themselves.
|
||||||
|
QHash<ushort,ushort*> extendedCharTable;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Q_DECLARE_TYPEINFO(Character, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
|
#endif // CHARACTER_H
|
||||||
|
|
294
konsole-qml-plugin/src/CharacterColor.h
Normal file
@ -0,0 +1,294 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Konsole, KDE's terminal.
|
||||||
|
|
||||||
|
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
|
||||||
|
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||||
|
|
||||||
|
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 CHARACTERCOLOR_H
|
||||||
|
#define CHARACTERCOLOR_H
|
||||||
|
|
||||||
|
// Qt
|
||||||
|
#include <QtGui/QColor>
|
||||||
|
|
||||||
|
//#include <kdemacros.h>
|
||||||
|
#define KDE_NO_EXPORT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Each entry can also be transparent, in which case the terminal
|
||||||
|
* display should avoid drawing the background for any characters
|
||||||
|
* using the entry as a background.
|
||||||
|
*/
|
||||||
|
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 weight Specifies the font weight to use when drawing text with this color.
|
||||||
|
*/
|
||||||
|
ColorEntry(QColor c, bool tr, FontWeight weight = UseCurrentFormat)
|
||||||
|
: color(c), transparent(tr), fontWeight(weight) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new color palette entry with an undefined color, and
|
||||||
|
* with the transparent and bold flags set to false.
|
||||||
|
*/
|
||||||
|
ColorEntry() : transparent(false), fontWeight(UseCurrentFormat) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the color, transparency and boldness of this color to those of @p rhs.
|
||||||
|
*/
|
||||||
|
void operator=(const ColorEntry& rhs)
|
||||||
|
{
|
||||||
|
color = rhs.color;
|
||||||
|
transparent = rhs.transparent;
|
||||||
|
fontWeight = rhs.fontWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The color value of this entry for display. */
|
||||||
|
QColor color;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true character backgrounds using this color should be transparent.
|
||||||
|
* This is not applicable when the color is used to render text.
|
||||||
|
*/
|
||||||
|
bool transparent;
|
||||||
|
/**
|
||||||
|
* Specifies the font weight to use when drawing text with this color.
|
||||||
|
* This is not applicable when the color is used to draw a character's background.
|
||||||
|
*/
|
||||||
|
FontWeight fontWeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Attributed Character Representations ///////////////////////////////
|
||||||
|
|
||||||
|
// Colors
|
||||||
|
|
||||||
|
#define BASE_COLORS (2+8)
|
||||||
|
#define INTENSITIES 2
|
||||||
|
#define TABLE_COLORS (INTENSITIES*BASE_COLORS)
|
||||||
|
|
||||||
|
#define DEFAULT_FORE_COLOR 0
|
||||||
|
#define DEFAULT_BACK_COLOR 1
|
||||||
|
|
||||||
|
//a standard set of colors using black text on a white background.
|
||||||
|
//defined in TerminalDisplay.cpp
|
||||||
|
|
||||||
|
extern const ColorEntry base_color_table[TABLE_COLORS] KDE_NO_EXPORT;
|
||||||
|
|
||||||
|
/* CharacterColor is a union of the various color spaces.
|
||||||
|
|
||||||
|
Assignment is as follows:
|
||||||
|
|
||||||
|
Type - Space - Values
|
||||||
|
|
||||||
|
0 - Undefined - u: 0, v:0 w:0
|
||||||
|
1 - Default - u: 0..1 v:intense w:0
|
||||||
|
2 - System - u: 0..7 v:intense w:0
|
||||||
|
3 - Index(256) - u: 16..255 v:0 w:0
|
||||||
|
4 - RGB - u: 0..255 v:0..256 w:0..256
|
||||||
|
|
||||||
|
Default colour space has two separate colours, namely
|
||||||
|
default foreground and default background colour.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define COLOR_SPACE_UNDEFINED 0
|
||||||
|
#define COLOR_SPACE_DEFAULT 1
|
||||||
|
#define COLOR_SPACE_SYSTEM 2
|
||||||
|
#define COLOR_SPACE_256 3
|
||||||
|
#define COLOR_SPACE_RGB 4
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes the color of a single character in the terminal.
|
||||||
|
*/
|
||||||
|
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 using the specified @p colorSpace and with
|
||||||
|
* color value @p co
|
||||||
|
*
|
||||||
|
* The meaning of @p co depends on the @p colorSpace used.
|
||||||
|
*
|
||||||
|
* TODO : Document how @p co relates to @p colorSpace
|
||||||
|
*
|
||||||
|
* TODO : Add documentation about available color spaces.
|
||||||
|
*/
|
||||||
|
CharacterColor(quint8 colorSpace, int co)
|
||||||
|
: _colorSpace(colorSpace),
|
||||||
|
_u(0),
|
||||||
|
_v(0),
|
||||||
|
_w(0)
|
||||||
|
{
|
||||||
|
switch (colorSpace)
|
||||||
|
{
|
||||||
|
case COLOR_SPACE_DEFAULT:
|
||||||
|
_u = co & 1;
|
||||||
|
break;
|
||||||
|
case COLOR_SPACE_SYSTEM:
|
||||||
|
_u = co & 7;
|
||||||
|
_v = (co >> 3) & 1;
|
||||||
|
break;
|
||||||
|
case COLOR_SPACE_256:
|
||||||
|
_u = co & 255;
|
||||||
|
break;
|
||||||
|
case COLOR_SPACE_RGB:
|
||||||
|
_u = co >> 16;
|
||||||
|
_v = co >> 8;
|
||||||
|
_w = co;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_colorSpace = COLOR_SPACE_UNDEFINED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this character color entry is valid.
|
||||||
|
*/
|
||||||
|
bool isValid()
|
||||||
|
{
|
||||||
|
return _colorSpace != COLOR_SPACE_UNDEFINED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles the value of this color between a normal system color and the corresponding intensive
|
||||||
|
* system color.
|
||||||
|
*
|
||||||
|
* This is only applicable if the color is using the COLOR_SPACE_DEFAULT or COLOR_SPACE_SYSTEM
|
||||||
|
* color spaces.
|
||||||
|
*/
|
||||||
|
void toggleIntensive();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the color within the specified color @p palette
|
||||||
|
*
|
||||||
|
* The @p palette is only used if this color is one of the 16 system colors, otherwise
|
||||||
|
* it is ignored.
|
||||||
|
*/
|
||||||
|
QColor color(const ColorEntry* palette) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares two colors and returns true if they represent the same color value and
|
||||||
|
* use the same color space.
|
||||||
|
*/
|
||||||
|
friend bool operator == (const CharacterColor& a, const CharacterColor& b);
|
||||||
|
/**
|
||||||
|
* Compares two colors and returns true if they represent different color values
|
||||||
|
* or use different color spaces.
|
||||||
|
*/
|
||||||
|
friend bool operator != (const CharacterColor& a, const CharacterColor& b);
|
||||||
|
|
||||||
|
private:
|
||||||
|
quint8 _colorSpace;
|
||||||
|
|
||||||
|
// bytes storing the character color
|
||||||
|
quint8 _u;
|
||||||
|
quint8 _v;
|
||||||
|
quint8 _w;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool operator == (const CharacterColor& a, const CharacterColor& b)
|
||||||
|
{
|
||||||
|
return a._colorSpace == b._colorSpace &&
|
||||||
|
a._u == b._u &&
|
||||||
|
a._v == b._v &&
|
||||||
|
a._w == b._w;
|
||||||
|
}
|
||||||
|
inline bool operator != (const CharacterColor& a, const CharacterColor& b)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
// 16..231: 6x6x6 rgb color cube
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QColor CharacterColor::color(const ColorEntry* base) const
|
||||||
|
{
|
||||||
|
switch (_colorSpace)
|
||||||
|
{
|
||||||
|
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_UNDEFINED: return QColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_ASSERT(false); // invalid color space
|
||||||
|
|
||||||
|
return QColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CharacterColor::toggleIntensive()
|
||||||
|
{
|
||||||
|
if (_colorSpace == COLOR_SPACE_SYSTEM || _colorSpace == COLOR_SPACE_DEFAULT)
|
||||||
|
{
|
||||||
|
_v = !_v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CHARACTERCOLOR_H
|
||||||
|
|
774
konsole-qml-plugin/src/ColorScheme.cpp
Normal file
@ -0,0 +1,774 @@
|
|||||||
|
/*
|
||||||
|
This source file is part of Konsole, a terminal emulator.
|
||||||
|
|
||||||
|
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU 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 <QtGui/QBrush>
|
||||||
|
#include <QtCore/QFile>
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtDebug>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
|
||||||
|
// KDE
|
||||||
|
//#include <KColorScheme>
|
||||||
|
//#include <KConfig>
|
||||||
|
//#include <KLocale>
|
||||||
|
//#include <KDebug>
|
||||||
|
//#include <KConfigGroup>
|
||||||
|
//#include <KStandardDirs>
|
||||||
|
|
||||||
|
|
||||||
|
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), 0), ColorEntry(
|
||||||
|
QColor(0xFF,0xFF,0xFF), 1), // Dfore, Dback
|
||||||
|
ColorEntry( QColor(0x00,0x00,0x00), 0), ColorEntry(
|
||||||
|
QColor(0xB2,0x18,0x18), 0), // Black, Red
|
||||||
|
ColorEntry( QColor(0x18,0xB2,0x18), 0), ColorEntry(
|
||||||
|
QColor(0xB2,0x68,0x18), 0), // Green, Yellow
|
||||||
|
ColorEntry( QColor(0x18,0x18,0xB2), 0), ColorEntry(
|
||||||
|
QColor(0xB2,0x18,0xB2), 0), // Blue, Magenta
|
||||||
|
ColorEntry( QColor(0x18,0xB2,0xB2), 0), ColorEntry(
|
||||||
|
QColor(0xB2,0xB2,0xB2), 0), // Cyan, White
|
||||||
|
// intensive
|
||||||
|
ColorEntry( QColor(0x00,0x00,0x00), 0), ColorEntry(
|
||||||
|
QColor(0xFF,0xFF,0xFF), 1),
|
||||||
|
ColorEntry( QColor(0x68,0x68,0x68), 0), ColorEntry(
|
||||||
|
QColor(0xFF,0x54,0x54), 0),
|
||||||
|
ColorEntry( QColor(0x54,0xFF,0x54), 0), ColorEntry(
|
||||||
|
QColor(0xFF,0xFF,0x54), 0),
|
||||||
|
ColorEntry( QColor(0x54,0x54,0xFF), 0), ColorEntry(
|
||||||
|
QColor(0xFF,0x54,0xFF), 0),
|
||||||
|
ColorEntry( QColor(0x54,0xFF,0xFF), 0), ColorEntry(
|
||||||
|
QColor(0xFF,0xFF,0xFF), 0)
|
||||||
|
};
|
||||||
|
|
||||||
|
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 = 0;
|
||||||
|
_randomTable = 0;
|
||||||
|
_opacity = 1.0;
|
||||||
|
}
|
||||||
|
ColorScheme::ColorScheme(const ColorScheme& other)
|
||||||
|
: _opacity(other._opacity)
|
||||||
|
,_table(0)
|
||||||
|
,_randomTable(0)
|
||||||
|
{
|
||||||
|
setName(other.name());
|
||||||
|
setDescription(other.description());
|
||||||
|
|
||||||
|
if ( other._table != 0 )
|
||||||
|
{
|
||||||
|
for ( int i = 0 ; i < TABLE_COLORS ; i++ )
|
||||||
|
setColorTableEntry(i,other._table[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( other._randomTable != 0 )
|
||||||
|
{
|
||||||
|
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<TABLE_COLORS;i++)
|
||||||
|
_table[i] = defaultTable[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
_table[index] = entry;
|
||||||
|
}
|
||||||
|
ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const
|
||||||
|
{
|
||||||
|
Q_ASSERT( index >= 0 && index < TABLE_COLORS );
|
||||||
|
|
||||||
|
if ( randomSeed != 0 )
|
||||||
|
qsrand(randomSeed);
|
||||||
|
|
||||||
|
ColorEntry entry = colorTable()[index];
|
||||||
|
|
||||||
|
if ( randomSeed != 0 &&
|
||||||
|
_randomTable != 0 &&
|
||||||
|
!_randomTable[index].isNull() )
|
||||||
|
{
|
||||||
|
const RandomizationRange& range = _randomTable[index];
|
||||||
|
|
||||||
|
|
||||||
|
int hueDifference = range.hue ? (qrand() % range.hue) - range.hue/2 : 0;
|
||||||
|
int saturationDifference = range.saturation ? (qrand() % range.saturation) - range.saturation/2 : 0;
|
||||||
|
int valueDifference = range.value ? (qrand() % range.value) - range.value/2 : 0;
|
||||||
|
|
||||||
|
QColor& color = entry.color;
|
||||||
|
|
||||||
|
int newHue = qAbs( (color.hue() + hueDifference) % MAX_HUE );
|
||||||
|
int newValue = qMin( qAbs(color.value() + valueDifference) , 255 );
|
||||||
|
int newSaturation = qMin( qAbs(color.saturation() + saturationDifference) , 255 );
|
||||||
|
|
||||||
|
color.setHsv(newHue,newSaturation,newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
void ColorScheme::getColorTable(ColorEntry* table , uint randomSeed) const
|
||||||
|
{
|
||||||
|
for ( int i = 0 ; i < TABLE_COLORS ; i++ )
|
||||||
|
table[i] = colorEntry(i,randomSeed);
|
||||||
|
}
|
||||||
|
bool ColorScheme::randomizedBackgroundColor() const
|
||||||
|
{
|
||||||
|
return _randomTable == 0 ? 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 == 0 )
|
||||||
|
_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("General");
|
||||||
|
|
||||||
|
_description = s.value("Description", QObject::tr("Un-named Color Scheme")).toString();
|
||||||
|
_opacity = s.value("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(colorNames[index]);
|
||||||
|
}
|
||||||
|
QString ColorScheme::translatedColorNameForIndex(int index)
|
||||||
|
{
|
||||||
|
Q_ASSERT( index >= 0 && index < TABLE_COLORS );
|
||||||
|
|
||||||
|
return translatedColorNames[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorScheme::readColorEntry(QSettings * s , int index)
|
||||||
|
{
|
||||||
|
s->beginGroup(colorNameForIndex(index));
|
||||||
|
|
||||||
|
ColorEntry entry;
|
||||||
|
|
||||||
|
QStringList rgbList = s->value("Color", QStringList()).toStringList();
|
||||||
|
if (rgbList.count() != 3)
|
||||||
|
{
|
||||||
|
Q_ASSERT(0);
|
||||||
|
}
|
||||||
|
int r, g, b;
|
||||||
|
r = rgbList[0].toInt();
|
||||||
|
g = rgbList[1].toInt();
|
||||||
|
b = rgbList[2].toInt();
|
||||||
|
entry.color = QColor(r, g, b);
|
||||||
|
|
||||||
|
entry.transparent = s->value("Transparent",false).toBool();
|
||||||
|
|
||||||
|
// Deprecated key from KDE 4.0 which set 'Bold' to true to force
|
||||||
|
// 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("Bold"))
|
||||||
|
entry.fontWeight = s->value("Bold",false).toBool() ? ColorEntry::Bold :
|
||||||
|
ColorEntry::UseCurrentFormat;
|
||||||
|
|
||||||
|
quint16 hue = s->value("MaxRandomHue",0).toInt();
|
||||||
|
quint8 value = s->value("MaxRandomValue",0).toInt();
|
||||||
|
quint8 saturation = s->value("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 <robertknight@gmail.com> 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
|
||||||
|
}
|
||||||
|
|
||||||
|
KDE3ColorSchemeReader::KDE3ColorSchemeReader( QIODevice* device ) :
|
||||||
|
_device(device)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
ColorScheme* KDE3ColorSchemeReader::read()
|
||||||
|
{
|
||||||
|
Q_ASSERT( _device->openMode() == QIODevice::ReadOnly ||
|
||||||
|
_device->openMode() == QIODevice::ReadWrite );
|
||||||
|
|
||||||
|
ColorScheme* scheme = new ColorScheme();
|
||||||
|
|
||||||
|
QRegExp comment("#.*$");
|
||||||
|
while ( !_device->atEnd() )
|
||||||
|
{
|
||||||
|
QString line(_device->readLine());
|
||||||
|
line.remove(comment);
|
||||||
|
line = line.simplified();
|
||||||
|
|
||||||
|
if ( line.isEmpty() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( line.startsWith(QLatin1String("color")) )
|
||||||
|
{
|
||||||
|
if (!readColorLine(line,scheme))
|
||||||
|
qDebug() << "Failed to read KDE 3 color scheme line" << line;
|
||||||
|
}
|
||||||
|
else if ( line.startsWith(QLatin1String("title")) )
|
||||||
|
{
|
||||||
|
if (!readTitleLine(line,scheme))
|
||||||
|
qDebug() << "Failed to read KDE 3 color scheme title line" << line;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "KDE 3 color scheme contains an unsupported feature, '" <<
|
||||||
|
line << "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return scheme;
|
||||||
|
}
|
||||||
|
bool KDE3ColorSchemeReader::readColorLine(const QString& line,ColorScheme* scheme)
|
||||||
|
{
|
||||||
|
QStringList list = line.split(QChar(' '));
|
||||||
|
|
||||||
|
if (list.count() != 7)
|
||||||
|
return false;
|
||||||
|
if (list.first() != "color")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int index = list[1].toInt();
|
||||||
|
int red = list[2].toInt();
|
||||||
|
int green = list[3].toInt();
|
||||||
|
int blue = list[4].toInt();
|
||||||
|
int transparent = list[5].toInt();
|
||||||
|
int bold = list[6].toInt();
|
||||||
|
|
||||||
|
const int MAX_COLOR_VALUE = 255;
|
||||||
|
|
||||||
|
if( (index < 0 || index >= TABLE_COLORS )
|
||||||
|
|| (red < 0 || red > MAX_COLOR_VALUE )
|
||||||
|
|| (blue < 0 || blue > MAX_COLOR_VALUE )
|
||||||
|
|| (green < 0 || green > MAX_COLOR_VALUE )
|
||||||
|
|| (transparent != 0 && transparent != 1 )
|
||||||
|
|| (bold != 0 && bold != 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ColorEntry entry;
|
||||||
|
entry.color = QColor(red,green,blue);
|
||||||
|
entry.transparent = ( transparent != 0 );
|
||||||
|
entry.fontWeight = ( bold != 0 ) ? ColorEntry::Bold : ColorEntry::UseCurrentFormat;
|
||||||
|
|
||||||
|
scheme->setColorTableEntry(index,entry);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool KDE3ColorSchemeReader::readTitleLine(const QString& line,ColorScheme* scheme)
|
||||||
|
{
|
||||||
|
if( !line.startsWith(QLatin1String("title")) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int spacePos = line.indexOf(' ');
|
||||||
|
if( spacePos == -1 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QString description = line.mid(spacePos+1);
|
||||||
|
|
||||||
|
scheme->setDescription(description.toUtf8());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ColorSchemeManager::ColorSchemeManager()
|
||||||
|
: _haveLoadedAll(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
ColorSchemeManager::~ColorSchemeManager()
|
||||||
|
{
|
||||||
|
QHashIterator<QString,const ColorScheme*> iter(_colorSchemes);
|
||||||
|
while (iter.hasNext())
|
||||||
|
{
|
||||||
|
iter.next();
|
||||||
|
delete iter.value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void ColorSchemeManager::loadAllColorSchemes()
|
||||||
|
{
|
||||||
|
qDebug() << "loadAllColorSchemes";
|
||||||
|
int success = 0;
|
||||||
|
int failed = 0;
|
||||||
|
|
||||||
|
QList<QString> nativeColorSchemes = listColorSchemes();
|
||||||
|
|
||||||
|
QListIterator<QString> nativeIter(nativeColorSchemes);
|
||||||
|
while ( nativeIter.hasNext() )
|
||||||
|
{
|
||||||
|
if ( loadColorScheme( nativeIter.next() ) )
|
||||||
|
success++;
|
||||||
|
else
|
||||||
|
failed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QString> kde3ColorSchemes = listKDE3ColorSchemes();
|
||||||
|
QListIterator<QString> kde3Iter(kde3ColorSchemes);
|
||||||
|
while ( kde3Iter.hasNext() )
|
||||||
|
{
|
||||||
|
if ( loadKDE3ColorScheme( kde3Iter.next() ) )
|
||||||
|
success++;
|
||||||
|
else
|
||||||
|
failed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( failed > 0 )
|
||||||
|
qDebug() << "failed to load " << failed << " color schemes.";
|
||||||
|
|
||||||
|
_haveLoadedAll = true;
|
||||||
|
}
|
||||||
|
QList<const ColorScheme*> ColorSchemeManager::allColorSchemes()
|
||||||
|
{
|
||||||
|
if ( !_haveLoadedAll )
|
||||||
|
{
|
||||||
|
loadAllColorSchemes();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _colorSchemes.values();
|
||||||
|
}
|
||||||
|
bool ColorSchemeManager::loadKDE3ColorScheme(const QString& filePath)
|
||||||
|
{
|
||||||
|
QFile file(filePath);
|
||||||
|
if (!filePath.endsWith(QLatin1String(".schema")) || !file.open(QIODevice::ReadOnly))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
KDE3ColorSchemeReader reader(&file);
|
||||||
|
ColorScheme* scheme = reader.read();
|
||||||
|
scheme->setName(QFileInfo(file).baseName());
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
if (scheme->name().isEmpty())
|
||||||
|
{
|
||||||
|
qDebug() << "color scheme name is not valid.";
|
||||||
|
delete scheme;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfo info(filePath);
|
||||||
|
|
||||||
|
if ( !_colorSchemes.contains(info.baseName()) )
|
||||||
|
_colorSchemes.insert(scheme->name(),scheme);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "color scheme with name" << scheme->name() << "has already been" <<
|
||||||
|
"found, ignoring.";
|
||||||
|
delete scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#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::loadColorScheme(const QString& filePath)
|
||||||
|
{
|
||||||
|
if ( !filePath.endsWith(QLatin1String(".colorscheme")) || !QFile::exists(filePath) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QFileInfo info(filePath);
|
||||||
|
|
||||||
|
ColorScheme* scheme = new ColorScheme();
|
||||||
|
scheme->setName(info.baseName());
|
||||||
|
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(info.baseName()) )
|
||||||
|
{
|
||||||
|
_colorSchemes.insert(scheme->name(),scheme);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "color scheme with name" << scheme->name() << "has already been" <<
|
||||||
|
"found, ignoring.";
|
||||||
|
|
||||||
|
delete scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
QList<QString> ColorSchemeManager::listKDE3ColorSchemes()
|
||||||
|
{
|
||||||
|
QString dname(get_color_schemes_dir());
|
||||||
|
QDir dir(dname);
|
||||||
|
QStringList filters;
|
||||||
|
filters << "*.schema";
|
||||||
|
dir.setNameFilters(filters);
|
||||||
|
QStringList list = dir.entryList(filters);
|
||||||
|
QStringList ret;
|
||||||
|
foreach(QString i, list)
|
||||||
|
ret << dname + "/" + i;
|
||||||
|
return ret;
|
||||||
|
//return KGlobal::dirs()->findAllResources("data",
|
||||||
|
// "konsole/*.schema",
|
||||||
|
// KStandardDirs::NoDuplicates);
|
||||||
|
//
|
||||||
|
}
|
||||||
|
QList<QString> ColorSchemeManager::listColorSchemes()
|
||||||
|
{
|
||||||
|
QString dname(get_color_schemes_dir());
|
||||||
|
QDir dir(dname);
|
||||||
|
QStringList filters;
|
||||||
|
filters << "*.colorscheme";
|
||||||
|
dir.setNameFilters(filters);
|
||||||
|
QStringList list = dir.entryList(filters);
|
||||||
|
QStringList ret;
|
||||||
|
foreach(QString i, list)
|
||||||
|
ret << dname + "/" + 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");
|
||||||
|
QString path(get_color_schemes_dir() + "/"+ name + ".colorscheme");
|
||||||
|
if ( !path.isEmpty() )
|
||||||
|
return path;
|
||||||
|
|
||||||
|
//path = KStandardDirs::locate("data","konsole/"+name+".schema");
|
||||||
|
path = get_color_schemes_dir() + "/"+ name + ".schema";
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!path.isEmpty() && loadKDE3ColorScheme(path))
|
||||||
|
return findColorScheme(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "Could not find color scheme - " << name;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorSchemeManager* ColorSchemeManager::theColorSchemeManager = 0;
|
||||||
|
//K_GLOBAL_STATIC( ColorSchemeManager , theColorSchemeManager )
|
||||||
|
ColorSchemeManager* ColorSchemeManager::instance()
|
||||||
|
{
|
||||||
|
if (! theColorSchemeManager)
|
||||||
|
theColorSchemeManager = new ColorSchemeManager();
|
||||||
|
return theColorSchemeManager;
|
||||||
|
}
|
342
konsole-qml-plugin/src/ColorScheme.h
Normal file
@ -0,0 +1,342 @@
|
|||||||
|
/*
|
||||||
|
This source file is part of Konsole, a terminal emulator.
|
||||||
|
|
||||||
|
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU 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 <QtCore/QHash>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QMetaType>
|
||||||
|
#include <QtCore/QIODevice>
|
||||||
|
#include <QtCore/QSet>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
// Konsole
|
||||||
|
#include "CharacterColor.h"
|
||||||
|
|
||||||
|
class QIODevice;
|
||||||
|
//class KConfig;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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, uint randomSeed = 0) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a single color entry from the table.
|
||||||
|
*
|
||||||
|
* See getColorTable()
|
||||||
|
*/
|
||||||
|
ColorEntry colorEntry(int index , uint randomSeed = 0) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method. Returns the
|
||||||
|
* foreground color for this scheme,
|
||||||
|
* this is the primary color used to draw the
|
||||||
|
* 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();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a color scheme stored in the .schema format used in the KDE 3 incarnation
|
||||||
|
* of Konsole
|
||||||
|
*
|
||||||
|
* Only the basic essentials ( title and color palette entries ) are currently
|
||||||
|
* supported. Additional options such as background image and background
|
||||||
|
* blend colors are ignored.
|
||||||
|
*/
|
||||||
|
class KDE3ColorSchemeReader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructs a new reader which reads from the specified device.
|
||||||
|
* The device should be open in read-only mode.
|
||||||
|
*/
|
||||||
|
KDE3ColorSchemeReader( QIODevice* device );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads and parses the contents of the .schema file from the input
|
||||||
|
* device and returns the ColorScheme defined within it.
|
||||||
|
*
|
||||||
|
* Returns a null pointer if an error occurs whilst parsing
|
||||||
|
* the contents of the file.
|
||||||
|
*/
|
||||||
|
ColorScheme* read();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// reads a line from the file specifying a colour palette entry
|
||||||
|
// format is: color [index] [red] [green] [blue] [transparent] [bold]
|
||||||
|
bool readColorLine(const QString& line , ColorScheme* scheme);
|
||||||
|
bool readTitleLine(const QString& line , ColorScheme* scheme);
|
||||||
|
|
||||||
|
QIODevice* _device;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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<const ColorScheme*> allColorSchemes();
|
||||||
|
|
||||||
|
/** Returns the global color scheme manager instance. */
|
||||||
|
static ColorSchemeManager* instance();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// loads a color scheme from a KDE 4+ .colorscheme file
|
||||||
|
bool loadColorScheme(const QString& path);
|
||||||
|
// loads a color scheme from a KDE 3 .schema file
|
||||||
|
bool loadKDE3ColorScheme(const QString& path);
|
||||||
|
// returns a list of paths of color schemes in the KDE 4+ .colorscheme file format
|
||||||
|
QList<QString> listColorSchemes();
|
||||||
|
// returns a list of paths of color schemes in the .schema file format
|
||||||
|
// used in KDE 3
|
||||||
|
QList<QString> listKDE3ColorSchemes();
|
||||||
|
// loads all of the color schemes
|
||||||
|
void loadAllColorSchemes();
|
||||||
|
// finds the path of a color scheme
|
||||||
|
QString findColorSchemePath(const QString& name) const;
|
||||||
|
|
||||||
|
QHash<QString,const ColorScheme*> _colorSchemes;
|
||||||
|
QSet<ColorScheme*> _modifiedSchemes;
|
||||||
|
|
||||||
|
bool _haveLoadedAll;
|
||||||
|
|
||||||
|
static const ColorScheme _defaultColorScheme;
|
||||||
|
|
||||||
|
static ColorSchemeManager * theColorSchemeManager;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(const ColorScheme*)
|
||||||
|
|
||||||
|
#endif //COLORSCHEME_H
|
55
konsole-qml-plugin/src/ColorTables.h
Normal file
@ -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
|
||||||
|
|
2
konsole-qml-plugin/src/DefaultTranslatorText.h
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
"keyboard \"Fallback Key Translator\"\n"
|
||||||
|
"key Tab : \"\\t\" \0"
|
458
konsole-qml-plugin/src/Emulation.cpp
Normal file
@ -0,0 +1,458 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2007-2008 Robert Knight <robertknight@gmail.com>
|
||||||
|
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||||
|
Copyright 1996 by Matthias Ettrich <ettrich@kde.org>
|
||||||
|
|
||||||
|
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 "Emulation.h"
|
||||||
|
|
||||||
|
// System
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
// Qt
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QtGui/QClipboard>
|
||||||
|
#include <QtCore/QHash>
|
||||||
|
#include <QtGui/QKeyEvent>
|
||||||
|
#include <QtCore/QRegExp>
|
||||||
|
#include <QtCore/QTextStream>
|
||||||
|
#include <QtCore/QThread>
|
||||||
|
|
||||||
|
#include <QtCore/QTime>
|
||||||
|
|
||||||
|
// KDE
|
||||||
|
//#include <kdebug.h>
|
||||||
|
|
||||||
|
// Konsole
|
||||||
|
#include "KeyboardTranslator.h"
|
||||||
|
#include "Screen.h"
|
||||||
|
#include "TerminalCharacterDecoder.h"
|
||||||
|
#include "ScreenWindow.h"
|
||||||
|
|
||||||
|
Emulation::Emulation() :
|
||||||
|
_currentScreen(0),
|
||||||
|
_codec(0),
|
||||||
|
_decoder(0),
|
||||||
|
_keyTranslator(0),
|
||||||
|
_usesMouse(false)
|
||||||
|
{
|
||||||
|
// create screens with a default size
|
||||||
|
_screen[0] = new Screen(40,80);
|
||||||
|
_screen[1] = new Screen(40,80);
|
||||||
|
_currentScreen = _screen[0];
|
||||||
|
|
||||||
|
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)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Emulation::programUsesMouse() const
|
||||||
|
{
|
||||||
|
return _usesMouse;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::usesMouseChanged(bool usesMouse)
|
||||||
|
{
|
||||||
|
_usesMouse = usesMouse;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScreenWindow* Emulation::createWindow()
|
||||||
|
{
|
||||||
|
ScreenWindow* window = new ScreenWindow();
|
||||||
|
window->setScreen(_currentScreen);
|
||||||
|
_windows << window;
|
||||||
|
|
||||||
|
connect(window , SIGNAL(selectionChanged()),
|
||||||
|
this , SLOT(bufferedUpdate()));
|
||||||
|
|
||||||
|
connect(this , SIGNAL(outputChanged()),
|
||||||
|
window , SLOT(notifyOutputChanged()) );
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
Emulation::~Emulation()
|
||||||
|
{
|
||||||
|
QListIterator<ScreenWindow*> windowIter(_windows);
|
||||||
|
|
||||||
|
while (windowIter.hasNext())
|
||||||
|
{
|
||||||
|
delete windowIter.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
delete _screen[0];
|
||||||
|
delete _screen[1];
|
||||||
|
delete _decoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::setScreen(int n)
|
||||||
|
{
|
||||||
|
Screen *old = _currentScreen;
|
||||||
|
_currentScreen = _screen[n & 1];
|
||||||
|
if (_currentScreen != old)
|
||||||
|
{
|
||||||
|
// tell all windows onto this emulation to switch to the newly active screen
|
||||||
|
foreach(ScreenWindow* window,_windows)
|
||||||
|
window->setScreen(_currentScreen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::clearHistory()
|
||||||
|
{
|
||||||
|
_screen[0]->setScroll( _screen[0]->getScroll() , false );
|
||||||
|
}
|
||||||
|
void Emulation::setHistory(const HistoryType& t)
|
||||||
|
{
|
||||||
|
_screen[0]->setScroll(t);
|
||||||
|
|
||||||
|
showBulk();
|
||||||
|
}
|
||||||
|
|
||||||
|
const HistoryType& Emulation::history() const
|
||||||
|
{
|
||||||
|
return _screen[0]->getScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::setCodec(const QTextCodec * qtc)
|
||||||
|
{
|
||||||
|
if (qtc)
|
||||||
|
_codec = qtc;
|
||||||
|
else
|
||||||
|
setCodec(LocaleCodec);
|
||||||
|
|
||||||
|
delete _decoder;
|
||||||
|
_decoder = _codec->makeDecoder();
|
||||||
|
|
||||||
|
emit useUtf8Request(utf8());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::setCodec(EmulationCodec codec)
|
||||||
|
{
|
||||||
|
if ( codec == Utf8Codec )
|
||||||
|
setCodec( QTextCodec::codecForName("utf8") );
|
||||||
|
else if ( codec == LocaleCodec )
|
||||||
|
setCodec( QTextCodec::codecForLocale() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::setKeyBindings(const QString& name)
|
||||||
|
{
|
||||||
|
_keyTranslator = KeyboardTranslatorManager::instance()->findTranslator(name);
|
||||||
|
if (!_keyTranslator)
|
||||||
|
{
|
||||||
|
_keyTranslator = KeyboardTranslatorManager::instance()->defaultTranslator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Emulation::keyBindings() const
|
||||||
|
{
|
||||||
|
return _keyTranslator->name();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::receiveChar(int c)
|
||||||
|
// process application unicode input to terminal
|
||||||
|
// this is a trivial scanner
|
||||||
|
{
|
||||||
|
c &= 0xff;
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
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->displayCharacter(c); break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::sendKeyEvent( QKeyEvent* ev )
|
||||||
|
{
|
||||||
|
emit stateSet(NOTIFYNORMAL);
|
||||||
|
|
||||||
|
if (!ev->text().isEmpty())
|
||||||
|
{ // A block of text
|
||||||
|
// Note that the text is proper unicode.
|
||||||
|
// We should do a conversion here
|
||||||
|
emit sendData(ev->text().toUtf8(),ev->text().length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::sendString(const char*,int)
|
||||||
|
{
|
||||||
|
// default implementation does nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::sendMouseEvent(int /*buttons*/, int /*column*/, int /*row*/, int /*eventType*/)
|
||||||
|
{
|
||||||
|
// default implementation does nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
We are doing code conversion from locale to unicode first.
|
||||||
|
TODO: Character composition from the old code. See #96536
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Emulation::receiveData(const char* text, int length)
|
||||||
|
{
|
||||||
|
emit stateSet(NOTIFYACTIVITY);
|
||||||
|
|
||||||
|
bufferedUpdate();
|
||||||
|
|
||||||
|
QString unicodeText = _decoder->toUnicode(text,length);
|
||||||
|
|
||||||
|
//send characters to terminal emulator
|
||||||
|
for (int i=0;i<unicodeText.length();i++)
|
||||||
|
receiveChar(unicodeText[i].unicode());
|
||||||
|
|
||||||
|
//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<length;i++)
|
||||||
|
{
|
||||||
|
if (text[i] == '\030')
|
||||||
|
{
|
||||||
|
if ((length-i-1 > 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.
|
||||||
|
//
|
||||||
|
//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.
|
||||||
|
|
||||||
|
|
||||||
|
/*void Emulation::onRcvBlock(const char *s, int len)
|
||||||
|
{
|
||||||
|
emit notifySessionState(NOTIFYACTIVITY);
|
||||||
|
|
||||||
|
bufferedUpdate();
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
QString result = _decoder->toUnicode(&s[i],1);
|
||||||
|
int reslen = result.length();
|
||||||
|
|
||||||
|
// If we get a control code halfway a multi-byte sequence
|
||||||
|
// we flush the _decoder and continue with the control code.
|
||||||
|
if ((s[i] < 32) && (s[i] > 0))
|
||||||
|
{
|
||||||
|
// Flush _decoder
|
||||||
|
while(!result.length())
|
||||||
|
result = _decoder->toUnicode(&s[i],1);
|
||||||
|
reslen = 1;
|
||||||
|
result.resize(reslen);
|
||||||
|
result[0] = QChar(s[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < reslen; j++)
|
||||||
|
{
|
||||||
|
if (result[j].characterategory() == QChar::Mark_NonSpacing)
|
||||||
|
_currentScreen->compose(result.mid(j,1));
|
||||||
|
else
|
||||||
|
onRcvChar(result[j].unicode());
|
||||||
|
}
|
||||||
|
if (s[i] == '\030')
|
||||||
|
{
|
||||||
|
if ((len-i-1 > 3) && (strncmp(s+i+1, "B00", 3) == 0))
|
||||||
|
emit zmodemDetected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void Emulation::writeToStream( TerminalCharacterDecoder* _decoder ,
|
||||||
|
int startLine ,
|
||||||
|
int endLine)
|
||||||
|
{
|
||||||
|
_currentScreen->writeLinesToStream(_decoder,startLine,endLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Emulation::lineCount() const
|
||||||
|
{
|
||||||
|
// sum number of lines currently on _screen plus number of lines in history
|
||||||
|
return _currentScreen->getLines() + _currentScreen->getHistLines();
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BULK_TIMEOUT1 10
|
||||||
|
#define BULK_TIMEOUT2 40
|
||||||
|
|
||||||
|
void Emulation::showBulk()
|
||||||
|
{
|
||||||
|
_bulkTimer1.stop();
|
||||||
|
_bulkTimer2.stop();
|
||||||
|
|
||||||
|
emit outputChanged();
|
||||||
|
|
||||||
|
_currentScreen->resetScrolledLines();
|
||||||
|
_currentScreen->resetDroppedLines();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::bufferedUpdate()
|
||||||
|
{
|
||||||
|
_bulkTimer1.setSingleShot(true);
|
||||||
|
_bulkTimer1.start(BULK_TIMEOUT1);
|
||||||
|
if (!_bulkTimer2.isActive())
|
||||||
|
{
|
||||||
|
_bulkTimer2.setSingleShot(true);
|
||||||
|
_bulkTimer2.start(BULK_TIMEOUT2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char Emulation::eraseChar() const
|
||||||
|
{
|
||||||
|
return '\b';
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulation::setImageSize(int lines, int columns)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
emit imageSizeChanged(lines,columns);
|
||||||
|
|
||||||
|
bufferedUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize Emulation::imageSize() const
|
||||||
|
{
|
||||||
|
return QSize(_currentScreen->getColumns(), _currentScreen->getLines());
|
||||||
|
}
|
||||||
|
|
||||||
|
ushort ExtendedCharTable::extendedCharHash(ushort* unicodePoints , ushort length) const
|
||||||
|
{
|
||||||
|
ushort hash = 0;
|
||||||
|
for ( ushort i = 0 ; i < length ; i++ )
|
||||||
|
{
|
||||||
|
hash = 31*hash + unicodePoints[i];
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
bool ExtendedCharTable::extendedCharMatch(ushort hash , ushort* unicodePoints , ushort length) const
|
||||||
|
{
|
||||||
|
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 )
|
||||||
|
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 true;
|
||||||
|
}
|
||||||
|
ushort ExtendedCharTable::createExtendedChar(ushort* unicodePoints , ushort length)
|
||||||
|
{
|
||||||
|
// look for this sequence of points in the table
|
||||||
|
ushort hash = extendedCharHash(unicodePoints,length);
|
||||||
|
|
||||||
|
// check existing entry for match
|
||||||
|
while ( extendedCharTable.contains(hash) )
|
||||||
|
{
|
||||||
|
if ( extendedCharMatch(hash,unicodePoints,length) )
|
||||||
|
{
|
||||||
|
// this sequence already has an entry in the table,
|
||||||
|
// return its hash
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if hash is already used by another, different sequence of unicode character
|
||||||
|
// 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];
|
||||||
|
|
||||||
|
extendedCharTable.insert(hash,buffer);
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
ushort* ExtendedCharTable::lookupExtendedChar(ushort hash , ushort& length) const
|
||||||
|
{
|
||||||
|
// lookup index in table and if found, set the length
|
||||||
|
// argument and return a pointer to the character sequence
|
||||||
|
|
||||||
|
ushort* buffer = extendedCharTable[hash];
|
||||||
|
if ( buffer )
|
||||||
|
{
|
||||||
|
length = buffer[0];
|
||||||
|
return buffer+1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
length = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtendedCharTable::ExtendedCharTable()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
ExtendedCharTable::~ExtendedCharTable()
|
||||||
|
{
|
||||||
|
// free all allocated character buffers
|
||||||
|
QHashIterator<ushort,ushort*> iter(extendedCharTable);
|
||||||
|
while ( iter.hasNext() )
|
||||||
|
{
|
||||||
|
iter.next();
|
||||||
|
delete[] iter.value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// global instance
|
||||||
|
ExtendedCharTable ExtendedCharTable::instance;
|
||||||
|
|
||||||
|
|
||||||
|
//#include "Emulation.moc"
|
||||||
|
|
467
konsole-qml-plugin/src/Emulation.h
Normal file
@ -0,0 +1,467 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Konsole, an X terminal.
|
||||||
|
|
||||||
|
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
|
||||||
|
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||||
|
|
||||||
|
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 EMULATION_H
|
||||||
|
#define EMULATION_H
|
||||||
|
|
||||||
|
// System
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Qt
|
||||||
|
#include <QtGui/QKeyEvent>
|
||||||
|
//#include <QPointer>
|
||||||
|
#include <QtCore/QTextCodec>
|
||||||
|
#include <QtCore/QTextStream>
|
||||||
|
#include <QtCore/QTimer>
|
||||||
|
|
||||||
|
// Konsole
|
||||||
|
//#include "konsole_export.h"
|
||||||
|
#define KONSOLEPRIVATE_EXPORT
|
||||||
|
|
||||||
|
class KeyboardTranslator;
|
||||||
|
class HistoryType;
|
||||||
|
class Screen;
|
||||||
|
class ScreenWindow;
|
||||||
|
class TerminalCharacterDecoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This enum describes the available states which
|
||||||
|
* the terminal emulation may be set to.
|
||||||
|
*
|
||||||
|
* These are the values used by Emulation::stateChanged()
|
||||||
|
*/
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/** The emulation is currently receiving user input. */
|
||||||
|
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
|
||||||
|
* terminal input.
|
||||||
|
*/
|
||||||
|
NOTIFYACTIVITY=2,
|
||||||
|
|
||||||
|
// unused here?
|
||||||
|
NOTIFYSILENCE=3
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for terminal emulation back-ends.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* screen image accordingly. The codec used to decode the incoming character stream
|
||||||
|
* 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
|
||||||
|
* 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().
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* to the terminal program. Key presses can be processed by calling the sendKeyEvent() slot,
|
||||||
|
* while mouse events can be processed using the sendMouseEvent() slot. When the character
|
||||||
|
* stream has been produced, the emulation will emit a sendData() signal with a pointer
|
||||||
|
* to the character buffer. This data should be fed to the standard input of the terminal
|
||||||
|
* process. The translation of key presses into an output character stream is performed
|
||||||
|
* using a lookup in a set of key bindings which map key sequences to output
|
||||||
|
* 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 also maintains an activity state, which specifies whether
|
||||||
|
* terminal is currently active ( when data is received ), normal
|
||||||
|
* ( when the terminal is idle or receiving user input ) or trying
|
||||||
|
* to alert the user ( also known as a "Bell" event ). The stateSet() signal
|
||||||
|
* is emitted whenever the activity state is set. This can be used to determine
|
||||||
|
* how long the emulation has been active/idle for and also respond to
|
||||||
|
* a 'bell' event in different ways.
|
||||||
|
*/
|
||||||
|
class KONSOLEPRIVATE_EXPORT Emulation : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** Constructs a new terminal emulation */
|
||||||
|
Emulation();
|
||||||
|
~Emulation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new window onto the output from this emulation. The contents
|
||||||
|
* of the window are then rendered by views which are set to use this window using the
|
||||||
|
* TerminalDisplay::setScreenWindow() method.
|
||||||
|
*/
|
||||||
|
ScreenWindow* createWindow();
|
||||||
|
|
||||||
|
/** Returns the size of the screen image which the emulation produces */
|
||||||
|
QSize imageSize() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the total number of lines, including those stored in the history.
|
||||||
|
*/
|
||||||
|
int lineCount() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the history store used by this emulation. When new lines
|
||||||
|
* are added to the output, older lines at the top of the screen are transferred to a history
|
||||||
|
* store.
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
/** Clears the history scroll. */
|
||||||
|
void clearHistory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies the output history from @p startLine to @p endLine
|
||||||
|
* into @p stream, using @p decoder to convert the terminal
|
||||||
|
* characters into text.
|
||||||
|
*
|
||||||
|
* @param decoder A decoder which converts lines of terminal characters with
|
||||||
|
* appearance attributes into output text. PlainTextDecoder is the most commonly
|
||||||
|
* used decoder.
|
||||||
|
* @param startLine Index of first line to copy
|
||||||
|
* @param endLine Index of last line to copy
|
||||||
|
*/
|
||||||
|
virtual void writeToStream(TerminalCharacterDecoder* decoder,int startLine,int endLine);
|
||||||
|
|
||||||
|
/** Returns the codec used to decode incoming characters. See setCodec() */
|
||||||
|
const QTextCodec* codec() const { return _codec; }
|
||||||
|
/** Sets the codec used to decode incoming characters. */
|
||||||
|
void setCodec(const QTextCodec*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method.
|
||||||
|
* Returns true if the current codec used to decode incoming
|
||||||
|
* characters is UTF-8
|
||||||
|
*/
|
||||||
|
bool utf8() const
|
||||||
|
{ Q_ASSERT(_codec); return _codec->mibEnum() == 106; }
|
||||||
|
|
||||||
|
|
||||||
|
/** TODO Document me */
|
||||||
|
virtual char eraseChar() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the key bindings used to key events
|
||||||
|
* ( received through sendKeyEvent() ) into character
|
||||||
|
* streams to send to the terminal.
|
||||||
|
*/
|
||||||
|
void setKeyBindings(const QString& name);
|
||||||
|
/**
|
||||||
|
* Returns the name of the emulation's current key bindings.
|
||||||
|
* See setKeyBindings()
|
||||||
|
*/
|
||||||
|
QString keyBindings() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies the current image into the history and clears the screen.
|
||||||
|
*/
|
||||||
|
virtual void clearEntireScreen() =0;
|
||||||
|
|
||||||
|
/** Resets the state of the terminal. */
|
||||||
|
virtual void reset() =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the active terminal program wants
|
||||||
|
* mouse input events.
|
||||||
|
*
|
||||||
|
* The programUsesMouseChanged() signal is emitted when this
|
||||||
|
* changes.
|
||||||
|
*/
|
||||||
|
bool programUsesMouse() 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.
|
||||||
|
*/
|
||||||
|
virtual void sendKeyEvent(QKeyEvent*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts information about a mouse event into an xterm-compatible escape
|
||||||
|
* sequence and emits the character sequence via sendData()
|
||||||
|
*/
|
||||||
|
virtual void sendMouseEvent(int buttons, int column, int line, int eventType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a string of characters to the foreground terminal process.
|
||||||
|
*
|
||||||
|
* @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.
|
||||||
|
*
|
||||||
|
* receiveData() also starts a timer which causes the outputChanged() signal
|
||||||
|
* to be emitted when it expires. The timer allows multiple updates in quick
|
||||||
|
* succession to be buffered into a single outputChanged() signal emission.
|
||||||
|
*
|
||||||
|
* @param buffer A string of characters received from the terminal program.
|
||||||
|
* @param len The length of @p buffer
|
||||||
|
*/
|
||||||
|
void receiveData(const char* buffer,int len);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* @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
|
||||||
|
* suspended. Otherwise requests that sending of
|
||||||
|
* input be resumed.
|
||||||
|
*/
|
||||||
|
void lockPtyRequest(bool suspend);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests that the pty used by the terminal process
|
||||||
|
* be set to UTF 8 mode.
|
||||||
|
*
|
||||||
|
* TODO: More documentation
|
||||||
|
*/
|
||||||
|
void useUtf8Request(bool);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted when the activity state of the emulation is set.
|
||||||
|
*
|
||||||
|
* @param state The new activity state, one of NOTIFYNORMAL, NOTIFYACTIVITY
|
||||||
|
* or NOTIFYBELL
|
||||||
|
*/
|
||||||
|
void stateSet(int state);
|
||||||
|
|
||||||
|
/** TODO Document me */
|
||||||
|
void zmodemDetected();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests that the color of the text used
|
||||||
|
* to represent the tabs associated with this
|
||||||
|
* emulation be changed. This is a Konsole-specific
|
||||||
|
* extension from pre-KDE 4 times.
|
||||||
|
*
|
||||||
|
* TODO: Document how the parameter works.
|
||||||
|
*/
|
||||||
|
void changeTabTextColorRequest(int color);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is emitted when the program running in the shell indicates whether or
|
||||||
|
* not it is interested in mouse events.
|
||||||
|
*
|
||||||
|
* @param usesMouse This will be true if the program wants to be informed about
|
||||||
|
* mouse events or false otherwise.
|
||||||
|
*/
|
||||||
|
void programUsesMouseChanged(bool usesMouse);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted when the contents of the screen image change.
|
||||||
|
* The emulation buffers the updates from successive image changes,
|
||||||
|
* and only emits outputChanged() at sensible intervals when
|
||||||
|
* there is a lot of terminal activity.
|
||||||
|
*
|
||||||
|
* Normally there is no need for objects other than the screen windows
|
||||||
|
* created with createWindow() to listen for this signal.
|
||||||
|
*
|
||||||
|
* ScreenWindow objects created using createWindow() will emit their
|
||||||
|
* own outputChanged() signal in response to this signal.
|
||||||
|
*/
|
||||||
|
void outputChanged();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* should change and VALUE is a string specifying the new value.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @param title Specifies what to change.
|
||||||
|
* <ul>
|
||||||
|
* <li>0 - Set window icon text and session title to @p newTitle</li>
|
||||||
|
* <li>1 - Set window icon text to @p newTitle</li>
|
||||||
|
* <li>2 - Set session title to @p newTitle</li>
|
||||||
|
* <li>11 - Set the session's default background color to @p newTitle,
|
||||||
|
* where @p newTitle can be an HTML-style string ("#RRGGBB") or a named
|
||||||
|
* color (eg 'red', 'blue').
|
||||||
|
* See http://doc.trolltech.com/4.2/qcolor.html#setNamedColor for more
|
||||||
|
* details.
|
||||||
|
* </li>
|
||||||
|
* <li>31 - Supposedly treats @p newTitle as a URL and opens it (NOT IMPLEMENTED)</li>
|
||||||
|
* <li>32 - Sets the icon associated with the session. @p newTitle is the name
|
||||||
|
* of the icon to use, which can be the name of any icon in the current KDE icon
|
||||||
|
* theme (eg: 'konsole', 'kate', 'folder_home')</li>
|
||||||
|
* </ul>
|
||||||
|
* @param newTitle Specifies the new title
|
||||||
|
*/
|
||||||
|
|
||||||
|
void titleChanged(int title,const QString& newTitle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted when the program running in the terminal changes the
|
||||||
|
* screen size.
|
||||||
|
*/
|
||||||
|
void imageSizeChanged(int lineCount , int columnCount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted when the terminal program requests to change various properties
|
||||||
|
* 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.
|
||||||
|
* This string can be parsed using a ProfileCommandParser instance.
|
||||||
|
*
|
||||||
|
* @param text A string expected to contain a series of key and value pairs in
|
||||||
|
* the form: name=value;name2=value2 ...
|
||||||
|
*/
|
||||||
|
void profileChangeCommandReceived(const QString& text);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted when a flow control key combination ( Ctrl+S or Ctrl+Q ) is pressed.
|
||||||
|
* @param suspendKeyPressed True if Ctrl+S was pressed to suspend output or Ctrl+Q to
|
||||||
|
* resume output.
|
||||||
|
*/
|
||||||
|
void flowControlKeyPressed(bool suspendKeyPressed);
|
||||||
|
|
||||||
|
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(int ch);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the active screen. The terminal has two screens, primary and alternate.
|
||||||
|
* The primary screen is used by default. When certain interactive programs such
|
||||||
|
* as Vim are run, they trigger a switch to the alternate screen.
|
||||||
|
*
|
||||||
|
* @param index 0 to switch to the primary screen, or 1 to switch to the alternate screen
|
||||||
|
*/
|
||||||
|
void setScreen(int index);
|
||||||
|
|
||||||
|
enum EmulationCodec
|
||||||
|
{
|
||||||
|
LocaleCodec = 0,
|
||||||
|
Utf8Codec = 1
|
||||||
|
};
|
||||||
|
void setCodec(EmulationCodec codec); // codec number, 0 = locale, 1=utf8
|
||||||
|
|
||||||
|
|
||||||
|
QList<ScreenWindow*> _windows;
|
||||||
|
|
||||||
|
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
|
||||||
|
//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.
|
||||||
|
*/
|
||||||
|
void bufferedUpdate();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
// triggered by timer, causes the emulation to send an updated screen image to each
|
||||||
|
// view
|
||||||
|
void showBulk();
|
||||||
|
|
||||||
|
void usesMouseChanged(bool usesMouse);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _usesMouse;
|
||||||
|
QTimer _bulkTimer1;
|
||||||
|
QTimer _bulkTimer2;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // ifndef EMULATION_H
|
74
konsole-qml-plugin/src/ExtendedDefaultTranslator.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
"keyboard \"Default (XFree 4)\""
|
||||||
|
"key Escape : \"\\E\""
|
||||||
|
"key Tab -Shift : \"\\t\"\n"
|
||||||
|
"key Tab +Shift+Ansi : \"\\E[Z\"\n"
|
||||||
|
"key Tab +Shift-Ansi : \"\\t\"\n"
|
||||||
|
"key Backtab +Ansi : \"\\E[Z\"\n"
|
||||||
|
"key Backtab -Ansi : \"\\t\"\n"
|
||||||
|
"key Return-Shift-NewLine : \"\\r\"\n"
|
||||||
|
"key Return-Shift+NewLine : \"\\r\\n\"\n"
|
||||||
|
"key Return+Shift : \"\\EOM\"\n"
|
||||||
|
"key Backspace : \"\\x7f\"\n"
|
||||||
|
"key Up -Shift-Ansi : \"\\EA\"\n"
|
||||||
|
"key Down -Shift-Ansi : \"\\EB\"\n"
|
||||||
|
"key Right-Shift-Ansi : \"\\EC\"\n"
|
||||||
|
"key Left -Shift-Ansi : \"\\ED\"\n"
|
||||||
|
"key Up -Shift-AnyMod+Ansi+AppCuKeys : \"\\EOA\"\n"
|
||||||
|
"key Down -Shift-AnyMod+Ansi+AppCuKeys : \"\\EOB\"\n"
|
||||||
|
"key Right -Shift-AnyMod+Ansi+AppCuKeys : \"\\EOC\"\n"
|
||||||
|
"key Left -Shift-AnyMod+Ansi+AppCuKeys : \"\\EOD\"\n"
|
||||||
|
"key Up -Shift-AnyMod+Ansi-AppCuKeys : \"\\E[A\"\n"
|
||||||
|
"key Down -Shift-AnyMod+Ansi-AppCuKeys : \"\\E[B\"\n"
|
||||||
|
"key Right -Shift-AnyMod+Ansi-AppCuKeys : \"\\E[C\"\n"
|
||||||
|
"key Left -Shift-AnyMod+Ansi-AppCuKeys : \"\\E[D\"\n"
|
||||||
|
"key Up -Shift+AnyMod+Ansi : \"\\E[1;*A\"\n"
|
||||||
|
"key Down -Shift+AnyMod+Ansi : \"\\E[1;*B\"\n"
|
||||||
|
"key Right -Shift+AnyMod+Ansi : \"\\E[1;*C\"\n"
|
||||||
|
"key Left -Shift+AnyMod+Ansi : \"\\E[1;*D\"\n"
|
||||||
|
"key Enter+NewLine : \"\\r\\n\"\n"
|
||||||
|
"key Enter-NewLine : \"\\r\"\n"
|
||||||
|
"key Home -AnyMod -AppCuKeys : \"\\E[H\" \n"
|
||||||
|
"key End -AnyMod -AppCuKeys : \"\\E[F\" \n"
|
||||||
|
"key Home -AnyMod +AppCuKeys : \"\\EOH\" \n"
|
||||||
|
"key End -AnyMod +AppCuKeys : \"\\EOF\" \n"
|
||||||
|
"key Home +AnyMod : \"\\E[1;*H\"\n"
|
||||||
|
"key End +AnyMod : \"\\E[1;*F\"\n"
|
||||||
|
"key Insert -AnyMod : \"\\E[2~\"\n"
|
||||||
|
"key Delete -AnyMod : \"\\E[3~\"\n"
|
||||||
|
"key Insert +AnyMod : \"\\E[2;*~\"\n"
|
||||||
|
"key Delete +AnyMod : \"\\E[3;*~\"\n"
|
||||||
|
"key Prior -Shift-AnyMod : \"\\E[5~\"\n"
|
||||||
|
"key Next -Shift-AnyMod : \"\\E[6~\"\n"
|
||||||
|
"key Prior -Shift+AnyMod : \"\\E[5;*~\"\n"
|
||||||
|
"key Next -Shift+AnyMod : \"\\E[6;*~\"\n"
|
||||||
|
"key F1 -AnyMod : \"\\EOP\"\n"
|
||||||
|
"key F2 -AnyMod : \"\\EOQ\"\n"
|
||||||
|
"key F3 -AnyMod : \"\\EOR\"\n"
|
||||||
|
"key F4 -AnyMod : \"\\EOS\"\n"
|
||||||
|
"key F5 -AnyMod : \"\\E[15~\"\n"
|
||||||
|
"key F6 -AnyMod : \"\\E[17~\"\n"
|
||||||
|
"key F7 -AnyMod : \"\\E[18~\"\n"
|
||||||
|
"key F8 -AnyMod : \"\\E[19~\"\n"
|
||||||
|
"key F9 -AnyMod : \"\\E[20~\"\n"
|
||||||
|
"key F10 -AnyMod : \"\\E[21~\"\n"
|
||||||
|
"key F11 -AnyMod : \"\\E[23~\"\n"
|
||||||
|
"key F12 -AnyMod : \"\\E[24~\"\n"
|
||||||
|
"key F1 +AnyMod : \"\\EO*P\"\n"
|
||||||
|
"key F2 +AnyMod : \"\\EO*Q\"\n"
|
||||||
|
"key F3 +AnyMod : \"\\EO*R\"\n"
|
||||||
|
"key F4 +AnyMod : \"\\EO*S\"\n"
|
||||||
|
"key F5 +AnyMod : \"\\E[15;*~\"\n"
|
||||||
|
"key F6 +AnyMod : \"\\E[17;*~\"\n"
|
||||||
|
"key F7 +AnyMod : \"\\E[18;*~\"\n"
|
||||||
|
"key F8 +AnyMod : \"\\E[19;*~\"\n"
|
||||||
|
"key F9 +AnyMod : \"\\E[20;*~\"\n"
|
||||||
|
"key F10 +AnyMod : \"\\E[21;*~\"\n"
|
||||||
|
"key F11 +AnyMod : \"\\E[23;*~\"\n"
|
||||||
|
"key F12 +AnyMod : \"\\E[24;*~\"\n"
|
||||||
|
"key Space +Control : \"\\x00\"\n"
|
||||||
|
"key Up +Shift-AppScreen : scrollLineUp\n"
|
||||||
|
"key Prior +Shift-AppScreen : scrollPageUp\n"
|
||||||
|
"key Down +Shift-AppScreen : scrollLineDown\n"
|
||||||
|
"key Next +Shift-AppScreen : scrollPageDown\n"
|
||||||
|
"key ScrollLock : scrollLock\n"
|
||||||
|
"\0"
|
542
konsole-qml-plugin/src/Filter.cpp
Normal file
@ -0,0 +1,542 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU 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 "Filter.h"
|
||||||
|
|
||||||
|
// System
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
// Qt
|
||||||
|
#include <QtWidgets/QAction>
|
||||||
|
#include <QtWidgets/QApplication>
|
||||||
|
#include <QtGui/QClipboard>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QTextStream>
|
||||||
|
#include <QtCore/QSharedData>
|
||||||
|
#include <QtCore/QFile>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
// KDE
|
||||||
|
//#include <KLocale>
|
||||||
|
//#include <KRun>
|
||||||
|
|
||||||
|
// Konsole
|
||||||
|
#include "TerminalCharacterDecoder.h"
|
||||||
|
#include "konsole_wcwidth.h"
|
||||||
|
|
||||||
|
|
||||||
|
FilterChain::~FilterChain()
|
||||||
|
{
|
||||||
|
QMutableListIterator<Filter*> iter(*this);
|
||||||
|
|
||||||
|
while ( iter.hasNext() )
|
||||||
|
{
|
||||||
|
Filter* filter = iter.next();
|
||||||
|
iter.remove();
|
||||||
|
delete filter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FilterChain::addFilter(Filter* filter)
|
||||||
|
{
|
||||||
|
append(filter);
|
||||||
|
}
|
||||||
|
void FilterChain::removeFilter(Filter* filter)
|
||||||
|
{
|
||||||
|
removeAll(filter);
|
||||||
|
}
|
||||||
|
bool FilterChain::containsFilter(Filter* filter)
|
||||||
|
{
|
||||||
|
return contains(filter);
|
||||||
|
}
|
||||||
|
void FilterChain::reset()
|
||||||
|
{
|
||||||
|
QListIterator<Filter*> iter(*this);
|
||||||
|
while (iter.hasNext())
|
||||||
|
iter.next()->reset();
|
||||||
|
}
|
||||||
|
void FilterChain::setBuffer(const QString* buffer , const QList<int>* linePositions)
|
||||||
|
{
|
||||||
|
QListIterator<Filter*> iter(*this);
|
||||||
|
while (iter.hasNext())
|
||||||
|
iter.next()->setBuffer(buffer,linePositions);
|
||||||
|
}
|
||||||
|
void FilterChain::process()
|
||||||
|
{
|
||||||
|
QListIterator<Filter*> iter(*this);
|
||||||
|
while (iter.hasNext())
|
||||||
|
iter.next()->process();
|
||||||
|
}
|
||||||
|
void FilterChain::clear()
|
||||||
|
{
|
||||||
|
QList<Filter*>::clear();
|
||||||
|
}
|
||||||
|
Filter::HotSpot* FilterChain::hotSpotAt(int line , int column) const
|
||||||
|
{
|
||||||
|
QListIterator<Filter*> iter(*this);
|
||||||
|
while (iter.hasNext())
|
||||||
|
{
|
||||||
|
Filter* filter = iter.next();
|
||||||
|
Filter::HotSpot* spot = filter->hotSpotAt(line,column);
|
||||||
|
if ( spot != 0 )
|
||||||
|
{
|
||||||
|
return spot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<Filter::HotSpot*> FilterChain::hotSpots() const
|
||||||
|
{
|
||||||
|
QList<Filter::HotSpot*> list;
|
||||||
|
QListIterator<Filter*> iter(*this);
|
||||||
|
while (iter.hasNext())
|
||||||
|
{
|
||||||
|
Filter* filter = iter.next();
|
||||||
|
list << filter->hotSpots();
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
//QList<Filter::HotSpot*> FilterChain::hotSpotsAtLine(int line) const;
|
||||||
|
|
||||||
|
TerminalImageFilterChain::TerminalImageFilterChain()
|
||||||
|
: _buffer(0)
|
||||||
|
, _linePositions(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TerminalImageFilterChain::~TerminalImageFilterChain()
|
||||||
|
{
|
||||||
|
delete _buffer;
|
||||||
|
delete _linePositions;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalImageFilterChain::setImage(const Character* const image , int lines , int columns, const QVector<LineProperty>& lineProperties)
|
||||||
|
{
|
||||||
|
if (empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// reset all filters and hotspots
|
||||||
|
reset();
|
||||||
|
|
||||||
|
PlainTextDecoder decoder;
|
||||||
|
decoder.setTrailingWhitespace(false);
|
||||||
|
|
||||||
|
// setup new shared buffers for the filters to process on
|
||||||
|
QString* newBuffer = new QString();
|
||||||
|
QList<int>* newLinePositions = new QList<int>();
|
||||||
|
setBuffer( newBuffer , newLinePositions );
|
||||||
|
|
||||||
|
// free the old buffers
|
||||||
|
delete _buffer;
|
||||||
|
delete _linePositions;
|
||||||
|
|
||||||
|
_buffer = newBuffer;
|
||||||
|
_linePositions = newLinePositions;
|
||||||
|
|
||||||
|
QTextStream lineStream(_buffer);
|
||||||
|
decoder.begin(&lineStream);
|
||||||
|
|
||||||
|
for (int i=0 ; i < lines ; i++)
|
||||||
|
{
|
||||||
|
_linePositions->append(_buffer->length());
|
||||||
|
decoder.decodeLine(image + i*columns,columns,LINE_DEFAULT);
|
||||||
|
|
||||||
|
// pretend that each line ends with a newline character.
|
||||||
|
// this prevents a link that occurs at the end of one line
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
// 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');
|
||||||
|
}
|
||||||
|
decoder.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::Filter() :
|
||||||
|
_linePositions(0),
|
||||||
|
_buffer(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::~Filter()
|
||||||
|
{
|
||||||
|
QListIterator<HotSpot*> iter(_hotspotList);
|
||||||
|
while (iter.hasNext())
|
||||||
|
{
|
||||||
|
delete iter.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Filter::reset()
|
||||||
|
{
|
||||||
|
_hotspots.clear();
|
||||||
|
_hotspotList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Filter::setBuffer(const QString* buffer , const QList<int>* linePositions)
|
||||||
|
{
|
||||||
|
_buffer = buffer;
|
||||||
|
_linePositions = linePositions;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Filter::getLineColumn(int position , int& startLine , int& startColumn)
|
||||||
|
{
|
||||||
|
Q_ASSERT( _linePositions );
|
||||||
|
Q_ASSERT( _buffer );
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0 ; i < _linePositions->count() ; i++)
|
||||||
|
{
|
||||||
|
int nextLine = 0;
|
||||||
|
|
||||||
|
if ( i == _linePositions->count()-1 )
|
||||||
|
nextLine = _buffer->length() + 1;
|
||||||
|
else
|
||||||
|
nextLine = _linePositions->value(i+1);
|
||||||
|
|
||||||
|
if ( _linePositions->value(i) <= position && position < nextLine )
|
||||||
|
{
|
||||||
|
startLine = i;
|
||||||
|
startColumn = string_width(buffer()->mid(_linePositions->value(i),position - _linePositions->value(i)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*void Filter::addLine(const QString& text)
|
||||||
|
{
|
||||||
|
_linePositions << _buffer.length();
|
||||||
|
_buffer.append(text);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
const QString* Filter::buffer()
|
||||||
|
{
|
||||||
|
return _buffer;
|
||||||
|
}
|
||||||
|
Filter::HotSpot::~HotSpot()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void Filter::addHotSpot(HotSpot* spot)
|
||||||
|
{
|
||||||
|
_hotspotList << spot;
|
||||||
|
|
||||||
|
for (int line = spot->startLine() ; line <= spot->endLine() ; line++)
|
||||||
|
{
|
||||||
|
_hotspots.insert(line,spot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QList<Filter::HotSpot*> Filter::hotSpots() const
|
||||||
|
{
|
||||||
|
return _hotspotList;
|
||||||
|
}
|
||||||
|
QList<Filter::HotSpot*> Filter::hotSpotsAtLine(int line) const
|
||||||
|
{
|
||||||
|
return _hotspots.values(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::HotSpot* Filter::hotSpotAt(int line , int column) const
|
||||||
|
{
|
||||||
|
QListIterator<HotSpot*> spotIter(_hotspots.values(line));
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::HotSpot::HotSpot(int startLine , int startColumn , int endLine , int endColumn)
|
||||||
|
: _startLine(startLine)
|
||||||
|
, _startColumn(startColumn)
|
||||||
|
, _endLine(endLine)
|
||||||
|
, _endColumn(endColumn)
|
||||||
|
, _type(NotSpecified)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
QString Filter::HotSpot::tooltip() const
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
QList<QAction*> Filter::HotSpot::actions()
|
||||||
|
{
|
||||||
|
return QList<QAction*>();
|
||||||
|
}
|
||||||
|
int Filter::HotSpot::startLine() const
|
||||||
|
{
|
||||||
|
return _startLine;
|
||||||
|
}
|
||||||
|
int Filter::HotSpot::endLine() const
|
||||||
|
{
|
||||||
|
return _endLine;
|
||||||
|
}
|
||||||
|
int Filter::HotSpot::startColumn() const
|
||||||
|
{
|
||||||
|
return _startColumn;
|
||||||
|
}
|
||||||
|
int Filter::HotSpot::endColumn() const
|
||||||
|
{
|
||||||
|
return _endColumn;
|
||||||
|
}
|
||||||
|
Filter::HotSpot::Type Filter::HotSpot::type() const
|
||||||
|
{
|
||||||
|
return _type;
|
||||||
|
}
|
||||||
|
void Filter::HotSpot::setType(Type type)
|
||||||
|
{
|
||||||
|
_type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegExpFilter::RegExpFilter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RegExpFilter::HotSpot::HotSpot(int startLine,int startColumn,int endLine,int endColumn)
|
||||||
|
: Filter::HotSpot(startLine,startColumn,endLine,endColumn)
|
||||||
|
{
|
||||||
|
setType(Marker);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegExpFilter::HotSpot::activate(QObject*)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegExpFilter::HotSpot::setCapturedTexts(const QStringList& texts)
|
||||||
|
{
|
||||||
|
_capturedTexts = texts;
|
||||||
|
}
|
||||||
|
QStringList RegExpFilter::HotSpot::capturedTexts() const
|
||||||
|
{
|
||||||
|
return _capturedTexts;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegExpFilter::setRegExp(const QRegExp& regExp)
|
||||||
|
{
|
||||||
|
_searchText = regExp;
|
||||||
|
}
|
||||||
|
QRegExp RegExpFilter::regExp() const
|
||||||
|
{
|
||||||
|
return _searchText;
|
||||||
|
}
|
||||||
|
/*void RegExpFilter::reset(int)
|
||||||
|
{
|
||||||
|
_buffer = QString();
|
||||||
|
}*/
|
||||||
|
void RegExpFilter::process()
|
||||||
|
{
|
||||||
|
int pos = 0;
|
||||||
|
const QString* text = buffer();
|
||||||
|
|
||||||
|
Q_ASSERT( text );
|
||||||
|
|
||||||
|
// ignore any regular expressions which match an empty string.
|
||||||
|
// otherwise the while loop below will run indefinitely
|
||||||
|
static const QString emptyString("");
|
||||||
|
if ( _searchText.exactMatch(emptyString) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
while(pos >= 0)
|
||||||
|
{
|
||||||
|
pos = _searchText.indexIn(*text,pos);
|
||||||
|
|
||||||
|
if ( pos >= 0 )
|
||||||
|
{
|
||||||
|
int startLine = 0;
|
||||||
|
int endLine = 0;
|
||||||
|
int startColumn = 0;
|
||||||
|
int endColumn = 0;
|
||||||
|
|
||||||
|
getLineColumn(pos,startLine,startColumn);
|
||||||
|
getLineColumn(pos + _searchText.matchedLength(),endLine,endColumn);
|
||||||
|
|
||||||
|
RegExpFilter::HotSpot* spot = newHotSpot(startLine,startColumn,
|
||||||
|
endLine,endColumn);
|
||||||
|
spot->setCapturedTexts(_searchText.capturedTexts());
|
||||||
|
|
||||||
|
addHotSpot( spot );
|
||||||
|
pos += _searchText.matchedLength();
|
||||||
|
|
||||||
|
// if matchedLength == 0, the program will get stuck in an infinite loop
|
||||||
|
if ( _searchText.matchedLength() == 0 )
|
||||||
|
pos = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RegExpFilter::HotSpot* RegExpFilter::newHotSpot(int startLine,int startColumn,
|
||||||
|
int endLine,int endColumn)
|
||||||
|
{
|
||||||
|
return new RegExpFilter::HotSpot(startLine,startColumn,
|
||||||
|
endLine,endColumn);
|
||||||
|
}
|
||||||
|
RegExpFilter::HotSpot* UrlFilter::newHotSpot(int startLine,int startColumn,int endLine,
|
||||||
|
int endColumn)
|
||||||
|
{
|
||||||
|
return new UrlFilter::HotSpot(startLine,startColumn,
|
||||||
|
endLine,endColumn);
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
|
||||||
|
if ( FullUrlRegExp.exactMatch(url) )
|
||||||
|
return StandardUrl;
|
||||||
|
else if ( EmailAddressRegExp.exactMatch(url) )
|
||||||
|
return Email;
|
||||||
|
else
|
||||||
|
return Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UrlFilter::HotSpot::activate(QObject* object)
|
||||||
|
{
|
||||||
|
QString url = capturedTexts().first();
|
||||||
|
|
||||||
|
const UrlType kind = urlType();
|
||||||
|
|
||||||
|
const QString& actionName = object ? object->objectName() : QString();
|
||||||
|
|
||||||
|
if ( actionName == "copy-action" )
|
||||||
|
{
|
||||||
|
QApplication::clipboard()->setText(url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !object || actionName == "open-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("://"))
|
||||||
|
{
|
||||||
|
url.prepend("http://");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( kind == Email )
|
||||||
|
{
|
||||||
|
url.prepend("mailto:");
|
||||||
|
}
|
||||||
|
|
||||||
|
QDesktopServices::openUrl(QUrl(url));
|
||||||
|
//new KRun(url,QApplication::activeWindow());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: Altering these regular expressions can have a major effect on the performance of the filters
|
||||||
|
// 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:
|
||||||
|
// protocolname:// or www. followed by anything other than whitespaces, <, >, ' or ", and ends before whitespaces, <, >, ', ", ], !, comma and dot
|
||||||
|
const QRegExp UrlFilter::FullUrlRegExp("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]]");
|
||||||
|
// email address:
|
||||||
|
// [word chars, dots or dashes]@[word chars, dots or dashes].[word chars]
|
||||||
|
const QRegExp UrlFilter::EmailAddressRegExp("\\b(\\w|\\.|-)+@(\\w|\\.|-)+\\.\\w+\\b");
|
||||||
|
|
||||||
|
// matches full url or email address
|
||||||
|
const QRegExp UrlFilter::CompleteUrlRegExp('('+FullUrlRegExp.pattern()+'|'+
|
||||||
|
EmailAddressRegExp.pattern()+')');
|
||||||
|
|
||||||
|
UrlFilter::UrlFilter()
|
||||||
|
{
|
||||||
|
setRegExp( CompleteUrlRegExp );
|
||||||
|
}
|
||||||
|
UrlFilter::HotSpot::~HotSpot()
|
||||||
|
{
|
||||||
|
delete _urlObject;
|
||||||
|
}
|
||||||
|
void FilterObject::activated()
|
||||||
|
{
|
||||||
|
_filter->activate(sender());
|
||||||
|
}
|
||||||
|
QList<QAction*> UrlFilter::HotSpot::actions()
|
||||||
|
{
|
||||||
|
QList<QAction*> list;
|
||||||
|
|
||||||
|
const UrlType kind = urlType();
|
||||||
|
|
||||||
|
QAction* openAction = new QAction(_urlObject);
|
||||||
|
QAction* copyAction = new QAction(_urlObject);;
|
||||||
|
|
||||||
|
Q_ASSERT( kind == StandardUrl || kind == Email );
|
||||||
|
|
||||||
|
if ( kind == StandardUrl )
|
||||||
|
{
|
||||||
|
openAction->setText(QObject::tr("Open Link"));
|
||||||
|
copyAction->setText(QObject::tr("Copy Link Address"));
|
||||||
|
}
|
||||||
|
else if ( kind == Email )
|
||||||
|
{
|
||||||
|
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( QLatin1String("open-action" ));
|
||||||
|
copyAction->setObjectName( QLatin1String("copy-action" ));
|
||||||
|
|
||||||
|
QObject::connect( openAction , SIGNAL(triggered()) , _urlObject , SLOT(activated()) );
|
||||||
|
QObject::connect( copyAction , SIGNAL(triggered()) , _urlObject , SLOT(activated()) );
|
||||||
|
|
||||||
|
list << openAction;
|
||||||
|
list << copyAction;
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
//#include "Filter.moc"
|
380
konsole-qml-plugin/src/Filter.h
Normal file
@ -0,0 +1,380 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU 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 FILTER_H
|
||||||
|
#define FILTER_H
|
||||||
|
|
||||||
|
// Qt
|
||||||
|
#include <QtWidgets/QAction>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QHash>
|
||||||
|
#include <QtCore/QRegExp>
|
||||||
|
|
||||||
|
// Local
|
||||||
|
#include "Character.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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'.
|
||||||
|
*
|
||||||
|
* Each hotspot has a type identifier associated with it ( such as a link or a highlighted section ),
|
||||||
|
* and an action. When the user performs some activity such as a mouse-click in a hotspot area ( the exact
|
||||||
|
* action will depend on what is displaying the block of text which the filter is processing ), the hotspot's
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Different subclasses of filter will return different types of hotspot.
|
||||||
|
* Subclasses must reimplement the process() method to examine a block of text and identify sections of interest.
|
||||||
|
* 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
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Represents an area of text which matched the pattern a particular filter has been looking for.
|
||||||
|
*
|
||||||
|
* Each hotspot has a type identifier associated with it ( such as a link or a highlighted section ),
|
||||||
|
* and an action. When the user performs some activity such as a mouse-click in a hotspot area ( the exact
|
||||||
|
* action will depend on what is displaying the block of text which the filter is processing ), the hotspot's
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
HotSpot(int startLine , int startColumn , int endLine , int endColumn);
|
||||||
|
virtual ~HotSpot();
|
||||||
|
|
||||||
|
enum Type
|
||||||
|
{
|
||||||
|
// the type of the hotspot is not specified
|
||||||
|
NotSpecified,
|
||||||
|
// this hotspot represents a clickable link
|
||||||
|
Link,
|
||||||
|
// this hotspot represents a marker
|
||||||
|
Marker
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Returns the line when the hotspot area starts */
|
||||||
|
int startLine() const;
|
||||||
|
/** Returns the line where the hotspot area ends */
|
||||||
|
int endLine() const;
|
||||||
|
/** Returns the column on startLine() where the hotspot area starts */
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
|
virtual void activate(QObject* object = 0) = 0;
|
||||||
|
/**
|
||||||
|
* Returns a list of actions associated with the hotspot which can be used in a
|
||||||
|
* menu or toolbar
|
||||||
|
*/
|
||||||
|
virtual QList<QAction*> actions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the text of a tooltip to be shown when the mouse moves over the hotspot, or
|
||||||
|
* an empty string if there is no tooltip associated with this hotspot.
|
||||||
|
*
|
||||||
|
* The default implementation returns an empty string.
|
||||||
|
*/
|
||||||
|
virtual QString tooltip() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Sets the type of a hotspot. This should only be set once */
|
||||||
|
void setType(Type type);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _startLine;
|
||||||
|
int _startColumn;
|
||||||
|
int _endLine;
|
||||||
|
int _endColumn;
|
||||||
|
Type _type;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Constructs a new filter. */
|
||||||
|
Filter();
|
||||||
|
virtual ~Filter();
|
||||||
|
|
||||||
|
/** 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.
|
||||||
|
*/
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
/** Adds a new line of text to the filter and increments the line count */
|
||||||
|
//void addLine(const QString& string);
|
||||||
|
|
||||||
|
/** Returns the hotspot which covers the given @p line and @p column, or 0 if no hotspot covers that area */
|
||||||
|
HotSpot* hotSpotAt(int line , int column) const;
|
||||||
|
|
||||||
|
/** Returns the list of hotspots identified by the filter */
|
||||||
|
QList<HotSpot*> hotSpots() const;
|
||||||
|
|
||||||
|
/** Returns the list of hotspots identified by the filter which occur on a given line */
|
||||||
|
QList<HotSpot*> hotSpotsAtLine(int line) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Document me
|
||||||
|
*/
|
||||||
|
void setBuffer(const QString* buffer , const QList<int>* linePositions);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Adds a new hotspot to the list */
|
||||||
|
void addHotSpot(HotSpot*);
|
||||||
|
/** Returns the internal buffer */
|
||||||
|
const QString* buffer();
|
||||||
|
/** Converts a character position within buffer() to a line and column */
|
||||||
|
void getLineColumn(int position , int& startLine , int& startColumn);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMultiHash<int,HotSpot*> _hotspots;
|
||||||
|
QList<HotSpot*> _hotspotList;
|
||||||
|
|
||||||
|
const QList<int>* _linePositions;
|
||||||
|
const QString* _buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A filter which searches for sections of text matching a regular expression and creates a new RegExpFilter::HotSpot
|
||||||
|
* instance for them.
|
||||||
|
*
|
||||||
|
* Subclasses can reimplement newHotSpot() to return custom hotspot types when matches for the regular expression
|
||||||
|
* are found.
|
||||||
|
*/
|
||||||
|
class RegExpFilter : public Filter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Type of hotspot created by RegExpFilter. The capturedTexts() method can be used to find the text
|
||||||
|
* matched by the filter's regular expression.
|
||||||
|
*/
|
||||||
|
class HotSpot : public Filter::HotSpot
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HotSpot(int startLine, int startColumn, int endLine , int endColumn);
|
||||||
|
virtual void activate(QObject* object = 0);
|
||||||
|
|
||||||
|
/** Sets the captured texts associated with this hotspot */
|
||||||
|
void setCapturedTexts(const QStringList& texts);
|
||||||
|
/** Returns the texts found by the filter when matching the filter's regular expression */
|
||||||
|
QStringList capturedTexts() const;
|
||||||
|
private:
|
||||||
|
QStringList _capturedTexts;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Constructs a new regular expression filter */
|
||||||
|
RegExpFilter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
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()
|
||||||
|
*
|
||||||
|
* If regexp matches the empty string, then process() will return immediately
|
||||||
|
* without finding results.
|
||||||
|
*/
|
||||||
|
virtual void process();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* Called when a match for the regular expression is encountered. Subclasses should reimplement this
|
||||||
|
* to return custom hotspot types
|
||||||
|
*/
|
||||||
|
virtual RegExpFilter::HotSpot* newHotSpot(int startLine,int startColumn,
|
||||||
|
int endLine,int endColumn);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QRegExp _searchText;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FilterObject;
|
||||||
|
|
||||||
|
/** A filter which matches URLs in blocks of text */
|
||||||
|
class UrlFilter : public RegExpFilter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Hotspot type created by UrlFilter instances. The activate() method opens a web browser
|
||||||
|
* at the given URL when called.
|
||||||
|
*/
|
||||||
|
class HotSpot : public RegExpFilter::HotSpot
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HotSpot(int startLine,int startColumn,int endLine,int endColumn);
|
||||||
|
virtual ~HotSpot();
|
||||||
|
|
||||||
|
virtual QList<QAction*> actions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a web browser at the current URL. The url itself can be determined using
|
||||||
|
* the capturedTexts() method.
|
||||||
|
*/
|
||||||
|
virtual void activate(QObject* object = 0);
|
||||||
|
|
||||||
|
virtual QString tooltip() const;
|
||||||
|
private:
|
||||||
|
enum UrlType
|
||||||
|
{
|
||||||
|
StandardUrl,
|
||||||
|
Email,
|
||||||
|
Unknown
|
||||||
|
};
|
||||||
|
UrlType urlType() const;
|
||||||
|
|
||||||
|
FilterObject* _urlObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
UrlFilter();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual RegExpFilter::HotSpot* newHotSpot(int,int,int,int);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
static const QRegExp FullUrlRegExp;
|
||||||
|
static const QRegExp EmailAddressRegExp;
|
||||||
|
|
||||||
|
// combined OR of FullUrlRegExp and EmailAddressRegExp
|
||||||
|
static const QRegExp CompleteUrlRegExp;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FilterObject : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
FilterObject(Filter::HotSpot* filter) : _filter(filter) {}
|
||||||
|
private slots:
|
||||||
|
void activated();
|
||||||
|
private:
|
||||||
|
Filter::HotSpot* _filter;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* After processing a block of text, the reset() method can be used to set the filter chain's
|
||||||
|
* internal cursor back to the first line.
|
||||||
|
*
|
||||||
|
* The hotSpotAt() method will return the first hotspot which covers a given position.
|
||||||
|
*
|
||||||
|
* The hotSpots() and hotSpotsAtLine() method return all of the hotspots in the text and on
|
||||||
|
* a given line respectively.
|
||||||
|
*/
|
||||||
|
class FilterChain : protected QList<Filter*>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~FilterChain();
|
||||||
|
|
||||||
|
/** Adds a new filter to the chain. The chain will delete this filter when it is destroyed */
|
||||||
|
void addFilter(Filter* filter);
|
||||||
|
/** Removes a filter from the chain. The chain will no longer delete the filter when destroyed */
|
||||||
|
void removeFilter(Filter* filter);
|
||||||
|
/** Returns true if the chain contains @p filter */
|
||||||
|
bool containsFilter(Filter* filter);
|
||||||
|
/** Removes all filters from the chain */
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
/** Resets each filter in the chain */
|
||||||
|
void reset();
|
||||||
|
/**
|
||||||
|
* Processes each filter in the chain
|
||||||
|
*/
|
||||||
|
void process();
|
||||||
|
|
||||||
|
/** Sets the buffer for each filter in the chain to process. */
|
||||||
|
void setBuffer(const QString* buffer , const QList<int>* linePositions);
|
||||||
|
|
||||||
|
/** 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;
|
||||||
|
/** Returns a list of all the hotspots in all the chain's filters */
|
||||||
|
QList<Filter::HotSpot*> hotSpots() const;
|
||||||
|
/** Returns a list of all hotspots at the given line in all the chain's filters */
|
||||||
|
QList<Filter::HotSpot> hotSpotsAtLine(int line) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/** A filter chain which processes character images from terminal displays */
|
||||||
|
class TerminalImageFilterChain : public FilterChain
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TerminalImageFilterChain();
|
||||||
|
virtual ~TerminalImageFilterChain();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current terminal image to @p image.
|
||||||
|
*
|
||||||
|
* @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<LineProperty>& lineProperties);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString* _buffer;
|
||||||
|
QList<int>* _linePositions;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //FILTER_H
|
986
konsole-qml-plugin/src/History.cpp
Normal file
@ -0,0 +1,986 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Konsole, an X terminal.
|
||||||
|
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||||
|
|
||||||
|
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 "History.h"
|
||||||
|
|
||||||
|
// System
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
// KDE
|
||||||
|
//#include <kde_file.h>
|
||||||
|
//#include <kdebug.h>
|
||||||
|
|
||||||
|
// Reasonable line size
|
||||||
|
#define LINE_SIZE 1024
|
||||||
|
#define KDE_lseek lseek
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
An arbitrary long scroll.
|
||||||
|
|
||||||
|
One can modify the scroll only by adding either cells
|
||||||
|
or newlines, but access it randomly.
|
||||||
|
|
||||||
|
The model is that of an arbitrary wide typewriter scroll
|
||||||
|
in that the scroll is a serie of lines and each line is
|
||||||
|
a serie of cells with no overwriting permitted.
|
||||||
|
|
||||||
|
The implementation provides arbitrary length and numbers
|
||||||
|
of cells and line/column indexed read access to the scroll
|
||||||
|
at constant costs.
|
||||||
|
|
||||||
|
KDE4: Can we use QTemporaryFile here, instead of KTempFile?
|
||||||
|
|
||||||
|
FIXME: some complain about the history buffer comsuming 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.
|
||||||
|
|
||||||
|
I put in a workaround that should handle it problem
|
||||||
|
now gracefully. I'm not satisfied with the solution.
|
||||||
|
|
||||||
|
FIXME: Terminating the history is not properly indicated
|
||||||
|
in the menu. We should throw a signal.
|
||||||
|
|
||||||
|
FIXME: There is noticeable decrease in speed, also. Perhaps,
|
||||||
|
there whole feature needs to be revisited therefore.
|
||||||
|
Disadvantage of a more elaborated, say block-oriented
|
||||||
|
scheme with wrap around would be it's complexity.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//FIXME: tempory replacement for tmpfile
|
||||||
|
// this is here one for debugging purpose.
|
||||||
|
|
||||||
|
//#define tmpfile xTmpFile
|
||||||
|
|
||||||
|
// History File ///////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
A Row(X) data type which allows adding elements to the end.
|
||||||
|
*/
|
||||||
|
|
||||||
|
HistoryFile::HistoryFile()
|
||||||
|
: ion(-1),
|
||||||
|
length(0),
|
||||||
|
fileMap(0)
|
||||||
|
{
|
||||||
|
if (tmpFile.open())
|
||||||
|
{
|
||||||
|
tmpFile.setAutoRemove(true);
|
||||||
|
ion = tmpFile.handle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryFile::~HistoryFile()
|
||||||
|
{
|
||||||
|
if (fileMap)
|
||||||
|
unmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Mapping the entire file in will cause problems if the history file becomes exceedingly large,
|
||||||
|
//(ie. larger than available memory). HistoryFile::map() should only map in sections of the file at a time,
|
||||||
|
//to avoid this.
|
||||||
|
void HistoryFile::map()
|
||||||
|
{
|
||||||
|
assert( fileMap == 0 );
|
||||||
|
|
||||||
|
fileMap = (char*)mmap( 0 , 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() << __FILE__ << __LINE__ << ": mmap'ing history failed. errno = " << errno;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryFile::unmap()
|
||||||
|
{
|
||||||
|
int result = munmap( fileMap , length );
|
||||||
|
assert( result == 0 ); Q_UNUSED( result );
|
||||||
|
|
||||||
|
fileMap = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryFile::isMapped()
|
||||||
|
{
|
||||||
|
return (fileMap != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryFile::add(const unsigned char* bytes, int len)
|
||||||
|
{
|
||||||
|
if ( fileMap )
|
||||||
|
unmap();
|
||||||
|
|
||||||
|
readWriteBalance++;
|
||||||
|
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
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()
|
||||||
|
//calls (decided by using MAP_THRESHOLD) then mmap the log
|
||||||
|
//file to improve performance.
|
||||||
|
readWriteBalance--;
|
||||||
|
if ( !fileMap && readWriteBalance < MAP_THRESHOLD )
|
||||||
|
map();
|
||||||
|
|
||||||
|
if ( fileMap )
|
||||||
|
{
|
||||||
|
for (int i=0;i<len;i++)
|
||||||
|
bytes[i]=fileMap[loc+i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryFile::len()
|
||||||
|
{
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// History Scroll abstract base class //////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
HistoryScroll::HistoryScroll(HistoryType* t)
|
||||||
|
: m_histType(t)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryScroll::~HistoryScroll()
|
||||||
|
{
|
||||||
|
delete m_histType;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryScroll::hasScroll()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
buffer.
|
||||||
|
|
||||||
|
Note that index[0] addresses the second line
|
||||||
|
(line #1), while the first line (line #0) starts
|
||||||
|
at 0 in cells.
|
||||||
|
*/
|
||||||
|
|
||||||
|
HistoryScrollFile::HistoryScrollFile(const QString &logFileName)
|
||||||
|
: HistoryScroll(new HistoryTypeFile(logFileName)),
|
||||||
|
m_logFileName(logFileName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryScrollFile::~HistoryScrollFile()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryScrollFile::getLines()
|
||||||
|
{
|
||||||
|
return index.len() / sizeof(int);
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryScrollFile::getLineLen(int lineno)
|
||||||
|
{
|
||||||
|
return (startOfLine(lineno+1) - startOfLine(lineno)) / sizeof(Character);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryScrollFile::isWrappedLine(int lineno)
|
||||||
|
{
|
||||||
|
if (lineno>=0 && lineno <= getLines()) {
|
||||||
|
unsigned char flag;
|
||||||
|
lineflags.get((unsigned char*)&flag,sizeof(unsigned char),(lineno)*sizeof(unsigned char));
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryScrollFile::startOfLine(int lineno)
|
||||||
|
{
|
||||||
|
if (lineno <= 0) return 0;
|
||||||
|
if (lineno <= getLines())
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!index.isMapped())
|
||||||
|
index.map();
|
||||||
|
|
||||||
|
int res;
|
||||||
|
index.get((unsigned char*)&res,sizeof(int),(lineno-1)*sizeof(int));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
return cells.len();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollFile::getCells(int lineno, int colno, int count, Character res[])
|
||||||
|
{
|
||||||
|
cells.get((unsigned char*)res,count*sizeof(Character),startOfLine(lineno)+colno*sizeof(Character));
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollFile::addCells(const Character text[], int count)
|
||||||
|
{
|
||||||
|
cells.add((unsigned char*)text,count*sizeof(Character));
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollFile::addLine(bool previousWrapped)
|
||||||
|
{
|
||||||
|
if (index.isMapped())
|
||||||
|
index.unmap();
|
||||||
|
|
||||||
|
int locn = cells.len();
|
||||||
|
index.add((unsigned char*)&locn,sizeof(int));
|
||||||
|
unsigned char flags = previousWrapped ? 0x01 : 0x00;
|
||||||
|
lineflags.add((unsigned char*)&flags,sizeof(unsigned char));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// History Scroll Buffer //////////////////////////////////////
|
||||||
|
HistoryScrollBuffer::HistoryScrollBuffer(unsigned int maxLineCount)
|
||||||
|
: HistoryScroll(new HistoryTypeBuffer(maxLineCount))
|
||||||
|
,_historyBuffer()
|
||||||
|
,_maxLineCount(0)
|
||||||
|
,_usedLines(0)
|
||||||
|
,_head(0)
|
||||||
|
{
|
||||||
|
setMaxNbLines(maxLineCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryScrollBuffer::~HistoryScrollBuffer()
|
||||||
|
{
|
||||||
|
delete[] _historyBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollBuffer::addCellsVector(const QVector<Character>& cells)
|
||||||
|
{
|
||||||
|
_head++;
|
||||||
|
if ( _usedLines < _maxLineCount )
|
||||||
|
_usedLines++;
|
||||||
|
|
||||||
|
if ( _head >= _maxLineCount )
|
||||||
|
{
|
||||||
|
_head = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_historyBuffer[bufferIndex(_usedLines-1)] = cells;
|
||||||
|
_wrappedLine[bufferIndex(_usedLines-1)] = false;
|
||||||
|
}
|
||||||
|
void HistoryScrollBuffer::addCells(const Character a[], int count)
|
||||||
|
{
|
||||||
|
HistoryLine newLine(count);
|
||||||
|
qCopy(a,a+count,newLine.begin());
|
||||||
|
|
||||||
|
addCellsVector(newLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollBuffer::addLine(bool previousWrapped)
|
||||||
|
{
|
||||||
|
_wrappedLine[bufferIndex(_usedLines-1)] = previousWrapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryScrollBuffer::getLines()
|
||||||
|
{
|
||||||
|
return _usedLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryScrollBuffer::getLineLen(int lineNumber)
|
||||||
|
{
|
||||||
|
Q_ASSERT( lineNumber >= 0 && lineNumber < _maxLineCount );
|
||||||
|
|
||||||
|
if ( lineNumber < _usedLines )
|
||||||
|
{
|
||||||
|
return _historyBuffer[bufferIndex(lineNumber)].size();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryScrollBuffer::isWrappedLine(int lineNumber)
|
||||||
|
{
|
||||||
|
Q_ASSERT( lineNumber >= 0 && lineNumber < _maxLineCount );
|
||||||
|
|
||||||
|
if (lineNumber < _usedLines)
|
||||||
|
{
|
||||||
|
//kDebug() << "Line" << lineNumber << "wrapped is" << _wrappedLine[bufferIndex(lineNumber)];
|
||||||
|
return _wrappedLine[bufferIndex(lineNumber)];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollBuffer::getCells(int lineNumber, int startColumn, int count, Character buffer[])
|
||||||
|
{
|
||||||
|
if ( count == 0 ) return;
|
||||||
|
|
||||||
|
Q_ASSERT( lineNumber < _maxLineCount );
|
||||||
|
|
||||||
|
if (lineNumber >= _usedLines)
|
||||||
|
{
|
||||||
|
memset(buffer, 0, count * sizeof(Character));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HistoryLine& line = _historyBuffer[bufferIndex(lineNumber)];
|
||||||
|
|
||||||
|
//kDebug() << "startCol " << startColumn;
|
||||||
|
//kDebug() << "line.size() " << line.size();
|
||||||
|
//kDebug() << "count " << count;
|
||||||
|
|
||||||
|
Q_ASSERT( startColumn <= line.size() - count );
|
||||||
|
|
||||||
|
memcpy(buffer, line.constData() + startColumn , count * sizeof(Character));
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollBuffer::setMaxNbLines(unsigned int lineCount)
|
||||||
|
{
|
||||||
|
HistoryLine* oldBuffer = _historyBuffer;
|
||||||
|
HistoryLine* newBuffer = new HistoryLine[lineCount];
|
||||||
|
|
||||||
|
for ( int i = 0 ; i < qMin(_usedLines,(int)lineCount) ; i++ )
|
||||||
|
{
|
||||||
|
newBuffer[i] = oldBuffer[bufferIndex(i)];
|
||||||
|
}
|
||||||
|
|
||||||
|
_usedLines = qMin(_usedLines,(int)lineCount);
|
||||||
|
_maxLineCount = lineCount;
|
||||||
|
_head = ( _usedLines == _maxLineCount ) ? 0 : _usedLines-1;
|
||||||
|
|
||||||
|
_historyBuffer = newBuffer;
|
||||||
|
delete[] oldBuffer;
|
||||||
|
|
||||||
|
_wrappedLine.resize(lineCount);
|
||||||
|
dynamic_cast<HistoryTypeBuffer*>(m_histType)->m_nbLines = lineCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryScrollBuffer::bufferIndex(int lineNumber)
|
||||||
|
{
|
||||||
|
Q_ASSERT( lineNumber >= 0 );
|
||||||
|
Q_ASSERT( lineNumber < _maxLineCount );
|
||||||
|
Q_ASSERT( (_usedLines == _maxLineCount) || lineNumber <= _head );
|
||||||
|
|
||||||
|
if ( _usedLines == _maxLineCount )
|
||||||
|
{
|
||||||
|
return (_head+lineNumber+1) % _maxLineCount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return lineNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// History Scroll None //////////////////////////////////////
|
||||||
|
|
||||||
|
HistoryScrollNone::HistoryScrollNone()
|
||||||
|
: HistoryScroll(new HistoryTypeNone())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryScrollNone::~HistoryScrollNone()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryScrollNone::hasScroll()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryScrollNone::getLines()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryScrollNone::getLineLen(int)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryScrollNone::isWrappedLine(int /*lineno*/)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollNone::getCells(int, int, int, Character [])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollNone::addCells(const Character [], int)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollNone::addLine(bool)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// History Scroll BlockArray //////////////////////////////////////
|
||||||
|
|
||||||
|
HistoryScrollBlockArray::HistoryScrollBlockArray(size_t size)
|
||||||
|
: HistoryScroll(new HistoryTypeBlockArray(size))
|
||||||
|
{
|
||||||
|
m_blockArray.setHistorySize(size); // nb. of lines.
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryScrollBlockArray::~HistoryScrollBlockArray()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryScrollBlockArray::getLines()
|
||||||
|
{
|
||||||
|
return m_lineLengths.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryScrollBlockArray::getLineLen(int lineno)
|
||||||
|
{
|
||||||
|
if ( m_lineLengths.contains(lineno) )
|
||||||
|
return m_lineLengths[lineno];
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryScrollBlockArray::isWrappedLine(int /*lineno*/)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollBlockArray::getCells(int lineno, int colno,
|
||||||
|
int count, Character res[])
|
||||||
|
{
|
||||||
|
if (!count) return;
|
||||||
|
|
||||||
|
const Block *b = m_blockArray.at(lineno);
|
||||||
|
|
||||||
|
if (!b) {
|
||||||
|
memset(res, 0, count * sizeof(Character)); // still better than random data
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(((colno + count) * sizeof(Character)) < ENTRIES);
|
||||||
|
memcpy(res, b->data + (colno * sizeof(Character)), count * sizeof(Character));
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollBlockArray::addCells(const Character a[], int count)
|
||||||
|
{
|
||||||
|
Block *b = m_blockArray.lastBlock();
|
||||||
|
|
||||||
|
if (!b) return;
|
||||||
|
|
||||||
|
// put cells in block's data
|
||||||
|
assert((count * sizeof(Character)) < ENTRIES);
|
||||||
|
|
||||||
|
memset(b->data, 0, ENTRIES);
|
||||||
|
|
||||||
|
memcpy(b->data, a, count * sizeof(Character));
|
||||||
|
b->size = count * sizeof(Character);
|
||||||
|
|
||||||
|
size_t res = m_blockArray.newBlock();
|
||||||
|
assert (res > 0);
|
||||||
|
Q_UNUSED( res );
|
||||||
|
|
||||||
|
m_lineLengths.insert(m_blockArray.getCurrent(), count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryScrollBlockArray::addLine(bool)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
// Compact History Scroll //////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
void* CompactHistoryBlock::allocate ( size_t length )
|
||||||
|
{
|
||||||
|
Q_ASSERT ( length > 0 );
|
||||||
|
if ( tail-blockStart+length > blockLength )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
void* block = tail;
|
||||||
|
tail += length;
|
||||||
|
//kDebug() << "allocated " << length << " bytes at address " << block;
|
||||||
|
allocCount++;
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompactHistoryBlock::deallocate ( )
|
||||||
|
{
|
||||||
|
allocCount--;
|
||||||
|
Q_ASSERT ( allocCount >= 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void* CompactHistoryBlockList::allocate(size_t size)
|
||||||
|
{
|
||||||
|
CompactHistoryBlock* block;
|
||||||
|
if ( list.isEmpty() || list.last()->remaining() < size)
|
||||||
|
{
|
||||||
|
block = new CompactHistoryBlock();
|
||||||
|
list.append ( block );
|
||||||
|
//kDebug() << "new block created, remaining " << block->remaining() << "number of blocks=" << list.size();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
block = list.last();
|
||||||
|
//kDebug() << "old block used, remaining " << block->remaining();
|
||||||
|
}
|
||||||
|
return block->allocate(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompactHistoryBlockList::deallocate(void* ptr)
|
||||||
|
{
|
||||||
|
Q_ASSERT( !list.isEmpty());
|
||||||
|
|
||||||
|
int i=0;
|
||||||
|
CompactHistoryBlock *block = list.at(i);
|
||||||
|
while ( i<list.size() && !block->contains(ptr) )
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
block=list.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_ASSERT( i<list.size() );
|
||||||
|
|
||||||
|
block->deallocate();
|
||||||
|
|
||||||
|
if (!block->isInUse())
|
||||||
|
{
|
||||||
|
list.removeAt(i);
|
||||||
|
delete block;
|
||||||
|
//kDebug() << "block deleted, new size = " << list.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CompactHistoryBlockList::~CompactHistoryBlockList()
|
||||||
|
{
|
||||||
|
qDeleteAll ( list.begin(), list.end() );
|
||||||
|
list.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void* CompactHistoryLine::operator new (size_t size, CompactHistoryBlockList& blockList)
|
||||||
|
{
|
||||||
|
return blockList.allocate(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
CompactHistoryLine::CompactHistoryLine ( const TextLine& line, CompactHistoryBlockList& bList )
|
||||||
|
: blockList(bList),
|
||||||
|
formatLength(0)
|
||||||
|
{
|
||||||
|
length=line.size();
|
||||||
|
|
||||||
|
if (line.size() > 0) {
|
||||||
|
formatLength=1;
|
||||||
|
int k=1;
|
||||||
|
|
||||||
|
// count number of different formats in this text line
|
||||||
|
Character c = line[0];
|
||||||
|
while ( k<length )
|
||||||
|
{
|
||||||
|
if ( !(line[k].equalsFormat(c)))
|
||||||
|
{
|
||||||
|
formatLength++; // format change detected
|
||||||
|
c=line[k];
|
||||||
|
}
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//kDebug() << "number of different formats in string: " << formatLength;
|
||||||
|
formatArray = (CharacterFormat*) blockList.allocate(sizeof(CharacterFormat)*formatLength);
|
||||||
|
Q_ASSERT (formatArray!=NULL);
|
||||||
|
text = (quint16*) blockList.allocate(sizeof(quint16)*line.size());
|
||||||
|
Q_ASSERT (text!=NULL);
|
||||||
|
|
||||||
|
length=line.size();
|
||||||
|
formatLength=formatLength;
|
||||||
|
wrapped=false;
|
||||||
|
|
||||||
|
// record formats and their positions in the format array
|
||||||
|
c=line[0];
|
||||||
|
formatArray[0].setFormat ( c );
|
||||||
|
formatArray[0].startPos=0; // there's always at least 1 format (for the entire line, unless a change happens)
|
||||||
|
|
||||||
|
k=1; // look for possible format changes
|
||||||
|
int j=1;
|
||||||
|
while ( k<length && j<formatLength )
|
||||||
|
{
|
||||||
|
if (!(line[k].equalsFormat(c)))
|
||||||
|
{
|
||||||
|
c=line[k];
|
||||||
|
formatArray[j].setFormat(c);
|
||||||
|
formatArray[j].startPos=k;
|
||||||
|
//kDebug() << "format entry " << j << " at pos " << formatArray[j].startPos << " " << &(formatArray[j].startPos) ;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy character values
|
||||||
|
for ( int i=0; i<line.size(); i++ )
|
||||||
|
{
|
||||||
|
text[i]=line[i].character;
|
||||||
|
//kDebug() << "char " << i << " at mem " << &(text[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//kDebug() << "line created, length " << length << " at " << &(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
CompactHistoryLine::~CompactHistoryLine()
|
||||||
|
{
|
||||||
|
//kDebug() << "~CHL";
|
||||||
|
if (length>0) {
|
||||||
|
blockList.deallocate(text);
|
||||||
|
blockList.deallocate(formatArray);
|
||||||
|
}
|
||||||
|
blockList.deallocate(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompactHistoryLine::getCharacter ( int index, Character &r )
|
||||||
|
{
|
||||||
|
Q_ASSERT ( index < length );
|
||||||
|
int formatPos=0;
|
||||||
|
while ( ( formatPos+1 ) < formatLength && index >= formatArray[formatPos+1].startPos )
|
||||||
|
formatPos++;
|
||||||
|
|
||||||
|
r.character=text[index];
|
||||||
|
r.rendition = formatArray[formatPos].rendition;
|
||||||
|
r.foregroundColor = formatArray[formatPos].fgColor;
|
||||||
|
r.backgroundColor = formatArray[formatPos].bgColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompactHistoryLine::getCharacters ( Character* array, int length, int startColumn )
|
||||||
|
{
|
||||||
|
Q_ASSERT ( startColumn >= 0 && length >= 0 );
|
||||||
|
Q_ASSERT ( startColumn+length <= ( int ) getLength() );
|
||||||
|
|
||||||
|
for ( int i=startColumn; i<length+startColumn; i++ )
|
||||||
|
{
|
||||||
|
getCharacter ( i, array[i-startColumn] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CompactHistoryScroll::CompactHistoryScroll ( unsigned int maxLineCount )
|
||||||
|
: HistoryScroll ( new CompactHistoryType ( maxLineCount ) )
|
||||||
|
,lines()
|
||||||
|
,blockList()
|
||||||
|
{
|
||||||
|
//kDebug() << "scroll of length " << maxLineCount << " created";
|
||||||
|
setMaxNbLines ( maxLineCount );
|
||||||
|
}
|
||||||
|
|
||||||
|
CompactHistoryScroll::~CompactHistoryScroll()
|
||||||
|
{
|
||||||
|
qDeleteAll ( lines.begin(), lines.end() );
|
||||||
|
lines.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompactHistoryScroll::addCellsVector ( const TextLine& cells )
|
||||||
|
{
|
||||||
|
CompactHistoryLine *line;
|
||||||
|
line = new(blockList) CompactHistoryLine ( cells, blockList );
|
||||||
|
|
||||||
|
if ( lines.size() > ( int ) _maxLineCount )
|
||||||
|
{
|
||||||
|
delete lines.takeAt ( 0 );
|
||||||
|
}
|
||||||
|
lines.append ( line );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompactHistoryScroll::addCells ( const Character a[], int count )
|
||||||
|
{
|
||||||
|
TextLine newLine ( count );
|
||||||
|
qCopy ( a,a+count,newLine.begin() );
|
||||||
|
addCellsVector ( newLine );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompactHistoryScroll::addLine ( bool previousWrapped )
|
||||||
|
{
|
||||||
|
CompactHistoryLine *line = lines.last();
|
||||||
|
//kDebug() << "last line at address " << line;
|
||||||
|
line->setWrapped(previousWrapped);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CompactHistoryScroll::getLines()
|
||||||
|
{
|
||||||
|
return lines.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CompactHistoryScroll::getLineLen ( int lineNumber )
|
||||||
|
{
|
||||||
|
Q_ASSERT ( lineNumber >= 0 && lineNumber < lines.size() );
|
||||||
|
CompactHistoryLine* line = lines[lineNumber];
|
||||||
|
//kDebug() << "request for line at address " << line;
|
||||||
|
return line->getLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CompactHistoryScroll::getCells ( int lineNumber, int startColumn, int count, Character buffer[] )
|
||||||
|
{
|
||||||
|
if ( count == 0 ) return;
|
||||||
|
Q_ASSERT ( lineNumber < lines.size() );
|
||||||
|
CompactHistoryLine* line = lines[lineNumber];
|
||||||
|
Q_ASSERT ( startColumn >= 0 );
|
||||||
|
Q_ASSERT ( (unsigned int)startColumn <= line->getLength() - count );
|
||||||
|
line->getCharacters ( buffer, count, startColumn );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompactHistoryScroll::setMaxNbLines ( unsigned int lineCount )
|
||||||
|
{
|
||||||
|
_maxLineCount = lineCount;
|
||||||
|
|
||||||
|
while (lines.size() > (int) lineCount) {
|
||||||
|
delete lines.takeAt(0);
|
||||||
|
}
|
||||||
|
//kDebug() << "set max lines to: " << _maxLineCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CompactHistoryScroll::isWrappedLine ( int lineNumber )
|
||||||
|
{
|
||||||
|
Q_ASSERT ( lineNumber < lines.size() );
|
||||||
|
return lines[lineNumber]->isWrapped();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// History Types
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
HistoryType::HistoryType()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryType::~HistoryType()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
|
HistoryTypeNone::HistoryTypeNone()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryTypeNone::isEnabled() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryScroll* HistoryTypeNone::scroll(HistoryScroll *old) const
|
||||||
|
{
|
||||||
|
delete old;
|
||||||
|
return new HistoryScrollNone();
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryTypeNone::maximumLineCount() const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
|
HistoryTypeBlockArray::HistoryTypeBlockArray(size_t size)
|
||||||
|
: m_size(size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryTypeBlockArray::isEnabled() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryTypeBlockArray::maximumLineCount() const
|
||||||
|
{
|
||||||
|
return m_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryScroll* HistoryTypeBlockArray::scroll(HistoryScroll *old) const
|
||||||
|
{
|
||||||
|
delete old;
|
||||||
|
return new HistoryScrollBlockArray(m_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
|
HistoryTypeBuffer::HistoryTypeBuffer(unsigned int nbLines)
|
||||||
|
: m_nbLines(nbLines)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryTypeBuffer::isEnabled() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryTypeBuffer::maximumLineCount() const
|
||||||
|
{
|
||||||
|
return m_nbLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryScroll* HistoryTypeBuffer::scroll(HistoryScroll *old) const
|
||||||
|
{
|
||||||
|
if (old)
|
||||||
|
{
|
||||||
|
HistoryScrollBuffer *oldBuffer = dynamic_cast<HistoryScrollBuffer*>(old);
|
||||||
|
if (oldBuffer)
|
||||||
|
{
|
||||||
|
oldBuffer->setMaxNbLines(m_nbLines);
|
||||||
|
return oldBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryScroll *newScroll = new HistoryScrollBuffer(m_nbLines);
|
||||||
|
int lines = old->getLines();
|
||||||
|
int startLine = 0;
|
||||||
|
if (lines > (int) m_nbLines)
|
||||||
|
startLine = lines - m_nbLines;
|
||||||
|
|
||||||
|
Character line[LINE_SIZE];
|
||||||
|
for(int i = startLine; i < lines; i++)
|
||||||
|
{
|
||||||
|
int size = old->getLineLen(i);
|
||||||
|
if (size > LINE_SIZE)
|
||||||
|
{
|
||||||
|
Character *tmp_line = new Character[size];
|
||||||
|
old->getCells(i, 0, size, tmp_line);
|
||||||
|
newScroll->addCells(tmp_line, size);
|
||||||
|
newScroll->addLine(old->isWrappedLine(i));
|
||||||
|
delete [] tmp_line;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
old->getCells(i, 0, size, line);
|
||||||
|
newScroll->addCells(line, size);
|
||||||
|
newScroll->addLine(old->isWrappedLine(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete old;
|
||||||
|
return newScroll;
|
||||||
|
}
|
||||||
|
return new HistoryScrollBuffer(m_nbLines);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
|
HistoryTypeFile::HistoryTypeFile(const QString& fileName)
|
||||||
|
: m_fileName(fileName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryTypeFile::isEnabled() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString& HistoryTypeFile::getFileName() const
|
||||||
|
{
|
||||||
|
return m_fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryScroll* HistoryTypeFile::scroll(HistoryScroll *old) const
|
||||||
|
{
|
||||||
|
if (dynamic_cast<HistoryFile *>(old))
|
||||||
|
return old; // Unchanged.
|
||||||
|
|
||||||
|
HistoryScroll *newScroll = new HistoryScrollFile(m_fileName);
|
||||||
|
|
||||||
|
Character line[LINE_SIZE];
|
||||||
|
int lines = (old != 0) ? old->getLines() : 0;
|
||||||
|
for(int i = 0; i < lines; i++)
|
||||||
|
{
|
||||||
|
int size = old->getLineLen(i);
|
||||||
|
if (size > LINE_SIZE)
|
||||||
|
{
|
||||||
|
Character *tmp_line = new Character[size];
|
||||||
|
old->getCells(i, 0, size, tmp_line);
|
||||||
|
newScroll->addCells(tmp_line, size);
|
||||||
|
newScroll->addLine(old->isWrappedLine(i));
|
||||||
|
delete [] tmp_line;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
old->getCells(i, 0, size, line);
|
||||||
|
newScroll->addCells(line, size);
|
||||||
|
newScroll->addLine(old->isWrappedLine(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete old;
|
||||||
|
return newScroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HistoryTypeFile::maximumLineCount() const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
|
CompactHistoryType::CompactHistoryType ( unsigned int nbLines )
|
||||||
|
: m_nbLines ( nbLines )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CompactHistoryType::isEnabled() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CompactHistoryType::maximumLineCount() const
|
||||||
|
{
|
||||||
|
return m_nbLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryScroll* CompactHistoryType::scroll ( HistoryScroll *old ) const
|
||||||
|
{
|
||||||
|
if ( old )
|
||||||
|
{
|
||||||
|
CompactHistoryScroll *oldBuffer = dynamic_cast<CompactHistoryScroll*> ( old );
|
||||||
|
if ( oldBuffer )
|
||||||
|
{
|
||||||
|
oldBuffer->setMaxNbLines ( m_nbLines );
|
||||||
|
return oldBuffer;
|
||||||
|
}
|
||||||
|
delete old;
|
||||||
|
}
|
||||||
|
return new CompactHistoryScroll ( m_nbLines );
|
||||||
|
}
|
490
konsole-qml-plugin/src/History.h
Normal file
@ -0,0 +1,490 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Konsole, an X terminal.
|
||||||
|
Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
|
||||||
|
|
||||||
|
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 TEHISTORY_H
|
||||||
|
#define TEHISTORY_H
|
||||||
|
|
||||||
|
// Qt
|
||||||
|
#include <QtCore/QBitRef>
|
||||||
|
#include <QtCore/QHash>
|
||||||
|
#include <QtCore/QVector>
|
||||||
|
#include <QTemporaryFile>
|
||||||
|
|
||||||
|
// KDE
|
||||||
|
//#include <ktemporaryfile.h>
|
||||||
|
|
||||||
|
// Konsole
|
||||||
|
#include "BlockArray.h"
|
||||||
|
#include "Character.h"
|
||||||
|
|
||||||
|
// map
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
/*
|
||||||
|
An extendable tmpfile(1) based buffer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class HistoryFile
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HistoryFile();
|
||||||
|
virtual ~HistoryFile();
|
||||||
|
|
||||||
|
virtual void add(const unsigned char* bytes, int len);
|
||||||
|
virtual void get(unsigned char* bytes, int len, int loc);
|
||||||
|
virtual int len();
|
||||||
|
|
||||||
|
//mmaps the file in read-only mode
|
||||||
|
void map();
|
||||||
|
//un-mmaps the file
|
||||||
|
void unmap();
|
||||||
|
//returns true if the file is mmap'ed
|
||||||
|
bool isMapped();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
int ion;
|
||||||
|
int length;
|
||||||
|
QTemporaryFile tmpFile;
|
||||||
|
|
||||||
|
//pointer to start of mmap'ed file data, or 0 if the file is not mmap'ed
|
||||||
|
char* fileMap;
|
||||||
|
|
||||||
|
//incremented whenver 'add' is called and decremented whenever
|
||||||
|
//'get' is called.
|
||||||
|
//this is used to detect when a large number of lines are being read and processed from the history
|
||||||
|
//and automatically mmap the file for better performance (saves the overhead of many lseek-read calls).
|
||||||
|
int readWriteBalance;
|
||||||
|
|
||||||
|
//when readWriteBalance goes below this threshold, the file will be mmap'ed automatically
|
||||||
|
static const int MAP_THRESHOLD = -1000;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Abstract base class for file and buffer versions
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
class HistoryType;
|
||||||
|
|
||||||
|
class HistoryScroll
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HistoryScroll(HistoryType*);
|
||||||
|
virtual ~HistoryScroll();
|
||||||
|
|
||||||
|
virtual bool hasScroll();
|
||||||
|
|
||||||
|
// access to history
|
||||||
|
virtual int getLines() = 0;
|
||||||
|
virtual int getLineLen(int lineno) = 0;
|
||||||
|
virtual void getCells(int lineno, int colno, int count, Character res[]) = 0;
|
||||||
|
virtual bool isWrappedLine(int lineno) = 0;
|
||||||
|
|
||||||
|
// backward compatibility (obsolete)
|
||||||
|
Character getCell(int lineno, int colno) { Character res; getCells(lineno,colno,1,&res); return res; }
|
||||||
|
|
||||||
|
// adding lines.
|
||||||
|
virtual void addCells(const Character a[], int count) = 0;
|
||||||
|
// convenience method - this is virtual so that subclasses can take advantage
|
||||||
|
// of QVector's implicit copying
|
||||||
|
virtual void addCellsVector(const QVector<Character>& cells)
|
||||||
|
{
|
||||||
|
addCells(cells.data(),cells.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void addLine(bool previousWrapped=false) = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// FIXME: Passing around constant references to HistoryType instances
|
||||||
|
// is very unsafe, because those references will no longer
|
||||||
|
// be valid if the history scroll is deleted.
|
||||||
|
//
|
||||||
|
const HistoryType& getType() { return *m_histType; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
HistoryType* m_histType;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// File-based history (e.g. file log, no limitation in length)
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class HistoryScrollFile : public HistoryScroll
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HistoryScrollFile(const QString &logFileName);
|
||||||
|
virtual ~HistoryScrollFile();
|
||||||
|
|
||||||
|
virtual int getLines();
|
||||||
|
virtual int getLineLen(int lineno);
|
||||||
|
virtual void getCells(int lineno, int colno, int count, Character res[]);
|
||||||
|
virtual bool isWrappedLine(int lineno);
|
||||||
|
|
||||||
|
virtual void addCells(const Character a[], int count);
|
||||||
|
virtual void addLine(bool previousWrapped=false);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int startOfLine(int lineno);
|
||||||
|
|
||||||
|
QString m_logFileName;
|
||||||
|
HistoryFile index; // lines Row(int)
|
||||||
|
HistoryFile cells; // text Row(Character)
|
||||||
|
HistoryFile lineflags; // flags Row(unsigned char)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Buffer-based history (limited to a fixed nb of lines)
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
class HistoryScrollBuffer : public HistoryScroll
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef QVector<Character> HistoryLine;
|
||||||
|
|
||||||
|
HistoryScrollBuffer(unsigned int maxNbLines = 1000);
|
||||||
|
virtual ~HistoryScrollBuffer();
|
||||||
|
|
||||||
|
virtual int getLines();
|
||||||
|
virtual int getLineLen(int lineno);
|
||||||
|
virtual void getCells(int lineno, int colno, int count, Character res[]);
|
||||||
|
virtual bool isWrappedLine(int lineno);
|
||||||
|
|
||||||
|
virtual void addCells(const Character a[], int count);
|
||||||
|
virtual void addCellsVector(const QVector<Character>& cells);
|
||||||
|
virtual void addLine(bool previousWrapped=false);
|
||||||
|
|
||||||
|
void setMaxNbLines(unsigned int nbLines);
|
||||||
|
unsigned int maxNbLines() { return _maxLineCount; }
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
int bufferIndex(int lineNumber);
|
||||||
|
|
||||||
|
HistoryLine* _historyBuffer;
|
||||||
|
QBitArray _wrappedLine;
|
||||||
|
int _maxLineCount;
|
||||||
|
int _usedLines;
|
||||||
|
int _head;
|
||||||
|
|
||||||
|
//QVector<histline*> m_histBuffer;
|
||||||
|
//QBitArray m_wrappedLine;
|
||||||
|
//unsigned int m_maxNbLines;
|
||||||
|
//unsigned int m_nbLines;
|
||||||
|
//unsigned int m_arrayIndex;
|
||||||
|
//bool m_buffFilled;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*class HistoryScrollBufferV2 : public HistoryScroll
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual int getLines();
|
||||||
|
virtual int getLineLen(int lineno);
|
||||||
|
virtual void getCells(int lineno, int colno, int count, Character res[]);
|
||||||
|
virtual bool isWrappedLine(int lineno);
|
||||||
|
|
||||||
|
virtual void addCells(const Character a[], int count);
|
||||||
|
virtual void addCells(const QVector<Character>& cells);
|
||||||
|
virtual void addLine(bool previousWrapped=false);
|
||||||
|
|
||||||
|
};*/
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Nothing-based history (no history :-)
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
class HistoryScrollNone : public HistoryScroll
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HistoryScrollNone();
|
||||||
|
virtual ~HistoryScrollNone();
|
||||||
|
|
||||||
|
virtual bool hasScroll();
|
||||||
|
|
||||||
|
virtual int getLines();
|
||||||
|
virtual int getLineLen(int lineno);
|
||||||
|
virtual void getCells(int lineno, int colno, int count, Character res[]);
|
||||||
|
virtual bool isWrappedLine(int lineno);
|
||||||
|
|
||||||
|
virtual void addCells(const Character a[], int count);
|
||||||
|
virtual void addLine(bool previousWrapped=false);
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// BlockArray-based history
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
class HistoryScrollBlockArray : public HistoryScroll
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HistoryScrollBlockArray(size_t size);
|
||||||
|
virtual ~HistoryScrollBlockArray();
|
||||||
|
|
||||||
|
virtual int getLines();
|
||||||
|
virtual int getLineLen(int lineno);
|
||||||
|
virtual void getCells(int lineno, int colno, int count, Character res[]);
|
||||||
|
virtual bool isWrappedLine(int lineno);
|
||||||
|
|
||||||
|
virtual void addCells(const Character a[], int count);
|
||||||
|
virtual void addLine(bool previousWrapped=false);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BlockArray m_blockArray;
|
||||||
|
QHash<int,size_t> m_lineLengths;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// History using compact storage
|
||||||
|
// This implementation uses a list of fixed-sized blocks
|
||||||
|
// where history lines are allocated in (avoids heap fragmentation)
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
typedef QVector<Character> TextLine;
|
||||||
|
|
||||||
|
class CharacterFormat
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool equalsFormat(const CharacterFormat &other) const {
|
||||||
|
return other.rendition==rendition && other.fgColor==fgColor && other.bgColor==bgColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool equalsFormat(const Character &c) const {
|
||||||
|
return c.rendition==rendition && c.foregroundColor==fgColor && c.backgroundColor==bgColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFormat(const Character& c) {
|
||||||
|
rendition=c.rendition;
|
||||||
|
fgColor=c.foregroundColor;
|
||||||
|
bgColor=c.backgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
CharacterColor fgColor, bgColor;
|
||||||
|
quint16 startPos;
|
||||||
|
quint8 rendition;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CompactHistoryBlock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
CompactHistoryBlock(){
|
||||||
|
blockLength = 4096*64; // 256kb
|
||||||
|
head = (quint8*) mmap(0, blockLength, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
|
||||||
|
//head = (quint8*) malloc(blockLength);
|
||||||
|
Q_ASSERT(head != MAP_FAILED);
|
||||||
|
tail = blockStart = head;
|
||||||
|
allocCount=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~CompactHistoryBlock(){
|
||||||
|
//free(blockStart);
|
||||||
|
munmap(blockStart, blockLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual unsigned int remaining(){ return blockStart+blockLength-tail;}
|
||||||
|
virtual unsigned length() { return blockLength; }
|
||||||
|
virtual void* allocate(size_t length);
|
||||||
|
virtual bool contains(void *addr) {return addr>=blockStart && addr<(blockStart+blockLength);}
|
||||||
|
virtual void deallocate();
|
||||||
|
virtual bool isInUse(){ return allocCount!=0; } ;
|
||||||
|
|
||||||
|
private:
|
||||||
|
size_t blockLength;
|
||||||
|
quint8* head;
|
||||||
|
quint8* tail;
|
||||||
|
quint8* blockStart;
|
||||||
|
int allocCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CompactHistoryBlockList {
|
||||||
|
public:
|
||||||
|
CompactHistoryBlockList() {};
|
||||||
|
~CompactHistoryBlockList();
|
||||||
|
|
||||||
|
void *allocate( size_t size );
|
||||||
|
void deallocate(void *);
|
||||||
|
int length() {return list.size();}
|
||||||
|
private:
|
||||||
|
QList<CompactHistoryBlock*> list;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CompactHistoryLine
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CompactHistoryLine(const TextLine&, CompactHistoryBlockList& blockList);
|
||||||
|
virtual ~CompactHistoryLine();
|
||||||
|
|
||||||
|
// custom new operator to allocate memory from custom pool instead of heap
|
||||||
|
static void *operator new( size_t size, CompactHistoryBlockList& blockList);
|
||||||
|
static void operator delete( void *) { /* do nothing, deallocation from pool is done in destructor*/ } ;
|
||||||
|
|
||||||
|
virtual void getCharacters(Character* array, int length, int startColumn) ;
|
||||||
|
virtual void getCharacter(int index, Character &r) ;
|
||||||
|
virtual bool isWrapped() const {return wrapped;};
|
||||||
|
virtual void setWrapped(bool isWrapped) { wrapped=isWrapped;};
|
||||||
|
virtual unsigned int getLength() const {return length;};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CompactHistoryBlockList& blockList;
|
||||||
|
CharacterFormat* formatArray;
|
||||||
|
quint16 length;
|
||||||
|
quint16* text;
|
||||||
|
quint16 formatLength;
|
||||||
|
bool wrapped;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CompactHistoryScroll : public HistoryScroll
|
||||||
|
{
|
||||||
|
typedef QList<CompactHistoryLine*> HistoryArray;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CompactHistoryScroll(unsigned int maxNbLines = 1000);
|
||||||
|
virtual ~CompactHistoryScroll();
|
||||||
|
|
||||||
|
virtual int getLines();
|
||||||
|
virtual int getLineLen(int lineno);
|
||||||
|
virtual void getCells(int lineno, int colno, int count, Character res[]);
|
||||||
|
virtual bool isWrappedLine(int lineno);
|
||||||
|
|
||||||
|
virtual void addCells(const Character a[], int count);
|
||||||
|
virtual void addCellsVector(const TextLine& cells);
|
||||||
|
virtual void addLine(bool previousWrapped=false);
|
||||||
|
|
||||||
|
void setMaxNbLines(unsigned int nbLines);
|
||||||
|
unsigned int maxNbLines() const { return _maxLineCount; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool hasDifferentColors(const TextLine& line) const;
|
||||||
|
HistoryArray lines;
|
||||||
|
CompactHistoryBlockList blockList;
|
||||||
|
|
||||||
|
unsigned int _maxLineCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// History type
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class HistoryType
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HistoryType();
|
||||||
|
virtual ~HistoryType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the history is enabled ( can store lines of output )
|
||||||
|
* or false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool isEnabled() const = 0;
|
||||||
|
/**
|
||||||
|
* Returns true if the history size is unlimited.
|
||||||
|
*/
|
||||||
|
bool isUnlimited() const { return maximumLineCount() == 0; }
|
||||||
|
/**
|
||||||
|
* Returns the maximum number of lines which this history type
|
||||||
|
* can store or 0 if the history can store an unlimited number of lines.
|
||||||
|
*/
|
||||||
|
virtual int maximumLineCount() const = 0;
|
||||||
|
|
||||||
|
virtual HistoryScroll* scroll(HistoryScroll *) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class HistoryTypeNone : public HistoryType
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HistoryTypeNone();
|
||||||
|
|
||||||
|
virtual bool isEnabled() const;
|
||||||
|
virtual int maximumLineCount() const;
|
||||||
|
|
||||||
|
virtual HistoryScroll* scroll(HistoryScroll *) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class HistoryTypeBlockArray : public HistoryType
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HistoryTypeBlockArray(size_t size);
|
||||||
|
|
||||||
|
virtual bool isEnabled() const;
|
||||||
|
virtual int maximumLineCount() const;
|
||||||
|
|
||||||
|
virtual HistoryScroll* scroll(HistoryScroll *) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
size_t m_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
class HistoryTypeFile : public HistoryType
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HistoryTypeFile(const QString& fileName=QString());
|
||||||
|
|
||||||
|
virtual bool isEnabled() const;
|
||||||
|
virtual const QString& getFileName() const;
|
||||||
|
virtual int maximumLineCount() const;
|
||||||
|
|
||||||
|
virtual HistoryScroll* scroll(HistoryScroll *) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString m_fileName;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class HistoryTypeBuffer : public HistoryType
|
||||||
|
{
|
||||||
|
friend class HistoryScrollBuffer;
|
||||||
|
|
||||||
|
public:
|
||||||
|
HistoryTypeBuffer(unsigned int nbLines);
|
||||||
|
|
||||||
|
virtual bool isEnabled() const;
|
||||||
|
virtual int maximumLineCount() const;
|
||||||
|
|
||||||
|
virtual HistoryScroll* scroll(HistoryScroll *) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
unsigned int m_nbLines;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CompactHistoryType : public HistoryType
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CompactHistoryType(unsigned int size);
|
||||||
|
|
||||||
|
virtual bool isEnabled() const;
|
||||||
|
virtual int maximumLineCount() const;
|
||||||
|
|
||||||
|
virtual HistoryScroll* scroll(HistoryScroll *) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
unsigned int m_nbLines;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // TEHISTORY_H
|