summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/client/client.go8
-rw-r--r--internal/client/ui/core/chat/chat.go38
-rw-r--r--internal/client/ui/viminput/viminput.go74
3 files changed, 60 insertions, 60 deletions
diff --git a/internal/client/client.go b/internal/client/client.go
index 49e3c80..a779bf9 100644
--- a/internal/client/client.go
+++ b/internal/client/client.go
@@ -8,12 +8,10 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/davecgh/go-spew/spew"
- "github.com/muesli/termenv"
"github.com/kyren223/eko/internal/client/config"
"github.com/kyren223/eko/internal/client/ui"
"github.com/kyren223/eko/internal/client/ui/auth"
- "github.com/kyren223/eko/internal/client/ui/colors"
"github.com/kyren223/eko/pkg/assert"
)
@@ -43,12 +41,6 @@ func Run() {
log.Fatalf("Config file at '%v' was unable to load successfully\n%v\n", config.ConfigFile, err)
}
- // HACK: Sets the terminal color and keeps it that way
- // I am not aware of a way to query the current background color (to revert this)
- // Ideally bubbletea will handle the setting/reventing, for now it's fine
- // It only changes the current pane so new terminal panes/windows are not affected.
- termenv.DefaultOutput().SetBackgroundColor(termenv.RGBColor(colors.ToHex(colors.Background)))
-
program := tea.NewProgram(initialModel(dump), tea.WithAltScreen())
assert.AddFlush(BubbleTeaCloser{program})
ui.Program = program
diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go
index ceb8aeb..230c155 100644
--- a/internal/client/ui/core/chat/chat.go
+++ b/internal/client/ui/core/chat/chat.go
@@ -23,13 +23,14 @@ import (
)
var (
- blurStyle = lipgloss.NewStyle().Foreground(colors.White)
- focusStyle = lipgloss.NewStyle().Foreground(colors.Focus)
- readOnlyStyle = lipgloss.NewStyle().Foreground(colors.Gray)
- mutedStyle = lipgloss.NewStyle().Foreground(colors.Red)
- editStyle = lipgloss.NewStyle().Foreground(colors.Gold)
+ blurStyle = BackgroundStyle.Foreground(colors.White)
+ focusStyle = BackgroundStyle.Foreground(colors.Focus)
+ readOnlyStyle = BackgroundStyle.Foreground(colors.Gray)
+ mutedStyle = BackgroundStyle.Foreground(colors.Red)
+ editStyle = BackgroundStyle.Foreground(colors.Gold)
ViBlurredBorder = lipgloss.NewStyle().
+ Background(colors.Background).BorderBackground(colors.Background).
Border(lipgloss.RoundedBorder(), true, true, false).
Padding(0, 1)
ViFocusedBorder = ViBlurredBorder.BorderForeground(colors.Focus)
@@ -37,9 +38,10 @@ var (
ViMutedBorder = ViBlurredBorder.BorderForeground(colors.Red)
ViEditBorder = ViBlurredBorder.BorderForeground(colors.Gold)
- VimModeStyle = lipgloss.NewStyle().Bold(true)
+ VimModeStyle = lipgloss.NewStyle().Bold(true).Background(colors.Background)
- DateTimeStyle = lipgloss.NewStyle().Foreground(colors.LightGray).SetString("")
+ DateTimeStyle = lipgloss.NewStyle().Background(colors.Background).
+ Foreground(colors.LightGray).SetString("")
PaddingCount = 1
Padding = strings.Repeat(" ", PaddingCount)
@@ -47,13 +49,14 @@ var (
LeftCorner = Border.BottomLeft + Border.Bottom
RightCorner = Border.Bottom + Border.BottomRight
- NoMessages = lipgloss.NewStyle().
+ NoMessages = lipgloss.NewStyle().Background(colors.Background).
Foreground(colors.LightGray).Padding(0, PaddingCount, 1).
AlignHorizontal(lipgloss.Center).AlignVertical(lipgloss.Bottom).
SetString("This frequency has no messages, start transmiting!")
NoAccess = NoMessages.SetString("You do not have permission to see messages in this frequency")
- SelectedGap = lipgloss.NewStyle().Background(colors.BackgroundDim)
+ SelectedGap = lipgloss.NewStyle().Background(colors.BackgroundDim)
+ BackgroundStyle = lipgloss.NewStyle().Background(colors.Background)
SendMessagePlaceholder = "Send a message..."
ReadOnlyPlaceholder = "You do not have permission to send messages in this frequency"
@@ -85,7 +88,7 @@ var (
PingedEveryone = lipgloss.NewStyle().Foreground(colors.Purple).Render("@everyone ")
PingedUserStyle = lipgloss.NewStyle().Foreground(colors.Gold)
- MessageStyle = lipgloss.NewStyle().
+ MessageStyle = lipgloss.NewStyle().Background(colors.Background).
PaddingLeft(PaddingCount + 2).PaddingRight(PaddingCount)
PingedMessageStyle = lipgloss.NewStyle().
MarginLeft(PaddingCount).PaddingLeft(1).PaddingRight(PaddingCount).
@@ -137,7 +140,6 @@ type Model struct {
func New() Model {
vi := viminput.New()
- vi.PlaceholderStyle = lipgloss.NewStyle().Foreground(colors.Gray)
return Model{
vi: vi,
@@ -173,7 +175,7 @@ func (m *Model) Prerender() {
frequencyHeight := lipgloss.Height(frequencyName)
messagebox := m.renderMessageBox()
- messageBoxHeight := lipgloss.Height(messagebox)
+ messageBoxHeight := lipgloss.Height(messagebox) - 1
messagesHeight := ui.Height - messageBoxHeight - frequencyHeight
@@ -185,7 +187,9 @@ func (m *Model) Prerender() {
m.messagesCache = &messages
m.messagesHeight = messagesHeight
- m.prerender = frequencyName + *m.messagesCache + messagebox
+ m.prerender = lipgloss.NewStyle().
+ Background(colors.Background).
+ Render(frequencyName + *m.messagesCache + messagebox)
}
func (m Model) View() string {
@@ -838,13 +842,14 @@ func (m *Model) renderMessageBox() string {
builder.WriteString(m.style.Render(bottom))
builder.WriteString(leftAngle)
- builder.WriteString(countStr)
+ builder.WriteString(BackgroundStyle.Render(countStr))
builder.WriteString(rightAngle)
builder.WriteString(m.style.Render(RightCorner))
+ builder.WriteByte('\n')
result := builder.String()
- return lipgloss.NewStyle().Padding(0, PaddingCount).Render(result)
+ return lipgloss.NewStyle().Background(colors.Background).Padding(0, PaddingCount).Render(result)
}
func (m *Model) renderMessages(screenHeight int) string {
@@ -1292,6 +1297,9 @@ func (m *Model) renderHeader(message data.Message, selected bool) []byte {
if selected {
style := lipgloss.NewStyle().Background(colors.BackgroundDim).Width(m.width).Inline(true)
buf = []byte(style.Render(string(buf)))
+ } else {
+ style := lipgloss.NewStyle().Background(colors.Background).Width(m.width).Inline(true)
+ buf = []byte(style.Render(string(buf)))
}
buf = append(buf, '\n')
diff --git a/internal/client/ui/viminput/viminput.go b/internal/client/ui/viminput/viminput.go
index 53ba046..22f6bfd 100644
--- a/internal/client/ui/viminput/viminput.go
+++ b/internal/client/ui/viminput/viminput.go
@@ -17,6 +17,7 @@ var (
CursorStyle = lipgloss.NewStyle().Background(colors.White).Foreground(colors.Background)
InactiveCursorStyle = lipgloss.NewStyle()
VisualStyle = lipgloss.NewStyle().Background(colors.DarkGray)
+ PlaceholderStyle = lipgloss.NewStyle().Foreground(colors.Gray).Background(colors.Background)
)
const (
@@ -41,8 +42,7 @@ const (
)
type Model struct {
- PlaceholderStyle lipgloss.Style
- PromptStyle lipgloss.Style
+ PromptStyle lipgloss.Style
Placeholder string
register string
@@ -74,33 +74,32 @@ type Model struct {
func New() Model {
return Model{
- PlaceholderStyle: lipgloss.NewStyle(),
- PromptStyle: lipgloss.NewStyle(),
- Placeholder: "",
- register: "",
- lines: [][]rune{[]rune("")},
- undoStack: []State{{[][]rune{[]rune("")}, 0, 0}},
- redoStack: []State{},
- cursorLine: 0,
- cursorColumn: 0,
- goalColumn: InvalidGoal,
- mode: NormalMode,
- count: NoCount,
- vline: 0,
- vcol: 0,
- pending: NullChar,
- gmod: false,
- fchar: NullChar,
- fmod: NullChar,
- tlast: false,
- imod: false,
- amod: false,
- inactive: false,
- focus: false,
- width: -1,
- height: 1,
- maxHeight: -1,
- offset: 0,
+ PromptStyle: lipgloss.NewStyle(),
+ Placeholder: "",
+ register: "",
+ lines: [][]rune{[]rune("")},
+ undoStack: []State{{[][]rune{[]rune("")}, 0, 0}},
+ redoStack: []State{},
+ cursorLine: 0,
+ cursorColumn: 0,
+ goalColumn: InvalidGoal,
+ mode: NormalMode,
+ count: NoCount,
+ vline: 0,
+ vcol: 0,
+ pending: NullChar,
+ gmod: false,
+ fchar: NullChar,
+ fmod: NullChar,
+ tlast: false,
+ imod: false,
+ amod: false,
+ inactive: false,
+ focus: false,
+ width: -1,
+ height: 1,
+ maxHeight: -1,
+ offset: 0,
}
}
@@ -116,7 +115,7 @@ func (m Model) View() string {
cursorStyle = InactiveCursorStyle
}
- m.PlaceholderStyle = m.PlaceholderStyle.Width(m.width)
+ placeholderStyle := PlaceholderStyle.MaxWidth(m.width)
var builder strings.Builder
switch m.mode {
@@ -128,9 +127,9 @@ func (m Model) View() string {
if len(m.lines) == 1 && len(line) == 0 && m.Placeholder != "" {
cursorChar := cursorStyle.
- Foreground(m.PlaceholderStyle.GetForeground()).
+ Foreground(placeholderStyle.GetForeground()).
Render(m.Placeholder[0:1])
- rest := m.PlaceholderStyle.Render(m.Placeholder[1:])
+ rest := placeholderStyle.Render(m.Placeholder[1:])
builder.WriteString(cursorChar)
builder.WriteString(rest)
builder.WriteByte('\n')
@@ -160,9 +159,9 @@ func (m Model) View() string {
if len(m.lines) == 1 && len(line) == 0 && m.Placeholder != "" {
cursorChar := cursorStyle.
- Foreground(m.PlaceholderStyle.GetForeground()).
+ Foreground(placeholderStyle.GetForeground()).
Render(m.Placeholder[0:1])
- rest := m.PlaceholderStyle.Render(m.Placeholder[1:])
+ rest := placeholderStyle.Render(m.Placeholder[1:])
builder.WriteString(cursorChar)
builder.WriteString(rest)
builder.WriteByte('\n')
@@ -268,9 +267,9 @@ func (m Model) View() string {
if len(m.lines) == 1 && len(line) == 0 && m.Placeholder != "" {
cursorChar := cursorStyle.
- Foreground(m.PlaceholderStyle.GetForeground()).
+ Foreground(placeholderStyle.GetForeground()).
Render(m.Placeholder[0:1])
- rest := m.PlaceholderStyle.Render(m.Placeholder[1:])
+ rest := placeholderStyle.Render(m.Placeholder[1:])
builder.WriteString(cursorChar)
builder.WriteString(rest)
builder.WriteByte('\n')
@@ -305,7 +304,8 @@ func (m Model) View() string {
result := builder.String()
result = result[:len(result)-1] // Remove last \n
- result = lipgloss.NewStyle().Width(m.width).Height(m.height).Render(result)
+ result = lipgloss.NewStyle().Background(colors.Background).
+ Width(m.width).Height(m.height).Render(result)
return result
}