client: support shift+tab to autocomplete backward

This commit is contained in:
mappu 2017-02-05 18:29:44 +13:00
parent ade4439f92
commit 3f077f15f0

View File

@ -514,7 +514,7 @@ var writerFor = function(username) {
var tabcomplete_state = ''; var tabcomplete_state = '';
var tabcompletion_start = function() { var tabcompletion_start = function(direction) {
var cursor = $("#chatbox").value.replace(/^.*\s([^\s]+)$/, '$1'); var cursor = $("#chatbox").value.replace(/^.*\s([^\s]+)$/, '$1');
@ -548,7 +548,7 @@ var tabcompletion_start = function() {
} }
} }
var targetName = match[(i + 1) % match.length]; var targetName = match[negmod(i + direction, match.length)];
// Replace in textbox // Replace in textbox
@ -825,7 +825,7 @@ window.onload = function() {
$("#chatbox").onkeydown = function(ev) { $("#chatbox").onkeydown = function(ev) {
if (ev.keyCode === 9 /* Tab */) { if (ev.keyCode === 9 /* Tab */) {
tabcompletion_start(); tabcompletion_start( ev.shiftKey ? -1 : 1 );
ev.preventDefault(); ev.preventDefault();
return false; return false;