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

implement ncplane_resize() and ncplane_move() #64

Closed
dankamongmen opened this issue Nov 28, 2019 · 2 comments
Closed

implement ncplane_resize() and ncplane_move() #64

dankamongmen opened this issue Nov 28, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@dankamongmen
Copy link
Owner

Now that we can create and destroy ncplanes, let's add the functionality necessary to move and resize them. For moving, it's fine to just accept a new origin point (perhaps relative to either the screen or some other ncplane). For resize, rather than ncurses's wresize(), which takes new dimensions but applies them from the origin, i want to accept a new subsection of the ncplane, which will be left where it is (even if the resize is a growth, and it's now partially offscreen). move moves, resize resizes, and the resize is general.

actually, a fully general resize would require:

  • section of current ncplane to keep,
  • where it ought be RELATIVE TO new ncplane, and
  • new dimensions of ncplane

where the new section must be wholly within the new ncplane, but the ncplane can be beyond the screen. note that move is still distinct: in this sceme, the resize is "anchored" by the subsection that we keep.

if you want to resize or move, but don't care about keeping any of it, i guess it can apply to the origin. so to resize down and to the right by 2, currently at yoff/xoff with dimensions ylen/xlen, it would be

ncplane_resize(zero-area section, {0,0}, {ylen + 2, xlen + 2})

and to resize by 2 but put the current origin at the lower right, it would be:

ncplane_resize(zero-area section, {ylen + 2 - 1, xlen + 2 - 1}, {ylen + 2, xlen + 2})

and to resize by 2 to the up and left, it would be:

ncplane_resize(zero-area section, {2, 2}, {ylen + 2, xlen + 2}

in the first example, you get two new empty rows and two new empty columns, retaining all current data. in the second, you lose all data, and have a window with its lower-right corner where the upper-left corner was. in the third, you have two new empty rows and two new empty columns, retaining all current data, but they're above and to the left of you. yeah, i like that.

you still can't implement move() via resize(), which i like. resize() is fundamentally a data-rearranging operation within the ncplane, whereas move() is rearranging data at the notcurses level.

@dankamongmen dankamongmen self-assigned this Nov 28, 2019
@dankamongmen dankamongmen added this to the v0.1.0 milestone Nov 28, 2019
@dankamongmen dankamongmen added the enhancement New feature or request label Nov 28, 2019
@dankamongmen dankamongmen changed the title implement ncplane_resize() and ncplane_remove() implement ncplane_resize() and ncplane_move() Nov 28, 2019
@dankamongmen
Copy link
Owner Author

ncplane_move() appears to work perfectly, w00t!

dankamongmen added a commit that referenced this issue Nov 28, 2019
dankamongmen added a commit that referenced this issue Nov 29, 2019
dankamongmen added a commit that referenced this issue Nov 29, 2019
dankamongmen added a commit that referenced this issue Nov 29, 2019
dankamongmen added a commit that referenced this issue Nov 29, 2019
@dankamongmen
Copy link
Owner Author

Done! We have unit tests, but I want these integrated into demo code, as well.

dankamongmen added a commit that referenced this issue Nov 29, 2019
* sliding: bounding box around puzzle
* slider: make moves, deleting planes #61
* implement z-index move functions
* demo: allow demos to be chosen via command-line option
* allow default bg/fg to be explicitly chosen
* ncplane_resize() unit test #64
* useful links
* slider: use random colors
* use find_above() in ncplace_destroy()
* ncplane_resize() work #64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant