tab completion #32

Closed
sirkitree opened this Issue Mar 31, 2012 · 15 comments

Projects

None yet

2 participants

@sirkitree

It's be pretty bangin' if this had tab completion for nicks. It's a pretty standard feature for most irc clients.

I did a search to see what I could find, but most things just wanna autocomplete with a list.

The closest I found was in Jash.
http://www.billyreisinger.com/jash/source/latest/Jash_source.js

On line 1338 you'll find a TabCompletion function.

Know of anything a little more pluggable? Interested in helping me get this in?

@sirkitree

Capturing tab keypress in Chrome is a little funky: http://stackoverflow.com/questions/3362/capturing-tab-key-in-text-box

@sirkitree

Here on line 370 here is a tabcomplete function in javascript as well... not sure how good this one is though, since hitting tab makes the textarea lose focus, though it does autocomplete something like doc[tab] to document.

@microp11
Collaborator

This is so cool, i did not even know what or how this tab completion works until today. Came up in a discussion with alejandro and then you came up with this comment. This is a cool feature. Will certainly look on implementing. Thank you for the code examples.

@sirkitree

Fortuitous! yw :) Please let me know if I can help out in any way.

@microp11
Collaborator

"I did a search to see what I could find, but most things just wanna autocomplete with a list."

If there is code already to autocomplete from a list, all users in the irc client are currently in an array. This may change, but for now that's how they are. It shouldn't be hard to adapt. I think I saw somewhere js code to intercept the keys, including code for IE.

@sirkitree

When I wrote that I mean that the autocomplete was like a dropdown list, rather than cycling through the matches within the textbox itself. There's huge difference between the typical "web" autocomplete and "bash" autocomplete. I think bash autocomplete is more what we want in this case.

@sirkitree

Yeah, so this works pretty well! Couple of caveats:

  • must prepend @ to a name for autocomplete to work
  • doesn't cycle through the matches
  • only completes if there is 1 match

So it's not completely ideal, but it's a great start!


To test I did the following:

  • loaded up the jquery plugin within index.html
@@ -70,6 +70,7 @@
   <script type="text/javascript" src="/js/plugins.min.js"></script>
   <script src="/socket.io/socket.io.js"></script>
   <script src="/js/app.js" type="text/javascript"></script>
+  <script src="/js/jquery.nickname-tab-complete.js" type="text/javascript"></script>
 </div>
 </body>
 </html>
  • added a short line to the end of app.js calling the plugin
@@ -455,6 +455,10 @@ $(document).ready(function(){
         } else {
             $("#btnTones").text("Enable tones");
         }
-    })
-    
+    });
+
+    $("input#text_input.btn").nicknameTabComplete({
+        nicknames: nicks
+    });
+
 });
@sirkitree

The functionality pieces that would be nice to have, I've created as issues for @dcneiner here: https://github.com/dcneiner/NicknameTabComplete/issues

@microp11
Collaborator

sirkitree, the resources you indicated are great. I started to look into this. Will let you know what I find, also let me know if you find any more helpful data on the subject.

@microp11
Collaborator
microp11 commented Apr 1, 2012

sirkitree, after looking at the code in the examples you provided and trying to understand them, I realised it was simpler to write the code from scratch. thank you for the idea and for the code examples. enjoy our solution.

@sirkitree

Nice! This looks much better (simpler code) and work even better! :)

@sirkitree sirkitree closed this Apr 1, 2012
@microp11
Collaborator
microp11 commented Apr 1, 2012

:) Thanks. Please check the "multiple tab completion" added today as well. What we're thinking is to make a small snippet for gitHub so anyone can find out and use the code.

@sirkitree

yes that would be awesome considering there is really very little out
there, and none that I've found so elegant :)

On Sun, Apr 1, 2012 at 1:54 PM, microp11 <
reply@reply.github.com

wrote:

:) Thanks. Please check the "multiple tab completion" added today as well.
What we're thinking is to make a small snippet for gitHub so anyone can
find out and use the code.


Reply to this email directly or view it on GitHub:
#32 (comment)

~Jerad

@microp11
Collaborator
microp11 commented Apr 2, 2012

My own very first repository: https://github.com/microp11/tabcomplete

Any comments welcome! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment