itsjunetime / tdf

A tui-based PDF viewer
Mozilla Public License 2.0
295 stars 5 forks source link

really small text #7

Open komprimiert opened 1 week ago

komprimiert commented 1 week ago

hi how do i zoom with this / change the render size? there doesn't seem to be a .config or a man page or a ? key or tdf--help or tdf -h it seems to be vim keys but other than that i can't find anything else

itsjunetime commented 1 week ago

So this is, unfortunately, something that I haven't yet been able to figure out how to implement well (I'll explain in a second). As of right now, this app has no config file or help page, as there are no options to configure and it is currently extremely simple (or at least intended to be), without need for configuration.

The issue with zooming: This app is built to render in the terminal, which means that it is very constrained in what it can show you. It, unfortunately, can't arbitrarily zoom into any image that you're showing, because that's just how terminal image protocols work. You tell it to render an image, and it renders that image, until you tell it to render a different image or some text.

Some image protocols (such as kitty) allow you to display only part of an image, which would allow us to do this zooming efficiently (since we could just display the relevant part of the rendered image), but some others (such as iterm) only support displaying an entire image, which means that we would need to render every single level of zoom that is requested by the user, on-demand, with exactly the scroll and zoom level that the user has set. Unfortunately, that's very expensive to do, and even on very fast computers, doesn't provide a very nice experience.

I would probably be ok with implementing a protocol-based solution (e.g. allow displaying part of an image if you're using kitty, but force re-rendering with the worse experience if you're not), but that would be really difficult to do with ratatui_image (the image library I'm using) since it tries to present a unified interface for all graphics protocols.

That being said: I've thought of ways to implement this, but they're just ugly, would require a lot of annoying hacks and copy-pasted code from other libraries, and would not be performant at all. I have a suspicion that there's a better way to do what I'm describing (as, believe me, I'm also annoyed by this issue; I would also like to have my pdfs fill the page instead of just fit it sometimes), but I haven't quite worked out what it might be yet. If you have any ideas, feel free to mention them - I'm all ears :)

komprimiert commented 1 week ago

I really appreciate your effort As with open source things hopefully someone really smart will have a good idea I think this project will have a bright future