Auto-indent new line in sendbox

This commit is contained in:
miruka 2019-07-21 19:12:32 -04:00
parent 67e06aa739
commit 4c7815554c
2 changed files with 15 additions and 4 deletions

View File

@ -14,16 +14,15 @@
- When qml syntax highlighting supports string interpolation, use them
- Fixes
- `<hr>`, need to add width attribute
- Keyboard flicking against top/bottom edge
- Don't strip user spacing in html
- Past events loading (limit 100) freezes the GUI - need to move upsert func
to a WorkerScript
- `MessageDelegate.qml:63: TypeError: 'reloadPreviousItem' not a function`
- Horrible performance for big rooms
- [hr not working](https://bugreports.qt.io/browse/QTBUG-74342)
- UI
- mod+enter in sendbox: respect previous line indent
- When reduced, show the full-window sidepane instead of Default page
- Adapt shortcuts flicking speed to font size and DPI
- Show error box if uploading avatar fails

View File

@ -8,6 +8,8 @@ import "../Base"
HRectangle {
function setFocus() { areaScrollView.forceActiveFocus() }
property string indent: " "
property var aliases: window.settings.writeAliases
property string writingUserId: chatPage.userId
property string toSend: ""
@ -40,6 +42,7 @@ HRectangle {
id: areaScrollView
placeholderText: qsTr("Type a message...")
backgroundColor: "transparent"
area.tabStopDistance: 4 * 4 // 4 spaces
area.focus: true
function setTyping(typing) {
@ -109,7 +112,16 @@ HRectangle {
event.modifiers & Qt.ControlModifier ||
event.modifiers & Qt.AltModifier)
{
textArea.insert(textArea.cursorPosition, "\n")
let line = textArea.text.split("\n").slice(-1)[0]
let indents = 0
for (let part of line.split(indent)) {
if (part) { break }
indents += 1
}
let add = indent.repeat(indents)
textArea.insert(textArea.cursorPosition, "\n" + add)
return
}
@ -124,7 +136,7 @@ HRectangle {
area.Keys.onEnterPressed.connect(area.Keys.onReturnPressed)
area.Keys.onTabPressed.connect(event => {
textArea.insert(textArea.cursorPosition, " ")
textArea.insert(textArea.cursorPosition, indent)
})
}
}