Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistency #672

Merged
merged 4 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 67 additions & 67 deletions doc/apps.md

Large diffs are not rendered by default.

170 changes: 144 additions & 26 deletions doc/settings.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/netxs/apps/term.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace netxs::app::terminal
X(TerminalSelectionCopy ) /* */ \
X(TerminalSelectionMode ) /* */ \
X(TerminalSelectionRect ) /* Linear/Rectangular */ \
X(TerminalSelectionClear ) /* */ \
X(TerminalSelectionCancel ) /* */ \
X(TerminalSelectionOneShot ) /* One-shot toggle to copy text while mouse tracking is active */ \
X(TerminalViewportPageUp ) /* */ \
X(TerminalViewportPageDown ) /* */ \
Expand Down Expand Up @@ -427,7 +427,7 @@ namespace netxs::app::terminal
_update_to(boss, item, selbox);
};
}
static void TerminalSelectionClear(ui::item& boss, menu::item& item)
static void TerminalSelectionCancel(ui::item& boss, menu::item& item)
{
_submit<true>(boss, item, [](auto& boss, auto& /*item*/, auto& /*gear*/)
{
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/desktopio/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace netxs::app

namespace netxs::app::shared
{
static const auto version = "v0.9.99.38";
static const auto version = "v0.9.99.39";
static const auto repository = "https://github.com/directvt/vtm";
static const auto usr_config = "~/.config/vtm/settings.xml"s;
static const auto sys_config = "/etc/vtm/settings.xml"s;
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/desktopio/console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ namespace netxs::ui
LISTEN(tier::preview, hids::events::keybd::key::any, gear, tokens)
{
//todo unify
//todo key
//todo key action="DebugOverlayToggle"
if (gear.keybd::cluster == props.debug_toggle)
{
debug ? debug.stop()
Expand Down
76 changes: 55 additions & 21 deletions src/netxs/desktopio/controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1827,26 +1827,47 @@ namespace netxs::ui
std::unordered_map<text, std::list<wptr>, qiew::hash, qiew::equal> handlers_preview;
std::unordered_map<text, std::list<wptr>, qiew::hash, qiew::equal> handlers_release;
std::unordered_map<text, sptr, qiew::hash, qiew::equal> api_map;
std::vector<sptr> chord_handlers;

auto _get_chords(qiew chord_str)
{
auto chords = input::key::kmap::chord_list(chord_str);
if (chords.size())
{
return std::optional{ chords };
}
else
{
log("%%Unknown key chord: '%chord%'", prompt::user, chord_str);
return std::optional<decltype(chords)>{};
}
}
template<si32 Tier = tier::release>
auto _set(qiew chord_str, sptr handler_ptr)
{
auto& handlers = Tier == tier::release ? handlers_release : handlers_preview;
auto chords = input::key::kmap::chord_list(chord_str);
if (chords.size())
if (auto chords = _get_chords(chord_str))
{
for (auto& chord : chords)
for (auto& chord : chords.value())
{
handlers[chord].push_back(handler_ptr);
}
return true;
}
else
else return faux;
}
template<si32 Tier = tier::release>
auto _reset(qiew chord_str)
{
auto& handlers = Tier == tier::release ? handlers_release : handlers_preview;
if (auto chords = _get_chords(chord_str))
{
log("%%Unknown key chord: '%chord%'", prompt::user, chord_str);
return faux;
for (auto& chord : chords.value())
{
handlers[chord].clear();
}
return true;
}
else return faux;
}
template<si32 Tier = tier::release>
void _dispatch(hids& gear, qiew chord)
Expand Down Expand Up @@ -1892,37 +1913,50 @@ namespace netxs::ui
if (!gear.handled) _dispatch<tier::preview>(gear, gear.scchord);
}
};
proc("Drop", [](hids& gear){ gear.set_handled(); });
}

auto proc(qiew name, func proc)
void proc(qiew name, func proc)
{
api_map[name] = ptr::shared(std::move(proc));
}
//template<class ...Args>
//auto bind(qiew chord_str, func handler, Args&&... chords_handlers)
//{
// auto handler_ptr = ptr::shared(std::move(handler));
// if (_set(chord_str, handler_ptr)) chord_handlers.push_back(handler_ptr);
// if constexpr (sizeof...(Args)) bind(std::forward<Args>(chords_handlers)...);
//}
template<si32 Tier = tier::release>
auto bind(qiew chord_str, qiew proc_name)
{
if (auto iter = api_map.find(proc_name); iter != api_map.end())
if (!chord_str) return;
if (proc_name)
{
if (_set<Tier>(chord_str, iter->second))
if (auto iter = api_map.find(proc_name); iter != api_map.end())
{
//chord_handlers.push_back(iter->second);
_set<Tier>(chord_str, iter->second);
}
else log("%%Action '%proc%' not found", prompt::user, proc_name);
}
else
{
_reset<Tier>(chord_str);
}
else log("%%Function '%proc%' not found", prompt::user, proc_name);
}
auto reset()
auto wipe()
{
chord_handlers.clear();
handlers_release.clear();
handlers_preview.clear();
}
template<si32 Tier = tier::release>
auto load(xmls& config, qiew path)
{
auto keybinds = config.list(path);
for (auto keybind_ptr : keybinds)
{
auto& keybind = *keybind_ptr;
if (!keybind.fake)
{
auto chord = keybind.take_value();
auto action = keybind.take("action", ""s);
bind<Tier>(chord, action);
}
}
}
};

// pro: Glow gradient filter.
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/desktopio/directvt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ namespace netxs::directvt
SEQ_TEMP_macro(WRAP_macro(struct_members)) \
set(); \
} \
void syncto(auto& dst) \
void syncto(auto& dst) const \
{ \
SEQ_SYNC_macro(WRAP_macro(struct_members)) \
} \
Expand Down
37 changes: 22 additions & 15 deletions src/netxs/desktopio/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,9 @@ namespace netxs::gui
static constexpr auto end = 0x23; // VK_END;
static constexpr auto home = 0x24; // VK_HOME;

static constexpr auto f11 = 0x7A; // VK_F11;
static constexpr auto f12 = 0x7B; // VK_F12;

static constexpr auto key_0 = '0'; // VK_0;

static constexpr auto numlock = 0x90; // VK_NUMLOCK;
Expand Down Expand Up @@ -2942,7 +2945,7 @@ namespace netxs::gui
{
auto keystat = input::key::released;
auto virtcod = 0;
if (keybd_read_input(keystat, virtcod)) return;
if (!keybd_read_input(keystat, virtcod)) return;
if (keystat)
{
//todo key
Expand Down Expand Up @@ -2998,21 +3001,25 @@ namespace netxs::gui
window_shutdown();
});
}
else if (keybd_test_pressed(vkey::control) && keybd_test_pressed(vkey::shift) // Roll font list. Renumerate font list.
&& (keybd_test_pressed(vkey::f11) || keybd_test_pressed(vkey::f12))
&& fcache.families.size())
{
auto& families = fcache.families;
if (keybd_test_pressed(vkey::f12))
{
families.push_back(std::move(families.front()));
families.pop_front();
}
else
{
families.push_front(std::move(families.back()));
families.pop_back();
}
set_font_list(families);
//print_font_list(true);
}
}
//else if (keystat == input::key::released && fcache.families.size()) // Renumerate font list.
//{
// auto flen = fcache.families.size();
// auto index = virtcod == 0x30 ? fcache.families.size() - 1 : virtcod - 0x30;
// if (index > 0 && index < flen)
// {
// auto& flist = fcache.families;
// auto iter = flist.begin();
// std::advance(iter, index);
// flist.splice(flist.begin(), flist, iter, std::next(iter)); // Move it to the begining of the list.
// set_font_list(flist);
// print_font_list(true);
// }
//}
}
arch run_command(arch command, arch lParam)
{
Expand Down
13 changes: 12 additions & 1 deletion src/netxs/desktopio/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,18 @@ namespace netxs::input
}
return crop;
}
static auto get_key_event_by_chord(qiew chord)
{
//todo implement
chord.clear();
auto k = syskeybd{};
k.keystat = 0 ? input::key::pressed : input::key::released;
k.virtcod = {};
k.scancod = {};
k.keycode = {};
k.cluster = {};
return k;
}
static auto chord_list(qiew chord)
{
struct key_t
Expand Down Expand Up @@ -2030,7 +2042,6 @@ namespace netxs::input

if (auto it_alone = alone_key.find(v); it_alone != alone_key.end())
{
//todo key
if (v >= key::KeyEnd && v <= key::KeyDownArrow) it_alone->second[1] = decckm ? 'O' : '[';
return it_alone->second;
}
Expand Down
21 changes: 2 additions & 19 deletions src/netxs/desktopio/terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7737,7 +7737,7 @@ namespace netxs::ui
chords.proc("TerminalViewportOnePageDown", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bypage::y, { .vector = -dot_01 }); });
chords.proc("TerminalViewportTop", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::to_top::y); });
chords.proc("TerminalViewportEnd", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::to_end::y); });
chords.proc("TerminalSelectionClear", [&](hids& gear){ if (!selection_active()) return; gear.set_handled(); exec_cmd(commands::ui::deselect); });
chords.proc("TerminalSelectionCancel", [&](hids& gear){ if (!selection_active()) return; gear.set_handled(); exec_cmd(commands::ui::deselect); });
chords.proc("TerminalToggleCwdSync", [&](hids& gear){ gear.set_handled(); base::riseup(tier::preview, ui::term::events::toggle::cwdsync, true); });
chords.proc("TerminalToggleWrapMode", [&](hids& gear){ gear.set_handled(); exec_cmd(commands::ui::togglewrp); });
chords.proc("TerminalQuit", [&](hids& gear){ gear.set_handled(); exec_cmd(commands::ui::sighup); });
Expand All @@ -7753,24 +7753,7 @@ namespace netxs::ui
chords.proc("TerminalSelectionOneShot", [&](hids& gear){ gear.set_handled(); set_oneshot(mime::textonly); });
chords.proc("TerminalViewportCopy", [&](hids& gear){ gear.set_handled(); prnscrn(gear); });
chords.proc("TerminalToggleStdioLog", [&](hids& gear){ gear.set_handled(); set_log(!io_log); ondata<true>(); });

