Open hagfelsh opened 4 years ago
It does not have a pagination feature, But it could. I have written several “pagers” using blessed, one in x/84, and one in wcwidth. I will include a link shortly.
And blessed should mix with any other library, this problem is solved in curses module, and maybe others like urwid, but I don’t have a recommendation.
If it can be done succinctly, and have tests and documentation, I’m very open to expanding blessed to support more things—so long as it still allows developers to be creative and flexible, I just don’t want it to be “opinionated” about style and appearance.
And thank you for thanking me, about the docs, I lost my job last year and the very first project I did that i thought would benefit others was a complete rewrite of the blessed docs over a lonely Christmas period, so it makes me happy to hear that you enjoy having it, I hope you are being creative and having fun doing it!
Both of these pagers are very specific and detailed and long, I wouldn't include anything of that size in blessed, i would want something more basic in blessed
Thanks for the nudge! I'll start poring over them to see which makes the most sense.
I'm writing the first thing I've ever written in python and after weeks of research on what modules would cover the most ground, blessed handily eliminated the others. For a new writer, its name is certainly a match for how it's been using it :) Sorry about the job, I hope you're back at it now?
I've found myself in a puzzle. I made a pager that prints lines of a list using indexing slices as the top and bottom limits. User key strokes modify the index slices and calls the for loop again to redraw the new range.
This is great if everything you ever wanted is in that list, but ... what about lovely features like term.move_xy() that let me have little side-boxes of text elsewhere? Those don't fit into an iterator very well unless the composite line is flattened before being added to the list i'm printing through.
How would you handle displaying content that doesn't start at 0,0 with a pager?
Glad to hear you perused this :)
what about lovely features like term.move_xy() that let me have little side-boxes of text elsewhere?
How would you handle displaying content that doesn't start at 0,0 with a pager?
Good question. What I did with x/84, is create a type of "window", so your pager could be just 20% of the window width and height, and, you would use a position function attached to the window, so (0, 0) in the window might translate to (10, 5) on the screen.
And then I would subclass this window, to make "pagers" and "editors" or "lineeditors", https://github.com/jquast/x84/blob/master/x84/bbs/ansiwin.py#L169-L172 and https://github.com/jquast/x84/blob/master/x84/bbs/pager.py#L223 for example.
In the curses library, you can use the newwin()
function, https://docs.python.org/3/library/curses.html#curses.newwin to create a smaller window on the screen, which returns the same Window object as the initscr()
function you would otherwise use. https://docs.python.org/3/library/curses.html#curses.initscr
So they both accept the same functions, like addch(y, x, ch)
in a position-relative manner.
I hope this answers your question, using curses directly may be your best solution. Urwid also provides some of this functionality. Blessed can mix-in with any of these, it tries to make some of the most complicated parts of curses easy to use, but it doesn't replace all of it.
I think I've read every line of readthedocs... but I'm terribly new at Python so I might not have recognized a pagination function even as I read it.
Does one exist in blessed? And if not... do you have any recommendations? Blessed has solved every other problem I had so far so I'd love to stay close to home if its possible :)
Also, thank you for your marvelous documentation. It's been so incredibly helpful.