Skip to content

Commit

Permalink
1.2.2
Browse files Browse the repository at this point in the history
・デフォルトのローマ字仮名変換表とconfig.xmlのサンプルを修正しました。
 平仮名、片仮名モードの「!」「?」を全角文字にしました。
 半角片仮名モードの「z+space」を全角文字にしました。
 config.xmlのサンプルのキー設定で欠けてた箇所を追加しました。
 kanatable.txtで片仮名モードの「]」が空になっていたのを修正しました。

  coさん、情報ありがとうございました。

・実行変換もどきで/関数が\057にエスケープされて実行していなかったのを修正しました。

・実行変換もどきにskk-relative-date関数を追加しました。

・関数名、変数名にスペルミスがあったのを修正しました。


git-svn-id: http://corvus-skk.googlecode.com/svn/trunk@177 59f9050b-5214-92d2-4700-6fac3f2ee9b9
  • Loading branch information
[email protected] committed Sep 25, 2013
1 parent 773ea75 commit 48b2f84
Show file tree
Hide file tree
Showing 18 changed files with 153 additions and 95 deletions.
6 changes: 3 additions & 3 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define COMMON_H

#define TEXTSERVICE_NAME L"CorvusSKK"
#define TEXTSERVICE_VER L"1.2.1"
#define TEXTSERVICE_VER L"1.2.2"

#ifndef _DEBUG
#define TEXTSERVICE_DESC TEXTSERVICE_NAME
Expand All @@ -14,8 +14,8 @@
//for resource
#define RC_AUTHOR "Nathan Corvus Solis"
#define RC_PRODUCT "CorvusSKK"
#define RC_VERSION "1.2.1"
#define RC_VERSION_D 1,2,1,0
#define RC_VERSION "1.2.2"
#define RC_VERSION_D 1,2,2,0

#define DICBUFSIZE 0x2000
#define PIPEBUFSIZE 0x2000
Expand Down
14 changes: 7 additions & 7 deletions imcrvcnf/convtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ const ROMAN_KANA_CONV roman_kana_conv_default[ROMAN_KANA_TBL_DEF_NUM] =
{L"v.", L"", L"", L""}, //半濁点
{L"x,", L"\x3099", L"\x3099", L""}, //結合文字用濁音
{L"x.", L"\x309A", L"\x309A", L""}, //結合文字用半濁音「か゚」→「カ゚」
{L"z;", L"", L"", L""}, //濁点
{L"z:", L"", L"", L""}, //半濁点

//数字
{L"0", L"0", L"0", L"0"}, {L"1", L"1", L"1", L"1"},
Expand All @@ -194,7 +192,7 @@ const ROMAN_KANA_CONV roman_kana_conv_default[ROMAN_KANA_TBL_DEF_NUM] =

//記号
{L"\x20", L"\x20", L"\x20", L"\x20"},
{L"!", L"!", L"!", L"!"},
{L"!", L"", L"", L"!"}, //full-width
{L"\"", L"\"", L"\"", L"\""},
{L"#", L"#", L"#", L"#"},
{L"$", L"$", L"$", L"$"},
Expand All @@ -215,7 +213,7 @@ const ROMAN_KANA_CONV roman_kana_conv_default[ROMAN_KANA_TBL_DEF_NUM] =
{L"<", L"<", L"<", L"<"},
{L"=", L"=", L"=", L"="},
{L">", L">", L">", L">"},
{L"?", L"?", L"?", L"?"},
{L"?", L"", L"", L"?"}, //full-width
{L"@", L"@", L"@", L"@"},
// // [A-Z] //
{L"[", L"", L"", L""}, //full-width, half width katakana
Expand All @@ -231,22 +229,24 @@ const ROMAN_KANA_CONV roman_kana_conv_default[ROMAN_KANA_TBL_DEF_NUM] =
{L"~", L"~", L"~", L"~"},

