-
Notifications
You must be signed in to change notification settings - Fork 9
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
Khard - Supporting a command using user input and escape sequences #28
Comments
Hello Tomasz, thank you for your report. |
By the way, you made a nice description of the problem. Congratulations ! |
Thank you @mbornet-hl I just posted a solution in a new issue at Khard. Your links helped me to eliminate the most obvious possibility (forcing the flush). it did not work, but adding some more newlines in the code worked. hl could still be involved in the issue because piping to |
Thank you for your quick answer. |
OK, no need to write C programs to test, I'm able to reproduce the problem with the following shell commands : So I confirm that there's a problem in the way hl reads its input. |
About Nice test with the I checked it with every pager I have (bat, less, more, glow) and they all wait for an end of line. So hl is behaving more like a pager than cat on this issue. |
I typed something wrong and made a mistake in the previous message. This command works fine:
The Prompt is not colorized (the rest is), but it's displaying at the right time. The |
I just posted a bit of an analysis at the corresponding issue for khard](lucc/khard#333 (comment)). I also think the problem is routed in input/output buffering but I am not sure if there is even a solution: I did not read your source and could not find a hint in the readme but I assume that hl works in linewise mode. So I assume it waits for a complete line on stdin until it starts to match and output that line. But I do not know if there is any way around it. You could of course check all the regexes in the active config and for some unfinished input you can know that it will not be part of a match but for some other partial lines you never know if they will match at some later point. See for example (echo -n foo; read x; if [ -z "$x" ]; then echo bar ; else echo baz; fi) | hl -eg '(f)ooba(r)' |
Introduction
I use khard to search and edit my vcard contacts.
The main issue was that it was designed for the console, so I wrote a config for hl and a function to call it with khard.
For a simple listing, there is no issue:
khard | hl --khard
But a more useful command in khard is
show
to get details for one contact, it filters the list with options or by asking the user to provide an index number manually:khard show
2
Issues
When
khard show
is piped to hl the user promptEnter Index (0 for None, q to quit):
is not visible before user input.khard show | hl --khard
After the user input, there is an issue with the escaping sequence and the prompt appears on the first line of the output, with the name of the contact.
2
Question
This kind of command (khard show) is probably not designed to be piped so I don't want to open an issue with khard at first.
Is there a way to solved that on hl side?
Reproduce
~/.config/khard/khard.conf
~/.contacts/fake/Jane_Doe.vcf
~/.contacts/fake/John_Doe.vcf
The text was updated successfully, but these errors were encountered: