fix: ctrl-q now properly exits
This commit is contained in:
@@ -13,8 +13,11 @@ defmodule BDS.Application do
|
||||
end
|
||||
|
||||
# Local TUI: the headless server plus a TUI on the launching terminal, so
|
||||
# a GUI (via tunnel) and the local terminal can work in parallel.
|
||||
def mode_children(:tui, env), do: mode_children(:server, env) ++ [{BDS.TUI, []}]
|
||||
# a GUI (via tunnel) and the local terminal can work in parallel. Quitting
|
||||
# this TUI stops the whole VM — the terminal is the app in this mode.
|
||||
# SSH-served TUI sessions never get this flag and stay session-local.
|
||||
def mode_children(:tui, env),
|
||||
do: mode_children(:server, env) ++ [{BDS.TUI, [stop_vm_on_exit: true]}]
|
||||
|
||||
def mode_children(:desktop, env), do: desktop_children(env)
|
||||
|
||||
|
||||
@@ -37,13 +37,17 @@ defmodule BDS.TUI do
|
||||
# ── Mount ────────────────────────────────────────────────────────────────
|
||||
|
||||
@impl true
|
||||
def mount(_opts) do
|
||||
def mount(opts) do
|
||||
UILocale.put(BDS.Desktop.ShellData.ui_language())
|
||||
:ok = Events.subscribe()
|
||||
|
||||
project_id = Projects.shell_snapshot().active_project_id
|
||||
|
||||
state = %{
|
||||
# Set only for the local BDS_MODE=tui child: quitting the TUI then
|
||||
# shuts the VM down instead of leaving a headless server behind.
|
||||
stop_vm_on_exit: Keyword.get(opts, :stop_vm_on_exit, false),
|
||||
stop_fun: Keyword.get(opts, :stop_fun, &System.stop/0),
|
||||
project_id: project_id,
|
||||
view: "posts",
|
||||
sidebar: nil,
|
||||
@@ -60,6 +64,14 @@ defmodule BDS.TUI do
|
||||
{:ok, load_sidebar(state)}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def terminate(_reason, %{stop_vm_on_exit: true, stop_fun: stop_fun}) do
|
||||
stop_fun.()
|
||||
:ok
|
||||
end
|
||||
|
||||
def terminate(_reason, _state), do: :ok
|
||||
|
||||
# ── Events: global keys ──────────────────────────────────────────────────
|
||||
|
||||
@impl true
|
||||
|
||||
Reference in New Issue
Block a user