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

Extend PromptSession to a full screen application #672

Open
techtonik opened this issue Jul 11, 2018 · 7 comments
Open

Extend PromptSession to a full screen application #672

techtonik opened this issue Jul 11, 2018 · 7 comments

Comments

@techtonik
Copy link
Contributor

Instead of trying to embed prompt into full screen app (#652 #640), is it possible to just extend PromptSession, because it is already the app that runs the event loop?

@jonathanslenders
Copy link
Member

Hi @techtonik, I'm really not sure about this, honestly. I've no idea what the APIs would look like in this case.
If somebody can make a proof-of-concept, I will definitely like to have a look at that.

I understand that combining the ideas of what PromptSession offers, with a full-screen application and pop-up dialogs, is not straightforward, right now, but I'd like to grow this slowly, and see how we can move towards the most flexible architecture.

@techtonik
Copy link
Contributor Author

Here is how to get application object from PromptSession.

session = PromptSession(os.getcwd() + ">", key_bindings=global_kb, bottom_toolbar=bottom_toolbar, style=style)
app = session.app

Now it needs some experiments - how to add/call Dialogs to/from it.

@decentral1se
Copy link
Contributor

Could you explain further your thinking about why this would be good @techtonik?

My thoughts so far:

Is it possible to de-couple the application from the PromptSession and keep the feature set?

From my limited understanding, right now, we need to build a Window/Buffer/BufferControl setup to start to approach the feature set of the PromptSession in full screen applications. Since a big part of the full screen application (so far) is configuring the application and setting up (sometimes complicated) Layouts - I think I would rather see a PromptSession that has all the niceties that I can just simply pass to the Application in the Layout. I still setup my own event loop.

@techtonik
Copy link
Contributor Author

The only reason I have is that learning curve to go from prompt tutorial to a full screen application is too steep. Mentioning how to embed PromptSession (or underlying object) into another layout would help. Without this, there is a lot of manipulation with invisible layouts in my head that I can not compile yet.

@ghost
Copy link

ghost commented Sep 12, 2018

Couldn't the layout engine operate at a lower level? For example it would directly handle multiplexing stdin/stdout, which would eliminate the need for a major refactor.

@codingedward
Copy link

Thank you for this great library!

I am also trying to create a full-screen application that embeds a PromptSession like so:

+--------------------+------------+
|                    |            |
|    PromptSession   |  Custom    |
|       Window       |  Window    |
|                    |            |
+--------------------+------------+

I was able to get the following example working but I am now facing an issue with the fact that I can't use a VSplit in place of HSplit since the custom_window occupies the whole application's window width.

class MyPromptSession(PromptSession):
    def _create_layout(self):
        custom_buffer = Buffer()
        custom_window = Window(BufferControl(buffer=custom_buffer))
        layout = super()._create_layout()
        main_window = layout.container
        return Layout(
            HSplit(children=[main_window, custom_window], # <-- I can't use VSplit here :(
                padding_char='*',
                padding=1,
            ), 
            main_window
        )

Any help will be greatly appreciated!

@lfvjimisola
Copy link

@codingedward Is the rest of your code available somewhere for me to have a look at?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants