Skip to content

Commit

Permalink
Merge branch 'fixScroll'
Browse files Browse the repository at this point in the history
  • Loading branch information
pit-ray committed Jan 20, 2021
2 parents 3bf9942 + 9206290 commit 092454a
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 46 deletions.
6 changes: 3 additions & 3 deletions build_resources/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "pit-ray\0"
VALUE "FileDescription", "win-vind (32-bit)\0"
VALUE "FileDescription", "win-vind (64-bit)\0"
VALUE "LegalCopyright", "Copyright (c) 2020 pit-ray\0"
VALUE "InternalName", "win-vind (32-bit)\0"
VALUE "InternalName", "win-vind (64-bit)\0"
VALUE "OriginalFilename", "win-vind.exe\0"
VALUE "ProductName", "win-vind (32bit)\0"
VALUE "ProductName", "win-vind (64bit)\0"
VALUE "ProductVersion", "3.0.1\0"
END
END
Expand Down
9 changes: 2 additions & 7 deletions core/include/common/text_analyzer.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#ifndef _TEXT_ANALYZER_HPP
#define _TEXT_ANALYZER_HPP

#include "disable_gcc_warning.hpp"
#include <functional>
#include <string>
#include "enable_gcc_warning.hpp"

namespace TextAnalyzer
{
Expand All @@ -22,13 +24,6 @@ namespace TextAnalyzer
: str(),
having_EOL(false)
{}

virtual ~SelRes() noexcept = default ;

SelRes(SelRes&&) noexcept = default ;
SelRes& operator=(SelRes&&) noexcept = default ;
SelRes(const SelRes&) noexcept = default ;
SelRes& operator=(const SelRes&) = default ;
} ;

const SelRes get_selected_text(
Expand Down
1 change: 1 addition & 0 deletions core/include/disable_gcc_warning.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#if defined(_MSC_VER) && _MSC_VER >= 1500
#pragma warning(disable : 4996)
#pragma warning(disable : 5054)
#pragma warning(disable : 4244)

#else
#pragma warning(disable : 4068)
Expand Down
2 changes: 1 addition & 1 deletion core/include/editor_bindings/edi_edit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TextAnalyzer
{
class SelRes ;
struct SelRes ;
}

//Copy
Expand Down
1 change: 1 addition & 0 deletions core/include/enable_gcc_warning.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#if defined(_MSC_VER) && _MSC_VER >= 1500
#pragma warning(default : 4996)
#pragma warning(default : 5054)
#pragma warning(default : 4244)

#else
#pragma warning(disable : 4068)
Expand Down
22 changes: 13 additions & 9 deletions core/src/common/key_absorber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,30 @@ namespace KeyAbsorber
static unique_ptr<HHOOK, decltype(uninstaller)> p_handle(nullptr, uninstaller) ;

static LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {
const auto release = [&wParam, &lParam](const int code) {
return CallNextHookEx(*p_handle, code, wParam, lParam) ;
} ;

if(nCode < HC_ACTION) {
//not processed
return release(nCode) ;
return CallNextHookEx(*p_handle, nCode, wParam, lParam) ;
}
const auto code = static_cast<unsigned char>(reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam)->vkCode) ;

const auto code = static_cast<unsigned char>(
reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam)->vkCode) ;

const auto state = (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) ;
g_real_state[code] = state ;
g_state[code] = state ;
g_state[VKCConverter::get_representative_key(code)] = state ;

const auto rep = VKCConverter::get_representative_key(code) ;
g_real_state[rep] = state ;
g_state[rep] = state ;

if(!g_ignored_keys.empty()) {
if(std::find(g_ignored_keys.cbegin(), g_ignored_keys.cend(), code) != g_ignored_keys.cend()) {
return release(HC_ACTION) ;
return CallNextHookEx(*p_handle, HC_ACTION, wParam, lParam) ;
}
}
return g_absorbed_flag ? -1 : release(HC_ACTION) ;

