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

[Feature request] Add option to control or disable indentation of paragraphs in terminal output #129

Closed
itshog opened this issue Dec 3, 2023 · 4 comments

Comments

@itshog
Copy link

itshog commented Dec 3, 2023

Would it be possible to add a command line option which disables the indentation of normal paragraphs in -tterm output? I'm thinking about something like --term-no-indent for disabling indentation globally, or --term-indent=code,lists,paragraphs,tables... to specify exactly what should be indented if we need more granularity.

My use case for this is using lowdown for previewing markdown files in vifm (but I guess the same applies for almost every terminal file manager), and having so much empty space between the file list and the preview looks ugly and needlessly shrinks the space for the actual text (I'm attaching a couple of screenshots to show what I mean). I know that I could just pipe the output into sed 's/^ *//g' to remove the leading white spaces, but this lacks granularity (it doesn't differentiate between paragraphs, lists, code blocks etc.) and needs an external utility to accomplish something that IMO could be an option in lowdown itself.

Anyway, thanks for the great piece of software!

20231203_13h18m07s_grim
20231203_13h18m09s_grim
20231203_13h20m21s_grim
20231203_13h20m31s_grim

@kristapsdz
Copy link
Owner

If you have control of the software from source, you can edit term.h line 167 to be

static const struct pfx pfx_body =	{ "", 0 };

This is the style applied by terminal output to regular text. I think a better feature request would be to read in a file, if provided, that styles the text in a non-hard-coded way.

@itshog
Copy link
Author

itshog commented Dec 7, 2023

If you have control of the software from source, you can edit term.h line 167 to be

static const struct pfx pfx_body =	{ "", 0 };

This is the style applied by terminal output to regular text. I think a better feature request would be to read in a file, if provided, that styles the text in a non-hard-coded way.

Thanks for the response! Honestly, in my opinion the details of the implementation for this feature don't matter that much from the end user point of view: it could be a command line flag, it could be a user-provided file containing information about the style, it could be some sort of configuration file in ~/.config or something else, as long as it achieves the aforementioned granularity that piping into sed doesn't have.

@WhyNotHugo
Copy link

I'm needing this too. I'm using lowdown to preview files in fzf, but the indentation really breaks things apart.

There's the --term-hmargin=margin flag, which defaults to zero, but this value is not respected for paragraphs; paragraphs always have a hardcoded indentation of four.

Should the value of --term-hmargin be used instead of the hardcoded value here?

@kristapsdz
Copy link
Owner

Ok, a more elegant fix is in the works. First, I'm introducing --term-hpadding, which does what the default term.h body value did: introduce a left-padding that cuts into the --term-width. It defaults to 4 to preserve existing layouts. While here, I fixed some off-by-ones for cleaner output and am also clarifying:

| columns                                   |
| hmargin | hpadding | ---content--- |      |
          | width                    |      |

At some point, I want to introduce RTL capabilities, so this isn't quite future-proof yet, as --term-hmargin and --term-padding don't affect the right-hand side of the output.

kristapsdz added a commit that referenced this issue Dec 21, 2024
This introduces an ABI change to `struct lowdown_opts`.

Split out the terminal-related members of `lowdown_opts` into
`lowdown_opts_term` and push processing of its variables directly
into term.c, where it belongs.

References #129
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

3 participants