Skip to content

Commit

Permalink
tui: make color.NoColor=true on RawContent
Browse files Browse the repository at this point in the history
fixes #13
  • Loading branch information
azimut committed May 2, 2023
1 parent f0d122a commit 3101d0d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
6 changes: 5 additions & 1 deletion internal/discourse/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package discourse
import (
"github.com/azimut/cli-view/internal/tui"
tea "github.com/charmbracelet/bubbletea"
"github.com/fatih/color"
)

const rightPadding = 10
Expand All @@ -29,11 +30,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
// Initialize data to be used for links scrapping
if m.render.RawContent == "" {
oldColor := color.NoColor
oldCommentWidth := m.CommentWidth
m.LineWidth = 400
color.NoColor = true
m.CommentWidth = 300
m.LineWidth = 400
m.render.RawContent = m.String()
m.CommentWidth = oldCommentWidth
color.NoColor = oldColor
}
m.render, cmd = m.render.Update(msg)
switch msg := msg.(type) {
Expand Down
6 changes: 5 additions & 1 deletion internal/fourchan/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fourchan
import (
"github.com/azimut/cli-view/internal/tui"
tea "github.com/charmbracelet/bubbletea"
"github.com/fatih/color"
)

type Model struct {
Expand All @@ -27,11 +28,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
// Initialize data to be used for links scrapping
if m.render.RawContent == "" {
oldColor := color.NoColor
oldCommentWidth := m.CommentWidth
m.LineWidth = 400
color.NoColor = true
m.CommentWidth = 300
m.LineWidth = 400
m.render.RawContent = m.String()
m.CommentWidth = oldCommentWidth
color.NoColor = oldColor
}
m.render, cmd = m.render.Update(msg)
switch msg := msg.(type) {
Expand Down
6 changes: 5 additions & 1 deletion internal/hackernews/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package hackernews
import (
"github.com/azimut/cli-view/internal/tui"
tea "github.com/charmbracelet/bubbletea"
"github.com/fatih/color"
)

const rightPadding = 10
Expand All @@ -29,11 +30,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
// Initialize data to be used for links scrapping
if m.render.RawContent == "" {
oldColor := color.NoColor
oldCommentWidth := m.CommentWidth
m.LineWidth = 400
color.NoColor = true
m.CommentWidth = 300
m.LineWidth = 400
m.render.RawContent = m.String()
m.CommentWidth = oldCommentWidth
color.NoColor = oldColor
}
m.render, cmd = m.render.Update(msg)
switch msg := msg.(type) {
Expand Down
6 changes: 5 additions & 1 deletion internal/reddit/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package reddit
import (
"github.com/azimut/cli-view/internal/tui"
tea "github.com/charmbracelet/bubbletea"
"github.com/fatih/color"
)

const rightPadding = 10
Expand All @@ -29,11 +30,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
// Initialize data to be used for links scrapping
if m.render.RawContent == "" {
oldColor := color.NoColor
oldCommentWidth := m.CommentWidth
m.LineWidth = 400
color.NoColor = true
m.CommentWidth = 300
m.LineWidth = 400
m.render.RawContent = m.String()
m.CommentWidth = oldCommentWidth
color.NoColor = oldColor
}
m.render, cmd = m.render.Update(msg) // initializes the structs it needed
switch msg := msg.(type) {
Expand Down
8 changes: 6 additions & 2 deletions internal/vichan/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/azimut/cli-view/internal/tui"
tea "github.com/charmbracelet/bubbletea"
"github.com/fatih/color"
)

const rightPadding = 10
Expand All @@ -31,11 +32,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
// Initialize data to be used for links scrapping
if m.render.RawContent == "" {
oldColor := color.NoColor
oldCommentWidth := m.CommentWidth
m.LineWidth = 400
color.NoColor = true
m.CommentWidth = 300
m.render.RawContent = fmt.Sprint(m)
m.LineWidth = 400
m.render.RawContent = m.String()
m.CommentWidth = oldCommentWidth
color.NoColor = oldColor
}
m.render, cmd = m.render.Update(msg)
switch msg := msg.(type) {
Expand Down

0 comments on commit 3101d0d

Please sign in to comment.