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

Support rendering to a subregion of the terminal #293

Closed
dankamongmen opened this issue Jan 24, 2020 · 16 comments
Closed

Support rendering to a subregion of the terminal #293

dankamongmen opened this issue Jan 24, 2020 · 16 comments
Assignees
Labels
demo relevant to notcurses-demo documentation Improvements or additions to documentation enhancement New feature or request
Milestone

Comments

@dankamongmen
Copy link
Owner

While documenting #77, the video question gave me pause. it would be pretty neat to run a (small, heh) video in the terminal below your prompt ala lsix but with video. now, imagine, you can't have this going while you've got your next program running attached to the term, but it can run until then without blowing away the screen, right?

well if there's nothing else running, there's no threat of scrolling, in which case we're actually just rendering to a subregion of the terminal. and i think that's the way to get this effect. allow the toplevel notcurses object to be restricted to a subregion (whether this ought be defined by a static geometry or a static margin is an open question). the subregion will be expressed in a fashion that allows it to be symbolically offset from the current cursor position (which we must be able to retrieve, but can be done much more portably than acquiring screen content).

this isn't high priority by any means, but something to think about.

@dankamongmen dankamongmen added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 24, 2020
@dankamongmen
Copy link
Owner Author

It would be awesome if this could be combined with #310 (at least in concept) so that we could run one notcurses program within an ncplane of another.

@dankamongmen dankamongmen added this to the 1.3.0 milestone Feb 18, 2020
@dankamongmen dankamongmen self-assigned this Feb 21, 2020
@dankamongmen
Copy link
Owner Author

So the geometry vs margin question....which of the following do we want the user to be able to specify?

  • Exact size independent of resize (screen must be large enough)
  • Minimum size, no restriction on how large it can get
  • Maximum size, no restriction on how small it can get
  • An absolute range of sizes
  • Exact margins
  • Minimum margins
  • Maximum margins

@dankamongmen
Copy link
Owner Author

I'm thinking maybe minimum size + minimum margin are sufficient for now? Maybe even just minimum margin? So that would be:

  • minimum horizontal margin (this can double as "x offset")
  • minimum vertical margin (this can double as "y offset")

It could also be, if we want to support something other than just centering:

  • minimum top, bottom, left, right margins

And then if we wanted a minimum size:

  • minimum width
  • minimum height

The actual size, assuming

  • dimx >= minimum width + 2 * horizontal margins
  • dimy >= minimum height + 2 * vertical margins

(since otherwise it can't be displayed) will be:

  • dimx - 2 * horizontal margins (possibly larger than minimum with)
  • dimy - 2 * vertical margins (possibly larger than minimum height)

Yeah, so 4 margins + 2 minima seem sufficient.

If we're allowing a minimum size to be specified, we ought enforce it in notcurses_init() and notcurses_resize(). What does enforcement mean? Do we exit? Stop rendering, and render some
warning message? What if we're too small for that message?

@dankamongmen
Copy link
Owner Author

I think maybe we want maximum absolute and minimum margin...?

@dankamongmen
Copy link
Owner Author

I've added margin_{tbrl} to notcurses_options, and documented it on the notcurses_init(3) man page.

dankamongmen added a commit that referenced this issue Mar 9, 2020
@dankamongmen dankamongmen added the demo relevant to notcurses-demo label Mar 9, 2020
@dankamongmen
Copy link
Owner Author

I've added a -m option to notcurses-demo, which can take either a single common margin, or all four margins explicitly supplied.

@dankamongmen
Copy link
Owner Author

Just ran through a full demo with a right and bottom border. Everything looks great! Need to test with left and top, and also need to test with a resize.

@dankamongmen
Copy link
Owner Author

Either a top or a left border gives us problems on numerous demos. We're not done yet :).

@dankamongmen
Copy link
Owner Author

Getting closer (-m2)
2020-03-12-230247_722x1417_scrot

@dankamongmen
Copy link
Owner Author

H
2020-03-12-230506_1001x1417_scrot

@dankamongmen
Copy link
Owner Author

Is it just me, or is the centering off on the intro scene above (written with -m5)? I think there is. It looks like there are maybe 5 columns on the left, and 3 on the right. If so, that explains why the intro appears to be left atop later drawing (see chunli two above)...

@dankamongmen
Copy link
Owner Author

yep:

Term: 111x74 xterm-256color (xterm with 256 colors)
y: [5..69) x: [5..106)
y: [5..64) x: [5..101)
y: [5..64) x: [5..101)
y: [5..64) x: [5..101)
y: [5..64) x: [5..101)
y: [5..64) x: [5..101)
y: [5..64) x: [5..101)

@dankamongmen
Copy link
Owner Author

Fixed up the corruption we were seeing. Everything works now, except we're not drawing the last line when we have a top margin. This should be done soon.

dankamongmen added a commit that referenced this issue Mar 13, 2020
@dankamongmen
Copy link
Owner Author

We're also not drawing the righmost column when we have a left margin.

@dankamongmen
Copy link
Owner Author

Working perfectly, and it looks AWESOME
2020-03-13-044846_1163x1417_scrot

@dankamongmen
Copy link
Owner Author

2020-03-13-045024_1163x1417_scrot

BOSS

dankamongmen added a commit that referenced this issue Mar 13, 2020
dankamongmen added a commit that referenced this issue Mar 13, 2020
Add four new fields to notcurses_options: margin_{tblr}, which requests margins to the top, right, bottom, and left. Render only within those margins, leaving the screen otherwise untouched (well, cleared if using the alternate screen). #293
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
demo relevant to notcurses-demo documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant