Copyright | (C) 2018 David Lettier |
---|---|
License | BSD3 |
Maintainer | David Lettier |
Safe Haskell | None |
Language | Haskell2010 |
webviewhs is a Haskell binding to the webview library created by Serge Zaitsev.
According to webview:
[webview is] a tiny cross-platform webview library for C/C++/Golang to build modern cross-platform GUIs. It uses Cocoa/WebKit on macOS, gtk-webkit2 on Linux and MSHTML (IE10/11) on Windows.
For more information, see the webview README.
Be sure to explore the provided examples.
To exclude clay, jmacro, and text-format-heavy, use the cabal build flag light
.
Be sure to explore the provided light examples
for more information.
- data WindowParams = WindowParams {}
- data WindowBackgroundColor = WindowBackgroundColor {}
- data WindowAlertDialogType
- type Window = Ptr
- newtype WithWindowLoopSetUp a = WithWindowLoopSetUp (Window a -> IO ())
- newtype WithWindowLoopTearDown a = WithWindowLoopTearDown (Window a -> IO ())
- createWindowAndBlock :: WindowParams -> IO ()
- createWindow :: WindowParams -> (Window a -> Text -> IO ()) -> IO (Either Text (Window a))
- setWindowTitle :: Window a -> Text -> IO ()
- setWindowFullscreen :: Window a -> Bool -> IO ()
- setWindowBackgroundColor :: Window a -> WindowBackgroundColor -> IO ()
- withWindowLoop :: WindowParams -> (Window a -> Text -> IO ()) -> WithWindowLoopSetUp a -> WithWindowLoopTearDown a -> (Window a -> IO Bool) -> IO ()
- iterateWindowLoop :: Window a -> Bool -> IO Bool
- runJavaScript' :: Window a -> Text -> IO Bool
- runJavaScript :: (JsToDoc js, JMacro js) => Window a -> js -> IO Bool
- injectCss :: Window a -> Css -> IO Bool
- log :: VarContainer vars => Format -> vars -> IO ()
- injectCss' :: Window a -> Text -> IO Bool
- openWindowAlertDialog :: Window a -> WindowAlertDialogType -> Text -> Text -> IO ()
- withWindowOpenDialog :: Window a -> Text -> Bool -> (Text -> IO ()) -> IO ()
- withWindowSaveDialog :: Window a -> Text -> (Text -> IO ()) -> IO ()
- dispatchToMain :: Window a -> (Window a -> IO ()) -> IO ()
- log' :: Text -> IO ()
- terminateWindowLoop :: Window a -> IO ()
- destroyWindow :: Window a -> IO ()
Documentation
data WindowParams Source #
Specifies the window creation parameters.
WindowParams | |
|
data WindowBackgroundColor Source #
Specifies the RGBA for the window background color.
data WindowAlertDialogType Source #
Specifies the window alert dialog type.
newtype WithWindowLoopSetUp a Source #
WithWindowLoopSetUp (Window a -> IO ()) |
newtype WithWindowLoopTearDown a Source #
WithWindowLoopTearDown (Window a -> IO ()) |
createWindowAndBlock :: WindowParams -> IO () Source #
Creates a window and runs the main loop unless the window is destroyed. Useful for loading a web page and not having to manage the loop.
setWindowBackgroundColor :: Window a -> WindowBackgroundColor -> IO () Source #
If the loaded web page does not specify a background color, this sets the window's background color.
:: WindowParams | |
-> (Window a -> Text -> IO ()) | A callback function that can be invoked from the JavaScript side.
The callback must accept a |
-> WithWindowLoopSetUp a | A function that is called before iterating.
It must accept a |
-> WithWindowLoopTearDown a | A function that is called after iterating.
It must accept a |
-> (Window a -> IO Bool) | A function that is called each iteration.
Return |
-> IO () |
Manages the window and main loop for you. It accepts a JavaScript callback, setup, teardown, and iteration function.
Runs the given JavaScript inside the window. The given JavaScript is not checked for validity.
Runs the given JavaScript inside the window.
Uses Language.Javascript.JMacro.
Note, this function is not available when using the light
cabal build flag.
Injects CSS into the window.
Uses Clay.
Note, this function is not available when using the light
cabal build flag.
log :: VarContainer vars => Format -> vars -> IO () Source #
Logs the given formatted input to stderr, macOS console,
or Windows DebugView depending on the build platform.
Uses Data.Text.Format.Heavy.
Note, this function is not available when using the light
cabal build flag.
Injects CSS into the window. The given CSS is not checked for validity.
openWindowAlertDialog Source #
:: Window a | |
-> WindowAlertDialogType | |
-> Text | This is the primary message. |
-> Text | This is the secondary message. |
-> IO () |
Opens a window alert dialog.
:: Window a | |
-> Text | The open dialog window title. |
-> Bool | Pass |
-> (Text -> IO ()) | A callback that accepts the result of the dialog. |
-> IO () |
Opens a native file chooser dialog. Accepts a callback that receives the selection.
:: Window a | |
-> Text | The save dialog window title. |
-> (Text -> IO ()) | A callback that accepts the result of the dialog. |
-> IO () |
Opens a native file saving dialog. Accepts a callback that receives the selection. Does not actually save the file. Save the file inside the provided callback.
dispatchToMain :: Window a -> (Window a -> IO ()) -> IO () Source #
Runs the given function in the main window UI thread. Use this function whenever you wish to interact with the window but you're not running in the main window UI thread.
log' :: Text -> IO () Source #
Logs the given input to stderr, macOS console, or Windows DebugView depending on the build platform.
terminateWindowLoop :: Window a -> IO () Source #
Terminates the window's loop.
destroyWindow :: Window a -> IO () Source #
Destroys the window.