diff --git a/webui/bindings.nim b/webui/bindings.nim index ea3873e..b0ad757 100644 --- a/webui/bindings.nim +++ b/webui/bindings.nim @@ -35,7 +35,7 @@ when useWebuiStaticLib: {.passL: "-L.".} # so gcc/clang can find the library {.passL: "-l" & webuiStaticLib.} # link the static library itself - + when defined(webuiTls): {.passL: "-lcrypto".} {.passL: "-lssl".} @@ -69,12 +69,12 @@ else: # -d:webuiLog when defined(webuiLog): {.passC: "-DWEBUI_LOG".} - + # -d:webuiTLS when defined(webuiTLS): when defined(windows): {.passL: "-lbcrypt".} - + {.passL: "-lcrypto".} {.passL: "-lssl".} @@ -109,9 +109,9 @@ else: when defined(macos) or defined(macosx): {.passL: "-framework Cocoa -framework WebKit".} {.passC: "-I" & currentSourceDir / "webui/src/webview".} - + {.compile: currentSourceDir / "webui/src/webview/wkwebview.m".} - + # fix for cpp when (defined(clang) or defined(gcc)) and defined(cpp): {.passL: "-static".} @@ -124,7 +124,7 @@ else: {.pragma: webui, cdecl.} const - WEBUI_VERSION* = "2.5.0-Beta.2" ## Version + WEBUI_VERSION* = "2.5.0-Beta.4" ## Version WEBUI_MAX_IDS* = (256) WEBUI_MAX_ARG* = (16) @@ -154,54 +154,60 @@ type wrBun ## 2. Use Bun runtime for .js files WebuiEvent* = enum - weDisconnected ## 0. Window disconnection event - weConnected ## 1. Window connection event - weMultiConnection ## 2. New window connection event - weUnwantedConnection ## 3. New unwanted window connection event - weMouseClick ## 4. Mouse click event - weNavigation ## 5. Window navigation event - weCallback ## 6. Function call event + weDisconnected ## 0. Window disconnection event + weConnected ## 1. Window connection event + # weMultiConnection ## 2. New window connection event + # weUnwantedConnection ## 3. New unwanted window connection event + weMouseClick ## 4. Mouse click event + weNavigation ## 5. Window navigation event + weCallback ## 6. Function call event WebuiConfig* = enum wcShowWaitConnection ## Control if `show()` and `showX()` (e.g. `showBrowser()` & `showWv`) ## should wait for the window to connect before returns or not. - ## + ## ## Default: `true` wcUiEventBlocking ## Control if WebUI should block and process the UI events one a time in ## a single thread (`true`), or process every event in a new non-blocking ## thread (`false`). This updates all windows. You can use ## `setEventBlocking()` for a specific single window update. - ## + ## ## Default: `false` wcFolderMonitor ## Automatically refresh the window UI when any file in the root folder ## changes - ## + ## ## Default: `false` wcMultiClient ## Allow multiple clients to connect to the same window. This is helpful ## for web apps (non-desktop software). Please see the documentation for ## more details. - ## + ## ## Default: `false` wcUseCookies ## Allow multiple clients to connect to the same window. This is helpful ## for web apps (non-desktop software). Please see the documentation for ## more details. - ## + ## + ## Default: `false` + wcAscynchronousResponse + ## If the backend uses asynchronous operations, set this + ## option to `True`. This will make webui wait until the + ## backend sets a response using `webui_return_x()`. + ## ## Default: `false` Event* {.bycopy.} = object - window*: csize_t ## The window object number - eventType*: csize_t ## Event type - element*: cstring ## HTML element ID - eventNumber*: csize_t ## Internal WebUI - bindId*: csize_t ## Bind ID - clientId*: csize_t ## Client's unique ID - connectionId*: csize_t ## Client's connection ID - cookies*: cstring ## Client's full cookies + window*: csize_t ## The window object number + eventType*: csize_t ## Event type + element*: cstring ## HTML element ID + eventNumber*: csize_t ## Internal WebUI + bindId*: csize_t ## Bind ID + clientId*: csize_t ## Client's unique ID + connectionId*: csize_t ## Client's connection ID + cookies*: cstring ## Client's full cookies # aliases to reduce breaking changes const @@ -225,8 +231,8 @@ const EventsDisconnected* {.deprecated.} = weDisconnected EventsConnected* {.deprecated.} = weConnected - EventsMultiConnection* {.deprecated.} = weMultiConnection - EventsUnwantedConnection* {.deprecated.} = weUnwantedConnection + # EventsMultiConnection* {.deprecated.} = weMultiConnection + # EventsUnwantedConnection* {.deprecated.} = weUnwantedConnection EventsMouseClick* {.deprecated.} = weMouseClick EventsNavigation* {.deprecated.} = weNavigation EventsCallback* {.deprecated.} = weCallback @@ -236,55 +242,83 @@ const proc newWindow*(): csize_t {.webui, importc: "webui_new_window".} ## Create a new WebUI window object. -proc newWindowId*(windowNumber: csize_t): csize_t {.webui, importc: "webui_new_window_id".} +proc newWindowId*(windowNumber: csize_t): csize_t {.webui, + importc: "webui_new_window_id".} ## Create a new webui window object using a specified window number. proc getNewWindowId*(): csize_t {.webui, importc: "webui_get_new_window_id".} ## Get a free window number that can be used with `newWindowId()` -proc `bind`*(window: csize_t; element: cstring; `func`: proc (e: ptr Event) {.cdecl.}): csize_t {.webui, - importc: "webui_bind".} +proc `bind`*(window: csize_t; element: cstring; `func`: proc ( + e: ptr Event) {.cdecl.}): csize_t {.webui, importc: "webui_bind".} ## Bind an HTML element and a JavaScript object with a backend function. ## Empty `element` means all events. -proc getBestBrowser*(window: csize_t): csize_t {.webui, importc: "webui_get_best_browser".} +proc setContext*(window: csize_t; element: cstring; context: pointer) {.webui, + importc: "webui_set_context".} + ## Use this API after using `bind()` to add any user data to it that can be + ## read later using `getContext()`. + +proc getContext*(e: ptr Event) {.webui, + importc: "webui_get_context".} + ## Get user data that is set using `setContext()`. + +proc getBestBrowser*(window: csize_t): csize_t {.webui, + importc: "webui_get_best_browser".} ## Get the "best" browser to be used. If running `show()` or passing ## `wbAnyBrowser` to `showBrowser()`, this function will return the same ## browser that will be used. -proc show*(window: csize_t; content: cstring): bool {.webui, importc: "webui_show".} +proc show*(window: csize_t; content: cstring): bool {.webui, + importc: "webui_show".} ## 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. -proc showClient*(e: ptr Event; content: cstring): bool {.webui, importc: "webui_show_client".} +proc showClient*(e: ptr Event; content: cstring): bool {.webui, + importc: "webui_show_client".} ## Show a window using embedded HTML, or a file. If the window is already ## open, it will be refreshed. Single client. -proc showBrowser*(window: csize_t; content: cstring; browser: csize_t): bool {.webui, importc: "webui_show_browser".} +proc showBrowser*(window: csize_t; content: cstring; + browser: csize_t): bool {.webui, importc: "webui_show_browser".} ## Same as `show()`, but using a specific web browser. -proc startServer*(window: csize_t; path: cstring): cstring {.webui, importc: "webui_start_server".} +proc startServer*(window: csize_t; path: cstring): cstring {.webui, + importc: "webui_start_server".} ## Same as `webui_show()`. But start only the web server and return the URL. ## No window will be shown. -proc showWv*(window: csize_t; content: cstring): bool {.webui, importc: "webui_show_wv".} +proc showWv*(window: csize_t; content: cstring): bool {.webui, + importc: "webui_show_wv".} ## Show a WebView window using embedded HTML, or a file. If the window is ## already open, it will be refreshed. - ## + ## ## .. note:: Windows needs `WebView2Loader.dll`. -proc setKiosk*(window: csize_t; status: bool) {.webui, importc: "webui_set_kiosk".} +proc setKiosk*(window: csize_t; status: bool) {.webui, + importc: "webui_set_kiosk".} ## Set the window in Kiosk mode (Full screen). -proc setHighContrast*(window: csize_t; status: bool) {.webui, importc: "webui_set_high_contrast".} - ## Setup the window with high-contrast support. Useful when you want to +proc setCustomParameters*(window: csize_t; params: cstring) {.webui, + importc: "webui_set_custom_parameters".} + ## Add a user-defined web browser's CLI parameters. + +proc setHighContrast*(window: csize_t; status: bool) {.webui, + importc: "webui_set_high_contrast".} + ## Setup the window with high-contrast support. Useful when you want to ## build a better high-contrast theme with CSS. +proc setResizable*(window: csize_t; status: bool) {.webui, + importc: "webui_set_resizable".} + ## Sets whether the window frame is resizable or fixed. + ## Works only on WebView window. + proc isHighContrast*(): bool {.webui, importc: "webui_is_high_contrast".} ## Get the OS's high contrast preference. -proc browserExist*(browser: WebuiBrowser): bool {.webui, importc: "webui_browser_exist".} +proc browserExist*(browser: WebuiBrowser): bool {.webui, + importc: "webui_browser_exist".} ## Check if a web browser is installed. proc wait*() {.webui, importc: "webui_wait".} @@ -294,6 +328,12 @@ proc close*(window: csize_t) {.webui, importc: "webui_close".} ## Close a specific window only. The window object will still exist. All ## clients. +proc minimize*(window: csize_t) {.webui, importc: "webui_minimize".} + ## Minimize a WebView window. + +proc maximize*(window: csize_t) {.webui, importc: "webui_maximize".} + ## Maximize a WebView window. + proc closeClient*(e: ptr Event) {.webui, importc: "webui_close_client".} ## Close a specific client. @@ -303,17 +343,40 @@ proc destroy*(window: csize_t) {.webui, importc: "webui_destroy".} proc exit*() {.webui, importc: "webui_exit".} ## Close all open windows. `wait()` will return (Break). -proc setRootFolder*(window: csize_t; path: cstring): bool {.webui, importc: "webui_set_root_folder".} +proc setRootFolder*(window: csize_t; path: cstring): bool {.webui, + importc: "webui_set_root_folder".} ## Set the web-server root folder path for a specific window. -proc setDefaultRootFolder*(path: cstring): bool {.webui, importc: "webui_default_set_root_folder".} +proc setBrowserFolder*(path: cstring) {.webui, + importc: "webui_set_browser_folder".} + ## Set custom browser folder path. + +proc setDefaultRootFolder*(path: cstring): bool {.webui, + importc: "webui_default_set_root_folder".} ## Set the web-server root folder path for all windows. Should be used ## before `show()`. -proc setFileHandler*(window: csize_t; handler: proc (filename: cstring; length: ptr cint): pointer {.cdecl.}) {.webui, - importc: "webui_set_file_handler".} - ## Set a custom handler to serve files. This custom handler should return - ## the full HTTP headers and body. +proc setFileHandler*(window: csize_t; handler: proc (filename: cstring; + length: ptr cint): pointer {.cdecl.}) {.webui, + +importc: "webui_set_file_handler".} + ## 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` + +proc setFileHandlerWindow*(window: csize_t; handler: proc (window: csize_t; + filename: cstring; length: ptr cint): pointer {.cdecl.}) {.webui, + +importc: "webui_set_file_handler_window".} + ## 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` + +proc interfaceSetResponseFileHandler*(window: csize_t; response: pointer; + length: cint) {.webui, + importc: "webui_interface_set_response_file_handler".} + ## Use this API to set a file handler response if your backend need async + ## response for `setFileHandler()`. proc isShown*(window: csize_t): bool {.webui, importc: "webui_is_shown".} ## Check if the specified winFdow is still running. @@ -323,7 +386,8 @@ proc setTimeout*(second: csize_t) {.webui, importc: "webui_set_timeout".} ## will affect `show()` and `wait()`. Setting the timeout to `0` will cause ## WebUI to wait forever. -proc setIcon*(window: csize_t; icon: cstring; `type`: cstring) {.webui, importc: "webui_set_icon".} +proc setIcon*(window: csize_t; icon: cstring; `type`: cstring) {.webui, + importc: "webui_set_icon".} ## Set the default embedded HTML favicon. proc encode*(str: cstring): cstring {.webui, importc: "webui_encode".} @@ -343,26 +407,45 @@ proc malloc*(size: csize_t): pointer {.webui, importc: "webui_malloc".} ## Safely allocate memory using the WebUI memory management system. It ## can be safely freed using `free()` at any time. -proc sendRaw*(window: csize_t; function: cstring; raw: pointer; size: csize_t) {.webui, importc: "webui_send_raw".} +proc memcpy*(dest: pointer; src: pointer; count: csize_t) {.webui, + importc: "webui_memcpy".} + ## Copy raw data. + +proc sendRaw*(window: csize_t; function: cstring; raw: pointer; + size: csize_t) {.webui, importc: "webui_send_raw".} ## Safely send raw data to the UI. All clients. -proc sendRawClient*(e: ptr Event; function: cstring; raw: pointer; size: csize_t) {.webui, importc: "webui_send_raw_client".} +proc sendRawClient*(e: ptr Event; function: cstring; raw: pointer; + size: csize_t) {.webui, importc: "webui_send_raw_client".} ## Safely send raw data to the UI. Single client. -proc setHide*(window: csize_t; status: bool) {.webui, importc: "webui_set_hide".} +proc setHide*(window: csize_t; status: bool) {.webui, + importc: "webui_set_hide".} ## Set a window in hidden mode. Should be called before `show()`. -proc setSize*(window: csize_t; width: cuint; height: cuint) {.webui, importc: "webui_set_size".} +proc setSize*(window: csize_t; width: cuint; height: cuint) {.webui, + importc: "webui_set_size".} ## Set the window size. -proc setPosition*(window: csize_t; x: cuint; y: cuint) {.webui, importc: "webui_set_position".} +proc setMinimumSize*(window: csize_t; width: cuint; height: cuint) {.webui, + importc: "webui_set_minimum_size".} + ## Set the window minimum size. + +proc setPosition*(window: csize_t; x: cuint; y: cuint) {.webui, + importc: "webui_set_position".} ## Set the window position. -proc setProfile*(window: csize_t; name: cstring; path: cstring) {.webui, importc: "webui_set_profile".} +proc setCenter*(window: csize_t) {.webui, importc: "webui_set_center".} + ## Centers the window on the screen. Works better with + ## WebView. Call this function before `show()` for better results. + +proc setProfile*(window: csize_t; name: cstring; path: cstring) {.webui, + importc: "webui_set_profile".} ## Set the web browser profile to use. An empty `name` and `path` means ## the default user profile. Must be called before `show()`. -proc setProxy*(window: csize_t; proxy_server: cstring) {.webui, importc: "webui_set_proxy".} +proc setProxy*(window: csize_t; proxy_server: cstring) {.webui, + importc: "webui_set_proxy".} ## Set the web browser to use `proxy_server`. Must be called before ## `show()`. @@ -372,13 +455,16 @@ proc getUrl*(window: csize_t): cstring {.webui, importc: "webui_get_url".} proc openUrl*(url: cstring) {.webui, importc: "webui_open_url".} ## Open an URL in the native default web browser. -proc setPublic*(window: csize_t; status: bool) {.webui, importc: "webui_set_public".} +proc setPublic*(window: csize_t; status: bool) {.webui, + importc: "webui_set_public".} ## Allow a specific window address to be accessible from a public network. -proc navigate*(window: csize_t; url: cstring) {.webui, importc: "webui_navigate".} +proc navigate*(window: csize_t; url: cstring) {.webui, + importc: "webui_navigate".} ## Navigate to a specific URL. All clients. -proc navigateClient*(e: ptr Event; url: cstring) {.webui, importc: "webui_navigate_client".} +proc navigateClient*(e: ptr Event; url: cstring) {.webui, + importc: "webui_navigate_client".} ## Navigate to a specific URL. Single client. proc clean*() {.webui, importc: "webui_clean".} @@ -391,18 +477,26 @@ proc deleteAllProfiles*() {.webui, importc: "webui_delete_all_profiles".} proc deleteProfile*(window: csize_t) {.webui, importc: "webui_delete_profile".} ## Delete a specific window web-browser local folder profile. -proc getParentProcessId*(window: csize_t): csize_t {.webui, importc: "webui_get_parent_process_id".} +proc getParentProcessId*(window: csize_t): csize_t {.webui, + importc: "webui_get_parent_process_id".} ## Get the ID of the parent process (The web browser may re-create ## another new process). -proc getChildProcessId*(window: csize_t): csize_t {.webui, importc: "webui_get_child_process_id".} +proc getChildProcessId*(window: csize_t): csize_t {.webui, + importc: "webui_get_child_process_id".} ## Get the ID of the last child process. +proc win32GetHwnd*(window: csize_t): pointer {.webui, + importc: "webui_win32_get_hwnd".} + ## Gets Win32 window `HWND`. More reliable with WebView + ## than web browser window, as browser PIDs may change on launch. + proc getPort*(window: csize_t): csize_t {.webui, importc: "webui_get_port", discardable.} ## Get the network port of a running window. This can be useful to determine ## the HTTP link of `webui.js`. -proc setPort*(window: csize_t; port: csize_t): bool {.webui, importc: "webui_set_port", discardable.} +proc setPort*(window: csize_t; port: csize_t): bool {.webui, + importc: "webui_set_port", discardable.} ## 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. @@ -410,22 +504,35 @@ proc setPort*(window: csize_t; port: csize_t): bool {.webui, importc: "webui_set proc getFreePort*(): csize_t {.webui, importc: "webui_get_free_port".} ## Get an available and usable free network port. -proc setConfig*(option: WebuiConfig; status: bool) {.webui, importc: "webui_set_config".} - ## Control WebUI's behaviour. It's recommended to call this at the beginning. +proc setConfig*(option: WebuiConfig; status: bool) {.webui, + importc: "webui_set_config".} + ## Control WebUI's behaviour. It's recommended to call this at the beginning. -proc setEventBlocking*(window: csize_t; status: bool) {.webui, importc: "webui_set_event_blocking".} +proc setEventBlocking*(window: csize_t; status: bool) {.webui, + importc: "webui_set_event_blocking".} ## 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 function only updates a ## single window. You can use `setConfig(wcUiEventBlocking, ...)` to update ## all windows. -proc getMimeType*(file: cstring): cstring {.webui, importc: "webui_get_mime_type".} - ## Get the HTTP mime type of a file. +proc setFrameless*(window: csize_t; status: bool) {.webui, + importc: "webui_set_frameless".} + ## Make a WebView window frameless. + +proc setTransparent*(window: csize_t; status: bool) {.webui, + importc: "webui_set_transparent".} + ## Make a WebView window transparent. + +proc getMimeType*(file: cstring): cstring {.webui, + importc: "webui_get_mime_type".} + ## Get the HTTP mime type of a file. # -- SSL/TLS ------------------------- -proc setTlsCertificate*(certificate_pem: cstring; private_key_pem: cstring): bool {.webui, importc: "webui_set_tls_certificate".} +proc setTlsCertificate*(certificate_pem: cstring; + private_key_pem: cstring): bool {.webui, + importc: "webui_set_tls_certificate".} ## 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. @@ -435,94 +542,128 @@ proc setTlsCertificate*(certificate_pem: cstring; private_key_pem: cstring): boo proc run*(window: csize_t; script: cstring) {.webui, importc: "webui_run".} ## Run JavaScript without waiting for the response. All clients. -proc runClient*(e: ptr Event; script: cstring) {.webui, importc: "webui_run_client".} +proc runClient*(e: ptr Event; script: cstring) {.webui, + importc: "webui_run_client".} ## Run JavaScript without waiting for the response. Single client. -proc script*(window: csize_t; script: cstring; timeout: csize_t; buffer: cstring; bufferLength: csize_t): bool {.webui, importc: "webui_script".} +proc script*(window: csize_t; script: cstring; timeout: csize_t; + buffer: cstring; bufferLength: csize_t): bool {.webui, + importc: "webui_script".} ## Run JavaScript and get the response back. Make sure your local buffer can ## hold the response. All clients. -proc scriptClient*(e: ptr Event; script: cstring; timeout: csize_t; buffer: cstring; bufferLength: csize_t): bool {.webui, importc: "webui_script_client".} +proc scriptClient*(e: ptr Event; script: cstring; timeout: csize_t; + buffer: cstring; bufferLength: csize_t): bool {.webui, + importc: "webui_script_client".} ## Run JavaScript and get the response back. Make sure your local buffer can ## hold the response. Single client. -proc setRuntime*(window: csize_t; runtime: csize_t) {.webui, importc: "webui_set_runtime".} +proc setRuntime*(window: csize_t; runtime: csize_t) {.webui, + importc: "webui_set_runtime".} ## Chose between Deno and Nodejs as runtime for .js and .ts files. proc getCount*(e: ptr Event): csize_t {.webui, importc: "webui_get_count".} ## Get how many arguments there are in an event. -proc getIntAt*(e: ptr Event; index: csize_t): clonglong {.webui, importc: "webui_get_int_at".} +proc getIntAt*(e: ptr Event; index: csize_t): clonglong {.webui, + importc: "webui_get_int_at".} ## Get an argument as integer at a specific index. proc getInt*(e: ptr Event): clonglong {.webui, importc: "webui_get_int".} ## Get the first argument as integer. -proc getFloatAt*(e: ptr Event; index: csize_t): cdouble {.webui, importc: "webui_get_float_at".} +proc getFloatAt*(e: ptr Event; index: csize_t): cdouble {.webui, + importc: "webui_get_float_at".} ## Get an argument as float at a specific index. proc getFloat*(e: ptr Event): cdouble {.webui, importc: "webui_get_float".} ## Get the first argument as float. -proc getStringAt*(e: ptr Event; index: csize_t): cstring {.webui, importc: "webui_get_string_at".} +proc getStringAt*(e: ptr Event; index: csize_t): cstring {.webui, + importc: "webui_get_string_at".} ## Get an argument as string at a specific index. proc getString*(e: ptr Event): cstring {.webui, importc: "webui_get_string".} ## Get the first argument as string. -proc getBoolAt*(e: ptr Event; index: csize_t): csize_t {.webui, importc: "webui_get_bool_at".} +proc getBoolAt*(e: ptr Event; index: csize_t): csize_t {.webui, + importc: "webui_get_bool_at".} ## Get an argument as boolean at a specific index. proc getBool*(e: ptr Event): csize_t {.webui, importc: "webui_get_bool".} ## Get the first argument as boolean. -proc getSizeAt*(e: ptr Event; index: csize_t): csize_t {.webui, importc: "webui_get_size_at".} +proc getSizeAt*(e: ptr Event; index: csize_t): csize_t {.webui, + importc: "webui_get_size_at".} ## Get the size in bytes of an argument at a specific index. proc getSize*(e: ptr Event): csize_t {.webui, importc: "webui_get_size".} ## Get size in bytes of the first argument. -proc returnInt*(e: ptr Event; n: clonglong) {.webui, importc: "webui_return_int".} +proc returnInt*(e: ptr Event; n: clonglong) {.webui, + importc: "webui_return_int".} ## Return the response to JavaScript as integer. -proc returnFloat*(e: ptr Event; f: cdouble) {.webui, importc: "webui_return_float".} +proc returnFloat*(e: ptr Event; f: cdouble) {.webui, + importc: "webui_return_float".} ## Return the response to JavaScript as integer. -proc returnString*(e: ptr Event; s: cstring) {.webui, importc: "webui_return_string".} +proc returnString*(e: ptr Event; s: cstring) {.webui, + importc: "webui_return_string".} ## Return the response to JavaScript as string. proc returnBool*(e: ptr Event; b: bool) {.webui, importc: "webui_return_bool".} ## Return the response to JavaScript as boolean. +proc getLastErrorNumber*(): csize_t {.webui, + importc: "webui_get_last_error_number".} + ## Get the last WebUI error code. + +proc getLastErrorMessage*(): cstring {.webui, + importc: "webui_get_last_error_message".} + ## Get the last WebUI error code. + # -- Interface ----------------------- -proc interfaceBind*(window: csize_t; element: cstring; `func`: proc (window: csize_t; eventType: csize_t; element: cstring; eventNumber: csize_t; bindId: csize_t) {.cdecl.}): csize_t {.webui, importc: "webui_interface_bind".} +proc interfaceBind*(window: csize_t; element: cstring; `func`: proc ( + window: csize_t; eventType: csize_t; element: cstring; + eventNumber: csize_t; + bindId: csize_t) {.cdecl.}): csize_t {.webui, + importc: "webui_interface_bind".} ## Bind a specific HTML element click event with a function. Empty element ## means all events. - ## + ## ## :func: The callback as `myFunc(Window, EventType, Element, EventNumber, BindID)` -proc interfaceSetResponse*(window: csize_t; event_number: csize_t; repsonse: cstring) {.webui, importc: "webui_interface_set_response".} +proc interfaceSetResponse*(window: csize_t; event_number: csize_t; + repsonse: cstring) {.webui, importc: "webui_interface_set_response".} ## When using `interfaceBind()`, you may need this function to easily set a ## response. -proc interfaceIsAppRunning*(): bool {.webui, importc: "webui_interface_is_app_running".} +proc interfaceIsAppRunning*(): bool {.webui, + importc: "webui_interface_is_app_running".} ## Check if the app still running or not. This replaces `wait()`. -proc interfaceGetWindowId*(window: csize_t): csize_t {.webui, importc: "webui_interface_get_window_id".} +proc interfaceGetWindowId*(window: csize_t): csize_t {.webui, + importc: "webui_interface_get_window_id".} ## Get a unique window ID. -proc interfaceGetIntAt*(window: csize_t; event_number: csize_t; index: csize_t): clonglong {.webui, importc: "webui_interface_get_int_at".} +proc interfaceGetIntAt*(window: csize_t; event_number: csize_t; + index: csize_t): clonglong {.webui, importc: "webui_interface_get_int_at".} ## Get an argument as an integer at a specific index. -proc interfaceGetFloatAt*(window: csize_t; event_number: csize_t; index: csize_t): cdouble {.webui, importc: "webui_interface_get_float_at".} +proc interfaceGetFloatAt*(window: csize_t; event_number: csize_t; + index: csize_t): cdouble {.webui, importc: "webui_interface_get_float_at".} ## Get an argument as a float at a specific index. -proc interfaceGetStringAt*(window: csize_t; event_number: csize_t; index: csize_t): cstring {.webui, importc: "webui_interface_get_string_at".} +proc interfaceGetStringAt*(window: csize_t; event_number: csize_t; + index: csize_t): cstring {.webui, importc: "webui_interface_get_string_at".} ## Get an argument as a string at a specific index. -proc interfaceGetBoolAt*(window: csize_t; event_number: csize_t; index: csize_t): bool {.webui, importc: "webui_interface_get_bool_at".} +proc interfaceGetBoolAt*(window: csize_t; event_number: csize_t; + index: csize_t): bool {.webui, importc: "webui_interface_get_bool_at".} ## Get an argument as a boolean at a specific index. -proc interfaceGetSizeAt*(window: csize_t; event_number: csize_t; index: csize_t): csize_t {.webui, importc: "webui_interface_get_size_at".} +proc interfaceGetSizeAt*(window: csize_t; event_number: csize_t; + index: csize_t): csize_t {.webui, importc: "webui_interface_get_size_at".} ## Get the size in bytes of an argument at a specific index. diff --git a/webui/webui b/webui/webui index 2e94629..27679f3 160000 --- a/webui/webui +++ b/webui/webui @@ -1 +1 @@ -Subproject commit 2e94629304402fdf4b9144397c85cf56e18a35ee +Subproject commit 27679f3ec01a387ee3f0d4db6f8624741a3d7dc2