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

feat(control char): add basic control char support #238

Merged
merged 14 commits into from
Jan 10, 2022

Conversation

cmsxbc
Copy link

@cmsxbc cmsxbc commented Sep 10, 2021

Try to fix #138

Description

  • A basic solution for control chars render (\n, \r, \b, \t)

reproduce

# any mono font is good.
./i3lock -t -e -f -n --no-verify \
    --greeter-pos=1200:500 \
    --greeter-font="Cascadia Code" \
    --greeter-text="A example
$(printf 'newline\nnewline')
$(printf 'carriage\rreturn')
$(printf 'newline\r\nreturn')
$(printf 'tab\ttab')
$(printf 'backspace\bbackspace')
$(printf '\rdef    def')
$(printf 'tabtab\ttab')
$(printf 'tabtabtab\ttab')"

Screenshots/screencaps

before fix.

40639034-D623-4787-978B-FB434A7417D5

after fix.

D09B2B22-AC0E-4174-9C5D-C384BDD04D7B

Release notes

Notes: Support basic control chars.(\n \r \b \t)

@Raymo111
Copy link
Owner

This looks great. Can you add \t support as well, or would that be too difficult?

@cmsxbc
Copy link
Author

cmsxbc commented Sep 10, 2021

This looks great. Can you add \t support as well, or would that be too difficult?

Yep, I will have a try, but i don't know the exactly behavior of \t yet, especially when the font is not monospace.
Or maybe I could just replace \t with 2 spaces (or 4, 8 or any other user configured) ?

@Raymo111
Copy link
Owner

Actually you know what, I don't think tab is very useful or necessary. People can just just multiple spaces.

@cmsxbc
Copy link
Author

cmsxbc commented Sep 10, 2021

Actually you know what, I don't think tab is very useful or necessary. People can just just multiple spaces.

So do I. I just have implemented a \t with same behavior as printf in c

Copy link
Owner

@Raymo111 Raymo111 left a comment

Choose a reason for hiding this comment

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

I like that this works without printf as well (just put the characters in a script). Nice job. Can you document your changes in the manpage (and bump the manpage date to Sep 2021) please?

Copy link
Owner

@Raymo111 Raymo111 left a comment

Choose a reason for hiding this comment

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

More importantly, bug: when there's a tab character immediately after a newline the 2nd line goes all the way to the left of the screen:
2021-09-19-011325_3840x2160_scrot

@cmsxbc
Copy link
Author

cmsxbc commented Sep 19, 2021

Done, and I'm not good at English, please fix me if there is any unreadable thing.

Copy link
Owner

@Raymo111 Raymo111 left a comment

Choose a reason for hiding this comment

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

LGTM

@Raymo111 Raymo111 merged commit 1e284b9 into Raymo111:master Jan 10, 2022
@ShadiZade
Copy link

Hey, This just doesn't work for me. I even used your exact same example code, and the problem in your first image still shows up. Here's my code:

numofdays=$(date +"%j")
numofweeks=$(echo "scale=1; $numofdays/7" | bc )
i3lock -kef -c aa2200ff --radius 150 --ring-width 5.0 --ring-color=000000ff \
	 --ringver-color=000000ff --insidever-color=00000000 --ringwrong-color=000000ff \
	 --insidewrong-color=00000000 --keyhl-color=ffffffff --bshl-color=aa2200ff \
	 --date-font="Inconsolata Semi Condensed SemiBold" --verif-font="Inconsolata Extra Condensed ExtraBold" \
	 --time-font="Inconsolata Extra Condensed ExtraBold" --layout-font="Inconsolata Extra Condensed ExtraBold" \
	 --wrong-font="Inconsolata Extra Condensed ExtraBold" --wrong-text="INCORRECT" --verif-text="UNLOCKING" \
	 --noinput-text="" --verif-size=22 --wrong-size=22 --time-size=75 --date-size=18 \
	 --date-str="%a, %e %b %Y ("$numofweeks" weeks)" \
	 --greeter-text="A example
	 $(printf 'newline\nnewline')
	 $(printf 'carriage\rreturn')
	 $(printf 'newline\r\nreturn')
	 $(printf 'tab\ttab')
	 $(printf 'backspace\bbackspace')
	 $(printf '\rdef    def')
	 $(printf 'tabtab\ttab')
	 $(printf 'tabtabtab\ttab')" \
	 --no-verify

Here's the info
i3lock: version 2.13.c.4
zsh 5.9 (x86_64-pc-linux-gnu
Kernel: 5.18.12-3-MANJARO
awesome v4.3

@Raymo111
Copy link
Owner

Raymo111 commented Jul 21, 2022

@ShadiZade try with Bash? (it works for me)
Check your bash version as well.

@ShadiZade
Copy link

@Raymo111 Nope, doesn't work with bash either.
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)

@Raymo111
Copy link
Owner

I'm on the same version of bash. What happens when you run it as a script after adding #!/bin/bash to the top?

@ShadiZade
Copy link

same thing.

@Raymo111
Copy link
Owner

Sorry, not sure then. I copy-pasted your code into a blank bash script and it worked...

@cmsxbc
Copy link
Author

cmsxbc commented Jul 21, 2022

@ShadiZade I think this fix is not included in 2.13.c.4 which released at June 5, 2021. And this fix merged into master at Jan 11, 2022.

@ShadiZade
Copy link

@cmsxbc how come the AUR package is so far behind?

P.S. I tried installing i3lock-color-git from the AUR, and it threw me a bunch of errors about the --no-verify flag. the \n worked though.

@ShadiZade
Copy link

@Raymo111 I went ahead and built the package manually. It worked (looks like @cmsxbc was right), but only in the greeter text. Was it never meant to work in the date string?

@Raymo111
Copy link
Owner

@ShadiZade I'm using i3lock-color-git from the AUR and everything works, no errors with the no-verify flag. I haven't created a new release in a year now hence the discrepancy between the packages/releases and self-built ones, I'll spin up a new release next week.

@ShadiZade
Copy link

Very well, thanks for your efforts. One last question: is the linebreak supposed to work in the date string, or only in the greeter text?

@Raymo111
Copy link
Owner

It's supposed to work everywhere.

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.

Support control characters (\n, \r, \b, \t)
3 participants