//z記号
{L"z\x20", L" ", L" ", L"\x20"}, //全角スペース
{L"z\x20", L" ", L" ", L" "}, //全角スペース
{L"z,", L"", L"", L""},
{L"z-", L"", L"", L""},
{L"z.", L"", L"", L""},
{L"z/", L"", L"", L""}, //half width katakana
{L"z(", L"", L"", L""},
{L"z)", L"", L"", L""},
{L"z[", L"", L"", L""},
{L"z]", L"", L"", L""},
{L"z{", L"", L"", L""},
{L"z}", L"", L"", L""},
{L"z(", L"", L"", L""},
{L"z)", L"", L"", L""},
{L"zh", L"", L"", L""},
{L"zj", L"", L"", L""},
{L"zk", L"", L"", L""},
{L"zl", L"", L"", L""},
{L"zL", L"", L"", L""},
{L"z;", L"", L"", L""}, //濁点
{L"z:", L"", L"", L""}, //半濁点

{L"",L"",L"",L""}
};
Expand Down
10 changes: 8 additions & 2 deletions imcrvmgr/ConvDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,15 @@ std::wstring ConvMisc(const std::wstring &key, const std::wstring &candidate)
candidate_tmp = ret;
}

if(candidate_tmp.size() > 2 && candidate_tmp[0] == L'(' && candidate_tmp[candidate_tmp.size() - 1] == L')')
//concat関数で"/"関数が\057にエスケープされる為2回実行する
for(int i=0; i<2; i++)
{
ret = ConvGaget(key, candidate_tmp);
if(candidate_tmp.size() > 2 &&
candidate_tmp[0] == L'(' && candidate_tmp[candidate_tmp.size() - 1] == L')')
{
ret = ConvGadget(key, candidate_tmp);
candidate_tmp = ret;
}
}

return ret;
Expand Down
118 changes: 83 additions & 35 deletions imcrvmgr/ConvGadget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ static std::wstring gadgetkey;
static std::vector<std::wstring> skk_num_list;
static time_t gadgettime;

std::wstring gadget_func(const std::wstring s);



static std::wstring xf(const _GPARAM &param)
Expand Down Expand Up @@ -151,13 +153,6 @@ static std::wstring car(const _GPARAM &param)
return ret;
}

static std::wstring lambda(const _GPARAM &param)
{
if(param.size() < 2) return L"";

return param[1];
}

static std::wstring plus1(const _GPARAM &param)
{
if(param.size() < 1) return L"";
Expand Down Expand Up @@ -234,19 +229,18 @@ static std::wstring mul(const _GPARAM &param)

static std::wstring div(const _GPARAM &param)
{
int n = 1;
for(size_t i = 0; i<param.size(); i++)
if(param.size() < 2) return L"";

int n1 = _wtoi(param[0].c_str());
int n2 = _wtoi(param[1].c_str());
if(n2 == 0)
{
if(_wtoi(param[i].c_str()) == 0)
{
n = 0;
break;
}
n /= _wtoi(param[i].c_str());
n1 = 0;
n2 = 1;
}

WCHAR num[32];
_snwprintf_s(num, _TRUNCATE, L"%d", n);
_snwprintf_s(num, _TRUNCATE, L"%d", n1 / n2);

return num;
}
Expand Down Expand Up @@ -412,26 +406,35 @@ static std::wstring skk_gengo_to_ad(const _GPARAM &param)

static std::wstring skk_current_date(const _GPARAM &param)
{
if(param.size() > 0) return param[0];

struct tm d;
localtime_s(&d, &gadgettime);
WCHAR y[5];
_snwprintf_s(y, _TRUNCATE, L"%d", d.tm_year + 1900);
std::wstring gg = conv_ad_to_gengo(y, L"0", L"#1", L"");
if (gg.empty())
std::wstring ret;
if(param.size() == 0)
{
struct tm d;
localtime_s(&d, &gadgettime);
WCHAR y[5];
_snwprintf_s(y, _TRUNCATE, L"%d", d.tm_year + 1900);
std::wstring gg = conv_ad_to_gengo(y, L"0", L"#1", L"");
if (gg.empty())
{
return L"";
}
WCHAR st[32];
WCHAR sm[4];
WCHAR sd[4];
_snwprintf_s(sm, _TRUNCATE, L"%d", d.tm_mon + 1);
_snwprintf_s(sd, _TRUNCATE, L"%d", d.tm_mday);
_snwprintf_s(st, _TRUNCATE, L"%s年%s月%s日(%s)",
gg.c_str(), ConvNum(sm, L"#1").c_str(), ConvNum(sd, L"#1").c_str(), week_jp[d.tm_wday]);
ret = st;
}
else
{
return L"";
ret = gadget_func(param[0]);
//format param[1];
//and-time param[2];
}
WCHAR st[32];
WCHAR sm[4];
WCHAR sd[4];
_snwprintf_s(sm, _TRUNCATE, L"%d", d.tm_mon + 1);
_snwprintf_s(sd, _TRUNCATE, L"%d", d.tm_mday);
_snwprintf_s(st, _TRUNCATE, L"%s年%s月%s日(%s)",
gg.c_str(), ConvNum(sm, L"#1").c_str(), ConvNum(sd, L"#1").c_str(), week_jp[d.tm_wday]);

return st;
return ret;
}

static std::wstring skk_default_current_date(const _GPARAM &param)
Expand Down Expand Up @@ -532,6 +535,45 @@ static std::wstring skk_default_current_date(const _GPARAM &param)
return ret;
}

