Skip to content

Commit

Permalink
directvt#571 WIP: Enable cli readline for GUI sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
o-sdn-o committed Sep 12, 2024
1 parent fdffc09 commit 0364f52
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/netxs/desktopio/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,23 @@ namespace netxs::app::shared
fontlist.push_back(f->value());
}
}
auto event_domain = netxs::events::auth{};
auto window = event_domain.create<gui::window>(event_domain, fontlist, cellsize, aliasing, blinking);
window->connect(winstate, wincoord, gridsize);
auto connect = [&]
{
auto event_domain = netxs::events::auth{};
auto window = event_domain.create<gui::window>(event_domain, fontlist, cellsize, aliasing, blinking);
window->connect(winstate, wincoord, gridsize);
};
if (os::stdout_fd != os::invalid_fd)
{
auto runcmd = directvt::binary::command{};
auto readln = os::tty::readline([&](auto line){ runcmd.send(client, line); }, [&]{ if (client) client->shut(); });
connect();
readln.stop();
}
else
{
connect();
}
}
}
void start(text cmd, text aclass, xmls& config)
Expand All @@ -579,10 +593,8 @@ namespace netxs::app::shared
}};
//if (!config.cd("/config/" + aclass)) config.cd("/config/appearance/");
config.cd("/config/appearance/runapp/", "/config/appearance/defaults/");
auto domain = ui::host::ctor(server, config)
->plugin<scripting::host>();
auto appcfg = eccc{ .cmd = cmd,
.cfg = os::dtvt::active ? ""s : "<config simple=1/>"s };
auto domain = ui::host::ctor(server, config)->plugin<scripting::host>();
auto appcfg = eccc{ .cmd = cmd, .cfg = os::dtvt::active ? ""s : "<config simple=1/>"s };
auto applet = app::shared::builder(aclass)(appcfg, config);
domain->invite(server, applet, os::dtvt::vtmode, os::dtvt::gridsz);
domain->stop();
Expand Down
18 changes: 18 additions & 0 deletions src/netxs/desktopio/console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,23 @@ namespace netxs::ui
s11n::ack_input_fields.send(canal, ext_gear_id, field_list);
});
}
void handle(s11n::xs::command lock)
{
//todo implement
//auto cmd = eccc{ .cmd = lock.thing.utf8 };
//notify(scripting::events::invoke, cmd);
auto cmd = qiew{ lock.thing.utf8 };
if (cmd.starts_with("exit") || cmd.starts_with("quit"))
{
lock.unlock();
disconnect();
}
else
{
auto msg = utf::concat(prompt::repl, ansi::err("Not implemented: "), ansi::clr(yellowlt, utf::trim(cmd, "\r\n")));
s11n::logs.send(canal, ui32{}, datetime::now(), msg);
}
}
void handle(s11n::xs::sysfocus lock)
{
auto& focus = lock.thing;
Expand Down Expand Up @@ -1303,6 +1320,7 @@ namespace netxs::ui
//LISTEN(tier::general, e2::conio::logs, utf8, tokens)
//{
// //todo application internal log output
// //conio.logs.send(canal, os::process::id.first, os::process::id.second, text{ utf8 });
//};
LISTEN(tier::anycast, e2::form::upon::started, item_ptr, tokens)
{
Expand Down

0 comments on commit 0364f52

Please sign in to comment.