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

Add showcmd #236

Merged
merged 10 commits into from
May 18, 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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.6.0)
project(win-vind VERSION 5.12.0)
set(INTERNAL_VERSION ${PROJECT_VERSION}.0)
project(win-vind VERSION 5.13.0)
set(INTERNAL_VERSION ${PROJECT_VERSION}.1)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
Expand Down
13 changes: 11 additions & 2 deletions docs/cheat_sheet/options/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,21 @@ Font size of GUI
Specify the characters of hint used for EasyClick and GridMove. It accpets as input a set of non-duplicate characters and assigns them to the hints in order from the first to the last.



## Command Line

### **`vcmdline`**
**type**: bool, **default**: true
show virtual command line
Show virtual command line

<hr class="dash">

### **`showcmd`**
**type**: bool, **default**: true
Show the partial command in the virtual command line.
This feature causes some overhead.
If the count of repeats for a command is specified, the command is displayed following the count of repeats.
If you do not enter a repeat count for a command, then the repeat count is denoted as 1.
Unlike Vim, the repeat count is always explicitly displayed to reduce mistakes in the repeat count.

<hr class="dash">

Expand Down
35 changes: 34 additions & 1 deletion src/core/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ SOFTWARE.
#include <cstring>
#include <fstream>
#include <memory>
#include <sstream>

#include "autocmd.hpp"

Expand Down Expand Up @@ -317,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 @@ -370,10 +372,41 @@ namespace vind

do {
CmdUnit::SPtr input ;
std::uint16_t count ;
std::uint16_t count = 0 ;
if(!ihub.pull_input(input, count)) {
if(count > 0) {
opt::VCmdLine::reset() ;
opt::VCmdLine::print(opt::StaticMessage(std::to_string(count))) ;
}
continue ;
}

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 ;
}
std::stringstream ss ;
ss << count ;

auto cmd = matcher->get_command() ;
auto end_itr = cmd.begin() + hist_size ;
for(auto itr = cmd.begin() ; itr != end_itr ; itr ++) {
ss << **itr ;
}
opt::VCmdLine::reset() ;
opt::VCmdLine::print(opt::StaticMessage(ss.str())) ;
break ;
}
}

handle_system_call(input->execute(count)) ;

// correct the state to avoid cases that a virtual key
Expand Down
3 changes: 3 additions & 0 deletions src/core/inputhub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ namespace vind
*input, pimpl->count_.size() > 0) ;
if(!new_count.empty()) {
pimpl->count_ += new_count ;

// Store the count number, but return as false.
count = util::extract_num<std::uint16_t>(pimpl->count_) ;
return false ;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/inputhub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace vind
public:
static InputHub& get_instance() ;

std::shared_ptr<MapSolver> get_solver(Mode mode) ;
std::shared_ptr<MapSolver> get_solver(Mode mode=get_global_mode()) ;

/*
* Emulate text input and retrieve input at the appropriate time.
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
2 changes: 1 addition & 1 deletion src/core/version.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _VERSION_HPP
#define _VERSION_HPP

#define WIN_VIND_VERSION "5.11.3.0"
#define WIN_VIND_VERSION "5.13.0.1"

#endif
12 changes: 6 additions & 6 deletions tools/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@

@if %compiler% == -msvc (
if %3 == 32 (
cmake -B release_32 -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -A win32 .
cmake -B release_32 -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A win32 .
cmake --build release_32 --config Release
xcopy /E /Y release_32\Release\*.exe release_32
) else (
cmake -B release_64 -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -A x64 .
cmake -B release_64 -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A x64 .
cmake --build release_64 --config Release
xcopy /E /Y release_64\Release\*.exe release_64
)
Expand All @@ -62,10 +62,10 @@
Del /q "debug/Debug"

if "%3" == "32" (
cmake -B debug -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A win32 .
cmake -B debug -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 17 2022" -A win32 .
cmake --build debug --config Debug
) else (
INTERNALcmake -B debug -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A x64 .
INTERNALcmake -B debug -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 17 2022" -A x64 .
cmake --build debug --config Debug
)

Expand All @@ -80,7 +80,7 @@
@set covdir=build_cov
@if %compiler% == -msvc (
"cov_tools/bin/cov-configure" --config %covdir%/covtest/cov.xml --msvc --template --xml-option=skip_file:".*/libs.*"
cmake -B %covdir% -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A x64 .
cmake -B %covdir% -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 17 2022" -A x64 .
xcopy /e /Y %covdir%\Debug\*.exe %covdir%

) else (
Expand All @@ -97,7 +97,7 @@
:test
cd tests
@if %compiler% == -msvc (
cmake -B build_msvc -G "Visual Studio 16 2019" unit
cmake -B build_msvc -G "Visual Studio 17 2022" unit
cmake --build build_msvc
ctest -C Debug --test-dir build_msvc --output-on-failure
) else (
Expand Down
Loading