mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 20:55:47 +00:00
refactor: changed color of commit message field to match rest of TUI
This commit is contained in:
@@ -13,6 +13,11 @@ import (
|
||||
"github.com/charmbracelet/bubbles/key"
|
||||
"github.com/charmbracelet/bubbles/textarea"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
var (
|
||||
barStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("170"))
|
||||
)
|
||||
|
||||
type KeyMap struct {
|
||||
@@ -47,18 +52,20 @@ type errMsg error
|
||||
|
||||
type model_cm struct {
|
||||
textarea textarea.Model
|
||||
keys *KeyMap
|
||||
keys *KeyMap
|
||||
err error
|
||||
}
|
||||
|
||||
func initialModel_cm() model_cm {
|
||||
ti := textarea.New()
|
||||
ti.FocusedStyle = textarea.Style{Base: lipgloss.NewStyle().Foreground(lipgloss.Color("170"))}
|
||||
|
||||
ti.Placeholder = "Write your commit message here..."
|
||||
ti.Focus()
|
||||
|
||||
return model_cm{
|
||||
textarea: ti,
|
||||
keys: newKeyMap(),
|
||||
keys: newKeyMap(),
|
||||
err: nil,
|
||||
}
|
||||
}
|
||||
@@ -74,8 +81,8 @@ func (m model_cm) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
switch msg := msg.(type) {
|
||||
case tea.KeyMsg:
|
||||
switch {
|
||||
case key.Matches(msg, m.keys.EndWithMes):
|
||||
return m, tea.Quit
|
||||
case key.Matches(msg, m.keys.EndWithMes):
|
||||
return m, tea.Quit
|
||||
}
|
||||
switch msg.Type {
|
||||
case tea.KeyCtrlC:
|
||||
@@ -101,9 +108,8 @@ func (m model_cm) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
|
||||
func (m model_cm) View() string {
|
||||
return fmt.Sprintf(
|
||||
"Tell me a story.\n\n%s\n\n%s",
|
||||
"Commit message:\n\n%s\n\n%s",
|
||||
m.textarea.View(),
|
||||
"alt+enter|Submit\nctrl+c|Cancel",
|
||||
"(alt+enter | Submit)\n(ctrl+c | Cancel)",
|
||||
) + "\n\n"
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@ import (
|
||||
|
||||
var content string
|
||||
|
||||
var helpStyle_us = lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Render
|
||||
var (
|
||||
helpStyle_us = lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Render
|
||||
)
|
||||
|
||||
type example struct {
|
||||
viewport viewport.Model
|
||||
@@ -82,6 +84,10 @@ func (e example) helpView() string {
|
||||
|
||||
func Entry_US(author_file string) {
|
||||
file, err := os.Open(author_file)
|
||||
if err != nil {
|
||||
fmt.Println("Could not open file:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
var cnt strings.Builder
|
||||
|
||||
Reference in New Issue
Block a user