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

Is there a way to calculate secondary_prompt length? #375

Open
snuyanzin opened this issue Apr 11, 2019 · 3 comments
Open

Is there a way to calculate secondary_prompt length? #375

snuyanzin opened this issue Apr 11, 2019 · 3 comments

Comments

@snuyanzin
Copy link
Contributor

snuyanzin commented Apr 11, 2019

Especially interested in case of usage of colorized dynamic prompt, i.e. do not want to take into account color symbols

@gnodet
Copy link
Member

gnodet commented Jul 4, 2019

Could you give a bit more details ? I'm not sure where your code would be or what the input would be. The secondary prompts are computed as a List<AttributedString> and the AttributedString has a length() method which returns the number of characters. You also have columnLength() which returns the number of columns taking into account wide characters.

@snuyanzin
Copy link
Contributor Author

snuyanzin commented Jul 4, 2019

Sorry for delay.
The initial idea was to use this length for padding calculation for secondary prompt especially for cases when secondary prompt contains colorized symbols or line numbers.
But then I found %P for that and currently I use

.setVariable(LineReader.SECONDARY_PROMPT_PATTERN, "%N%P %M> ");

and the result is
image
The issue with this approach that I could not find a way how I can do padding not just with one char but with several e.g. . rather than just space. So I want to see something like this

sqlline> !set prompt '%[foreground:yellow,bold,italic%]my_sql_prompt> '
my_sql_prompt> select
2. .semicolon> 1
3. .semicolon> from
4. .semicolon> dual;

@gnodet
Copy link
Member

gnodet commented Jul 4, 2019

There's no easy way to do that without changing the code right now. I think this would require a new pattern which would use a string rather than a single char.
Another way would be to have a way to plug in some processing but the two insertSecondaryPrompts are currently private.

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

No branches or pull requests

2 participants