v0.13.0 976176a

clipboard.go RawHistoryFolder

1package control
2
3import (
4	"log"
5
6	"github.com/bnema/dumber/pkg/clipboard"
7	"github.com/bnema/dumber/pkg/webkit"
8)
9
10// ClipboardController handles clipboard operations
11type ClipboardController struct {
12	webView *webkit.WebView
13}
14
15// NewClipboardController creates a new clipboard controller
16func NewClipboardController(webView *webkit.WebView) *ClipboardController {
17	return &ClipboardController{
18		webView: webView,
19	}
20}
21
22// CopyCurrentURL copies the current WebView URL to the clipboard
23func (c *ClipboardController) CopyCurrentURL() {
24	log.Printf("Shortcut: Copy URL")
25	currentURL := c.webView.GetCurrentURL()
26	if currentURL == "" {
27		log.Printf("No URL to copy")
28		c.showToast("No URL to copy", "error")
29		return
30	}
31
32	if err := clipboard.CopyToClipboard(currentURL); err != nil {
33		log.Printf("Failed to copy URL to clipboard: %v", err)
34		c.showToast("Failed to copy URL", "error")
35	} else {
36		log.Printf("URL copied to clipboard: %s", currentURL)
37		c.showToast("URL copied to clipboard", "success")
38	}
39}
40
41func (c *ClipboardController) showToast(message, toastType string) {
42	if c == nil || c.webView == nil {
43		return
44	}
45
46	detail := map[string]any{
47		"message":  message,
48		"duration": 2000,
49	}
50	if toastType != "" {
51		detail["type"] = toastType
52	}
53
54	if err := c.webView.DispatchCustomEvent("dumber:showToast", detail); err != nil {
55		log.Printf("Failed to dispatch toast event: %v", err)
56	}
57}
58
59// Detach releases the WebView reference when the pane is closed.
60func (c *ClipboardController) Detach() {
61	if c == nil {
62		return
63	}
64	c.webView = nil
65}

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