Skip to content

Commit

Permalink
zen mode added
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-ward committed Mar 7, 2024
1 parent 9595ad9 commit cd46c11
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
19 changes: 14 additions & 5 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/dustin-ward/termtyping/internal/character"
"github.com/dustin-ward/termtyping/internal/config"
"github.com/dustin-ward/termtyping/internal/data"
"github.com/dustin-ward/termtyping/internal/stats"
"github.com/dustin-ward/termtyping/internal/statusbar"
"github.com/dustin-ward/termtyping/internal/styles"
)

var Config config.Config

type AppState int

const (
Expand Down Expand Up @@ -107,9 +110,15 @@ func (m AppModel) View() string {
view_text = b.String()
}

return styles.BorderStyle.Render(lipgloss.JoinVertical(
lipgloss.Left,
styles.StatusBar.Render(m.status_bar.View()),
styles.TextBox.Render(view_text),
))
var view string
if Config.ZenMode {
view = styles.BorderStyle.Render(styles.Zen_TextBox.Render(view_text))
} else {
view = styles.BorderStyle.Render(lipgloss.JoinVertical(
lipgloss.Left,
styles.StatusBar.Render(m.status_bar.View()),
styles.TextBox.Render(view_text),
))
}
return view
}
5 changes: 5 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package config

type Config struct {
ZenMode bool
}
4 changes: 4 additions & 0 deletions internal/styles/styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ var (
RemainingText = lipgloss.NewStyle().Foreground(LightGrey)
ActiveText = lipgloss.NewStyle().Foreground(White)

// Regular Mode
TextBox = lipgloss.NewStyle().Width(APP_WIDTH).Margin(0, 2)
StatusBar = lipgloss.NewStyle().Width(APP_WIDTH).Margin(0, 2).Border(lipgloss.NormalBorder()).BorderForeground(LightGrey).BorderTop(false).BorderLeft(false).BorderRight(false)
BorderStyle = lipgloss.NewStyle().BorderStyle(lipgloss.RoundedBorder()).Foreground(White)

// Zen Mode
Zen_TextBox = lipgloss.NewStyle().Width(APP_WIDTH).Margin(1, 2)
)
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
package main

import (
"flag"
"log"

tea "github.com/charmbracelet/bubbletea"
"github.com/dustin-ward/termtyping/internal/app"
"github.com/dustin-ward/termtyping/internal/config"
)

var zen_flag bool

func init() {
flag.BoolVar(&zen_flag, "zen", false, "enable zen mode (default=false)")
flag.Parse()
}

func main() {
config := config.Config{
ZenMode: zen_flag,
}
app.Config = config

p := tea.NewProgram(app.NewAppModel(app.StateDefault, nil))
if _, err := p.Run(); err != nil {
log.Fatal(err)
Expand Down

0 comments on commit cd46c11

Please sign in to comment.