open_file: file associations, default editor and 'Open with' dialog
- New open_file IPC message: resolves [open_with] extension mapping,
falls back to default_editor for known text formats, otherwise opens
an 'Öppna med' dialog where the user types a command (live preview
of the full command line, path tail-truncated so the extension stays
visible) and chooses open-once or save-as-default for the extension
(persisted to [open_with] in config.toml)
- default_editor configurable in the settings dialog (new Editor row
with inline text editing) and in config.toml; '{}' in commands is
replaced with the shell-quoted path
- Documented in SOCKET_API.md; integration suite covers dialog →
save-association → direct open (38/38)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -396,7 +396,8 @@ def main():
|
||||
text = disp.frame_text(timeout=5.0, contains="Tema:")
|
||||
check("inställningsdialogen öppnas från panelen", "Tema:" in text
|
||||
and "Skugga" in text and "config.toml" in text)
|
||||
# Ned två rader till Skugga och toggla av
|
||||
# Ned tre rader till Skugga (0=Tema, 1=Panel, 2=Editor, 3=Skugga)
|
||||
disp.send(key_event(code="Down"))
|
||||
disp.send(key_event(code="Down"))
|
||||
disp.send(key_event(code="Down"))
|
||||
disp.send(key_event(code="Enter"))
|
||||
@@ -407,6 +408,38 @@ def main():
|
||||
disp.send(key_event(code="Esc"))
|
||||
time.sleep(0.3)
|
||||
|
||||
# ── 4i. open_file: Öppna med-dialog, spara association, direktöppning ─
|
||||
marker = "OPENFILE-MARKER-77"
|
||||
txt = os.path.join(cfgdir, "prov.txt")
|
||||
with open(txt, "w") as f:
|
||||
f.write(marker + "\n")
|
||||
# 1) ingen editor konfigurerad → textfil ger Öppna med-dialogen
|
||||
app.send({"type": "open_file", "path": txt, "request_id": "of1"})
|
||||
app.recv_until("window_opened")
|
||||
text = disp.frame_text(timeout=5.0, contains="Öppna med")
|
||||
check("open_file utan editor visar Öppna med-dialogen",
|
||||
"Öppna med" in text and "prov.txt" in text)
|
||||
# skriv kommandot, kryssa i "spara som standard", öppna
|
||||
for ch in "less":
|
||||
disp.send(key_event(ch=ch))
|
||||
disp.send(key_event(code="Tab"))
|
||||
disp.send(key_event(code="Enter"))
|
||||
text = disp.frame_text(timeout=6.0, contains=marker)
|
||||
check("Öppna med öppnar filen med angivet kommando", marker in text)
|
||||
cfg_now = open(os.path.join(cfgdir, "config.toml")).read()
|
||||
check("'spara som standard' skriver [open_with] till config",
|
||||
'txt = "less"' in cfg_now, f"config: {cfg_now[-200:]!r}")
|
||||
disp.send(key_event(ch="q")) # avsluta less → fönstret stängs
|
||||
time.sleep(0.4)
|
||||
# 2) associationen finns nu → öppnas direkt utan dialog
|
||||
app.send({"type": "open_file", "path": txt, "request_id": "of2"})
|
||||
op2 = app.recv_until("window_opened")
|
||||
text = disp.frame_text(timeout=6.0, contains=marker)
|
||||
check("filassociationen öppnar direkt", marker in text
|
||||
and "Öppna med" not in text)
|
||||
app.send({"type": "close_window", "window_id": op2["id"]})
|
||||
time.sleep(0.3)
|
||||
|
||||
# ── 5. Popup + popup_result via Enter ───────────────────────────
|
||||
app.send({
|
||||
"type": "spawn_popup", "message": "Integrationstest?",
|
||||
|
||||
Reference in New Issue
Block a user