mirror of
https://github.com/thelounge/thelounge
synced 2024-11-23 04:23:13 +00:00
Autocomplete bracket and quote characters like in a modern IDE
This commit is contained in:
parent
51696ed813
commit
051f6c5a7f
1 changed files with 23 additions and 0 deletions
|
@ -127,6 +127,29 @@ for (const hotkey in colorsHotkeys) {
|
|||
});
|
||||
}
|
||||
|
||||
// Autocomplete bracket and quote characters like in a modern IDE
|
||||
// For example, select `text`, press `[` key, and it becomes `[text]`
|
||||
const bracketWraps = {
|
||||
'"': '"',
|
||||
"'": "'",
|
||||
"(": ")",
|
||||
"<": ">",
|
||||
"[": "]",
|
||||
"{": "}",
|
||||
"*": "*",
|
||||
"`": "`",
|
||||
"~": "~",
|
||||
_: "_",
|
||||
};
|
||||
|
||||
inputTrap.bind(Object.keys(bracketWraps), function(e) {
|
||||
if (e.target.selectionStart !== e.target.selectionEnd) {
|
||||
wrapCursor(e.target, e.key, bracketWraps[e.key]);
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Ignored keys which should not automatically focus the input bar
|
||||
const ignoredKeys = {
|
||||
8: true, // Backspace
|
||||
|
|
Loading…
Reference in a new issue