static std::wstring skk_relative_date(const _GPARAM &param)
{
_GPARAM x;
if(param.size() == 0) return skk_current_date(x);

if(param.size() < 5) return L"";

std::wstring func = param[0];
if(param[0] == L"nil")
{
func = L"(skk-current-date)";
}

//format param[1];
//and-time param[2];
std::wstring ymd = param[3];
int diff = _wtoi(param[4].c_str());

struct tm d;
localtime_s(&d, &gadgettime);

if(ymd == L":yy") d.tm_year += diff;
else if(ymd == L":mm") d.tm_mon += diff;
else if(ymd == L":dd") d.tm_mday += diff;

time_t gadgettime_bak= gadgettime;
gadgettime = mktime(&d);

std::wstring ret;
if(gadgettime != (time_t)-1)
{
ret = gadget_func(func);
}

gadgettime = gadgettime_bak;

return ret;
}



struct {
Expand All @@ -545,7 +587,7 @@ struct {
{L"string-to-number", string_to_number},
{L"current-time-string", current_time_string},
{L"car", car},
{L"lambda", lambda},
{L"lambda", xf},
{L"1+", plus1},
{L"1-", minus1},
{L"+", plus},
Expand All @@ -565,6 +607,7 @@ struct {
{L"skk-gengo-to-ad", skk_gengo_to_ad},
{L"skk-current-date", skk_current_date},
{L"skk-default-current-date", skk_default_current_date},
{L"skk-relative-date", skk_relative_date},

{L"", xf}
};
Expand Down Expand Up @@ -635,6 +678,11 @@ static std::wstring gadget_func(const std::wstring s)
else
{
funcname = ss.substr(0, i);
if(funcname == L"lambda")
{
return std::regex_replace(ss,
std::wregex(L"lambda\\s+\\(.*?\\)\\s+(\\(.+\\))"), std::wstring(L"$1"));
}

iparam = i + 1;
ibracketcnt = 0;
Expand Down Expand Up @@ -709,7 +757,7 @@ static std::wstring gadget_func(const std::wstring s)
return ret;
}

std::wstring ConvGaget(const std::wstring &key, const std::wstring &candidate)
std::wstring ConvGadget(const std::wstring &key, const std::wstring &candidate)
{
std::wstring ret;
size_t i;
Expand Down
2 changes: 1 addition & 1 deletion imcrvmgr/imcrvmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void InitSKKDic();
void ConvCandidate(const std::wstring &searchkey, const std::wstring &candidate, std::wstring &conv);

// ConvGadget
std::wstring ConvGaget(const std::wstring &key, const std::wstring &candidate);
std::wstring ConvGadget(const std::wstring &key, const std::wstring &candidate);

// ConvNum
std::wstring ConvNum(const std::wstring &key, const std::wstring &candidate);
Expand Down
10 changes: 5 additions & 5 deletions imcrvtip/CandidateUIElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CCandidateWindow::CCandidateWindow(CTextService *pTextService)
_uIndex = 0;
_uPageCnt = 0;
_CandCount.clear();
_PageInex.clear();
_PageIndex.clear();
_CandStr.clear();

hFont = NULL;
Expand Down Expand Up @@ -351,7 +351,7 @@ STDAPI CCandidateWindow::GetPageIndex(UINT *pIndex, UINT uSize, UINT *puPageCnt)
{
for(i=0; i<uSize; i++)
{
*pIndex = _PageInex[i];
*pIndex = _PageIndex[i];
pIndex++;
}
}
Expand Down Expand Up @@ -394,7 +394,7 @@ STDAPI CCandidateWindow::SetPageIndex(UINT *pIndex, UINT uPageCnt)
}
}

_PageInex.clear();
_PageIndex.clear();
_CandCount.clear();
_CandStr.clear();
j = 0;
Expand All @@ -411,7 +411,7 @@ STDAPI CCandidateWindow::SetPageIndex(UINT *pIndex, UINT uPageCnt)
}

