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

[Bug]: 0.118.0 No cursor when using black text on white background (regression: worked in 0.117.0) #2653

Closed
Jamie-Landeg-Jones opened this issue Mar 11, 2022 · 19 comments

Comments

@Jamie-Landeg-Jones
Copy link

Problem description

Whilst it was fine in 0.117.0, the cursor is no longer visible with 0.118.0 when using a black text on white background theme.

Steps to reproduce the behavior.

install 0.118.0 and set the foreground and background colours appropriately, or install one of the black on white themes

What is the expected behavior?

A visible cursor!

System information

  • Termux application version: 0.118.0
  • Android OS version: 9
  • Device model: Chromebox Reference
@agnostic-apollo
Copy link
Member

Can you provide screenshots for differences or at least of issue and the exact theme you are using.

@Jamie-Landeg-Jones
Copy link
Author

Jamie-Landeg-Jones commented Mar 11, 2022

I was just using white background colour and black foreground in colors.properties but the same thing happens with any white background, for instance, the "black on white" style.

termux.mp4

Attached is a quick demonstration - at the end i'm pressing cursor-left - you can see how the text on the command line
responds

I just had a further look around, and this looks suspect: 4a74618

I tried adding this to colors.properties but it didn't do anything:

cursor: #ffA9AAA9

I can't compile the source at the moment, so I wasn't able to try regressing the above patch.

It would seem to be useful if the default cursor colour was dark when the background colour is close to white. Or maybe an option to set the cursor colour?

Let me know if you need anything else.

Thanks, Jamie

(Apologies for the edits, my browser went mental and I had to force-close it)

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Mar 12, 2022

cursor: #ffA9AAA9

You need to add cursor: #000000 to ~/.termux/colors.properties after selecting Black on White theme. Then restart termux or run termux-reload-settings.

I just had a further look around, and this looks suspect: 4a74618

Yeah, previously default color was grey and was changed to white with the commit cause its easier to read text with white as contrast. However, issue is not with the commit, but with the color themes. "Some" don't have cursor key set and were relying on termux default value grey. Anyways, I'll look into fixing the termux-provided themes when I merge termux-styling with termux-app soon.

The default color will not be changed though since if you are using custom theme, then it's your responsibility to set colors appropriately. There should ideally have been a wiki for it.

Let me know if you need anything else.

Well... Now, that you mention it...

Apologies for the edits, my browser went mental and I had to force-close it)

Yeah, yeah, blame the poor browser...

@dessalines
Copy link

When using android dark mode, the cursor color in color.properties is completely ignored, and is alway black.

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Mar 12, 2022

When using android dark mode, the cursor color in color.properties is completely ignored, and is alway black.

It's working fine on my android 11. Dark mode with cursor=#ffffff sets a white cursor. As far as I see, night mode should not affect terminal colors and only other components like left drawer, etc.

What's your termux app version?

Post colors.properties and screenshots/video.

@dessalines
Copy link

Yep just verified again, this is only an issue when using android dark mode, it ignores the cursor color.

termux-info
Application version:
0.118.0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://termux.mentality.rip/termux-main stable main
Updatable packages:
apt/stable 2.4.1 aarch64 [upgradable from: 2.3.15-1]
command-not-found/stable 1.74 aarch64 [upgradable from: 1.73]
curl/stable 7.82.0 aarch64 [upgradable from: 7.81.0-2]
dialog/stable 1.3-20220117-0 aarch64 [upgradable from: 1.3-20211214-0]
libcurl/stable 7.82.0 aarch64 [upgradable from: 7.81.0-2]
libexpat/stable 2.4.7 aarch64 [upgradable from: 2.4.6]
starship/stable 1.4.2 aarch64 [upgradable from: 1.3.0-2]
termux-tools/stable 0.167 all [upgradable from: 0.166]
Android version:
11
Kernel build information:
Linux localhost 4.14.180-perf-g6231c11929a2 #1 SMP PREEMPT Mon Jan 17 03:17:34 CST 2022 aarch64 Android
Device manufacturer:
Xiaomi
Device model:
21051182G

@agnostic-apollo
Copy link
Member

So actual file name is colors.properties, not color.properties. Even I miswrote above. Can you try adding it to ~/.termux/colors.properties? That could be the issue.

@dessalines
Copy link

You'll notice the cursor is black, yet the code is #ffffff. As soon as I switch to light mode, it correctly is able to change the cursor color.

IMG_20220312_155531

@agnostic-apollo
Copy link
Member

hmmm, I even installed github 0.118.0 release apk in case any later commits changed the behaviour, but worked fine even with it.

I'll test with android avd later and report back, could be a device specific issue. Are you using f-droid or github builds in case debugging is required?

Was it broken on older releases as well or 0.118.0 broke it? There were theming changes done in the release, although terminal cursor color setting is separate and manually done.

@dessalines
Copy link

f-droid builds. I don't know if it worked or was broken previously, as this is the only version of termux I've used.

@Jamie-Landeg-Jones
Copy link
Author

