Skip to content

Commit

Permalink
directvt#571 WIP: Make GUI-mode default
Browse files Browse the repository at this point in the history
  • Loading branch information
o-sdn-o committed Sep 12, 2024
1 parent fb92f92 commit fdffc09
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 158 deletions.
12 changes: 6 additions & 6 deletions doc/command-line-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ vtm -i | -u | -v | -?
<script relay via piped redirection> | vtm [ -p <id> ]
```

> By default, vtm runs Desktop Client, running an additional instance with Desktop Server in background if it is not found.
> By default, vtm runs Desktop Client, running an additional instance with Desktop Server in background if it is not running.
Option | Description
------------------------|-------------------------------------------------------
Expand All @@ -23,17 +23,17 @@ Option | Description
`-t`, `--tui` | Force TUI mode.
`-g`, `--gui` | Force GUI mode.
`-i`, `--install` | Perform system-wide installation. Allow Desktop Server to run in user context in Session 0 on Windows.<br>Placing Desktop Server in Session 0 allows console applications to run independently of the user's GUI login session. Note: This prevents GUI applications from running from the vtm desktop environment. See "Session 0 Isolation" on the Web for details.
`-0`, `--session0` | Use Session 0 to run Desktop Server in background.
`-u`, `--uninstall` | Perform system-wide deinstallation.
`-0`, `--session0` | Use Session 0 to run Desktop Server in background.
`-q`, `--quiet` | Disable logging.
`-x`, `--script <cmds>` | Specifies script commands to be run by the desktop when ready.
`-c`, `--config <file>` | Specifies the settings file to load.
`-p`, `--pin <id>` | Specifies the desktop id it is pinned to.
`-c`, `--config <file>` | Specifies a settings file to load or plain xml-data to merge.
`-p`, `--pin <id>` | Specifies the desktop id it will be pinned to.
`-s`, `--server` | Run Desktop Server.
`-d`, `--daemon` | Run Desktop Server in background.
`-m`, `--monitor` | Run Desktop Monitor.
`-r`, `--`, `--run` | Run desktop applet standalone.
`<type>` | Desktop applet type to run.
`<type>` | Desktop applet to run.
`<args...>` | Desktop applet arguments.

### Desktop Applets
Expand All @@ -49,7 +49,7 @@ The following commands have a short form:
- `vtm -r vtty <cui_app...>` can be shortened to `vtm <cui_app...>`.
- `vtm -r dtty ssh <user@host dtvt_app...>` can be shortened to `vtm ssh <user@host dtvt_app...>`.

Instead of the path to the configuration file, the configuration body itself can be specified:
It is possible to specify plain xml-data to modify current settings (this case is detected by the `<config` literal at the beginning):

- `vtm -c \"<config><term><scrollback size=1000000/></term></config>\" -r term`.

