feat: add sciter

This commit is contained in:
2021-05-05 19:36:02 +08:00
parent 1addcd26ea
commit 134c0dc166
6 changed files with 203 additions and 0 deletions

76
__gui/sciter/Cargo.lock generated Normal file
View File

@@ -0,0 +1,76 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
[[package]]
name = "malloc_buf"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
dependencies = [
"libc",
]
[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
dependencies = [
"malloc_buf",
]
[[package]]
name = "objc-foundation"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
dependencies = [
"block",
"objc",
"objc_id",
]
[[package]]
name = "objc_id"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b"
dependencies = [
"objc",
]
[[package]]
name = "sciter"
version = "0.1.0"
dependencies = [
"sciter-rs",
]
[[package]]
name = "sciter-rs"
version = "0.5.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "265a6c1d8f32138274afbb250d4231e7329d579589d5c5d9b8b7fb9210aac90a"
dependencies = [
"lazy_static",
"libc",
"objc",
"objc-foundation",
]

12
__gui/sciter/Cargo.toml Normal file
View File

@@ -0,0 +1,12 @@
[package]
name = "sciter"
version = "0.1.0"
authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
sciter-rs = "0.5.56"

View File

@@ -0,0 +1,87 @@
<html window-icon="this://app/favicon.png">
<head>
<title>Sample Sciter demo</title>
<style>
html {
background: radial-gradient(75% 75%, circle farthest-side, white, orange, rgb(0,0,204));
color: #fff;
}
html:rtl {
mapping: left-to-right(background);
}
a { color: white; }
code { font-weight: bold; }
</style>
<script type="text/tiscript">
view.caption = $(head > title).value;
$(#machine).text = Sciter.machineName();
$(#version).text = String.printf("%d.%d.%d.%d",
(Sciter.VERSION >> 16) & 0xffff, Sciter.VERSION & 0xffff,
(Sciter.REVISION >> 16) & 0xffff, Sciter.REVISION & 0xffff);
try {
// since 4.2.5.0
$(#revision).text = Sciter.BUILD.toString();
} catch(e) {
$(#revision).text = "N/A";
}
var counter = 0;
$(button#append).on("click", function() {
$(body).$append(<h1#test>{ ++counter }</h1>);
});
$(button#open).on("click", function() {
var fn = view.selectFile(#open,
"HTML Files (*.htm,*.html)|*.HTM;*.HTML|All Files (*.*)|*.*" , "html" );
// if the dialog was closed or
// filesystem interaction was disabled via `ALLOW_FILE_IO`
// the selected file `fn` would be `undefined`.
stdout.println("selected file: " + fn);
if (fn) {
$(body).$append(<h1#test>{fn}</h1>);
}
});
// Some tricks with hyperlinks:
$(a).on("click", function() {
Sciter.launch(this.attributes["href"]);
return true;
});
for (var a in $$(a)) {
a.attributes["title"] = a.attributes["href"];
}
</script>
</head>
<body>
<h1>Sample Sciter Application</h1>
<p>Running on <em #machine /> machine</p>
<p>Sciter version <span #version /> rev <span #revision /></p>
<button #append>Append</button>
<button #open>Open</button>
<select>
<option>Some</option>
<option>Items</option>
<option>in select</option>
</select>
<section class=footer>
<p>You can inspect this window in the <a href="https://sciter.com/developers/development-tools/">Inspector tool</a>
from the <a href="https://sciter.com/download/">Sciter SDK</a>.</p>
<p>Run the Inspector first and then press <code>CTRL+SHIFT+I</code> in this window.</p>
</section>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

1
__gui/sciter/src/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
assets.rc

27
__gui/sciter/src/main.rs Normal file
View File

@@ -0,0 +1,27 @@
#![windows_subsystem = "windows"]
extern crate sciter;
// https://github.com/sciter-sdk/rust-sciter/blob/master/examples/minimal.rs
fn main() {
// let app_bytes = include_bytes!("app.htm");
// sciter::set_options(sciter::RuntimeOptions::ScriptFeatures(
// sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_SYSINFO as u8 // Enables `Sciter.machineName()`. Required for opening file dialog (`view.selectFile()`)
// | sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_FILE_IO as u8 // Enables opening file dialog (`view.selectFile()`)
// )).unwrap();
let mut frame = sciter::Window::new();
if cfg!(target_os="macos") {
// a temporary workaround for OSX, see
// https://sciter.com/forums/topic/global-sciter_set_debug_mode-does-not-work-in-osx/
frame.set_options(sciter::window::Options::DebugMode(true)).unwrap();
}
let favicon_bytes = include_bytes!("assets.rc");
frame.archive_handler(favicon_bytes).expect("Error load assets.rc!");
frame.load_file("this://app/app.htm");
// frame.load_html(app_bytes, Some("app://app.htm"));
frame.run_app();
}