v0.20.0 c741a39

deps.go RawHistoryFolder

1// Package ui provides the GTK4 presentation layer for the dumber browser.
2package ui
3
4import (
5	"context"
6
7	"github.com/bnema/dumber/internal/application/port"
8	"github.com/bnema/dumber/internal/application/usecase"
9	"github.com/bnema/dumber/internal/domain/repository"
10	"github.com/bnema/dumber/internal/infrastructure/config"
11	"github.com/bnema/dumber/internal/infrastructure/favicon"
12	"github.com/bnema/dumber/internal/infrastructure/filtering"
13	"github.com/bnema/dumber/internal/infrastructure/webkit"
14	"github.com/bnema/dumber/internal/ui/theme"
15)
16
17// Dependencies holds all injected dependencies for the UI layer.
18// This struct is created once at startup and passed to UI components.
19type Dependencies struct {
20	// Core context and configuration
21	Ctx        context.Context
22	Config     *config.Config
23	InitialURL string // URL to open on startup (optional)
24
25	// Theme management
26	Theme *theme.Manager
27
28	// WebKit infrastructure
29	WebContext    *webkit.WebKitContext
30	Pool          *webkit.WebViewPool
31	Factory       port.WebViewFactory
32	Settings      *webkit.SettingsManager
33	Injector      *webkit.ContentInjector
34	MessageRouter *webkit.MessageRouter
35
36	// Repositories
37	HistoryRepo  repository.HistoryRepository
38	FavoriteRepo repository.FavoriteRepository
39	ZoomRepo     repository.ZoomRepository
40	FilterRepo   repository.ContentWhitelistRepository
41
42	// Use Cases
43	TabsUC      *usecase.ManageTabsUseCase
44	PanesUC     *usecase.ManagePanesUseCase
45	NavigateUC  *usecase.NavigateUseCase
46	ZoomUC      *usecase.ManageZoomUseCase
47	FavoritesUC *usecase.ManageFavoritesUseCase
48	HistoryUC   *usecase.SearchHistoryUseCase
49	CopyURLUC   *usecase.CopyURLUseCase
50
51	// Infrastructure Adapters
52	Clipboard      port.Clipboard
53	FaviconService *favicon.Service
54	FilterManager  *filtering.Manager
55}
56
57// Validate checks that all required dependencies are set.
58func (d *Dependencies) Validate() error {
59	if d.Ctx == nil {
60		return ErrMissingDependency("Ctx")
61	}
62	if d.Config == nil {
63		return ErrMissingDependency("Config")
64	}
65	// WebKit dependencies are optional for testing without WebViews
66	// Use cases are optional - can be nil if not needed
67	return nil
68}
69
70// DependencyError indicates a missing required dependency.
71type DependencyError struct {
72	Name string
73}
74
75func (e DependencyError) Error() string {
76	return "missing required dependency: " + e.Name
77}
78
79// ErrMissingDependency creates a new DependencyError.
80func ErrMissingDependency(name string) error {
81	return DependencyError{Name: name}
82}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close