mirror of
https://github.com/IllusionMan1212/gorc.git
synced 2026-10-24 02:12:33 +00:00
feat: message timestamps
* made it easier to styles and prefix messages * added timestamps to messages * added prefix and styles to server messages * append current date to host channel * fixed some styles issues
This commit is contained in:
+1
-3
@@ -92,11 +92,9 @@ func (s State) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
|
||||
s.UI.CurrentScreen = MainScreen
|
||||
|
||||
// create new client with the provided host and port
|
||||
s.Client.Initialize(host, port, tlsEnabled)
|
||||
s.Client.Register(nickname, password, channel)
|
||||
|
||||
s.Client.LastTabIndexInTabBar = len(s.Client.Channels) - 1
|
||||
s.Client.SetDay()
|
||||
|
||||
go handler.ReadLoop(s.Client)
|
||||
|
||||
|
||||
+2
-2
@@ -123,8 +123,8 @@ func (s State) Update(msg tea.Msg) (State, tea.Cmd) {
|
||||
}
|
||||
|
||||
s.Inputs[i].Blur()
|
||||
s.Inputs[i].PromptStyle = NoStyle
|
||||
s.Inputs[i].TextStyle = NoStyle
|
||||
s.Inputs[i].PromptStyle = ui.DefaultStyle
|
||||
s.Inputs[i].TextStyle = ui.DefaultStyle
|
||||
}
|
||||
|
||||
return s, tea.Batch(cmds...)
|
||||
|
||||
@@ -69,7 +69,6 @@ var (
|
||||
Padding(0, 2).
|
||||
Align(lipgloss.Center).
|
||||
Render("Connect")
|
||||
|
||||
FocusedCheckbox = lipgloss.NewStyle().
|
||||
Foreground(ui.AccentColor).
|
||||
MarginTop(1).
|
||||
@@ -101,5 +100,4 @@ var (
|
||||
Foreground(ui.AccentColor)
|
||||
FocusedStyle = lipgloss.NewStyle().
|
||||
Foreground(ui.AccentColor)
|
||||
NoStyle = lipgloss.NewStyle()
|
||||
)
|
||||
|
||||
@@ -90,7 +90,11 @@ func (s State) Update(msg tea.Msg) (State, tea.Cmd) {
|
||||
} else {
|
||||
if s.Client.ActiveChannel != s.Client.Host {
|
||||
fullMsg := s.Client.Nickname + ": " + msg.Msg
|
||||
s.Client.Channels[s.Client.ActiveChannelIndex].History += fullMsg + irc.CRLF
|
||||
msgOpts := irc.MsgFmtOpts{
|
||||
WithTimestamp: true,
|
||||
}
|
||||
|
||||
s.Client.Channels[s.Client.ActiveChannelIndex].AppendMsg(msg.Timestamp, fullMsg, msgOpts)
|
||||
// TODO: make sure to only append the message to the history if server sends back no errors
|
||||
s.Client.SendCommand(commands.PRIVMSG, s.Client.ActiveChannel, msg.Msg)
|
||||
s.Viewport.SetContent(s.Client.Channels[s.Client.ActiveChannelIndex].History)
|
||||
|
||||
@@ -22,16 +22,16 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
InputboxStyle = lipgloss.NewStyle().
|
||||
InputboxStyle = ui.DefaultStyle.Copy().
|
||||
Border(lipgloss.NormalBorder(), true).
|
||||
Padding(0, 1).
|
||||
Width(ui.MainStyle.GetWidth()).
|
||||
BorderForeground(ui.AccentColor)
|
||||
MessagesStyle = lipgloss.NewStyle().
|
||||
MessagesStyle = ui.DefaultStyle.Copy().
|
||||
Border(lipgloss.NormalBorder(), false, true, true, true).
|
||||
Width(ui.MainStyle.GetWidth() * 8 / 10).
|
||||
BorderForeground(ui.PrimaryColor)
|
||||
SidePanelStyle = lipgloss.NewStyle().
|
||||
SidePanelStyle = ui.DefaultStyle.Copy().
|
||||
Border(lipgloss.NormalBorder(), true).
|
||||
Width(ui.MainStyle.GetWidth() * 2 / 10).
|
||||
BorderForeground(ui.PrimaryColor)
|
||||
|
||||
+12
-1
@@ -23,6 +23,9 @@ var (
|
||||
Width(0).
|
||||
Height(0)
|
||||
|
||||
DefaultStyle = lipgloss.NewStyle().
|
||||
Foreground(PrimaryColor)
|
||||
|
||||
AccentColor = lipgloss.AdaptiveColor{
|
||||
Dark: "#1C6DD0",
|
||||
Light: "#1C6DD0",
|
||||
@@ -43,5 +46,13 @@ var (
|
||||
Light: "#CCC",
|
||||
}
|
||||
|
||||
Red = lipgloss.Color("#F00")
|
||||
ErrorColor = lipgloss.Color("#F00")
|
||||
DateColor = lipgloss.AdaptiveColor{
|
||||
Dark: "#0F0",
|
||||
Light: "#090",
|
||||
}
|
||||
ServerMsgColor = lipgloss.AdaptiveColor{
|
||||
Dark: "#999",
|
||||
Light: "#777",
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user