Skip to content

Commit

Permalink
add showcmd option
Browse files Browse the repository at this point in the history
  • Loading branch information
pit-ray committed Apr 21, 2024
1 parent 7713dc9 commit b928707
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/core/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ namespace vind

void VindEntry::update() {
auto& ihub = InputHub::get_instance() ;
auto& settable = SetTable::get_instance() ;

// NOTE: it assume that these hwnd are fixed.
static const auto desktop_hwnd = GetDesktopWindow() ;
Expand Down Expand Up @@ -376,27 +377,26 @@ namespace vind
continue ;
}

auto solver = ihub.get_solver() ;
for(const auto& matcher : solver->get_trigger_matchers()) {
if(matcher->is_matching()) {
if(settable.get("showcmd").get<bool>()) {
auto solver = ihub.get_solver() ;
for(const auto& matcher : solver->get_trigger_matchers()) {
if(!matcher->is_matching()) {
continue ;
}
auto hist_size = matcher->history_size() ;
// If the any matcher isn't matched, the history size is zero.
if(hist_size == 0) {
opt::VCmdLine::reset() ;
break ;
}
auto cmd = matcher->get_command() ;
std::stringstream ss ;
for(
auto itr = cmd.begin() ;
itr < (cmd.begin() + hist_size) ;
itr ++) {
for(auto& key : **itr) {
auto uni = core::keycode_to_unicode(key, **itr) ;
if(!uni.empty()) {
ss << uni ;
}
}
auto cmd = matcher->get_command() ;
auto end_itr = cmd.begin() + hist_size ;
for(auto itr = cmd.begin() ; itr != end_itr ; itr ++) {
ss << **itr ;
}
std::cout << ss.str() << std::endl ;
opt::VCmdLine::reset() ;
opt::VCmdLine::print(opt::StaticMessage(ss.str())) ;
break ;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/core/settable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ namespace
Param("uiacachebuild_stayend", 2000),

Param("vcmdline", true),
Param("showcmd", true),

Param("vscroll_pageratio", 0.125f),
Param("vscroll_speed", 30),
Expand Down

0 comments on commit b928707

Please sign in to comment.