if(g_absorbed_flag) return -1 ;
else return CallNextHookEx(*p_handle, HC_ACTION, wParam, lParam) ;
}

void install_hook() {
Expand Down
23 changes: 1 addition & 22 deletions core/src/common/smart_clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ void SmartClipboard::open() {
}
if(!OpenClipboard(pimpl->hwnd)) {
throw RUNTIME_EXCEPT("failed opening clipboard") ;
return ;
}
pimpl->opening = true ;
}
Expand All @@ -56,39 +55,33 @@ void SmartClipboard::close() {
}
if(!CloseClipboard()) {
throw RUNTIME_EXCEPT("failed closing clipboard") ;
return ;
}
pimpl->opening = false ;
}

void SmartClipboard::get_as_str(std::string& str, bool& having_EOL) {
if(!pimpl->opening) {
throw LOGIC_EXCEPT("Thread does not have a clipboard open.") ;
return ;
}

if(!IsClipboardFormatAvailable(COMMON_FORMAT)) {
throw RUNTIME_EXCEPT("the current clipboard data is not supported unicode") ;
return ;
}

auto data = GetClipboardData(COMMON_FORMAT) ;
if(data == NULL) {
throw RUNTIME_EXCEPT("cannot get clipboard data") ;
return ;
}

auto unlocker = [](void* ptr) {GlobalUnlock(ptr) ;} ;
std::unique_ptr<void, decltype(unlocker)> locked_data(GlobalLock(data), unlocker) ;
if(locked_data == NULL) {
throw RUNTIME_EXCEPT("cannot lock global clipboard data ") ;
return ;
}

auto data_size = GlobalSize(locked_data.get()) ;
if(!data_size) {
throw RUNTIME_EXCEPT("the clipboard does not have data.") ;
return ;
}
auto rawstr = reinterpret_cast<char*>(locked_data.get()) ;
str = rawstr ;
Expand All @@ -107,27 +100,23 @@ void SmartClipboard::get_as_str(std::string& str, bool& having_EOL) {
void SmartClipboard::backup() {
if(!pimpl->opening) {
throw LOGIC_EXCEPT("Thread does not have a clipboard open.") ;
return ;
}

if(pimpl->cache != NULL) {
if(!GlobalFree(pimpl->cache)) {
throw RUNTIME_EXCEPT("Cannot free cache for backup") ;
return ;
}
}

auto data = GetClipboardData(COMMON_FORMAT) ;
if(data == NULL) {
throw RUNTIME_EXCEPT("cannot get clipboard data") ;
return ;
}

auto unlocker = [](void* ptr) {GlobalUnlock(ptr) ;} ;
std::unique_ptr<void, decltype(unlocker)> locked_data(GlobalLock(data), unlocker) ;
if(locked_data == NULL) {
throw RUNTIME_EXCEPT("cannot lock global clipboard data") ;
return ;
}

auto data_size = GlobalSize(locked_data.get()) ;
Expand All @@ -139,7 +128,6 @@ void SmartClipboard::backup() {
auto gmem = GlobalAlloc(GHND, data_size) ;
if(gmem == NULL) {
throw RUNTIME_EXCEPT("cannot alloc memories in global area.") ;
return ;
}

std::unique_ptr<void, decltype(unlocker)> locked_gmem(GlobalLock(gmem), unlocker) ;
Expand All @@ -156,50 +144,42 @@ void SmartClipboard::backup() {
void SmartClipboard::restore_backup() {
if(!pimpl->opening) {
throw LOGIC_EXCEPT("Thread does not have a clipboard open.") ;
return ;
}

if(pimpl->cache == NULL) {
throw LOGIC_EXCEPT("cache does not have backup") ;
return ;
}

if(!EmptyClipboard()) {
throw RUNTIME_EXCEPT("Failed initalization of clipboard") ;
return ;
}

//If SetClipboardData succeeds, the system owns gmem, so should not free gmem.
if(!SetClipboardData(COMMON_FORMAT, pimpl->cache)) {
throw RUNTIME_EXCEPT("cannot set data into clipboard") ;
return ;
}
pimpl->cache = NULL ;
}

void SmartClipboard::set(const char* const ar, const std::size_t size) {
if(!pimpl->opening) {
throw LOGIC_EXCEPT("Thread does not have a clipboard open.") ;
return ;
}

auto gmem = GlobalAlloc(GHND, size) ;
if(gmem == NULL) {
throw RUNTIME_EXCEPT("cannot alloc memories in global area.") ;
return ;
}

auto unlocker = [](void* ptr) {GlobalUnlock(ptr) ;} ;
std::unique_ptr<void, decltype(unlocker)> locked_gmem(GlobalLock(gmem), unlocker) ;
if(locked_gmem == NULL) {
throw RUNTIME_EXCEPT("cannot lock global memory for backup.") ;
GlobalFree(gmem) ;
return ;
throw RUNTIME_EXCEPT("cannot lock global memory for backup.") ;
}

if(!EmptyClipboard()) {
throw RUNTIME_EXCEPT("Failed initalization of clipboard") ;
return ;
}

std::memcpy(locked_gmem.get(), ar, size) ;
Expand All @@ -208,6 +188,5 @@ void SmartClipboard::set(const char* const ar, const std::size_t size) {
//If SetClipboardData succeeds, the system owns gmem, so should not free gmem.
if(!SetClipboardData(COMMON_FORMAT, gmem)) {
throw RUNTIME_EXCEPT("cannot set data into clipboard") ;
return ;
}
}
2 changes: 1 addition & 1 deletion core/src/common_bindings/filer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ namespace FilerUtility
if(FAILED(ppf2->GetCurFolder(&raw_pidl))) {
throw RUNTIME_EXCEPT("cannot get current folder.") ;
}
auto idl_deleter = [](LPITEMIDLIST ptr) {CoTaskMemFree(ptr) ;} ;
auto idl_deleter = [](ITEMIDLIST* ptr) {CoTaskMemFree(ptr) ;} ;
std::unique_ptr<ITEMIDLIST, decltype(idl_deleter)> pidl(raw_pidl, idl_deleter) ;

//convert to path
Expand Down
8 changes: 5 additions & 3 deletions core/src/editor_bindings/edi_replace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,14 @@ void EdiSwitchCharCase::sprocess(
KeybrdEventer::pushup(VKCConverter::get_vkc(c + delta)) ;
}
else {
unsigned char vkc = 0 ;
if((vkc = VKCConverter::get_vkc(c))) {
auto vkc = VKCConverter::get_vkc(c) ;
if(vkc) {
KeybrdEventer::pushup(vkc) ;
continue ;
}
else if((vkc = VKCConverter::get_shifted_vkc(c))) {

vkc = VKCConverter::get_shifted_vkc(c) ;
if(vkc) {
KeybrdEventer::pushup(VKC_LSHIFT, vkc) ;
continue ;
}
Expand Down
1 change: 1 addition & 0 deletions core/src/key_binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ namespace KeyBinder
if(l_repeat_num != 0) {
l_logger.back() -= c_nums ;
}

auto matched_func = find_func(l_logger, l_running_func) ;

if(!matched_func) {
Expand Down
3 changes: 3 additions & 0 deletions log/error.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Error] Windows Error Code: [0], 0 0 ` is not supported in "config\US.kmp", L2. (JumpCursorUtility::load_config()::<lambda(auto:1)> [with auto:1 = const char*])
[Error] Windows Error Code: [0], 12 0 = is not supported in "config\US.kmp", L14. (JumpCursorUtility::load_config()::<lambda(auto:1)> [with auto:1 = const char*])
[Error] Windows Error Code: [0], 11.75 2 ' is not supported in "config\US.kmp", L43. (JumpCursorUtility::load_config()::<lambda(auto:1)> [with auto:1 = const char*])

0 comments on commit 092454a

Please sign in to comment.