auto keybinds = xml_config.list("/config/term/hotkeys/key");
for (auto keybind_ptr : keybinds)
{
auto& keybind = *keybind_ptr;
if (!keybind.fake)
{
auto chord = keybind.take_value();
if (chord.size())
{
auto action = keybind.take("action", ""s);
if (action.size())
{
chords.bind(chord, action);
}
}
}
}
chords.load<tier::release>(xml_config, "/config/term/hotkeys/key");

LISTEN(tier::general, e2::timer::tick, timestamp) // Update before world rendering.
{
Expand Down
8 changes: 4 additions & 4 deletions src/netxs/desktopio/xml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ namespace netxs::xml
result.chan.a = 0xff;
return result;
}
else log("%%Unknown hex color format: { %value% }, expected #rrggbbaa or #rrggbb color hex value", prompt::xml, value);
//log("%%Unknown hex color format: { %value% }, expected #rrggbbaa or #rrggbb color hex value", prompt::xml, value);
}
else if (shadow.starts_with("0x")) // hex: 0xaarrggbb
{
Expand All @@ -143,7 +143,7 @@ namespace netxs::xml
result.chan.b = (tobyte(shadow[4]) << 4) + tobyte(shadow[5]);
return result;
}
else log("%%Unknown hex color format: { %value% }, expected 0xaarrggbb or 0xrrggbb color hex value", prompt::xml, value);
//log("%%Unknown hex color format: { %value% }, expected 0xaarrggbb or 0xrrggbb color hex value", prompt::xml, value);
}
else if (utf::check_any(shadow, ",;/")) // dec: 000,000,000,000
{
Expand All @@ -165,7 +165,7 @@ namespace netxs::xml
}
}
}
log("%%Unknown hex color format: { %value% }, expected 000,000,000,000 decimal (r,g,b,a) color value", prompt::xml, value);
//log("%%Unknown hex color format: { %value% }, expected 000,000,000,000 decimal (r,g,b,a) color value", prompt::xml, value);
}
else if (auto c = utf::to_int(shadow)) // Single ANSI color value
{
Expand All @@ -174,7 +174,7 @@ namespace netxs::xml
result = argb::vt256[c.value()];
return result;
}
else log("%%Unknown ANSI 256-color value format: { %value% }, expected 0-255 decimal value", prompt::xml, value);
//log("%%Unknown ANSI 256-color value format: { %value% }, expected 0-255 decimal value", prompt::xml, value);
}
return std::nullopt;
}
Expand Down
20 changes: 2 additions & 18 deletions src/vtm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,25 +739,9 @@ namespace netxs::app::vtm
keybd.proc("FocusPrevWindow", [&](hids& gear){ focus_next_window(gear, feed::rev); });
keybd.proc("FocusNextWindow", [&](hids& gear){ focus_next_window(gear, feed::fwd); });
keybd.proc("Disconnect", [&](hids& gear){ disconnect(gear); });
keybd.proc("TryQuit", [&](hids& gear){ try_quit(gear); });
keybd.proc("TryToQuit", [&](hids& gear){ try_quit(gear); });
keybd.load<tier::preview>(config, "/config/desktop/hotkeys/key");

auto keybinds = config.list("/config/desktop/hotkeys/key");
for (auto keybind_ptr : keybinds)
{
auto& keybind = *keybind_ptr;
if (!keybind.fake)
{
auto chord = keybind.take_value();
if (chord.size())
{
auto action = keybind.take("action", ""s);
if (action.size())
{
keybd.bind<tier::preview>(chord, action);
}
}
}
}
LISTEN(tier::release, e2::form::upon::vtree::attached, world_ptr)
{
nexthop = world_ptr;
Expand Down
Loading