webui/bindings

Search:
Group by:

This file is automatically generated by command : "nim scripts/generate_bindings.nims" Do not edit this file directly Nim bindings for WebUIDynamic Library Exports

Types

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 -------------------------
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
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
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
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

Consts

useWebuiDll = false
WEBUI_MAX_ARG = 16
Max allowed argument's index
WEBUI_MAX_IDS = 256
Max windows, servers and threads
WEBUI_VERSION = "2.5.0-beta.3"
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.

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);

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);

proc clean() {.cdecl, importc: "webui_clean", ...raises: [], tags: [], forbids: [].}

@brief Free all memory resources. Should be called only at the end.

@example webui_wait(); webui_clean();

proc close(window: csize_t) {.cdecl, importc: "webui_close", ...raises: [],
                              tags: [], forbids: [].}

@brief Close a specific window only. The window object will still exist. All clients.

@param window The window number

@example webui_close(myWindow);

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);

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=");

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();

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.

proc destroy(window: csize_t) {.cdecl, importc: "webui_destroy", ...raises: [],
                                tags: [], forbids: [].}

@brief Close a specific window and free all memory resources.

@param window The window number

@example webui_destroy(myWindow);

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");

proc exit() {.cdecl, importc: "webui_exit", ...raises: [], tags: [], forbids: [].}

@brief Close all open windows. webui_wait() will return (Break).

@example webui_exit();

proc free(ptr: pointer) {.cdecl, importc: "webui_free", ...raises: [], tags: [],
                          forbids: [].}

@brief Safely free a buffer allocated by WebUI using webui_malloc().

@param ptr The buffer to be freed

@example webui_free(myBuffer);

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);

proc get_bool(e: ptr Event): bool {.cdecl, importc: "webui_get_bool",
                                    ...raises: [], tags: [], forbids: [].}

@brief Get the first argument as boolean.

@param e The event struct

@return Returns argument as boolean

@example bool myBool = webui_get_bool(e);

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);

proc get_child_process_id(window: csize_t): csize_t {.cdecl,
    importc: "webui_get_child_process_id", ...raises: [], tags: [], forbids: [].}

@brief Get the ID of the last child 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);

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); }

proc get_count(e: ptr Event): csize_t {.cdecl, importc: "webui_get_count",
                                        ...raises: [], tags: [], forbids: [].}

@brief Get how many arguments there are in an event.

@param e The event struct

@return Returns the arguments count.

@example size_t count = webui_get_count(e);

proc get_float(e: ptr Event): cdouble {.cdecl, importc: "webui_get_float",
                                        ...raises: [], tags: [], forbids: [].}

@brief Get the first argument as float.

@param e The event struct

@return Returns argument as float

@example double myNum = webui_get_float(e);

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);

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();

proc get_int(e: ptr Event): clonglong {.cdecl, importc: "webui_get_int",
                                        ...raises: [], tags: [], forbids: [].}

@brief Get the first argument as integer.

@param e The event struct

@return Returns argument as integer

@example long long int myNum = webui_get_int(e);

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);

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");

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();

proc get_parent_process_id(window: csize_t): csize_t {.cdecl,
    importc: "webui_get_parent_process_id", ...raises: [], tags: [], forbids: [].}

@brief Get the ID of the parent process (The web browser may re-create another new 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);

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);

proc get_size(e: ptr Event): csize_t {.cdecl, importc: "webui_get_size",
                                       ...raises: [], tags: [], forbids: [].}

@brief Get size in bytes of the first argument.

@param e The event struct

@return Returns size in bytes

@example size_t argLen = webui_get_size(e);

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);

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);

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);

proc get_url(window: csize_t): cstring {.cdecl, importc: "webui_get_url",
    ...raises: [], tags: [], forbids: [].}

@brief Get current URL of a running window.

@param window The window number

@return Returns the full URL string

@example const char* url = webui_get_url(myWindow);

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);

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);

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);

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);

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);

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);

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);

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);

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();

proc interface_navigate_client(window: csize_t; event_number: csize_t;
                               url: cstring) {.cdecl,
    importc: "webui_interface_navigate_client", ...raises: [], tags: [],
    forbids: [].}

@brief Navigate to a specific URL. Single client.

@param window The window number @param event_number The event number @param url Full HTTP URL

@example webui_navigate_client(e, "http://domain.com");

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');");

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);

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);

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...");

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);

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://...");

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();

proc is_shown(window: csize_t): bool {.cdecl, importc: "webui_is_shown",
                                       ...raises: [], tags: [], forbids: [].}

@brief Check if the specified window is still running.

@param window The window number

@example webui_is_shown(myWindow);

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);

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);

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();

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);

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");

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);

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);

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);

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...");

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');");

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');");

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);

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);

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);

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);

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);

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); }

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");

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/");

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);

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);

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);

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);

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);

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");

proc set_kiosk(window: csize_t; status: bool) {.cdecl,
    importc: "webui_set_kiosk", ...raises: [], tags: [], forbids: [].}

@brief Set the window in Kiosk mode (Full screen).

@param window The window number @param status True or False

@example webui_set_kiosk(myWindow, true);

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);

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);

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);

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, "", "");

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");

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);

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/");

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);

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);

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);

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...");

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://...");

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);

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://...");

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://...");

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");

proc wait() {.cdecl, importc: "webui_wait", ...raises: [], tags: [], forbids: [].}

@brief Wait until all opened windows get closed.

@example webui_wait();

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);