bevy_term 0.18.0

Easy terminal event handling and rendering with Bevy!
Documentation
<!-- SPDX-FileCopyrightText: 2024 sntx <sntx@sntx.space> -->
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->

# Bevy Term

Easy terminal event handling and rendering with Bevy!

---

![bevy_term_counter screenshot](./.rsc/bevy_term_counter.png)

## Description

This crate primarily provides the `TerminalPlugin` for Bevy.
It allows for easily rendering to the terminal and handling terminal events.

## Features

- Work In Progress
- ...

## Usage

Check out the [examples](./examples) directory!

<details>
  <summary>Add the TerminalPlugin</summary>

```rust
fn main() -> AppExit {
    App::new()
        .add_plugins(TerminalPlugin)
        // ...
        .run()
}
```

</details>

<details>
  <summary>Register a system for rendering to the terminal</summary>

```rust
fn main() -> AppExit {
    App::new()
        .add_systems(PostUpdate, render)
        // ...
        .run()
}

fn render(mut terminal: ResMut<Terminal>) {
    terminal
        .0
        .draw(|frame| {
            let chunks = Layout::default()
                .direction(Direction::Vertical)
                .constraints([Constraint::Percentage(49), Constraint::Min(1)].as_ref())
                .split(frame.area());

            frame.render_widget(
                Paragraph::new("Hellow World!\nPress `ESC` or `C-d` to exit.")
                    .alignment(Alignment::Center),
                chunks[1],
            );
        })
        .unwrap();
}
```

</details>

<details>
  <summary>(Optional) Register a system for handling terminal events</summary>

```rust
fn main() -> AppExit {
    App::new()
        .add_systems(PreUpdate, handler)
        // ...
        .run()
}

fn handler(
    mut terminal_events: EventReader<bevy_term::Event>,
    mut tui_state: ResMut<bevy_term::State>,
) {
    for terminal_event in terminal_events.read() {
        if let Event::Key(key_event) = terminal_event.0 {
            if key_event.code == KeyCode::Esc {
                *tui_state = bevy_term::State::Exit
            }
        }
    }
}
```

</details>