Skip to content

Commit

Permalink
Merge pull request #674 from o-sdn-o/gui-bridge
Browse files Browse the repository at this point in the history
Implement keyboard-only access for Info page
  • Loading branch information
o-sdn-o authored Nov 7, 2024
2 parents 6b88ca2 + 3a768b9 commit df9b48c
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 60 deletions.
87 changes: 54 additions & 33 deletions src/netxs/apps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ namespace netxs::app::shared
->active()
->invoke([](auto& boss)
{
//boss.keybd.accept(true);
closing_by_gesture(boss);
closing_on_quit(boss);
})
Expand Down Expand Up @@ -104,7 +103,6 @@ namespace netxs::app::shared
->active(colors)
->invoke([&](auto& boss)
{
//boss.keybd.accept(true);
closing_by_gesture(boss);
closing_on_quit(boss);
});
Expand All @@ -119,7 +117,6 @@ namespace netxs::app::shared
->plugin<pro::notes>(" Left+Right click to close ")
->invoke([&](auto& boss)
{
//boss.keybd.accept(true);
closing_by_gesture(boss);
closing_on_quit(boss);
boss.LISTEN(tier::release, e2::form::upon::vtree::attached, parent)
Expand Down Expand Up @@ -243,7 +240,6 @@ namespace netxs::app::shared
->plugin<pro::cache>()
->invoke([](auto& boss)
{
//boss.keybd.accept(true);
closing_on_quit(boss);
});
auto object = window->attach(ui::fork::ctor(axis::Y))
Expand Down Expand Up @@ -515,6 +511,7 @@ namespace netxs::app::shared
.add(app::shared::repository);
auto window = ui::cake::ctor()
->plugin<pro::focus>(pro::focus::mode::focused)
->plugin<pro::keybd>()
->plugin<pro::acryl>()
->plugin<pro::cache>()
->colors(whitedk, 0x30000000)
Expand All @@ -524,15 +521,16 @@ namespace netxs::app::shared
{
boss.base::riseup(tier::release, e2::form::proceed::quit::one, fast);
};
boss.LISTEN(tier::anycast, e2::form::upon::started, window_ptr2)
{
auto window_ptr = boss.base::riseup(tier::request, e2::form::prop::window::instance);
//todo too hacky
if (auto form_ptr = std::dynamic_pointer_cast<ui::cake>(window_ptr))
{
form_ptr->template plugins<pro::title>().live = faux;
}
};
//todo Should the title of the info page be hidden?
//boss.LISTEN(tier::anycast, e2::form::upon::started, window_ptr2)
//{
// auto window_ptr = boss.base::riseup(tier::request, e2::form::prop::window::instance);
// //todo too hacky
// if (auto form_ptr = std::dynamic_pointer_cast<ui::cake>(window_ptr))
// {
// form_ptr->template plugins<pro::title>().live = faux;
// }
//};
});
auto object = window->attach(ui::fork::ctor(axis::Y))
->colors(whitelt, 0);
Expand Down Expand Up @@ -687,7 +685,7 @@ namespace netxs::app::shared
pressed_label, pressed[0], pressed[1], pressed[2], pressed[3],
released_label, released[0], released[1], released[2], released[3] });
released[0]->set("<Press any keys>")->hidden = faux;;
auto update = [pressed, released](auto& boss, hids& gear, bool is_key_event)
auto update_ptr = ptr::shared([pressed, released](auto& boss, hids& gear, bool is_key_event)
{
//log("vkchord=%% keyid=%% hexvkchord=%% hexscchord=%% hexchchord=%%", input::key::kmap::to_string(gear.vkchord, faux),
// input::key::map::data(gear.keycode).name,
Expand Down Expand Up @@ -728,7 +726,7 @@ namespace netxs::app::shared
rec_ptr->upload(*iter++, -1);
}
}
};
});
for (auto& item : body)
{
auto stats = items->subset.size() < 3;
Expand All @@ -743,34 +741,57 @@ namespace netxs::app::shared
}
items->invoke([&](auto& boss)
{
boss.LISTEN(tier::release, hids::events::mouse::button::down::any, gear, -, (update)) //todo MS VS2019 can't capture static 'auto update =...'.
boss.LISTEN(tier::release, hids::events::mouse::button::down::any, gear, -, (update_ptr))
{
update(boss, gear, faux);
(*update_ptr)(boss, gear, faux);
};
});
window->invoke([&](auto& boss)
{
auto& items_inst = *items;
auto& scroll_inst = *scroll;
auto esc_pressed = ptr::shared(faux);
boss.LISTEN(tier::release, hids::events::keybd::key::any, gear, -, (update, esc_pressed)) //todo MS VS2019 can't capture static 'auto update =...'.
auto& keybd = boss.template plugins<pro::keybd>();
keybd.proc("WindowClose", [&, esc_pressed](hids& gear)
{
auto changed = faux;
//todo key
if (gear.chord(input::key::Esc))
if (!gear.is_exclusive() && *esc_pressed)
{
if (gear.keystat == input::key::released && gear.vkchord.size())
{
boss.bell::signal(tier::anycast, e2::form::proceed::quit::one, true);
gear.set_handled(true);
return;
}
if (!std::exchange(*esc_pressed, gear.vkchord.size())) changed = true;
boss.bell::signal(tier::anycast, e2::form::proceed::quit::one, true);
gear.set_handled(true);
}
else if (std::exchange(*esc_pressed, faux)) changed = true;
if (changed) boss.bell::signal(tier::release, e2::form::state::keybd::command::close, *esc_pressed);
if (gear.keystat != input::key::repeated) update(items_inst, gear, true);
gear.set_handled(true);
};
});
keybd.proc("WindowClosePreview", [&, esc_pressed](hids& /*gear*/)
{
if (std::exchange(*esc_pressed, true) != *esc_pressed)
{
boss.bell::signal(tier::release, e2::form::state::keybd::command::close, *esc_pressed);
}
});
keybd.proc("UpdateChordPreview", [&, esc_pressed, update_ptr](hids& gear)
{
if (std::exchange(*esc_pressed, faux) != *esc_pressed) boss.bell::signal(tier::release, e2::form::state::keybd::command::close, *esc_pressed);
if (gear.keystat != input::key::repeated) (*update_ptr)(items_inst, gear, true);
});
keybd.template bind<tier::preview>( "Esc", "DropIfRepeats");
keybd.template bind<tier::release>( "Esc", "WindowClosePreview");
keybd.template bind<tier::preview>("-Esc", "WindowClose");
keybd.template bind<tier::release>( "Any", "UpdateChordPreview");
keybd.proc("ScrollPageUp" , [&](hids& gear){ if (!gear.is_exclusive()) { scroll_inst.base::signal(tier::preview, e2::form::upon::scroll::bypage::y, { .vector = { 0, 1 }}); } });
keybd.proc("ScrollPageDown" , [&](hids& gear){ if (!gear.is_exclusive()) { scroll_inst.base::signal(tier::preview, e2::form::upon::scroll::bypage::y, { .vector = { 0,-1 }}); } });
keybd.proc("ScrollLineUp" , [&](hids& gear){ if (!gear.is_exclusive()) { scroll_inst.base::signal(tier::preview, e2::form::upon::scroll::bystep::y, { .vector = { 0, 3 }}); } });
keybd.proc("ScrollLineDown" , [&](hids& gear){ if (!gear.is_exclusive()) { scroll_inst.base::signal(tier::preview, e2::form::upon::scroll::bystep::y, { .vector = { 0,-3 }}); } });
keybd.proc("ScrollCharLeft" , [&](hids& gear){ if (!gear.is_exclusive()) { scroll_inst.base::signal(tier::preview, e2::form::upon::scroll::bystep::x, { .vector = { 3, 0 }}); } });
keybd.proc("ScrollCharRight", [&](hids& gear){ if (!gear.is_exclusive()) { scroll_inst.base::signal(tier::preview, e2::form::upon::scroll::bystep::x, { .vector = {-3, 0 }}); } });
keybd.proc("ScrollTop" , [&](hids& gear){ if (!gear.is_exclusive()) { scroll_inst.base::signal(tier::preview, e2::form::upon::scroll::to_top::y); } });
keybd.proc("ScrollEnd" , [&](hids& gear){ if (!gear.is_exclusive()) { scroll_inst.base::signal(tier::preview, e2::form::upon::scroll::to_end::y); } });
keybd.bind("PageUp" , "ScrollPageUp" );
keybd.bind("PageDown" , "ScrollPageDown" );
keybd.bind("UpArrow" , "ScrollLineUp" );
keybd.bind("DownArrow" , "ScrollLineDown" );
keybd.bind("LeftArrow" , "ScrollCharLeft" );
keybd.bind("RightArrow", "ScrollCharRight");
keybd.bind("Home" , "ScrollTop" );
keybd.bind("End" , "ScrollEnd" );
});
inside->attach(slot::_2, ui::post::ctor())
->limits({ -1, 1 })
Expand Down
1 change: 0 additions & 1 deletion src/netxs/apps/calc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ namespace netxs::app::calc
->plugin<pro::cache>()
->invoke([&](auto& boss)
{
//boss.keybd.accept(true);
boss.LISTEN(tier::anycast, e2::form::proceed::quit::any, fast)
{
boss.base::riseup(tier::release, e2::form::proceed::quit::one, fast);
Expand Down
1 change: 0 additions & 1 deletion src/netxs/apps/shop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ namespace netxs::app::shop
->plugin<pro::cache>()
->invoke([](auto& boss)
{
//boss.keybd.accept(true);
boss.LISTEN(tier::anycast, e2::form::proceed::quit::any, fast)
{
boss.base::riseup(tier::release, e2::form::proceed::quit::one, fast);
Expand Down
1 change: 0 additions & 1 deletion src/netxs/apps/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ namespace netxs::app::test
->plugin<pro::cache>()
->invoke([](auto& boss)
{
//boss.keybd.accept(true);
boss.LISTEN(tier::anycast, e2::form::proceed::quit::any, fast)
{
boss.base::riseup(tier::release, e2::form::proceed::quit::one, fast);
Expand Down
1 change: 0 additions & 1 deletion src/netxs/apps/text.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ displaying the requested definition in a popup window or temporary buffer. Some
->plugin<pro::cache>()
->invoke([&](auto& boss)
{
//boss.keybd.accept(true);
boss.LISTEN(tier::anycast, e2::form::proceed::quit::any, fast)
{
boss.base::riseup(tier::release, e2::form::proceed::quit::one, fast);
Expand Down
3 changes: 1 addition & 2 deletions 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.40";
static const auto version = "v0.9.99.41";
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 Expand Up @@ -417,7 +417,6 @@ namespace netxs::app::shared
->plugin<pro::acryl>()
->invoke([&](auto& boss)
{
//boss.keybd.accept(true);
closing_on_quit(boss);
closing_by_gesture(boss);
boss.LISTEN(tier::release, e2::form::upon::vtree::attached, parent)
Expand Down
2 changes: 2 additions & 0 deletions src/netxs/desktopio/controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,7 @@ namespace netxs::ui
{
if (gear.payload == input::keybd::type::keypress)
{
if (!gear.handled) _dispatch<tier::release>(gear, input::key::kmap::any_key);
if (!gear.handled) _dispatch<tier::release>(gear, gear.vkchord);
if (!gear.handled) _dispatch<tier::release>(gear, gear.chchord);
if (!gear.handled) _dispatch<tier::release>(gear, gear.scchord);
Expand All @@ -1911,6 +1912,7 @@ namespace netxs::ui
if (!gear.handled) _dispatch<tier::preview>(gear, gear.vkchord);
if (!gear.handled) _dispatch<tier::preview>(gear, gear.chchord);
if (!gear.handled) _dispatch<tier::preview>(gear, gear.scchord);
if (!gear.handled) _dispatch<tier::preview>(gear, input::key::kmap::any_key);
}
};
proc("Drop", [](hids& gear){ gear.set_handled(); });
Expand Down
23 changes: 6 additions & 17 deletions src/netxs/desktopio/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,18 +650,7 @@ 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 constexpr auto any_key = qiew{ "\0"sv };
static auto chord_list(qiew chord)
{
struct key_t
Expand All @@ -676,6 +665,11 @@ namespace netxs::input
};
auto keys = std::vector<key_t>{};
auto crop = std::vector<text>{};
if (utf::to_low(chord) == "any")
{
crop.push_back(any_key);
return crop;
}
auto take = [](qiew& chord)
{
auto k = key_t{};
Expand Down Expand Up @@ -1749,11 +1743,6 @@ namespace netxs::input
}

auto meta(si32 ctl_key = -1) { return hids::ctlstat & ctl_key; }
auto chord(si32 k, si32 mods = {})
{
if (mods) return k == keybd::keycode && meta(mods) && !meta(~mods & hids::anyMod);
else return k == keybd::keycode && !meta(hids::anyMod);
}

// hids: Stop handeling this event.
void dismiss(bool set_nodbl = faux)
Expand Down
8 changes: 4 additions & 4 deletions src/netxs/desktopio/terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7719,14 +7719,14 @@ namespace netxs::ui

chords.proc("TerminalFindPrev", [&](hids& gear){ gear.set_handled(); selection_search(gear, feed::rev); });
chords.proc("TerminalFindNext", [&](hids& gear){ gear.set_handled(); selection_search(gear, feed::fwd); });
chords.proc("TerminalViewportOnePageLeft", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bypage::x, { .vector = dot_10 }); });
chords.proc("TerminalViewportOnePageRight", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bypage::x, { .vector = -dot_10 }); });
chords.proc("TerminalViewportOnePageLeft", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bypage::x, { .vector = { 1, 0 }}); });
chords.proc("TerminalViewportOnePageRight", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bypage::x, { .vector = {-1, 0 }}); });
chords.proc("TerminalViewportOneCharLeft", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bystep::x, { .vector = { 1, 0 }}); });
chords.proc("TerminalViewportOneCharRight", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bystep::x, { .vector = {-1, 0 }}); });
chords.proc("TerminalViewportOneCharUp", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bystep::y, { .vector = { 0, 1 }}); });
chords.proc("TerminalViewportOneCharDown", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bystep::y, { .vector = { 0,-1 }}); });
chords.proc("TerminalViewportOnePageUp", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bypage::y, { .vector = dot_01 }); });
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("TerminalViewportOnePageUp", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bypage::y, { .vector = { 0, 1 }}); });
chords.proc("TerminalViewportOnePageDown", [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bypage::y, { .vector = { 0,-1 }}); });
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("TerminalSelectionCancel", [&](hids& gear){ if (!selection_active()) return; gear.set_handled(); exec_cmd(commands::ui::deselect); });
Expand Down

0 comments on commit df9b48c

Please sign in to comment.