diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..df35f1b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/mers/target +/mers_libs/*/target diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/gui.txt b/gui.txt old mode 100644 new mode 100755 index 61f4ac7..9efdf91 --- a/gui.txt +++ b/gui.txt @@ -1,4 +1,4 @@ -lib gui.sh +lib mers_libs/gui base = gui_init() column = base.gui_add(Column: []) diff --git a/mers/Cargo.lock b/mers/Cargo.lock new file mode 100644 index 0000000..74a3980 --- /dev/null +++ b/mers/Cargo.lock @@ -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" diff --git a/Cargo.toml b/mers/Cargo.toml old mode 100644 new mode 100755 similarity index 100% rename from Cargo.toml rename to mers/Cargo.toml diff --git a/src/libs/inlib.rs b/mers/src/libs/inlib.rs old mode 100644 new mode 100755 similarity index 100% rename from src/libs/inlib.rs rename to mers/src/libs/inlib.rs diff --git a/src/libs/mod.rs b/mers/src/libs/mod.rs old mode 100644 new mode 100755 similarity index 100% rename from src/libs/mod.rs rename to mers/src/libs/mod.rs diff --git a/src/libs/path.rs b/mers/src/libs/path.rs old mode 100644 new mode 100755 similarity index 60% rename from src/libs/path.rs rename to mers/src/libs/path.rs index 655305d..9aed570 --- a/src/libs/path.rs +++ b/mers/src/libs/path.rs @@ -5,9 +5,16 @@ pub fn path_from_string(path: &str, script_directory: &PathBuf) -> Option 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) + } + } + } +} diff --git a/script.txt b/script.txt new file mode 100755 index 0000000..9efdf91 --- /dev/null +++ b/script.txt @@ -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)") + } + } + } + } + [] +}