Inspector popup: show module file name and clip the note to the popup width
CI / test (push) Failing after 28s
CI / test (push) Failing after 28s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6fc921b431
commit
df1f37ee78
1 file changed
+23
-2
@@ -47,6 +47,17 @@ let components : Array[Component] = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
///| Last path component of `path` (a module id may be a full file path).
|
||||||
|
fn base_name(path : String) -> String {
|
||||||
|
let mut start = 0
|
||||||
|
for i = 0; i < path.length(); i = i + 1 {
|
||||||
|
if path[i] == '/' {
|
||||||
|
start = i + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
path[start:].to_string()
|
||||||
|
}
|
||||||
|
|
||||||
///| The component behind `id`: a loaded panel module (described from its real binary:
|
///| The component behind `id`: a loaded panel module (described from its real binary:
|
||||||
/// the plasmoid contract it exports and the capability interfaces it imports) or one
|
/// the plasmoid contract it exports and the capability interfaces it imports) or one
|
||||||
/// of the fixed shell parts (panel, desktop, window decoration, client surface).
|
/// of the fixed shell parts (panel, desktop, window decoration, client surface).
|
||||||
@@ -60,7 +71,7 @@ fn DesktopShell::find_component(self : DesktopShell, id : String) -> Component?
|
|||||||
Some({
|
Some({
|
||||||
id,
|
id,
|
||||||
title: w.pl.name,
|
title: w.pl.name,
|
||||||
note: "wasm module " + w.module_id + ", imports: " + (if w.caps.length() == 0 { "nothing" } else { w.caps.join(", ") }),
|
note: "wasm module " + base_name(w.module_id) + ", imports: " + (if w.caps.length() == 0 { "nothing" } else { w.caps.join(", ") }),
|
||||||
world: None,
|
world: None,
|
||||||
ifaces,
|
ifaces,
|
||||||
})
|
})
|
||||||
@@ -299,7 +310,17 @@ fn DesktopShell::render_inspector(
|
|||||||
local.push(@ui.fill_rect(@ui.rect(0, 0, dw, dh), p.surface_popup, radius=r + 4))
|
local.push(@ui.fill_rect(@ui.rect(0, 0, dw, dh), p.surface_popup, radius=r + 4))
|
||||||
local.push(@ui.stroke_rect(@ui.rect(0, 0, dw, dh), p.accent, radius=r + 4))
|
local.push(@ui.stroke_rect(@ui.rect(0, 0, dw, dh), p.accent, radius=r + 4))
|
||||||
local.push(@ui.text(14, 16, c.title, 14, p.foreground, bold=true))
|
local.push(@ui.text(14, 16, c.title, 14, p.foreground, bold=true))
|
||||||
local.push(@ui.text(14, 34, c.note, 11, p.foreground_muted))
|
// Clip the note to the popup so a long path or import list can't run past its edge.
|
||||||
|
let mut note = c.note
|
||||||
|
while note.length() > 3 &&
|
||||||
|
@renderer.text_width(note, 11, false, false) > dw - 28 {
|
||||||
|
note = note[:note.length() - 3].to_string()
|
||||||
|
if @renderer.text_width(note + "..", 11, false, false) <= dw - 28 {
|
||||||
|
note = note + ".."
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
local.push(@ui.text(14, 34, note, 11, p.foreground_muted))
|
||||||
local.push(@ui.fill_rect(@ui.rect(10, 46, dw - 20, 1), p.border))
|
local.push(@ui.fill_rect(@ui.rect(10, 46, dw - 20, 1), p.border))
|
||||||
let mut y = 58 + line_h / 2
|
let mut y = 58 + line_h / 2
|
||||||
let space = @renderer.text_width(" ", body_sz, false, false)
|
let space = @renderer.text_width(" ", body_sz, false, false)
|
||||||
|
|||||||
Reference in new issue
Block a user