mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-10-30 22:54:21 +00:00 
			
		
		
		
	Moved to new version of yat. Yat is no longer a submodule but is now integrated.
This commit is contained in:
		
							
								
								
									
										4
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +0,0 @@ | |||||||
| [submodule "yat"] |  | ||||||
| 	path = yat |  | ||||||
| 	url = https://github.com/Swordifish90/yat |  | ||||||
| 	branch = stable |  | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| QT += widgets quick | QT += widgets quick core-private gui-private qml-private quick quick-private | ||||||
|  |  | ||||||
| include(yat/yat_declarative/yat_declarative.pro) | include(yat/yat_declarative/yat_declarative.pro) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,3 +1,26 @@ | |||||||
|  | /******************************************************************************* | ||||||
|  | * 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 2.0 | ||||||
|  |  | ||||||
| Item { | Item { | ||||||
| @@ -5,15 +28,19 @@ Item { | |||||||
|  |  | ||||||
|     property real characterWidth: 0 |     property real characterWidth: 0 | ||||||
|     property real characterHeight: 0 |     property real characterHeight: 0 | ||||||
|     property int screenWidth: width / characterWidth |     property int screenWidth: 0 | ||||||
|  |  | ||||||
|     property point start |     property int startX | ||||||
|     property point end |     property int startY | ||||||
|  |  | ||||||
|  |     property int endX | ||||||
|  |     property int endY | ||||||
|  |  | ||||||
|     property color color: "grey" |     property color color: "grey" | ||||||
|  |  | ||||||
|  |     y: startY * characterHeight | ||||||
|     width: parent.width |     width: parent.width | ||||||
|     height: parent.height |     height: (endY - startY + 1) * characterHeight | ||||||
|  |  | ||||||
|     opacity: 0.8 |     opacity: 0.8 | ||||||
|  |  | ||||||
| @@ -48,27 +75,29 @@ Item { | |||||||
|     onCharacterHeightChanged: calculateRectangles(); |     onCharacterHeightChanged: calculateRectangles(); | ||||||
|     onScreenWidthChanged: calculateRectangles(); |     onScreenWidthChanged: calculateRectangles(); | ||||||
|  |  | ||||||
|     onStartChanged: calculateRectangles(); |     onStartXChanged: calculateRectangles(); | ||||||
|     onEndChanged: calculateRectangles(); |     onStartYChanged: calculateRectangles(); | ||||||
|  |     onEndXChanged: calculateRectangles(); | ||||||
|  |     onEndYChanged: calculateRectangles(); | ||||||
|  |  | ||||||
|     function calculateRectangles() { |     function calculateRectangles() { | ||||||
|         highlightArea.y = start.y * characterHeight; |         highlightArea.y = startY * characterHeight; | ||||||
|         begginning_rectangle.x = start.x * characterWidth; |         begginning_rectangle.x = startX * characterWidth; | ||||||
|         if (start.y === end.y) { |         if (startY === endY) { | ||||||
|             middle_rectangle.visible = false; |             middle_rectangle.visible = false; | ||||||
|             end_rectangle.visible = false |             end_rectangle.visible = false | ||||||
|             begginning_rectangle.width = (end.x - start.x) * characterWidth; |             begginning_rectangle.width = (endX - startX) * characterWidth; | ||||||
|         } else { |         } else { | ||||||
|             begginning_rectangle.width = (screenWidth - start.x) * characterWidth; |             begginning_rectangle.width = (screenWidth - startX) * characterWidth; | ||||||
|             if (start.y === end.y - 1) { |             if (startY === endY - 1) { | ||||||
|                 middle_rectangle.height = 0; |                 middle_rectangle.height = 0; | ||||||
|                 middle_rectangle.visible = false; |                 middle_rectangle.visible = false; | ||||||
|             }else { |             }else { | ||||||
|                 middle_rectangle.visible = true; |                 middle_rectangle.visible = true; | ||||||
|                 middle_rectangle.height = (end.y - start.y - 1) * characterHeight; |                 middle_rectangle.height = (endY - startY - 1) * characterHeight; | ||||||
|             } |             } | ||||||
|             end_rectangle.visible = true; |             end_rectangle.visible = true; | ||||||
|             end_rectangle.width = end.x * characterWidth; |             end_rectangle.width = endX * characterWidth; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										66
									
								
								qml/cool-old-term/TerminalCursor.qml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								qml/cool-old-term/TerminalCursor.qml
									
									
									
									
									
										Normal 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); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| @@ -1,4 +1,28 @@ | |||||||
|  | /******************************************************************************* | ||||||
|  | * 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 2.0 | ||||||
|  | import QtQuick.Controls 1.1 | ||||||
|  |  | ||||||
| import org.yat 1.0 | import org.yat 1.0 | ||||||
|  |  | ||||||
| @@ -10,10 +34,35 @@ TerminalScreen { | |||||||
|     property real fontHeight: fontMetricText.paintedHeight |     property real fontHeight: fontMetricText.paintedHeight | ||||||
|  |  | ||||||
|     property var lineComponent : Qt.createComponent("TerminalLine.qml") |     property var lineComponent : Qt.createComponent("TerminalLine.qml") | ||||||
|  |     property var textComponent : Qt.createComponent("TerminalText.qml") | ||||||
|  |     property var cursorComponent : Qt.createComponent("TerminalCursor.qml") | ||||||
|  |  | ||||||
|     font.family: "Pet Me" |     font.family: "Pet Me" | ||||||
|     font.pointSize: 14 |     font.pixelSize: 20 | ||||||
|     //font.bold: true |     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 { |     Text { | ||||||
|         id: fontMetricText |         id: fontMetricText | ||||||
| @@ -23,10 +72,47 @@ TerminalScreen { | |||||||
|         textFormat: Text.PlainText |         textFormat: Text.PlainText | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     Rectangle { |     Flickable { | ||||||
|         id: background |         id: flickable | ||||||
|         anchors.fill: parent |         anchors.top: parent.top | ||||||
|         color: "black" |         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 { |     Connections { | ||||||
| @@ -38,24 +124,44 @@ TerminalScreen { | |||||||
|             flashAnimation.start() |             flashAnimation.start() | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         onCursorPositionChanged: { |  | ||||||
|             cursor.x = x * fontWidth; |  | ||||||
|             cursor.y = y * fontHeight; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         onReset: { |         onReset: { | ||||||
|             resetScreenItems(); |             resetScreenItems(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         onLineCreated: { |         onTextCreated: { | ||||||
|             var lineVariable = lineComponent.createObject(screenItem, |             var textSegment = textComponent.createObject(screenItem, | ||||||
|                 { |                 { | ||||||
|                     "objectHandle" : line, |                     "parent" : background, | ||||||
|                     "font": screenItem.font, |                     "objectHandle" : text, | ||||||
|  |                     "font" : screenItem.font, | ||||||
|                     "fontWidth" : screenItem.fontWidth, |                     "fontWidth" : screenItem.fontWidth, | ||||||
|                     "fontHeight" : screenItem.fontHeight, |                     "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: { |     onFontChanged: { | ||||||
| @@ -77,6 +183,7 @@ TerminalScreen { | |||||||
|     function setTerminalWidth() { |     function setTerminalWidth() { | ||||||
|         if (fontWidth > 0) { |         if (fontWidth > 0) { | ||||||
|             var pty_width = Math.floor(width / fontWidth); |             var pty_width = Math.floor(width / fontWidth); | ||||||
|  |             flickable.width = pty_width * fontWidth; | ||||||
|             screen.width = pty_width; |             screen.width = pty_width; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -84,50 +191,16 @@ TerminalScreen { | |||||||
|     function setTerminalHeight() { |     function setTerminalHeight() { | ||||||
|         if (fontHeight > 0) { |         if (fontHeight > 0) { | ||||||
|             var pty_height = Math.floor(height / fontHeight); |             var pty_height = Math.floor(height / fontHeight); | ||||||
|  |             flickable.height = pty_height * fontHeight; | ||||||
|             screen.height = pty_height; |             screen.height = pty_height; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     Item { |  | ||||||
|         id: keyHandler |  | ||||||
|         focus: true |  | ||||||
|         Keys.onPressed: { |  | ||||||
|             terminal.screen.sendKey(event.text, event.key, event.modifiers); |  | ||||||
|             if (event.text === "?") { |  | ||||||
|                 terminal.screen.printScreen() |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     HighlightArea { |  | ||||||
|         characterHeight: fontHeight |  | ||||||
|         characterWidth: fontWidth |  | ||||||
|  |  | ||||||
|         start: screen.selectionAreaStart |  | ||||||
|         end: screen.selectionAreaEnd |  | ||||||
|  |  | ||||||
|         visible: screen.selectionEnabled |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     Rectangle { |  | ||||||
|         id: cursor |  | ||||||
|         width: fontWidth |  | ||||||
|         height: fontHeight |  | ||||||
|         x: 0 |  | ||||||
|         y: 0 |  | ||||||
|         color: "white" |  | ||||||
| //        SequentialAnimation on opacity{ |  | ||||||
| //            NumberAnimation{from: 0; to: 1; duration: 500} |  | ||||||
| //            NumberAnimation{from: 1; to: 0; duration: 500} |  | ||||||
| //            loops: Animation.Infinite |  | ||||||
| //        } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     Rectangle { |     Rectangle { | ||||||
|         id: flash |         id: flash | ||||||
|  |         z: 1.2 | ||||||
|         anchors.fill: parent |         anchors.fill: parent | ||||||
|         color: "white" |         color: "grey" | ||||||
|         opacity: 0 |         opacity: 0 | ||||||
|         SequentialAnimation { |         SequentialAnimation { | ||||||
|             id: flashAnimation |             id: flashAnimation | ||||||
| @@ -149,39 +222,49 @@ TerminalScreen { | |||||||
|     MouseArea { |     MouseArea { | ||||||
|         id:mousArea |         id:mousArea | ||||||
|  |  | ||||||
|         property point drag_start |         property int drag_start_x | ||||||
|  |         property int drag_start_y | ||||||
|  |  | ||||||
|         anchors.fill: parent |         anchors.fill: parent | ||||||
|         acceptedButtons: Qt.LeftButton | Qt.MiddleButton |         acceptedButtons: Qt.LeftButton | Qt.MiddleButton | ||||||
|         onPressed: { |         onPressed: { | ||||||
|             if (mouse.button == Qt.LeftButton) { |             if (mouse.button == Qt.LeftButton) { | ||||||
|                 hoverEnabled = true; |                 hoverEnabled = true; | ||||||
|                 var character = Math.floor((mouse.x / screen.charWidth)); |                 var transformed_mouse = mapToItem(textContainer, mouse.x, mouse.y); | ||||||
|                 var line = Math.floor(mouse.y / screen.lineHeight); |                 var character = Math.floor((transformed_mouse.x / fontWidth)); | ||||||
|  |                 var line = Math.floor(transformed_mouse.y / fontHeight); | ||||||
|                 var start = Qt.point(character,line); |                 var start = Qt.point(character,line); | ||||||
|                 drag_start = start; |                 drag_start_x = character; | ||||||
|                 screen.selectionAreaStart = start; |                 drag_start_y = line; | ||||||
|                 screen.selectionAreaEnd = start; |                 screen.selection.startX = character; | ||||||
|  |                 screen.selection.startY = line; | ||||||
|  |                 screen.selection.endX = character; | ||||||
|  |                 screen.selection.endY = line; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         onPositionChanged: { |         onPositionChanged: { | ||||||
|             var character = Math.floor(mouse.x / screen.charWidth); |             var transformed_mouse = mapToItem(textContainer, mouse.x, mouse.y); | ||||||
|             var line = Math.floor(mouse.y / screen.lineHeight); |             var character = Math.floor(transformed_mouse.x / fontWidth); | ||||||
|  |             var line = Math.floor(transformed_mouse.y / fontHeight); | ||||||
|             var current_pos = Qt.point(character,line); |             var current_pos = Qt.point(character,line); | ||||||
|             if (line < drag_start.y || (line === drag_start.y && character < drag_start.x)) { |             if (line < drag_start_y || (line === drag_start_y && character < drag_start_x)) { | ||||||
|                 screen.selectionAreaStart = current_pos; |                 screen.selection.startX = character; | ||||||
|                 screen.selectionAreaEnd = drag_start; |                 screen.selection.startY = line; | ||||||
|  |                 screen.selection.endX = drag_start_x; | ||||||
|  |                 screen.selection.endY = drag_start_y; | ||||||
|             }else { |             }else { | ||||||
|                 screen.selectionAreaEnd = current_pos; |                 screen.selection.startX = drag_start_x; | ||||||
|                 screen.selectionAreaStart = drag_start; |                 screen.selection.startY = drag_start_y; | ||||||
|  |                 screen.selection.endX = character; | ||||||
|  |                 screen.selection.endY = line; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         onReleased: { |         onReleased: { | ||||||
|             if (mouse.button == Qt.LeftButton) { |             if (mouse.button == Qt.LeftButton) { | ||||||
|                 hoverEnabled = false; |                 hoverEnabled = false; | ||||||
|                 screen.sendSelectionToSelection(); |                 screen.selection.sendToSelection(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -190,10 +273,12 @@ TerminalScreen { | |||||||
|                 screen.pasteFromSelection(); |                 screen.pasteFromSelection(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         onDoubleClicked: { |         onDoubleClicked: { | ||||||
|             if (mouse.button == Qt.LeftButton) { |             if (mouse.button == Qt.LeftButton) { | ||||||
|                 var character = Math.floor(mouse.x / screen.charWidth); |                 var transformed_mouse = mapToItem(textContainer, mouse.x, mouse.y); | ||||||
|                 var line = Math.floor(mouse.y / screen.lineHeight); |                 var character = Math.floor(transformed_mouse.x / fontWidth); | ||||||
|  |                 var line = Math.floor(transformed_mouse.y / fontHeight); | ||||||
|                 screen.doubleClicked(Qt.point(character,line)); |                 screen.doubleClicked(Qt.point(character,line)); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -29,9 +29,10 @@ ObjectDestructItem { | |||||||
|     id: textItem |     id: textItem | ||||||
|     property font font |     property font font | ||||||
|     property real fontWidth |     property real fontWidth | ||||||
|  |     property real fontHeight | ||||||
|  |  | ||||||
|     y: 0 |     y: objectHandle.line * fontHeight; | ||||||
|     x: 0 |     x: objectHandle.index * fontWidth; | ||||||
|  |  | ||||||
|     width: textElement.paintedWidth |     width: textElement.paintedWidth | ||||||
|     height: textElement.paintedHeight |     height: textElement.paintedHeight | ||||||
| @@ -40,39 +41,41 @@ ObjectDestructItem { | |||||||
|  |  | ||||||
|     Rectangle { |     Rectangle { | ||||||
|         anchors.fill: parent |         anchors.fill: parent | ||||||
|         color: textItem.objectHandle.backgroundColor |         color: "black" //objectHandle.backgroundColor | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |         MonoText { | ||||||
|  |             id: textElement | ||||||
|  |             anchors.fill: parent | ||||||
|  |             text: objectHandle.text | ||||||
|  |             color: "white" //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 | ||||||
|  |  | ||||||
|     Text { |             SequentialAnimation { | ||||||
|         id: textElement |                 running: objectHandle.blinking | ||||||
|         anchors.fill: parent |                 loops: Animation.Infinite | ||||||
|         text: objectHandle.text |                 onRunningChanged: { | ||||||
|         color: "white" |                     if (running === false) | ||||||
|         font: textItem.font |                         textElement.opacity = 1 | ||||||
|         textFormat: Text.PlainText |                 } | ||||||
|     } |                 NumberAnimation { | ||||||
|  |                     target: textElement | ||||||
|     Connections { |                     property: "opacity" | ||||||
|         target: objectHandle |                     to: 0 | ||||||
|  |                     duration: 250 | ||||||
|         onIndexChanged: { |                 } | ||||||
|             textItem.x = objectHandle.index *  textItem.fontWidth; |                 NumberAnimation { | ||||||
|  |                     target: textElement | ||||||
|  |                     property: "opacity" | ||||||
|  |                     to: 1 | ||||||
|  |                     duration: 250 | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     //Component.onCompleted: { |  | ||||||
|     //    //color = randomBg(); |  | ||||||
|     //} |  | ||||||
|     //function randomBg() |  | ||||||
|     //{ |  | ||||||
|     //    var hex1=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F") |  | ||||||
|     //        var hex2=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F") |  | ||||||
|     //        var hex3=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F") |  | ||||||
|     //        var hex4=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F") |  | ||||||
|     //        var hex5=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F") |  | ||||||
|     //        var hex6=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F") |  | ||||||
|     //        var bg="#"+hex1[Math.floor(Math.random()*hex1.length)]+hex2[Math.floor(Math.random()*hex2.length)]+hex3[Math.floor(Math.random()*hex3.length)]+hex4[Math.floor(Math.random()*hex4.length)]+hex5[Math.floor(Math.random()*hex5.length)]+hex6[Math.floor(Math.random()*hex6.length)] |  | ||||||
|     //        return bg |  | ||||||
|     //} |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -229,13 +229,12 @@ ApplicationWindow{ | |||||||
|  |  | ||||||
|         TerminalScreen { |         TerminalScreen { | ||||||
|             id: terminal |             id: terminal | ||||||
|             anchors.centerIn: parent |             anchors.fill: parent | ||||||
|             width: mainwindow.width |  | ||||||
|             height: mainwindow.height |  | ||||||
|             visible: false |  | ||||||
|  |  | ||||||
|             //FIXME: Ugly forced clear terminal at the beginning |             //FIXME: Ugly forced clear terminal at the beginning | ||||||
|             Component.onCompleted: terminal.screen.sendKey("l", 76, 67108864); |             Component.onCompleted: { | ||||||
|  |                 terminal.screen.sendKey("l", 76, 67108864); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         RadialGradient{ |         RadialGradient{ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user