Skip to content

Commit

Permalink
DEC特殊文字をUnicodeへマッピングできるようにした
Browse files Browse the repository at this point in the history
- DEC特殊文字をUnicodeで置き換えるコードを追加
- codingタブにDEC特殊文字に関する設定を追加

git-svn-id: https://svn.osdn.net/svnroot/ttssh2/trunk@10805 f5f01b69-1e22-0410-acbf-894ab4bd6246
  • Loading branch information
zmatsuo committed Jul 23, 2023
1 parent d660041 commit 9bccc07
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 15 deletions.
5 changes: 5 additions & 0 deletions installer/release/lang_utf8/Japanese.lng
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ DLG_TERM_KANJISEND=コーディング-送信(&N)
DLG_TERM_KANASEND=半角カナ(&D)
DLG_TERM_KIN=漢字イン(&N):
DLG_TERM_KOUT=漢字アウト(&O):
DLG_CODING_UNICODE_TO_DEC=UnicodeをDEC特殊文字へマッピングする
DLG_CODING_DEC_TO_UNICODE=DEC特殊文字をUnicodeへマッピングする
DLG_CODING_UNICODE_TO_DEC_BOXDRAWING=罫線素片(U+2500-U+257F)
DLG_CODING_UNICODE_TO_DEC_PUNCTUATION=
DLG_CODING_UNICODE_TO_DEC_MIDDLEDOT=中点(U+00B7,U+2024,U+2219)

DLG_WIN_TITLE=Tera Term: ウィンドウの設定
DLG_WIN_TITLELABEL=タイトル(&T):
Expand Down
1 change: 1 addition & 0 deletions teraterm/common/tttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ struct tttset {
wchar_t DialogFontNameW[LF_FACESIZE];
BOOL NotifySound;
wchar_t *LogDefaultNameW;
BOOL Dec2Unicode;

// Experimental
BYTE ExperimentalTreeProprtySheetEnable;
Expand Down
21 changes: 21 additions & 0 deletions teraterm/teraterm/coding_pp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ static INT_PTR CALLBACK Proc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{IDC_TERMKANASEND, "DLG_TERM_KANASEND"},
{IDC_TERMKINTEXT, "DLG_TERM_KIN"},
{IDC_TERMKOUTTEXT, "DLG_TERM_KOUT"},
{ IDC_UNICODE2DEC, "DLG_CODING_UNICODE_TO_DEC" },
{ IDC_DEC2UNICODE, "DLG_CODING_DEC_TO_UNICODE" },
{ IDC_DEC2UNICODE_BOXDRAWING, "DLG_CODING_UNICODE_TO_DEC_BOXDRAWING" },
{ IDC_DEC2UNICODE_PUNCTUATION, "DLG_CODING_UNICODE_TO_DEC_PUNCTUATION" },
{ IDC_DEC2UNICODE_MIDDLEDOT, "DLG_CODING_UNICODE_TO_DEC_MIDDLEDOT" },
};
CodingPPData *DlgData = (CodingPPData *)GetWindowLongPtr(hWnd, DWLP_USER);

Expand Down Expand Up @@ -142,6 +147,16 @@ static INT_PTR CALLBACK Proc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
SetDropDownList(hWnd, IDC_EMOJI_WIDTH_COMBO, CellWidthList, ts->UnicodeEmojiWidth == 1 ? 1 : 2);
EnableWindow(GetDlgItem(hWnd, IDC_EMOJI_WIDTH_COMBO), ts->UnicodeEmojiOverride);

// DEC Special Graphics
CheckDlgButton(hWnd, IDC_UNICODE2DEC, ts->Dec2Unicode ? BST_UNCHECKED : BST_CHECKED);
CheckDlgButton(hWnd, IDC_DEC2UNICODE, ts->Dec2Unicode ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_DEC2UNICODE_BOXDRAWING,
(ts->UnicodeDecSpMapping & 0x01) != 0 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_DEC2UNICODE_PUNCTUATION,
(ts->UnicodeDecSpMapping & 0x02) != 0 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_DEC2UNICODE_MIDDLEDOT,
(ts->UnicodeDecSpMapping & 0x04) != 0 ? BST_CHECKED : BST_UNCHECKED);

