Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
[anthy] fix the hack, scim detect 97/211 while we want to detect 132/133
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed May 15, 2014
1 parent e70dd19 commit 2460066
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions src/key2kana.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <fcitx/module/xkb/fcitx-xkb.h>
#include "key2kana.h"
#include "factory.h"
#include "imengine.h"
Expand Down Expand Up @@ -121,9 +122,45 @@ Key2KanaConvertor::append (const KeyEvent & key,
}

static
void split_string_list(std::vector<std::string>& str, const std::string& s)
int split_string_list(std::vector<std::string>& vec, const std::string& str)
{
int count = 0;

std::string temp;
std::string::const_iterator bg, ed;

vec.clear ();

bg = str.begin ();
ed = str.begin ();

while (bg != str.end () && ed != str.end ()) {
for (; ed != str.end (); ++ed) {
if (*ed == ',')
break;
}
temp.assign (bg, ed);
vec.push_back (temp);
++count;

if (ed != str.end ())
bg = ++ ed;
}
return count;
}

static inline bool CheckLayout(FcitxInstance* instance)
{
char *layout = NULL, *variant = NULL;
bool layout_is_jp = false;
FcitxXkbGetCurrentLayout(instance, &layout, &variant);
if (layout && strcmp(layout, "jp") == 0)
layout_is_jp = true;

fcitx_utils_free(layout);
fcitx_utils_free(variant);

return layout_is_jp;
}

bool
Expand All @@ -150,7 +187,9 @@ Key2KanaConvertor::append (const std::string & str,

/* find matched table */
if ((m_anthy.get_typing_method () == FCITX_ANTHY_TYPING_METHOD_KANA) &&
(m_last_key.keycode == 132 || m_last_key.keycode == 133) &&
(CheckLayout(m_anthy.get_owner())) &&
(m_last_key.sym == FcitxKey_backslash) &&
(!(m_last_key.keycode == 132 || m_last_key.keycode == 133)) &&
(m_anthy.get_config()->m_kana_layout_ro_key[0]))
{
// Special treatment for Kana "Ro" key.
Expand Down

0 comments on commit 2460066

Please sign in to comment.