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;
qwebirc.ui.QueryNickTabCompleter = new Class({
Extends: qwebirc.ui.BaseTabCompleter,
initialize: function(prefix, existingText, suffix, window) {
- nick = window.name
+ var nick = window.name
this.parent(window.client, prefix, existingText, suffix, [nick]);
}
});
Extends: qwebirc.ui.BaseTabCompleter,
initialize: function(prefix, existingText, suffix, window) {
- /* WTB map */
- var l = [];
- var wa = window.parentObject.windows[window.parentObject.getClientId(window.client)];
-
- for(var c in window.client.channels) {
- var w = wa[c];
+ var wa = window.parentObject.windows.get(window.parentObject.getClientId(window.client));
+ var l = window.client.channels.map(function(c) {
+ var w = wa.get(c);
/* redundant? */
if($defined(w))
w = w.lastSelected;
- l.push([w, c]);
- }
+ return [w, c];
+ });
l.sort(function(a, b) {
return b[0] - a[0];
qwebirc.ui.ChannelUsersTabCompleter = new Class({
Extends: qwebirc.ui.BaseTabCompleter,
initialize: function(prefix, existingText, suffix, window) {
- var nc = window.client.tracker.getSortedByLastSpoke(window.name);
+ var nc = window.client.tracker.getSortedByLastSpokePrefix(window.name);
this.parent(window.client, prefix, existingText, suffix, nc);
}