Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cnjinhao committed May 15, 2024
1 parent eb391cb commit a10d2aa
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 92 deletions.
6 changes: 4 additions & 2 deletions include/nana/gui/detail/virtual_keyboard.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Virtual Keyboard Implementations
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2023 Jinhao([email protected])
* Copyright(C) 2003-2024 Jinhao([email protected])
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
Expand Down Expand Up @@ -41,9 +41,11 @@ namespace nana::detail
virtual_keyboard();
~virtual_keyboard();

static std::string& default_im_value() noexcept;

void attach(window);
bool qwerty(window, std::vector<std::string> langs, behaves, modes);
bool numeric(window);
bool numeric(window, bool padding);
private:
implementation* const impl_;
};
Expand Down
5 changes: 3 additions & 2 deletions include/nana/gui/widgets/skeletons/text_editor.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* A text editor implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2023 Jinhao([email protected])
* Copyright(C) 2003-2024 Jinhao([email protected])
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
Expand Down Expand Up @@ -164,6 +164,7 @@ namespace nana::widgets::skeletons
bool select(bool);

bool select_points(nana::upoint arg_a, nana::upoint arg_b);
::std::wstring make_select_string() const;

/// IM candidate mode
void im_candidate_mode(bool);
Expand Down Expand Up @@ -196,6 +197,7 @@ namespace nana::widgets::skeletons
void render(bool focused);
public:
upoint im_input(upoint insert_pos, const std::wstring& str, bool candidate);
void im_cancel();
void put(std::wstring, bool perform_event);
void put(wchar_t);
void copy() const;
Expand Down Expand Up @@ -255,7 +257,6 @@ namespace nana::widgets::skeletons

::nana::upoint _m_erase_select(bool perform_event);

::std::wstring _m_make_select_string() const;
static bool _m_resolve_text(const ::std::wstring&, std::vector<std::pair<std::size_t, std::size_t>> & lines);

bool _m_cancel_select(int align);
Expand Down
23 changes: 9 additions & 14 deletions source/gui/detail/keyboard_im.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace nana::detail
enum class labels
{
name,
short_name,
alphabet,
space,
done
Expand Down Expand Up @@ -58,6 +59,7 @@ namespace nana::detail
switch (l)
{
case labels::name:
case labels::short_name:
return L"EN";
case labels::alphabet:
return L"ABC";
Expand Down Expand Up @@ -119,6 +121,7 @@ namespace nana::detail
switch (l)
{
case labels::name:
case labels::short_name:
return L"RU";
case labels::alphabet:
return L"АБВ";
Expand Down Expand Up @@ -614,14 +617,6 @@ namespace nana::detail
table[L"zun"] = L"拵捘栫袸尊僔銌遵墫撙嶟噂樽罇繜瀳譐鐏鳟鷷鱒";
table[L"zuo"] = L"左作坐阼佐苲怍岝咗岞侳柮柞昨祚胙唑座秨袏莋笮做捽唶葄酢葃琢蓙稓筰鈼飵撮諎嘬穝繓糳";

for (auto& m : table)
{
auto idx = pinyin_list_.size();
pinyin_list_.push_back(m.first);

for (auto ch : m.second)
chartable_[ch].push_back(idx);
}

//常用词组
phrase_.insert(L"我们");
Expand Down Expand Up @@ -649,7 +644,6 @@ namespace nana::detail

start = end;
}

return pinyins;
}

Expand Down Expand Up @@ -788,14 +782,15 @@ namespace nana::detail
{
auto candidates = matched;

for (auto i = candidates.begin(); i != candidates.end();)
auto piece = s.substr(start, pos - start + 1);
for (auto i = candidates.cbegin(); i != candidates.cend(); )
{
if ((pos - start + 1 > i->size()) || ((*i)[pos - start] != s[pos]))
if ((piece.size() > i->size()) || (std::wstring::npos == i->find(piece)))
{
i = candidates.erase(i);
continue;
}

++i;
}

Expand All @@ -809,8 +804,6 @@ namespace nana::detail
}
private:
std::map<std::wstring, std::wstring> table_;
std::vector<std::wstring> pinyin_list_;
std::map<wchar_t, std::vector<std::size_t>> chartable_;
std::set<std::wstring> phrase_;
};

Expand All @@ -834,6 +827,8 @@ namespace nana::detail
return L"空格";
case labels::done:
return L"完成";
default:
break;
}
return {};
}
Expand Down
1 change: 0 additions & 1 deletion source/gui/detail/native_window_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,6 @@ namespace detail{
}
else
::MoveWindow(reinterpret_cast<HWND>(wd), x, y, r.right - r.left, r.bottom - r.top, true);

#elif defined(NANA_X11)
Display * disp = restrict::spec.open_display();

Expand Down
Loading

0 comments on commit a10d2aa

Please sign in to comment.