Fixed wrapping issues of placeholder in viminput and also re-phrased

some things
This commit is contained in:
2025-01-28 19:33:51 +02:00
parent 7abb46eb81
commit 2e9e0785c3
2 changed files with 17 additions and 9 deletions

View File

@@ -51,13 +51,13 @@ var (
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 permissions to see messages in this frequency")
NoAccess = NoMessages.SetString("You do not have permission to see messages in this frequency")
SelectedGap = lipgloss.NewStyle().Background(colors.BackgroundDim)
SendMessagePlaceholder = "Send a message..."
ReadOnlyPlaceholder = "You do not have permissions to send messages in this frequency"
MutedPlaceholder = "You have been muted by a server adminstrator"
ReadOnlyPlaceholder = "You do not have permission to send messages in this frequency"
MutedPlaceholder = "You have been muted by a network adminstrator"
EditedIndicator = lipgloss.NewStyle().
Foreground(colors.LightGray).SetString(" (edited)").String()

View File

@@ -116,6 +116,8 @@ func (m Model) View() string {
cursorStyle = InactiveCursorStyle
}
m.PlaceholderStyle = m.PlaceholderStyle.Width(m.width)
var builder strings.Builder
switch m.mode {
case NormalMode, InsertMode, OpendingMode:
@@ -125,9 +127,11 @@ func (m Model) View() string {
}
if len(m.lines) == 1 && len(line) == 0 && m.Placeholder != "" {
cursorChar := m.PlaceholderStyle.Render(m.Placeholder[0:1])
cursorChar := cursorStyle.
Foreground(m.PlaceholderStyle.GetForeground()).
Render(m.Placeholder[0:1])
rest := m.PlaceholderStyle.Render(m.Placeholder[1:])
builder.WriteString(cursorStyle.Render(cursorChar))
builder.WriteString(cursorChar)
builder.WriteString(rest)
builder.WriteByte('\n')
continue
@@ -155,9 +159,11 @@ func (m Model) View() string {
}
if len(m.lines) == 1 && len(line) == 0 && m.Placeholder != "" {
cursorChar := m.PlaceholderStyle.Render(m.Placeholder[0:1])
cursorChar := cursorStyle.
Foreground(m.PlaceholderStyle.GetForeground()).
Render(m.Placeholder[0:1])
rest := m.PlaceholderStyle.Render(m.Placeholder[1:])
builder.WriteString(cursorStyle.Render(cursorChar))
builder.WriteString(cursorChar)
builder.WriteString(rest)
builder.WriteByte('\n')
continue
@@ -261,9 +267,11 @@ func (m Model) View() string {
}
if len(m.lines) == 1 && len(line) == 0 && m.Placeholder != "" {
cursorChar := m.PlaceholderStyle.Render(m.Placeholder[0:1])
cursorChar := cursorStyle.
Foreground(m.PlaceholderStyle.GetForeground()).
Render(m.Placeholder[0:1])
rest := m.PlaceholderStyle.Render(m.Placeholder[1:])
builder.WriteString(cursorStyle.Render(cursorChar))
builder.WriteString(cursorChar)
builder.WriteString(rest)
builder.WriteByte('\n')
continue