### Install All Example APKs Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt A target to install all generated example APKs onto connected devices. This aggregates individual install targets. ```cmake add_custom_target(install-sdl-example-apks DEPENDS ${install_targets} VERBATIM ) ``` -------------------------------- ### Conditional Example Installation Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt Handles the installation of example executables and resource files based on build configurations like SDL_INSTALL_EXAMPLES, RISCOS, and MSVC. It ensures correct file placement and PDB file installation for MSVC. ```cmake if(SDL_INSTALL_EXAMPLES) if(RISCOS) install( FILES ${SDL_EXAMPLE_EXECUTABLES_AIF} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-examples/SDL3 ) else() install( TARGETS ${SDL_EXAMPLE_EXECUTABLES} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-examples/SDL3 ) endif() if(MSVC) foreach(example IN LISTS SDL_EXAMPLE_EXECUTABLES) SDL_install_pdb(${example} "${CMAKE_INSTALL_LIBEXECDIR}/installed-examples/SDL3") endforeach() endif() install( FILES ${RESOURCE_FILES} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-examples/SDL3 ) endif() ``` -------------------------------- ### Install and Run WebSocket Echo Server Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/samples/websockets/websocket-echo-server/README.md Installs dependencies and starts the WebSocket echo server. Ensure Node.js is installed. ```bash npm install ``` ```bash node index.js ``` -------------------------------- ### Install Local Package on Windows Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-gdk.md Installs a locally created application package. The application will then be available from the start menu. ```bash wdapp install PACKAGENAME.msixvc ``` -------------------------------- ### Build, Install, and Start a test with CMake Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-android.md A convenience CMake target that automates the process of building, installing, and starting a specific SDL test application. This streamlines the workflow for testing. ```bash cmake --build . --target build-install-start-testsprite ``` -------------------------------- ### Sciter.js Bootstrap Execution Example Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/scapp/bootstrap-runtime-mode.md This script configures the graphics backend and initializes the main window during the bootstrap phase. It selects the startup script based on the platform and starts the application's message loop. ```javascript import * as env from "@env"; import * as sys from "@sys"; let startup; let gfx = "gpu"; // use best GPU backend... switch(env.PLATFORM) { case "Windows": startup = "main-win.js"; break; case "OSX": startup = "main-mac.js"; gfx = "opengl"; // force using OpenGL instead of Metal break; default: startup = "main-linux.js"; break; } application.start(gfx); // configure graphics backend const mainWindow = new Window({ url:__DIR__ + "hello.htm", parameters: {} // parameters to pass }); mainWindow.on("close",() => application.quit(0)); //... other initialization ... let quitVal = application.run(); // message pump loop //... shutdown ... ``` -------------------------------- ### Install Dependencies Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/samples.sciter/code-beautifier/README.md Run this command in your project directory to install necessary dependencies for Prettier. ```sh npm install ``` -------------------------------- ### Add Simple Audio Playback Example Executable Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt Adds an executable for the simple audio playback example. ```cmake add_sdl_example_executable(audio-simple-playback SOURCES audio/01-simple-playback/simple-playback.c) ``` -------------------------------- ### Installation and Version Printing Options Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/src/hidapi/CMakeLists.txt Enables targets for installation and prints the library version during the build process. ```cmake set(HIDAPI_INSTALL_TARGETS ON) set(HIDAPI_PRINT_VERSION ON) ``` -------------------------------- ### Build SDL examples with CMake Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-cmake.md Enables building SDL example programs. Add -DSDL_EXAMPLES=ON to the initial CMake configuration command. ```sh cmake -S . -B build -DSDL_EXAMPLES=ON ``` -------------------------------- ### Start Activity Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt Launches the main activity of the installed Android application using ADB. This command is conditional on the SdlAndroid::adb target being available. ```cmake add_custom_target(start-${EXAMPLE} COMMAND "${ADB_BIN}" shell am start-activity -S "${ANDROID_MANIFEST_PACKAGE}/.SDLTestActivity" ) ``` -------------------------------- ### Add Simple Audio Playback Callback Example Executable Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt Adds an executable for the simple audio playback using a callback example. ```cmake add_sdl_example_executable(audio-simple-playback-callback SOURCES audio/02-simple-playback-callback/simple-playback-callback.c) ``` -------------------------------- ### Install remarkable-emoji Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/samples/markdown/remarkable/plugins/emoji/README.md Install the plugin using npm. This is the first step before using it in your project. ```bash npm install remarkable-emoji ``` -------------------------------- ### Enable HIDAPI Installation and Customize Locations Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/src/hidapi/BUILD.cmake.md Enable the installation of HIDAPI targets and optionally change default installation directories by setting HIDAPI_INSTALL_TARGETS and CMAKE_INSTALL_LIBDIR before adding the subdirectory. ```cmake # enable the installation if you need it set(HIDAPI_INSTALL_TARGETS ON) # (optionally) change default installation locations if it makes sense for your target platform, etc. set(CMAKE_INSTALL_LIBDIR "lib64") add_subdirectory(hidapi) ``` -------------------------------- ### Build, Install, and Run Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt A convenience target that automates the process of building, installing, and running the Android application. ```cmake add_custom_target(build-install-start-${EXAMPLE} COMMAND "${CMAKE_COMMAND}" -DACTION=build-install-run "-DEXECUTABLES=${EXAMPLE}" "-DBUILD_FOLDER=${CMAKE_BINARY_DIR}" -P "${SDL3_SOURCE_DIR}/cmake/android/SdlAndroidScript.cmake" ) ``` -------------------------------- ### Install HIDAPI Libraries with CMake Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/src/hidapi/BUILD.cmake.md Install the HIDAPI libraries. The order of installation matters: install the static libraries first, followed by the shared libraries. This ensures that both types are available and correctly configured. ```bash # Install the libraries # NOTE: order of installation matters - install Shared variant *the last* # Static libraries cmake --install "/static" # Shared libraries cmake --install "/shared" ``` -------------------------------- ### Enable installation of SDL test programs Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-cmake.md Use `-DSDL_INSTALL_TESTS=ON` to include the SDL test programs in the installation. ```cmake -DSDL_INSTALL_TESTS=ON ``` -------------------------------- ### Build and Install Android APK Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-android.md Execute the Gradle wrapper command to build and install your application's APK onto a connected Android device. ```bash ./gradlew installDebug ``` ```bash ./gradlew installRelease ``` -------------------------------- ### Install SDL3 Package Configuration (CMake) Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/CMakeLists.txt Installs the sdl3.pc file, which is used by pkg-config to provide information about the installed SDL3 library. This is skipped if SDL_FRAMEWORK is enabled. ```cmake if(SDL_INSTALL) ##### sdl3.pc ##### configure_sdl3_pc() if(NOT SDL_FRAMEWORK) install(FILES ${SDL3_BINARY_DIR}/sdl3.pc DESTINATION "${SDL_PKGCONFIG_INSTALLDIR}") endif() ##### Installation targets #####() install(TARGETS SDL3_Headers EXPORT SDL3headersTargets) ``` -------------------------------- ### Install Autotools on FreeBSD Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/src/hidapi/BUILD.autotools.md Installs Autotools and GNU make on FreeBSD systems using pkg_add. ```bash pkg_add -r autotools ``` ```bash pkg_add -r gmake ``` -------------------------------- ### Install libiconv on FreeBSD Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/src/hidapi/BUILD.md Installs the libiconv library on FreeBSD systems using pkg_add. This is a prerequisite for building HIDAPI on FreeBSD. ```sh pkg_add -r libiconv ``` -------------------------------- ### Determine Example Binary Directory in CMake Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt Sets the directory for example executable binaries. It handles absolute and relative paths, and appends the configuration name for multi-configuration generators. ```cmake set(SDL_EXAMPLE_EXECUTABLES) if(CMAKE_RUNTIME_OUTPUT_DIRECTORY) set(example_bin_dir "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") if(NOT IS_ABSOLUTE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") set(example_bin_dir "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() else() set(example_bin_dir "${CMAKE_CURRENT_BINARY_DIR}") endif() if(NOT CMAKE_VERSION VERSION_LESS 3.20) get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) set(example_bin_dir "${example_bin_dir}$<$:/$>") endif() ``` -------------------------------- ### Configure Installation Folders (CMake) Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/CMakeLists.txt Sets default installation directories for CMake configuration files and pkgconfig files, adapting to different operating systems and build types. ```cmake if(WINDOWS AND NOT MINGW) set(SDL_INSTALL_CMAKEDIR_ROOT_DEFAULT "cmake") else() set(SDL_INSTALL_CMAKEDIR_ROOT_DEFAULT "${CMAKE_INSTALL_LIBDIR}/cmake/SDL3") endif() set(SDL_INSTALL_CMAKEDIR_ROOT "${SDL_INSTALL_CMAKEDIR_ROOT_DEFAULT}" CACHE STRING "Root folder where to install SDL3Config.cmake related files (SDL3 subfolder for MSVC projects)") if(FREEBSD) # FreeBSD uses ${PREFIX}/libdata/pkgconfig set(SDL_PKGCONFIG_INSTALLDIR "libdata/pkgconfig") else() set(SDL_PKGCONFIG_INSTALLDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig") endif() if(WINDOWS AND NOT MINGW) set(SDL_INSTALL_CMAKEDIR "${SDL_INSTALL_CMAKEDIR_ROOT}") set(SDL_INSTALL_LICENSEDIR "licenses/SDL3") set(SDL_INSTALL_HEADERSDIR "${CMAKE_INSTALL_INCLUDEDIR}/SDL3") elseif(SDL_FRAMEWORK) set(SDL_INSTALL_CMAKEDIR "SDL3.framework/Versions/${SDL_FRAMEWORK_VERSION}/Resources/CMake") set(SDL_INSTALL_LICENSEDIR "Resources") set(SDL_INSTALL_HEADERSDIR "Headers") else() set(SDL_INSTALL_CMAKEDIR "${SDL_INSTALL_CMAKEDIR_ROOT}") set(SDL_INSTALL_LICENSEDIR "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${PROJECT_NAME}") set(SDL_INSTALL_HEADERSDIR "${CMAKE_INSTALL_INCLUDEDIR}/SDL3") endif() ``` ```cmake if(SDL_FRAMEWORK) set(SDL_SDL_INSTALL_RESOURCEDIR "SDL3.framework/Resources") set(SDL_SDL_INSTALL_CMAKEDIR "${SDL_SDL_INSTALL_RESOURCEDIR}/CMake") set(SDL_SDL_INSTALL_REAL_RESOURCEDIR "SDL3.framework/Versions/${SDL_FRAMEWORK_VERSION}/Resources") set(SDL_SDL_INSTALL_REAL_CMAKEDIR "${SDL_SDL_INSTALL_REAL_RESOURCEDIR}/CMake") set(SDL_SDLtest_INSTALL_RESOURCEDIR "SDL3_test.framework/Resources") set(SDL_SDLtest_INSTALL_CMAKEDIR "${SDL_SDLtest_INSTALL_RESOURCEDIR}/CMake") set(SDL_SDLtest_INSTALL_CMAKEFILENAME "SDL3_testConfig.cmake") else() set(SDL_SDL_INSTALL_RESOURCEDIR ".") set(SDL_SDL_INSTALL_CMAKEDIR ${SDL_INSTALL_CMAKEDIR}) set(SDL_SDL_INSTALL_REAL_CMAKEDIR ${SDL_INSTALL_CMAKEDIR}) # Install SDL3*Targets.cmake files in lib/cmake/SDL3 set(SDL_SDLstatic_INSTALL_RESOURCEDIR ".") set(SDL_SDLstatic_INSTALL_CMAKEDIR "${SDL_SDL_INSTALL_CMAKEDIR}") set(SDL_SDLstatic_INSTALL_CMAKEFILENAME "SDL3staticTargets.cmake") set(SDL_SDLtest_INSTALL_RESOURCEDIR ".") set(SDL_SDLtest_INSTALL_CMAKEDIR "${SDL_SDL_INSTALL_CMAKEDIR}") set(SDL_SDLtest_INSTALL_CMAKEFILENAME "SDL3testTargets.cmake") endif() ``` -------------------------------- ### Install Static Library Targets (CMake) Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/CMakeLists.txt Installs the SDL3 static library, including archives, framework resources, and PDB files for MSVC. ```cmake if(SDL_STATIC) install(TARGETS SDL3-static EXPORT SDL3staticTargets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" FRAMEWORK DESTINATION "." RESOURCE DESTINATION "${SDL_SDLstatic_INSTALL_RESOURCEDIR}" ) if(MSVC) SDL_install_pdb(SDL3-static "${CMAKE_INSTALL_LIBDIR}") endif() endif() ``` -------------------------------- ### Install Autotools on Ubuntu Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/src/hidapi/BUILD.autotools.md Installs the required Autotools packages (autoconf, automake, libtool) on Ubuntu systems using APT. ```bash sudo apt install autoconf automake libtool ``` -------------------------------- ### Installation Configuration for GLFW Library Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sciter/glfw/src/CMakeLists.txt Configures the installation of the GLFW library targets, including runtime binaries, archives, and libraries, based on the GLFW_INSTALL flag. ```cmake if (GLFW_INSTALL) install(TARGETS glfw EXPORT glfwTargets RUNTIME DESTINATION "bin" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") endif() ``` -------------------------------- ### Add Geometry Rendering Example Executable Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt Adds an executable for the geometry rendering example, including a sample BMP data file. ```cmake add_sdl_example_executable(renderer-geometry SOURCES renderer/10-geometry/geometry.c DATAFILES ${CMAKE_CURRENT_SOURCE_DIR}/../test/sample.bmp) ``` -------------------------------- ### SDL2 Audio Playback with Callback Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-migration.md Example of setting up an audio callback for audio playback in SDL2. Requires defining a callback function and opening an audio device. ```c void SDLCALL MyAudioCallback(void *userdata, Uint8 * stream, int len) { /* Calculate a little more audio here, maybe using `userdata`, write it to `stream` */ } /* ...somewhere near startup... */ SDL_AudioSpec my_desired_audio_format; SDL_zero(my_desired_audio_format); my_desired_audio_format.format = AUDIO_S16; my_desired_audio_format.channels = 2; my_desired_audio_format.freq = 44100; my_desired_audio_format.samples = 1024; my_desired_audio_format.callback = MyAudioCallback; my_desired_audio_format.userdata = &my_audio_callback_user_data; SDL_AudioDeviceID my_audio_device = SDL_OpenAudioDevice(NULL, 0, &my_desired_audio_format, NULL, 0); SDL_PauseAudioDevice(my_audio_device, 0); ``` -------------------------------- ### Add Viewport Rendering Example Executable Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt Adds an executable for the viewport rendering example, including a sample BMP data file. ```cmake add_sdl_example_executable(renderer-viewport SOURCES renderer/14-viewport/viewport.c DATAFILES ${CMAKE_CURRENT_SOURCE_DIR}/../test/sample.bmp) ``` -------------------------------- ### Window Constructor Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/DOM/Window.md Demonstrates how to create a new Window instance with various configuration options. ```APIDOC ## Window Constructor ### Description Creates a new desktop window instance. ### Method `new Window(params)` ### Parameters #### Request Body - **params** (object) - Optional. An object containing configuration properties for the new window. - **type** (enum) - Optional. The type of window. Defaults to `Window.FRAME_WINDOW`. Possible values: `Window.POPUP_WINDOW`, `Window.TOOL_WINDOW`, `Window.CHILD_WINDOW`, `Window.FRAME_WINDOW`, `Window.DIALOG_WINDOW`. - **parent** (Window) - Optional. The parent window instance. The new window's lifecycle and z-order are tied to its parent. - **caption** (string) - Optional. The window's title or caption. - **x** (integer) - Optional. The horizontal screen position of the window. - **y** (integer) - Optional. The vertical screen position of the window. - **width** (integer) - Optional. The width of the window in screen pixels. - **height** (integer) - Optional. The height of the window in screen pixels. - **client** (boolean) - Optional. If true, `x`, `y`, `width`, and `height` refer to the client area coordinates and dimensions. - **alignment** (integer) - Optional. Alignment of the window on the monitor (1-9) or against its parent (-1 to -9). - **screen** (integer) - Optional. The monitor index for multi-monitor systems. - **state** (enum) - Optional. The initial state of the window. Defaults to `Window.WINDOW_SHOWN`. Possible values: `Window.WINDOW_SHOWN`, `Window.WINDOW_MINIMIZED`, `Window.WINDOW_MAXIMIZED`, `Window.WINDOW_HIDDEN`, `Window.WINDOW_FULL_SCREEN`. - **url** (string) - Optional. The URL of the HTML file to load into the window. - **parameters** (array | string | object) - Optional. Extra parameters to pass to the new window. ### Request Example ```javascript new Window({ "type": Window.POPUP_WINDOW, "caption": "My Popup Window", "width": 400, "height": 300, "url": "./my_popup.html" }); ``` ``` -------------------------------- ### Get Installed Font Families Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/graphics/README.md Retrieves an array of strings, where each string is the name of a font family installed on the system. ```javascript let listOfFontFamilies = Graphics.fontFamilies(); ``` -------------------------------- ### Import External Wayland Surface with Qt 6 Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-wayland.md This example demonstrates integrating SDL with Qt 6 by sharing the wl_display and importing a Qt-generated wl_surface into an SDL window. Ensure the windowing system is Wayland and avoid setting high pixel density properties if Qt manages scaling. ```c++ #include #include #include #include int main(int argc, char *argv[]) { int ret = -1; int done = 0; SDL_PropertiesID props; SDL_Event e; SDL_Window *sdlWindow = NULL; SDL_Renderer *sdlRenderer = NULL; struct wl_display *display = NULL; struct wl_surface *surface = NULL; /* Initialize Qt */ QApplication qtApp(argc, argv); QWindow qtWindow; /* The windowing system must be Wayland. */ if (QApplication::platformName() != "wayland") { goto exit; } { /* Get the wl_display object from Qt */ QNativeInterface::QWaylandApplication *qtWlApp = qtApp.nativeInterface(); display = qtWlApp->display(); if (!display) { goto exit; } } /* Set SDL to use the existing wl_display object from Qt and initialize. */ SDL_SetPointerProperty(SDL_GetGlobalProperties(), SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER, display); SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS); /* Create a basic, frameless QWindow */ qtWindow.setFlags(Qt::FramelessWindowHint); qtWindow.setGeometry(0, 0, 640, 480); qtWindow.show(); { /* Get the native wl_surface backing resource for the window */ QPlatformNativeInterface *qtNative = qtApp.platformNativeInterface(); surface = (struct wl_surface *)qtNative->nativeResourceForWindow("surface", &qtWindow); if (!surface) { goto exit; } } /* Create a window that wraps the wl_surface from the QWindow. * Qt objects should not be flagged as DPI-aware or protocol violations will result. */ props = SDL_CreateProperties(); SDL_SetPointerProperty(props, SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER, surface); SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN, true); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, 640); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, 480); sdlWindow = SDL_CreateWindowWithProperties(props); SDL_DestroyProperties(props); if (!sdlWindow) { goto exit; } /* Create a renderer */ sdlRenderer = SDL_CreateRenderer(sdlWindow, NULL); if (!sdlRenderer) { goto exit; } ``` -------------------------------- ### Uninstall All Example APKs Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt A target to uninstall all installed example applications from connected devices. This uses ADB to remove packages based on a list. ```cmake add_custom_target(uninstall-sdl-example-apks COMMAND "${CMAKE_COMMAND}" "-DADB=$" -DACTION=uninstall "-DPACKAGES=${packages}" -P "${SDL3_SOURCE_DIR}/cmake/android/SdlAndroidScript.cmake" VERBATIM ) ``` -------------------------------- ### Get Selection Start Position Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-edit.md The `selectionStart` property returns the starting index of the current text selection, or the caret position if no text is selected. ```javascript element.edit.selectionStart: int ``` -------------------------------- ### Start testsprite executable with CMake Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-android.md Start the 'testsprite' executable on an Android device using a CMake target. This command assumes the test is already built and installed. ```bash cmake --build . --target start-testsprite ``` -------------------------------- ### Create a String Index Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/storage/Storage.Index.md Example of creating a persistent index for notes, keyed by a string (GUID). ```javascript storage.root = { version:1, notes: storage.createIndex("string") // note by id (string, GUID) index } ``` -------------------------------- ### Initialize and Interact with HID Device in C Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/src/hidapi/README.md This C code snippet demonstrates the basic workflow of using the HIDAPI library. It includes initializing the library, opening a device by Vendor ID and Product ID, retrieving device strings, sending commands, reading data, and closing the device. Error checking is omitted for simplicity. Warning: Writing data to HID devices can potentially break them. ```c #include // printf #include // wchar_t #include #define MAX_STR 255 int main(int argc, char* argv[]) { int res; unsigned char buf[65]; wchar_t wstr[MAX_STR]; hid_device *handle; int i; // Initialize the hidapi library res = hid_init(); // Open the device using the VID, PID, // and optionally the Serial number. handle = hid_open(0x4d8, 0x3f, NULL); if (!handle) { printf("Unable to open device\n"); hid_exit(); return 1; } // Read the Manufacturer String res = hid_get_manufacturer_string(handle, wstr, MAX_STR); printf("Manufacturer String: %ls\n", wstr); // Read the Product String res = hid_get_product_string(handle, wstr, MAX_STR); printf("Product String: %ls\n", wstr); // Read the Serial Number String res = hid_get_serial_number_string(handle, wstr, MAX_STR); printf("Serial Number String: (%d) %ls\n", wstr[0], wstr); // Read Indexed String 1 res = hid_get_indexed_string(handle, 1, wstr, MAX_STR); printf("Indexed String 1: %ls\n", wstr); // Toggle LED (cmd 0x80). The first byte is the report number (0x0). buf[0] = 0x0; buf[1] = 0x80; res = hid_write(handle, buf, 65); // Request state (cmd 0x81). The first byte is the report number (0x0). buf[0] = 0x0; buf[1] = 0x81; res = hid_write(handle, buf, 65); // Read requested state res = hid_read(handle, buf, 65); // Print out the returned buffer. for (i = 0; i < 4; i++) printf("buf[%d]: %d\n", i, buf[i]); // Close the device hid_close(handle); // Finalize the hidapi library res = hid_exit(); return 0; } ``` -------------------------------- ### Conditional Installation and Launch Targets Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/test/CMakeLists.txt Sets up custom targets for installing, starting, and building/installing/running the Android application, conditional on the SdlAndroid::adb target being available. These commands utilize CMake scripts for Android-specific actions. ```cmake if(TARGET SdlAndroid::adb) add_custom_target(install-${TEST} COMMAND "${CMAKE_COMMAND}" -DACTION=install "-DAPKS=$" -P "${SDL3_SOURCE_DIR}/cmake/android/SdlAndroidScript.cmake" DEPENDS "${TEST}-apk" ) add_custom_target(start-${TEST} COMMAND "${ADB_BIN}" shell am start-activity -S "${ANDROID_MANIFEST_PACKAGE}/.SDLTestActivity" ) add_custom_target(build-install-start-${TEST} COMMAND "${CMAKE_COMMAND}" -DACTION=build-install-run "-DEXECUTABLES=${TEST}" "-DBUILD_FOLDER=${CMAKE_BINARY_DIR}" -P "${SDL3_SOURCE_DIR}/cmake/android/SdlAndroidScript.cmake" ) endif() ``` -------------------------------- ### Build SDL with MinGW-w64 and CMake Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-windows.md Commands to configure, build, and install SDL using MinGW-w64 and CMake. Ensure MSYS2 and necessary toolchains are installed prior to execution. ```sh mkdir build cmake -S . -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE=build-scripts/cmake-toolchain-mingw64-x86_64.cmake cmake --build build --parallel cmake --install build --prefix C:/Libraries ``` -------------------------------- ### Build from Command Line Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-macos.md Use the `xcode-build` command in the same directory as your .pbxproj file to build the project from the command line. ```bash xcode-build ``` -------------------------------- ### Plaintext Selection Properties Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-plaintext.md Read-only properties to get the start and end line/position of the selection, and the selected text itself. ```javascript const selectionStart = el.plaintext.selectionStart; ``` ```javascript const selectionEnd = el.plaintext.selectionEnd; ``` ```javascript const selectedText = el.plaintext.selectionText; ``` -------------------------------- ### Get List of Mounted Drives Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/JS.runtime/module-env.md Retrieves an array of root paths for all mounted drives on the system. Example output for Windows is shown. ```javascript const drives = env.drives(); // drives: ["C:","D:"] on Windows ``` -------------------------------- ### Load and Play Audio with Sciter Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/JS.runtime/Audio.md This example demonstrates how to load an audio file using `Audio.load` and play it to completion using `audio.play`. Ensure the audio file path is correct. ```javascript async function sayHello() { let audio = await Audio.load(__DIR__ + "/sounds/hello.mp3"); console.log("playing started"); await audio.play(); console.log("playing done"); } ``` -------------------------------- ### Get CSS Property using camelCase Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/DOM/Element/Style.md Access CSS properties using their camelCase names. No specific setup is required beyond having an element reference. ```javascript var bgColor = element.style.backgroundColor; ``` -------------------------------- ### CMake Minimum Version and Project Setup Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/cmake/test/CMakeLists.txt Sets the minimum required CMake version and defines the project name and languages. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required(VERSION 3.12) project(SDL_cmake_selftest LANGUAGES C) ``` -------------------------------- ### Initialize WebGL Demo and GUI Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/samples.webgl/basic/1-cube-lights/index.htm This script initializes the WebGL demo and sets up the lil-gui interface. It requires the 'webgl-demo.js' module for the main WebGL logic and 'gui.js' for the GUI. The GUI controls 'speed' and 'background' parameters of the demo. ```javascript body { margin:0; } import {main} from "./webgl-demo.js"; import {GUI} from "../../../widgets/lil-gui/gui.js"; document.on("ready", function() { const canvas = document.$("canvas#gl"); const params = main(canvas); const gui = new GUI(); gui.add(params,"speed",0,2.0,0.1); gui.add(params,"background"); }); ``` -------------------------------- ### Get Content and Selection as Source Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-htmlarea.md Returns the current content and selection of the editor as an array containing the HTML string, a URL for resolving relative paths, and the start and end offsets of the selection. ```javascript htmlarea.contentToSource() : [html:string, url:string, selStart:integer, selEnd:integer] ``` -------------------------------- ### Build SDL Framework Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-macos.md Open the framework project in Xcode and build it. The SDL.framework bundle is typically installed in /Library/Frameworks by default. ```bash # No specific code provided, refers to Xcode IDE actions. ``` -------------------------------- ### Initialize WebGL Canvas and GUI Controls Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/samples.webgl/basic/2-element-as-texture/index.htm Sets up the WebGL canvas and initializes GUI controls for rendering parameters. Requires 'webgl-demo.js' and 'lil-gui.js'. ```javascript body { margin:0; } video { size:100px; } import {main,bindSourceElement} from "./webgl-demo.js"; import {GUI} from "../../../widgets/lil-gui/gui.js"; import {TextureSources} from "./texture-sources.js" document.on("ready", function() { const canvas = document.$("canvas#gl"); const params = main(canvas); const gui = new GUI(); gui.add(params,"speed",0,2.0,0.1); gui.add(params,"background"); }); // pass bindSourceElement to TextureSources document.body.append(); ``` -------------------------------- ### Get CSS Property using hyphen-case Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/DOM/Element/Style.md Access CSS properties using their original hyphen-case names by treating the style object like a map. No specific setup is required beyond having an element reference. ```javascript var bgColor = element.style["background-color"]; ``` -------------------------------- ### Create and Manage Windows in Sciter.JS Source: https://context7.com/sciter-engine/sciter-js-sdk/llms.txt Demonstrates creating a new window with various options, accessing the current window, managing its state and properties, and handling file dialogs. Use this for initializing and controlling application windows. ```javascript // Create a new window with various options const win = new Window({ type: Window.FRAME_WINDOW, caption: "My Application", width: 800, height: 600, alignment: 5, // Center on screen (NUMPAD style: 5 = center) state: Window.WINDOW_SHOWN, url: "file://app/main.htm", parameters: { userId: 123 } }); // Access current window const currentWindow = Window.this; // Window state management currentWindow.state = Window.WINDOW_MAXIMIZED; // SHOWN, MINIMIZED, MAXIMIZED, HIDDEN, FULL_SCREEN // Set window properties currentWindow.caption = "Updated Title"; currentWindow.minSize = [400, 300]; currentWindow.maxSize = [1920, 1080]; currentWindow.isResizable = true; currentWindow.blurBehind = "light source-desktop"; // Mica effect on Win11 // Get window geometry const [x, y, w, h] = currentWindow.box("xywh", "border", "desktop"); const [screenW, screenH] = currentWindow.screenBox("workarea", "dimension"); // Move and resize currentWindow.move(100, 100, 800, 600); currentWindow.moveTo(0, 50, 50, 640, 480); // Move to specific monitor // File dialogs const filePath = currentWindow.selectFile({ mode: "open", filter: "Images (*.png,*.jpg)|*.png;*.jpg|All Files (*.*)|*.*", ``` ```javascript caption: "Select Image" }); const folderPath = currentWindow.selectFolder({ caption: "Select Output Folder", path: "C:\\Users\\Default" }); ``` -------------------------------- ### Create Solid Window with Shadow Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/samples.sciter/window/window-chrome-types.htm Opens a new window with a solid frame and a shadow effect. This example also demonstrates setting minimum and maximum window sizes. ```javascript var wnd = new Window({ url : __DIR + "chrome-types/window-frame-solid-with-shadow.htm", state : Window.WINDOW_SHOWN }); ``` -------------------------------- ### Install HIDAPI Include Library Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/src/hidapi/src/CMakeLists.txt Installs the HIDAPI include library targets if HIDAPI_INSTALL_TARGETS is enabled. This ensures header files are correctly placed during installation. ```cmake if(HIDAPI_INSTALL_TARGETS) install(TARGETS hidapi_include EXPORT hidapi) endif() ``` -------------------------------- ### HID Device and Preparsed Data Structure Example Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/src/hidapi/windows/pp_data_dump/README.md This example shows the typical content of a .pp_data file generated by pp_data_dump.exe. It includes device information and the parsed structure of the Preparsed Data, mirroring HIDAPI's internal representation. ```text # HIDAPI device info struct: dev->vendor_id = 0x046D dev->product_id = 0xB010 dev->manufacturer_string = "Logitech" dev->product_string = "Logitech Bluetooth Wireless Mouse" dev->release_number = 0x0000 dev->interface_number = -1 dev->usage = 0x0001 dev->usage_page = 0x000C dev->path = "\\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002046d_pid&b010&col02#8&1cf1c1b9&3&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}" # Preparsed Data struct: pp_data->MagicKey = 0x48696450204B4452 pp_data->Usage = 0x0001 pp_data->UsagePage = 0x000C pp_data->Reserved = 0x00000000 # Input caps_info struct: pp_data->caps_info[0]->FirstCap = 0 pp_data->caps_info[0]->LastCap = 1 pp_data->caps_info[0]->NumberOfCaps = 1 pp_data->caps_info[0]->ReportByteLength = 2 # Output caps_info struct: pp_data->caps_info[1]->FirstCap = 1 pp_data->caps_info[1]->LastCap = 1 pp_data->caps_info[1]->NumberOfCaps = 0 pp_data->caps_info[1]->ReportByteLength = 0 # Feature caps_info struct: pp_data->caps_info[2]->FirstCap = 1 pp_data->caps_info[2]->LastCap = 1 pp_data->caps_info[2]->NumberOfCaps = 0 pp_data->caps_info[2]->ReportByteLength = 0 # LinkCollectionArray Offset & Size: pp_data->FirstByteOfLinkCollectionArray = 0x0068 pp_data->NumberLinkCollectionNodes = 1 ``` -------------------------------- ### Render 'Hello World' with Preact in Sciter.js Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/samples/preact/hello-world.html Demonstrates basic UI rendering using Preact within a Sciter.js environment. Ensure Preact is correctly imported. ```javascript import { h, Component, render } from "./preact.js"; // Create your app const app = h('h1', null, 'Hello World!'); console.log(app); render(app, document.body); ``` -------------------------------- ### Install HIDAPI Development Package on Ubuntu Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/src/hidapi/README.md This command installs the HIDAPI development package on Ubuntu systems using the APT package manager. Ensure you have the necessary permissions to install packages. ```sh sudo apt install libhidapi-dev ``` -------------------------------- ### Installing SDL Test Executables Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/test/CMakeLists.txt Conditionally installs SDL test executables to a specific destination directory based on the `SDL_INSTALL_TESTS` variable. Handles RISC OS specific file installations separately. ```cmake if(SDL_INSTALL_TESTS) if(RISCOS) install( FILES ${SDL_TEST_EXECUTABLES_AIF} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL3 ) else() install( TARGETS ${SDL_TEST_EXECUTABLES} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL3 ) endif() endif() ``` -------------------------------- ### Install testsprite APK with CMake Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-android.md Install the 'testsprite.apk' onto a connected Android device or emulator using a specific CMake target. This allows for direct installation without manual ADB commands. ```bash cmake --build . --target install-testsprite ``` -------------------------------- ### Initialize Sciter.js Environment Information Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.d2d/windows-directx/res/sys-info.htm This script populates UI elements with Sciter.js version, revision, QuickJS version, and environment details like OS type, OS version, graphics backend, user, machine, domain, country, and language. It requires the sciter and env modules to be imported. ```javascript import * as sciter from "@sciter"; import * as env from "@env"; const $ = sciter.$; const on = sciter.on; document.ready = function() { $("#version").innerText = sciter.VERSION; $("#revision").innerText = sciter.REVISION; $("#quickjs-version").innerText = sciter.QUICKJS_VERSION; $("#os-type").innerText = env.DEVICE; $("#os-version").innerText = env.OS; $("#user").innerText = env.userName(); $("#machine").innerText = env.machineName(); $("#domain").innerText = env.domainName(); $("#language").innerText = env.language(); $("#country").innerText = env.country(); $("#gfx-backend").innerText = Window.this.graphicsBackend; } ``` -------------------------------- ### Fetch local file using home:// scheme Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/URL-sciter-schemes.md Use the `home://` scheme to access local files relative to the Sciter engine or application executable. This example fetches a configuration file. ```javascript let res = await fetch("home://config.json"); ``` -------------------------------- ### Add Camera Read and Draw Example Executable Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt Adds an executable for reading from a camera and drawing its output. ```cmake add_sdl_example_executable(camera-read-and-draw SOURCES camera/01-read-and-draw/read-and-draw.c) ``` -------------------------------- ### Disable SDL documentation installation Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-cmake.md Set `-DSDL_DISABLE_INSTALL_DOCS=ON` to prevent the installation of SDL documentation. ```cmake -DSDL_DISABLE_INSTALL_DOCS=ON ``` -------------------------------- ### Create and Show a Reactor Window Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/samples.sciter/window/window-reactor.htm Demonstrates how to create a new window using HTML content and display it when a specific element is clicked. Requires the Window class to be available. ```javascript Test const windowDoc = Hello World ; document.on("click", "#show", function() { new Window({html:windowDoc}); }); Show Reactor Window ``` -------------------------------- ### Aggregate Install and Uninstall Targets Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/test/CMakeLists.txt Defines aggregate custom targets for installing all generated test APKs and uninstalling packages. These targets depend on individual install targets and use CMake scripts for execution. ```cmake if(TARGET SdlAndroid::adb) add_custom_target(install-sdl-test-apks DEPENDS ${install_targets} VERBATIM ) add_custom_target(uninstall-sdl-test-apks COMMAND "${CMAKE_COMMAND}" "-DADB=$" -DACTION=uninstall "-DPACKAGES=${packages}" -P "${SDL3_SOURCE_DIR}/cmake/android/SdlAndroidScript.cmake" VERBATIM ) endif() endif() endif() ``` -------------------------------- ### Native Function Call Example (beginDownload) Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos/integration/res/default.htm Calls a native function 'beginDownload' and logs its return value. Assumes 'nativeFunctionsB' provides this function. ```javascript let nativeApi = Window.this.assetInterface.nativeFunctionsB(); console.log( nativeApi.beginDownload() ); ``` -------------------------------- ### Masked Edit Examples Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-masked-edit.md Demonstrates practical examples of how to declare and configure masked-edit input fields. ```APIDOC ## Examples Declaration of IP4 address input field: ```xml ``` More precise declaration of IP4 address input field using aspect function for initialization, markup: ```xml ``` CSS: ```css input.ip4 { aspect:IP4 } ``` Script: ```js function IP4() { const ipmask = [ { type:"integer", width:3, min:0, max:255, "leading-zero":true }, ".", { type:"integer", width:3, min:0, max:255, "leading-zero":true }, ".", { type:"integer", width:3, min:0, max:255, "leading-zero":true }, ".", { type:"integer", width:3, min:0, max:255, "leading-zero":true } ]; this.masked.mask = ipmask; // initialization of fields and separators } ``` ``` -------------------------------- ### Input Element Example Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-edit.md An example of an inline single-line input element using the 'edit' behavior. ```html ``` -------------------------------- ### Configure New Xcode Project for SDL Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-macos.md Manually set up a new Xcode project for SDL by configuring include paths, framework search paths, and linker flags. Ensure 'main.m', 'MainMenu.xib', and 'AppDelegates.*' are removed if not needed. ```bash # Add "$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path # Add "$(HOME)/Library/Frameworks" to the frameworks search path # Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS" ``` -------------------------------- ### Add Streaming Textures Example Executable Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt Adds an executable for the streaming textures rendering example. ```cmake add_sdl_example_executable(renderer-streaming-textures SOURCES renderer/07-streaming-textures/streaming-textures.c) ``` -------------------------------- ### Add Load WAV Audio Example Executable Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt Adds an executable for loading and playing a WAV audio file. ```cmake add_sdl_example_executable(audio-load-wav SOURCES audio/03-load-wav/load-wav.c DATAFILES ${CMAKE_CURRENT_SOURCE_DIR}/../test/sample.wav) ``` -------------------------------- ### Initialize Markdown Editor and Load Content Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/samples/markdown/md2html.htm Sets up the Remarkable Markdown parser with plugins and loads initial content from a file. Handles potential file reading errors. ```javascript import * as sys from '@sys'; import * as sciter from '@sciter'; import * as env from '@env'; import { Remarkable } from 'remarkable/index.js'; import { HeaderIds } from 'remarkable/plugins/header-ids.js'; import RemarkableEmoji from 'remarkable/plugins/emoji/index.js'; const editor = document.$("plaintext#editor"); const output = document.$("section#html"); const md = new Remarkable(); md.block.ruler.enable(['footnote','deflist']); md.use( HeaderIds({ anchorText:" " }) ); md.use( RemarkableEmoji ); function render() { output.innerHTML = md.render(editor.value); } editor.on("input",function() { editor.timer(100, render); // throttling render call }); document.on("^click","section#html a[href]", function(evt, a) { evt.stopPropagation(); let href = a.getAttribute("href"); if( href.startsWith("#") ) { let target = output.$(href); console.log(href,target); if(target) target.scrollIntoView(true); } else { // external URL env.launch(href); } }); async function load() { try { let text = await sys.fs.readFile( URL.toPath( __DIR__ + "test.md") ); editor.value = sciter.decode(text,"utf-8"); render(); } catch(e) { console.error(e.message,e.stack); } } load(); ``` -------------------------------- ### Add Debug Text Rendering Example Executable Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt Adds an executable for the debug text rendering example. ```cmake add_sdl_example_executable(renderer-debug-text SOURCES renderer/18-debug-text/debug-text.c) ``` -------------------------------- ### Include SDL_main.h with Callbacks Defined Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-main-functions.md Include SDL_main.h in a single source file to enable the callback entry points. This should be done with the SDL_MAIN_USE_CALLBACKS define. ```c #define SDL_MAIN_USE_CALLBACKS #include ``` -------------------------------- ### Configure SDL Example Build Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/examples/CMakeLists.txt This CMake script sets up the build environment for SDL examples. It includes modules for checking include files and struct members, and configures the SDL library name component based on the `SDL_EXAMPLES_LINK_SHARED` variable. ```cmake list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake") include(CheckIncludeFile) include(CheckStructHasMember) include(CMakePushCheckState) include(sdlcompilers) if(SDL_EXAMPLES_LINK_SHARED) set(sdl_name_component SDL3-shared) else() set(sdl_name_component SDL3-static) endif() set(HAVE_EXAMPLES_LINK_SHARED "${SDL_EXAMPLES_LINK_SHARED}" PARENT_SCOPE) ``` -------------------------------- ### Set Range Start Before Node Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/DOM/Node/Range.md Use setStartBefore to position the start of the range immediately before the specified node. ```javascript range.setStartBefore(node) ``` -------------------------------- ### Disable SDL installation target Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/docs/README-cmake.md Use `-DSDL_DISABLE_INSTALL=ON` to prevent the creation of an SDL install target during the build process. ```cmake -DSDL_DISABLE_INSTALL=ON ``` -------------------------------- ### Render 'Hello World!' with Preact and JSX Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/samples/preact/hello-world-jsx.html This snippet shows how to set up Preact and render a simple 'Hello World!' component using JSX in Sciter.js. Ensure Preact is imported correctly. ```javascript import { h, Component, render } from "./preact.js"; JSX = h; // let's use PReact::h() as a driver of JSX expressions // Create your app const app =

Hello World!

; render(app, document.body); ``` -------------------------------- ### Password Input Properties: Selection Start Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-password.md Returns the start position of the selection, or the caret position if no selection exists. ```javascript selectionStart ``` -------------------------------- ### Get All Attribute Names Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/DOM/Element/README.md Use getAttributeNames() to get an array of strings representing all attribute names declared on the element. ```javascript element.getAttributeNames() ``` -------------------------------- ### XML Frameset Layout Example Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-frame-set.md Defines a typical help window layout using a frameset with columns. The first pane is a div for the index, followed by a splitter for resizing, and a frame for the content. ```XML Select topic from index ``` -------------------------------- ### Create and Manipulate Points Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/graphics/Point.md Demonstrates various ways to create Point instances, including using the constructor with coordinates, another Point, a Size, or a Rect. Also shows basic operator usage for addition and subtraction. ```javascript const position1 = Point(10,10); const position2 = Point.make(20,20); const position3 = Point(Rect(10,10,100,100)); // origin of the rect // operators const sum = Point(0,0) + Point(50,50); const sub = Point(0,0) - Point(50,50); // [-50,-50] ``` -------------------------------- ### Install HIDAPI to a Specific Prefix Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/demos.lite/lite-sdl/sdl/src/hidapi/BUILD.cmake.md Configure the CMake build to install HIDAPI into a custom directory by setting the CMAKE_INSTALL_PREFIX variable. ```bash cmake -DCMAKE_INSTALL_PREFIX=/usr ``` -------------------------------- ### Basic flow:row() Example Source: https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/samples.css/css-sciter-flex/grid-row-template.htm Demonstrates a simple row layout with distinct elements. ```text flow:row() with variants ------------------------ first name second name gender male female liberal ```