diff --git a/src/netxs/apps.hpp b/src/netxs/apps.hpp index c89b134afe..3808874e3f 100644 --- a/src/netxs/apps.hpp +++ b/src/netxs/apps.hpp @@ -741,12 +741,12 @@ namespace netxs::app::shared auto& state_inst = *state_state; auto& keybd = boss.template plugins(); app::shared::base_kb_navigation(keybd, scroll, boss); - keybd.proc("UpdateChordPreview", [&, update_ptr](hids& gear, txts&) + keybd.proc("UpdateChordPreview", [&, update_ptr](hids& gear) { if (gear.keystat != input::key::repeated) (*update_ptr)(items_inst, gear, true); if (rawkbd) gear.set_handled(); }); - keybd.proc("ExclusiveKeyboardMode", [&, update_ptr](hids& gear, txts&) + keybd.proc("ExclusiveKeyboardMode", [&, update_ptr](hids& gear) { state_inst.bell::signal(tier::release, ui::term::events::rawkbd); if (gear.keystat != input::key::repeated) (*update_ptr)(items_inst, gear, true); diff --git a/src/netxs/apps/tile.hpp b/src/netxs/apps/tile.hpp index 429e58f4f5..a24703ba71 100644 --- a/src/netxs/apps/tile.hpp +++ b/src/netxs/apps/tile.hpp @@ -352,10 +352,10 @@ namespace netxs::app::tile gear.dismiss(); }; auto& keybd = boss.template plugins(); - keybd.proc(action::TileMoveGrip , [&](hids& gear, txts& args){ gear.set_handled(); boss.base::riseup(tier::preview, app::tile::events::ui::grips::move, { args.size() ? xml::take_or(args.front(), dot_00) : dot_00 }); }); - keybd.proc(action::TileResizeGrip , [&](hids& gear, txts& args){ gear.set_handled(); boss.base::riseup(tier::preview, app::tile::events::ui::grips::resize, { args.size() ? xml::take_or(args.front(), 0) : 0 }); }); - keybd.proc(action::TileFocusPrevGrip, [&](hids& gear, txts& /*args*/){ boss.base::riseup(tier::preview, app::tile::events::ui::focus::prevgrip, gear); }); - keybd.proc(action::TileFocusNextGrip, [&](hids& gear, txts& /*args*/){ boss.base::riseup(tier::preview, app::tile::events::ui::focus::nextgrip, gear); }); + keybd.proc(action::TileMoveGrip , [&](hids& gear){ gear.set_handled(); boss.base::riseup(tier::preview, app::tile::events::ui::grips::move, gear.get_args_or()); }); + keybd.proc(action::TileResizeGrip , [&](hids& gear){ gear.set_handled(); boss.base::riseup(tier::preview, app::tile::events::ui::grips::resize, gear.get_args_or()); }); + keybd.proc(action::TileFocusPrevGrip, [&](hids& gear){ boss.base::riseup(tier::preview, app::tile::events::ui::focus::prevgrip, gear); }); + keybd.proc(action::TileFocusNextGrip, [&](hids& gear){ boss.base::riseup(tier::preview, app::tile::events::ui::focus::nextgrip, gear); }); keybd.bind(*grip_bindings_ptr); }); return node; @@ -902,21 +902,21 @@ namespace netxs::app::tile boss.base::riseup(tier::release, e2::form::proceed::quit::one, true); }; auto& keybd = boss.template plugins(); - keybd.proc(action::TileFocusPrev , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::focus::prev, gear); }); - keybd.proc(action::TileFocusNext , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::focus::next, gear); }); - keybd.proc(action::TileFocusPrevPane , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::focus::prevpane, gear); }); - keybd.proc(action::TileFocusNextPane , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::focus::nextpane, gear); }); - keybd.proc(action::TileFocusPrevGrip , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::focus::prevgrip, gear); }); - keybd.proc(action::TileFocusNextGrip , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::focus::nextgrip, gear); }); - keybd.proc(action::TileRunApplicatoin , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::create, gear); }); - keybd.proc(action::TileSelectAllPanes , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::select, gear); }); - keybd.proc(action::TileSplitHorizontally , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::split::hz, gear); }); - keybd.proc(action::TileSplitVertically , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::split::vt, gear); }); - keybd.proc(action::TileSplitOrientation , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::rotate, gear); }); - keybd.proc(action::TileSwapPanes , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::swap, gear); }); - keybd.proc(action::TileEqualizeSplitRatio, [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::equalize, gear); }); - keybd.proc(action::TileSetManagerTitle , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::title , gear); }); - keybd.proc(action::TileClosePane , [&](hids& gear, txts& /*args*/){ boss.bell::signal(tier::preview, app::tile::events::ui::close, gear); }); + keybd.proc(action::TileFocusPrev , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::focus::prev, gear); }); + keybd.proc(action::TileFocusNext , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::focus::next, gear); }); + keybd.proc(action::TileFocusPrevPane , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::focus::prevpane, gear); }); + keybd.proc(action::TileFocusNextPane , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::focus::nextpane, gear); }); + keybd.proc(action::TileFocusPrevGrip , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::focus::prevgrip, gear); }); + keybd.proc(action::TileFocusNextGrip , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::focus::nextgrip, gear); }); + keybd.proc(action::TileRunApplicatoin , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::create, gear); }); + keybd.proc(action::TileSelectAllPanes , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::select, gear); }); + keybd.proc(action::TileSplitHorizontally , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::split::hz, gear); }); + keybd.proc(action::TileSplitVertically , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::split::vt, gear); }); + keybd.proc(action::TileSplitOrientation , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::rotate, gear); }); + keybd.proc(action::TileSwapPanes , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::swap, gear); }); + keybd.proc(action::TileEqualizeSplitRatio, [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::equalize, gear); }); + keybd.proc(action::TileSetManagerTitle , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::title , gear); }); + keybd.proc(action::TileClosePane , [&](hids& gear){ boss.bell::signal(tier::preview, app::tile::events::ui::close, gear); }); auto bindings = pro::keybd::load(config, "tile"); keybd.bind(bindings); diff --git a/src/netxs/desktopio/application.hpp b/src/netxs/desktopio/application.hpp index 61beb59b13..e95c8c6a92 100644 --- a/src/netxs/desktopio/application.hpp +++ b/src/netxs/desktopio/application.hpp @@ -114,7 +114,7 @@ namespace netxs::app::shared { auto& scroll_inst = *scroll; auto esc_pressed = ptr::shared(faux); - keybd.proc("WindowClose", [&, esc_pressed](hids& gear, txts&) + keybd.proc("WindowClose", [&, esc_pressed](hids& gear) { if (*esc_pressed) { @@ -122,30 +122,30 @@ namespace netxs::app::shared gear.set_handled(); } }); - keybd.proc("WindowClosePreview", [&, esc_pressed](hids& /*gear*/, txts&) + keybd.proc("WindowClosePreview", [&, esc_pressed](hids& /*gear*/) { if (std::exchange(*esc_pressed, true) != *esc_pressed) { boss.bell::signal(tier::anycast, e2::form::state::keybd::command::close, *esc_pressed); } }); - keybd.proc("CancelWindowClose", [&, esc_pressed](hids& /*gear*/, txts&) + keybd.proc("CancelWindowClose", [&, esc_pressed](hids& /*gear*/) { if (std::exchange(*esc_pressed, faux) != *esc_pressed) { boss.bell::signal(tier::anycast, e2::form::state::keybd::command::close, *esc_pressed); } }); - keybd.proc("ScrollPageUp" , [&](hids& gear, txts&){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::bypage::y, { .vector = { 0, 1 }}); }); - keybd.proc("ScrollPageDown" , [&](hids& gear, txts&){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::bypage::y, { .vector = { 0,-1 }}); }); - keybd.proc("ScrollLineUp" , [&](hids& gear, txts&){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::bystep::y, { .vector = { 0, 3 }}); }); - keybd.proc("ScrollLineDown" , [&](hids& gear, txts&){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::bystep::y, { .vector = { 0,-3 }}); }); - keybd.proc("ScrollCharLeft" , [&](hids& gear, txts&){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::bystep::x, { .vector = { 3, 0 }}); }); - keybd.proc("ScrollCharRight" , [&](hids& gear, txts&){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::bystep::x, { .vector = {-3, 0 }}); }); - keybd.proc("ScrollTop" , [&](hids& gear, txts&){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::to_top::y); }); - keybd.proc("ScrollEnd" , [&](hids& gear, txts&){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::to_end::y); }); - keybd.proc("ToggleMaximize" , [&](hids& gear, txts&){ gear.set_handled(); scroll_inst.bell::enqueue(boss.This(), [&, gear_id = gear.id](auto& /*boss*/){ if (auto gear_ptr = boss.bell::getref(gear_id)) scroll_inst.base::riseup(tier::preview, e2::form::size::enlarge::maximize, *gear_ptr); }); }); // Refocus-related operations require execution outside of keyboard eves. - keybd.proc("ToggleFullscreen", [&](hids& gear, txts&){ gear.set_handled(); scroll_inst.bell::enqueue(boss.This(), [&, gear_id = gear.id](auto& /*boss*/){ if (auto gear_ptr = boss.bell::getref(gear_id)) scroll_inst.base::riseup(tier::preview, e2::form::size::enlarge::fullscreen, *gear_ptr); }); }); + keybd.proc("ScrollPageUp" , [&](hids& gear){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::bypage::y, { .vector = { 0, 1 }}); }); + keybd.proc("ScrollPageDown" , [&](hids& gear){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::bypage::y, { .vector = { 0,-1 }}); }); + keybd.proc("ScrollLineUp" , [&](hids& gear){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::bystep::y, { .vector = { 0, 3 }}); }); + keybd.proc("ScrollLineDown" , [&](hids& gear){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::bystep::y, { .vector = { 0,-3 }}); }); + keybd.proc("ScrollCharLeft" , [&](hids& gear){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::bystep::x, { .vector = { 3, 0 }}); }); + keybd.proc("ScrollCharRight" , [&](hids& gear){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::bystep::x, { .vector = {-3, 0 }}); }); + keybd.proc("ScrollTop" , [&](hids& gear){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::to_top::y); }); + keybd.proc("ScrollEnd" , [&](hids& gear){ gear.set_handled(); scroll_inst.base::riseup(tier::preview, e2::form::upon::scroll::to_end::y); }); + keybd.proc("ToggleMaximize" , [&](hids& gear){ gear.set_handled(); scroll_inst.bell::enqueue(boss.This(), [&, gear_id = gear.id](auto& /*boss*/){ if (auto gear_ptr = boss.bell::getref(gear_id)) scroll_inst.base::riseup(tier::preview, e2::form::size::enlarge::maximize, *gear_ptr); }); }); // Refocus-related operations require execution outside of keyboard eves. + keybd.proc("ToggleFullscreen", [&](hids& gear){ gear.set_handled(); scroll_inst.bell::enqueue(boss.This(), [&, gear_id = gear.id](auto& /*boss*/){ if (auto gear_ptr = boss.bell::getref(gear_id)) scroll_inst.base::riseup(tier::preview, e2::form::size::enlarge::fullscreen, *gear_ptr); }); }); keybd.bind( "Esc", "DropAutoRepeat" , true); keybd.bind( "Esc", "WindowClosePreview", true); diff --git a/src/netxs/desktopio/console.hpp b/src/netxs/desktopio/console.hpp index 6347342239..d0e811bbdd 100644 --- a/src/netxs/desktopio/console.hpp +++ b/src/netxs/desktopio/console.hpp @@ -1125,7 +1125,7 @@ namespace netxs::ui yield{ faux }, fullscreen{ faux } { - keybd.proc("ToggleDebugOverlay", [&](hids& gear, txts&){ gear.set_handled(); debug ? debug.stop() : debug.start(); }); + keybd.proc("ToggleDebugOverlay", [&](hids& gear){ gear.set_handled(); debug ? debug.stop() : debug.start(); }); auto bindings = pro::keybd::load(config, "tui"); keybd.bind(bindings); diff --git a/src/netxs/desktopio/controls.hpp b/src/netxs/desktopio/controls.hpp index d62c07db87..4f04ac4c50 100644 --- a/src/netxs/desktopio/controls.hpp +++ b/src/netxs/desktopio/controls.hpp @@ -2040,7 +2040,7 @@ namespace netxs::ui class keybd : public skill { - using func = std::function; + using func = std::function; using wptr = netxs::wptr; using sptr = netxs::sptr; using skill::boss, @@ -2098,7 +2098,12 @@ namespace netxs::ui auto proc_ptr = proc_wptr.lock(); if (proc_ptr) { - if (!interrupt_key_proc) (*proc_ptr)(gear, *args_ptr); + if (!interrupt_key_proc) + { + auto temp = std::exchange(gear.args_ptr, args_ptr); + (*proc_ptr)(gear); + gear.args_ptr = temp; + } } return !proc_ptr; }); @@ -2164,8 +2169,8 @@ namespace netxs::ui if (!gear.touched && !gear.handled) _dispatch(gear, true, input::key::kmap::any_key); } }; - proc("Noop", [&](hids& gear, txts&){ gear.set_handled(); interrupt_key_proc = true; }); - proc("DropAutoRepeat", [&](hids& gear, txts&){ if (gear.keystat == input::key::repeated) { gear.set_handled(); interrupt_key_proc = true; }}); + proc("Noop", [&](hids& gear){ gear.set_handled(); interrupt_key_proc = true; }); + proc("DropAutoRepeat", [&](hids& gear){ if (gear.keystat == input::key::repeated) { gear.set_handled(); interrupt_key_proc = true; }}); } auto filter(hids& gear) diff --git a/src/netxs/desktopio/gui.hpp b/src/netxs/desktopio/gui.hpp index 9ee250acdf..c11060a49b 100644 --- a/src/netxs/desktopio/gui.hpp +++ b/src/netxs/desktopio/gui.hpp @@ -1994,14 +1994,14 @@ namespace netxs::gui wdelta{ 24.f }, stream{ *this, *os::dtvt::client } { - wkeybd.proc("IncreaseCellHeight" , [&](hids& gear, txts&){ gear.set_handled(); IncreaseCellHeight(1.f); }); - wkeybd.proc("DecreaseCellHeight" , [&](hids& gear, txts&){ gear.set_handled(); IncreaseCellHeight(-1.f);}); - wkeybd.proc("ResetCellHeight" , [&](hids& gear, txts&){ gear.set_handled(); ResetCellHeight(); }); - wkeybd.proc("ToggleFullscreenMode" , [&](hids& gear, txts&){ gear.set_handled(); ToggleFullscreenMode(); }); - wkeybd.proc("ToggleAntialiasingMode", [&](hids& gear, txts&){ gear.set_handled(); ToggleAntialiasingMode(); }); - wkeybd.proc("RollFontsBackward" , [&](hids& gear, txts&){ gear.set_handled(); RollFontList(feed::rev); }); - wkeybd.proc("RollFontsForward" , [&](hids& gear, txts&){ gear.set_handled(); RollFontList(feed::fwd); }); - wkeybd.proc("_ResetWheelAccumulator", [&](hids& /*gear*/, txts&){ whlacc = {}; }); + wkeybd.proc("IncreaseCellHeight" , [&](hids& gear){ gear.set_handled(); IncreaseCellHeight(1.f); }); + wkeybd.proc("DecreaseCellHeight" , [&](hids& gear){ gear.set_handled(); IncreaseCellHeight(-1.f);}); + wkeybd.proc("ResetCellHeight" , [&](hids& gear){ gear.set_handled(); ResetCellHeight(); }); + wkeybd.proc("ToggleFullscreenMode" , [&](hids& gear){ gear.set_handled(); ToggleFullscreenMode(); }); + wkeybd.proc("ToggleAntialiasingMode", [&](hids& gear){ gear.set_handled(); ToggleAntialiasingMode(); }); + wkeybd.proc("RollFontsBackward" , [&](hids& gear){ gear.set_handled(); RollFontList(feed::rev); }); + wkeybd.proc("RollFontsForward" , [&](hids& gear){ gear.set_handled(); RollFontList(feed::fwd); }); + wkeybd.proc("_ResetWheelAccumulator", [&](hids& /*gear*/){ whlacc = {}; }); wkeybd.bind("-Ctrl", "_ResetWheelAccumulator", true); wkeybd.bind("-Ctrl", "_ResetWheelAccumulator", true); wkeybd.bind(hotkeys); diff --git a/src/netxs/desktopio/input.hpp b/src/netxs/desktopio/input.hpp index 0023de1462..a7b790cb71 100644 --- a/src/netxs/desktopio/input.hpp +++ b/src/netxs/desktopio/input.hpp @@ -1504,6 +1504,24 @@ namespace netxs::input rect slot; // slot for pro::maker and e2::createby. bool slot_forced = faux; // . + //todo unify + netxs::sptr args_ptr; // args passed by pro::keybd. + template + auto get_args_or(T fallback = {}) + { + if (args_ptr && args_ptr->size()) + { + return xml::take_or(args_ptr->front(), fallback); + } + else + { + return fallback; + } + } + template<> auto get_args_or(text fallback) { return args_ptr && args_ptr->size() ? args_ptr->front() : fallback; } + template<> auto get_args_or(qiew fallback) { return args_ptr && args_ptr->size() ? qiew{ args_ptr->front() } : fallback; } + template<> auto get_args_or(view fallback) { return args_ptr && args_ptr->size() ? view{ args_ptr->front() } : fallback; } + //todo unify bool mouse_disabled = faux; // Hide mouse cursor. bool keybd_disabled = faux; // Inactive gear. diff --git a/src/netxs/desktopio/terminal.hpp b/src/netxs/desktopio/terminal.hpp index be69f9c97f..14ea932104 100644 --- a/src/netxs/desktopio/terminal.hpp +++ b/src/netxs/desktopio/terminal.hpp @@ -7839,34 +7839,34 @@ namespace netxs::ui publish_property(ui::term::events::search::status, [&](auto& v){ v = target->selection_button(); }); selection_selmod(config.def_selmod); - chords.proc(action::TerminalScrollViewportByPage, [&](hids& gear, txts& args){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bypage::v, { .vector = args.size() ? xml::take_or(args.front(), dot_00) : dot_00 }); }); - chords.proc(action::TerminalScrollViewportByCell, [&](hids& gear, txts& args){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bystep::v, { .vector = args.size() ? xml::take_or(args.front(), dot_00) : dot_00 }); }); - chords.proc(action::TerminalScrollViewportToTop, [&](hids& gear, txts&){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::to_top::y); }); - chords.proc(action::TerminalScrollViewportToEnd, [&](hids& gear, txts&){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::to_end::y); }); - chords.proc(action::TerminalFindPrev, [&](hids& gear, txts&){ gear.set_handled(); selection_search(gear, feed::rev); }); - chords.proc(action::TerminalFindNext, [&](hids& gear, txts&){ gear.set_handled(); selection_search(gear, feed::fwd); }); - chords.proc(action::TerminalCwdSync, [&](hids& gear, txts&){ gear.set_handled(); base::riseup(tier::preview, ui::term::events::toggle::cwdsync, true); }); - chords.proc(action::TerminalQuit, [&](hids& gear, txts&){ gear.set_handled(); exec_cmd(commands::ui::sighup); }); - chords.proc(action::TerminalRestart, [&](hids& gear, txts&){ gear.set_handled(); exec_cmd(commands::ui::restart); }); - chords.proc(action::TerminalFullscreen, [&](hids& gear, txts&){ gear.set_handled(); bell::enqueue(This(), [&, gear_id = gear.id](auto& /*boss*/){ if (auto gear_ptr = bell::getref(gear_id)) base::riseup(tier::preview, e2::form::size::enlarge::fullscreen, *gear_ptr); }); }); // Refocus-related operations require execution outside of keyboard events. - chords.proc(action::TerminalMaximize, [&](hids& gear, txts&){ gear.set_handled(); bell::enqueue(This(), [&, gear_id = gear.id](auto& /*boss*/){ if (auto gear_ptr = bell::getref(gear_id)) base::riseup(tier::preview, e2::form::size::enlarge::maximize, *gear_ptr); }); }); - chords.proc(action::TerminalMinimize, [&](hids& gear, txts&){ gear.set_handled(); bell::enqueue(This(), [&, gear_id = gear.id](auto& /*boss*/){ if (auto gear_ptr = bell::getref(gear_id)) base::riseup(tier::release, e2::form::size::minimize, *gear_ptr); }); }); - chords.proc(action::TerminalUndo, [&](hids& gear, txts&){ gear.set_handled(); exec_cmd(commands::ui::undo); }); - chords.proc(action::TerminalRedo, [&](hids& gear, txts&){ gear.set_handled(); exec_cmd(commands::ui::redo); }); - chords.proc(action::TerminalClipboardCopy, [&](hids& gear, txts&){ if (selection_active()) { copy(gear); gear.set_handled(); } else if (auto v = ipccon.get_current_line()) { _copy(gear, v.value()); gear.set_handled(); }}); - chords.proc(action::TerminalClipboardPaste, [&](hids& gear, txts&){ gear.set_handled(); paste(gear); }); - chords.proc(action::TerminalClipboardWipe, [&](hids& gear, txts&){ gear.set_handled(); gear.clear_clipboard(); }); - chords.proc(action::TerminalClipboardFormat, [&](hids& gear, txts& args){ gear.set_handled(); if (args.empty()) exec_cmd(commands::ui::togglesel); else set_selmod((si32)netxs::get_or(xml::options::format, args.front(), mime::textonly)); }); - chords.proc(action::TerminalViewportCopy, [&](hids& gear, txts&){ gear.set_handled(); prnscrn(gear); }); - chords.proc(action::TerminalSelectionCancel, [&](hids& gear, txts&){ if (!selection_active()) return; gear.set_handled(); exec_cmd(commands::ui::deselect); }); - chords.proc(action::TerminalSelectionRect, [&](hids& gear, txts& args){ gear.set_handled(); if (args.empty()) exec_cmd(commands::ui::toggleselalt); else set_selalt(xml::take_or(args.front(), faux)); }); - chords.proc(action::TerminalSelectionOneShot, [&](hids& gear, txts& args){ gear.set_handled(); if (args.empty()) set_oneshot(mime::textonly); else set_oneshot(netxs::get_or(xml::options::format, args.front(), mime::textonly)); }); - chords.proc(action::TerminalStdioLog, [&](hids& gear, txts& args){ gear.set_handled(); set_log(args.size() ? xml::take_or(args.front(), !io_log) : !io_log); ondata(); }); - chords.proc(action::TerminalSendKey, [&](hids& gear, txts& args){ gear.set_handled(); if (args.size()) data_out(args.front()); }); - chords.proc(action::TerminalOutput, [&](hids& gear, txts& args){ gear.set_handled(); if (args.size()) data_in(args.front()); }); - chords.proc(action::TerminalAlignMode, [&](hids& gear, txts& args){ gear.set_handled(); if (args.empty()) exec_cmd(commands::ui::togglejet); else set_align((si32)netxs::get_or(xml::options::align, args.front(), bias::none)); }); - chords.proc(action::TerminalWrapMode, [&](hids& gear, txts& args){ gear.set_handled(); if (args.empty()) exec_cmd(commands::ui::togglewrp); else set_wrapln(1 + (si32)!xml::take_or(args.front(), true)); }); - chords.proc(action::ExclusiveKeyboardMode, [&](hids& gear, txts& args){ gear.set_handled(); if (args.empty()) exec_cmd(commands::ui::toggleraw); else set_rawkbd(1 + (si32)!xml::take_or(args.front(), true)); }); + chords.proc(action::TerminalScrollViewportByPage, [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bypage::v, { .vector = gear.get_args_or() }); }); + chords.proc(action::TerminalScrollViewportByCell, [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::bystep::v, { .vector = gear.get_args_or() }); }); + chords.proc(action::TerminalScrollViewportToTop, [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::to_top::y); }); + chords.proc(action::TerminalScrollViewportToEnd, [&](hids& gear){ if (target != &normal) return; gear.set_handled(); base::riseup(tier::preview, e2::form::upon::scroll::to_end::y); }); + chords.proc(action::TerminalFindPrev, [&](hids& gear){ gear.set_handled(); selection_search(gear, feed::rev); }); + chords.proc(action::TerminalFindNext, [&](hids& gear){ gear.set_handled(); selection_search(gear, feed::fwd); }); + chords.proc(action::TerminalCwdSync, [&](hids& gear){ gear.set_handled(); base::riseup(tier::preview, ui::term::events::toggle::cwdsync, true); }); + chords.proc(action::TerminalQuit, [&](hids& gear){ gear.set_handled(); exec_cmd(commands::ui::sighup); }); + chords.proc(action::TerminalRestart, [&](hids& gear){ gear.set_handled(); exec_cmd(commands::ui::restart); }); + chords.proc(action::TerminalFullscreen, [&](hids& gear){ gear.set_handled(); bell::enqueue(This(), [&, gear_id = gear.id](auto& /*boss*/){ if (auto gear_ptr = bell::getref(gear_id)) base::riseup(tier::preview, e2::form::size::enlarge::fullscreen, *gear_ptr); }); }); // Refocus-related operations require execution outside of keyboard events. + chords.proc(action::TerminalMaximize, [&](hids& gear){ gear.set_handled(); bell::enqueue(This(), [&, gear_id = gear.id](auto& /*boss*/){ if (auto gear_ptr = bell::getref(gear_id)) base::riseup(tier::preview, e2::form::size::enlarge::maximize, *gear_ptr); }); }); + chords.proc(action::TerminalMinimize, [&](hids& gear){ gear.set_handled(); bell::enqueue(This(), [&, gear_id = gear.id](auto& /*boss*/){ if (auto gear_ptr = bell::getref(gear_id)) base::riseup(tier::release, e2::form::size::minimize, *gear_ptr); }); }); + chords.proc(action::TerminalUndo, [&](hids& gear){ gear.set_handled(); exec_cmd(commands::ui::undo); }); + chords.proc(action::TerminalRedo, [&](hids& gear){ gear.set_handled(); exec_cmd(commands::ui::redo); }); + chords.proc(action::TerminalClipboardCopy, [&](hids& gear){ if (selection_active()) { copy(gear); gear.set_handled(); } else if (auto v = ipccon.get_current_line()) { _copy(gear, v.value()); gear.set_handled(); }}); + chords.proc(action::TerminalClipboardPaste, [&](hids& gear){ gear.set_handled(); paste(gear); }); + chords.proc(action::TerminalClipboardWipe, [&](hids& gear){ gear.set_handled(); gear.clear_clipboard(); }); + chords.proc(action::TerminalClipboardFormat, [&](hids& gear){ gear.set_handled(); if (!gear.args_ptr || gear.args_ptr->empty()) exec_cmd(commands::ui::togglesel); else set_selmod((si32)netxs::get_or(xml::options::format, gear.args_ptr->front(), mime::textonly)); }); + chords.proc(action::TerminalViewportCopy, [&](hids& gear){ gear.set_handled(); prnscrn(gear); }); + chords.proc(action::TerminalSelectionCancel, [&](hids& gear){ if (!selection_active()) return; gear.set_handled(); exec_cmd(commands::ui::deselect); }); + chords.proc(action::TerminalSelectionRect, [&](hids& gear){ gear.set_handled(); if (!gear.args_ptr || gear.args_ptr->empty()) exec_cmd(commands::ui::toggleselalt); else set_selalt(xml::take_or(gear.args_ptr->front(), faux)); }); + chords.proc(action::TerminalSelectionOneShot, [&](hids& gear){ gear.set_handled(); if (!gear.args_ptr || gear.args_ptr->empty()) set_oneshot(mime::textonly); else set_oneshot(netxs::get_or(xml::options::format, gear.args_ptr->front(), mime::textonly)); }); + chords.proc(action::TerminalStdioLog, [&](hids& gear){ gear.set_handled(); set_log(gear.get_args_or(!io_log)); ondata(); }); + chords.proc(action::TerminalSendKey, [&](hids& gear){ gear.set_handled(); if (auto crop = gear.get_args_or()) data_out(crop); }); + chords.proc(action::TerminalOutput, [&](hids& gear){ gear.set_handled(); if (auto crop = gear.get_args_or()) data_in(crop); }); + chords.proc(action::TerminalAlignMode, [&](hids& gear){ gear.set_handled(); if (!gear.args_ptr || gear.args_ptr->empty()) exec_cmd(commands::ui::togglejet); else set_align((si32)netxs::get_or(xml::options::align, gear.args_ptr->front(), bias::none)); }); + chords.proc(action::TerminalWrapMode, [&](hids& gear){ gear.set_handled(); if (!gear.args_ptr || gear.args_ptr->empty()) exec_cmd(commands::ui::togglewrp); else set_wrapln(1 + (si32)!gear.get_args_or(true)); }); + chords.proc(action::ExclusiveKeyboardMode, [&](hids& gear){ gear.set_handled(); if (!gear.args_ptr || gear.args_ptr->empty()) exec_cmd(commands::ui::toggleraw); else set_rawkbd(1 + (si32)!gear.get_args_or(true)); }); auto bindings = pro::keybd::load(xml_config, "terminal"); chords.bind(bindings); diff --git a/src/netxs/desktopio/xml.hpp b/src/netxs/desktopio/xml.hpp index 0c85be7d2d..7d521faa04 100644 --- a/src/netxs/desktopio/xml.hpp +++ b/src/netxs/desktopio/xml.hpp @@ -70,6 +70,32 @@ namespace netxs::xml return std::nullopt; } template<> + auto take(qiew utf8) -> std::optional + { + utf::trim_front(utf8, " ({[\"\'"); + if (utf8) + if (auto l = utf::to_int(utf8)) + { + utf::trim_front(utf8, " ,.x/:;"); + if (auto r = utf::to_int(utf8)) + { + utf::trim_front(utf8, " ,.x/:;"); + if (auto t = utf::to_int(utf8)) + { + utf::trim_front(utf8, " ,.x/:;"); + if (auto b = utf::to_int(utf8)) + { + return dent{ l.value(), r.value(), t.value(), b.value() }; + } + else return dent{ l.value(), r.value(), t.value() }; + } + else return dent{ l.value(), r.value() }; + } + else return dent{ l.value() }; + } + return std::nullopt; + } + template<> auto take(qiew utf8) -> std::optional { using namespace std::chrono; diff --git a/src/vtm.hpp b/src/vtm.hpp index 5de37d13ac..e60fdc8ed3 100644 --- a/src/vtm.hpp +++ b/src/vtm.hpp @@ -745,11 +745,17 @@ namespace netxs::app::vtm { //todo local=>nexthop local = faux; - keybd.proc("FocusPrevWindow", [&](hids& gear, txts&){ focus_next_window(gear, feed::rev); }); - keybd.proc("FocusNextWindow", [&](hids& gear, txts&){ focus_next_window(gear, feed::fwd); }); - keybd.proc("Disconnect", [&](hids& gear, txts&){ disconnect(gear); }); - keybd.proc("TryToQuit", [&](hids& gear, txts&){ try_quit(gear); }); - keybd.proc("RunApplication", [&](hids& gear, txts& args){ create_app(gear, args.empty() ? "" : args.front()); gear.set_handled(); }); + 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("TryToQuit", [&](hids& gear){ try_quit(gear); }); + keybd.proc("RunApplication", [&](hids& gear){ create_app(gear); gear.set_handled(); }); + //keybd.proc("AlwaysOnTopWindow", [&](hids& gear){ always_on_top_focused_windows(gear); }); + //keybd.proc("WarpWindow", [&](hids& gear){ warp_focused_windows(gear); }); + //keybd.proc("CloseWindow", [&](hids& gear){ close_focused_windows(gear); }); + //keybd.proc("MinimizeWindow", [&](hids& gear){ minimize_focused_windows(gear); }); + //keybd.proc("MaximizeWindow", [&](hids& gear){ maximize_focused_windows(gear); }); + //keybd.proc("FullscreenWindow", [&](hids& gear){ fullscreen_first_focused_window(gear); }); auto bindings = pro::keybd::load(config, "desktop"); keybd.bind(bindings); @@ -878,9 +884,10 @@ namespace netxs::app::vtm }; } - void create_app(hids& gear, qiew inst_id = {}) + void create_app(hids& gear) { static auto offset = dot_00; // static: Share initial offset between all instances. + auto inst_id = gear.get_args_or(); if (auto world_ptr = nexthop.lock()) { if (inst_id) @@ -1765,6 +1772,41 @@ namespace netxs::app::vtm bell::signal(tier::general, e2::shutdown, utf::concat(prompt::repl, "Server shutdown")); return "ok"s; } + void always_on_top_focused_windows(hids& gear) + { + if (gear.args_ptr) + { + auto state = gear.args_ptr->empty() ? -1 : (si32)xml::take_or(gear.args_ptr->front(), faux); + log("always_on_top_focused_windows"); + gear.set_handled(); + } + } + void close_focused_windows(hids& gear) + { + log("close_focused_windows"); + gear.set_handled(); + } + void minimize_focused_windows(hids& gear) + { + log("minimize_focused_windows"); + gear.set_handled(); + } + void maximize_focused_windows(hids& gear) + { + log("maximize_focused_windows"); + gear.set_handled(); + } + void fullscreen_first_focused_window(hids& gear) + { + log("fullscreen_first_focused_window"); + gear.set_handled(); + } + void warp_focused_windows(hids& gear) + { + auto warp_delta = gear.get_args_or(); + log("warp_focused_windows"); + gear.set_handled(); + } public: hall(xipc server, xmls& config) diff --git a/src/vtm.xml b/src/vtm.xml index 6f77f1cb22..11edc62ccf 100644 --- a/src/vtm.xml +++ b/src/vtm.xml @@ -454,6 +454,12 @@ R"==( + + + + + +