ultralight

package module
v0.0.0-...-86713d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2019 License: MIT Imports: 7 Imported by: 0

README

Go Documentation Go Report Card

ultralight-go

Go bindings for https://ultralig.ht/

Initial work to implement Go bindiongs for Ultralight (https://github.com/ultralight-ux/ultralight).

For now this requires a few manual steps:

  • Get a recent version of the Ultralight SDK. Best option for now is to clone the Ultralight repository and build it locally.

  • Copy/link the Ultralight SDK in this folder. If you built locally, the SDK is in {repo}/build/SDK.

  • Enable setting additional CGO LDFLAGS (at least for MacOS):

    export CGO_LDFLAGS_ALLOW=-Wl,-rpath.*
    
  • Run example:

    go run examples/resize.go
    
  • Run browser:

    cd examples/browser; make 
    ./browser
    

    The browser needs the HTML assets in examples/browser/assets and expects them in the current directory, so you need to "cd" in there.

    It also expects the SDK to be in the current directy, so the Makefile creates a link.

Documentation

Index

Constants

View Source
const (
	JSTypeUndefined = JSType(C.kJSTypeUndefined)
	JSTypeNull      = JSType(C.kJSTypeNull)
	JSTypeBoolean   = JSType(C.kJSTypeBoolean)
	JSTypeNumber    = JSType(C.kJSTypeNumber)
	JSTypeString    = JSType(C.kJSTypeString)
	JSTypeObject    = JSType(C.kJSTypeObject)
)
View Source
const (
	MessageSourceXML            = MessageSource(C.kMessageSource_XML)
	MessageSourceJS             = MessageSource(C.kMessageSource_JS)
	MessageSourceNetwork        = MessageSource(C.kMessageSource_Network)
	MessageSourceConsoleAPI     = MessageSource(C.kMessageSource_ConsoleAPI)
	MessageSourceStorage        = MessageSource(C.kMessageSource_Storage)
	MessageSourceAppCache       = MessageSource(C.kMessageSource_AppCache)
	MessageSourceRendering      = MessageSource(C.kMessageSource_Rendering)
	MessageSourceCSS            = MessageSource(C.kMessageSource_CSS)
	MessageSourceSecurity       = MessageSource(C.kMessageSource_Security)
	MessageSourceContentBlocker = MessageSource(C.kMessageSource_ContentBlocker)
	MessageSourceOther          = MessageSource(C.kMessageSource_Other)
)
View Source
const (
	MessageLevelLog     = MessageLevel(C.kMessageLevel_Log)
	MessageLevelWarning = MessageLevel(C.kMessageLevel_Warning)
	MessageLevelError   = MessageLevel(C.kMessageLevel_Error)
	MessageLevelDebug   = MessageLevel(C.kMessageLevel_Debug)
	MessageLevelInfo    = MessageLevel(C.kMessageLevel_Info)
)
View Source
const (
	CursorPointer                  = Cursor(C.kCursor_Pointer)
	CursorCross                    = Cursor(C.kCursor_Cross)
	CursorHand                     = Cursor(C.kCursor_Hand)
	CursorIBeam                    = Cursor(C.kCursor_IBeam)
	CursorWait                     = Cursor(C.kCursor_Wait)
	CursorHelp                     = Cursor(C.kCursor_Help)
	CursorEastResize               = Cursor(C.kCursor_EastResize)
	CursorNorthResize              = Cursor(C.kCursor_NorthResize)
	CursorNorthEastResize          = Cursor(C.kCursor_NorthEastResize)
	CursorNorthWestResize          = Cursor(C.kCursor_NorthWestResize)
	CursorSouthResize              = Cursor(C.kCursor_SouthResize)
	CursorSouthEastResize          = Cursor(C.kCursor_SouthEastResize)
	CursorSouthWestResize          = Cursor(C.kCursor_SouthWestResize)
	CursorWestResize               = Cursor(C.kCursor_WestResize)
	CursorNorthSouthResize         = Cursor(C.kCursor_NorthSouthResize)
	CursorEastWestResize           = Cursor(C.kCursor_EastWestResize)
	CursorNorthEastSouthWestResiz  = Cursor(C.kCursor_NorthEastSouthWestResize)
	CursorNorthWestSouthEastResize = Cursor(C.kCursor_NorthWestSouthEastResize)
	CursorColumnResize             = Cursor(C.kCursor_ColumnResize)
	CursorRowResize                = Cursor(C.kCursor_RowResize)
	CursorMiddlePanning            = Cursor(C.kCursor_MiddlePanning)
	CursorEastPanning              = Cursor(C.kCursor_EastPanning)
	CursorNorthPanning             = Cursor(C.kCursor_NorthPanning)
	CursorNorthEastPanning         = Cursor(C.kCursor_NorthEastPanning)
	CursorNorthWestPanning         = Cursor(C.kCursor_NorthWestPanning)
	CursorSouthPanning             = Cursor(C.kCursor_SouthPanning)
	CursorSouthEastPanning         = Cursor(C.kCursor_SouthEastPanning)
	CursorSouthWestPanning         = Cursor(C.kCursor_SouthWestPanning)
	CursorWestPanning              = Cursor(C.kCursor_WestPanning)
	CursorMove                     = Cursor(C.kCursor_Move)
	CursorVerticalText             = Cursor(C.kCursor_VerticalText)
	CursorCell                     = Cursor(C.kCursor_Cell)
	CursorContextMenu              = Cursor(C.kCursor_ContextMenu)
	CursorAlias                    = Cursor(C.kCursor_Alias)
	CursorProgress                 = Cursor(C.kCursor_Progress)
	CursorNoDrop                   = Cursor(C.kCursor_NoDrop)
	CursorCopy                     = Cursor(C.kCursor_Copy)
	CursorNone                     = Cursor(C.kCursor_None)
	CursorNotAllowed               = Cursor(C.kCursor_NotAllowed)
	CursorZoomIn                   = Cursor(C.kCursor_ZoomIn)
	CursorZoomOut                  = Cursor(C.kCursor_ZoomOut)
	CursorGrab                     = Cursor(C.kCursor_Grab)
	CursorGrabbing                 = Cursor(C.kCursor_Grabbing)
	CursorCustom                   = Cursor(C.kCursor_Custom)
)

Variables

This section is empty.

Functions

func DeviceScaleHint

func DeviceScaleHint(value float64) configOption

func EnableImages

func EnableImages(enabled bool) configOption

func EnableJavascript

func EnableJavascript(enabled bool) configOption

func FontFamilyFixed

func FontFamilyFixed(fontName string) configOption

func FontFamilySansSerif

func FontFamilySansSerif(fontName string) configOption

func FontFamilySerif

func FontFamilySerif(fontName string) configOption

func FontFamilyStandard

func FontFamilyStandard(fontName string) configOption

func UseBGRA

func UseBGRA(enabled bool) configOption

func UserAgent

func UserAgent(agent string) configOption

func UserStylesheet

func UserStylesheet(css string) configOption

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App is the main application object

func NewApp

func NewApp() *App

NewApp creates the App singleton.

Note: You should only create one of these per application lifetime.

func (*App) Destroy

func (app *App) Destroy()

Destroy destroys the App instance.

func (*App) IsRunning

func (app *App) IsRunning() bool

IsRunning checks whether or not the App is running.

func (*App) NewWindow

func (app *App) NewWindow(width, height uint, fullscreen bool, title string) *Window

NewWindow create a new window and sets it as the main application window.

func (*App) OnUpdate

func (app *App) OnUpdate(cb func())

OnUpdate sets a callback for whenever the App updates. You should update all app logic here.

func (*App) Quit

func (app *App) Quit()

Quit the application.

func (*App) Run

func (app *App) Run()

Run runs the main loop.

func (*App) Window

func (app *App) Window() *Window

Window gets the main application window.

type Config

type Config struct {
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(options ...configOption) *Config

Create config with default values (see <Ultralight/platform/Config.h>).

func (*Config) Destroy

func (c *Config) Destroy()

Destroy config.

func (*Config) DeviceScaleHint

func (c *Config) DeviceScaleHint(value float64)

Set the amount that the application DPI has been scaled, used for scaling device coordinates to pixels and oversampling raster shapes. (Default = 1.0)

func (*Config) EnableImages

func (c *Config) EnableImages(enabled bool)

Set whether images should be enabled (Default = True)

func (*Config) EnableJavascript

func (c *Config) EnableJavascript(enabled bool)

Set whether JavaScript should be eanbled (Default = True)

func (*Config) FontFamilyFixed

func (c *Config) FontFamilyFixed(fontName string)

Set default font-family to use for fixed fonts, eg <pre> and <code>. (Default = Courier New)

func (*Config) FontFamilySansSerif

func (c *Config) FontFamilySansSerif(fontName string)

Set default font-family to use for sans-serif fonts. (Default = Arial)

func (*Config) FontFamilySerif

func (c *Config) FontFamilySerif(fontName string)

Set default font-family to use for serif fonts. (Default = Times New Roman)

func (*Config) FontFamilyStandard

func (c *Config) FontFamilyStandard(fontName string)

Set default font-family to use (Default = Times New Roman)

func (*Config) UseBGRAForOffscreenRendering

func (c *Config) UseBGRAForOffscreenRendering(enabled bool)

Set whether we should use BGRA byte order (instead of RGBA) for View bitmaps. (Default = False)

func (*Config) UserAgent

func (c *Config) UserAgent(agent string)

Set user agent string. (See <Ultralight/platform/Config.h> for the default)

func (*Config) UserStylesheet

func (c *Config) UserStylesheet(css string)

Set user stylesheet (CSS). (Default = Empty)

type Cursor

type Cursor int

type FunctionCallback

type FunctionCallback func(function, this *JSObject, args ...*JSValue) *JSValue

type JSContext

type JSContext struct {
	// contains filtered or unexported fields
}

JSContext

func (*JSContext) Boolean

func (ctx *JSContext) Boolean(v bool) JSValue

Creates a JavaScript value of the boolean type.

func (*JSContext) FunctionCallback

func (ctx *JSContext) FunctionCallback(name string, cb FunctionCallback) *JSValue

Convenience method for creating a JavaScript function with a given callback as its implementation.

func (*JSContext) GlobalContext

func (ctx *JSContext) GlobalContext() JSGlobalContext

Gets the global object of a JavaScript execution context.

func (*JSContext) GlobalObject

func (ctx *JSContext) GlobalObject() *JSObject

Gets the global object of a JavaScript execution context.

func (*JSContext) JSValue

func (ctx *JSContext) JSValue(v interface{}) JSValue

func (*JSContext) Null

func (ctx *JSContext) Null() JSValue

Creates a JavaScript value of the null type.

func (*JSContext) Number

func (ctx *JSContext) Number(v float64) JSValue

Creates a JavaScript value of the number type.

func (*JSContext) String

func (ctx *JSContext) String(v string) JSValue

Creates a JavaScript value of the string type.

func (*JSContext) Undefined

func (ctx *JSContext) Undefined() JSValue

Creates a JavaScript value of the undefined type.

type JSGlobalContext

type JSGlobalContext struct {
	// contains filtered or unexported fields
}

JSGlobalContext

type JSObject

type JSObject struct {
	// contains filtered or unexported fields
}

JSObject

func (*JSObject) Call

func (o *JSObject) Call(this *JSObject, args ...interface{}) *JSValue

Calls an object as a function.

func (*JSObject) IsFunction

func (o *JSObject) IsFunction() bool

Tests whether an object can be called as a function.

func (*JSObject) Property

func (o *JSObject) Property(name string) *JSValue

Gets a property from an object.

func (*JSObject) PropertyNames

func (o *JSObject) PropertyNames() []string

Gets the names of an object's enumerable properties.

func (*JSObject) SetProperty

func (o *JSObject) SetProperty(name string, value *JSValue)

Sets a property on an object.

func (*JSObject) SetPropertyValue

func (o *JSObject) SetPropertyValue(name string, value interface{})

type JSType

type JSType int

type JSValue

type JSValue struct {
	// contains filtered or unexported fields
}

JSValue

func (*JSValue) Boolean

func (v *JSValue) Boolean() bool

Converts a JavaScript value to boolean and returns the resulting boolean.

func (*JSValue) IsArray

func (v *JSValue) IsArray() bool

Tests whether a JavaScript value is an array.

func (*JSValue) IsBoolean

func (v *JSValue) IsBoolean() bool

Tests whether a JavaScript value's type is the boolean type.

func (*JSValue) IsDate

func (v *JSValue) IsDate() bool

Tests whether a JavaScript value is a date.

func (*JSValue) IsFunction

func (v *JSValue) IsFunction() bool

func (*JSValue) IsNull

func (v *JSValue) IsNull() bool

Tests whether a JavaScript value's type is the null type.

func (*JSValue) IsNumber

func (v *JSValue) IsNumber() bool

Tests whether a JavaScript value's type is the number type.

func (*JSValue) IsObject

func (v *JSValue) IsObject() bool

Tests whether a JavaScript value's type is the object type.

func (*JSValue) IsString

func (v *JSValue) IsString() bool

Tests whether a JavaScript value's type is the string type.

func (*JSValue) IsUndefined

func (v *JSValue) IsUndefined() bool

Tests whether a JavaScript value's type is the undefined type.

func (*JSValue) Number

func (v *JSValue) Number() float64

Converts a JavaScript value to number and returns the resulting number.

func (*JSValue) Object

func (v *JSValue) Object() *JSObject

Converts a JavaScript value to object and returns the resulting object.

func (*JSValue) String

func (v *JSValue) String() string

Converts a JavaScript value to string and copies the result into a JavaScript string.

func (*JSValue) Type

func (v *JSValue) Type() JSType

Returns a JavaScript value's type.

type MessageLevel

type MessageLevel int

type MessageSource

type MessageSource int

type Overlay

type Overlay struct {
	// contains filtered or unexported fields
}

func (*Overlay) Destroy

func (ovl *Overlay) Destroy()

Destroy an overlay.

func (*Overlay) Focus

func (ovl *Overlay) Focus()

Grant this overlay exclusive keyboard focus.

func (*Overlay) HasFocus

func (ovl *Overlay) HasFocus() bool

Whether or not an overlay has keyboard focus.

func (*Overlay) Hide

func (ovl *Overlay) Hide()

Hide the overlay (will no longer be drawn)

func (*Overlay) IsHidden

func (ovl *Overlay) IsHidden() bool

Whether or not the overlay is hidden (not drawn).

func (*Overlay) Resize

func (ovl *Overlay) Resize(width, height uint)

Resize resizes the overlay (and underlying View). Dimensions should be specified in device coordinates.

func (*Overlay) Show

func (ovl *Overlay) Show()

Show the overlay.

func (*Overlay) Unfocus

func (ovl *Overlay) Unfocus()

Remove keyboard focus.

func (*Overlay) View

func (ovl *Overlay) View() *View

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

func NewRenderer

func NewRenderer(c *Config) *Renderer

Create renderer (create this only once per application lifetime).

func (*Renderer) Destroy

func (r *Renderer) Destroy()

Destroy renderer.

func (*Renderer) NewView

func (r *Renderer) NewView(width, height uint, transparent bool) *View

Create a View with certain size (in device coordinates).

func (*Renderer) Render

func (r *Renderer) Render()

Render all active Views to their respective bitmaps.

func (*Renderer) Update

func (r *Renderer) Update()

Update timers and dispatch internal callbacks (JavaScript and network)

type View

type View struct {
	// contains filtered or unexported fields
}

View is the window "content"

func (*View) CanGoBack

func (view *View) CanGoBack() bool

CanGoBack checks if can navigate backwards in history

func (*View) CanGoForward

func (view *View) CanGoForward() bool

CanGoForward checks if can navigate forwards in history

func (*View) Destroy

func (v *View) Destroy()

Destroy a View.

func (*View) EvaluateScript

func (view *View) EvaluateScript(script string) *JSValue

EvaluateScript evaluates a raw string of JavaScript and return result

func (*View) GoBack

func (view *View) GoBack()

GoBack navigates backwards in history

func (*View) GoForward

func (view *View) GoForward()

GoForward navigates forwards in history

func (*View) GoToHistoryOffset

func (view *View) GoToHistoryOffset(offset int)

GoToHistoryOffset navigates to arbitrary offset in history

func (*View) IsLoading

func (view *View) IsLoading() bool

IsLoading Checks if main frame is loading.

func (*View) JSContext

func (view *View) JSContext() *JSContext

JSContext gets the page's JSContext for use with JavaScriptCore API

func (*View) LoadHTML

func (view *View) LoadHTML(html string)

LoadHTML loads a raw string of html

func (*View) LoadURL

func (view *View) LoadURL(url string)

LoadURL loads a URL into main frame

func (*View) OnBeginLoading

func (view *View) OnBeginLoading(cb func())

Set callback for when the page begins loading new URL into main frame

func (*View) OnChangeCursor

func (view *View) OnChangeCursor(cb func(Cursor))

Set callback for when the mouse cursor changes

func (*View) OnChangeTitle

func (view *View) OnChangeTitle(cb func(string))

Set callback for when the page title changes

func (*View) OnChangeURL

func (view *View) OnChangeURL(cb func(string))

Set callback for when the page URL changes

func (*View) OnConsoleMessage

func (view *View) OnConsoleMessage(cb func(source MessageSource, level MessageLevel,
	message string, line uint, col uint, sourceID string))

Set callback for when a message is added to the console (useful for JavaScript / network errors and debugging)

func (*View) OnDOMReady

func (view *View) OnDOMReady(cb func())

Set callback for when all JavaScript has been parsed and the document is ready. This is the best time to make initial JavaScript calls to your page.

func (*View) OnFinishLoading

func (view *View) OnFinishLoading(cb func())

Set callback for when the page finishes loading new URL into main frame

func (*View) OnUpdateHistory

func (view *View) OnUpdateHistory(cb func())

Set callback for when the history (back/forward state) is modified

func (*View) Reload

func (view *View) Reload()

Reload reloads the current page

func (*View) Stop

func (view *View) Stop()

Stop stops all page loads

func (*View) Title

func (view *View) Title() string

Title returns the current title.

func (*View) URL

func (view *View) URL() string

URL returns the current URL.

func (*View) WriteToPNG

func (v *View) WriteToPNG(filename string) bool

Write bitmap to a PNG on disk.

type Window

type Window struct {
	// contains filtered or unexported fields
}

Window is an application window

func (*Window) Close

func (win *Window) Close()

Close closes the window.

func (*Window) Destroy

func (win *Window) Destroy()

Destroy destroys the window.

func (*Window) Focus

func (win *Window) Focus()

Grant this overlay exclusive keyboard focus.

func (*Window) HasFocus

func (win *Window) HasFocus() bool

Whether or not an overlay has keyboard focus.

func (*Window) Height

func (win *Window) Height() uint

func (*Window) Hide

func (win *Window) Hide()

Hide the overlay (will no longer be drawn)

func (*Window) IsFullscreen

func (win *Window) IsFullscreen() bool

IsFullscreen checks whether or not a window is fullscreen.

func (*Window) IsHidden

func (win *Window) IsHidden() bool

Whether or not the overlay is hidden (not drawn).

func (*Window) NOverlay

func (win *Window) NOverlay() int

func (*Window) NewOverlay

func (win *Window) NewOverlay(width, height uint, x, y int) *Overlay

Create a new Overlay.

func (*Window) OnClose

func (win *Window) OnClose(cb func())

OnClose sets a callback to be notified when a window closes.

func (*Window) OnResize

func (win *Window) OnResize(cb func(width, height uint))

OnResize sets a callback to be notified when a window resizes (parameters are passed back in device coordinates).

func (*Window) Overlay

func (win *Window) Overlay(i int) *Overlay

func (*Window) RemoveOverlay

func (win *Window) RemoveOverlay(i int)

func (*Window) Resize

func (win *Window) Resize(width, height uint)

Resize resizes the window (and underlying View). Dimensions should be specified in device coordinates.

func (*Window) SetCursor

func (win *Window) SetCursor(cursor Cursor)

func (*Window) SetTitle

func (win *Window) SetTitle(title string)

SetTitle sets the window title.

func (*Window) Show

func (win *Window) Show()

Show the overlay.

func (*Window) Unfocus

func (win *Window) Unfocus()

Remove keyboard focus.

func (*Window) View

func (win *Window) View() *View

View gets the underlying View.

func (*Window) Width

func (win *Window) Width() uint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL