Moved to new version of yat. Yat is no longer a submodule but is now integrated.

This commit is contained in:
Filippo Scognamiglio
2013-12-27 00:31:43 +01:00
parent bd39a63a64
commit 6b4b187df5
62 changed files with 14743 additions and 125 deletions

View File

@@ -0,0 +1,104 @@
/*******************************************************************************
* Copyright (c) 2013 Jørgen Lind
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*******************************************************************************/
import QtQuick 2.0
Item {
id: highlightArea
property real characterWidth: 0
property real characterHeight: 0
property int screenWidth: 0
property int startX
property int startY
property int endX
property int endY
property color color: "grey"
y: startY * characterHeight
width: parent.width
height: (endY - startY + 1) * characterHeight
opacity: 0.8
Rectangle {
id: begginning_rectangle
color: parent.color
opacity: parent.opacity
y:0
height: characterHeight
}
Rectangle {
id: middle_rectangle
color: parent.color
opacity: parent.opacity
width: parent.width
x: 0
anchors.top: begginning_rectangle.bottom
}
Rectangle {
id: end_rectangle
color: parent.color
opacity: parent.opacity
x: 0
height: characterHeight
anchors.top: middle_rectangle.bottom
}
onCharacterWidthChanged: calculateRectangles();
onCharacterHeightChanged: calculateRectangles();
onScreenWidthChanged: calculateRectangles();
onStartXChanged: calculateRectangles();
onStartYChanged: calculateRectangles();
onEndXChanged: calculateRectangles();
onEndYChanged: calculateRectangles();
function calculateRectangles() {
highlightArea.y = startY * characterHeight;
begginning_rectangle.x = startX * characterWidth;
if (startY === endY) {
middle_rectangle.visible = false;
end_rectangle.visible = false
begginning_rectangle.width = (endX - startX) * characterWidth;
} else {
begginning_rectangle.width = (screenWidth - startX) * characterWidth;
if (startY === endY - 1) {
middle_rectangle.height = 0;
middle_rectangle.visible = false;
}else {
middle_rectangle.visible = true;
middle_rectangle.height = (endY - startY - 1) * characterHeight;
}
end_rectangle.visible = true;
end_rectangle.width = endX * characterWidth;
}
}
}

View File

@@ -0,0 +1,66 @@
/*******************************************************************************
* Copyright (c) 2013 Jørgen Lind
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*******************************************************************************/
import QtQuick 2.0
import org.yat 1.0
ObjectDestructItem {
id: cursor
property real fontHeight
property real fontWidth
height: fontHeight
width: fontWidth
x: objectHandle.x * fontWidth
y: objectHandle.y * fontHeight
z: 1.1
visible: objectHandle.visible
ShaderEffect {
anchors.fill: parent
property variant source: fragmentSource
fragmentShader:
"uniform lowp float qt_Opacity;" +
"uniform sampler2D source;" +
"varying highp vec2 qt_TexCoord0;" +
"void main() {" +
" lowp vec4 color = texture2D(source, qt_TexCoord0 ) * qt_Opacity;" +
" gl_FragColor = vec4(1.0 - color.r, 1.0 - color.g, 1.0 - color.b, color.a);" +
"}"
ShaderEffectSource {
id: fragmentSource
sourceItem: background
live: true
sourceRect: Qt.rect(cursor.x,cursor.y,cursor.width,cursor.height);
}
}
}

View File