cursor: #ffA9AAA9

You need to add cursor: #000000 to ~/.termux/colors.properties after selecting Black on White theme. Then restart termux or run termux-reload-settings.

The thing is, this is "what I did", but rather, I chose the original grey cursor as shown above, but it didn't work. If it had, I'd not have logged the ticket....

But... I was an idiot (again). If you look at the command I quoted, I had an extra "ff" before the colour code.

Removing it and everything works as expected.

Yeah, previously default color was grey and was changed to white with the commit cause its easier to read text with white as contrast. However, issue is not with the commit, but with the color themes. "Some" don't have cursor key set and were relying on termux default value grey. Anyways, I'll look into fixing the termux-provided themes when I merge termux-styling with termux-app soon.

That makes sense, and I'd have come to the same conclusion if I'd managed to set "cursor" correctly. My stupid mistake made me think "cursor" wasn't an accepted instruction (I couldn't see it in the docs)

The default color will not be changed though since if you are using custom theme, then it's your responsibility to set colors appropriately. There should ideally have been a wiki for it.

Yes, and that's what I attempted to do, but the cockup was mine.

My only suggestion - it may avoid stupid tickets like this, and ones regarding themes... How about, if cursor color isn't set by the users config, instead of default it to #ffffff always, instead set it to #000000 if background-color >> #800000

Let me know if you need anything else.

Well... Now, that you mention it...

gulp me and my big mouth!

Apologies for the edits, my browser went mental and I had to force-close it)

Yeah, yeah, blame the poor browser...

Well, I know my track record doesn't really support my case, but that's the excuse I'm sticking with. If you don't believe that, then how about "my dog ate my browser", or my cat posted the comment when I was preparing food for him (he's sly that way)

Anything but take personal responsibility, of course!

slips off embarrassedly

@wizdoux
Copy link
Contributor

wizdoux commented Mar 31, 2022

@Jamie-Landeg-Jones so, the problem is solved?

@Jamie-Landeg-Jones
Copy link
Author

Jamie-Landeg-Jones commented May 10, 2022

@Jamie-Landeg-Jones so, the problem is solved?

Apologies for the delay - I missed the notification for this.

It's "solved' for me, in that I could manually change the cursor color after I realised I messed up my original attempt.

The other issues reported in this thread are presumably still present.

I don't know the intricacies of the code, so this may be dumb, but I did suggest that if no cursor color is specified, default it to black for light backgrounds, white otherwise. Brightness can be calculated using something like.

sqrt (c.R * c.R * .241 + c.G * c.G * .691 + c.B * c.B * .068)

(from https://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx )

@wizdoux
Copy link
Contributor

wizdoux commented May 10, 2022

@agnostic-apollo i think you can close this issue

@agnostic-apollo
Copy link
Member

I did suggest that if no cursor color is specified, default it to black for light backgrounds, white otherwise. Brightness can be calculated using something like.

@Jamie-Landeg-Jones thanks for the math! I have added your request and seems to be working good with different backgrounds. You can test yourself if using github builds.

https://github.com/termux/termux-app/actions/runs/2509680073

https://github.com/termux/termux-app#Installation

gulp me and my big mouth!

Too late now, time to pay up! ;)

"my dog ate my browser"

That's not how you are supposed to bury your browser history!

slips off embarrassedly

Me at @termux does not let people get away that easily. You stay right here.

@agnostic-apollo
Copy link
Member

@dessalines Sorry dude, I tried again and can't reproduce it. A video would be helpful, you can also send me privately at [email protected]

Does it happen outside text editors too?

Best way to debug this would be with logs. I can add them to the app and you can install and send them back. But you would need to use github builds. Since you installed from F-Droid, you would have to uninstall it first due to different signing keys of F-Droid and github builds, optionally after backing up. Let me know if you are willing to do that.

https://github.com/termux/termux-app#Installation

https://wiki.termux.com/wiki/Backing_up_Termux

@agnostic-apollo
Copy link
Member

If reinstalling from github, use the build at https://github.com/termux/termux-app/actions/runs/2518728695 instead, it has an unrelated bug fix for bootstrap not being installed.

@dessalines
Copy link

I reinstalled and it appeared to fix the issue.

@agnostic-apollo
Copy link
Member

Great. Thanks.

AdamMickiewich pushed a commit to VolyaTeam/dzida-app that referenced this issue Aug 8, 2022
… instead of always white if colors.properties didn't have cursor color set

Credit for algorithm link belong to @Jamie-Landeg-Jones

Closes termux#2653
shrihankp pushed a commit to reisxd/termux-app that referenced this issue Oct 20, 2022
… instead of always white if colors.properties didn't have cursor color set

Credit for algorithm link belong to @Jamie-Landeg-Jones

Closes termux#2653
agnostic-apollo added a commit that referenced this issue Jun 17, 2024
… instead of always white if colors.properties didn't have cursor color set

Credit for algorithm link belong to @Jamie-Landeg-Jones

Closes #2653
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants