### Running the App Source: https://ultralig.ht/api/c/1_4_0/_app_core_2_c_a_p_i_8h_source Provides a complete `main` function example that initializes AppCore components and starts the application's run loop. ```c #include int main() { // Initialize app, window, overlay, etc. here... ulAppRun(app); ulDestroyApp(app); return 0; } ``` -------------------------------- ### Ultralight C API Documentation Source: https://ultralig.ht/api/c/1_4_0/_app_core_2_c_a_p_i_8h This section details the core functions of the Ultralight C API for initializing the application and creating windows. It includes function signatures, parameter descriptions, and usage examples. ```APIDOC ulCreateApp: ACExport ULApp ulCreateApp(ULSettings settings, ULConfig config) Create the App singleton. Parameters: settings: ULSettings structure for app configuration. config: ULConfig structure for app settings. Returns: ULApp: A handle to the App singleton. Example: // Create the App using default config and settings ULApp app = ulCreateApp(NULL, NULL); ulCreateWindow: ACExport ULWindow ulCreateWindow(ULMonitor monitor, unsigned int width, unsigned int height, bool fullscreen, unsigned int window_flags) Create a new Window. Parameters: monitor: The monitor to create the window on. width: The width of the window. height: The height of the window. fullscreen: Whether the window should be fullscreen. window_flags: Flags to control window behavior (e.g., titled, resizable). Returns: ULWindow: A handle to the newly created window. Example: ULWindow window = ulCreateWindow(ulAppGetMainMonitor(app), 1024, 768, false, kWindowFlags_Titled | kWindowFlags_Resizable); ulAppGetMainMonitor: ACExport ULMonitor ulAppGetMainMonitor(ULApp app) Get the main monitor (this is never NULL). Parameters: app: The App singleton handle. Returns: ULMonitor: A handle to the main monitor. kWindowFlags_Titled: @ kWindowFlags_Titled Flag to indicate a window should have a title bar. kWindowFlags_Resizable: @ kWindowFlags_Resizable Flag to indicate a window should be resizable. ``` -------------------------------- ### Creating an App Source: https://ultralig.ht/api/c/1_4_0/_app_core_2_c_a_p_i_8h_source Demonstrates how to initialize the AppCore library and create the main application singleton using default settings. ```c // Create the App using default config and settings ULApp app = ulCreateApp(NULL, NULL); ``` -------------------------------- ### Empty JSClassDefinition Example Source: https://ultralig.ht/api/c/1_4_0/_j_s_object_ref_8h_source An example of an empty JSClassDefinition structure. ```javascript const JSClassDefinition kJSClassDefinitionEmpty = { 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ``` -------------------------------- ### Start Remote Inspector Server Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___renderer_8h_source Starts a remote inspector server to allow debugging of the Ultralight renderer. Requires a renderer instance, an address, and a port. ```c bool ulStartRemoteInspectorServer(ULRenderer renderer, const char* address, unsigned short port); ``` -------------------------------- ### Start Remote Inspector Server Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___renderer_8h Starts a remote inspector server for the given renderer. This allows for remote inspection of Views loaded into the renderer by navigating to `inspector://
:`. It requires an active renderer instance, an address, and a port. ```APIDOC ulStartRemoteInspectorServer(ULRenderer* renderer, const char* address, unsigned short port) - Starts the remote inspector server. - Parameters: - renderer: The active renderer instance. - address: The address for the server to listen on (e.g., "127.0.0.1"). - port: The port for the server to listen on (e.g., 9222). - Returns: - Returns whether the server started successfully or not. ``` -------------------------------- ### AppCore C API Reference Source: https://ultralig.ht/api/c/1_4_0/_app_core_2_c_a_p_i_8h_source This section details the core C API functions for AppCore, including initialization, window and overlay management, and the application run loop. ```APIDOC AppCore C API Overview: This API provides functions to manage a windowing system for desktop applications using the Ultralight renderer. Core Types: - ULSettings: Represents application settings. - ULApp: Represents the main application singleton. - ULWindow: Represents a window in the application. - ULMonitor: Represents a display monitor. - ULOverlay: Represents an overlay within a window for displaying web content. Window Creation Flags: - kWindowFlags_Borderless: Creates a window without a border. - kWindowFlags_Titled: Creates a window with a title bar. - kWindowFlags_Resizable: Allows the window to be resized by the user. - kWindowFlags_Maximizable: Allows the window to be maximized. Key Functions: - ulCreateApp(ULSettings settings, void* userData): Initializes the AppCore library and creates the App singleton. - ulCreateWindow(ULMonitor monitor, int width, int height, bool fullscreen, uint32_t flags): Creates a new window. - ulCreateOverlay(ULWindow window, int width, int height, int x, int y): Creates an overlay within a window. - ulOverlayGetView(ULOverlay overlay): Retrieves the View associated with an overlay. - ulViewLoadURL(ULView view, ULString url): Loads a URL into the View. - ulAppRun(ULApp app): Starts the main application run loop. - ulDestroyApp(ULApp app): Destroys the App singleton and cleans up resources. ``` -------------------------------- ### Create Ultralight Renderer Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___renderer_8h Demonstrates the process of creating an Ultralight renderer instance. This involves setting up configuration, enabling platform handlers for font loading and file system access, and finally creating the renderer. It also shows the cleanup of resources like configuration objects. ```c // Setup our config. ULConfig config = ulCreateConfig(); // Use AppCore's font loader. ulEnablePlatformFontLoader(); // Use AppCore's file system to load file:/// URLs from the OS. ULString base_dir = ulCreateString("./assets/"); ulEnablePlatformFileSystem(base_dir); ulDestroyString(base_dir); // Create the renderer. ULRenderer renderer = ulCreateRenderer(config); // Destroy the config. ulDestroyConfig(config); // Set up Views here... ``` -------------------------------- ### Get JavaScript String Length Source: https://ultralig.ht/api/c/1_4_0/_j_s_string_ref_8h_source Retrieves the number of characters in a JavaScript string. ```C size_t JSStringGetLength(JSStringRef string); ``` -------------------------------- ### Get Library Version Patch Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___defines_8h_source Retrieves the numeric patch version of the Ultralight library. ```c unsigned int ulVersionPatch() { // Implementation details... return 0; } ``` -------------------------------- ### Creating an Overlay Source: https://ultralig.ht/api/c/1_4_0/_app_core_2_c_a_p_i_8h_source Illustrates the creation of an overlay within a window, which is used to display web content. ```c ULOverlay overlay = ulCreateOverlay(window, 1024, 768, 0, 0); ``` -------------------------------- ### Get ULString Length Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___string_8h_source Returns the length of the ULString in bytes. This length does not include the null terminator character. ```c ULExport size_t ulStringGetLength(ULString str); ``` -------------------------------- ### Create and Load Overlay Source: https://ultralig.ht/api/c/1_4_0/_app_core_2_c_a_p_i_8h Demonstrates how to create an overlay within a window, retrieve its associated view, and load a URL into that view. It also shows the proper destruction of string resources. ```c #include // Assuming 'window' is a valid ULWindow instance ULOverlay overlay = ulCreateOverlay(window, 1024, 768, 0, 0); ULString url = ulCreateString("https://google.com"); ULView view = ulOverlayGetView(overlay); ulViewLoadURL(view, url); ulDestroyString(url); ``` -------------------------------- ### Get JavaScript String Characters Pointer Source: https://ultralig.ht/api/c/1_4_0/_j_s_string_ref_8h_source Obtains a pointer to the internal Unicode character buffer of a JavaScript string. ```C const JSChar* JSStringGetCharactersPtr(JSStringRef string); ``` -------------------------------- ### Creating a Window Source: https://ultralig.ht/api/c/1_4_0/_app_core_2_c_a_p_i_8h_source Shows how to create a new window with specified dimensions and flags, attached to the main monitor. ```c ULWindow window = ulCreateWindow(ulAppGetMainMonitor(app), 1024, 768, false, kWindowFlags_Titled | kWindowFlags_Resizable); ``` -------------------------------- ### Ultralight View API - Get Render Target Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___view_8h Retrieves the ULRenderTarget associated with a ULView. This is applicable only for GPU-accelerated views. ```APIDOC ulViewGetRenderTarget(ULView* view) - Returns the RenderTarget for the View. - Parameters: - view: A pointer to the ULView object. - Returns: A pointer to the ULRenderTarget object. Returns NULL if the view is not GPU accelerated. ``` -------------------------------- ### Ultralight C API - Main Entry Point Source: https://ultralig.ht/api/c/1_4_0/dir_9ba26be01cd8d28d21a7e6ade2e908eb This header file serves as the main entry point for the Ultralight C API, providing access to core functionalities. ```c #include "CAPI.h" ``` -------------------------------- ### View Rendering and Target Functions Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___view_8h_source Provides functions to get the render target for a view and check if navigation forward is possible. ```c ULExport ULRenderTarget ulViewGetRenderTarget(ULView view) // Get the RenderTarget for the View. bool ulViewCanGoForward(ULView view) // Check if can navigate forwards in history. ``` -------------------------------- ### Ultralight C API - Platform Integration Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___config_8h APIs for interacting with the underlying platform, including logging, GPU drivers, font loading, file system access, clipboard, and surface management. ```c #include #include #include #include #include #include #include ``` -------------------------------- ### Create and Configure Ultralight View Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___view_8h_source Demonstrates how to create a View configuration, set its properties like display ID, acceleration, transparency, and initial device scale, and then create a View with these settings. It also shows how to clean up the configuration. ```c #include // Create a ULViewConfig with default values ULViewConfig view_config = ulCreateViewConfig(); // Set View configuration properties ulViewConfigSetDisplayId(view_config, 0); // Set display ID to 0 ulViewConfigSetIsAccelerated(view_config, true); // Enable GPU acceleration ulViewConfigSetIsTransparent(view_config, false); // Disable transparency // ulViewConfigSetInitialDeviceScale(view_config, 2.0); // Example: Set initial device scale to 2.0 // Create a View, 500 by 500 pixels in size, using the default Session // ULView view = ulCreateView(renderer, 500, 500, view_config, NULL); // Clean up the ULViewConfig ulDestroyViewConfig(view_config); ``` -------------------------------- ### JavaScript Context Inspectability Source: https://ultralig.ht/api/c/1_4_0/_j_s_context_ref_8h_source Functions to set and get the inspectability of a global JavaScript context, allowing it to be debugged in Web Inspector. ```APIDOC void JSGlobalContextSetInspectable(JSGlobalContextRef ctx, bool inspectable) Sets whether the context is inspectable in Web Inspector. Default value is NO. Availability: macos(JSC_MAC_TBA), ios(JSC_IOS_TBA) bool JSGlobalContextIsInspectable(JSGlobalContextRef ctx) Gets whether the context is inspectable in Web Inspector. Availability: macos(JSC_MAC_TBA) ``` -------------------------------- ### ULFontLoader Methods Source: https://ultralig.ht/api/c/1_4_0/struct_u_l_font_loader-members Provides documentation for the ULFontLoader struct's methods, including getting fallback fonts and loading fonts. ```APIDOC ULFontLoader: get_fallback_font_for_characters(font_loader: ULFontLoader, characters: str) -> ULFont font_loader: The font loader instance. characters: A string of characters to find a fallback font for. Returns: The ULFont that supports the given characters, or null if none is found. load(font_loader: ULFontLoader, font_config: ULFontConfig) -> ULFont font_loader: The font loader instance. font_config: The configuration for the font to load. Returns: The loaded ULFont, or null if the font could not be loaded. ``` -------------------------------- ### Ultralight C API Documentation Overview Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___clipboard_8h_source This section provides a high-level overview of the Ultralight C API, version 1.4.0. It lists the main documentation entry points and categorizes the API into logical modules such as Library Management, View Management, Rendering Output, JavaScriptCore API, AppCore API, and Utility Classes. Links to specific header files are provided for detailed information. ```APIDOC Ultralight C API v1.4.0 Documentation: Main Entry Point: - Main Page: https://ultralig.ht/api/c/1_4_0/index.html Modules: - Library Management: - CAPI_Renderer.h - CAPI_Config.h - CAPI_Platform.h - CAPI_Logger.h - CAPI_GPUDriver.h - CAPI_FontLoader.h - CAPI_FileSystem.h - CAPI_Clipboard.h - CAPI_Surface.h - View Management: - CAPI_View.h - CAPI_Session.h - Input Events: - CAPI_MouseEvent.h - CAPI_KeyEvent.h - CAPI_ScrollEvent.h - CAPI_GamepadEvent.h - Rendering Output: - CPU Renderer: - CAPI_Surface.h - CAPI_Bitmap.h - GPU Renderer: - CAPI_GPUDriver.h - JavaScriptCore API: - JSBase.h - JSContextRef.h - JSStringRef.h - JSValueRef.h - JSObjectRef.h - JSObjectRefPrivate.h - JSTypedArray.h - JSRetainPtr.h - AppCore API: - AppCore/CAPI.h - Utility Classes: - CAPI_String.h - CAPI_Bitmap.h - CAPI_Buffer.h - CAPI_ImageSource.h - CAPI_FontFile.h - CAPI_Geometry.h - CAPI_Defines.h External Links: - Site Home: https://ultralig.ht - Docs: https://docs.ultralig.ht - C++ API: https://ultralig.ht/api/cpp/1_4_0/ ``` -------------------------------- ### Ultralight C API - Platform Source: https://ultralig.ht/api/c/1_4_0/struct_u_l_render_target Documentation for platform-specific functionalities, including GPU drivers, font loading, file system, clipboard, and surfaces. ```APIDOC CAPI_Platform.h - Provides platform-specific abstractions. CAPI_Logger.h - Handles logging functionalities. CAPI_GPUDriver.h - Interface for GPU driver interactions. CAPI_FontLoader.h - Manages font loading. CAPI_FileSystem.h - Provides file system access. CAPI_Clipboard.h - Handles clipboard operations. CAPI_Surface.h - Defines surface structures for rendering. ``` -------------------------------- ### Ultralight View API - Get Width Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___view_8h Retrieves the width of a ULView in pixels. This function is part of the Ultralight View API. ```APIDOC ulViewGetWidth(ULView* view) - Returns the width of the view in pixels. - Parameters: - view: A pointer to the ULView object. - Returns: An unsigned integer representing the width in pixels. ``` -------------------------------- ### Ultralight C API - Platform API Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___platform_8h This section details the Platform API, which handles fundamental system interactions and device management. It includes functionalities for general platform operations, logging, GPU driver interaction, font loading, file system access, clipboard operations, and surface management. ```APIDOC CAPI_Platform.h: Core platform functions for interacting with the operating system and Ultralight. CAPI_Logger.h: Defines functions for logging messages and events within the application. CAPI_GPUDriver.h: Provides an interface for interacting with the GPU driver for rendering. CAPI_FontLoader.h: Includes functions for loading and managing font files. CAPI_FileSystem.h: Defines operations for accessing and manipulating the file system. CAPI_Clipboard.h: Contains functions for interacting with the system clipboard. CAPI_Surface.h: Defines structures and functions for managing rendering surfaces. ``` -------------------------------- ### Ultralight View API - Get Height Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___view_8h Retrieves the height of a ULView in pixels. This function is part of the Ultralight View API. ```APIDOC ulViewGetHeight(ULView* view) - Returns the height of the view in pixels. - Parameters: - view: A pointer to the ULView object. - Returns: An unsigned integer representing the height in pixels. ``` -------------------------------- ### File System Configuration Source: https://ultralig.ht/api/c/1_4_0/_app_core_2_c_a_p_i_8h Functions for enabling and configuring the platform file system, which is necessary for loading `file:///` URLs. ```APIDOC ulEnablePlatformFileSystem(ULString _base_dir_): void Description: Initializes the platform file system and sets it as the current FileSystem. This is required for loading `file:///` URLs. Parameters: _base_dir_: The base directory path to resolve relative paths against. Notes: This function is only needed if `ulCreateApp()` is not called. ``` -------------------------------- ### Get ULString Data Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___string_8h Retrieves a pointer to the native UTF-8 encoded character buffer of a ULString. The returned buffer is always null-terminated. ```c ULExport char* ulStringGetData(ULString* str); ``` -------------------------------- ### Ultralight AppCore Settings API Source: https://ultralig.ht/api/c/1_4_0/_app_core_2_c_a_p_i_8h_source Provides functions for managing application settings, including initialization, destruction, and configuration of developer name, app name, file system path, and shader loading. ```APIDOC ULSettings ulCreateSettings() - Creates settings with default values. - Returns: A ULSettings object. void ulDestroySettings(ULSettings settings) - Destroys the provided settings object. - Parameters: - settings: The ULSettings object to destroy. void ulSettingsSetDeveloperName(ULSettings settings, ULString name) - Sets the developer name for the application. - This is used to generate a unique path for local application data. - Default: "MyCompany" - Parameters: - settings: The ULSettings object. - name: The developer name. void ulSettingsSetAppName(ULSettings settings, ULString name) - Sets the application name. - This is used to generate a unique path for local application data. - Default: "MyApp" - Parameters: - settings: The ULSettings object. - name: The application name. void ulSettingsSetFileSystemPath(ULSettings settings, ULString path) - Sets the root file path for the file system. - Used to resolve all file URLs (e.g., file:///page.html). - Default path: "./assets/" - Path resolution logic: - Windows: relative to the executable path - Linux: relative to the executable path - macOS: relative to YourApp.app/Contents/Resources/ - Parameters: - settings: The ULSettings object. - path: The file system path. void ulSettingsSetLoadShadersFromFileSystem(ULSettings settings, bool enabled) - Enables or disables loading shaders from the file system. - If false (default), pre-compiled shaders from memory are used for faster startup. - Parameters: - settings: The ULSettings object. - enabled: Boolean indicating whether to load shaders from the file system. ``` -------------------------------- ### Get ULString Length Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___string_8h Returns the length of the UTF-8 encoded data within a ULString in bytes. This length does not include the null terminator. ```c ULExport size_t ulStringGetLength(ULString* str); ``` -------------------------------- ### Accessing Pixel Data Example Source: https://ultralig.ht/api/c/1_4_0/_c_a_p_i___bitmap_8h_source Demonstrates how to lock, access, and unlock pixel data for a bitmap. This is crucial for directly manipulating the pixel buffer. ```c void* pixels = ulBitmapLockPixels(bitmap); if (pixels) { // Zero out the pixel buffer memset(pixels, 0, ulBitmapGetSize(bitmap)); } // Unlock the pixels when you're done. ulBitmapUnlockPixels(bitmap); ``` -------------------------------- ### Ultralight C API - Platform API Source: https://ultralig.ht/api/c/1_4_0/dir_303917a3fddf2f785fad25ea9b974e71 Documentation for the Platform API, which provides interfaces for interacting with the underlying operating system and hardware. This includes functionalities for platform-specific operations, GPU drivers, font loading, file system access, clipboard operations, and surface management. ```APIDOC Platform API Headers: - CAPI_Platform.h: Core platform interface. - CAPI_Logger.h: For logging functionalities. - CAPI_GPUDriver.h: Interface for GPU driver interactions. - CAPI_FontLoader.h: For loading font files. - CAPI_FileSystem.h: For file system operations. - CAPI_Clipboard.h: For clipboard access. - CAPI_Surface.h: For surface management. ``` -------------------------------- ### Ultralight C API - Platform API Reference Source: https://ultralig.ht/api/c/1_4_0/_j_s_value_ref_8h This section outlines the Platform API for the Ultralight C API, covering essential system interactions. It includes functionalities for GPU drivers, font loading, file system access, clipboard operations, and surface management. ```APIDOC CAPI_GPUDriver.h - Interface for interacting with the GPU driver for rendering. CAPI_FontLoader.h - Functions for loading and managing fonts. CAPI_FileSystem.h - APIs for accessing and manipulating the file system. CAPI_Clipboard.h - Functions for interacting with the system clipboard. CAPI_Surface.h - Definitions for managing rendering surfaces. ``` -------------------------------- ### Get Maximum UTF8 String Size Source: https://ultralig.ht/api/c/1_4_0/_j_s_string_ref_8h_source Calculates the maximum number of bytes required to represent a JavaScript string as a null-terminated UTF8 string. ```C size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string); ```