Server Autocomplete
Sebastian Andersson
bofh69 at gmail.com
Thu Jun 24 10:24:56 EDT 2010
On Thu, Jun 24, 2010 at 15:57, A.C. <kynshny at hotmail.com> wrote:
> Hi everyone,
>
> I'm currently working on a telnet server that takes in user input.
> Everything is working great and netty is working out perfectly. I'm
> wondering if there's a way for netty to autocomplete commands. I've
> seen this implemented on other remote telnet servers before, but I
> haven't been able to figure out a way to do it yet.
>
> For example, if a user types: [ch ]
>
> when the space is typed, the server goes through the command list and
> if it sees a match, it will change the [ch ] to [change ], for
> example, sort of similar to filename completion when you're at the
> command prompt and you press [tab].
This is not something that is built into netty.
The telnet example in netty is not so much a TELNET implementation as
a simple text line-by-line receiver.
Unless you actually implement the TELNET protocol or use port 23, many
telnet clients will use line-by-line mode and in that mode all the
command line editing is happening in the client outside of your
control.
If you have already implemented the TELNET protocol, you simply store
where on the command line the cursor is when you receive a tab
character, lookup the first word that matches what has already been
received and sends the remaining characters of the new word. If you
receive another tab character, send a few backspace characters back
and the next matching word. If the new word is shorter than the
previously matched word, you'll have to send a few blank spaces to
erase all of the old word, and then a few backspaces to get the cursor
to the right place
I have it implemented in a client written in haXe. Except for the
backspace/space sending, the algorithm is the same on the client and
server.
The source is here: http://code.google.com/p/soiled/source/browse/#svn/trunk
If you have not implemented the TELNET protocol, you should probably
read these RFCs:
* 854 - Telnet Protocol Specification.
* 855 - Telnet Option Specification.
* 857 - Telnet Echo Option
* 858 - Telnet Suppress Go Ahead Option
* 1143 - The Q Method of Implemeneting TELNET Option
And these two are pretty nice to have too:
* 1073 - Telnet window size option.
* 1413 - Identification Protocol (half of it anyway).
/Sebastian
--
One laptop per child project: http://laptop.org/
More information about the netty-users
mailing list