godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.11k stars 69 forks source link

Add built-in terminal to editor's bottom panel #1379

Open neqs20 opened 4 years ago

neqs20 commented 4 years ago

Describe the project you are working on:

Godot Editor

Describe the problem or limitation you are having in your project:

When working on your project you usually use a terminal for all kinds of tasks (e.g. git, searching for files or in my case - compaling GDNative plugin). This requires you to switch between multiple windows and that takes a bit of the time.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:

There could be a terminal interface integrated into editor that could save a lot of time. It would be similar to the Visual Studio Code one but simpler. Here's a screenshot of it: screenshot

Godot's terminal would include:

We also need to make sure that it's cross-platform. This feature targets OSX, Linux and Windows platforms.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

I faced some limitations while imlementing this feature with EditorPlugin:

Egzample 1 What do I mean by "spawns new process"? Take a look at this code:

func _ready():
    var output = []
    OS.execute("cd", ["c:/Users/user_name/Desktop/"])
    # use blocking mode to receive output
    OS.execute("some_program.bat", [], true, output, true)
    print(output)
    """
        prints: ['some_program.bat' is not recognized as an internal or external command, operable program or batch file.]
    """

Even though I changed directory to Desktop where my batch script resides I can't run it. That's because OS.execute doesn't behave like one terminal. Every time we try to run commands one after another we wait for the first one to finish and then read the output. After it's done the process is terminated and then the next OS.execute call is run.

To fix this we can chain commands together in one OS.execute call with a composite command:

func _ready():
    var output = []
    OS.execute("cmd.exe", ["/c", "c:/users/micha/desktop/ && some_program.bat"], true, output, true)
    print(output)
    """
        prints: ['WELL DONE!']
    """

It's not that straightforward as it seems but pretty doable.

Egzample 2

To execute commands terminal needs some sort of input box or input element. It also needs to output information. Terminals that we use combain those two elements into one: Example

Output is a part of terminal's text which should never be overwrttien by the user. Input on the other hand is a part that user needs to control.

When a user issues the command it becomes part of the output.

I had troubles with that approch so I came up with a simpler design:

screenshot

As you can see the terminal consists of 3 parts:

Note that it's really simple prototype created with EditorPlugin just to showcase this feature.

If this enhancement will not be used often, can it be worked around with a few lines of script?:

I belive many people will use this feature. Definitely can't be worked around with few lines of code.

Is there a reason why this should be core and not an add-on in the asset library?:

There are 3 ways to add this:

I think the feature would benefit a lot if it was made as a part of the editor code.

Additional information:

All of this was tested in Godot 3.2.3 and Windows 10 version 2004

jonbonazza commented 4 years ago

Terminal UI aside, it would be nice to have proper Command/Process API that supported things like piping and what not.

Calinou commented 4 years ago

@jonbonazza That's definitely for a separate proposal :slightly_smiling_face:

ShalokShalom commented 4 years ago

Wow, I just thought about this and found your Reddit post on the research. Thanks a lot for proposing this, and of course the development. I absolutely support this and hope, it becomes some standard in the editor. A bit a naive question:

Is it not possible to simply embedded the library of a fully functional multi-platform terminal, like libtmt?

umarcor commented 4 years ago

FTR, Godot Live Q&A with engine developers – July 2020: Is the Godot script editor going to have a Vim mode anytime? and https://youtu.be/k5DKlhMy5wQ?t=3950. See also #1409.

ShalokShalom commented 1 year ago

I found another library, that seems very useful for this project. It is maintained by Jupyter, the guys from which the popular "Jupyter Notebooks" come from. So very well maintained and programmed. It seems documentation is also laid out to be helpful for people in our situation.

https://github.com/jupyter-xeus/cpp-terminal

ShalokShalom commented 1 year ago

I would also like to add another thing: This could be way more, than just a helpful terminal at the bottom.

Putting it as a replacement for the scripting editor, could it help to facilitate the usage of programming languages, who are supported by the engine, but not by the build in editor.

Simply loading Neovim, Emacs or another terminal based editor, and eventually even integrating them via an own "settings" section, and so on, could greatly improve the user experience within Godot.