pIndex[j] = k;
_PageInex.push_back(k);
_PageIndex.push_back(k);
_CandCount.push_back(uCandCnt);

for(i=0; i<uCandCnt; i++)
Expand Down Expand Up @@ -476,7 +476,7 @@ STDAPI CCandidateWindow::GetCurrentPage(UINT *puPage)

for(i=1; i<_uPageCnt; i++)
{
if(_PageInex[i] > _uIndex)
if(_PageIndex[i] > _uIndex)
{
break;
}
Expand Down
14 changes: 7 additions & 7 deletions imcrvtip/CandidateWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ HRESULT CCandidateWindow::_OnKeyDown(UINT uVKey)
GetCurrentPage(&page);
if(i < _CandCount[page])
{
index = (UINT)(_pTextService->c_untilcandlist - 1) + _PageInex[page] + i;
index = (UINT)(_pTextService->c_untilcandlist - 1) + _PageIndex[page] + i;
if(index < _pTextService->candidates.size())
{
if(!regword)
Expand Down Expand Up @@ -927,11 +927,11 @@ void CCandidateWindow::_InitList()

_uPageCnt = ((_uCount - (_uCount % MAX_SELKEY)) / MAX_SELKEY) + ((_uCount % MAX_SELKEY) == 0 ? 0 : 1);

_PageInex.clear();
_PageIndex.clear();
_CandCount.clear();
for(i=0; i<_uPageCnt; i++)
{
_PageInex.push_back(i * MAX_SELKEY);
_PageIndex.push_back(i * MAX_SELKEY);
_CandCount.push_back( (i < (_uPageCnt - 1)) ? MAX_SELKEY :
(((_uCount % MAX_SELKEY) == 0) ? MAX_SELKEY : (_uCount % MAX_SELKEY)) );
}
Expand Down Expand Up @@ -992,7 +992,7 @@ void CCandidateWindow::_NextPage()
}
}

_uIndex = _PageInex[uNewPage];
_uIndex = _PageIndex[uNewPage];

_dwFlags = TF_CLUIE_SELECTION;
if(uNewPage != uOldPage)
Expand Down Expand Up @@ -1075,7 +1075,7 @@ void CCandidateWindow::_PrevPage()
return;
}

_uIndex = _PageInex[uNewPage];
_uIndex = _PageIndex[uNewPage];

_dwFlags = TF_CLUIE_SELECTION;
if(uNewPage != uOldPage)
Expand Down Expand Up @@ -1135,7 +1135,7 @@ void CCandidateWindow::_OnKeyDownRegword(UINT uVKey)
if(!_reg)
{
_InitList();
_uIndex = _PageInex[_PageInex.size() - 1];
_uIndex = _PageIndex[_PageIndex.size() - 1];
_Update();
_UpdateUIElement();
}
Expand Down Expand Up @@ -1224,7 +1224,7 @@ void CCandidateWindow::_OnKeyDownRegword(UINT uVKey)
if(!_reg)
{
_InitList();
_uIndex = _PageInex[_PageInex.size() - 1];
_uIndex = _PageIndex[_PageIndex.size() - 1];
_Update();
_UpdateUIElement();
}
Expand Down
Loading

0 comments on commit 48b2f84

Please sign in to comment.