Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change background #42

Merged
merged 4 commits into from
Apr 10, 2024
Merged

Conversation

AnshumanNeon
Copy link
Contributor

Added the ability to change background color in the config file of the theme. To do so you should use "backgroundWindow" parameter in the json file. Example of it is available in the catpuccin.json file of these commits

@AnshumanNeon
Copy link
Contributor Author

@lescx please check if these work. I started work on this after the #34 issue was opened

@lescx
Copy link
Contributor

lescx commented Apr 10, 2024

Ok @lescx. Do you mind adding the background colors for the other themes as well?

  • Dracula: #282a36
  • Gruvbox: #282828
  • Kaolin: #17171a
  • Nord: #2e3440
  • Rose Pine: #191724

@AnshumanNeon
Copy link
Contributor Author

it's alr. I will

@AnshumanNeon
Copy link
Contributor Author

i've done it in #43

@yorukot
Copy link
Owner

yorukot commented Apr 10, 2024

hummm i actually did this what do you think?

model.go

var output = termenv.NewOutput(os.Stdout)
var terminalBackgroundColor = output.BackgroundColor()

var channel = make(chan channelMessage, 1000)
func (m model) Init() tea.Cmd {
	output := termenv.NewOutput(os.Stdout)
	output.SetBackgroundColor(output.Color(theme.TerminalBackground))
	return tea.Batch(
		tea.SetWindowTitle("SuperFile"),
		textinput.Blink,
		listenForchannelMessage(channel),
	)
}
case Config.Quit[0], Config.Quit[1]:
	output.SetBackgroundColor(terminalBackgroundColor)
	return m, tea.Quit

main.go

func main() {
	output := termenv.NewOutput(os.Stdout)
	terminalBackgroundColor := output.BackgroundColor()
	app := &cli.App{
		Name:        "superfile",
		Version:     currentVersion,
		Description: "A Modern file manager with golang",
		ArgsUsage:   "[path]",
		Action: func(c *cli.Context) error {
			path := ""
			if c.Args().Present() {
				path = c.Args().First()
			}

			InitConfigFile()

			p := tea.NewProgram(components.InitialModel(path), tea.WithAltScreen())
			if _, err := p.Run(); err != nil {
				output.SetBackgroundColor(terminalBackgroundColor)
				log.Fatalf("Alas, there's been an error: %v", err)
				os.Exit(1)
			}
			CheckForUpdates()
			return nil
		},
	}

	err := app.Run(os.Args)
	if err != nil {
		log.Fatalln(err)
	}
}

@yorukot
Copy link
Owner

yorukot commented Apr 10, 2024

It sets the terminal color as the background color and on error or exit it returns to the default color

@lescx
Copy link
Contributor

lescx commented Apr 10, 2024

Please just send the code or a diff but not images when asking for code reviews, @MHNightCat

This changes nothing as currently it uses the terminal background color by default.

@AnshumanNeon
Copy link
Contributor Author

but this is exactly what it is doing right now even

@yorukot
Copy link
Owner

yorukot commented Apr 10, 2024

i am so sorry

@AnshumanNeon
Copy link
Contributor Author

it's alright

@yorukot
Copy link
Owner

yorukot commented Apr 10, 2024

So what do you think about this

@lescx
Copy link
Contributor

lescx commented Apr 10, 2024

I like @AnshumanNeon's solution of just using the themes background color. Nothing wrong with that.

@AnshumanNeon
Copy link
Contributor Author

The bg color should match the theme, otherwise no point in a theme. I have just added a lot of .background(backrgoundwindow) in the code. it works. for now.
maybe there is a better way to do the same

@yorukot
Copy link
Owner

yorukot commented Apr 10, 2024

i just did a quick test for it, and it work but seems
image
There are some minor problems in some places
But i can fix it!

@yorukot yorukot merged commit 53819f0 into yorukot:main Apr 10, 2024
@yorukot
Copy link
Owner

yorukot commented Apr 10, 2024

image
just fix it in here

@yorukot yorukot changed the title Anshuman main branch Change background Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants