-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
Print QR code to terminal #524
Conversation
af4b75f
to
7853a9d
Compare
889e869
to
05ddf23
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty clean but somehow it doesn't scan for me.
src/main.rs
Outdated
{ | ||
match QrCode::encode_text(&url, QrCodeEcc::Low) { | ||
Ok(qr) => { | ||
println!("QR code for {} :", Color::Green.paint(url).bold()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
println!("QR code for {} :", Color::Green.paint(url).bold()); | |
println!("QR code for {}:", Color::Green.paint(url).bold()); |
src/main.rs
Outdated
// Prints the given QrCode object to the console. | ||
fn print_qr(qr: &QrCode) { | ||
let border: i32 = 4; | ||
for y in (-border..qr.size() + border).step_by(2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you print a two character-wide white border around these? This might fix the code not scanning properly on black terminals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this properly~ I mean the content is already white. If doesn't scan then the problem more probably is with the rendering code print_qr
because I modified it from https://github.com/nayuki/QR-Code-generator/blob/master/rust/examples/qrcodegen-demo.rs to show smaller code. But I have tested it locally and it scans well.
Can you try another scanner to pinpoint the cause here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it and it works on my CLI if the colors are reversed (and with a border). If you want to try it:
echo "lolomg" | qrencode -t UTF8
works but echo "lolomg" | qrencode -t UTF8i
doesn't.
Suggestion, since we have lots of horizontal space anyway: Just put the inversed and bordered version right next to the other one. This way, we'll make sure it works for everybody.
05ddf23
to
94940ad
Compare
src/main.rs
Outdated
// Prints the given QrCode object to the console. | ||
fn print_qr(qr: &QrCode) { | ||
let border: i32 = 4; | ||
for y in (-border..qr.size() + border).step_by(2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it and it works on my CLI if the colors are reversed (and with a border). If you want to try it:
echo "lolomg" | qrencode -t UTF8
works but echo "lolomg" | qrencode -t UTF8i
doesn't.
Suggestion, since we have lots of horizontal space anyway: Just put the inversed and bordered version right next to the other one. This way, we'll make sure it works for everybody.
Followup for #341
Based on #500
Closes #45