mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-21 18:50:47 +03:00
Open completer on tab
This commit is contained in:
parent
08e9461611
commit
b7505fe562
2 changed files with 30 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -57,6 +57,7 @@ ui_*.h
|
|||
# Vim
|
||||
*.swp
|
||||
*.swo
|
||||
*.swn
|
||||
|
||||
#####=== CMake ===#####
|
||||
|
||||
|
|
|
@ -75,6 +75,13 @@ Rectangle {
|
|||
textArea.insert(cursorPosition, completion);
|
||||
}
|
||||
|
||||
function openCompleter(pos, type) {
|
||||
completerTriggeredAt = pos;
|
||||
popup.completerName = type;
|
||||
popup.open();
|
||||
popup.completer.setSearchString(textArea.getText(completerTriggeredAt, cursorPosition));
|
||||
}
|
||||
|
||||
placeholderText: qsTr("Write a message...")
|
||||
placeholderTextColor: colors.buttonText
|
||||
color: colors.text
|
||||
|
@ -106,12 +113,10 @@ Rectangle {
|
|||
} else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_N) {
|
||||
textArea.text = TimelineManager.timeline.input.nextText();
|
||||
} else if (event.key == Qt.Key_At) {
|
||||
completerTriggeredAt = cursorPosition;
|
||||
popup.completerName = "user";
|
||||
textArea.openCompleter(cursorPosition, "user");
|
||||
popup.open();
|
||||
} else if (event.key == Qt.Key_Colon) {
|
||||
completerTriggeredAt = cursorPosition;
|
||||
popup.completerName = "emoji";
|
||||
textArea.openCompleter(cursorPosition, "emoji");
|
||||
popup.open();
|
||||
} else if (event.key == Qt.Key_Escape && popup.opened) {
|
||||
completerTriggeredAt = -1;
|
||||
|
@ -132,9 +137,27 @@ Rectangle {
|
|||
TimelineManager.timeline.input.send();
|
||||
textArea.clear();
|
||||
event.accepted = true;
|
||||
} else if (event.key == Qt.Key_Tab && popup.opened) {
|
||||
} else if (event.key == Qt.Key_Tab) {
|
||||
event.accepted = true;
|
||||
popup.down();
|
||||
if (popup.opened) {
|
||||
popup.up();
|
||||
} else {
|
||||
var pos = cursorPosition - 1;
|
||||
while (pos > -1) {
|
||||
var t = textArea.getText(pos, pos + 1);
|
||||
console.log('"' + t + '"');
|
||||
if (t == '@' || t == ' ' || t == '\t') {
|
||||
textArea.openCompleter(pos, "user");
|
||||
return ;
|
||||
} else if (t == ':') {
|
||||
textArea.openCompleter(pos, "emoji");
|
||||
return ;
|
||||
}
|
||||
pos = pos - 1;
|
||||
}
|
||||
// At start of input
|
||||
textArea.openCompleter(0, "user");
|
||||
}
|
||||
} else if (event.key == Qt.Key_Up && popup.opened) {
|
||||
event.accepted = true;
|
||||
popup.up();
|
||||
|
|
Loading…
Reference in a new issue