|
| 1 | +/*! |
| 2 | +Components are the visible building blocks in gitui. |
| 3 | +
|
| 4 | +They have a state, handle events, and render to the terminal: |
| 5 | +
|
| 6 | +* Some are full screen. That would be all the [`tabs`](super::tabs). |
| 7 | +* Some look like panels, eg [`CommitDetailsComponent`] |
| 8 | +* Some overlap others. They are collected in module [`popups`](super::popups) |
| 9 | +* Some are decorations, eg [`HorizontalScroll`](utils::scroll_horizontal::HorizontalScroll). |
| 10 | +
|
| 11 | +Components can be reused. |
| 12 | +For example, [`CommitList`] is used in both tab "revlog" and tab "stashlist". |
| 13 | +
|
| 14 | +
|
| 15 | +## Composition |
| 16 | +
|
| 17 | +In gitui, composition is driven by code. This means each component must |
| 18 | +have code that explicitly forwards component function calls like draw, |
| 19 | +commands and event to the components it is composed of. |
| 20 | +
|
| 21 | +Other systems use composition by data: They provide a generic data structure |
| 22 | +that reflects the visual hierarchy, and uses it at runtime to |
| 23 | +determine which code should be executed. This is not how gitui works. |
| 24 | +
|
| 25 | +## Traits |
| 26 | +
|
| 27 | +There are two traits defined here: |
| 28 | +* [`Component`] handles events from the user, |
| 29 | +* [`DrawableComponent`] renders to the terminal. |
| 30 | +
|
| 31 | +In the current codebase these are always implemented together, and it probably |
| 32 | +makes more sense to merge them some time in the future. |
| 33 | +It is a little strange that you implement `draw()` on a `DrawableComponent`, |
| 34 | +but have function `hide()` from trait Component which does not know how |
| 35 | +to `draw()`. |
| 36 | +*/ |
| 37 | + |
1 | 38 | mod changes;
|
2 | 39 | mod command;
|
3 | 40 | mod commit_details;
|
|
0 commit comments