From d38cd59d5d7ecfc4378b0f0e579500f7073d2d14 Mon Sep 17 00:00:00 2001 From: pit-ray Date: Sat, 18 Nov 2023 00:33:32 +0900 Subject: [PATCH 1/4] add placeholder --- src/bind/mouse/focustextarea.cpp | 0 src/bind/mouse/focustextarea.hpp | 4 ++++ 2 files changed, 4 insertions(+) create mode 100644 src/bind/mouse/focustextarea.cpp create mode 100644 src/bind/mouse/focustextarea.hpp diff --git a/src/bind/mouse/focustextarea.cpp b/src/bind/mouse/focustextarea.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/bind/mouse/focustextarea.hpp b/src/bind/mouse/focustextarea.hpp new file mode 100644 index 00000000..548e81d1 --- /dev/null +++ b/src/bind/mouse/focustextarea.hpp @@ -0,0 +1,4 @@ +#ifndef _FOCUSTEXTAREA_HPP +#define _FOCUSTEXTAREA_HPP + +#endif From 99e1c6fda0ccddc8b0f6fa8a4765ea2359e659d1 Mon Sep 17 00:00:00 2001 From: pit-ray Date: Thu, 4 Jan 2024 17:35:39 +0900 Subject: [PATCH 2/4] add focus command --- res/resources/defaults/tiny.vindrc | 1 + src/bind/bindinglist.cpp | 2 + src/bind/mouse/focustextarea.cpp | 170 +++++++++++++++++++++++++++++ src/bind/mouse/focustextarea.hpp | 29 +++++ src/core/version.hpp | 2 +- 5 files changed, 203 insertions(+), 1 deletion(-) diff --git a/res/resources/defaults/tiny.vindrc b/res/resources/defaults/tiny.vindrc index 354bae33..f10606bd 100644 --- a/res/resources/defaults/tiny.vindrc +++ b/res/resources/defaults/tiny.vindrc @@ -61,6 +61,7 @@ gnnoremap Fo gnnoremap Fa gnnoremap Fm gnnoremap Fh +gnnoremap Ft gnnoremap gnnoremap AA diff --git a/src/bind/bindinglist.cpp b/src/bind/bindinglist.cpp index 29353727..f8aadc87 100644 --- a/src/bind/bindinglist.cpp +++ b/src/bind/bindinglist.cpp @@ -27,6 +27,7 @@ #include "mouse/click.hpp" #include "mouse/easyclick.hpp" +#include "mouse/focustextarea.hpp" #include "mouse/gridmove.hpp" #include "mouse/jump_actwin.hpp" #include "mouse/jump_cursor.hpp" @@ -110,6 +111,7 @@ namespace vind ExitConfigGUI::create(), Exit::create(), Sleep::create(), + FocusTextArea::create(), ForwardUINavigation::create(), GotoNextPage::create(), GotoPrevPage::create(), diff --git a/src/bind/mouse/focustextarea.cpp b/src/bind/mouse/focustextarea.cpp index e69de29b..1f4c9213 100644 --- a/src/bind/mouse/focustextarea.cpp +++ b/src/bind/mouse/focustextarea.cpp @@ -0,0 +1,170 @@ +#include "focustextarea.hpp" + +#include "core/errlogger.hpp" +#include "core/settable.hpp" +#include "opt/uiacachebuild.hpp" +#include "util/box2d.hpp" +#include "util/debug.hpp" +#include "util/def.hpp" +#include "util/rect.hpp" +#include "util/uia.hpp" +#include "util/uiwalker.hpp" +#include "util/winwrap.hpp" + +#include + +#undef max + + +namespace +{ + using namespace vind ; + + struct TextAreaScanner : public util::UIWalker { + explicit TextAreaScanner() + : UIWalker{ + UIA_IsTextPatternAvailablePropertyId, + UIA_IsValuePatternAvailablePropertyId, + UIA_HasKeyboardFocusPropertyId, + UIA_ValueIsReadOnlyPropertyId + } + { + UIWalker::enable_fullcontrol() ; + } + + virtual bool pinpoint_element(const util::SmartElement& elem) override { + BOOL flag ; + if(util::is_failed(elem->get_CachedHasKeyboardFocus(&flag))) { + throw RUNTIME_EXCEPT("Could not get a cached property value: HasKeyboardFocus.") ; + } + return flag == TRUE ; + } + + virtual bool filter_element(const util::SmartElement& elem) override { + VARIANT val ; + + if(util::is_failed(elem->GetCachedPropertyValue( + UIA_ValueIsReadOnlyPropertyId, &val))) { + throw RUNTIME_EXCEPT("Could not get a chached property value: IsReadOnly.") ; + } + if(val.vt != VT_BOOL) { + return false ; + } + if(val.boolVal == VARIANT_TRUE) { + return false ; + } + + if(util::is_failed(elem->GetCachedPropertyValue( + UIA_IsTextPatternAvailablePropertyId, &val))) { + throw RUNTIME_EXCEPT("Could not get a chached property value: IsTextPatternAvailable.") ; + } + if(val.vt != VT_BOOL) { + return false ; + } + if(val.boolVal == VARIANT_FALSE) { + return false ; + } + + if(util::is_failed(elem->GetCachedPropertyValue( + UIA_IsValuePatternAvailablePropertyId, &val))) { + throw RUNTIME_EXCEPT("Could not get a chached property value: IsValuePatternAvailable.") ; + } + if(val.vt != VT_BOOL) { + return false ; + } + if(val.boolVal == VARIANT_FALSE) { + return false ; + } + + return true ; + } + } ; +} + + +namespace vind +{ + namespace bind + { + struct FocusTextArea::Impl { + TextAreaScanner scanner_{} ; + + void focus_nearest_textarea( + HWND hwnd, + const util::Point2D& point) { + + std::vector editables{} ; + + auto& settable = core::SetTable::get_instance() ; + if(settable.get("uiacachebuild").get()) { + auto root_elem = opt::AsyncUIACacheBuilder::get_root_element(hwnd) ; + scanner_.scan(root_elem, editables) ; + } + else { + scanner_.scan(hwnd, editables) ; + } + + if(editables.empty()) { + return ; + } + + if(editables.size() == 1) { + if(util::is_failed(editables.front()->SetFocus())) { + throw RUNTIME_EXCEPT("SetFocus Failed.") ; + } + return ; + } + + util::SmartElement nearest ; + util::Box2D nearest_box ; + auto min_distance = std::numeric_limits::max() ; + + for(auto& elem : editables) { + // scan GUI objects only at leaves in tree. + util::Box2D box ; + if(util::is_failed(elem->get_CachedBoundingRectangle(&box.data()))) { + throw RUNTIME_EXCEPT("Could not get the a rectangle of a element.") ; + } + + auto distance = util::l2_distance_nosq( + point.x(), point.y(), + box.center_x(), box.center_y()) / 100 ; + + if(min_distance > distance) { + nearest = elem ; + min_distance = distance ; + nearest_box = box ; + } + } + + if(util::is_failed(nearest->SetFocus())) { + throw RUNTIME_EXCEPT("SetFocus Failed.") ; + } + + // Move the cursor into the text area. + util::set_cursor_pos(nearest_box.center_x(), nearest_box.center_y()) ; + } + } ; + + FocusTextArea::FocusTextArea() + : BindedFuncVoid("focus_textarea"), + pimpl(std::make_unique()) + { + opt::AsyncUIACacheBuilder::register_properties( + pimpl->scanner_.get_properties()) ; + } + + FocusTextArea::~FocusTextArea() noexcept = default ; + FocusTextArea::FocusTextArea(FocusTextArea&&) = default ; + FocusTextArea& FocusTextArea::operator=(FocusTextArea&&) = default ; + + void FocusTextArea::sprocess( + std::uint16_t UNUSED(count), + const std::string& UNUSED(args)) { + if(auto hwnd = util::get_foreground_window()) { + auto pos = util::get_cursor_pos() ; + pimpl->focus_nearest_textarea(hwnd, pos) ; + } + } + } +} diff --git a/src/bind/mouse/focustextarea.hpp b/src/bind/mouse/focustextarea.hpp index 548e81d1..2609f7c7 100644 --- a/src/bind/mouse/focustextarea.hpp +++ b/src/bind/mouse/focustextarea.hpp @@ -1,4 +1,33 @@ #ifndef _FOCUSTEXTAREA_HPP #define _FOCUSTEXTAREA_HPP +#include "bind/bindedfunc.hpp" + +#include + + +namespace vind +{ + namespace bind + { + class FocusTextArea : public BindedFuncVoid { + private: + struct Impl ; + std::unique_ptr pimpl ; + + public: + explicit FocusTextArea() ; + virtual ~FocusTextArea() noexcept ; + + void sprocess( + std::uint16_t count, const std::string& args) ; + + FocusTextArea(FocusTextArea&&) ; + FocusTextArea& operator=(FocusTextArea&&) ; + FocusTextArea(const FocusTextArea&) = delete ; + FocusTextArea& operator=(const FocusTextArea&) = delete ; + } ; + } +} + #endif diff --git a/src/core/version.hpp b/src/core/version.hpp index df49308d..dbff3470 100644 --- a/src/core/version.hpp +++ b/src/core/version.hpp @@ -1,6 +1,6 @@ #ifndef _VERSION_HPP #define _VERSION_HPP -#define WIN_VIND_VERSION "5.6.0.1" +#define WIN_VIND_VERSION "5.7.0.0" #endif From 19f1807888917d0b5f1e1541e766f48240c2bc8e Mon Sep 17 00:00:00 2001 From: pit-ray Date: Thu, 4 Jan 2024 17:55:48 +0900 Subject: [PATCH 3/4] update document --- docs/cheat_sheet/defaults/big/index.md | 38 +++++++-------- docs/cheat_sheet/defaults/huge/index.md | 2 +- docs/cheat_sheet/defaults/normal/index.md | 54 +++++++++++----------- docs/cheat_sheet/defaults/small/index.md | 30 ++++++------ docs/cheat_sheet/defaults/tiny/index.md | 27 +++++------ docs/cheat_sheet/functions/index.md | 15 ++++++ docs/imgs/focus_textarea.png | Bin 0 -> 10159 bytes 7 files changed, 91 insertions(+), 75 deletions(-) create mode 100644 docs/imgs/focus_textarea.png diff --git a/docs/cheat_sheet/defaults/big/index.md b/docs/cheat_sheet/defaults/big/index.md index 88f17d4c..19b1bfd8 100644 --- a/docs/cheat_sheet/defaults/big/index.md +++ b/docs/cheat_sheet/defaults/big/index.md @@ -19,13 +19,13 @@ nav: Big Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| |`V`|[\]({{ site.url }}/cheat_sheet/functions/#select_all)| -|`yy`, `y`, `Y`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_copy)| -|`P`, `p`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_paste)| -|`dd`, `D`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_cut)| +|`Y`, `y`, `yy`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_copy)| +|`p`, `P`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_paste)| +|`D`, `dd`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_cut)| |`x`, ``|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_delete)| |`X`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_backspace)| |``|[\]({{ site.url }}/cheat_sheet/functions/#redo)| -|`u`, `U`|[\]({{ site.url }}/cheat_sheet/functions/#undo)| +|`U`, `u`|[\]({{ site.url }}/cheat_sheet/functions/#undo)| |`h`|[\]({{ site.url }}/cheat_sheet/functions/#switch_to_left_vdesktop)| |`l`|[\]({{ site.url }}/cheat_sheet/functions/#switch_to_right_vdesktop)| |`n`|[\]({{ site.url }}/cheat_sheet/functions/#create_new_vdesktop)| @@ -44,24 +44,24 @@ nav: Big Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#to_gui_normal)| +|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#to_gui_normal)| |``|[\]({{ site.url }}/cheat_sheet/functions/#to_resident)| ### Mouse Movement |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``, `h`|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_left)| -|`l`, ``, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_right)| -|`-`, `k`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_up)| -|`+`, `j`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_down)| +|``, ``, `h`|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_left)| +|``, `l`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_right)| +|`k`, `-`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_up)| +|`+`, ``, `j`|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_down)| ### Mouse Jumping |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|`0`, `^`, ``|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_left)| -|`$`, ``|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_right)| +|`^`, `0`, ``|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_left)| +|``, `$`|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_right)| |`gg`|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_top)| |`G`|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_bottom)| |`gm`|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_hcenter)| @@ -71,13 +71,13 @@ nav: Big Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up)| +|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up)| |``, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_down)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up_halfpage)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_down_halfpage)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up_onepage)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_down_onepage)| -|`zh`, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_left)| +|``, `zh`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_left)| |``, `zl`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_right)| |`zH`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_left_halfpage)| |`zL`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_right_halfpage)| @@ -86,9 +86,9 @@ nav: Big Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|`yy`, `y`, `Y`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_copy)| -|`P`, `p`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_paste)| -|`dd`, `D`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_cut)| +|`Y`, `y`, `yy`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_copy)| +|`p`, `P`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_paste)| +|`D`, `dd`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_cut)| |`x`, ``|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_delete)| |`X`|[\]({{ site.url }}/cheat_sheet/functions/#hotkey_backspace)| @@ -107,14 +107,14 @@ nav: Big Mappings |`vdprev`|[\]({{ site.url }}/cheat_sheet/functions/#switch_to_left_vdesktop)| |`vdnext`|[\]({{ site.url }}/cheat_sheet/functions/#switch_to_right_vdesktop)| |`closev`|[\]({{ site.url }}/cheat_sheet/functions/#close_current_vdesktop)| -|`tv`, `vdesktoplist`, `taskview`|[\]({{ site.url }}/cheat_sheet/functions/#taskview)| +|`tv`, `taskview`, `vdesktoplist`|[\]({{ site.url }}/cheat_sheet/functions/#taskview)| |`tabprevious`|[\]({{ site.url }}/cheat_sheet/functions/#switch_to_left_tab)| |`tabnext`|[\]({{ site.url }}/cheat_sheet/functions/#switch_to_right_tab)| |`tabnew`|[\]({{ site.url }}/cheat_sheet/functions/#open_new_tab)| -|`q`, `q!`, `tabclose`|[\]({{ site.url }}/cheat_sheet/functions/#close_current_tab)| +|`q!`, `q`, `tabclose`|[\]({{ site.url }}/cheat_sheet/functions/#close_current_tab)| |`ex`, `explorer`|[\]({{ site.url }}/cheat_sheet/functions/#start_explorer)| |`win`, `start`|[\]({{ site.url }}/cheat_sheet/functions/#open_startmenu)| -|`find`, `open`|[\]({{ site.url }}/cheat_sheet/functions/#open)| +|`open`, `find`|[\]({{ site.url }}/cheat_sheet/functions/#open)| |`forward`|[\]({{ site.url }}/cheat_sheet/functions/#forward_ui_navigation)| |`backward`|[\]({{ site.url }}/cheat_sheet/functions/#backward_ui_navigation)| |`decide`|[\]({{ site.url }}/cheat_sheet/functions/#decide_focused_ui_object)| diff --git a/docs/cheat_sheet/defaults/huge/index.md b/docs/cheat_sheet/defaults/huge/index.md index 6fbaaf39..3d7ce6e1 100644 --- a/docs/cheat_sheet/defaults/huge/index.md +++ b/docs/cheat_sheet/defaults/huge/index.md @@ -10,7 +10,7 @@ nav: Huge Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|`mkdir`, `md`|[\]({{ site.url }}/cheat_sheet/functions/#makedir)| +|`md`, `mkdir`|[\]({{ site.url }}/cheat_sheet/functions/#makedir)|

