browser_popup_window.go RawHistoryFolder

1package ui
2
3import (
4	"context"
5	"fmt"
6	"sync"
7
8	"github.com/bnema/dumber/internal/application/port"
9	"github.com/bnema/dumber/internal/domain/entity"
10	"github.com/bnema/dumber/internal/ui/coordinator/content"
11)
12
13var showPopupBrowserWindow = func(bw *browserWindow) {
14	if bw != nil && bw.mainWindow != nil {
15		bw.mainWindow.Show()
16	}
17}
18
19// openPopupBrowserWindow adopts the exact related WebView created for a
20// browsing-context request into a complete Dumber browser window.
21func (a *App) openPopupBrowserWindow(ctx context.Context, input content.BrowserWindowInput) (content.BrowserWindowResult, error) {
22	if input.PopupPane == nil || input.PopupWebView == nil {
23		return content.BrowserWindowResult{}, fmt.Errorf("popup browser window requires pane and webview")
24	}
25	bw, err := a.createEmptyBrowserWindow(ctx)
26	if err != nil {
27		return content.BrowserWindowResult{}, err
28	}
29	tab, err := a.tabCoord.CreateWithPane(
30		ctx,
31		a.ensureTabTargetForBrowserWindow(bw),
32		input.PopupPane,
33		input.PopupWebView,
34		input.TargetURI,
35	)
36	if err != nil {
37		a.cleanupEjectTargetWindow(bw)
38		return content.BrowserWindowResult{}, err
39	}
40	a.setBrowserWindowForTab(tab.ID, bw)
41	a.activateBrowserWindow(bw)
42
43	var showOnce sync.Once
44	show := func() {
45		showOnce.Do(func() { showPopupBrowserWindow(bw) })
46	}
47	if lifecycle, ok := input.PopupWebView.(port.PopupLifecycleCapable); ok {
48		lifecycle.SetOnClose(func() { a.closeAdoptedPopupTab(context.Background(), bw, tab.ID) })
49		if !input.Ready {
50			lifecycle.SetOnReadyToShow(show)
51			return content.BrowserWindowResult{WindowID: bw.id}, nil
52		}
53	}
54	show()
55	return content.BrowserWindowResult{WindowID: bw.id}, nil
56}
57
58func (a *App) closeAdoptedPopupTab(ctx context.Context, bw *browserWindow, tabID entity.TabID) {
59	if a == nil || bw == nil || bw.tabs == nil || bw.tabs.Find(tabID) == nil {
60		return
61	}
62	bw.tabs.SetActive(tabID)
63	_ = a.tabCoord.Close(ctx, a.ensureTabTargetForBrowserWindow(bw))
64}

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