Skip to content

Can I make long forms or nested layouts that are scrollable? #1065

@andy0130tw

Description

@andy0130tw

When building applications that prompt rich forms, we may need the capability that we could scroll some long contents, optionally with viewport following the cursor. An example that implements this concept is nmtui.

long form in nmtui

If a widget is simple, one approach is to (ab)use FormattedTextControl inside a window, typesetting (?) the content of each block and arrange cursor positions. This idea works well with smaller components, and is already seen in widgets like CheckboxList, #711 for editable buffers, and the option list of pyvim (this is especially brilliant, in my oponion).

When building some complex blocks to compose them, the logic to maintain contents/positions for a long block would be a nightmare. For an instance of what I mean complex, see cslack, in urwid.

complex form

It is straightforward to mock a view using HSplit and VSplit, however they seem to divide the screen and cannot be placed inside a window. I have seen a similar feature request in #949 and surveyed some showcases, but still have no idea on how to achieve this. Maybe I should start by inheriting UIContent. Is there some development docs that I can refer to create such a component?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions