mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 06:04:18 +00:00
Remove some consts + check cell widths of prompts, not byte lengths
We're able to remove those consts by virtue of reflow's new-ish ansi.PrintableRuneWidth.
This commit is contained in:
parent
4b121593d4
commit
8277cbb71f
2 changed files with 10 additions and 14 deletions
14
ui/pager.go
14
ui/pager.go
|
@ -19,11 +19,7 @@ import (
|
|||
te "github.com/muesli/termenv"
|
||||
)
|
||||
|
||||
const (
|
||||
statusBarHeight = 1
|
||||
noteHeadingText = " Set Memo "
|
||||
notePromptText = " > "
|
||||
)
|
||||
const statusBarHeight = 1
|
||||
|
||||
var (
|
||||
pagerHelpHeight int
|
||||
|
@ -31,7 +27,7 @@ var (
|
|||
mintGreen = common.NewColorPair("#89F0CB", "#89F0CB")
|
||||
darkGreen = common.NewColorPair("#1C8760", "#1C8760")
|
||||
|
||||
noteHeading = te.String(noteHeadingText).
|
||||
noteHeading = te.String(" Set Memo ").
|
||||
Foreground(common.Cream.Color()).
|
||||
Background(common.Green.Color()).
|
||||
String()
|
||||
|
@ -100,7 +96,7 @@ func newPagerModel(cfg *Config, as authStatus) pagerModel {
|
|||
|
||||
// Text input for notes/memos
|
||||
ti := textinput.NewModel()
|
||||
ti.Prompt = te.String(notePromptText).
|
||||
ti.Prompt = te.String(" > ").
|
||||
Foreground(common.Color(darkGray)).
|
||||
Background(common.YellowGreen.Color()).
|
||||
String()
|
||||
|
@ -132,7 +128,9 @@ func (m *pagerModel) setSize(w, h int) {
|
|||
m.height = h
|
||||
m.viewport.Width = w
|
||||
m.viewport.Height = h - statusBarHeight
|
||||
m.textInput.Width = w - len(noteHeadingText) - len(notePromptText) - 1
|
||||
m.textInput.Width = w -
|
||||
ansi.PrintableRuneWidth(noteHeading) -
|
||||
ansi.PrintableRuneWidth(m.textInput.Prompt) - 1
|
||||
|
||||
if m.showHelp {
|
||||
if pagerHelpHeight == 0 {
|
||||
|
|
10
ui/stash.go
10
ui/stash.go
|
@ -29,8 +29,6 @@ const (
|
|||
stashViewTopPadding = 5
|
||||
stashViewBottomPadding = 4
|
||||
stashViewHorizontalPadding = 6
|
||||
setNotePromptText = "Memo: "
|
||||
searchNotePromptText = "Search: "
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -127,8 +125,8 @@ func (m *stashModel) setSize(width, height int) {
|
|||
// Update the paginator
|
||||
m.setTotalPages()
|
||||
|
||||
m.noteInput.Width = m.terminalWidth - stashViewHorizontalPadding*2 - len(setNotePromptText)
|
||||
m.searchInput.Width = m.terminalWidth - stashViewHorizontalPadding*2 - len(searchNotePromptText)
|
||||
m.noteInput.Width = m.terminalWidth - stashViewHorizontalPadding*2 - ansi.PrintableRuneWidth(m.noteInput.Prompt)
|
||||
m.searchInput.Width = m.terminalWidth - stashViewHorizontalPadding*2 - ansi.PrintableRuneWidth(m.searchInput.Prompt)
|
||||
}
|
||||
|
||||
// Sets the total paginator pages according to the amount of markdowns for the
|
||||
|
@ -319,13 +317,13 @@ func newStashModel(cfg *Config, as authStatus) stashModel {
|
|||
p.InactiveDot = common.Subtle("•")
|
||||
|
||||
ni := textinput.NewModel()
|
||||
ni.Prompt = stashTextInputPromptStyle(setNotePromptText)
|
||||
ni.Prompt = stashTextInputPromptStyle("Memo: ")
|
||||
ni.CursorColor = common.Fuschia.String()
|
||||
ni.CharLimit = noteCharacterLimit
|
||||
ni.Focus()
|
||||
|
||||
si := textinput.NewModel()
|
||||
si.Prompt = stashTextInputPromptStyle(searchNotePromptText)
|
||||
si.Prompt = stashTextInputPromptStyle("Search: ")
|
||||
si.CursorColor = common.Fuschia.String()
|
||||
si.CharLimit = noteCharacterLimit
|
||||
si.Focus()
|
||||
|
|
Loading…
Reference in a new issue