}\r
\r
(function () {\r
- var tokens = inp_val.substring(0, inp[0].selectionStart).split(' '),\r
- val,\r
- p1,\r
- newnick,\r
- range,\r
- nick = tokens[tokens.length - 1];\r
+ var tokens, // Words before the cursor position\r
+ val, // New value being built up\r
+ p1, // Position in the value just before the nick \r
+ newnick, // New nick to be displayed (cycles through)\r
+ range, // TextRange for setting new text cursor position\r
+ nick, // Current nick in the value\r
+ trailing = ': '; // Text to be inserted after a tabbed nick\r
+\r
+ tokens = inp_val.substring(0, inp[0].selectionStart).split(' ');\r
+ if (tokens[tokens.length-1] == ':')\r
+ tokens.pop();\r
+\r
+ nick = tokens[tokens.length - 1];\r
+\r
if (this.tabcomplete.prefix === '') {\r
this.tabcomplete.prefix = nick;\r
}\r
});\r
\r
if (this.tabcomplete.data.length > 0) {\r
+ // Get the current value before cursor position\r
p1 = inp[0].selectionStart - (nick.length);\r
val = inp_val.substr(0, p1);\r
+\r
+ // Include the current selected nick\r
newnick = this.tabcomplete.data.shift();\r
this.tabcomplete.data.push(newnick);\r
val += newnick;\r
+\r
+ if (inp_val.substr(inp[0].selectionStart, 2) !== trailing)\r
+ val += trailing;\r
+\r
+ // Now include the rest of the current value\r
val += inp_val.substr(inp[0].selectionStart);\r
+\r
inp.val(val);\r
\r
+ // Move the cursor position to the end of the nick\r
if (inp[0].setSelectionRange) {\r
- inp[0].setSelectionRange(p1 + newnick.length, p1 + newnick.length);\r
+ inp[0].setSelectionRange(p1 + newnick.length + trailing.length, p1 + newnick.length + trailing.length);\r
} else if (inp[0].createTextRange) { // not sure if this bit is actually needed....\r
range = inp[0].createTextRange();\r
range.collapse(true);\r
- range.moveEnd('character', p1 + newnick.length);\r
- range.moveStart('character', p1 + newnick.length);\r
+ range.moveEnd('character', p1 + newnick.length + trailing.length);\r
+ range.moveStart('character', p1 + newnick.length + trailing.length);\r
range.select();\r
}\r
}\r
if (show_timestamps === _kiwi.global.settings) {\r
show_timestamps = arguments[1];\r
}\r
- \r
+\r
if (show_timestamps) {\r
this.$el.addClass('timestamps');\r
} else {\r