From 15d281d77ca5dcee09133d933c2370ae1979c738 Mon Sep 17 00:00:00 2001 From: pit-ray Date: Fri, 3 Dec 2021 13:47:17 +0900 Subject: [PATCH] add cmd2cmd noremap, but not support global pool yet --- src/core/main_loop.cpp | 19 ++++++++----------- src/core/mapgate.cpp | 28 +++++++++++++++++----------- src/core/mapgate.hpp | 2 +- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/core/main_loop.cpp b/src/core/main_loop.cpp index eb486158..bb2dd523 100644 --- a/src/core/main_loop.cpp +++ b/src/core/main_loop.cpp @@ -52,19 +52,10 @@ namespace vind KeyLog log{} ; if(!has_pool) { log = get_pressed_list() ; - } - else { - log = std::move(g_logpool.front()) ; - g_logpool.pop() ; - } - auto result = g_ntlgr.logging_state(log) ; - if(!has_pool) { - auto logpool = MapGate::get_instance().map_logger(g_ntlgr) ; + auto logpool = MapGate::get_instance().map_logger(log) ; if(!logpool.empty()) { - g_ntlgr.clear() ; - - result = g_ntlgr.logging_state(std::move(logpool.front())) ; + log = std::move(logpool.front()) ; logpool.pop() ; if(!logpool.empty()) { @@ -72,6 +63,12 @@ namespace vind } } } + else { + log = std::move(g_logpool.front()) ; + g_logpool.pop() ; + } + + auto result = g_ntlgr.logging_state(log) ; if(NTYPE_EMPTY(result)) { return ; diff --git a/src/core/mapgate.cpp b/src/core/mapgate.cpp index a5a70d61..8ba1b0fa 100644 --- a/src/core/mapgate.cpp +++ b/src/core/mapgate.cpp @@ -440,24 +440,30 @@ namespace vind } MapGate::KeyLogPool MapGate::map_logger( - const NTypeLogger& lgr, + const KeyLog& log, Mode mode) { auto midx = static_cast(mode) ; auto& mgr = pimpl->mgr_table_[midx] ; - mgr.transition_parser_states_in_batch(lgr) ; - auto maphook = mgr.find_accepted_parser() ; - if(!maphook) { - return KeyLogPool{} ; - } + auto parser = mgr.find_parser_with_transition(log) ; + if(parser) { + if(parser->is_accepted()) { + auto func = parser->get_func() ; + func->process() ; + mgr.reset_parser_states() ; + return pimpl->logpool_table_[midx][func->id()] ; - auto func = maphook->get_func() ; - bind::safe_for(lgr.get_head_num(), [&func] { - func->process() ; - }) ; + } + else if(parser->is_rejected_with_ready()) { + mgr.reset_parser_states() ; + } + } + else { + mgr.reset_parser_states() ; + } - return pimpl->logpool_table_[midx][func->id()] ; + return KeyLogPool{} ; } bool MapGate::map_syncstate( diff --git a/src/core/mapgate.hpp b/src/core/mapgate.hpp index d2cd927d..d9cfdac7 100644 --- a/src/core/mapgate.hpp +++ b/src/core/mapgate.hpp @@ -40,7 +40,7 @@ namespace vind // using KeyLogPool = std::queue ; KeyLogPool map_logger( - const NTypeLogger& lgr, + const KeyLog& log, Mode mode=get_global_mode()) ; //