@@ -0,0 +1,285 @@
/*******************************************************************************
* Copyright (c) 2013 Jørgen Lind
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*******************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.1
import org.yat 1.0
TerminalScreen {
id: screenItem
property font font
property real fontWidth: fontMetricText.paintedWidth
property real fontHeight: fontMetricText.paintedHeight
property var lineComponent : Qt.createComponent("TerminalLine.qml")
property var textComponent : Qt.createComponent("TerminalText.qml")
property var cursorComponent : Qt.createComponent("TerminalCursor.qml")
font.family: "menlo"
focus: true
Action {
id: copyAction
shortcut: "Ctrl+Shift+C"
onTriggered: screen.selection.sendToClipboard()
}
Action {
id: paseAction
shortcut: "Ctrl+Shift+V"
onTriggered: screen.selection.pasteFromClipboard()
}
onActiveFocusChanged: {
if (activeFocus) {
Qt.inputMethod.show();
}
}
Keys.onPressed: {
if (event.text === "?") {
terminal.screen.printScreen()
}
}
Text {
id: fontMetricText
text: "B"
font: parent.font
visible: false
textFormat: Text.PlainText
}
Flickable {
id: flickable
anchors.top: parent.top
anchors.left: parent.left
contentWidth: width
contentHeight: textContainer.height
interactive: true
flickableDirection: Flickable.VerticalFlick
contentY: ((screen.contentHeight - screen.height) * screenItem.fontHeight)
Item {
id: textContainer
width: parent.width
height: screen.contentHeight * screenItem.fontHeight
Rectangle {
id: background
anchors.fill: parent
color: terminal.screen.defaultBackgroundColor
}
HighlightArea {
characterHeight: fontHeight
characterWidth: fontWidth
screenWidth: terminalWindow.width
startX: screen.selection.startX
startY: screen.selection.startY
endX: screen.selection.endX
endY: screen.selection.endY
visible: screen.selection.enable
}
}
onContentYChanged: {
if (!atYEnd) {
var top_line = Math.floor(Math.max(contentY,0) / screenItem.fontHeight);
screen.ensureVisiblePages(top_line);
}
}
}
Connections {
id: connections
target: terminal.screen
onFlash: {
flashAnimation.start()
}
onReset: {
resetScreenItems();
}
onTextCreated: {
var textSegment = textComponent.createObject(screenItem,
{
"parent" : background,
"objectHandle" : text,
"font" : screenItem.font,
"fontWidth" : screenItem.fontWidth,
"fontHeight" : screenItem.fontHeight,
})
}
onCursorCreated: {
if (cursorComponent.status != Component.Ready) {
console.log(cursorComponent.errorString());
return;
}
var cursorVariable = cursorComponent.createObject(screenItem,
{
"parent" : textContainer,
"objectHandle" : cursor,
"fontWidth" : screenItem.fontWidth,
"fontHeight" : screenItem.fontHeight,
})
}
onRequestHeightChange: {
terminalWindow.height = newHeight * screenItem.fontHeight;
terminalWindow.contentItem.height = newHeight * screenItem.fontHeight;
}
onRequestWidthChange: {
terminalWindow.width = newWidth * screenItem.fontWidth;
terminalWindow.contentItem.width = newWidth * screenItem.fontWidth;
}
}
onFontChanged: {
setTerminalHeight();
setTerminalWidth();
}
onWidthChanged: {
setTerminalWidth();
}
onHeightChanged: {
setTerminalHeight();
}
Component.onCompleted: {
setTerminalWidth();
setTerminalHeight();
}
function setTerminalWidth() {
if (fontWidth > 0) {
var pty_width = Math.floor(width / fontWidth);
flickable.width = pty_width * fontWidth;
screen.width = pty_width;
}
}
function setTerminalHeight() {
if (fontHeight > 0) {
var pty_height = Math.floor(height / fontHeight);
flickable.height = pty_height * fontHeight;
screen.height = pty_height;
}
}
Rectangle {
id: flash
z: 1.2
anchors.fill: parent
color: "grey"
opacity: 0
SequentialAnimation {
id: flashAnimation
NumberAnimation {
target: flash
property: "opacity"
to: 1
duration: 75
}
NumberAnimation {
target: flash
property: "opacity"
to: 0
duration: 75
}
}
}
MouseArea {
id:mousArea
property int drag_start_x
property int drag_start_y
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
onPressed: {
if (mouse.button == Qt.LeftButton) {
hoverEnabled = true;
var transformed_mouse = mapToItem(textContainer, mouse.x, mouse.y);
var character = Math.floor((transformed_mouse.x / fontWidth));
var line = Math.floor(transformed_mouse.y / fontHeight);
var start = Qt.point(character,line);
drag_start_x = character;
drag_start_y = line;
screen.selection.startX = character;
screen.selection.startY = line;
screen.selection.endX = character;
screen.selection.endY = line;
}
}
onPositionChanged: {
var transformed_mouse = mapToItem(textContainer, mouse.x, mouse.y);
var character = Math.floor(transformed_mouse.x / fontWidth);
var line = Math.floor(transformed_mouse.y / fontHeight);
var current_pos = Qt.point(character,line);
if (line < drag_start_y || (line === drag_start_y && character < drag_start_x)) {
screen.selection.startX = character;
screen.selection.startY = line;
screen.selection.endX = drag_start_x;
screen.selection.endY = drag_start_y;
}else {
screen.selection.startX = drag_start_x;
screen.selection.startY = drag_start_y;
screen.selection.endX = character;
screen.selection.endY = line;
}
}
onReleased: {
if (mouse.button == Qt.LeftButton) {
hoverEnabled = false;
screen.selection.sendToSelection();
}
}
onClicked: {
if (mouse.button == Qt.MiddleButton) {
screen.pasteFromSelection();
}
}
onDoubleClicked: {
if (mouse.button == Qt.LeftButton) {
var transformed_mouse = mapToItem(textContainer, mouse.x, mouse.y);
var character = Math.floor(transformed_mouse.x / fontWidth);
var line = Math.floor(transformed_mouse.y / fontHeight);
screen.doubleClicked(Qt.point(character,line));
}
}
}
}

View File

@@ -0,0 +1,81 @@
/*******************************************************************************
* Copyright (c) 2013 Jørgen Lind
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*******************************************************************************/
import QtQuick 2.0
import org.yat 1.0
ObjectDestructItem {
id: textItem
property font font
property real fontWidth
property real fontHeight
y: objectHandle.line * fontHeight;
x: objectHandle.index * fontWidth;
width: textElement.paintedWidth
height: textElement.paintedHeight
visible: objectHandle.visible
Rectangle {
anchors.fill: parent
color: objectHandle.backgroundColor
MonoText {
id: textElement
anchors.fill: parent
text: objectHandle.text
color: objectHandle.foregroundColor
font.family: textItem.font.family
font.pixelSize: textItem.font.pixelSize
font.pointSize: textItem.font.pointSize
font.bold: objectHandle.bold
font.underline: objectHandle.underline
latin: objectHandle.latin
SequentialAnimation {
running: objectHandle.blinking
loops: Animation.Infinite
onRunningChanged: {
if (running === false)
textElement.opacity = 1
}
NumberAnimation {
target: textElement
property: "opacity"
to: 0
duration: 250
}
NumberAnimation {
target: textElement
property: "opacity"
to: 1
duration: 250
}
}
}
}
}

View File

@@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (c) 2013 Jørgen Lind
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*******************************************************************************/
import QtQuick 2.0
import QtQuick.Window 2.0
Window {
id: terminalWindow
TerminalScreen {
id: terminal
anchors.fill: parent
Component.onCompleted: terminalWindow.visible = true
}
width: 800
height: 600
color: terminal.screen.defaultBackgroundColor
}