Expand Down
2 changes: 1 addition & 1 deletion src/netxs/desktopio/baseui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ namespace netxs::ui
}
}
// base: Update nested object.
virtual void update(sptr old_item_ptr, sptr new_item_ptr)
virtual void replace(sptr old_item_ptr, sptr new_item_ptr)
{
auto head = subset.begin();
auto tail = subset.end();
Expand Down
6 changes: 3 additions & 3 deletions src/netxs/desktopio/controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2365,7 +2365,7 @@ namespace netxs::ui
auto new_item = item_template(data_src, arg_new_value)
->depend(data_src);
item_shadow = ptr::shadow(new_item); // Update current item shadow.
boss_ptr->update(old_item, new_item);
boss_ptr->replace(old_item, new_item);
}
};
branch(new_item);
Expand Down Expand Up @@ -3482,7 +3482,7 @@ namespace netxs::ui
else base::subset.clear();
}
// rail: Update nested object.
void update(sptr old_object, sptr new_object) override
void replace(sptr old_object, sptr new_object) override
{
auto object_coor = dot_00;
if (!empty())
Expand Down Expand Up @@ -3990,7 +3990,7 @@ namespace netxs::ui
else base::subset.clear();
}
// pads: Update nested object.
void update(sptr old_object, sptr new_object) override
void replace(sptr old_object, sptr new_object) override
{
remove(old_object);
attach(new_object);
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/desktopio/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ namespace netxs::gui
netxs::set_flag<fontcat::loaded>(fontstat[i].s);
auto is_primary = fallback.empty();
auto& f = fallback.emplace_back(*this, barefont, i, cellsize, is_primary);
log("%%Using font '%fontname%' (%iscolor%). Order %index%.", prompt::gui, f.font_name, f.color ? "color" : "monochromatic", fallback.size() - 1);
log("%%Using font '%fontname%' (%iscolor%). Index %index%.", prompt::gui, f.font_name, f.color ? "color" : "monochromatic", fallback.size() - 1);
}
return hit;
};
Expand Down
52 changes: 14 additions & 38 deletions src/netxs/desktopio/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,8 @@ namespace netxs::os
static constexpr auto unexpected = " returns unexpected result"sv;
static auto autosync = true; // Auto sync viewport with cursor position (win7/8 console).
static auto finalized = flag{ faux }; // Ready flag for clean exit.
static auto logbuffer = text{};
void release(bool clear_log = true)
void release()
{
if (clear_log) os::logbuffer.clear(); // Graceful exit w/o errors.
os::finalized.exchange(true);
os::finalized.notify_all();
}
Expand Down Expand Up @@ -3631,7 +3629,7 @@ namespace netxs::os
}
return std::max(dot_11, winsz);
}
auto initialize(bool trygui = faux, [[maybe_unused]] bool forced = faux)
auto initialize(bool rungui = faux)
{
#if defined(_WIN32)
os::stdin_fd = fd_t{ ptr::test(::GetStdHandle(STD_INPUT_HANDLE ), os::invalid_fd) };
Expand Down Expand Up @@ -3743,13 +3741,15 @@ namespace netxs::os
else
{
dtvt::gridsz = dtvt::consize();
if (trygui)
if (rungui)
{
#if defined(_WIN32)

if (nt::session()) // There is no gui mode in Session0.
{
dtvt::vtmode |= ui::console::gui;
auto processpid = DWORD{};
auto proc_count = ::GetConsoleProcessList(&processpid, 1);
if (forced || 1 == proc_count) // Run gui console.
if (1 == proc_count) // Run gui console. Close the parent text console when we are alone.
{
//auto r = RECT{};
//auto h = ::GetConsoleWindow();
Expand All @@ -3775,19 +3775,18 @@ namespace netxs::os
////dtvt::wingui = {{ r.left, r.top }, { r.right - r.left, r.bottom - r.top }}; // It doesn't work with WT.
//dtvt::wingui = dtvt::window;
//dtvt::wingui.size *= twod{ std::max(1, cell_height / 2), cell_height};
dtvt::vtmode |= ui::console::gui;
os::stdin_fd = os::invalid_fd;
os::stdout_fd = os::invalid_fd;
os::stderr_fd = os::invalid_fd;
//if constexpr (!debugmode) ::FreeConsole();
::FreeConsole();
}
// We are hosted by a shell.
}
#else
if (!haspty)
{
dtvt::vtmode |= ui::console::gui;
}
if (!haspty)
{
dtvt::vtmode |= ui::console::gui;
}
#endif
if (dtvt::vtmode & ui::console::gui)
{
Expand Down Expand Up @@ -4694,7 +4693,7 @@ namespace netxs::os
parser.cout(utf8);
#endif
}
else if (!(dtvt::vtmode & ui::console::redirio))
else if (!(dtvt::vtmode & ui::console::redirio || dtvt::vtmode & ui::console::direct))
{
io::send(utf8);
}
Expand Down Expand Up @@ -4799,40 +4798,17 @@ namespace netxs::os
auto logger()
{
static auto dtvt_output = [](auto& data){ io::send(os::stdout_fd, data); };
if (dtvt::vtmode & ui::console::gui)
{
auto errmsg = []
{
if (os::logbuffer.size())
{
#if defined(_WIN32)
auto utf8log = ui::page{ utf::trunc(os::logbuffer, 32) }.to_utf8<faux>();
auto message = utf::to_utf(utf::trim_front(view{ utf8log }, '\n'));
auto caption = utf::to_utf(os::process::binary());
::MessageBoxW(NULL, message.data(), caption.data(), MB_OK);
#else
#endif
}
};
std::atexit(errmsg);
}
return netxs::logger::attach([](qiew utf8)
{
if (dtvt::vtmode & ui::console::gui) // Deferred logs in gui mode.
{
os::logbuffer += utf8;
utf8 = os::logbuffer;
}
if (utf8.empty()) return;
if (dtvt::active || dtvt::client)
{
static auto logs = netxs::directvt::binary::logs_t{};
logs.set(os::process::id.first, os::process::id.second, utf8);
dtvt::active ? logs.sendfx(dtvt_output) // Send logs to the dtvt-app hoster.
: logs.sendby(dtvt::client); // Send logs to the dtvt-app.
os::logbuffer.clear();
}
else if (os::stdout_fd != os::invalid_fd)
if (os::stdout_fd != os::invalid_fd)
{
tty::cout(utf8);
}
Expand Down
Loading

0 comments on commit fdffc09

Please sign in to comment.