GUI packages, examples, and documentation for building desktop applications with Go and web technologies. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
// Package docs provides documentation window management.
|
|
package docs
|
|
|
|
import (
|
|
"github.com/host-uk/core-gui/pkg/core"
|
|
"github.com/host-uk/core-gui/pkg/display"
|
|
)
|
|
|
|
// Service manages documentation windows.
|
|
type Service struct {
|
|
core *core.Core
|
|
baseURL string
|
|
}
|
|
|
|
// Options configures the docs service.
|
|
type Options struct {
|
|
BaseURL string
|
|
}
|
|
|
|
// New creates a new docs service.
|
|
func New(opts Options) (*Service, error) {
|
|
return &Service{
|
|
baseURL: opts.BaseURL,
|
|
}, nil
|
|
}
|
|
|
|
// SetCore sets the core reference for accessing other services.
|
|
func (s *Service) SetCore(c *core.Core) {
|
|
s.core = c
|
|
}
|
|
|
|
// SetBaseURL sets the base URL for documentation.
|
|
func (s *Service) SetBaseURL(url string) {
|
|
s.baseURL = url
|
|
}
|
|
|
|
// OpenDocsWindow opens a documentation window at the specified path.
|
|
// The path is appended to the base URL to form the full documentation URL.
|
|
func (s *Service) OpenDocsWindow(path string) error {
|
|
url := s.baseURL
|
|
if path != "" {
|
|
if url != "" && url[len(url)-1] != '/' && path[0] != '/' {
|
|
url += "/"
|
|
}
|
|
url += path
|
|
}
|
|
|
|
// Fire an ACTION to request a window from the display service
|
|
return s.core.ACTION(display.ActionOpenWindow{
|
|
WebviewWindowOptions: display.Window{
|
|
Name: "docs-window",
|
|
Title: "Documentation",
|
|
URL: url,
|
|
Width: 1200,
|
|
Height: 800,
|
|
},
|
|
})
|
|
}
|