},
__handleHotkey: function(x) {
var success = false;
- if(!x.alt || x.control) {
+ if(!x.alt && !x.control && !x.shift && !x.meta) {
if((x.key == "backspace" || x.key == "/") && !this.getInputFocused(x)) {
success = true;
}
+ } else if(!x.alt || x.control || x.meta) {
+ /* do nothing */
} else if(x.key == "a" || x.key == "A") {
var highestNum = 0;
var highestIndex = -1;
}
if(highestIndex > -1)
this.selectWindow(this.windowArray[highestIndex]);
- } else if(x.key >= '0' && x.key <= '9') {
+ } else if((x.key >= '0' && x.key <= '9') && !x.shift) {
success = true;
number = x.key - '0';
return;
this.selectWindow(this.windowArray[number]);
- } else if(x.key == "left") {
+ } else if((x.key == "left" || x.key == "up") && !x.shift) {
this.prevWindow();
success = true;
- } else if(x.key == "right") {
+ } else if((x.key == "right" || x.key == "down") && !x.shift) {
this.nextWindow();
success = true;
}
+
if(success) {
new Event(x).stop();
x.preventDefault();
return null;
},
- tabComplete: function(element) {
- this.tabCompleter.tabComplete(element);
+ tabComplete: function(element, backwards) {
+ this.tabCompleter.tabComplete(element, backwards);
},
resetTabComplete: function() {
this.tabCompleter.reset();
new Event(e).stop();
sendInput();
});
-
- inputbox.addEvent("focus", this.resetTabComplete.bind(this));
- inputbox.addEvent("mousedown", this.resetTabComplete.bind(this));
-
+
+ var reset = this.resetTabComplete.bind(this);
+ inputbox.addEvent("focus", reset);
+ inputbox.addEvent("mousedown", reset);
+ inputbox.addEvent("keypress", reset);
+
inputbox.addEvent("keydown", function(e) {
var resultfn;
var cvalue = inputbox.value;
-
- if(e.key == "up") {
+
+ if(e.alt || e.control || e.meta)
+ return;
+
+ if(e.key == "up" && !e.shift) {
resultfn = this.commandhistory.upLine;
- } else if(e.key == "down") {
+ } else if(e.key == "down" && !e.shift) {
resultfn = this.commandhistory.downLine;
- } else if(e.key == "tab" && !e.altKey && !e.ctrlKey && !e.shiftKey) {
+ } else if(e.key == "tab") {
+ this.tabComplete(inputbox, e.shift);
+
new Event(e).stop();
- this.tabComplete(inputbox);
+ e.preventDefault();
return;
} else {
- /* ideally alt and other keys wouldn't break this */
- this.resetTabComplete();
return;
}
var result = resultfn.bind(this.commandhistory)();
new Event(e).stop();
+ e.preventDefault();
+
if(!result)
result = "";
this.lastcvalue = result;
this.ui = ui;
this.reset();
},
- tabComplete: function(textBox) {
+ tabComplete: function(textBox, backwards) {
var text = textBox.value;
if(!$defined(this.obj)) {
return;
}
- var r = this.obj.get();
+ var r = this.obj.get(backwards);
if(!$defined(r))
return;
* ideally next would do the list gubbins recursively, but no JS engine currently
* support tail recursion :(
*/
- if(!$defined(this.list))
+ if(!$defined(this.list) || this.list.length == 0)
return null;
this.pos = this.pos + 1;
if(this.pos >= this.list.length)
this.pos = 0;
+ return this.list[this.pos];
+ },
+ prev: function() {
+ if(!$defined(this.list) || this.list.length == 0)
+ return null;
+
+ this.pos = this.pos - 1;
+ if(this.pos < 0)
+ this.pos = this.list.length - 1;
+
return this.list[this.pos];
}
});
this.suffix = suffix;
this.iterator = new qwebirc.ui.TabIterator(client, existingNick, list);
},
- get: function() {
- var n = this.iterator.next();
+ get: function(backwards) {
+ var n = backwards ? this.iterator.prev() : this.iterator.next();
if(!$defined(n))
return null;