This file is automatically generated by command : "nim scripts/generate_bindings.nims" Do not edit this file directly.
Nim wrapper for WebUI
| author: | neroist |
|---|---|
| WebUI Version: | 2.5.0-Beta |
See Nim Docs: https://yesdrx.github.io/nim-webui/
Nim bindings for WebUIDynamic Library ExportsTypes
Event {.bycopy.} = object window*: csize_t ## The window object number event_type*: csize_t ## Event type element*: cstring ## HTML element ID event_number*: csize_t ## Internal WebUI bind_id*: csize_t ## Bind ID client_id*: csize_t ## Client's unique ID connection_id*: csize_t ## Client's connection ID cookies*: cstring ## Client's full cookies
- -- Structs ------------------------- Source Edit
WebuiBrowser = helper do: type WebuiBrowserHelper = enum wbNoBrowser = 0, wbAnyBrowser = 1, wbChrome, wbFirefox, wbEdge, wbSafari, wbChromium, wbOpera, wbBrave, wbVivaldi, wbEpic, wbYandex, wbChromiumBased, wbWebview let NoBrowser = WebuiBrowserHelper.wbNoBrowser let AnyBrowser = WebuiBrowserHelper.wbAnyBrowser let Chrome = WebuiBrowserHelper.wbChrome let Firefox = WebuiBrowserHelper.wbFirefox let Edge = WebuiBrowserHelper.wbEdge let Safari = WebuiBrowserHelper.wbSafari let Chromium = WebuiBrowserHelper.wbChromium let Opera = WebuiBrowserHelper.wbOpera let Brave = WebuiBrowserHelper.wbBrave let Vivaldi = WebuiBrowserHelper.wbVivaldi let Epic = WebuiBrowserHelper.wbEpic let Yandex = WebuiBrowserHelper.wbYandex let ChromiumBased = WebuiBrowserHelper.wbChromiumBased let Webview = WebuiBrowserHelper.wbWebview WebuiBrowserHelper
- Source Edit
WebuiConfig = helper do: type WebuiConfigHelper = enum wcWaitConnection = 0, wcEventBlocking, wcMonitor, wcClient, wcCookies, wcResponse let ShowWaitConnection = WebuiConfigHelper.wcWaitConnection let UiEventBlocking = WebuiConfigHelper.wcEventBlocking let FolderMonitor = WebuiConfigHelper.wcMonitor let MultiClient = WebuiConfigHelper.wcClient let UseCookies = WebuiConfigHelper.wcCookies let AsynchronousResponse = WebuiConfigHelper.wcResponse WebuiConfigHelper
- Source Edit
WebuiEvent = helper do: type WebuiEventHelper = enum weDisconnected = 0, weConnected, weMouseClick, weNavigation, weCallback let EventsDisconnected = WebuiEventHelper.weDisconnected let EventsConnected = WebuiEventHelper.weConnected let EventsMouseClick = WebuiEventHelper.weMouseClick let EventsNavigation = WebuiEventHelper.weNavigation let EventsCallback = WebuiEventHelper.weCallback WebuiEventHelper
- Source Edit
WebuiLoggerLevel = helper do: type WebuiLoggerLevelHelper = enum wllLevelDebug = 0, wllLevelInfo, wllLevelError let LoggerLevelDebug = WebuiLoggerLevelHelper.wllLevelDebug let LoggerLevelInfo = WebuiLoggerLevelHelper.wllLevelInfo let LoggerLevelError = WebuiLoggerLevelHelper.wllLevelError WebuiLoggerLevelHelper
- Source Edit
WebuiRuntime = helper do: type WebuiRuntimeHelper = enum wrNone = 0, wrDeno, wrNodeJS, wrBun let None = WebuiRuntimeHelper.wrNone let Deno = WebuiRuntimeHelper.wrDeno let NodeJS = WebuiRuntimeHelper.wrNodeJS let Bun = WebuiRuntimeHelper.wrBun WebuiRuntimeHelper
- Source Edit
Consts
useWebuiDll = false
- Source Edit
useWebuiStaticLib = false
- Source Edit
WEBUI_MAX_ARG = 16
- Max allowed argument's index Source Edit
WEBUI_MAX_IDS = 256
- Max windows, servers and threads Source Edit
WEBUI_VERSION = "2.5.0-beta.4"
- WebUI Library https://webui.me https://github.com/webui-dev/webui Copyright (c) 2020-2025 Hassan Draga. Licensed under MIT License. All rights reserved. Canada. Source Edit
Procs
proc `bind`(window: csize_t; element: cstring; func: proc (e: ptr Event) {.cdecl.}): csize_t {.cdecl, importc: "webui_bind", ...raises: [], tags: [], forbids: [].}
-
@brief Bind an HTML element and a JavaScript object with a backend function. Empty element name means all events.
@param window The window number @param element The HTML element / JavaScript object @param func The callback function
@return Returns a unique bind ID.
@example webui_bind(myWindow, "myFunction", myFunction);
Source Edit proc browser_exist(browser: csize_t): bool {.cdecl, importc: "webui_browser_exist", ...raises: [], tags: [], forbids: [].}
-
@brief Check if a web browser is installed.
@return Returns True if the specified browser is available
@example bool status = webui_browser_exist(Chrome);
Source Edit proc close_client(e: ptr Event) {.cdecl, importc: "webui_close_client", ...raises: [], tags: [], forbids: [].}
-
@brief Close a specific client.
@param e The event struct
@example webui_close_client(e);
Source Edit proc decode(str: cstring): cstring {.cdecl, importc: "webui_decode", ...raises: [], tags: [], forbids: [].}
-
@brief Decode a Base64 encoded text. The returned buffer need to be freed.
@param str The string to decode (Should be null terminated)
@return Returns the base64 decoded string
@example char* str = webui_decode("SGVsbG8=");
Source Edit proc delete_all_profiles() {.cdecl, importc: "webui_delete_all_profiles", ...raises: [], tags: [], forbids: [].}
-
@brief Delete all local web-browser profiles folder. It should be called at the end.
@example webui_wait(); webui_delete_all_profiles(); webui_clean();
Source Edit proc delete_profile(window: csize_t) {.cdecl, importc: "webui_delete_profile", ...raises: [], tags: [], forbids: [].}
-
@brief Delete a specific window web-browser local folder profile.
@param window The window number
@example webui_wait(); webui_delete_profile(myWindow); webui_clean();
@note This can break functionality of other windows if using the same web-browser.
Source Edit proc encode(str: cstring): cstring {.cdecl, importc: "webui_encode", ...raises: [], tags: [], forbids: [].}
-
@brief Encode text to Base64. The returned buffer need to be freed.
@param str The string to encode (Should be null terminated)
@return Returns the base64 encoded string
@example char* base64 = webui_encode("Foo Bar");
Source Edit proc get_best_browser(window: csize_t): csize_t {.cdecl, importc: "webui_get_best_browser", ...raises: [], tags: [], forbids: [].}
-
@brief Get the recommended web browser ID to use. If you are already using one, this function will return the same ID.
@param window The window number
@return Returns a web browser ID.
@example size_t browserID = webui_get_best_browser(myWindow);
Source Edit proc get_bool_at(e: ptr Event; index: csize_t): bool {.cdecl, importc: "webui_get_bool_at", ...raises: [], tags: [], forbids: [].}
-
@brief Get an argument as boolean at a specific index.
@param e The event struct @param index The argument position starting from 0
@return Returns argument as boolean
@example bool myBool = webui_get_bool_at(e, 0);
Source Edit proc get_child_process_id(window: csize_t): csize_t {.cdecl, importc: "webui_get_child_process_id", ...raises: [], tags: [], forbids: [].}
-
@brief Get the child process ID created by the parent, which refers to the web browser window.
Note: In WebView mode, this will return the parent process ID because the backend and the WebView window run in the same process.
@param window The window number
@return Returns the the child process id as integer
@example size_t id = webui_get_child_process_id(myWindow);
Source Edit proc get_context(e: ptr Event): pointer {.cdecl, importc: "webui_get_context", ...raises: [], tags: [], forbids: [].}
-
@brief Get user data that is set using webui_set_context().
@param e The event struct
@return Returns user data pointer.
@example webui_bind(myWindow, "myFunction", myFunction);
webui_set_context(myWindow, "myFunction", myData);
void myFunction(webui_event_t* e) { void* myData = webui_get_context(e); }
Source Edit proc get_float_at(e: ptr Event; index: csize_t): cdouble {.cdecl, importc: "webui_get_float_at", ...raises: [], tags: [], forbids: [].}
-
@brief Get an argument as float at a specific index.
@param e The event struct @param index The argument position starting from 0
@return Returns argument as float
@example double myNum = webui_get_float_at(e, 0);
Source Edit proc get_free_port(): csize_t {.cdecl, importc: "webui_get_free_port", ...raises: [], tags: [], forbids: [].}
-
@brief Get an available usable free network port.
@return Returns a free port
@example size_t port = webui_get_free_port();
Source Edit proc get_hwnd(window: csize_t): pointer {.cdecl, importc: "webui_get_hwnd", ...raises: [], tags: [], forbids: [].}
-
@brief Get window HWND. More reliable with WebView than web browser window, as browser PIDs may change on launch.
@param window The window number
@return Returns the window hwnd in Win32, GtkWindow in Linux.
@example HWND hwnd = webui_get_hwnd(myWindow); // Win32 (Work with WebView and web browser) GtkWindow* window = webui_get_hwnd(myWindow); // Linux (Work with WebView only)
Source Edit proc get_int_at(e: ptr Event; index: csize_t): clonglong {.cdecl, importc: "webui_get_int_at", ...raises: [], tags: [], forbids: [].}
-
@brief Get an argument as integer at a specific index.
@param e The event struct @param index The argument position starting from 0
@return Returns argument as integer
@example long long int myNum = webui_get_int_at(e, 0);
Source Edit proc get_last_error_message(): cstring {.cdecl, importc: "webui_get_last_error_message", ...raises: [], tags: [], forbids: [].}
-
@brief Get the last WebUI error message.
@example const char* error_msg = webui_get_last_error_message();
Source Edit proc get_last_error_number(): csize_t {.cdecl, importc: "webui_get_last_error_number", ...raises: [], tags: [], forbids: [].}
-
@brief Get the last WebUI error code.
@example int error_num = webui_get_last_error_number();
Source Edit proc get_mime_type(file: cstring): cstring {.cdecl, importc: "webui_get_mime_type", ...raises: [], tags: [], forbids: [].}
-
@brief Get the HTTP mime type of a file.
@return Returns the HTTP mime string
@example const char* mime = webui_get_mime_type("foo.png");
Source Edit proc get_new_window_id(): csize_t {.cdecl, importc: "webui_get_new_window_id", ...raises: [], tags: [], forbids: [].}
-
@brief Get a free window number that can be used with webui_new_window_id().
@return Returns the first available free window number. Starting from 1.
@example size_t myWindowNumber = webui_get_new_window_id();
Source Edit proc get_parent_process_id(window: csize_t): csize_t {.cdecl, importc: "webui_get_parent_process_id", ...raises: [], tags: [], forbids: [].}
-
@brief Get the parent process ID, which refers to the current backend application process.
@param window The window number
@return Returns the the parent process id as integer
@example size_t id = webui_get_parent_process_id(myWindow);
Source Edit proc get_port(window: csize_t): csize_t {.cdecl, importc: "webui_get_port", ...raises: [], tags: [], forbids: [].}
-
@brief Get the network port of a running window. This can be useful to determine the HTTP link of webui.js
@param window The window number
@return Returns the network port of the window
@example size_t port = webui_get_port(myWindow);
Source Edit proc get_size_at(e: ptr Event; index: csize_t): csize_t {.cdecl, importc: "webui_get_size_at", ...raises: [], tags: [], forbids: [].}
-
@brief Get the size in bytes of an argument at a specific index.
@param e The event struct @param index The argument position starting from 0
@return Returns size in bytes
@example size_t argLen = webui_get_size_at(e, 0);
Source Edit proc get_string(e: ptr Event): cstring {.cdecl, importc: "webui_get_string", ...raises: [], tags: [], forbids: [].}
-
@brief Get the first argument as string.
@param e The event struct
@return Returns argument as string
@example const char* myStr = webui_get_string(e);
Source Edit proc get_string_at(e: ptr Event; index: csize_t): cstring {.cdecl, importc: "webui_get_string_at", ...raises: [], tags: [], forbids: [].}
-
@brief Get an argument as string at a specific index.
@param e The event struct @param index The argument position starting from 0
@return Returns argument as string
@example const char* myStr = webui_get_string_at(e, 0);
Source Edit proc interface_bind(window: csize_t; element: cstring; func: proc (a1: csize_t; a2: csize_t; a3: cstring; a4: csize_t; a5: csize_t) {.cdecl.}): csize_t {. cdecl, importc: "webui_interface_bind", ...raises: [], tags: [], forbids: [].}
-
-- Wrapper's Interface -------------
@brief Bind a specific HTML element click event with a function. Empty element means all events.
@param window The window number @param element The element ID @param func The callback as myFunc(Window, EventType, Element, EventNumber, BindID)
@return Returns unique bind ID
@example size_t id = webui_interface_bind(myWindow, "myID", myCallback);
Source Edit proc interface_close_client(window: csize_t; event_number: csize_t) {.cdecl, importc: "webui_interface_close_client", ...raises: [], tags: [], forbids: [].}
-
@brief Close a specific client.
@param window The window number @param event_number The event number
@example webui_close_client(e);
Source Edit proc interface_get_bool_at(window: csize_t; event_number: csize_t; index: csize_t): bool {.cdecl, importc: "webui_interface_get_bool_at", ...raises: [], tags: [], forbids: [].}
-
@brief Get an argument as boolean at a specific index.
@param window The window number @param event_number The event number @param index The argument position
@return Returns argument as boolean
@example bool myBool = webui_interface_get_bool_at(myWindow, e->event_number, 0);
Source Edit proc interface_get_float_at(window: csize_t; event_number: csize_t; index: csize_t): cdouble {.cdecl, importc: "webui_interface_get_float_at", ...raises: [], tags: [], forbids: [].}
-
@brief Get an argument as float at a specific index.
@param window The window number @param event_number The event number @param index The argument position
@return Returns argument as float
@example double myFloat = webui_interface_get_int_at(myWindow, e->event_number, 0);
Source Edit proc interface_get_int_at(window: csize_t; event_number: csize_t; index: csize_t): clonglong {. cdecl, importc: "webui_interface_get_int_at", ...raises: [], tags: [], forbids: [].}
-
@brief Get an argument as integer at a specific index.
@param window The window number @param event_number The event number @param index The argument position
@return Returns argument as integer
@example long long int myNum = webui_interface_get_int_at(myWindow, e->event_number, 0);
Source Edit proc interface_get_size_at(window: csize_t; event_number: csize_t; index: csize_t): csize_t {.cdecl, importc: "webui_interface_get_size_at", ...raises: [], tags: [], forbids: [].}
-
@brief Get the size in bytes of an argument at a specific index.
@param window The window number @param event_number The event number @param index The argument position
@return Returns size in bytes
@example size_t argLen = webui_interface_get_size_at(myWindow, e->event_number, 0);
Source Edit proc interface_get_string_at(window: csize_t; event_number: csize_t; index: csize_t): cstring {.cdecl, importc: "webui_interface_get_string_at", ...raises: [], tags: [], forbids: [].}
-
@brief Get an argument as string at a specific index.
@param window The window number @param event_number The event number @param index The argument position
@return Returns argument as string
@example const char* myStr = webui_interface_get_string_at(myWindow, e->event_number, 0);
Source Edit proc interface_get_window_id(window: csize_t): csize_t {.cdecl, importc: "webui_interface_get_window_id", ...raises: [], tags: [], forbids: [].}
-
@brief Get a unique window ID.
@param window The window number
@return Returns the unique window ID as integer
@example size_t id = webui_interface_get_window_id(myWindow);
Source Edit proc interface_is_app_running(): bool {.cdecl, importc: "webui_interface_is_app_running", ...raises: [], tags: [], forbids: [].}
-
@brief Check if the app still running.
@return Returns True if app is running
@example bool status = webui_interface_is_app_running();
Source Edit proc interface_run_client(window: csize_t; event_number: csize_t; script: cstring) {.cdecl, importc: "webui_interface_run_client", ...raises: [], tags: [], forbids: [].}
-
@brief Run JavaScript without waiting for the response. Single client.
@param window The window number @param event_number The event number @param script The JavaScript to be run
@example webui_run_client(e, "alert('Hello');");
Source Edit proc interface_script_client(window: csize_t; event_number: csize_t; script: cstring; timeout: csize_t; buffer: cstring; buffer_length: csize_t): bool {.cdecl, importc: "webui_interface_script_client", ...raises: [], tags: [], forbids: [].}
-
@brief Run JavaScript and get the response back. Single client. Make sure your local buffer can hold the response.
@param window The window number @param event_number The event number @param script The JavaScript to be run @param timeout The execution timeout in seconds @param buffer The local buffer to hold the response @param buffer_length The local buffer size
@return Returns True if there is no execution error
@example bool err = webui_script_client(e, "return 4 + 6;", 0, myBuffer, myBufferSize);
Source Edit proc interface_send_raw_client(window: csize_t; event_number: csize_t; function: cstring; raw: pointer; size: csize_t) {. cdecl, importc: "webui_interface_send_raw_client", ...raises: [], tags: [], forbids: [].}
-
@brief Safely send raw data to the UI. Single client.
@param window The window number @param event_number The event number @param function The JavaScript function to receive raw data: function myFunc(myData){} @param raw The raw data buffer @param size The raw data size in bytes
@example webui_send_raw_client(e, "myJavaScriptFunc", myBuffer, 64);
Source Edit proc interface_set_response(window: csize_t; event_number: csize_t; response: cstring) {.cdecl, importc: "webui_interface_set_response", ...raises: [], tags: [], forbids: [].}
-
@brief When using webui_interface_bind(), you may need this function to easily set a response.
@param window The window number @param event_number The event number @param response The response as string to be send to JavaScript
@example webui_interface_set_response(myWindow, e->event_number, "Response...");
Source Edit proc interface_set_response_file_handler(window: csize_t; response: pointer; length: cint) {.cdecl, importc: "webui_interface_set_response_file_handler", ...raises: [], tags: [], forbids: [].}
-
@brief Use this API to set a file handler response if your backend need async response for webui_set_file_handler().
@param window The window number @param response The response buffer @param length The response size
@example webui_interface_set_response_file_handler(myWindow, buffer, 1024);
Source Edit proc interface_show_client(window: csize_t; event_number: csize_t; content: cstring): bool {.cdecl, importc: "webui_interface_show_client", ...raises: [], tags: [], forbids: [].}
-
@brief Show a window using embedded HTML, or a file. If the window is already open, it will be refreshed. Single client.
@param window The window number @param event_number The event number @param content The HTML, URL, Or a local file
@return Returns True if showing the window is successed.
@example webui_show_client(e, "<html>...</html>"); | webui_show_client(e, "index.html"); | webui_show_client(e, "http://...");
Source Edit proc is_high_contrast(): bool {.cdecl, importc: "webui_is_high_contrast", ...raises: [], tags: [], forbids: [].}
-
@brief Get OS high contrast preference.
@return Returns True if OS is using high contrast theme
@example bool hc = webui_is_high_contrast();
Source Edit proc malloc(size: csize_t): pointer {.cdecl, importc: "webui_malloc", ...raises: [], tags: [], forbids: [].}
-
@brief Safely allocate memory using the WebUI memory management system. It can be safely freed using webui_free() at any time.
@param size The size of memory in bytes
@example char* myBuffer = (char*)webui_malloc(1024);
Source Edit proc memcpy(dest: pointer; src: pointer; count: csize_t) {.cdecl, importc: "webui_memcpy", ...raises: [], tags: [], forbids: [].}
-
@brief Copy raw data.
@param dest Destination memory pointer @param src Source memory pointer @param count Bytes to copy
@example webui_memcpy(myBuffer, myData, 64);
Source Edit proc new_window(): csize_t {.cdecl, importc: "webui_new_window", ...raises: [], tags: [], forbids: [].}
-
-- Definitions ---------------------
@brief Create a new WebUI window object.
@return Returns the window number.
@example size_t myWindow = webui_new_window();
Source Edit proc new_window_id(window_number: csize_t): csize_t {.cdecl, importc: "webui_new_window_id", ...raises: [], tags: [], forbids: [].}
-
@brief Create a new webui window object using a specified window number.
@param window_number The window number (should be > 0, and < WEBUI_MAX_IDS)
@return Returns the same window number if success.
@example size_t myWindow = webui_new_window_id(123);
Source Edit proc open_url(url: cstring) {.cdecl, importc: "webui_open_url", ...raises: [], tags: [], forbids: [].}
-
@brief Open an URL in the native default web browser.
@param url The URL to open
@example webui_open_url("https://webui.me");
Source Edit proc return_bool(e: ptr Event; b: bool) {.cdecl, importc: "webui_return_bool", ...raises: [], tags: [], forbids: [].}
-
@brief Return the response to JavaScript as boolean.
@param e The event struct @param n The boolean to be send to JavaScript
@example webui_return_bool(e, true);
Source Edit proc return_float(e: ptr Event; f: cdouble) {.cdecl, importc: "webui_return_float", ...raises: [], tags: [], forbids: [].}
-
@brief Return the response to JavaScript as float.
@param e The event struct @param f The float number to be send to JavaScript
@example webui_return_float(e, 123.456);
Source Edit proc return_int(e: ptr Event; n: clonglong) {.cdecl, importc: "webui_return_int", ...raises: [], tags: [], forbids: [].}
-
@brief Return the response to JavaScript as integer.
@param e The event struct @param n The integer to be send to JavaScript
@example webui_return_int(e, 123);
Source Edit proc return_string(e: ptr Event; s: cstring) {.cdecl, importc: "webui_return_string", ...raises: [], tags: [], forbids: [].}
-
@brief Return the response to JavaScript as string.
@param e The event struct @param n The string to be send to JavaScript
@example webui_return_string(e, "Response...");
Source Edit proc run(window: csize_t; script: cstring) {.cdecl, importc: "webui_run", ...raises: [], tags: [], forbids: [].}
-
-- JavaScript ----------------------
@brief Run JavaScript without waiting for the response. All clients.
@param window The window number @param script The JavaScript to be run
@example webui_run(myWindow, "alert('Hello');");
Source Edit proc run_client(e: ptr Event; script: cstring) {.cdecl, importc: "webui_run_client", ...raises: [], tags: [], forbids: [].}
-
@brief Run JavaScript without waiting for the response. Single client.
@param e The event struct @param script The JavaScript to be run
@example webui_run_client(e, "alert('Hello');");
Source Edit proc script(window: csize_t; script: cstring; timeout: csize_t; buffer: cstring; buffer_length: csize_t): bool {.cdecl, importc: "webui_script", ...raises: [], tags: [], forbids: [].}
-
@brief Run JavaScript and get the response back. Work only in single client mode. Make sure your local buffer can hold the response.
@param window The window number @param script The JavaScript to be run @param timeout The execution timeout in seconds @param buffer The local buffer to hold the response @param buffer_length The local buffer size
@return Returns True if there is no execution error
@example bool err = webui_script(myWindow, "return 4 + 6;", 0, myBuffer, myBufferSize);
Source Edit proc script_client(e: ptr Event; script: cstring; timeout: csize_t; buffer: cstring; buffer_length: csize_t): bool {.cdecl, importc: "webui_script_client", ...raises: [], tags: [], forbids: [].}
-
@brief Run JavaScript and get the response back. Single client. Make sure your local buffer can hold the response.
@param e The event struct @param script The JavaScript to be run @param timeout The execution timeout in seconds @param buffer The local buffer to hold the response @param buffer_length The local buffer size
@return Returns True if there is no execution error
@example bool err = webui_script_client(e, "return 4 + 6;", 0, myBuffer, myBufferSize);
Source Edit proc send_raw(window: csize_t; function: cstring; raw: pointer; size: csize_t) {. cdecl, importc: "webui_send_raw", ...raises: [], tags: [], forbids: [].}
-
@brief Safely send raw data to the UI. All clients.
@param window The window number @param function The JavaScript function to receive raw data: function myFunc(myData){} @param raw The raw data buffer @param size The raw data size in bytes
@example webui_send_raw(myWindow, "myJavaScriptFunc", myBuffer, 64);
Source Edit proc send_raw_client(e: ptr Event; function: cstring; raw: pointer; size: csize_t) {.cdecl, importc: "webui_send_raw_client", ...raises: [], tags: [], forbids: [].}
-
@brief Safely send raw data to the UI. Single client.
@param e The event struct @param function The JavaScript function to receive raw data: function myFunc(myData){} @param raw The raw data buffer @param size The raw data size in bytes
@example webui_send_raw_client(e, "myJavaScriptFunc", myBuffer, 64);
Source Edit proc set_browser_folder(path: cstring) {.cdecl, importc: "webui_set_browser_folder", ...raises: [], tags: [], forbids: [].}
-
@brief Set custom browser folder path.
@param path The browser folder path
@example webui_set_browser_folder("/home/Foo/Bar/");
Source Edit proc set_center(window: csize_t) {.cdecl, importc: "webui_set_center", ...raises: [], tags: [], forbids: [].}
-
@brief Centers the window on the screen. Works better with WebView. Call this function before webui_show() for better results.
@param window The window number
@example webui_set_center(myWindow);
Source Edit proc set_close_handler_wv(window: csize_t; close_handler: proc (window: csize_t): bool {.cdecl.}) {. cdecl, importc: "webui_set_close_handler_wv", ...raises: [], tags: [], forbids: [].}
-
@brief Set a callback to catch the close event of the WebView window. Must return false to prevent the close event, true otherwise.
@example bool myCloseEvent(size_t window) { // Prevent WebView window close event return false; } webui_set_close_handler(myWindow, myCloseEvent);
Source Edit proc set_config(option: WebuiConfig; status: bool) {.cdecl, importc: "webui_set_config", ...raises: [], tags: [], forbids: [].}
-
@brief Control the WebUI behaviour. It's recommended to be called at the beginning.
@param option The desired option from webui_config enum @param status The status of the option, true or false
@example webui_set_config(show_wait_connection, false);
Source Edit proc set_context(window: csize_t; element: cstring; context: pointer) {.cdecl, importc: "webui_set_context", ...raises: [], tags: [], forbids: [].}
-
@brief Use this API after using webui_bind() to add any user data to it that can be read later using webui_get_context().
@param window The window number @param element The HTML element / JavaScript object @param context Any user data
@example webui_bind(myWindow, "myFunction", myFunction);
webui_set_context(myWindow, "myFunction", myData);
void myFunction(webui_event_t* e) { void* myData = webui_get_context(e); }
Source Edit proc set_custom_parameters(window: csize_t; params: cstring) {.cdecl, importc: "webui_set_custom_parameters", ...raises: [], tags: [], forbids: [].}
-
@brief Add a user-defined web browser's CLI parameters.
@param window The window number @param params Command line parameters
@example webui_set_custom_parameters(myWindow, "--remote-debugging-port=9222");
Source Edit proc set_default_root_folder(path: cstring): bool {.cdecl, importc: "webui_set_default_root_folder", ...raises: [], tags: [], forbids: [].}
-
@brief Set the web-server root folder path for all windows. Should be used before webui_show().
@param path The local folder full path
@example webui_set_default_root_folder("/home/Foo/Bar/");
Source Edit proc set_event_blocking(window: csize_t; status: bool) {.cdecl, importc: "webui_set_event_blocking", ...raises: [], tags: [], forbids: [].}
-
@brief Control if UI events comming from this window should be processed one a time in a single blocking thread True, or process every event in a new non-blocking thread False. This update single window. You can use webui_set_config(ui_event_blocking, ...) to update all windows.
@param window The window number @param status The blocking status true or false
@example webui_set_event_blocking(myWindow, true);
Source Edit proc set_file_handler(window: csize_t; handler: proc (filename: cstring; length: ptr cint): pointer {.cdecl.}) {.cdecl, importc: "webui_set_file_handler", ...raises: [], tags: [], forbids: [].}
-
@brief Set a custom handler to serve files. This custom handler should return full HTTP header and body. This deactivates any previous handler set with webui_set_file_handler_window
@param window The window number @param handler The handler function: void myHandler(const char\* filename, int* length)
@example webui_set_file_handler(myWindow, myHandlerFunction);
Source Edit proc set_file_handler_window(window: csize_t; handler: proc (window: csize_t; filename: cstring; length: ptr cint): pointer {.cdecl.}) {.cdecl, importc: "webui_set_file_handler_window", ...raises: [], tags: [], forbids: [].}
-
@brief Set a custom handler to serve files. This custom handler should return full HTTP header and body. This deactivates any previous handler set with webui_set_file_handler
@param window The window number @param handler The handler function: void myHandler(size_t window, const char\* filename, int* length)
@example webui_set_file_handler_window(myWindow, myHandlerFunction);
Source Edit proc set_frameless(window: csize_t; status: bool) {.cdecl, importc: "webui_set_frameless", ...raises: [], tags: [], forbids: [].}
-
@brief Make a WebView window frameless.
@param window The window number @param status The frameless status true or false
@example webui_set_frameless(myWindow, true);
Source Edit proc set_hide(window: csize_t; status: bool) {.cdecl, importc: "webui_set_hide", ...raises: [], tags: [], forbids: [].}
-
@brief Set a window in hidden mode. Should be called before webui_show().
@param window The window number @param status The status: True or False
@example webui_set_hide(myWindow, True);
Source Edit proc set_high_contrast(window: csize_t; status: bool) {.cdecl, importc: "webui_set_high_contrast", ...raises: [], tags: [], forbids: [].}
-
@brief Set the window with high-contrast support. Useful when you want to build a better high-contrast theme with CSS.
@param window The window number @param status True or False
@example webui_set_high_contrast(myWindow, true);
Source Edit proc set_icon(window: csize_t; icon: cstring; icon_type: cstring) {.cdecl, importc: "webui_set_icon", ...raises: [], tags: [], forbids: [].}
-
@brief Set the default embedded HTML favicon.
@param window The window number @param icon The icon as string: <svg>...</svg> @param icon_type The icon type: image/svg+xml
@example webui_set_icon(myWindow, "<svg>...</svg>", "image/svg+xml");
Source Edit proc set_logger(func: proc (level: csize_t; log: cstring; user_data: pointer) {. cdecl.}; user_data: pointer) {.cdecl, importc: "webui_set_logger", ...raises: [], tags: [], forbids: [].}
-
@brief Set a custom logger function.
@example void myLogger(size_t level, const char* log, void* user_data) { printf("myLogger (%d): %s", level, log); } webui_set_logger(myLogger, NULL);
Source Edit proc set_minimum_size(window: csize_t; width: cuint; height: cuint) {.cdecl, importc: "webui_set_minimum_size", ...raises: [], tags: [], forbids: [].}
-
@brief Set the window minimum size.
@param window The window number @param width The window width @param height The window height
@example webui_set_minimum_size(myWindow, 800, 600);
Source Edit proc set_port(window: csize_t; port: csize_t): bool {.cdecl, importc: "webui_set_port", ...raises: [], tags: [], forbids: [].}
-
@brief Set a custom web-server/websocket network port to be used by WebUI. This can be useful to determine the HTTP link of webui.js in case you are trying to use WebUI with an external web-server like NGNIX.
@param window The window number @param port The web-server network port WebUI should use
@return Returns True if the port is free and usable by WebUI
@example bool ret = webui_set_port(myWindow, 8080);
Source Edit proc set_position(window: csize_t; x: cuint; y: cuint) {.cdecl, importc: "webui_set_position", ...raises: [], tags: [], forbids: [].}
-
@brief Set the window position.
@param window The window number @param x The window X @param y The window Y
@example webui_set_position(myWindow, 100, 100);
Source Edit proc set_profile(window: csize_t; name: cstring; path: cstring) {.cdecl, importc: "webui_set_profile", ...raises: [], tags: [], forbids: [].}
-
@brief Set the web browser profile to use. An empty name and path means the default user profile. Need to be called before webui_show().
@param window The window number @param name The web browser profile name @param path The web browser profile full path
@example webui_set_profile(myWindow, "Bar", "/Home/Foo/Bar"); | webui_set_profile(myWindow, "", "");
Source Edit proc set_proxy(window: csize_t; proxy_server: cstring) {.cdecl, importc: "webui_set_proxy", ...raises: [], tags: [], forbids: [].}
-
@brief Set the web browser proxy server to use. Need to be called before webui_show().
@param window The window number @param proxy_server The web browser proxy_server
@example webui_set_proxy(myWindow, "http://127.0.0.1:8888");
Source Edit proc set_public(window: csize_t; status: bool) {.cdecl, importc: "webui_set_public", ...raises: [], tags: [], forbids: [].}
-
@brief Allow a specific window address to be accessible from a public network.
@param window The window number @param status True or False
@example webui_set_public(myWindow, true);
Source Edit proc set_resizable(window: csize_t; status: bool) {.cdecl, importc: "webui_set_resizable", ...raises: [], tags: [], forbids: [].}
-
@brief Sets whether the window frame is resizable or fixed. Works only on WebView window.
@param window The window number @param status True or False
@example webui_set_resizable(myWindow, true);
Source Edit proc set_root_folder(window: csize_t; path: cstring): bool {.cdecl, importc: "webui_set_root_folder", ...raises: [], tags: [], forbids: [].}
-
@brief Set the web-server root folder path for a specific window.
@param window The window number @param path The local folder full path
@example webui_set_root_folder(myWindow, "/home/Foo/Bar/");
Source Edit proc set_runtime(window: csize_t; runtime: csize_t) {.cdecl, importc: "webui_set_runtime", ...raises: [], tags: [], forbids: [].}
-
@brief Chose between Deno and Nodejs as runtime for .js and .ts files.
@param window The window number @param runtime Deno | Bun | Nodejs | None
@example webui_set_runtime(myWindow, Deno);
Source Edit proc set_size(window: csize_t; width: cuint; height: cuint) {.cdecl, importc: "webui_set_size", ...raises: [], tags: [], forbids: [].}
-
@brief Set the window size.
@param window The window number @param width The window width @param height The window height
@example webui_set_size(myWindow, 800, 600);
Source Edit proc set_timeout(second: csize_t) {.cdecl, importc: "webui_set_timeout", ...raises: [], tags: [], forbids: [].}
-
@brief Set the maximum time in seconds to wait for the window to connect. This effect show() and wait(). Value of 0 means wait forever.
@param second The timeout in seconds
@example webui_set_timeout(30);
Source Edit proc set_tls_certificate(certificate_pem: cstring; private_key_pem: cstring): bool {. cdecl, importc: "webui_set_tls_certificate", ...raises: [], tags: [], forbids: [].}
-
-- SSL/TLS -------------------------
@brief Set the SSL/TLS certificate and the private key content, both in PEM format. This works only with webui-2-secure library. If set empty WebUI will generate a self-signed certificate.
@param certificate_pem The SSL/TLS certificate content in PEM format @param private_key_pem The private key content in PEM format
@return Returns True if the certificate and the key are valid.
@example bool ret = webui_set_tls_certificate("-----BEGIN CERTIFICATE-----n...", "-----BEGIN PRIVATE KEY-----n...");
Source Edit proc set_transparent(window: csize_t; status: bool) {.cdecl, importc: "webui_set_transparent", ...raises: [], tags: [], forbids: [].}
-
@brief Make a WebView window transparent.
@param window The window number @param status The transparency status true or false
@example webui_set_transparent(myWindow, true);
Source Edit proc show(window: csize_t; content: cstring): bool {.cdecl, importc: "webui_show", ...raises: [], tags: [], forbids: [].}
-
@brief Show a window using embedded HTML, or a file. If the window is already open, it will be refreshed. This will refresh all windows in multi-client mode.
@param window The window number @param content The HTML, URL, Or a local file
@return Returns True if showing the window is successed.
@example webui_show(myWindow, "<html>...</html>"); | webui_show(myWindow, "index.html"); | webui_show(myWindow, "http://...");
Source Edit proc show_browser(window: csize_t; content: cstring; browser: csize_t): bool {. cdecl, importc: "webui_show_browser", ...raises: [], tags: [], forbids: [].}
-
@brief Same as webui_show(). But using a specific web browser.
@param window The window number @param content The HTML, Or a local file @param browser The web browser to be used
@return Returns True if showing the window is successed.
@example webui_show_browser(myWindow, "<html>...</html>", Chrome); | webui_show(myWindow, "index.html", Firefox);
Source Edit proc show_client(e: ptr Event; content: cstring): bool {.cdecl, importc: "webui_show_client", ...raises: [], tags: [], forbids: [].}
-
@brief Show a window using embedded HTML, or a file. If the window is already open, it will be refreshed. Single client.
@param e The event struct @param content The HTML, URL, Or a local file
@return Returns True if showing the window is successed.
@example webui_show_client(e, "<html>...</html>"); | webui_show_client(e, "index.html"); | webui_show_client(e, "http://...");
Source Edit proc show_wv(window: csize_t; content: cstring): bool {.cdecl, importc: "webui_show_wv", ...raises: [], tags: [], forbids: [].}
-
@brief Show a WebView window using embedded HTML, or a file. If the window is already open, it will be refreshed. Note: Win32 need WebView2Loader.dll.
@param window The window number @param content The HTML, URL, Or a local file
@return Returns True if showing the WebView window is successed.
@example webui_show_wv(myWindow, "<html>...</html>"); | webui_show_wv(myWindow, "index.html"); | webui_show_wv(myWindow, "http://...");
Source Edit proc start_server(window: csize_t; content: cstring): cstring {.cdecl, importc: "webui_start_server", ...raises: [], tags: [], forbids: [].}
-
@brief Same as webui_show(). But start only the web server and return the URL. No window will be shown.
@param window The window number @param content The HTML, Or a local file
@return Returns the url of this window server.
@example const char* url = webui_start_server(myWindow, "/full/root/path");
Source Edit proc win32_get_hwnd(window: csize_t): pointer {.cdecl, importc: "webui_win32_get_hwnd", ...raises: [], tags: [], forbids: [].}
-
@brief Gets Win32 window HWND. More reliable with WebView than web browser window, as browser PIDs may change on launch.
@param window The window number
@return Returns the window hwnd as void*
@example HWND hwnd = webui_win32_get_hwnd(myWindow);
Source Edit