change name and work on gui
This commit is contained in:
18
Cargo.lock
generated
18
Cargo.lock
generated
@@ -2,6 +2,15 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "Omlet"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"eframe",
|
||||||
|
"egui 0.21.0",
|
||||||
|
"egui_extras",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ab_glyph"
|
name = "ab_glyph"
|
||||||
version = "0.2.29"
|
version = "0.2.29"
|
||||||
@@ -2185,15 +2194,6 @@ dependencies = [
|
|||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation 0.2.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "oeufman"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"eframe",
|
|
||||||
"egui 0.21.0",
|
|
||||||
"egui_extras",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.21.3"
|
version = "1.21.3"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "oeufman"
|
name = "Omlet"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
|||||||
1
library/OMELETTE
Normal file
1
library/OMELETTE
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Omelette
|
||||||
22
src/gui.rs
22
src/gui.rs
@@ -1,14 +1,12 @@
|
|||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
pub struct Omelt {
|
pub struct Omelt {
|
||||||
name: String,
|
text: String,
|
||||||
age: u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Omelt {
|
impl Default for Omelt {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
name: "Arthur".to_owned(),
|
text: "Test of text.".to_owned(),
|
||||||
age: 42,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,17 +14,11 @@ impl Default for Omelt {
|
|||||||
impl eframe::App for Omelt {
|
impl eframe::App for Omelt {
|
||||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
ui.heading("My egui Application");
|
ui.heading("Omelt");
|
||||||
ui.horizontal(|ui| {
|
ui.add_sized(
|
||||||
let name_label = ui.label("Your name: ");
|
ui.available_size(),
|
||||||
ui.text_edit_singleline(&mut self.name)
|
egui::TextEdit::multiline(&mut self.text).code_editor(),
|
||||||
.labelled_by(name_label.id);
|
);
|
||||||
});
|
|
||||||
ui.add(egui::Slider::new(&mut self.age, 0..=120).text("age"));
|
|
||||||
if ui.button("Increment").clicked() {
|
|
||||||
self.age += 1;
|
|
||||||
}
|
|
||||||
ui.label(format!("Hello '{}', age {}", self.name, self.age));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/main.rs
11
src/main.rs
@@ -51,6 +51,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
after_compression.write_all(string.as_bytes())?;
|
after_compression.write_all(string.as_bytes())?;
|
||||||
to_compress.seek(SeekFrom::Start(0))?;
|
to_compress.seek(SeekFrom::Start(0))?;
|
||||||
let map = tree_to_map(&mut tree, true);
|
let map = tree_to_map(&mut tree, true);
|
||||||
|
eprintln!("map = {:?}", map);
|
||||||
let trad = body_to_bin(&mut to_compress, map);
|
let trad = body_to_bin(&mut to_compress, map);
|
||||||
let trad_bin = string_to_binary(&trad);
|
let trad_bin = string_to_binary(&trad);
|
||||||
let len_body = trad.len() as u32;
|
let len_body = trad.len() as u32;
|
||||||
@@ -69,7 +70,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
let mut to_print = File::open(f)?;
|
let mut to_print = File::open(f)?;
|
||||||
if is_valid_file(&mut to_print) {
|
if is_valid_file(&mut to_print) {
|
||||||
let untranslate = string_translate(&mut to_print);
|
let untranslate = string_translate(&mut to_print);
|
||||||
eprintln!("untranslate = {}", untranslate);
|
println!("{}", untranslate);
|
||||||
} else {
|
} else {
|
||||||
println!("Error oppening file, check type file !")
|
println!("Error oppening file, check type file !")
|
||||||
}
|
}
|
||||||
@@ -110,16 +111,14 @@ fn main() -> std::io::Result<()> {
|
|||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let options = eframe::NativeOptions {
|
let options = eframe::NativeOptions {
|
||||||
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
|
viewport: egui::ViewportBuilder::default().with_inner_size([640.0, 480.0]),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let _ = eframe::run_native(
|
let _ = eframe::run_native(
|
||||||
"My egui App",
|
"Omelt",
|
||||||
options,
|
options,
|
||||||
Box::new(|cc| {
|
Box::new(|_| {
|
||||||
// This gives us image support:
|
// This gives us image support:
|
||||||
egui_extras::install_image_loaders(&cc.egui_ctx);
|
|
||||||
|
|
||||||
Ok(Box::<Omelt>::default())
|
Ok(Box::<Omelt>::default())
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
14
src/node.rs
14
src/node.rs
@@ -1,5 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
pub struct Node {
|
pub struct Node {
|
||||||
pub val: Option<char>,
|
pub val: Option<char>,
|
||||||
@@ -8,6 +9,15 @@ pub struct Node {
|
|||||||
pub n: i32,
|
pub n: i32,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
}
|
}
|
||||||
|
impl fmt::Debug for Node {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_struct("Node")
|
||||||
|
.field("Val", &self.val)
|
||||||
|
.field("n", &self.n)
|
||||||
|
.field("path", &self.path)
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
impl PartialEq for Node {
|
impl PartialEq for Node {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.n == other.n
|
self.n == other.n
|
||||||
@@ -91,7 +101,9 @@ pub fn create_tree(mut nodes: Vec<Node>) -> Node {
|
|||||||
new_root.insert(l, r);
|
new_root.insert(l, r);
|
||||||
//nodes.push(new_root);
|
//nodes.push(new_root);
|
||||||
match nodes.binary_search(&new_root) {
|
match nodes.binary_search(&new_root) {
|
||||||
Ok(_) => {}
|
Ok(pos) => {
|
||||||
|
nodes.insert(pos, new_root);
|
||||||
|
}
|
||||||
Err(pos) => {
|
Err(pos) => {
|
||||||
nodes.insert(pos, new_root);
|
nodes.insert(pos, new_root);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user