cmd lib for terminal

This commit is contained in:
Penwing 2024-01-16 08:05:46 +01:00
parent 142a14cddb
commit 2d55760b63
3 changed files with 174 additions and 40 deletions

204
Cargo.lock generated
View file

@ -113,13 +113,22 @@ dependencies = [
"zerocopy",
]
[[package]]
name = "aho-corasick"
version = "0.6.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5"
dependencies = [
"memchr 2.7.1",
]
[[package]]
name = "aho-corasick"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
dependencies = [
"memchr",
"memchr 2.7.1",
]
[[package]]
@ -135,7 +144,7 @@ dependencies = [
"jni",
"jni-sys",
"libc",
"log",
"log 0.4.20",
"ndk",
"ndk-context",
"ndk-sys",
@ -156,7 +165,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aafb29b107435aa276664c1db8954ac27a6e105cdad3c88287a199eb0e313c08"
dependencies = [
"clipboard-win",
"log",
"log 0.4.20",
"objc",
"objc-foundation",
"objc_id",
@ -244,7 +253,7 @@ dependencies = [
"cfg-if",
"concurrent-queue",
"futures-lite 1.13.0",
"log",
"log 0.4.20",
"parking",
"polling 2.8.0",
"rustix 0.37.27",
@ -583,8 +592,9 @@ version = "0.1.0"
dependencies = [
"eframe",
"egui_extras",
"env_logger",
"env_logger 0.10.1",
"rfd",
"run_shell",
"syntect",
]
@ -595,7 +605,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b50b5a44d59a98c55a9eeb518f39bf7499ba19fd98ee7d22618687f3f10adbf"
dependencies = [
"bitflags 2.4.1",
"log",
"log 0.4.20",
"polling 3.3.1",
"rustix 0.38.30",
"slab",
@ -715,7 +725,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4"
dependencies = [
"bytes",
"memchr",
"memchr 2.7.1",
]
[[package]]
@ -884,7 +894,7 @@ dependencies = [
"glutin-winit",
"image",
"js-sys",
"log",
"log 0.4.20",
"objc",
"parking_lot",
"percent-encoding",
@ -907,7 +917,7 @@ dependencies = [
"accesskit",
"ahash",
"epaint",
"log",
"log 0.4.20",
"nohash-hasher",
"serde",
]
@ -921,7 +931,7 @@ dependencies = [
"accesskit_winit",
"arboard",
"egui",
"log",
"log 0.4.20",
"raw-window-handle 0.5.2",
"smithay-clipboard",
"web-time",
@ -937,7 +947,7 @@ checksum = "753c36d3e2f7a32425af5290af2e52efb3471ea3a263b87f003b5433351b0fd7"
dependencies = [
"egui",
"enum-map",
"log",
"log 0.4.20",
"mime_guess2",
"serde",
]
@ -951,7 +961,7 @@ dependencies = [
"bytemuck",
"egui",
"glow",
"log",
"log 0.4.20",
"memoffset 0.7.1",
"wasm-bindgen",
"web-sys",
@ -1020,6 +1030,16 @@ dependencies = [
"syn 2.0.48",
]
[[package]]
name = "env_logger"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b"
dependencies = [
"log 0.3.9",
"regex 0.2.11",
]
[[package]]
name = "env_logger"
version = "0.10.1"
@ -1028,7 +1048,7 @@ checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece"
dependencies = [
"humantime",
"is-terminal",
"log",
"log 0.4.20",
"termcolor",
]
@ -1043,7 +1063,7 @@ dependencies = [
"bytemuck",
"ecolor",
"emath",
"log",
"log 0.4.20",
"nohash-hasher",
"parking_lot",
"serde",
@ -1055,6 +1075,17 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
dependencies = [
"errno-dragonfly",
"libc",
"winapi",
]
[[package]]
name = "errno"
version = "0.3.8"
@ -1065,6 +1096,16 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "errno-dragonfly"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "error-code"
version = "2.3.1"
@ -1210,7 +1251,7 @@ dependencies = [
"fastrand 1.9.0",
"futures-core",
"futures-io",
"memchr",
"memchr 2.7.1",
"parking",
"pin-project-lite",
"waker-fn",
@ -1251,7 +1292,7 @@ dependencies = [
"futures-io",
"futures-sink",
"futures-task",
"memchr",
"memchr 2.7.1",
"pin-project-lite",
"pin-utils",
"slab",
@ -1348,7 +1389,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
dependencies = [
"khronos_api",
"log",
"log 0.4.20",
"xml-rs",
]
@ -1598,7 +1639,7 @@ dependencies = [
"cfg-if",
"combine",
"jni-sys",
"log",
"log 0.4.20",
"thiserror",
"walkdir",
"windows-sys 0.45.0",
@ -1710,6 +1751,15 @@ dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
dependencies = [
"log 0.4.20",
]
[[package]]
name = "log"
version = "0.4.20"
@ -1725,6 +1775,15 @@ dependencies = [
"libc",
]
[[package]]
name = "memchr"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a"
dependencies = [
"libc",
]
[[package]]
name = "memchr"
version = "2.7.1"
@ -1792,7 +1851,7 @@ checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7"
dependencies = [
"bitflags 2.4.1",
"jni-sys",
"log",
"log 0.4.20",
"ndk-sys",
"num_enum",
"raw-window-handle 0.5.2",
@ -1833,6 +1892,15 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]]
name = "nom"
version = "3.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b"
dependencies = [
"memchr 1.0.2",
]
[[package]]
name = "num-traits"
version = "0.2.17"
@ -2116,7 +2184,7 @@ dependencies = [
"cfg-if",
"concurrent-queue",
"libc",
"log",
"log 0.4.20",
"pin-project-lite",
"windows-sys 0.48.0",
]
@ -2181,7 +2249,7 @@ version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956"
dependencies = [
"memchr",
"memchr 2.7.1",
]
[[package]]
@ -2190,7 +2258,7 @@ version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33"
dependencies = [
"memchr",
"memchr 2.7.1",
]
[[package]]
@ -2262,14 +2330,27 @@ dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "regex"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384"
dependencies = [
"aho-corasick 0.6.10",
"memchr 2.7.1",
"regex-syntax 0.5.6",
"thread_local",
"utf8-ranges",
]
[[package]]
name = "regex"
version = "1.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
dependencies = [
"aho-corasick",
"memchr",
"aho-corasick 1.1.2",
"memchr 2.7.1",
"regex-automata",
"regex-syntax 0.8.2",
]
@ -2280,11 +2361,20 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
dependencies = [
"aho-corasick",
"memchr",
"aho-corasick 1.1.2",
"memchr 2.7.1",
"regex-syntax 0.8.2",
]
[[package]]
name = "regex-syntax"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
dependencies = [
"ucd-util",
]
[[package]]
name = "regex-syntax"
version = "0.6.29"
@ -2309,7 +2399,7 @@ dependencies = [
"gobject-sys",
"gtk-sys",
"js-sys",
"log",
"log 0.4.20",
"objc",
"objc-foundation",
"objc_id",
@ -2320,6 +2410,21 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "run_shell"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9504daf4912b22217ff6faa9c7707496037bdd200d8acfc87bce7ed271c8251e"
dependencies = [
"env_logger 0.4.3",
"errno 0.2.8",
"lazy_static",
"libc",
"log 0.3.9",
"nom",
"regex 0.2.11",
]
[[package]]
name = "rustix"
version = "0.37.27"
@ -2327,7 +2432,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2"
dependencies = [
"bitflags 1.3.2",
"errno",
"errno 0.3.8",
"io-lifetimes",
"libc",
"linux-raw-sys 0.3.8",
@ -2341,7 +2446,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca"
dependencies = [
"bitflags 2.4.1",
"errno",
"errno 0.3.8",
"libc",
"linux-raw-sys 0.4.12",
"windows-sys 0.52.0",
@ -2387,7 +2492,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82b2eaf3a5b264a521b988b2e73042e742df700c4f962cde845d1541adb46550"
dependencies = [
"ab_glyph",
"log",
"log 0.4.20",
"memmap2",
"smithay-client-toolkit",
"tiny-skia",
@ -2505,7 +2610,7 @@ dependencies = [
"calloop-wayland-source",
"cursor-icon",
"libc",
"log",
"log 0.4.20",
"memmap2",
"rustix 0.38.30",
"thiserror",
@ -2672,6 +2777,15 @@ dependencies = [
"syn 2.0.48",
]
[[package]]
name = "thread_local"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
dependencies = [
"lazy_static",
]
[[package]]
name = "time"
version = "0.3.31"
@ -2711,7 +2825,7 @@ dependencies = [
"arrayvec",
"bytemuck",
"cfg-if",
"log",
"log 0.4.20",
"tiny-skia-path",
]
@ -2829,6 +2943,12 @@ version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "ucd-util"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abd2fc5d32b590614af8b0a20d837f32eca055edd0bbead59a9cfe80858be003"
[[package]]
name = "uds_windows"
version = "1.1.0"
@ -2887,6 +3007,12 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "utf8-ranges"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcfc827f90e53a02eaef5e535ee14266c1d569214c6aa70133a624d8a3164ba"
[[package]]
name = "version-compare"
version = "0.1.1"
@ -2938,7 +3064,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd"
dependencies = [
"bumpalo",
"log",
"log 0.4.20",
"once_cell",
"proc-macro2",
"quote",
@ -3091,7 +3217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af"
dependencies = [
"dlib",
"log",
"log 0.4.20",
"once_cell",
"pkg-config",
]
@ -3125,7 +3251,7 @@ dependencies = [
"core-foundation",
"home",
"jni",
"log",
"log 0.4.20",
"ndk-context",
"objc",
"raw-window-handle 0.5.2",
@ -3423,7 +3549,7 @@ dependencies = [
"icrate",
"js-sys",
"libc",
"log",
"log 0.4.20",
"memmap2",
"ndk",
"ndk-sys",
@ -3459,7 +3585,7 @@ version = "0.5.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16"
dependencies = [
"memchr",
"memchr 2.7.1",
]
[[package]]
@ -3540,7 +3666,7 @@ checksum = "6924668544c48c0133152e7eec86d644a056ca3d09275eb8d5cdb9855f9d8699"
dependencies = [
"bitflags 2.4.1",
"dlib",
"log",
"log 0.4.20",
"once_cell",
"xkeysym",
]
@ -3616,7 +3742,7 @@ dependencies = [
"proc-macro-crate 1.3.1",
"proc-macro2",
"quote",
"regex",
"regex 1.10.2",
"syn 1.0.109",
"zvariant_utils",
]

View file

@ -14,3 +14,4 @@ env_logger = { version = "0.10.1", default-features = false, features = [
rfd = "0.12.1"
egui_extras = { version = "0.25.0" }
syntect = "4.6"
run_shell = "0.1.13"

View file

@ -4,10 +4,17 @@
use eframe::egui;
use std::fs;
use std::path::Path;
use run_shell::*;
const TERMINAL_HEIGHT : f32 = 200.0;
fn main() -> Result<(), eframe::Error> {
//tools::code_editor::linked();
println!("{}", cmd!("echo General Kenobi").stdout_utf8().unwrap());
println!("{}", cmd!("pwd").stdout_utf8().unwrap());
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
@ -90,7 +97,7 @@ impl eframe::App for MyApp {
);
});
});
egui::TopBottomPanel::bottom("terminal").show(ctx, |ui| {
egui::TopBottomPanel::bottom("terminal").min_height(TERMINAL_HEIGHT.clone()).show(ctx, |ui| {
ui.label("Terminal ?");
});
}