Skip to content

Commit

Permalink
directvt#464 WIP: XLinkVT mode (shutdown)
Browse files Browse the repository at this point in the history
  • Loading branch information
o-sdn-o committed Dec 1, 2023
1 parent 7cc4792 commit e3171de
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
39 changes: 27 additions & 12 deletions src/netxs/apps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ namespace netxs::app::shared
};
boss.LISTEN(tier::preview, e2::form::proceed::quit::one, fast)
{
boss.sighup(fast);
boss.close(fast);
};
boss.LISTEN(tier::anycast, app::term::events::cmd, cmd)
{
Expand Down Expand Up @@ -485,33 +485,33 @@ namespace netxs::app::shared
->plugin<pro::acryl>()
->plugin<pro::cache>()
->active(cB);
//->invoke([&](auto& boss)
//{
// closing_on_quit(boss);
//});
auto dtvt = ui::dtvt::ctor();
auto scrl = term->attach(ui::rail::ctor());
auto inst = scrl->attach(ui::term::ctor(config))
->plugin<pro::focus>(pro::focus::mode::focused)
->colors(whitelt, blackdk)
->invoke([&](auto& boss)
{
auto& dtvt_inst = *dtvt;
boss.LISTEN(tier::anycast, e2::form::proceed::quit::any, fast)
{
boss.SIGNAL(tier::preview, e2::form::proceed::quit::one, fast);
};
boss.LISTEN(tier::preview, e2::form::proceed::quit::one, fast)
{
boss.sighup(fast);
boss.close(fast, faux);
};
boss.LISTEN(tier::request, e2::form::proceed::quit::one, fast)
{
dtvt_inst.stop(fast, faux);
};
});
term->attach(app::shared::scroll_bars(scrl));
auto& term_inst = *inst;

auto dtvt = ui::dtvt::ctor()
->plugin<pro::focus>(pro::focus::mode::focusable)
dtvt->plugin<pro::focus>(pro::focus::mode::focusable)
->limits(dot_11)
->invoke([&](auto& boss)
{
auto& term_inst = *inst;
auto& window_inst = *window;
boss.LISTEN(tier::anycast, e2::form::upon::started, root, -, (cmd, cwd, env, patch))
{
Expand Down Expand Up @@ -543,11 +543,26 @@ namespace netxs::app::shared
};
boss.LISTEN(tier::preview, e2::form::proceed::quit::one, fast)
{
boss.stop(fast);
boss.stop(fast, faux);
};
boss.LISTEN(tier::request, e2::form::proceed::quit::one, fast)
{
term_inst.close(fast, faux);
};
});
window->branch(dtvt)
->branch(term);
->branch(term)
->invoke([&](auto& boss)
{
boss.LISTEN(tier::release, e2::form::proceed::quit::any, fast, -, (count = 2))
{
if (--count == 0)
if (auto parent = boss.parent())
{
parent->RISEUP(tier::release, e2::form::proceed::quit::one, fast);
}
};
});
return window;
};
auto build_ANSIVT = [](text env, text cwd, text param, xmls& config, text patch)
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/apps/term.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ namespace netxs::app::term
};
boss.LISTEN(tier::preview, e2::form::proceed::quit::one, fast)
{
boss.sighup(fast);
boss.close(fast);
};
boss.LISTEN(tier::anycast, app::term::events::cmd, cmd)
{
Expand Down
16 changes: 7 additions & 9 deletions src/netxs/desktopio/terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7021,7 +7021,7 @@ namespace netxs::ui
case commands::ui::togglewrp: console.selection_setwrp(); break;
case commands::ui::togglesel: selection_selmod(); break;
case commands::ui::restart: restart(); break;
case commands::ui::sighup: sighup(true); break;
case commands::ui::sighup: close(true); break;
case commands::ui::undo: ipccon.undo(true); break;
case commands::ui::redo: ipccon.undo(faux); break;
case commands::ui::deselect: selection_cancel(); break;
Expand Down Expand Up @@ -7120,17 +7120,14 @@ namespace netxs::ui
fdlink = fds;
start();
}
void close()
{
this->RISEUP(tier::release, e2::form::proceed::quit::one, forced); //todo VS2019 requires `this`
}
void restart()
{
resume.exchange(true);
ipccon.sighup(faux);
}
void sighup(bool fast)
void close(bool fast = true, bool notify = true)
{
if (notify) this->SIGNAL(tier::request, e2::form::proceed::quit::one, fast);
forced = fast;
if (ipccon)
{
Expand All @@ -7139,14 +7136,14 @@ namespace netxs::ui
netxs::events::enqueue<faux>(This(), [&, backup = This()](auto& boss) mutable
{
ipccon.payoff(io_log); // Wait child process.
close();
this->RISEUP(tier::release, e2::form::proceed::quit::one, forced); //todo VS2019 requires `this`
});
}
}
else // Child process exited with non-zero code and term waits keypress.
{
onerun.reset();
close();
this->RISEUP(tier::release, e2::form::proceed::quit::one, forced); //todo VS2019 requires `this`
}
}
// term: Resize terminal window.
Expand Down Expand Up @@ -7835,8 +7832,9 @@ namespace netxs::ui
}
}
// dtvt: Close dtvt-object.
void stop(bool fast)
void stop(bool fast, bool notify = true)
{
if (notify) this->SIGNAL(tier::request, e2::form::proceed::quit::one, fast);
if (fast && active.exchange(faux) && ipccon) // Notify and queue closing immediately.
{
stream.s11n::sysclose.send(*this, fast);
Expand Down

0 comments on commit e3171de

Please sign in to comment.