Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions desktop/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ toolchain go1.27.3
require (
github.com/creack/pty v1.1.24
github.com/tailscale/hujson v0.0.0-20260727124030-b80ff77dac4f
github.com/vivaui/viva v0.6.4-0.20261114064951-b63e4a0994d3
github.com/vivaui/viva v0.6.5-0.20261115063318-1fc84f6ff1d3
github.com/zalando/go-keyring v0.2.8
golang.org/x/sys v0.50.0
)
Expand All @@ -20,4 +20,4 @@ require (
github.com/godbus/dbus/v5 v5.2.2 // indirect
)

replace github.com/vivaui/viva => github.com/Lithe-IDEA/viva v0.6.3-0.20261114132607-4829f2bdde18
replace github.com/vivaui/viva => github.com/Lithe-IDEA/viva v0.6.5-0.20261115071107-27ad1d78b978
6 changes: 4 additions & 2 deletions desktop/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/Lithe-IDEA/viva v0.6.3-0.20261114132607-4829f2bdde18 h1:2SRDSXAk+1fHMJ6B8lTlcPrPoz0zGm0rJXXowlOgDFE=
github.com/Lithe-IDEA/viva v0.6.3-0.20261114132607-4829f2bdde18/go.mod h1:e9In6+J77G7B9ow4enZ2FSOFh7U3q4cQ5iJr3Qn/Olk=
github.com/Lithe-IDEA/viva v0.6.5-0.20261115071107-27ad1d78b978 h1:h7klV5KTgiPRDE0zFUFk6ky32ZUBcf9yEATOXKYcg1o=
github.com/Lithe-IDEA/viva v0.6.5-0.20261115071107-27ad1d78b978/go.mod h1:e9In6+J77G7B9ow4enZ2FSOFh7U3q4cQ5iJr3Qn/Olk=
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMFLdQ=
Expand All @@ -14,6 +14,8 @@ github.com/gabstv/go-bsdiff v1.0.5 h1:g29MC/38Eaig+iAobW10/CiFvPtin8U3Jj4yNLcNG9
github.com/gabstv/go-bsdiff v1.0.5/go.mod h1:/Zz6GK+/f/TMylRtVaW3uwZlb0FZITILfA0q12XKGwg=
github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ=
github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=
github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
37 changes: 4 additions & 33 deletions desktop/internal/workbench/debug_menus.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/1lck/Lithe-IDEA/desktop/internal/core"
"github.com/1lck/Lithe-IDEA/desktop/internal/i18n"
"github.com/vivaui/viva/app"
"github.com/vivaui/viva/gfx"
"github.com/vivaui/viva/ui"
)

Expand All @@ -22,15 +21,6 @@ import (
// others. Each item acts
// through the action the panel's own controls run.

// debugVarMenu is the open context menu of one row of the variables tree. A tree row is
// painted by the tree, so its menu is opened from the right-click on the row and declared
// after the tree.
type debugVarMenu struct {
open bool
at ui.Rect
node *debugVarNode
}

// copyDebugText puts one value the debugger shows on the clipboard.
func (a *App) copyDebugText(action, text string) {
a.performed(action, surfaceContextMenu)
Expand Down Expand Up @@ -150,32 +140,13 @@ func (a *App) debugInstructionMenu(c ui.C, row ui.Box, p *project, instruction c
})
}

// debugVariablePointer opens the menu of variable row i when the row is right-clicked.
func (a *App) debugVariablePointer(c ui.C, p *project, i int, node *debugVarNode) {
v := &p.debug.vars
canvas := c.Canvas()
if node.moreFor != nil || canvas == nil {
return
}
event, ok := canvas.PointerOn(v.tree.RowID(i))
if !ok || event.Kind != gfx.PointerDown || event.Button != gfx.PointerButtonSecondary {
return
}
canvas.Consume()
v.menu = debugVarMenu{open: true, at: ui.Rect{X: event.X, Y: event.Y}, node: node}
}

