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

Ideas for better handling of long preformatted text lines #184

Open
mikejzx opened this issue Mar 4, 2021 · 1 comment
Open

Ideas for better handling of long preformatted text lines #184

mikejzx opened this issue Mar 4, 2021 · 1 comment
Labels
enhancement New feature or request gemini-text This issue is related to the gemini text format html This issue is related to html display

Comments

@mikejzx
Copy link
Contributor

mikejzx commented Mar 4, 2021

The problem

When viewing some pages (e.g gemini://random-projects.net/blog/2021-03-03-distributed-trust.gemini) the preformatted text can sometimes exceed the window/screen width and become unreadable:

image
(That's an example of it exceeding window width, but it actually exceeds my screen's width too)

Of course, according to the spec, we aren't supposed to do any line wrapping or anything to preformatted text. Instead the spec encourages an alternative approach - scroll bars:

Graphical clients should use scrolling mechanisms to present preformatted text lines which are longer than the client viewport, in preference to wrapping.

Currently, horizontal scrollbars on the KristallTextBrowser widget are actually disabled (as of #153, see this which I forgot to mention in that PR's description). I chose to disable it because since the text-width stuff (#149) was introduced, if a horizontal scrollbar was visible it would allow a user to "scroll the left/right margins" of the document, which looked really strange and most people would consider it a bug.

I should add that since the text-width stuff was added (before scrollbar was disabled), a horizontal scrollbar would show if there was any preformatted text lines longer than the max text width. The below diagram demonstrates that:

image

In current kristall builds, a curious user will be able to realise that the horizontal scrollbar is in fact just "hidden", because it is actually still possible to scroll horizontally in pages with long preformatted lines, by selecting some text and moving the mouse to the left/right edge of the KristallTextBrowser widget (it demonstrates the "left/right margin scrolling" I discussed above)

Potential solutions

There are two potential ways I can think think of to solve this:

The lagrange method

Lagrange tries to solve this same problem by reducing the font size of long preformatted lines:
image
(note how the first preformatted text is normal size, and the long line is smaller)

The two problems with this method are obviously:

  • Doesn't work for very long lines without making text literally unreadable (lagrange clamps to a minimum size)
  • Long lines are harder to read due to reduced font, which in effect is tampering with the user's preferred font size

The other "embedded scrollbars" method

The other method which I think would be ideal is to create a seperate scrollbar for these long preformatted blocks, like demonstrated below (mocked up in GIMP, so it doesn't look super-pretty)

image

However, it might be really tricky to embed one of these into a QTextDocument. I have no idea if it's even possible.

Just some ideas to think about 😉

@ikskuh
Copy link
Owner

ikskuh commented Mar 4, 2021

I would definitly prefer the second version, using embedded scroll bars for the text blocks. You can see that this looks pretty neat in the web version of random-projects.net.

I have no idea though how to display it properly. One option would be to write the rendering module for gemtext ourselfs (which i would rather not) or just split the "document view" into multiple QTextBrowser. This would break text selection though...

@ikskuh ikskuh added enhancement New feature or request gemini-text This issue is related to the gemini text format html This issue is related to html display labels Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gemini-text This issue is related to the gemini text format html This issue is related to html display
Projects
None yet
Development

No branches or pull requests

2 participants