v0.8.0 0fa6785

navigation.go RawHistoryFolder

1package control
2
3import (
4	"context"
5	"log"
6	"os"
7
8	"github.com/bnema/dumber/pkg/webkit"
9	"github.com/bnema/dumber/services"
10)
11
12// NavigationController manages navigation functionality
13type NavigationController struct {
14	parserService  *services.ParserService
15	browserService *services.BrowserService
16	webView        *webkit.WebView
17	zoomController *ZoomController
18}
19
20// NewNavigationController creates a new navigation controller
21func NewNavigationController(
22	parserService *services.ParserService,
23	browserService *services.BrowserService,
24	webView *webkit.WebView,
25	zoomController *ZoomController,
26) *NavigationController {
27	return &NavigationController{
28		parserService:  parserService,
29		browserService: browserService,
30		webView:        webView,
31		zoomController: zoomController,
32	}
33}
34
35// NavigateToURL parses input and navigates to the resulting URL
36func (n *NavigationController) NavigateToURL(input string) error {
37	ctx := context.Background()
38	result, err := n.parserService.ParseInput(ctx, input)
39	if err != nil {
40		return err
41	}
42
43	// Record navigation in browser service
44	if _, navErr := n.browserService.Navigate(ctx, result.URL); navErr != nil {
45		log.Printf("Warning: failed to navigate to %s: %v", result.URL, navErr)
46	}
47
48	// Load URL in WebView
49	if err := n.webView.LoadURL(result.URL); err != nil {
50		return err
51	}
52
53	// Apply zoom for the new URL
54	n.zoomController.ApplyZoomForURL(result.URL)
55
56	return nil
57}
58
59// HandleBrowseCommand processes the browse command line argument
60func (n *NavigationController) HandleBrowseCommand() {
61	if len(os.Args) >= 3 && os.Args[1] == "browse" {
62		log.Printf("Browse command detected: %s", os.Args[2])
63		ctx := context.Background()
64		result, err := n.parserService.ParseInput(ctx, os.Args[2])
65		if err == nil {
66			log.Printf("Parsed input → URL: %s", result.URL)
67			if _, navErr := n.browserService.Navigate(ctx, result.URL); navErr != nil {
68				log.Printf("Warning: failed to navigate to %s: %v", result.URL, navErr)
69			}
70			if n.webView != nil {
71				log.Printf("Loading URL in WebView: %s", result.URL)
72				if err := n.webView.LoadURL(result.URL); err != nil {
73					log.Printf("Warning: failed to load URL: %v", err)
74				}
75				n.zoomController.ApplyZoomForURL(result.URL)
76			}
77		}
78	}
79}

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