mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-06-12 05:12:12 +03:00
commit
ca580264f0
@ -71,7 +71,7 @@ things up with `make run`.
|
|||||||
* [x] set term width properly
|
* [x] set term width properly
|
||||||
* [x] client map rather than list
|
* [x] client map rather than list
|
||||||
* [x] backfill chat history
|
* [x] backfill chat history
|
||||||
* [ ] tab completion
|
* [x] tab completion
|
||||||
* [x] /ban
|
* [x] /ban
|
||||||
* [ ] /ban by ip
|
* [ ] /ban by ip
|
||||||
* [x] /help
|
* [x] /help
|
||||||
@ -88,7 +88,7 @@ things up with `make run`.
|
|||||||
* [ ] More tests.
|
* [ ] More tests.
|
||||||
* [ ] Even more tests.
|
* [ ] Even more tests.
|
||||||
* [ ] Lots of refactoring
|
* [ ] Lots of refactoring
|
||||||
* [ ] Pull out the chat-related stuff into isolation from the ssh serving
|
* [ ] Pull out the chat-related stuff into isolation from the ssh serving
|
||||||
stuff
|
stuff
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ const ABOUT_TEXT string = `-> ssh-chat is made by @shazow.
|
|||||||
|
|
||||||
For more, visit shazow.net or follow at twitter.com/shazow
|
For more, visit shazow.net or follow at twitter.com/shazow
|
||||||
`
|
`
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
Server *Server
|
Server *Server
|
||||||
Conn *ssh.ServerConn
|
Conn *ssh.ServerConn
|
||||||
@ -56,7 +55,7 @@ func NewClient(server *Server, conn *ssh.ServerConn) *Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) ColoredName() string {
|
func (c *Client) ColoredName() string {
|
||||||
return ColorString(c.Color, c.Name)
|
return ColorString(c.Color, c.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Write(msg string) {
|
func (c *Client) Write(msg string) {
|
||||||
@ -257,6 +256,8 @@ func (c *Client) handleChannels(channels <-chan ssh.NewChannel) {
|
|||||||
defer channel.Close()
|
defer channel.Close()
|
||||||
|
|
||||||
c.term = terminal.NewTerminal(channel, prompt)
|
c.term = terminal.NewTerminal(channel, prompt)
|
||||||
|
c.term.AutoCompleteCallback = c.Server.AutoCompleteFunction
|
||||||
|
|
||||||
for req := range requests {
|
for req := range requests {
|
||||||
var width, height int
|
var width, height int
|
||||||
var ok bool
|
var ok bool
|
||||||
|
22
server.go
22
server.go
@ -273,6 +273,28 @@ func (s *Server) Start(laddr string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) AutoCompleteFunction(line string, pos int, key rune) (newLine string, newPos int, ok bool) {
|
||||||
|
if key == 9 {
|
||||||
|
shortLine := strings.Split(line[:pos], " ")
|
||||||
|
partialNick := shortLine[len(shortLine)-1]
|
||||||
|
|
||||||
|
nicks := s.List(&partialNick)
|
||||||
|
if len(nicks) > 0 {
|
||||||
|
nick := nicks[len(nicks)-1]
|
||||||
|
posPartialNick := pos - len(partialNick)
|
||||||
|
|
||||||
|
newLine = strings.Replace(line[posPartialNick:],
|
||||||
|
partialNick, nick, 1)
|
||||||
|
newLine = line[:posPartialNick] + newLine
|
||||||
|
newPos = pos + (len(nick) - len(partialNick))
|
||||||
|
ok = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ok = false
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) Stop() {
|
func (s *Server) Stop() {
|
||||||
for _, client := range s.clients {
|
for _, client := range s.clients {
|
||||||
client.Conn.Close()
|
client.Conn.Close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user