return TRUE;
}
case WM_NOTIFY: {
Expand Down Expand Up @@ -206,6 +221,12 @@ static INT_PTR CALLBACK Proc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
ts->UnicodeEmojiOverride = (BYTE)IsDlgButtonChecked(hWnd, IDC_EMOJI_WIDTH_CHECK);
ts->UnicodeEmojiWidth = (BYTE)GetCurSel(hWnd, IDC_EMOJI_WIDTH_COMBO);

// DEC Special Graphics
ts->Dec2Unicode = (BYTE)IsDlgButtonChecked(hWnd, IDC_DEC2UNICODE);
ts->UnicodeDecSpMapping =
(WORD)((IsDlgButtonChecked(hWnd, IDC_DEC2UNICODE_BOXDRAWING) << 0) |
(IsDlgButtonChecked(hWnd, IDC_DEC2UNICODE_PUNCTUATION) << 1) |
(IsDlgButtonChecked(hWnd, IDC_DEC2UNICODE_MIDDLEDOT) << 2));
break;
}
case PSN_HELP: {
Expand Down
25 changes: 20 additions & 5 deletions teraterm/teraterm/coding_pp.rc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
// Dialog
//

IDD_TABSHEET_CODING DIALOGEX 0, 0, 323, 191
IDD_TABSHEET_CODING DIALOGEX 0, 0, 323, 213
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_CAPTION | WS_SYSMENU
CAPTION "Coding"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
Expand All @@ -43,10 +43,21 @@ BEGIN
LTEXT "Ambiguous Characters width",IDC_STATIC,10,95,113,8
COMBOBOX IDC_AMBIGUOUS_WIDTH_COMBO,22,108,49,60,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Override Emoji Characters width",IDC_EMOJI_WIDTH_CHECK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,127,136,10
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,127,131,10
COMBOBOX IDC_EMOJI_WIDTH_COMBO,22,143,49,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Language:",IDC_GENLANGLABEL,10,166,52,10,NOT WS_VISIBLE
COMBOBOX IDC_GENLANG,71,164,93,81,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
LTEXT "&Language:",IDC_GENLANGLABEL,10,188,52,10,NOT WS_VISIBLE
COMBOBOX IDC_GENLANG,71,187,93,81,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
LTEXT "DEC Special Graphics",IDC_STATIC,141,94,110,8
CONTROL "Mapping Unicode to DEC special Graphics",IDC_UNICODE2DEC,
"Button",BS_AUTORADIOBUTTON,153,107,160,10
CONTROL "Mapping DEC special Graphics to Unicode",IDC_DEC2UNICODE,
"Button",BS_AUTORADIOBUTTON,153,162,161,10
CONTROL "Box-drawing character (U+2500-U+257F)",IDC_DEC2UNICODE_BOXDRAWING,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,165,122,151,10
CONTROL "Punctuation, Block Elements, Shade",IDC_DEC2UNICODE_PUNCTUATION,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,165,135,132,10
CONTROL "Middle dots (U+00B7,U+2024,U+2219)",IDC_DEC2UNICODE_MIDDLEDOT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,165,149,141,10
END


Expand Down Expand Up @@ -90,8 +101,12 @@ BEGIN
VERTGUIDE, 22
VERTGUIDE, 71
VERTGUIDE, 110
VERTGUIDE, 141
VERTGUIDE, 153
VERTGUIDE, 165
VERTGUIDE, 198
BOTTOMMARGIN, 168
BOTTOMMARGIN, 205
HORZGUIDE, 193
END
END
#endif // APSTUDIO_INVOKED
Expand Down
7 changes: 6 additions & 1 deletion teraterm/teraterm/coding_pp_res.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
#define IDC_AMBIGUOUS_WIDTH_COMBO 2607
#define IDC_EMOJI_WIDTH_CHECK 2608
#define IDC_EMOJI_WIDTH_COMBO 2609
#define IDC_UNICODE2DEC 2612
#define IDC_DEC2UNICODE 2613
#define IDC_DEC2UNICODE_BOXDRAWING 2614
#define IDC_DEC2UNICODE_PUNCTUATION 2615
#define IDC_DEC2UNICODE_MIDDLEDOT 2616

// Next default values for new objects
//
Expand All @@ -27,7 +32,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 115
#define _APS_NEXT_COMMAND_VALUE 52031
#define _APS_NEXT_CONTROL_VALUE 2609
#define _APS_NEXT_CONTROL_VALUE 2615
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
45 changes: 36 additions & 9 deletions teraterm/teraterm/vtterm.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,26 +737,53 @@ static void PutU32NoLog(unsigned int code)
{
int LineEnd;
TCharAttr CharAttrTmp;
BOOL dec_special = FALSE;
BOOL dec_special;
int r;

CharAttrTmp = CharAttr;
LastPutCharacter = code;

dec_special = FALSE;
if (code <= 0xff) {
dec_special = CharSetIsSpecial(charset_data, code);
}

// UnicodeからDEC特殊文字へのマッピング
if (dec_special == FALSE && ts.UnicodeDecSpMapping) {
unsigned short cset;
cset = UTF32ToDecSp(code);
if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) {
dec_special = TRUE;
code = cset & 0xff;
if (ts.Dec2Unicode) {
if (dec_special) {
// DEC特殊文字からUnicodeへのマッピング
if (ts.Dec2Unicode) {
// 0x60から0x7e を Unicode に割り振る
static const char16_t dec2unicode[] = {
0x25c6, 0x2592, 0x2409, 0x240c, // 0x60 -
0x240d, 0x240a, 0x00b0, 0x00b1,
0x2424, 0x240b, 0x2518, 0x2510,
0x250c, 0x2514, 0x253c, 0x23ba, // 0x6c - 0x6f

0x23bb, 0x2500, 0x23bc, 0x23bd, // 0x70 -
0x251c, 0x2524, 0x2534, 0x252c,
0x2502, 0x2264, 0x2265, 0x03c0,
0x2260, 0x00a3, 0x00b7, // 0x7c - 0x7e
};
code = code & 0x7F;
if (0x60 <= code && code <= 0x7e) {
code = dec2unicode[code - 0x60];
dec_special = FALSE;
}
}
}
}
else {
// UnicodeからDEC特殊文字へのマッピング
if (dec_special == FALSE && ts.UnicodeDecSpMapping) {
unsigned short cset;
cset = UTF32ToDecSp(code);
if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) {
dec_special = TRUE;
code = cset & 0xff;
}
}
}

CharAttrTmp = CharAttr;
if (dec_special) {
CharAttrTmp.Attr |= AttrSpecial;
}
Expand Down
2 changes: 2 additions & 0 deletions teraterm/ttpset/ttset.c
Original file line number Diff line number Diff line change
Expand Up @@ -2076,6 +2076,8 @@ void PASCAL _ReadIniFile(const wchar_t *FName, PTTSet ts)
// 通知音
ts->NotifySound = GetOnOff(Section, "NotifySound", FName, TRUE);

ts->Dec2Unicode = FALSE;

// Experimental
ts->ExperimentalTreeProprtySheetEnable = GetOnOff("Experimental", "TreeProprtySheet", FName, FALSE);
ts->ExperimentalDontUseFontDialog = GetOnOff("Experimental", "DontUseFontDialog", FName, FALSE);
Expand Down

0 comments on commit 9bccc07

Please sign in to comment.