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

[WIP] Feature/combi format string #1123

Draft
wants to merge 7 commits into
base: next
Choose a base branch
from

Conversation

jchtt
Copy link

@jchtt jchtt commented May 12, 2020

This PR adds the ability to customize the output of combi mode as described here.

I tried using uncrustify but a) got an error (unknown option 'align_number_left'), and b) noticed that it changed a bunch of other files, so left it like this for now.

It's basically done, but I added WIP because I’m not super familiar with C (would like some code review, it’s pretty short) and I’d still have to write the documentation for it.

@DaveDavenport
Copy link
Collaborator

I can see the use of adding -combi-display-format. I am a bit weary of the other 3 options;

The option -markup-combi breaks entries from modi that do not use markup. If the entry contains a special character for the pango markup, it will fail to render.

I don't see the point of the linebreak options, I think they will cause a lot of confusion.

@jchtt
Copy link
Author

jchtt commented May 12, 2020

Thanks for taking a look!

The option -markup-combi breaks entries from modi that do not use markup. If the entry contains a special character for the pango markup, it will fail to render.

Ah, that’s annoying, I agree. Is there a way of escaping them if the mode does not set the style flag?

I don't see the point of the linebreak options, I think they will cause a lot of confusion.

I admit it’s a bit tricky. The point was to be able to have a nice two line layout where both the mode and parts of the original entry can appear on the first line. That’s only possible if I can have the line break appear either in the -combi-display-format or in the format string of the mode in question, as in the example on reddit. It can be easily ignored if people don’t want to use it, for example in the default format string {mode} {element}.

@DaveDavenport
Copy link
Collaborator

if you check if the called modi does not set the markup flag, you can use that to escape the returned string.

@jchtt jchtt marked this pull request as draft May 13, 2020 01:33
Comment on lines 255 to 267
if ( !(*state & MARKUP) && config.markup_combi ) {
// Mode does not use markup, but we want to, so escape output
char * tmp_str = g_markup_escape_text( str, -1 );
g_free(str);
str = tmp_str;
*state |= MARKUP;
}
if ( (*state & MARKUP) && !config.markup_combi ) {
// Mode does use markup, but we did not want to, so escape pattern string
char * tmp_str = g_markup_escape_text( format_str, -1 );
g_free(format_str);
format_str = tmp_str;
}
Copy link
Author

Choose a reason for hiding this comment

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

This should take care of the escaping.

Copy link
Collaborator

Choose a reason for hiding this comment

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

To avoid confusion, wouldn't it be better to remove the markup_combi option and always do markup (and convert element that is not markup).

So the combi_display_format option is always a markup string. (don't think this is unreasonable, and how drun-display-format works)

Copy link
Author

@jchtt jchtt May 13, 2020

Choose a reason for hiding this comment

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

Done! For now, I always enabled markup, without checking if there was a custom combi_display_format set, I hope this is OK (the same as drun, that also enables markup by default).

If you think the other two options are OK, I‘ll try to put some documentation in the man page.

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.

None yet

2 participants