mirror of
https://github.com/Dummi26/mers.git
synced 2025-03-10 05:43:53 +01:00
moved Cargo.toml and src/ to /mers/Cargo.toml and /mers/src/ because rust-analyzer was apparently very confused when I was trying to edit projects in mers_libs/*/.
This commit is contained in:
parent
5b051e72f1
commit
2acdcd3f53
2
.gitignore
vendored
Executable file
2
.gitignore
vendored
Executable file
@ -0,0 +1,2 @@
|
||||
/mers/target
|
||||
/mers_libs/*/target
|
2
gui.txt
Normal file → Executable file
2
gui.txt
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
lib gui.sh
|
||||
lib mers_libs/gui
|
||||
|
||||
base = gui_init()
|
||||
column = base.gui_add(Column: [])
|
||||
|
42
mers/Cargo.lock
generated
Normal file
42
mers/Cargo.lock
generated
Normal file
@ -0,0 +1,42 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "mers"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
|
0
Cargo.toml → mers/Cargo.toml
Normal file → Executable file
0
Cargo.toml → mers/Cargo.toml
Normal file → Executable file
0
src/libs/inlib.rs → mers/src/libs/inlib.rs
Normal file → Executable file
0
src/libs/inlib.rs → mers/src/libs/inlib.rs
Normal file → Executable file
0
src/libs/mod.rs → mers/src/libs/mod.rs
Normal file → Executable file
0
src/libs/mod.rs → mers/src/libs/mod.rs
Normal file → Executable file
13
src/libs/path.rs → mers/src/libs/path.rs
Normal file → Executable file
13
src/libs/path.rs → mers/src/libs/path.rs
Normal file → Executable file
@ -5,9 +5,16 @@ pub fn path_from_string(path: &str, script_directory: &PathBuf) -> Option<PathBu
|
||||
if path.is_absolute() {
|
||||
return Some(path);
|
||||
}
|
||||
let p = script_directory.join(&path);
|
||||
if p.exists() {
|
||||
return Some(p);
|
||||
if let Some(p) = script_directory
|
||||
.canonicalize()
|
||||
.unwrap_or_else(|_| script_directory.clone())
|
||||
.parent()
|
||||
{
|
||||
eprintln!("Parent: {:?}", p);
|
||||
let p = p.join(&path);
|
||||
if p.exists() {
|
||||
return Some(p);
|
||||
}
|
||||
}
|
||||
if let Ok(mers_lib_dir) = std::env::var("MERS_LIB_DIR") {
|
||||
let p = PathBuf::from(mers_lib_dir).join(&path);
|
0
src/main.rs → mers/src/main.rs
Normal file → Executable file
0
src/main.rs → mers/src/main.rs
Normal file → Executable file
0
src/parse/file.rs → mers/src/parse/file.rs
Normal file → Executable file
0
src/parse/file.rs → mers/src/parse/file.rs
Normal file → Executable file
0
src/parse/mod.rs → mers/src/parse/mod.rs
Normal file → Executable file
0
src/parse/mod.rs → mers/src/parse/mod.rs
Normal file → Executable file
0
src/parse/parse.rs → mers/src/parse/parse.rs
Normal file → Executable file
0
src/parse/parse.rs → mers/src/parse/parse.rs
Normal file → Executable file
0
src/script/block.rs → mers/src/script/block.rs
Normal file → Executable file
0
src/script/block.rs → mers/src/script/block.rs
Normal file → Executable file
0
src/script/builtins.rs → mers/src/script/builtins.rs
Normal file → Executable file
0
src/script/builtins.rs → mers/src/script/builtins.rs
Normal file → Executable file
0
src/script/mod.rs → mers/src/script/mod.rs
Normal file → Executable file
0
src/script/mod.rs → mers/src/script/mod.rs
Normal file → Executable file
0
src/script/val_data.rs → mers/src/script/val_data.rs
Normal file → Executable file
0
src/script/val_data.rs → mers/src/script/val_data.rs
Normal file → Executable file
0
src/script/val_type.rs → mers/src/script/val_type.rs
Normal file → Executable file
0
src/script/val_type.rs → mers/src/script/val_type.rs
Normal file → Executable file
0
src/script/value.rs → mers/src/script/value.rs
Normal file → Executable file
0
src/script/value.rs → mers/src/script/value.rs
Normal file → Executable file
0
mers_libs/gui_v1/Cargo.lock
generated
Normal file → Executable file
0
mers_libs/gui_v1/Cargo.lock
generated
Normal file → Executable file
2
mers_libs/gui_v1/Cargo.toml
Normal file → Executable file
2
mers_libs/gui_v1/Cargo.toml
Normal file → Executable file
@ -7,4 +7,4 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
iced = { version = "0.8.0", features = ["smol"] }
|
||||
mers = { path = "../../" }
|
||||
mers = { path = "../../mers/" }
|
||||
|
0
mers_libs/gui_v1/src/main.rs
Normal file → Executable file
0
mers_libs/gui_v1/src/main.rs
Normal file → Executable file
49
mers_libs/http_requests/Cargo.lock
generated
Normal file
49
mers_libs/http_requests/Cargo.lock
generated
Normal file
@ -0,0 +1,49 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http_requests"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"mers",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "mers"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
|
9
mers_libs/http_requests/Cargo.toml
Executable file
9
mers_libs/http_requests/Cargo.toml
Executable file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "http_requests"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
mers = { path = "../../mers/" }
|
29
mers_libs/http_requests/src/main.rs
Executable file
29
mers_libs/http_requests/src/main.rs
Executable file
@ -0,0 +1,29 @@
|
||||
fn main() {
|
||||
let (mut my_lib, mut run) = MyLib::new(
|
||||
"GUI-Iced".to_string(),
|
||||
(0, 0),
|
||||
"A basic GUI library for mers.".to_string(),
|
||||
vec![(
|
||||
"http_get".to_string(),
|
||||
vec![VSingleType::String],
|
||||
VType {
|
||||
types: vec![VSingleType::Tuple(vec![]), VSingleType::String],
|
||||
},
|
||||
)],
|
||||
);
|
||||
let mut stdin = std::io::stdin().lock();
|
||||
let mut stdout = std::io::stdout().lock();
|
||||
let mut layout = Layout::Row(vec![]);
|
||||
loop {
|
||||
run = match my_lib.run(run, &mut stdin, &mut stdout) {
|
||||
MyLibTask::None(v) => v,
|
||||
MyLibTask::RunFunction(mut f) => {
|
||||
let return_value = match f.function {
|
||||
0 => VDataEnum::List(VSingleType::Int.to(), vec![]).to(),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
f.done(&mut stdout, return_value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
51
script.txt
Executable file
51
script.txt
Executable file
@ -0,0 +1,51 @@
|
||||
lib mers_libs/gui
|
||||
|
||||
base = gui_init()
|
||||
column = base.gui_add(Column: [])
|
||||
|
||||
text = column.gui_add(Text: "Welcome to MERS GUI!")
|
||||
|
||||
button = column.gui_add(Button: "This is a button.")
|
||||
second_button = column.gui_add(Button: "This is a second button.")
|
||||
|
||||
text_state = -2
|
||||
second_text = column.gui_add(Text: "press the button above to remove this text!")
|
||||
|
||||
while {
|
||||
for event gui_updates() {
|
||||
switch! event {
|
||||
ButtonPressed([int]) {
|
||||
e = event.noenum()
|
||||
match e {
|
||||
&e.eq(&button) println("First button pressed")
|
||||
&e.eq(&second_button) {
|
||||
// don't match on text_state because we need to change the original from inside the match statement
|
||||
state = text_state
|
||||
match state {
|
||||
// the first, third, fifth, ... time the button is pressed: remove the text
|
||||
text_state.mod(2).eq(0) {
|
||||
if text_state.eq(-2) {
|
||||
// the first time the button is pressed
|
||||
text_state = 0
|
||||
set_title("keep pressing the button!")
|
||||
}
|
||||
second_text.gui_remove()
|
||||
}
|
||||
// the 2nd, 4th, 6th, ... time the button is pressed: add the text back
|
||||
text_state.eq(1) second_text = column.gui_add(Text: "i'm back!")
|
||||
text_state.eq(3) second_text = column.gui_add(Text: "you can't fully get rid of me!")
|
||||
true {
|
||||
second_text = column.gui_add(Text: "i always come back")
|
||||
// restart (set text_state to 0)
|
||||
text_state = -1
|
||||
}
|
||||
}
|
||||
text_state = text_state.add(1)
|
||||
}
|
||||
true println("A different button was pressed (unreachable)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[]
|
||||
}
|
Loading…
Reference in New Issue
Block a user