diff --git a/doc/Concepts.md b/doc/Concepts.md index eac4d04..92eaf5a 100644 --- a/doc/Concepts.md +++ b/doc/Concepts.md @@ -81,6 +81,31 @@ ctx.setForegroundColor(White); ctx.write("Hello world!"); ``` +## Under the hood + +There are a number of interfaces and classes that needs to be explained to understand how the GUI works. + +`TermWriteable` is an interface that allows the usage of the normal CC terminal write methods. Stuff like `write`, `setCursorPos` and `setCursorBlink` are defined here. This is of course implemented by the physical screens and the main terminal. + +Most of the time you will not write directory to a real screen but to a `VirtualTermWriter` which extends `TermWriteable` with some more methods like `enable` +and `setTarget`. The `setTarget` is used as the proxy target of a `VirtualTermWriter` and with `enable` and `disable` you can enable and disable the forwarding of the write methods to the target. + +The `StatelessVirtualTermWriter` and `BufferedVirtualTermWriter` are both `VirtualTermWriter`. They can have a real output as a target. Or they can have another `VirtualTermWriter` as target like the `BufferedVirtualTermWriter` which uses a `TermBuffer` as an intermediate target. + +All of that is just for printing to the screen. If you want to read input you have to use the `WindowContext` which is a `TermWriteable`. +`WindowContext` also handles events like `onClick` or `onKey`. This is need so that the right program gets the input depending on the active window on the +screen or terminal. + +All of the `WindowContext` are managed by the `WindowManager`. The `WindowManager` also delegates the events to the right `WindowContext`. + +## GUI helper classes + +Because we want a more abstract way of writing to the screen we have some "helper" classes. I call them "helper" but they a very essential to the GUI. + +First there is the `Pixel` class which is nothing more that a char and a foreground and background color. + +A collection of `Pixel` is called a `Canvas` which is nothing more than a 2D array of `Pixel` with some functions strapped to it. + # Proceses The concept of processes tryes to encapsulate programs. A process is basically an interface with the `run(handle: ProcessHandle)` method.