diff --git a/docs/cheat_sheet/defaults/normal/index.md b/docs/cheat_sheet/defaults/normal/index.md index c3aec4c4..5a249667 100644 --- a/docs/cheat_sheet/defaults/normal/index.md +++ b/docs/cheat_sheet/defaults/normal/index.md @@ -10,7 +10,7 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``, `I`|[\]({{ site.url }}/cheat_sheet/functions/#click_left)[\]({{ site.url }}/cheat_sheet/functions/#to_edi_normal)| +|`I`, ``, ``|[\]({{ site.url }}/cheat_sheet/functions/#click_left)[\]({{ site.url }}/cheat_sheet/functions/#to_edi_normal)| ## Editor Normal Mode @@ -18,7 +18,7 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#to_gui_normal)| +|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#to_gui_normal)| |``|[\]({{ site.url }}/cheat_sheet/functions/#to_resident)| |`:`|[\]({{ site.url }}/cheat_sheet/functions/#to_command)| |`i`|[\]({{ site.url }}/cheat_sheet/functions/#to_insert)| @@ -29,13 +29,13 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up)| +|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up)| |``, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_down)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up_halfpage)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_down_halfpage)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up_onepage)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_down_onepage)| -|`zh`, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_left)| +|``, `zh`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_left)| |``, `zl`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_right)| |`zH`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_left_halfpage)| |`zL`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_right_halfpage)| @@ -45,7 +45,7 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| |``|[\]({{ site.url }}/cheat_sheet/functions/#redo)| -|`u`, `U`|[\]({{ site.url }}/cheat_sheet/functions/#undo)| +|`U`, `u`|[\]({{ site.url }}/cheat_sheet/functions/#undo)| |`gT`|[\]({{ site.url }}/cheat_sheet/functions/#switch_to_left_tab)| |`gt`|[\]({{ site.url }}/cheat_sheet/functions/#switch_to_right_tab)| |`/`, `?`|[\]({{ site.url }}/cheat_sheet/functions/#search_pattern)| @@ -54,7 +54,7 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|`gI`, `I`|[\]({{ site.url }}/cheat_sheet/functions/#to_insert_bol)| +|`I`, `gI`|[\]({{ site.url }}/cheat_sheet/functions/#to_insert_bol)| |`a`|[\]({{ site.url }}/cheat_sheet/functions/#to_insert_append)| |`A`|[\]({{ site.url }}/cheat_sheet/functions/#to_insert_eol)| |`o`|[\]({{ site.url }}/cheat_sheet/functions/#to_insert_nlbelow)| @@ -64,10 +64,10 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``, ``, `h`|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_left)| -|`l`, ``, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_right)| -|``, `-`, `gk`, ``, `k`|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_up)| -|`j`, ``, ``, ``, `gj`, ``, `+`|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_down)| +|``, ``, ``, `h`|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_left)| +|``, `l`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_right)| +|`k`, ``, `gk`, ``, `-`|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_up)| +|``, ``, `gj`, `j`, ``, `+`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_down)| |`w`|[\]({{ site.url }}/cheat_sheet/functions/#move_fwd_word)| |`b`|[\]({{ site.url }}/cheat_sheet/functions/#move_bck_word)| |`W`|[\]({{ site.url }}/cheat_sheet/functions/#move_fwd_bigword)| @@ -81,8 +81,8 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|`0`, `g0`, ``|[\]({{ site.url }}/cheat_sheet/functions/#jump_caret_to_bol)| -|`$`, `g$`, ``|[\]({{ site.url }}/cheat_sheet/functions/#jump_caret_to_eol)| +|`g0`, `0`, ``|[\]({{ site.url }}/cheat_sheet/functions/#jump_caret_to_bol)| +|``, `g$`, `$`|[\]({{ site.url }}/cheat_sheet/functions/#jump_caret_to_eol)| |`gg`|[\]({{ site.url }}/cheat_sheet/functions/#jump_caret_to_bof)| |`G`|[\]({{ site.url }}/cheat_sheet/functions/#jump_caret_to_eof)| @@ -90,7 +90,7 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|`yy`, `Y`|[\]({{ site.url }}/cheat_sheet/functions/#yank_line)| +|`Y`, `yy`|[\]({{ site.url }}/cheat_sheet/functions/#yank_line)| |`y`|[\]({{ site.url }}/cheat_sheet/functions/#yank_with_motion)| |`p`|[\]({{ site.url }}/cheat_sheet/functions/#put_after)| |`P`|[\]({{ site.url }}/cheat_sheet/functions/#put_before)| @@ -115,7 +115,7 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#to_gui_normal)| +|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#to_gui_normal)| |``|[\]({{ site.url }}/cheat_sheet/functions/#to_resident)| |`:`|[\]({{ site.url }}/cheat_sheet/functions/#to_command)| |``, ``|[\]({{ site.url }}/cheat_sheet/functions/#to_edi_normal)| @@ -124,13 +124,13 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up)| +|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up)| |``, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_down)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up_halfpage)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_down_halfpage)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up_onepage)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_down_onepage)| -|`zh`, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_left)| +|``, `zh`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_left)| |``, `zl`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_right)| |`zH`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_left_halfpage)| |`zL`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_right_halfpage)| @@ -139,10 +139,10 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``, ``, `h`|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_left)| -|`l`, ``, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_right)| -|``, `-`, `gk`, ``, `k`|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_up)| -|`j`, ``, ``, ``, `gj`, ``, `+`|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_down)| +|``, ``, ``, `h`|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_left)| +|``, `l`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_right)| +|`k`, ``, `gk`, ``, `-`|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_up)| +|``, ``, `gj`, `j`, ``, `+`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_caret_down)| |`w`|[\]({{ site.url }}/cheat_sheet/functions/#move_fwd_word_simple)| |`b`|[\]({{ site.url }}/cheat_sheet/functions/#move_bck_word_simple)| @@ -150,8 +150,8 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|`0`, `g0`, ``|[\]({{ site.url }}/cheat_sheet/functions/#jump_caret_to_bol)| -|`$`, `g$`, ``|[\]({{ site.url }}/cheat_sheet/functions/#jump_caret_to_eol)| +|`g0`, `0`, ``|[\]({{ site.url }}/cheat_sheet/functions/#jump_caret_to_bol)| +|``, `g$`, `$`|[\]({{ site.url }}/cheat_sheet/functions/#jump_caret_to_eol)| |`gg`|[\]({{ site.url }}/cheat_sheet/functions/#jump_caret_to_bof)| |`G`|[\]({{ site.url }}/cheat_sheet/functions/#jump_caret_to_eof)| @@ -160,8 +160,8 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| |`y`|[\]({{ site.url }}/cheat_sheet/functions/#yank_highlight_text)| -|`x`, `X`, `d`|[\]({{ site.url }}/cheat_sheet/functions/#delete_highlight_text)| -|`S`, `c`, `s`|[\]({{ site.url }}/cheat_sheet/functions/#change_highlight_text)| +|`X`, `x`, `d`|[\]({{ site.url }}/cheat_sheet/functions/#delete_highlight_text)| +|`c`, `S`, `s`|[\]({{ site.url }}/cheat_sheet/functions/#change_highlight_text)| ## Insert Mode @@ -179,9 +179,9 @@ nav: Normal Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|`edinormal`, `en`|[\]({{ site.url }}/cheat_sheet/functions/#to_edi_normal)| -|`ev`, `edivisual`|[\]({{ site.url }}/cheat_sheet/functions/#to_edi_visual)| -|`evl`, `edivisualline`|[\]({{ site.url }}/cheat_sheet/functions/#to_edi_visual_line)| +|`en`, `edinormal`|[\]({{ site.url }}/cheat_sheet/functions/#to_edi_normal)| +|`edivisual`, `ev`|[\]({{ site.url }}/cheat_sheet/functions/#to_edi_visual)| +|`edivisualline`, `evl`|[\]({{ site.url }}/cheat_sheet/functions/#to_edi_visual_line)| ### Shortcut diff --git a/docs/cheat_sheet/defaults/small/index.md b/docs/cheat_sheet/defaults/small/index.md index 00c1836a..0a0af507 100644 --- a/docs/cheat_sheet/defaults/small/index.md +++ b/docs/cheat_sheet/defaults/small/index.md @@ -13,7 +13,7 @@ nav: Small Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| |`n`|[\]({{ site.url }}/cheat_sheet/functions/#open_new_window)| -|`q`, `c`|[\]({{ site.url }}/cheat_sheet/functions/#close_current_window)| +|`c`, `q`|[\]({{ site.url }}/cheat_sheet/functions/#close_current_window)| ### Window Select @@ -48,8 +48,8 @@ nav: Small Mappings |`-`|[\]({{ site.url }}/cheat_sheet/functions/#decrease_window_height)| |`u`|[\]({{ site.url }}/cheat_sheet/functions/#maximize_current_window)| |`d`|[\]({{ site.url }}/cheat_sheet/functions/#minimize_current_window)| -|``, `H`|[\]({{ site.url }}/cheat_sheet/functions/#snap_current_window_to_left)| -|`L`, ``|[\]({{ site.url }}/cheat_sheet/functions/#snap_current_window_to_right)| +|`H`, ``|[\]({{ site.url }}/cheat_sheet/functions/#snap_current_window_to_left)| +|``, `L`|[\]({{ site.url }}/cheat_sheet/functions/#snap_current_window_to_right)| |`K`|[\]({{ site.url }}/cheat_sheet/functions/#snap_current_window_to_top)| |`J`|[\]({{ site.url }}/cheat_sheet/functions/#snap_current_window_to_bottom)| |`e`|[\]({{ site.url }}/cheat_sheet/functions/#window_resizer)| @@ -60,10 +60,10 @@ nav: Small Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|`close`, `cl`|[\]({{ site.url }}/cheat_sheet/functions/#close_current_window)| +|`cl`, `close`|[\]({{ site.url }}/cheat_sheet/functions/#close_current_window)| |`new`|[\]({{ site.url }}/cheat_sheet/functions/#open_new_window)| -|`sp`, `split`|[\]({{ site.url }}/cheat_sheet/functions/#open_new_window_with_hsplit)| -|`vs`, `vsplit`|[\]({{ site.url }}/cheat_sheet/functions/#open_new_window_with_vsplit)| +|`split`, `sp`|[\]({{ site.url }}/cheat_sheet/functions/#open_new_window_with_hsplit)| +|`vsplit`, `vs`|[\]({{ site.url }}/cheat_sheet/functions/#open_new_window_with_vsplit)| ### Window Select @@ -75,20 +75,20 @@ nav: Small Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|`resizer`, `winresizer`|[\]({{ site.url }}/cheat_sheet/functions/#window_resizer)| -|`only`, `max`, `on`|[\]({{ site.url }}/cheat_sheet/functions/#maximize_current_window)| -|`hi`, `hide`, `min`|[\]({{ site.url }}/cheat_sheet/functions/#minimize_current_window)| +|`winresizer`, `resizer`|[\]({{ site.url }}/cheat_sheet/functions/#window_resizer)| +|`max`, `on`, `only`|[\]({{ site.url }}/cheat_sheet/functions/#maximize_current_window)| +|`min`, `hide`, `hi`|[\]({{ site.url }}/cheat_sheet/functions/#minimize_current_window)| |`lsplit`, `lsp`|[\]({{ site.url }}/cheat_sheet/functions/#snap_current_window_to_left)| -|`rsp`, `rsplit`|[\]({{ site.url }}/cheat_sheet/functions/#snap_current_window_to_right)| +|`rsplit`, `rsp`|[\]({{ site.url }}/cheat_sheet/functions/#snap_current_window_to_right)| |`tsp`, `tsplit`|[\]({{ site.url }}/cheat_sheet/functions/#snap_current_window_to_top)| -|`bsp`, `bsplit`|[\]({{ site.url }}/cheat_sheet/functions/#snap_current_window_to_bottom)| +|`bsplit`, `bsp`|[\]({{ site.url }}/cheat_sheet/functions/#snap_current_window_to_bottom)| |`arrange`|[\]({{ site.url }}/cheat_sheet/functions/#arrange_windows)| |`reload`|[\]({{ site.url }}/cheat_sheet/functions/#reload_current_window)| -|`rot`, `rotate`|[\]({{ site.url }}/cheat_sheet/functions/#rotate_windows)| +|`rotate`, `rot`|[\]({{ site.url }}/cheat_sheet/functions/#rotate_windows)| |`rerotate`, `rerot`|[\]({{ site.url }}/cheat_sheet/functions/#rotate_windows_in_reverse)| |`exchange`|[\]({{ site.url }}/cheat_sheet/functions/#exchange_window_with_nearest)| |`vertres`, `verticalresize`|[\]({{ site.url }}/cheat_sheet/functions/#resize_window_width)| -|`verticalresize+`, `vertres+`|[\]({{ site.url }}/cheat_sheet/functions/#increase_window_width)| +|`vertres+`, `verticalresize+`|[\]({{ site.url }}/cheat_sheet/functions/#increase_window_width)| |`verticalresize-`, `vertres-`|[\]({{ site.url }}/cheat_sheet/functions/#decrease_window_width)| |`res`, `resize`|[\]({{ site.url }}/cheat_sheet/functions/#resize_window_height)| |`resize+`, `res+`|[\]({{ site.url }}/cheat_sheet/functions/#increase_window_height)| @@ -99,8 +99,8 @@ nav: Small Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| |`!`|[\]({{ site.url }}/cheat_sheet/functions/#start_external)| -|`edit`, `execute`, `e`|[\]({{ site.url }}/cheat_sheet/functions/#execute)| -|`term`, `shell`, `terminal`, `sh`|[\]({{ site.url }}/cheat_sheet/functions/#start_shell)| +|`e`, `execute`, `edit`|[\]({{ site.url }}/cheat_sheet/functions/#execute)| +|`terminal`, `term`, `sh`, `shell`|[\]({{ site.url }}/cheat_sheet/functions/#start_shell)|

diff --git a/docs/cheat_sheet/defaults/tiny/index.md b/docs/cheat_sheet/defaults/tiny/index.md index 895cce87..9f56d085 100644 --- a/docs/cheat_sheet/defaults/tiny/index.md +++ b/docs/cheat_sheet/defaults/tiny/index.md @@ -12,7 +12,7 @@ nav: Tiny Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#to_gui_normal)| +|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#to_gui_normal)| |``|[\]({{ site.url }}/cheat_sheet/functions/#to_resident)| |`:`|[\]({{ site.url }}/cheat_sheet/functions/#to_command)| |`i`|[\]({{ site.url }}/cheat_sheet/functions/#click_left)[\]({{ site.url }}/cheat_sheet/functions/#to_insert)| @@ -21,9 +21,9 @@ nav: Tiny Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, `h`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_left)| -|`l`, ``, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_right)| -|`-`, `k`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_up)| +|``, ``, `h`|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_left)| +|``, `l`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_right)| +|`k`, `-`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_up)| |`+`, `j`, ``|[\]({{ site.url }}/cheat_sheet/functions/#move_cursor_down)| ### Mouse Clicking @@ -37,14 +37,14 @@ nav: Tiny Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up)| +|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up)| |``, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_down)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up_halfpage)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_down_halfpage)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_up_onepage)| |``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_down_onepage)| -|`zh`, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_left)| -|`zl`, ``|[\]({{ site.url }}/cheat_sheet/functions/#scroll_right)| +|``, `zh`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_left)| +|``, `zl`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_right)| |`zh`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_left_halfpage)| |`zl`|[\]({{ site.url }}/cheat_sheet/functions/#scroll_right_halfpage)| @@ -52,8 +52,8 @@ nav: Tiny Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|`0`, `^`, ``|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_left)| -|`$`, ``|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_right)| +|`^`, ``, `0`|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_left)| +|``, `$`|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_right)| |`gg`|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_top)| |`G`|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_bottom)| |`gm`|[\]({{ site.url }}/cheat_sheet/functions/#jump_cursor_to_hcenter)| @@ -69,8 +69,9 @@ nav: Tiny Mappings |`Fa`|[\]({{ site.url }}/cheat_sheet/functions/#easyclick)[\]({{ site.url }}/cheat_sheet/functions/#click_right)| |`Fm`|[\]({{ site.url }}/cheat_sheet/functions/#easyclick)[\]({{ site.url }}/cheat_sheet/functions/#click_mid)| |`Fh`|[\]({{ site.url }}/cheat_sheet/functions/#easyclick)| +|`Ft`|[\]({{ site.url }}/cheat_sheet/functions/#focus_textarea)| |``|[\]({{ site.url }}/cheat_sheet/functions/#gridmove)| -|`AA`, `Ao`|[\]({{ site.url }}/cheat_sheet/functions/#easyclick_all)[\]({{ site.url }}/cheat_sheet/functions/#click_left)| +|`Ao`, `AA`|[\]({{ site.url }}/cheat_sheet/functions/#easyclick_all)[\]({{ site.url }}/cheat_sheet/functions/#click_left)| |`Aa`|[\]({{ site.url }}/cheat_sheet/functions/#easyclick_all)[\]({{ site.url }}/cheat_sheet/functions/#click_right)| |`Am`|[\]({{ site.url }}/cheat_sheet/functions/#easyclick_all)[\]({{ site.url }}/cheat_sheet/functions/#click_mid)| |`Ah`|[\]({{ site.url }}/cheat_sheet/functions/#easyclick_all)| @@ -79,7 +80,7 @@ nav: Tiny Mappings |**Trigger Commands**|**Called Commands**| |:---:|:---:| -|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#to_gui_normal)| +|``, ``|[\]({{ site.url }}/cheat_sheet/functions/#to_gui_normal)| |``|[\]({{ site.url }}/cheat_sheet/functions/#to_instant_gui_normal)| |``|[\]({{ site.url }}/cheat_sheet/functions/#to_resident)| @@ -113,9 +114,9 @@ nav: Tiny Mappings |`{mode}unmap`|[\<{mode}unmap\>]({{ site.url }}/cheat_sheet/functions/#unmap)| |`{mode}mapclear`|[\<{mode}mapclear\>]({{ site.url }}/cheat_sheet/functions/#mapclear)| |`command`, `com`|[\]({{ site.url }}/cheat_sheet/functions/#command)| -|`delc`, `delcommand`|[\]({{ site.url }}/cheat_sheet/functions/#delcommand)| +|`delcommand`, `delc`|[\]({{ site.url }}/cheat_sheet/functions/#delcommand)| |`comclear`, `comc`|[\]({{ site.url }}/cheat_sheet/functions/#comclear)| -|`so`, `source`|[\]({{ site.url }}/cheat_sheet/functions/#source)| +|`source`, `so`|[\]({{ site.url }}/cheat_sheet/functions/#source)| |`autocmd`|[\]({{ site.url }}/cheat_sheet/functions/#autocmd_add)| |`autocmd!`|[\]({{ site.url }}/cheat_sheet/functions/#autocmd_del)| diff --git a/docs/cheat_sheet/functions/index.md b/docs/cheat_sheet/functions/index.md index 3ca11936..3a98f818 100644 --- a/docs/cheat_sheet/functions/index.md +++ b/docs/cheat_sheet/functions/index.md @@ -496,6 +496,21 @@ In order to change the grid size, set the size with `gridmove_size` option. It a
+ +### **``** +Select the text area closest to the cursor and move the mouse cursor over it. +If there are multiple text areas, the selection is based on the minimum Euclidean distance between the mouse cursor and the center point of the bounding box of the text area. + +In the previous version of win-vind, this function was attached to the Editor Normal Mode as the `autofocus_textarea` option, but it is now independent. Currently, the `autofocus_textarea` option is deprecated. For compatibility, `autofocus_textarea` defines a mapping to ``. + +

+ +

Focus the nearest text area and move the cursor.

+

+ +
+ + ### **``** Jump the mouse cursor to the left. diff --git a/docs/imgs/focus_textarea.png b/docs/imgs/focus_textarea.png new file mode 100644 index 0000000000000000000000000000000000000000..24978bbfb6c6f45aab46c259ef6f061671771021 GIT binary patch literal 10159 zcmeHNS6EYNw+qwLRCdk8vq~% z;{X3}<~RIrQ!t1hN_{KaW&IW;)|pd<>oXHJ5@{@q^1&C?L3llyy99&55*cohXNkQL3U|(khL&HO;5p?a>mwYajEgEm@+UF!T%x~F1exqGt z1U&CW__~$7hcm`=(rRi9{@LpB9>lJ6W>fAZJy(bJg!j37W3LrU z9(m^fN6W5+k__lnJaaG+LaUsW_tE4zcGT(fVgg#=^wj+SXz>5oq>$|MZZmJAr(e~5 zpHA?pQoPdtekg3^f_Z*~H*1c&2wl74el9|M=)kuQz&S9Ya zMnj5KwuB;Yf+IzQRhv4G;&=YoxT)$Dl~kt*kGY6_tATJqoVu3xXQ8x&YUYI?xBSbz zw9bWr4>1r0u6cKAuC#)dqu`oPv6v%mj<(|t2MwyWJyzK^VzxSVZ~!JFgpyUph{<eG35%#r`xB_sQMPFef1 z=WyN7L6w$Ei<9=2br%;t*jX4k1x59i7DI4J8w$=$X$Qyss* zXW!fq^Kl)q$%$y|cPv8fEX-KGoE5EK_F3ln)_8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ynera4{$M literal 0 HcmV?d00001 From 82744018b5f69c6e289ac5aebec882279090677a Mon Sep 17 00:00:00 2001 From: pit-ray Date: Thu, 4 Jan 2024 21:10:20 +0900 Subject: [PATCH 4/4] remove autofocus_textarea and keep compatibility --- CMakeLists.txt | 2 +- docs/cheat_sheet/functions/index.md | 2 +- docs/cheat_sheet/options/index.md | 8 +--- src/bind/mode/change_mode.cpp | 17 +------ src/bind/mode/change_mode.hpp | 7 +-- src/bind/mode/options.cpp | 74 ----------------------------- src/bind/mode/options.hpp | 20 -------- src/bind/mode/text_area_scanner.cpp | 71 --------------------------- src/bind/mode/text_area_scanner.hpp | 19 -------- src/bind/syscmd/source.cpp | 20 ++++++-- src/core/settable.cpp | 1 - 11 files changed, 21 insertions(+), 220 deletions(-) delete mode 100644 src/bind/mode/options.cpp delete mode 100644 src/bind/mode/options.hpp delete mode 100644 src/bind/mode/text_area_scanner.cpp delete mode 100644 src/bind/mode/text_area_scanner.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 37c58c18..3d214807 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.6.0) -project(win-vind VERSION 5.7.0) +project(win-vind VERSION 5.8.0) set(INTERNAL_VERSION ${PROJECT_VERSION}.0) if(NOT CMAKE_BUILD_TYPE) diff --git a/docs/cheat_sheet/functions/index.md b/docs/cheat_sheet/functions/index.md index 3a98f818..b7ebd47b 100644 --- a/docs/cheat_sheet/functions/index.md +++ b/docs/cheat_sheet/functions/index.md @@ -501,7 +501,7 @@ In order to change the grid size, set the size with `gridmove_size` option. It a Select the text area closest to the cursor and move the mouse cursor over it. If there are multiple text areas, the selection is based on the minimum Euclidean distance between the mouse cursor and the center point of the bounding box of the text area. -In the previous version of win-vind, this function was attached to the Editor Normal Mode as the `autofocus_textarea` option, but it is now independent. Currently, the `autofocus_textarea` option is deprecated. For compatibility, `autofocus_textarea` defines a mapping to ``. +In the previous version of win-vind, this function was attached to the Editor Normal Mode as the `autofocus_textarea` option, but it is now independent. Currently, the `autofocus_textarea` option is deprecated. For compatibility, `autofocus_textarea` defines a mapping such as `autocmd EdiNormalEnter * `.

diff --git a/docs/cheat_sheet/options/index.md b/docs/cheat_sheet/options/index.md index 2701a0e1..c5911c8e 100644 --- a/docs/cheat_sheet/options/index.md +++ b/docs/cheat_sheet/options/index.md @@ -292,12 +292,6 @@ Width of block style caret on solid mode ## AutoFocus -### **`autofocus_textarea`** -**type**: bool, **default**: false -Automatically focus on the nearest text area when switching to **Editor Normal Mode** - -


- ### **`autotrack_popup`** **type**: bool, **default**: false It is one of standard options on Windows. For example, if shown **Are you sure you want to move this file to the Recycle Bin?**, it automatically moves the cursor to the popup window. @@ -307,7 +301,7 @@ It is one of standard options on Windows. For example, if shown **Are you sure y ### **`uiacachebuild`** **type**: bool, **default**: false -EasyClick and `autofocus_textarea` are slow because they scan the UI object after being called. If this option is enabled, scanning is done asynchronously and cache is used as a result. Using the cache is 30 times faster than scanning linearly, but the location information, etc. may not always be correct. +[easyclick](../functions/#easyclick) and [focus_textarea](../functions/#focus_textarea) are slow because they scan the UI object after being called. If this option is enabled, scanning is done asynchronously and cache is used as a result. Using the cache is 30 times faster than scanning linearly, but the location information, etc. may not always be correct.
diff --git a/src/bind/mode/change_mode.cpp b/src/bind/mode/change_mode.cpp index 5dd89853..3e9f44c4 100644 --- a/src/bind/mode/change_mode.cpp +++ b/src/bind/mode/change_mode.cpp @@ -9,7 +9,6 @@ #include "core/settable.hpp" #include "opt/uiacachebuild.hpp" #include "opt/vcmdline.hpp" -#include "options.hpp" #include "util/debug.hpp" #include "util/def.hpp" #include "util/mouse.hpp" @@ -102,16 +101,10 @@ namespace vind ac.apply(core::get_enter_event(core::Mode::GUI_VISUAL)) ; } - // All instances share TextAreaScanner to keep staticity of sprocess. - TextAreaScanner ToEdiNormal::scanner_ ; - //ToEdiNormal ToEdiNormal::ToEdiNormal() : BindedFuncVoid("to_edi_normal") - { - opt::AsyncUIACacheBuilder::register_properties( - scanner_.get_properties()) ; - } + {} void ToEdiNormal::sprocess( std::uint16_t UNUSED(count), const std::string& UNUSED(args), @@ -138,14 +131,6 @@ namespace vind opt::VCmdLine::print(opt::GeneralMessage("-- EDI NORMAL --")) ; } - auto& settable = core::SetTable::get_instance() ; - if(settable.get("autofocus_textarea").get()) { - if(auto hwnd = util::get_foreground_window()) { - auto pos = util::get_cursor_pos() ; - focus_nearest_textarea(hwnd, pos, scanner_) ; - } - } - ac.apply(core::get_enter_event(Mode::EDI_NORMAL)) ; } diff --git a/src/bind/mode/change_mode.hpp b/src/bind/mode/change_mode.hpp index 35f71d08..480bc288 100644 --- a/src/bind/mode/change_mode.hpp +++ b/src/bind/mode/change_mode.hpp @@ -2,7 +2,6 @@ #define _CHANGE_MODE_HPP #include "bind/bindedfunc.hpp" -#include "text_area_scanner.hpp" namespace vind { @@ -44,11 +43,7 @@ namespace vind } } ; - class ToEdiNormal : public BindedFuncVoid { - private: - static TextAreaScanner scanner_ ; - - public: + struct ToEdiNormal : public BindedFuncVoid { explicit ToEdiNormal() ; static void sprocess( std::uint16_t count, diff --git a/src/bind/mode/options.cpp b/src/bind/mode/options.cpp deleted file mode 100644 index d3d1032b..00000000 --- a/src/bind/mode/options.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "options.hpp" - -#include "core/settable.hpp" -#include "opt/uiacachebuild.hpp" -#include "util/box2d.hpp" -#include "util/debug.hpp" -#include "util/def.hpp" -#include "util/rect.hpp" -#include "util/uia.hpp" -#include "util/winwrap.hpp" - -#include - - -#undef max - - -namespace vind -{ - namespace bind - { - void focus_nearest_textarea( - HWND hwnd, - const util::Point2D& point, - TextAreaScanner& instance) { - - std::vector editables{} ; - - auto& settable = core::SetTable::get_instance() ; - if(settable.get("uiacachebuild").get()) { - auto root_elem = opt::AsyncUIACacheBuilder::get_root_element(hwnd) ; - instance.scan(root_elem, editables) ; - } - else { - instance.scan(hwnd, editables) ; - } - - if(editables.empty()) { - return ; - } - - if(editables.size() == 1) { - if(util::is_failed(editables.front()->SetFocus())) { - throw RUNTIME_EXCEPT("SetFocus Failed.") ; - } - return ; - } - - util::SmartElement nearest ; - auto min_distance = std::numeric_limits::max() ; - - for(auto& elem : editables) { - // scan GUI objects only at leaves in tree. - util::Box2D box ; - if(util::is_failed(elem->get_CachedBoundingRectangle(&box.data()))) { - throw RUNTIME_EXCEPT("Could not get the a rectangle of a element.") ; - } - - auto distance = util::l2_distance_nosq( - point.x(), point.y(), - box.center_x(), box.center_y()) / 100 ; - - if(min_distance > distance) { - nearest = elem ; - min_distance = distance ; - } - } - - if(util::is_failed(nearest->SetFocus())) { - throw RUNTIME_EXCEPT("SetFocus Failed.") ; - } - } - } -} diff --git a/src/bind/mode/options.hpp b/src/bind/mode/options.hpp deleted file mode 100644 index 76387d2a..00000000 --- a/src/bind/mode/options.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _OPTIONS_HPP -#define _OPTIONS_HPP - -#include "text_area_scanner.hpp" -#include "util/point2d.hpp" - - -namespace vind -{ - namespace bind - { - void focus_nearest_textarea( - HWND hwnd, - const util::Point2D& point, - TextAreaScanner& instance) ; - - } -} - -#endif diff --git a/src/bind/mode/text_area_scanner.cpp b/src/bind/mode/text_area_scanner.cpp deleted file mode 100644 index 4f6abac3..00000000 --- a/src/bind/mode/text_area_scanner.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "text_area_scanner.hpp" - -#include "core/errlogger.hpp" -#include "util/debug.hpp" -#include "util/def.hpp" -#include "util/winwrap.hpp" - - -namespace vind -{ - namespace bind - { - TextAreaScanner::TextAreaScanner() - : UIWalker{ - UIA_IsTextPatternAvailablePropertyId, - UIA_IsValuePatternAvailablePropertyId, - UIA_HasKeyboardFocusPropertyId, - UIA_ValueIsReadOnlyPropertyId - } - { - UIWalker::enable_fullcontrol() ; - } - - bool TextAreaScanner::pinpoint_element(const util::SmartElement& elem) { - BOOL flag ; - if(util::is_failed(elem->get_CachedHasKeyboardFocus(&flag))) { - throw RUNTIME_EXCEPT("Could not get a cached property value: HasKeyboardFocus.") ; - } - return flag == TRUE ; - } - - bool TextAreaScanner::filter_element(const util::SmartElement& elem) { - VARIANT val ; - - if(util::is_failed(elem->GetCachedPropertyValue( - UIA_ValueIsReadOnlyPropertyId, &val))) { - throw RUNTIME_EXCEPT("Could not get a chached property value: IsReadOnly.") ; - } - if(val.vt != VT_BOOL) { - return false ; - } - if(val.boolVal == VARIANT_TRUE) { - return false ; - } - - if(util::is_failed(elem->GetCachedPropertyValue( - UIA_IsTextPatternAvailablePropertyId, &val))) { - throw RUNTIME_EXCEPT("Could not get a chached property value: IsTextPatternAvailable.") ; - } - if(val.vt != VT_BOOL) { - return false ; - } - if(val.boolVal == VARIANT_FALSE) { - return false ; - } - - if(util::is_failed(elem->GetCachedPropertyValue( - UIA_IsValuePatternAvailablePropertyId, &val))) { - throw RUNTIME_EXCEPT("Could not get a chached property value: IsValuePatternAvailable.") ; - } - if(val.vt != VT_BOOL) { - return false ; - } - if(val.boolVal == VARIANT_FALSE) { - return false ; - } - - return true ; - } - } -} diff --git a/src/bind/mode/text_area_scanner.hpp b/src/bind/mode/text_area_scanner.hpp deleted file mode 100644 index 462f783a..00000000 --- a/src/bind/mode/text_area_scanner.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _BIND_MODE_OPTIONS_HPP -#define _BIND_MODE_OPTIONS_HPP - -#include "util/uiwalker.hpp" - - -namespace vind -{ - namespace bind - { - struct TextAreaScanner : public util::UIWalker { - explicit TextAreaScanner() ; - virtual bool pinpoint_element(const util::SmartElement& elem) override ; - virtual bool filter_element(const util::SmartElement& elem) override ; - } ; - } -} - -#endif diff --git a/src/bind/syscmd/source.cpp b/src/bind/syscmd/source.cpp index 5e923eb7..7d94065c 100644 --- a/src/bind/syscmd/source.cpp +++ b/src/bind/syscmd/source.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -85,7 +86,7 @@ namespace return target_repo_path / ".vindrc" ; } - std::string to_compatible(std::string text) { + void to_compatible(std::string& cmd, std::string& args) { std::vector> compatible { {"system_command_comclear", "comclear"}, {"system_command_command", "command"}, @@ -116,9 +117,17 @@ namespace {"", ""}, } ; for(auto& [from, to] : compatible) { - text = util::replace_all(text, from, to) ; + args = util::replace_all(args, from, to) ; + } + + if(args.find("noautofocus_textarea") != std::string::npos) { + cmd.clear() ; + args.clear() ; + } + else if(args.find("autofocus_textarea") != std::string::npos) { + cmd = "autocmd" ; + args = "EdiNormalEnter * " ; } - return text ; } void do_runcommand( @@ -266,7 +275,10 @@ namespace vind } cmd = util::A2a(cmd) ; - line_args = to_compatible(line_args) ; + to_compatible(cmd, line_args) ; + if(cmd.empty()) { + continue ; + } if(!loaded_default_) { loaded_default_ = true ; diff --git a/src/core/settable.cpp b/src/core/settable.cpp index a8bf4dc2..9294692f 100644 --- a/src/core/settable.cpp +++ b/src/core/settable.cpp @@ -13,7 +13,6 @@ namespace Param("arrangewin_ignore", ""), - Param("autofocus_textarea", false), Param("autotrack_popup", false), Param("blockstylecaret", false),