Skip to content

Commit

Permalink
add lock guard
Browse files Browse the repository at this point in the history
  • Loading branch information
pit-ray committed Jul 6, 2024
1 parent 865d06d commit ef733a8
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 64 deletions.
130 changes: 66 additions & 64 deletions src/core/settable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,94 +4,95 @@
#include <unordered_map>
#include <vector>

namespace
namespace vind
{
using namespace vind::core ;

std::vector<Param> default_params {
Param("hintkeys", "asdghklqwertyuiopzxcvbnmfj"),
namespace core
{
std::vector<Param> SetTable::default_params {
Param("hintkeys", "asdghklqwertyuiopzxcvbnmfj"),

Param("arrangewin_ignore", ""),
Param("arrangewin_ignore", ""),

Param("autotrack_popup", false),
Param("autotrack_popup", false),

Param("blockstylecaret", false),
Param("blockstylecaret_mode", "solid"),
Param("blockstylecaret_width", 15),
Param("blockstylecaret", false),
Param("blockstylecaret_mode", "solid"),
Param("blockstylecaret_width", 15),

Param("charbreak", "grapheme"),
Param("charcache", false),
Param("charbreak", "grapheme"),
Param("charcache", false),

Param("cmd_bgcolor", "323232"),
Param("cmd_fadeout", 5),
Param("cmd_fontcolor", "c8c8c8"),
Param("cmd_fontextra", 1),
Param("cmd_fontname", "Consolas"),
Param("cmd_fontsize", 23),
Param("cmd_fontweight", 400),
Param("cmd_monitor", "primary"),
Param("cmd_roughpos", "LowerLeft"),
Param("cmd_xmargin", 32),
Param("cmd_ymargin", 96),
Param("cmd_bgcolor", "323232"),
Param("cmd_fadeout", 5),
Param("cmd_fontcolor", "c8c8c8"),
Param("cmd_fontextra", 1),
Param("cmd_fontname", "Consolas"),
Param("cmd_fontsize", 23),
Param("cmd_fontweight", 400),
Param("cmd_monitor", "primary"),
Param("cmd_roughpos", "LowerLeft"),
Param("cmd_xmargin", 32),
Param("cmd_ymargin", 96),

Param("cursor_accel", 90),
Param("cursor_resolution", 250),
Param("cursor_accel", 90),
Param("cursor_resolution", 250),

Param("dedicate_to_window", false),
Param("dedicate_to_window", false),

Param("easyclick_bgcolor", "323232"),
Param("easyclick_fontcolor", "c8c8c8"),
Param("easyclick_fontname", "Consolas"),
Param("easyclick_fontsize", 14),
Param("easyclick_fontweight", 500),
Param("easyclick_bgcolor", "323232"),
Param("easyclick_fontcolor", "c8c8c8"),
Param("easyclick_fontname", "Consolas"),
Param("easyclick_fontsize", 14),
Param("easyclick_fontweight", 500),

Param("gridmove_bgcolor", "323232"),
Param("gridmove_fontcolor", "c8c8c8"),
Param("gridmove_fontname", "Consolas"),
Param("gridmove_fontsize", 14),
Param("gridmove_fontweight", 500),
Param("gridmove_size", "12x8"),
Param("gridmove_bgcolor", "323232"),
Param("gridmove_fontcolor", "c8c8c8"),
Param("gridmove_fontname", "Consolas"),
Param("gridmove_fontsize", 14),
Param("gridmove_fontweight", 500),
Param("gridmove_size", "12x8"),

Param("gui_fontname", "Segoe UI"),
Param("gui_fontsize", 10),
Param("gui_fontname", "Segoe UI"),
Param("gui_fontsize", 10),

Param("hscroll_pageratio", 0.125f),
Param("hscroll_speed", 10),
Param("hscroll_pageratio", 0.125f),
Param("hscroll_speed", 10),

Param("icon_style", "icon32_flat.ico"),
Param("icon_style", "icon32_flat.ico"),

Param("initmode", "i"),
Param("initmode", "i"),

Param("jump_margin", 10),
Param("jump_margin", 10),

Param("keybrd_layout", ""),
Param("keybrd_layout", ""),

Param("listen_interval", 1.0f),
Param("listen_interval", 1.0f),

Param("shell", "cmd"),
Param("shell_startupdir", ""),
Param("shellcmdflag", "-c"),
Param("shell", "cmd"),
Param("shell_startupdir", ""),
Param("shellcmdflag", "-c"),

Param("suppress_for_vim", false),
Param("suppress_for_vim", false),

Param("tempdir", "~/Downloads"),
Param("tempdir", "~/Downloads"),

Param("uiacachebuild", false),
Param("uiacachebuild_lifetime", 1500),
Param("uiacachebuild_staybegin", 500),
Param("uiacachebuild_stayend", 2000),
Param("uiacachebuild", false),
Param("uiacachebuild_lifetime", 1500),
Param("uiacachebuild_staybegin", 500),
Param("uiacachebuild_stayend", 2000),

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

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

Param("window_hdelta", 100),
Param("window_vdelta", 100),
Param("window_velocity", 100),
Param("winresizer_initmode", 0),
} ;
Param("window_hdelta", 100),
Param("window_vdelta", 100),
Param("window_velocity", 100),
Param("winresizer_initmode", 0),
} ;
}
}


Expand All @@ -114,6 +115,7 @@ namespace vind
SetTable::SetTable()
: pimpl(std::make_unique<Impl>())
{
std::lock_guard<std::mutex> scoped_lock{pimpl->mtx_} ;
for(const auto& param : default_params) {
pimpl->deftable_[param.name()] = param ;
}
Expand Down
3 changes: 3 additions & 0 deletions src/core/settable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <type_traits>
#include <typeinfo>
#include <variant>
#include <vector>


namespace vind
Expand All @@ -23,6 +24,8 @@ namespace vind
explicit SetTable() ;
virtual ~SetTable() noexcept ;

static std::vector<Param> default_params ;

public:
static SetTable& get_instance() ;

Expand Down

0 comments on commit ef733a8

Please sign in to comment.