Moved to old version on yat due to crashes. Disabled scrolling due to glitches.
This commit is contained in:
@@ -28,19 +28,15 @@ Item {
|
||||
|
||||
property real characterWidth: 0
|
||||
property real characterHeight: 0
|
||||
property int screenWidth: 0
|
||||
property int screenWidth: width / characterWidth
|
||||
|
||||
property int startX
|
||||
property int startY
|
||||
|
||||
property int endX
|
||||
property int endY
|
||||
property point start
|
||||
property point end
|
||||
|
||||
property color color: "grey"
|
||||
|
||||
y: startY * characterHeight
|
||||
width: parent.width
|
||||
height: (endY - startY + 1) * characterHeight
|
||||
height: parent.height
|
||||
|
||||
opacity: 0.8
|
||||
|
||||
@@ -75,29 +71,27 @@ Item {
|
||||
onCharacterHeightChanged: calculateRectangles();
|
||||
onScreenWidthChanged: calculateRectangles();
|
||||
|
||||
onStartXChanged: calculateRectangles();
|
||||
onStartYChanged: calculateRectangles();
|
||||
onEndXChanged: calculateRectangles();
|
||||
onEndYChanged: calculateRectangles();
|
||||
onStartChanged: calculateRectangles();
|
||||
onEndChanged: calculateRectangles();
|
||||
|
||||
function calculateRectangles() {
|
||||
highlightArea.y = startY * characterHeight;
|
||||
begginning_rectangle.x = startX * characterWidth;
|
||||
if (startY === endY) {
|
||||
highlightArea.y = start.y * characterHeight;
|
||||
begginning_rectangle.x = start.x * characterWidth;
|
||||
if (start.y === end.y) {
|
||||
middle_rectangle.visible = false;
|
||||
end_rectangle.visible = false
|
||||
begginning_rectangle.width = (endX - startX) * characterWidth;
|
||||
begginning_rectangle.width = (end.x - start.x) * characterWidth;
|
||||
} else {
|
||||
begginning_rectangle.width = (screenWidth - startX) * characterWidth;
|
||||
if (startY === endY - 1) {
|
||||
begginning_rectangle.width = (screenWidth - start.x) * characterWidth;
|
||||
if (start.y === end.y - 1) {
|
||||
middle_rectangle.height = 0;
|
||||
middle_rectangle.visible = false;
|
||||
}else {
|
||||
middle_rectangle.visible = true;
|
||||
middle_rectangle.height = (endY - startY - 1) * characterHeight;
|
||||
middle_rectangle.height = (end.y - start.y - 1) * characterHeight;
|
||||
}
|
||||
end_rectangle.visible = true;
|
||||
end_rectangle.width = endX * characterWidth;
|
||||
end_rectangle.width = end.x * characterWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
*******************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.1
|
||||
|
||||
import org.yat 1.0
|
||||
|
||||
@@ -41,17 +40,6 @@ TerminalScreen {
|
||||
font.pixelSize: 20
|
||||
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();
|
||||
@@ -78,9 +66,10 @@ TerminalScreen {
|
||||
anchors.left: parent.left
|
||||
contentWidth: width
|
||||
contentHeight: textContainer.height
|
||||
interactive: true
|
||||
interactive: false
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
contentY: ((screen.contentHeight - screen.height) * screenItem.fontHeight)
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
||||
Item {
|
||||
id: textContainer
|
||||
@@ -91,22 +80,7 @@ TerminalScreen {
|
||||
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);
|
||||
@@ -156,11 +130,13 @@ TerminalScreen {
|
||||
onRequestHeightChange: {
|
||||
terminalWindow.height = newHeight * screenItem.fontHeight;
|
||||
terminalWindow.contentItem.height = newHeight * screenItem.fontHeight;
|
||||
console.log("banana");
|
||||
}
|
||||
|
||||
onRequestWidthChange: {
|
||||
terminalWindow.width = newWidth * screenItem.fontWidth;
|
||||
terminalWindow.contentItem.width = newWidth * screenItem.fontWidth;
|
||||
console.log("a");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +172,16 @@ TerminalScreen {
|
||||
}
|
||||
}
|
||||
|
||||
HighlightArea {
|
||||
characterHeight: fontHeight
|
||||
characterWidth: fontWidth
|
||||
|
||||
start: screen.selectionAreaStart
|
||||
end: screen.selectionAreaEnd
|
||||
|
||||
visible: screen.selectionEnabled
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: flash
|
||||
z: 1.2
|
||||
@@ -222,49 +208,39 @@ TerminalScreen {
|
||||
MouseArea {
|
||||
id:mousArea
|
||||
|
||||
property int drag_start_x
|
||||
property int drag_start_y
|
||||
property point drag_start
|
||||
|
||||
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 character = Math.floor((mouse.x / screen.charWidth));
|
||||
var line = Math.floor(mouse.y / screen.lineHeight);
|
||||
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;
|
||||
drag_start = start;
|
||||
screen.selectionAreaStart = start;
|
||||
screen.selectionAreaEnd = start;
|
||||
}
|
||||
}
|
||||
|
||||
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 character = Math.floor(mouse.x / screen.charWidth);
|
||||
var line = Math.floor(mouse.y / screen.lineHeight);
|
||||
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;
|
||||
if (line < drag_start.y || (line === drag_start.y && character < drag_start.x)) {
|
||||
screen.selectionAreaStart = current_pos;
|
||||
screen.selectionAreaEnd = drag_start;
|
||||
}else {
|
||||
screen.selection.startX = drag_start_x;
|
||||
screen.selection.startY = drag_start_y;
|
||||
screen.selection.endX = character;
|
||||
screen.selection.endY = line;
|
||||
screen.selectionAreaEnd = current_pos;
|
||||
screen.selectionAreaStart = drag_start;
|
||||
}
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
if (mouse.button == Qt.LeftButton) {
|
||||
hoverEnabled = false;
|
||||
screen.selection.sendToSelection();
|
||||
screen.sendSelectionToSelection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,12 +249,10 @@ TerminalScreen {
|
||||
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);
|
||||
var character = Math.floor(mouse.x / screen.charWidth);
|
||||
var line = Math.floor(mouse.y / screen.lineHeight);
|
||||
screen.doubleClicked(Qt.point(character,line));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@ ObjectDestructItem {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "black" //objectHandle.backgroundColor
|
||||
color: "black"
|
||||
|
||||
MonoText {
|
||||
id: textElement
|
||||
anchors.fill: parent
|
||||
text: objectHandle.text
|
||||
color: "white" //objectHandle.foregroundColor
|
||||
color: "white"
|
||||
font.family: textItem.font.family
|
||||
font.pixelSize: textItem.font.pixelSize
|
||||
font.pointSize: textItem.font.pointSize
|
||||
|
||||
@@ -30,7 +30,7 @@ import QtQuick.Controls 1.0
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
ApplicationWindow{
|
||||
id: mainwindow
|
||||
id: terminalWindow
|
||||
width: 1024
|
||||
height: 768
|
||||
|
||||
@@ -48,7 +48,7 @@ ApplicationWindow{
|
||||
text: qsTr("Settings")
|
||||
onTriggered: {
|
||||
var component = Qt.createComponent("SettingsWindow.qml");
|
||||
component.createObject(mainwindow);
|
||||
component.createObject(terminalWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user