Skip to content

Commit 9381f07

Browse files
authored
Merge pull request #11 from deton/mazeadjust
後置型交ぜ書き変換を、読みの文字数指定無しでも開始可能に
2 parents 2373d54 + fd39823 commit 9381f07

24 files changed

Lines changed: 668 additions & 40 deletions

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# tsf-tutcode ver. 0.5.0
2+
# tsf-tutcode ver. 0.6.0
33

44
Windowsで動作する漢字直接入力用のIMEです。
55

@@ -127,6 +127,16 @@ IMR_DOCUMENTFEEDにも対応していないアプリの場合は、tsf-tutcode
127127
例) 「あお」の後ろでn2(MazeK2機能。「あお―」で検索)→「▼仰」
128128
参考)「あお」の後ろでm2(Maze2機能)→「▼青」
129129

130+
### 後置型交ぜ書き変換における、読み/語幹の伸縮
131+
後置型交ぜ書き変換候補表示中は、`<``>`キーにより、読み/語幹(活用語尾以外の部分)の伸縮が可能です(ただし、読み文字数を指定した場合、伸ばせるのは指定した文字数まで)。
132+
133+
活用する語に関しては、語幹が長いものを優先して変換します。
134+
(なお、不要な候補が表示されないように、活用する語の語尾は最大4文字までとしています)
135+
136+
例)「あおい」`>`「おい」`>`「い」
137+
さらに縮めると活用する語として変換
138+
`>`「あおい―」`>`「あお―」`>`「おい―」`>`「あ―」`>`「お―」`>`「い―」`
139+
130140
### 後置型カタカナ変換
131141
#### 指定した文字数をカタカナに置換
132142
例)「あぷり」の後ろでk3(Kata3機能に割り当てたシーケンス)→「アプリ」
@@ -541,14 +551,18 @@ Visual C++ 2015 の 正規表現で、文法は ECMAScript を使用していま
541551
| Help2 | カーソル直前の2文字の打鍵ヘルプ表示 |
542552
| ... | |
543553
| Help9 | カーソル直前の9文字の打鍵ヘルプ表示 |
554+
| Maze0 | 後置型交ぜ書き変換開始。最長一致 |
544555
| Maze1 | 後置型交ぜ書き変換開始。読み1文字 |
545-
| Maze2 | 後置型交ぜ書き変換開始。読み2文字 |
546556
| ... | |
547557
| Maze9 | 後置型交ぜ書き変換開始。読み9文字 |
558+
| MazeK0 | 後置型交ぜ書き変換開始(活用する語。読みに―を追加)。最長一致 |
548559
| MazeK1 | 後置型交ぜ書き変換開始(活用する語。読みに―を追加)。読み1文字 |
549-
| MazeK2 | 後置型交ぜ書き変換開始(活用する語。読みに―を追加)。読み2文字 |
550560
| ... | |
551561
| MazeK9 | 後置型交ぜ書き変換開始(活用する語。読みに―を追加)。読み9文字 |
562+
| Mazek0 | 後置型交ぜ書き変換開始(読みを縮めた際に活用する語としての変換は試みない)。最長一致 |
563+
| Mazek1 | 後置型交ぜ書き変換開始(読みを縮めた際に活用する語としての変換は試みない)。読み1文字 |
564+
| ... | |
565+
| Mazek9 | 後置型交ぜ書き変換開始(読みを縮めた際に活用する語としての変換は試みない)。読み9文字 |
552566
| Kata0 | 後置型カタカナ変換。連続するひらがなをカタカナに置換 |
553567
| Kata1 | 後置型カタカナ変換。1文字をカタカナに置換 |
554568
| Kata2 | 後置型カタカナ変換。2文字をカタカナに置換 |
@@ -830,8 +844,7 @@ ASCII, JIS X 0201, JIS X 0213に変換できない文字が含まれていた場
830844

831845
以上の状況があてはまらない場合は、漢直Winを選ぶ方が良いです。
832846
tsf-tutcodeは未実装機能が多いため。
833-
(ヘルプ表示、前置型部首合成、熟語ヘルプ、ヒストリ入力、
834-
活用する語の交ぜ書き変換、交ぜ書き変換での語幹の伸縮、強制練習モード等)
847+
(ヘルプ表示、前置型部首合成、熟語ヘルプ、ヒストリ入力、強制練習モード等)
835848

836849
### ソースに関して
837850

@@ -886,6 +899,12 @@ pandoc 1.17.2
886899

887900
### 履歴
888901

902+
#### v0.6.0 (2016-10-24)
903+
* 後置型交ぜ書き変換を、読みの文字数指定無しでも開始可能に:`Maze0`,`MazeK0`
904+
+ 候補表示中に`>``<`キーにより、読み/語幹の伸縮可能
905+
+ 活用しない語を縮めていくと、活用する語としての変換を試行
906+
+ 活用しない語を縮めていった際に、活用する語としての変換を試行しない「機能」追加:`Mazek0`
907+
889908
#### v0.5.0 (2016-09-12)
890909
* 仮想鍵盤表示機能を追加。
891910
* ベースのCorvusSKKを2.4.5に更新。

common/version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
#define TEXTSERVICE_DESC TEXTSERVICE_NAME L"_DEBUG"
1010
#endif
1111
#define TEXTSERVICE_DIR L"IMTSFTUTCODE"
12-
#define TEXTSERVICE_VER L"0.5.0"
12+
#define TEXTSERVICE_VER L"0.6.0"
1313

1414
//for resource
1515
#define RC_AUTHOR "KIHARA Hideto"
1616
#define RC_PRODUCT "tsf-tutcode"
17-
#define RC_VERSION "0.5.0"
18-
#define RC_VERSION_D 0,5,0,0
17+
#define RC_VERSION "0.6.0"
18+
#define RC_VERSION_D 0,6,0,0
1919

2020
#endif

imcrvcnf/convtable.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const ROMAN_KANA_CONV roman_kana_conv_default[ROMAN_KANA_TBL_DEF_NUM] =
1010
{L"alj", L"maze", L"maze", L"maze", FALSE, FALSE, TRUE},
1111
{L"ald", L"Bushu", L"Bushu", L"Bushu", FALSE, FALSE, TRUE},
1212
{L"al?", L"Help4", L"Help4", L"Help4", FALSE, FALSE, TRUE},
13+
{L"m0", L"Maze0", L"Maze0", L"Maze0", FALSE, FALSE, TRUE},
1314
{L"m1", L"Maze1", L"Maze1", L"Maze1", FALSE, FALSE, TRUE},
1415
{L"m2", L"Maze2", L"Maze2", L"Maze2", FALSE, FALSE, TRUE},
1516
{L"m3", L"Maze3", L"Maze3", L"Maze3", FALSE, FALSE, TRUE},
@@ -19,6 +20,7 @@ const ROMAN_KANA_CONV roman_kana_conv_default[ROMAN_KANA_TBL_DEF_NUM] =
1920
{L"m7", L"Maze7", L"Maze7", L"Maze7", FALSE, FALSE, TRUE},
2021
{L"m8", L"Maze8", L"Maze8", L"Maze8", FALSE, FALSE, TRUE},
2122
{L"m9", L"Maze9", L"Maze9", L"Maze9", FALSE, FALSE, TRUE},
23+
{L"n0", L"MazeK0", L"MazeK0", L"MazeK0", FALSE, FALSE, TRUE},
2224
{L"n1", L"MazeK1", L"MazeK1", L"MazeK1", FALSE, FALSE, TRUE},
2325
{L"n2", L"MazeK2", L"MazeK2", L"MazeK2", FALSE, FALSE, TRUE},
2426
{L"n3", L"MazeK3", L"MazeK3", L"MazeK3", FALSE, FALSE, TRUE},

imcrvcnf/convtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "convtype.h"
66

7-
#define ROMAN_KANA_TBL_DEF_NUM 3133
7+
#define ROMAN_KANA_TBL_DEF_NUM 3135
88

99
//変換テーブル
1010
extern const ROMAN_KANA_CONV roman_kana_conv_default[ROMAN_KANA_TBL_DEF_NUM];

imcrvtip/CandidateList.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,15 @@ void CCandidateList::_SetText(const std::wstring &text, BOOL fixed, int mode)
493493
}
494494
}
495495

496+
//辞書登録時後置型交ぜ書き変換で読みから外した部分をセット。表示用
497+
void CCandidateList::_SetTextExcludedPostyomi(const std::wstring &text)
498+
{
499+
if(_pCandidateWindow != nullptr)
500+
{
501+
_pCandidateWindow->_SetTextExcludedPostyomi(text);
502+
}
503+
}
504+
496505
void CCandidateList::_GetPrecedingText(std::wstring *text)
497506
{
498507
if(_pCandidateWindow != NULL)

imcrvtip/CandidateList.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class CCandidateList :
3737
void _InvokeSfHandler(BYTE sf);
3838
void _Show(BOOL bShow);
3939
void _SetText(const std::wstring &text, BOOL fixed, int mode);
40+
//辞書登録時後置型交ぜ書き変換で読みから外した部分をセット。表示用
41+
void _SetTextExcludedPostyomi(const std::wstring &text);
4042
void _GetPrecedingText(std::wstring *text);
4143
void _DeletePrecedingText(size_t delete_count);
4244
void _Move(LPRECT lpr, TfEditCookie ec = TF_INVALID_EDIT_COOKIE, ITfContext *pContext = nullptr);

imcrvtip/CandidatePaint.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ std::wstring CCandidateWindow::_MakeRegWordString()
256256

257257
s.append(_regtext.substr(0, _regtextpos));
258258

259+
s.append(_regexcpostyomi);
259260
s.append(_regcomp + markCursor);
260261

261262
s.append(_regtext.substr(_regtextpos) + markNBSP);

imcrvtip/CandidateWindow.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ void CCandidateWindow::_SetText(const std::wstring &text, BOOL fixed, int mode)
405405
if(fixed)
406406
{
407407
_regcomp.clear();
408+
_regexcpostyomi.clear();
408409
_regtext.insert(_regtextpos, text);
409410
_regtextpos += text.size();
410411
}
@@ -421,16 +422,26 @@ void CCandidateWindow::_SetText(const std::wstring &text, BOOL fixed, int mode)
421422
_Update();
422423
}
423424

425+
//辞書登録時後置型交ぜ書き変換で読みから外した部分をセット。表示用
426+
void CCandidateWindow::_SetTextExcludedPostyomi(const std::wstring &text)
427+
{
428+
if(_pCandidateWindow != nullptr && !_preEnd)
429+
{
430+
_pCandidateWindow->_SetTextExcludedPostyomi(text);
431+
return;
432+
}
433+
434+
_regexcpostyomi.assign(text);
435+
}
436+
424437
void CCandidateWindow::_GetPrecedingText(std::wstring *text)
425438
{
426439
if(_pCandidateWindow != NULL && !_preEnd)
427440
{
428441
_pCandidateWindow->_GetPrecedingText(text);
429442
return;
430443
}
431-
432-
text->clear();
433-
text->append(_regtext.substr(0, _regtextpos));
444+
text->assign(_regtext, 0, _regtextpos);
434445
}
435446

436447
void CCandidateWindow::_DeletePrecedingText(size_t delete_count)
@@ -837,6 +848,7 @@ void CCandidateWindow::_BackUpStatus()
837848
candidates_bak = _pTextService->candidates;
838849
candidx_bak = _pTextService->candidx;
839850
candorgcnt_bak = _pTextService->candorgcnt;
851+
postmazeContext_bak = _pTextService->postmazeContext;
840852
}
841853

842854
void CCandidateWindow::_ClearStatus()
@@ -851,6 +863,7 @@ void CCandidateWindow::_ClearStatus()
851863
_pTextService->candidates.clear();
852864
_pTextService->candidx = 0;
853865
_pTextService->candorgcnt = 0;
866+
_pTextService->postmazeContext.Deactivate();
854867
_pTextService->showcandlist = FALSE;
855868
_pTextService->showentry = FALSE;
856869
_pTextService->inputkey = FALSE;
@@ -869,6 +882,7 @@ void CCandidateWindow::_RestoreStatusReg()
869882
_pTextService->candidates = candidates_bak;
870883
_pTextService->candidx = candidx_bak;
871884
_pTextService->candorgcnt = candorgcnt_bak;
885+
_pTextService->postmazeContext = postmazeContext_bak;
872886
_pTextService->showcandlist = TRUE;
873887
_pTextService->showentry = TRUE;
874888
_pTextService->inputkey = TRUE;
@@ -886,6 +900,7 @@ void CCandidateWindow::_ClearStatusReg()
886900
candidates_bak.clear();
887901
candidx_bak = 0;
888902
candorgcnt_bak = 0;
903+
postmazeContext_bak.Deactivate();
889904
}
890905

891906
void CCandidateWindow::_PreEndReq()

imcrvtip/CandidateWindow.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class CCandidateWindow : public ITfCandidateListUIElementBehavior
5151
BOOL _CanShowUIElement();
5252
void _Redraw();
5353
void _SetText(const std::wstring &text, BOOL fixed, int mode);
54+
//辞書登録時後置型交ぜ書き変換で読みから外した部分をセット。表示用
55+
void _SetTextExcludedPostyomi(const std::wstring &text);
5456
void _GetPrecedingText(std::wstring *text);
5557
void _DeletePrecedingText(size_t delete_count);
5658
void _PreEnd();
@@ -141,6 +143,7 @@ class CCandidateWindow : public ITfCandidateListUIElementBehavior
141143
std::wstring _regtext; //確定文字列
142144
size_t _regtextpos; //カーソルインデックス
143145
std::wstring _regcomp; //未確定文字列
146+
std::wstring _regexcpostyomi; //後置型交ぜ書き変換で読みから外した部分
144147

145148
CANDIDATES candidates; //描画用候補
146149
size_t candidx; //描画用候補インデックス
@@ -159,6 +162,7 @@ class CCandidateWindow : public ITfCandidateListUIElementBehavior
159162
CANDIDATES candidates_bak;
160163
size_t candidx_bak;
161164
size_t candorgcnt_bak;
165+
CPostMazeContext postmazeContext_bak;
162166
};
163167

164168
#endif //CANDIDATEWINDOW_H

imcrvtip/KeyHandlerChar.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "imcrvtip.h"
33
#include "TextService.h"
44
#include "CandidateList.h"
5+
#include "moji.h"
56

67
HRESULT CTextService::_HandleChar(TfEditCookie ec, ITfContext *pContext, WPARAM wParam, WCHAR ch, WCHAR chO)
78
{
@@ -11,6 +12,29 @@ HRESULT CTextService::_HandleChar(TfEditCookie ec, ITfContext *pContext, WPARAM
1112

1213
if(showentry)
1314
{
15+
//後置型交ぜ書き変換の候補表示時
16+
if(postmazeContext.IsActive())
17+
{
18+
if(ch == L'>') //読みを縮める操作が行われた
19+
{
20+
std::wstring yomi;
21+
if(postmazeContext.Shrink(&yomi))
22+
{
23+
_StartConvWithYomi(ec, pContext, yomi);
24+
}
25+
return S_OK;
26+
}
27+
else if(ch == L'<') //読みを伸ばす操作が行われた
28+
{
29+
std::wstring yomi;
30+
if(postmazeContext.Extend(&yomi))
31+
{
32+
_StartConvWithYomi(ec, pContext, yomi);
33+
}
34+
return S_OK;
35+
}
36+
}
37+
1438
_HandleCharShift(ec, pContext);
1539
}
1640

0 commit comments

Comments
 (0)