From 2acdcd3f53bb1b9da11f169399082617e5e30ac5 Mon Sep 17 00:00:00 2001 From: Dummi26 Date: Wed, 12 Apr 2023 22:23:07 +0200 Subject: [PATCH] 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/*/. --- .gitignore | 2 ++ README.md | 0 gui.txt | 2 +- mers/Cargo.lock | 42 +++++++++++++++++++++++ Cargo.toml => mers/Cargo.toml | 0 {src => mers/src}/libs/inlib.rs | 0 {src => mers/src}/libs/mod.rs | 0 {src => mers/src}/libs/path.rs | 13 +++++-- {src => mers/src}/main.rs | 0 {src => mers/src}/parse/file.rs | 0 {src => mers/src}/parse/mod.rs | 0 {src => mers/src}/parse/parse.rs | 0 {src => mers/src}/script/block.rs | 0 {src => mers/src}/script/builtins.rs | 0 {src => mers/src}/script/mod.rs | 0 {src => mers/src}/script/val_data.rs | 0 {src => mers/src}/script/val_type.rs | 0 {src => mers/src}/script/value.rs | 0 mers_libs/{gui.sh => gui} | 0 mers_libs/gui_v1/Cargo.lock | 0 mers_libs/gui_v1/Cargo.toml | 2 +- mers_libs/gui_v1/src/main.rs | 0 mers_libs/http_requests/Cargo.lock | 49 ++++++++++++++++++++++++++ mers_libs/http_requests/Cargo.toml | 9 +++++ mers_libs/http_requests/src/main.rs | 29 ++++++++++++++++ script.txt | 51 ++++++++++++++++++++++++++++ 26 files changed, 194 insertions(+), 5 deletions(-) create mode 100755 .gitignore mode change 100644 => 100755 README.md mode change 100644 => 100755 gui.txt create mode 100644 mers/Cargo.lock rename Cargo.toml => mers/Cargo.toml (100%) mode change 100644 => 100755 rename {src => mers/src}/libs/inlib.rs (100%) mode change 100644 => 100755 rename {src => mers/src}/libs/mod.rs (100%) mode change 100644 => 100755 rename {src => mers/src}/libs/path.rs (60%) mode change 100644 => 100755 rename {src => mers/src}/main.rs (100%) mode change 100644 => 100755 rename {src => mers/src}/parse/file.rs (100%) mode change 100644 => 100755 rename {src => mers/src}/parse/mod.rs (100%) mode change 100644 => 100755 rename {src => mers/src}/parse/parse.rs (100%) mode change 100644 => 100755 rename {src => mers/src}/script/block.rs (100%) mode change 100644 => 100755 rename {src => mers/src}/script/builtins.rs (100%) mode change 100644 => 100755 rename {src => mers/src}/script/mod.rs (100%) mode change 100644 => 100755 rename {src => mers/src}/script/val_data.rs (100%) mode change 100644 => 100755 rename {src => mers/src}/script/val_type.rs (100%) mode change 100644 => 100755 rename {src => mers/src}/script/value.rs (100%) mode change 100644 => 100755 rename mers_libs/{gui.sh => gui} (100%) mode change 100644 => 100755 mers_libs/gui_v1/Cargo.lock mode change 100644 => 100755 mers_libs/gui_v1/Cargo.toml mode change 100644 => 100755 mers_libs/gui_v1/src/main.rs create mode 100644 mers_libs/http_requests/Cargo.lock create mode 100755 mers_libs/http_requests/Cargo.toml create mode 100755 mers_libs/http_requests/src/main.rs create mode 100755 script.txt 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)") + } + } + } + } + [] +}