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

Add optional feature: alternating line colors #2903

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

v972501
Copy link

@v972501 v972501 commented Aug 30, 2023

Hello. I really like micro editor and wanted to add this feature. It alternates line colors like in old printer terminals or like excel spreadsheets - it makes navigation easier, especially with long lines:

Imgur
Code introduces a new bool option: altlinecolors, it's set to false by default. If it's set to true and alt-line color is given in the colorscheme, then it would change every other line's bg color to a specified one. I've included a demo colorscheme as well. I also posted a video demo in the Gitter group.

@v972501 v972501 changed the title Alternating line colors Add optional feature: alternating line colors Aug 31, 2023
@@ -489,6 +489,23 @@ func (w *BufWindow) displayBuffer() {
bloc.X = bslice

draw := func(r rune, combc []rune, style tcell.Style, highlight bool, showcursor bool) {
if b.Settings["altlinecolors"].(bool) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TL;DR I believe this code is messy and buggy. Please see my below descriptions of the bugs I've found. But instead of addressing them individually, I suggest to simply replace this implementation with dmaluka@18d9c5c (which not only simplifies the code but also makes these bugs go away).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great refactor, thank you! Can I replace my changes with it in this pull request? (I'm new to github, sorry if it's silly question)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you can use git push --force. (I'm assuming you are using git, not just github UI?)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, replaced with proposed refactor.

internal/display/bufwindow.go Outdated Show resolved Hide resolved
internal/display/bufwindow.go Outdated Show resolved Hide resolved
@v972501
Copy link
Author

v972501 commented Sep 2, 2023

I've added alt-line colors to some runtime colorschemes.
here's preview of non-tc ones with MICRO_TRUECOLOR=0 COLORTERM=24bit env:
Imgur
-tc ones with MICRO_TRUECOLOR=1 COLORTERM=truecolor env:
Imgur

@dmaluka
Copy link
Collaborator

dmaluka commented Sep 2, 2023

To me personally, in your truecolor colorschemes, the difference between alt-line and normal line colors is barely noticeable (unless I look closely). Is it just me?

@v972501
Copy link
Author

v972501 commented Sep 3, 2023

To me personally, in your truecolor colorschemes, the difference between alt-line and normal line colors is barely noticeable (unless I look closely). Is it just me?

I tried making them brighter, but they would become very similar to cursor-line color.
Making them darker than default lines didn't look very good.

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.

None yet

2 participants