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

1.1.4 #19

Merged
merged 4 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ratframe"
version = "1.1.1"
version = "1.1.4"
authors = ["gold-silver-copper"]
edition = "2021"
include = ["LICENSE-APACHE", "LICENSE-MIT", "**/*.rs", "Cargo.toml"]
Expand Down Expand Up @@ -41,7 +41,7 @@ eframe = { version = "0.27.2", default-features = false, features = [
"persistence", # Enable restoring app state when restarting the app.
] , optional= true}

web-time = {version = "1" , optional = true}
web-time = {version = "1" }


# native:
Expand All @@ -54,7 +54,7 @@ wasm-bindgen-futures = "0.4"
log = "0.4"

[features]
default = ["eframe", "web-time"]
default = ["eframe"]

[profile.release]
opt-level = 2 # fast and small wasm
Expand Down
2 changes: 1 addition & 1 deletion bevy_example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
[dependencies]
bevy = "0.13.2"
bevy_egui = "0.27.0"
ratatui = { version = "0.26.2", default-features = false }

Check warning on line 11 in bevy_example/Cargo.toml

View workflow job for this annotation

GitHub Actions / Spell Check

"ratatui" should be "ratatouille".
ratframe = {version = "1.0.13", default-features = false}
ratframe = {version = "1.1.3", default-features = false}
#disable defaults features for rat frame if you do not want to import eframe
2 changes: 1 addition & 1 deletion macroquad_example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ macroquad = "0.4.5"
egui-macroquad = { git = 'https://github.com/gold-silver-copper/egui-macroquad.git', branch="master" }

ratatui = { version = "0.26.2", default-features = false }
ratframe = {version = "1.0.13", default-features = false}
ratframe = {version = "1.1.3", default-features = false}
#disable defaults features for rat frame if you do not want to import eframe
10 changes: 7 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
mod ratagui_backend;

pub use ratagui_backend::RataguiBackend;

#[cfg(feature = "eframe")]
mod wasm_runner;
#[cfg(not(target_arch = "wasm32"))]
#[cfg(all(not(target_arch = "wasm32"),feature="eframe"))]
pub use wasm_runner::native_setup;

#[cfg(feature = "eframe")]
pub use wasm_runner::NewCC;

#[cfg(target_arch = "wasm32")]
#[cfg(all(target_arch = "wasm32", feature = "eframe"))]
pub use wasm_runner::wasm_setup;


9 changes: 5 additions & 4 deletions src/ratagui_backend.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
//! This module provides the `RataguiBackend` implementation for the [`Backend`] trait.
//! It is used in the integration tests to verify the correctness of the library.

use eframe::egui::text::TextWrapping;
use eframe::egui::{Label, Response, Stroke, Ui};
use eframe::epaint::{
use egui::text::TextWrapping;
use egui::{Label, Response, Stroke, Ui};
use egui::epaint::{
text::{LayoutJob, TextFormat},
Color32, FontFamily, FontId, Fonts,
};


use ratatui::style::{Color, Modifier};

Check warning on line 12 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Spell Check

"ratatui" should be "ratatouille".
use std::f32::INFINITY;
use std::io;
use web_time::Instant;

use ratatui::{

Check warning on line 17 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Spell Check

"ratatui" should be "ratatouille".
backend::{Backend, ClearType, WindowSize},
buffer::{Buffer, Cell},
layout::{Rect, Size},
};

///The RataguiBackend is the widget+backend itself , from which you can make a ratatui terminal ,

Check warning on line 23 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Spell Check

"ratatui" should be "ratatouille".
/// then you can do ui.add(terminal.backend_mut()) inside an egui context .
/// Spawn with RataguiBackend::new() or RataguiBackend::new_with_fonts() .
/// See the hello_world_web example for custom font usage
Expand All @@ -40,7 +41,7 @@
blinking_slow: bool,
blinking_fast: bool,
}
impl eframe::egui::Widget for &mut RataguiBackend {
impl egui::Widget for &mut RataguiBackend {
fn ui(self, ui: &mut Ui) -> Response {
ui.spacing_mut().item_spacing.x = 0.0;
ui.spacing_mut().item_spacing.y = 0.0;
Expand Down Expand Up @@ -120,14 +121,14 @@
let mut tf_fg_color = RataguiBackend::rat_to_egui_color(&cur_cell.fg, true);
let mut tf_bg_color = RataguiBackend::rat_to_egui_color(&cur_cell.bg, false);

if is_slowblink {

Check failure on line 124 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

this `if` statement can be collapsed

Check failure on line 124 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

this `if` statement can be collapsed
if self.blinking_slow {
tf_fg_color = tf_bg_color.clone();

Check failure on line 126 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

using `clone` on type `Color32` which implements the `Copy` trait

Check failure on line 126 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

using `clone` on type `Color32` which implements the `Copy` trait
}
}
if is_rapidblink {

Check failure on line 129 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

this `if` statement can be collapsed

Check failure on line 129 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

this `if` statement can be collapsed
if self.blinking_fast {
tf_fg_color = tf_bg_color.clone();

Check failure on line 131 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

using `clone` on type `Color32` which implements the `Copy` trait

Check failure on line 131 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

using `clone` on type `Color32` which implements the `Copy` trait
}
}

Expand All @@ -137,12 +138,12 @@
}

if is_reversed {
let holder = tf_bg_color;

Check failure on line 141 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

this looks like you are swapping `tf_bg_color` and `tf_fg_color` manually

Check failure on line 141 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

this looks like you are swapping `tf_bg_color` and `tf_fg_color` manually
tf_bg_color = tf_fg_color;
tf_fg_color = holder;
}
if is_hidden {
tf_fg_color = tf_bg_color.clone();

Check failure on line 146 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

using `clone` on type `Color32` which implements the `Copy` trait

Check failure on line 146 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

using `clone` on type `Color32` which implements the `Copy` trait
}

let tf_stroke = if is_crossed_out {
Expand Down Expand Up @@ -230,7 +231,7 @@
}

pub fn get_font_size(&self) -> u16 {
self.font_size.clone()

Check failure on line 234 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

using `clone` on type `u16` which implements the `Copy` trait

Check failure on line 234 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Clippy

using `clone` on type `u16` which implements the `Copy` trait
}
pub fn set_font_size(&mut self, desired: u16) {
self.font_size = desired;
Expand All @@ -257,7 +258,7 @@
fontiki.glyph_width(&fid, 'A')
}

pub fn rat_to_egui_color(rat_col: &ratatui::style::Color, is_a_fg: bool) -> Color32 {

Check warning on line 261 in src/ratagui_backend.rs

View workflow job for this annotation

GitHub Actions / Spell Check

"ratatui" should be "ratatouille".
match rat_col {
Color::Reset => {
if is_a_fg {
Expand Down
Loading