|
@ -4,78 +4,76 @@ import QtQuick.Layouts 1.0 |
|
|
import QtQuick.Controls 1.0 |
|
|
import QtQuick.Controls 1.0 |
|
|
import QtQuick.Controls.Styles 1.1 |
|
|
import QtQuick.Controls.Styles 1.1 |
|
|
|
|
|
|
|
|
Component { |
|
|
Item { |
|
|
Item { |
|
|
signal editorTextChanged |
|
|
signal editorTextChanged |
|
|
|
|
|
|
|
|
|
|
|
function setText(text) { |
|
|
function setText(text) { |
|
|
codeEditor.text = text; |
|
|
codeEditor.text = text; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function getText() { |
|
|
function getText() { |
|
|
return codeEditor.text; |
|
|
return codeEditor.text; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
anchors.fill: parent |
|
|
anchors.fill: parent |
|
|
id: contentView |
|
|
id: contentView |
|
|
width: parent.width |
|
|
width: parent.width |
|
|
height: parent.height * 0.7 |
|
|
height: parent.height * 0.7 |
|
|
Rectangle { |
|
|
Rectangle { |
|
|
id: lineColumn |
|
|
id: lineColumn |
|
|
property int rowHeight: codeEditor.font.pixelSize + 3 |
|
|
property int rowHeight: codeEditor.font.pixelSize + 3 |
|
|
color: "#202020" |
|
|
color: "#202020" |
|
|
width: 50 |
|
|
width: 50 |
|
|
height: parent.height |
|
|
height: parent.height |
|
|
Column { |
|
|
Column { |
|
|
y: -codeEditor.flickableItem.contentY + 4 |
|
|
y: -codeEditor.flickableItem.contentY + 4 |
|
|
width: parent.width |
|
|
width: parent.width |
|
|
Repeater { |
|
|
Repeater { |
|
|
model: Math.max(codeEditor.lineCount + 2, (lineColumn.height/lineColumn.rowHeight)) |
|
|
model: Math.max(codeEditor.lineCount + 2, (lineColumn.height/lineColumn.rowHeight)) |
|
|
delegate: Text { |
|
|
delegate: Text { |
|
|
id: text |
|
|
id: text |
|
|
color: codeEditor.textColor |
|
|
color: codeEditor.textColor |
|
|
font: codeEditor.font |
|
|
font: codeEditor.font |
|
|
width: lineColumn.width - 4 |
|
|
width: lineColumn.width - 4 |
|
|
horizontalAlignment: Text.AlignRight |
|
|
horizontalAlignment: Text.AlignRight |
|
|
verticalAlignment: Text.AlignVCenter |
|
|
verticalAlignment: Text.AlignVCenter |
|
|
height: lineColumn.rowHeight |
|
|
height: lineColumn.rowHeight |
|
|
renderType: Text.NativeRendering |
|
|
renderType: Text.NativeRendering |
|
|
text: index + 1 |
|
|
text: index + 1 |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
TextArea { |
|
|
TextArea { |
|
|
id: codeEditor |
|
|
id: codeEditor |
|
|
textColor: "#EEE8D5" |
|
|
textColor: "#EEE8D5" |
|
|
style: TextAreaStyle { |
|
|
style: TextAreaStyle { |
|
|
backgroundColor: "#002B36" |
|
|
backgroundColor: "#002B36" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
anchors.left: lineColumn.right |
|
|
anchors.left: lineColumn.right |
|
|
anchors.right: parent.right |
|
|
anchors.right: parent.right |
|
|
anchors.top: parent.top |
|
|
anchors.top: parent.top |
|
|
anchors.bottom: parent.bottom |
|
|
anchors.bottom: parent.bottom |
|
|
wrapMode: TextEdit.NoWrap |
|
|
wrapMode: TextEdit.NoWrap |
|
|
frameVisible: false |
|
|
frameVisible: false |
|
|
|
|
|
|
|
|
height: parent.height |
|
|
height: parent.height |
|
|
font.family: "Monospace" |
|
|
font.family: "Monospace" |
|
|
font.pointSize: 12 |
|
|
font.pointSize: 12 |
|
|
width: parent.width |
|
|
width: parent.width |
|
|
|
|
|
|
|
|
tabChangesFocus: false |
|
|
tabChangesFocus: false |
|
|
Keys.onPressed: { |
|
|
Keys.onPressed: { |
|
|
if (event.key === Qt.Key_Tab) { |
|
|
if (event.key === Qt.Key_Tab) { |
|
|
codeEditor.insert(codeEditor.cursorPosition, "\t"); |
|
|
codeEditor.insert(codeEditor.cursorPosition, "\t"); |
|
|
event.accepted = true; |
|
|
event.accepted = true; |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
onTextChanged: { |
|
|
|
|
|
editorTextChanged(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
onTextChanged: { |
|
|
|
|
|
editorTextChanged(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|