Skip to content

Commit

Permalink
Basic repl
Browse files Browse the repository at this point in the history
  • Loading branch information
Caznix committed Dec 1, 2024
0 parents commit 408f351
Show file tree
Hide file tree
Showing 19 changed files with 564 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --quiet --package xtask --"
29 changes: 29 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Rust

on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose

- name: Check formatting
run: cargo fmt -- --check

- name: Clippy
run: cargo clippy -- -D warnings
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/target
.idea
Cargo.lock
*.log
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

## Copyright (c) 2024 Caznix

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.**
Empty file added README.md
Empty file.
7 changes: 7 additions & 0 deletions cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[workspace]
resolver = "2"
members = [
"engine",
"editor",
"xtask"
]
7 changes: 7 additions & 0 deletions editor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "editor"
version = "0.1.0"
edition = "2021"

[dependencies]
floem = "0.2.0"
18 changes: 18 additions & 0 deletions editor/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use floem::{prelude::*, style::Style};

fn main() {
floem::launch(counter_view);
}

fn counter_view() -> impl IntoView {
let mut counter = RwSignal::new(20);
v_stack({
label("test")
}).style(Style::d);
h_stack((
button("Increment").action(move || counter += 1),
label(move || format!("Value: {counter}")),
button("Decrement").action(move || counter -= 1),
))
.style(|s| s.size_full().items_center().justify_center().gap(10))
}
1 change: 1 addition & 0 deletions engine/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
16 changes: 16 additions & 0 deletions engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "zenyx"
version = "0.1.0"
edition = "2021"

[dependencies]
chrono = "0.4.38"
colored = "2.1.0"
lazy_static = "1.5.0"
#log = "0.4.22"
log2 = "0.1.14"
parking_lot = "0.12.3"
reedline = "0.37.0"
regex = "1.11.1"
thiserror = "2.0.3"
tokio = { version = "1.41.1", features = ["macros", "rt", "rt-multi-thread"] }
36 changes: 36 additions & 0 deletions engine/src/core/commands.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use std::process::Command;

use log2::{debug, info};

use crate::core::repl::COMMAND_LIST;

pub fn say_hello() {
println!("Hello from your new command!");
}

pub fn echo(args: Vec<String>) {
debug!("{}", args.join(" "));
println!("{}", args.join(" "))
}

pub fn exit() {
debug!("Exiting...");
std::process::exit(0)
}
pub fn clear() {
info!("Clearing screen..., running command");
let _result = if cfg!(target_os = "windows") {
debug!("target_os is windows");
Command::new("cmd").args(["/c", "cls"]).spawn()
} else {
debug!("target_os was unix");
// "clear" or "tput reset"
Command::new("tput").arg("reset").spawn()
};
}
pub fn cmds() {
println!("Commands:");
for cmd in COMMAND_LIST.commands.read().iter() {
println!("{:#}", cmd);
}
}
3 changes: 3 additions & 0 deletions engine/src/core/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod commands;
pub mod repl;
pub mod splash;
Loading

0 comments on commit 408f351

Please sign in to comment.