Compare commits

..

2 commits

3 changed files with 31 additions and 9 deletions

View file

@ -19,6 +19,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security
## [0.2.3] - 2024-06-01
### Changed
- Reload chat history when changing room, with an option to keep history
## [0.2.2] - 2024-06-01
### Fixed
- Messages *actually* wrap properly with terminal viewport width this time
## [0.2.1] - 2024-05-31
### Fixed
@ -65,7 +77,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Go programs for [client](./tui/main.go) and [server](./server/main.go)
- GitHub Actions release flow, including binaries
[unreleased]: https://github.com/supleed2/go-chat/compare/v0.2.1...HEAD
[unreleased]: https://github.com/supleed2/go-chat/compare/v0.2.3...HEAD
[0.2.3]: https://github.com/supleed2/go-chat/releases/tag/v0.2.3
[0.2.2]: https://github.com/supleed2/go-chat/releases/tag/v0.2.2
[0.2.1]: https://github.com/supleed2/go-chat/releases/tag/v0.2.1
[0.2.0]: https://github.com/supleed2/go-chat/releases/tag/v0.2.0
[0.1.2]: https://github.com/supleed2/go-chat/releases/tag/v0.1.2

View file

@ -52,6 +52,7 @@ const (
)
type model struct {
kpHist bool
history viewport.Model
msgs []c.SMsg
showTim showTim
@ -68,14 +69,16 @@ type model struct {
type args struct {
Address string `arg:"positional" default:"gochat.8bit.lol" help:"address to connect to, without ws://" placeholder:"HOST[:PORT]"`
KeepHistory bool `arg:"-k" help:"append chat history when changing rooms, instead of clearing"`
Timestamps showTim `arg:"-t" default:"off" help:"display timestamps of messages, ctrl+t to cycle after startup [off, short, full]" placeholder:"CHOICE"`
Nick *string `arg:"-n" help:"attempt to automatically set nick after connecting"`
Password *string `arg:"-p" help:"password, if required"`
}
func (a *args) Version() string {
return "v0.2.1"
return "v0.2.3"
}
func (a *args) Description() string {
return "Go, chat!\nA basic irc-style chat client, written in Go using bubbletea and websockets"
}
@ -180,8 +183,9 @@ func initModel(ctx context.Context, conn *ws.Conn, a args, tz time.Location) mod
msgs: messages,
showTim: a.Timestamps,
tz: tz,
kpHist: a.KeepHistory,
history: vp,
idStyle: lipgloss.NewStyle(),
idStyle: lipgloss.NewStyle().Width(60),
pStyle: lipgloss.NewStyle().Bold(true),
help: help.New(),
recvCh: recvCh,
@ -230,6 +234,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} else if text == "ls" {
m.sendCh <- c.CMsg{Typ: c.Ls, Msg: ""}
} else if text, ok := strings.CutPrefix(text, "cd "); ok {
if !m.kpHist {
m.msgs = []c.SMsg{}
}
m.sendCh <- c.CMsg{Typ: c.Cd, Msg: text}
} else if text == "who" {
m.sendCh <- c.CMsg{Typ: c.Who, Msg: ""}
@ -250,7 +257,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.history.Width = msg.Width
m.history.GotoBottom()
m.input.Width = msg.Width - 3
m.help.Width = msg.Width - 1
m.idStyle = m.idStyle.Width(msg.Width)
m.help.Width = msg.Width
m.history.SetContent(m.viewMessages())
}

View file

@ -63,7 +63,7 @@ const createRoomTable = "CREATE TABLE IF NOT EXISTS %s (tim DATETIME, id TEXT, m
const insertRoomMsg = "INSERT INTO %v (tim, id, msg) VALUES (:tim, :id, :msg)"
func (a *args) Version() string {
return "v0.2.1"
return "v0.2.3"
}
func (a *args) Description() string {