// debugVariableMenu declares the menu of the variable right-clicked while it is open: Set
// Value selects the row, which shows the field that gives it a new value; Break on Field
// debugVariableMenu is the menu of one variable, opened from its name or anywhere on its row:
// Set Value selects the row, which shows the field that gives it a new value; Break on Field
// Access watches it; Add to Watches evaluates its expression at each stop.
func (a *App) debugVariableMenu(c ui.C, p *project) {
func (a *App) debugVariableMenu(c ui.C, name ui.Box, p *project, node *debugVarNode) {
d := &p.debug
v := &d.vars
if !v.menu.open {
return
}
node := v.menu.node
ui.MenuAt(c.Key("debug-var-menu"), v.menu.at.X, v.menu.at.Y, &v.menu.open, func(menu *ui.MenuItems) {
ui.ContextMenu(c, name, func(menu *ui.MenuItems) {
lang := a.language()
menu.WidthRange(180, 260)
edits := canEditDebugVariable(d, node)
Expand Down
9 changes: 4 additions & 5 deletions desktop/internal/workbench/debug_sections_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,12 @@ func (a *App) debugVariablesTree(c ui.C, p *project) {
rows := v.flatten()
ui.Tree(c, &v.tree, len(rows), v.label, func(i int) {
node := rows[i]
a.debugVariablePointer(c, p, i, node)
if node.moreFor != nil {
a.debugVariableStatusRow(c, node, t.LoadingVariables, t.LoadMore)
return
}
a.debugVariableRow(c, node)
a.debugVariableRow(c, p, v.tree.RowID(i), node)
}).Scrollbars().Grow(1).FillWidth()
a.debugVariableMenu(c, p)
if i, ok := v.tree.Toggled(); ok && i < len(rows) {
node := rows[i]
c.After(func() {
Expand All @@ -184,7 +182,7 @@ func (a *App) debugVariablesTree(c ui.C, p *project) {

// debugVariableRow declares one variable as IntelliJ IDEA writes it, "name = {type} value", after
// an icon that tells a value with children from a plain one. A scope is its name alone.
func (a *App) debugVariableRow(c ui.C, node *debugVarNode) {
func (a *App) debugVariableRow(c ui.C, p *project, row gfx.ID, node *debugVarNode) {
icon := icons.Variable
switch {
case node.scope:
Expand All @@ -193,7 +191,8 @@ func (a *App) debugVariableRow(c ui.C, node *debugVarNode) {
icon = icons.Braces
}
ui.Icon(c, icon).Size(treelist.Icon, treelist.Icon).Shrink(0).Color(a.colors.Subtle)
ui.Text(c, node.name).Shrink(0).FontSize(12.5).Color(treelist.Text(a.colors.Dark)).Weight(gfx.WeightMedium)
name := ui.Text(c, node.name).Shrink(0).FontSize(12.5).Color(treelist.Text(a.colors.Dark)).Weight(gfx.WeightMedium).LabelFor(row)
a.debugVariableMenu(c, name, p, node)
if node.scope || (node.value == "" && node.typeName == "") {
return
}
Expand Down
2 changes: 0 additions & 2 deletions desktop/internal/workbench/debug_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ type debugVariables struct {
// selected is the variable row the edit field acts on.
selected *debugVarNode
edit debugVariableEdit
// menu is the context menu of the row right-clicked.
menu debugVarMenu
// json shows the loaded tree as JSON instead.
json bool
// registersView shows the registers scope alone, as the Registers tab does; the Variables tab lists
Expand Down
2 changes: 1 addition & 1 deletion desktop/internal/workbench/editor_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (a *App) documentView(c ui.C, group string, d *document) {
if p := a.project; p != nil && !d.virtual {
ui.ContextMenu(c.Key("menu"+name), box, a.editorMenuItems(c, p, d))
at := d.actionPanel.menuAt
ui.MenuAt(c.Key("lanemenu"+name), at.X, at.Y+at.Height, &d.actionPanel.menuOpen, a.editorActionLaneMenu(c, p, d))
ui.ContextMenuAt(c.Key("lanemenu"+name), box, &d.actionPanel.menuOpen, gfx.Point{X: at.X, Y: at.Y + at.Height}, a.editorActionLaneMenu(c, p, d))
a.gitGutterPeek(c, p, d, box)
}
}
Expand Down
5 changes: 3 additions & 2 deletions desktop/internal/workbench/filetree.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ type fileTree struct {
// removal is the Delete dialog, open while the user chooses between the trash and deleting
// for good (filetree_batch.go).
removal treeRemoval
// rowRefs maps the hit identity of each row the last paint declared to its node, so a drag
// or drop finds the paths it names (filetree_dnd.go); clip is the cut or copied items.
// rowRefs maps the identity of each row the last paint declared (view.RowID, which the row's
// name labels) to its node, so a drag or drop finds the paths it names (filetree_dnd.go);
// clip is the cut or copied items.
rowRefs map[gfx.ID]treeRowRef
clip treeClipboard
// failed is why the root could not be listed; empty otherwise.
Expand Down
4 changes: 0 additions & 4 deletions desktop/internal/workbench/filetree_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,6 @@ func (h *harness) treeRowOwned(id gfx.ID) bool {
// A click on a file would open it at once, so a click on an empty folder gives the tree the
// keyboard and the arrows pick the file.
func TestProjectTreeOpenSelectedFollowsTheKeymap(t *testing.T) {
// The pinned Viva leaves a Tree's focused rows outside the box Tree returns, so no
// Shortcut on the project tree acts while a row has the focus. Remove this skip with the
// pin that carries Lithe-IDEA/viva#9 (vivaui/viva#234).
t.Skip("needs Box.Shortcut to cover Tree rows: Lithe-IDEA/viva#9")
root := t.TempDir()
if err := os.Mkdir(filepath.Join(root, "empty"), 0o700); err != nil {
t.Fatal(err)
Expand Down
16 changes: 9 additions & 7 deletions desktop/internal/workbench/filetree_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/1lck/Lithe-IDEA/desktop/internal/i18n"
"github.com/1lck/Lithe-IDEA/desktop/internal/wslpath"
"github.com/vivaui/viva/app"
"github.com/vivaui/viva/gfx"
"github.com/vivaui/viva/ui"
)

Expand Down Expand Up @@ -49,16 +50,17 @@ type treePrompt struct {
err string
}

// projectTreeMenu declares the context menu of one row. A row of a folder or the root can make
// files and folders; any row but the root can be renamed or deleted. The Git items appear only
// for a file the last status lists as changed.
func (a *App) projectTreeMenu(c ui.C, p *project, n *treeNode, target ui.Box) {
// projectTreeMenu makes the name of row the label of that row and declares the row's context
// menu on it, so the menu opens from anywhere on the row, and any row but the root is dragged
// from anywhere on it too. A row of a folder or the root can make files and folders; any row
// but the root can be renamed or deleted. The Git items appear only for a file the last status
// lists as changed.
func (a *App) projectTreeMenu(c ui.C, p *project, row gfx.ID, n *treeNode, target ui.Box) {
language := a.language()
root := n == p.tree.root
rowID := ui.ID(c.Key("treectx/" + n.path))
target.Hit(rowID, n.name)
target.LabelFor(row)
if !root {
p.tree.rememberRow(rowID, n)
p.tree.rememberRow(row, n)
target.DragSource(&a.dnd.tree)
}
if n.dir && !root {
Expand Down
24 changes: 24 additions & 0 deletions desktop/internal/workbench/filetree_menu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"

"github.com/1lck/Lithe-IDEA/desktop/internal/core"
"github.com/vivaui/viva/gfx"
)

// stubTreeTrash replaces the system trash for one test and returns the paths moved to it, so a
Expand Down Expand Up @@ -75,6 +76,29 @@ func TestProjectTreeCopyPathSubmenu(t *testing.T) {
}
}

// The name of a tree row labels its row: it is no stop of its own for Tab, and the row's menu
// opens from the empty part of the row past the name, acting on that row.
func TestProjectTreeRowMenuOpensPastTheName(t *testing.T) {
root := t.TempDir()
writeTreeFiles(t, root, "a.txt", "b.txt")
h := newHarness(t, &testKernel{Client: core.NewClient()})
p := h.openTree(t, root)

row, name := h.treeRowHit("b.txt"), h.treeNameHit("b.txt")
if !name.IsLabel || name.ID != row.ID || name.Focusable {
t.Fatalf("the name hit is %+v, want a label of row %v that takes no focus", name, row.ID)
}
if err := h.driver.ClickButton(row.Bounds.X+row.Bounds.Width-20, row.Bounds.Y+row.Bounds.Height/2, gfx.PointerButtonSecondary); err != nil {
t.Fatal(err)
}
h.settle()
h.click(center(h.popupHit(h.shared("desktop.files.delete"))))
h.settle()
if !p.tree.removal.open || !slices.Equal(p.tree.removal.paths, []string{"b.txt"}) {
t.Fatalf("Delete from the right-click past the name opened %+v, want the dialog for b.txt", p.tree.removal)
}
}

// treePromptFor opens one row's dialog in the test without a click: the dialog itself is
// declared by the next frame, and the action is what the test drives.
func treePromptFor(h *harness, p *project, kind treePromptKind, n *treeNode, name string) {
Expand Down
34 changes: 10 additions & 24 deletions desktop/internal/workbench/filetree_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ func (a *App) projectTree(c ui.C, p *project) {
t.view.RowWidth = a.measureTree(c.Canvas(), t)
// Names are never cut short: the rows are as wide as the widest one, and the tree
// scrolls sideways to show the rest of it.
named := -1
// IDEA's own disclosure arrows: filled 16 point geometry in the row's existing slot,
// so only the arrow changes and no row moves.
t.view.Disclosure = &components.TreeDisclosure{
Expand All @@ -85,9 +84,7 @@ func (a *App) projectTree(c ui.C, p *project) {
Size: 16,
}
tree := ui.Tree(c, &t.view, len(t.rows), t.label, func(i int) {
if a.drawTreeContent(c, p, t.rows[i]) {
named = i
}
a.drawTreeContent(c, p, t.view.RowID(i), t.rows[i])
}).Scrollbars().Grow(1).FillWidth().PadY(treelist.PadY)
if a.elementShortcut(tree, shortcuts.OpenSelected) {
c.After(func() { a.openSelectedTreeFile(p) })
Expand All @@ -106,15 +103,7 @@ func (a *App) projectTree(c ui.C, p *project) {
// first one left it. Enter is a choice with no click behind it.
info, clicked := c.Canvas().ClickInfo()
repeated := clicked && info.Clicks >= 2
i, ok := t.view.Chosen()
if !ok && named >= 0 {
// The name is the target of the row's context menu, which takes the click before the
// Tree sees it, so a click on the name is a click on its row. Viva's Tree gives a row
// no other place for a context menu; once the pinned Viva has Box.LabelFor
// (vivaui/viva#221), the name labels its row and this goes (#1821).
i, ok = named, true
}
if ok && i < len(t.rows) {
if i, ok := t.view.Chosen(); ok && i < len(t.rows) {
n := t.rows[i]
// The row a click chose takes the keyboard, so the arrow keys go on from it.
c.Canvas().RequestFocus(t.view.RowID(i))
Expand Down Expand Up @@ -193,13 +182,12 @@ func (a *App) measureTree(canvas *gfx.Canvas, t *fileTree) float32 {
return width + treeScrollPad
}

// drawTreeContent declares what a row of the tree shows after its chevron: the node's icon and
// its name, the root's in bold, and reports whether this paint delivers a click on the name.
// Viva's Tree starts a row without a chevron (a file, an empty folder) where the chevron of a
// folder at its depth is, so such a row keeps the chevron's room empty, and its icon lines up
// with the icons of the folders beside it.
func (a *App) drawTreeContent(c ui.C, p *project, n *treeNode) bool {
clicked := false
// drawTreeContent declares what row of the tree shows after its chevron: the node's icon and its
// name, the root's in bold, which labels the row and carries its context menu. Viva's Tree
// starts a row without a chevron (a file, an empty folder) where the chevron of a folder at its
// depth is, so such a row keeps the chevron's room empty, and its icon lines up with the icons
// of the folders beside it.
func (a *App) drawTreeContent(c ui.C, p *project, row gfx.ID, n *treeNode) {
content := func() {
icon := fileicons.ForFile(n.name, a.colors.Dark)
if n.dir {
Expand All @@ -210,15 +198,13 @@ func (a *App) drawTreeContent(c ui.C, p *project, n *treeNode) bool {
if n == p.tree.root {
name.Bold()
}
a.projectTreeMenu(c, p, n, name)
clicked = name.Clicked()
a.projectTreeMenu(c, p, row, n, name)
}
if n.dir && !n.empty {
content()
return clicked
return
}
ui.Row(c).Shrink(0).Items(ui.Center).Gap(c.Theme().Metrics.GapItem).PadLeft(treeChevron).Children(content)
return clicked
}

// focusTreeRow gives the keyboard to the row the locate button brought into view, once the row
Expand Down
8 changes: 1 addition & 7 deletions desktop/internal/workbench/gitlog_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ type logView struct {
// refLabel names the rows of refs, made once because a method value made in each paint
// allocates.
refLabel func(int) string
// refMenu says the menu of a reference is open, at refMenuAt, on refMenuRef of the repository
// refMenuRoot (gitlog_ref_menu.go).
refMenu bool
refMenuAt ui.Rect
refMenuRef core.GitReference
refMenuRoot string
// compareSource is the reference Select for Compare picked in the repository compareRoot,
// which the menu of another reference then compares with.
compareSource *core.GitReference
Expand Down Expand Up @@ -190,7 +184,7 @@ func (v *logView) reset() {
v.keyRows, v.keys = nil, nil
v.files = ui.ListState{}
v.refs.ListState = ui.ListState{}
v.refMenu, v.compareSource, v.compareRoot = false, nil, ""
v.compareSource, v.compareRoot = nil, ""
}

// capture keeps the width the commit list and the details shared, and takes a drag of the
Expand Down
37 changes: 5 additions & 32 deletions desktop/internal/workbench/gitlog_ref_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/1lck/Lithe-IDEA/desktop/internal/core"
"github.com/1lck/Lithe-IDEA/desktop/internal/i18n"
"github.com/vivaui/viva/app"
"github.com/vivaui/viva/gfx"
"github.com/vivaui/viva/ui"
)

Expand Down Expand Up @@ -49,37 +48,11 @@ type historyIntegrateState struct {
root string
}

// logRefPointer opens the reference menu of row i of the reference pane when it is pressed with
// the secondary button. A Tree has no menu of its own rows, so the press is read on the row.
func (a *App) logRefPointer(c ui.C, p *project, i int) {
v := &a.logView
row := v.refItems[i]
canvas := c.Canvas()
if row.kind != logRefReference || row.ref == nil || canvas == nil {
return
}
event, ok := canvas.PointerOn(v.refs.RowID(i))
if !ok || event.Kind != gfx.PointerDown || event.Button != gfx.PointerButtonSecondary {
return
}
canvas.Consume()
v.refMenu, v.refMenuAt, v.refMenuRef = true, ui.Rect{X: event.X, Y: event.Y}, *row.ref
v.refMenuRoot = p.logRepositoryRoot()
}

// drawLogRefMenu declares the reference menu while it is open.
func (a *App) drawLogRefMenu(c ui.C, p *project) {
v := &a.logView
if !v.refMenu {
return
}
if v.refMenuRoot != p.logRepositoryRoot() {
// The log walks another repository now; the reference is not one of it.
v.refMenu = false
return
}
ui.MenuAt(c.Key("log-ref-menu"), v.refMenuAt.X, v.refMenuAt.Y, &v.refMenu, func(menu *ui.MenuItems) {
a.drawLogRefMenuItems(c, menu, p, v.refMenuRef)
// drawLogRefMenu gives the name of a reference row the menu of reference r, which opens from
// the name or anywhere on its row, with Shift+F10 too while the row has the focus.
func (a *App) drawLogRefMenu(c ui.C, name ui.Box, p *project, r core.GitReference) {
ui.ContextMenu(c, name, func(menu *ui.MenuItems) {
a.drawLogRefMenuItems(c, menu, p, r)
})
}

Expand Down
4 changes: 2 additions & 2 deletions desktop/internal/workbench/gitlog_ref_menu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func (h *harness) logRefMenu(short string) {
h.t.Fatal(err)
}
h.settle()
if !v.refMenu || v.refMenuRef.ShortName != short {
h.t.Fatalf("the reference menu is open %v on %q, want it open on %q", v.refMenu, v.refMenuRef.ShortName, short)
if item := h.app.text.Branch.NewBranchFrom(short); !h.hasPopupItem(item) {
h.t.Fatalf("no menu item %q is shown after the right-click on %q", item, short)
}
}

Expand Down
Loading
Loading