Auto-indent new line in sendbox
This commit is contained in:
		
							
								
								
									
										3
									
								
								TODO.md
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								TODO.md
									
									
									
									
									
								
							| @@ -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 | ||||
|   | ||||
| @@ -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) | ||||
|                 }) | ||||
|             } | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	