Guest User

Untitled

a guest
Jul 30th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.78 KB | None | 0 0
  1. //! Minimalistic Sciter sample.
  2.  
  3. // Specify the Windows subsystem to eliminate console window.
  4. // Requires Rust 1.18.
  5. // #![windows_subsystem="windows"]
  6.  
  7. extern crate sciter;
  8.  
  9. use std::env;
  10. use std::io;
  11. use std::path::PathBuf;
  12.  
  13. fn inner_main() -> io::Result<PathBuf> {
  14.     let mut cwd = env::current_dir()?;
  15.     cwd.push("examples/movie_world.htm");
  16.     Ok(cwd)
  17. }
  18.  
  19. fn main() {
  20.     // Step 1: Include the 'minimal.html' file as a byte array.
  21.     // Hint: Take a look into 'minimal.html' which contains some tiscript code.
  22.    
  23.  
  24.     // Step 2: Enable the features we need in our tiscript code.
  25.     sciter::set_options(sciter::RuntimeOptions::ScriptFeatures(
  26.         sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_SYSINFO as u8 | // Enables Sciter.machineName()
  27.             sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_FILE_IO as u8 | // Enables opening file dialog (view.selectFile())
  28.             sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_SOCKET_IO as u8)).unwrap(); // Enables connecting to the inspector via Ctrl+Shift+I
  29.  
  30.     // Step 3: Create a new main sciter window of type `sciter::Window`.
  31.     // Hint: The sciter Window wrapper (src/window.rs) contains more
  32.     // interesting functions to open or attach to another existing window.
  33.     let mut frame = sciter::Window::new();
  34.  
  35.     // Step 4: Load HTML byte array from memory to `sciter::Window`.
  36.     // Hint: second parameter is an optional uri, it can be `None` in simple cases,
  37.     // but it is useful for debugging purposes (check the Inspector tool from the Sciter SDK).
  38.     // Also you can use a `load_file` method, but it requires an absolute path
  39.     // of the main document to resolve HTML resources properly.
  40.     let path = inner_main().expect("Couldn't");
  41.    
  42.     frame.load_file(path.to_str().unwrap());
  43.  
  44.     // Step 5: Show window and run the main app message loop until window been closed.
  45.     frame.run_app();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment