Tera Termの個人的な作業用リポジトリ
修订版 | 28a2863e3693e0b799d95184efa316b953de7593 (tree) |
---|---|
时间 | 2020-04-26 23:36:09 |
作者 | zmatsuo <zmatsuo@user...> |
Commiter | zmatsuo |
文字情報ポップアップを修正
- Unicode文字が正しく表示されていなかった
- 次の文字コードも表示するようにした
- debugビルド時はデフォルトで使用可能とした
git-svn-id: svn+ssh://svn.osdn.net/svnroot/ttssh2/trunk@8753 f5f01b69-1e22-0410-acbf-894ab4bd6246
@@ -2603,7 +2603,7 @@ static wchar_t *GetWCS(const buff_char_t *b) | ||
2603 | 2603 | p = strW; |
2604 | 2604 | *p++ = b->wc2[0]; |
2605 | 2605 | if (b->wc2[1] != 0) { |
2606 | - *p++ = b->wc2[0]; | |
2606 | + *p++ = b->wc2[1]; | |
2607 | 2607 | } |
2608 | 2608 | for (i=0; i<b->CombinationCharCount16; i++) { |
2609 | 2609 | *p++ = b->pCombinationChars16[i]; |
@@ -5261,7 +5261,7 @@ BOOL BuffCheckMouseOnURL(int Xw, int Yw) | ||
5261 | 5261 | static void awcscat(wchar_t **dest, const wchar_t *add) |
5262 | 5262 | { |
5263 | 5263 | if (*dest == NULL) { |
5264 | - *dest = wcsdup(add); | |
5264 | + *dest = _wcsdup(add); | |
5265 | 5265 | return; |
5266 | 5266 | } |
5267 | 5267 | else { |
@@ -5292,7 +5292,9 @@ wchar_t *BuffGetCharInfo(int Xw, int Yw) | ||
5292 | 5292 | wchar_t *pos_str; |
5293 | 5293 | wchar_t *attr_str; |
5294 | 5294 | wchar_t *ansi_str; |
5295 | - wchar_t *unicode_str; | |
5295 | + wchar_t *unicode_char_str; | |
5296 | + wchar_t *unicode_utf16_str; | |
5297 | + wchar_t *unicode_utf32_str; | |
5296 | 5298 | |
5297 | 5299 | DispConvWinToScreen(Xw, Yw, &X, &ScreenY, &Right); |
5298 | 5300 | Y = PageStart + ScreenY; |
@@ -5307,7 +5309,6 @@ wchar_t *BuffGetCharInfo(int Xw, int Yw) | ||
5307 | 5309 | Y = BuffEnd - 1; |
5308 | 5310 | |
5309 | 5311 | TmpPtr = GetLinePtr(Y); |
5310 | - LockBuffer(); | |
5311 | 5312 | b = &CodeBuffW[TmpPtr+X]; |
5312 | 5313 | |
5313 | 5314 | aswprintf(&pos_str, |
@@ -5315,18 +5316,20 @@ wchar_t *BuffGetCharInfo(int Xw, int Yw) | ||
5315 | 5316 | X, ScreenY, Y, |
5316 | 5317 | Xw, Yw); |
5317 | 5318 | |
5319 | + // アトリビュート | |
5318 | 5320 | { |
5319 | - const unsigned char attr = b->attr; | |
5320 | - wchar_t *attr1_1_str; | |
5321 | + wchar_t *attr1_attr_str; | |
5321 | 5322 | wchar_t *attr1_str; |
5322 | 5323 | wchar_t *attr2_str; |
5324 | + wchar_t *attr2_attr_str; | |
5323 | 5325 | wchar_t *width_property; |
5324 | 5326 | |
5325 | - if (attr == 0) { | |
5326 | - attr1_1_str = _wcsdup(L""); | |
5327 | + if (b->attr == 0) { | |
5328 | + attr1_attr_str = _wcsdup(L""); | |
5327 | 5329 | } else { |
5328 | - aswprintf(&attr1_1_str, | |
5329 | - L"(%S%S%S%S%S%S%S%S)", | |
5330 | + const unsigned char attr = b->attr; | |
5331 | + aswprintf(&attr1_attr_str, | |
5332 | + L"\n (%S%S%S%S%S%S%S%S)", | |
5330 | 5333 | (attr & AttrBold) != 0 ? "AttrBold " : "", |
5331 | 5334 | (attr & AttrUnder) != 0 ? "AttrUnder " : "", |
5332 | 5335 | (attr & AttrSpecial) != 0 ? "AttrSpecial ": "", |
@@ -5337,11 +5340,24 @@ wchar_t *BuffGetCharInfo(int Xw, int Yw) | ||
5337 | 5340 | (attr & AttrKanji) != 0 ? "AttrKanji ": ""); |
5338 | 5341 | } |
5339 | 5342 | |
5343 | + if (b->attr2 == 0) { | |
5344 | + attr2_attr_str = _wcsdup(L""); | |
5345 | + } else { | |
5346 | + const unsigned char attr2 = b->attr2; | |
5347 | + aswprintf(&attr2_attr_str, | |
5348 | + L"\n (%S%S%S)", | |
5349 | + (attr2 & Attr2Fore) != 0 ? "Attr2Fore " : "", | |
5350 | + (attr2 & Attr2Back) != 0 ? "Attr2Back " : "", | |
5351 | + (attr2 & Attr2Protect) != 0 ? "Attr2Protect ": ""); | |
5352 | + } | |
5353 | + | |
5340 | 5354 | aswprintf(&attr1_str, |
5341 | - L"attr 0x%02x%s%s\n" | |
5342 | - L"attr2 0x%02x\n", | |
5343 | - attr, (attr != 0) ? L"\n " : L"", attr1_1_str, | |
5344 | - (unsigned char)CodeBuffW[TmpPtr+X].attr2); | |
5355 | + L"attr 0x%02x%s\n" | |
5356 | + L"attr2 0x%02x%s\n", | |
5357 | + b->attr, attr1_attr_str, | |
5358 | + b->attr2, attr2_attr_str); | |
5359 | + free(attr1_attr_str); | |
5360 | + free(attr2_attr_str); | |
5345 | 5361 | |
5346 | 5362 | width_property = |
5347 | 5363 | b->WidthProperty == 'F' ? L"Fullwidth" : |
@@ -5363,8 +5379,6 @@ wchar_t *BuffGetCharInfo(int Xw, int Yw) | ||
5363 | 5379 | (b->HalfWidth ? L"TRUE" : L"FALSE"), |
5364 | 5380 | (b->Padding ? L"TRUE" : L"FALSE")); |
5365 | 5381 | |
5366 | - free(attr1_1_str); | |
5367 | - | |
5368 | 5382 | attr_str = NULL; |
5369 | 5383 | awcscat(&attr_str, attr1_str); |
5370 | 5384 | awcscat(&attr_str, attr2_str); |
@@ -5372,6 +5386,7 @@ wchar_t *BuffGetCharInfo(int Xw, int Yw) | ||
5372 | 5386 | free(attr2_str); |
5373 | 5387 | } |
5374 | 5388 | |
5389 | + // ANSI | |
5375 | 5390 | { |
5376 | 5391 | unsigned char mb[4]; |
5377 | 5392 | unsigned short c = b->ansi_char; |
@@ -5394,41 +5409,74 @@ wchar_t *BuffGetCharInfo(int Xw, int Yw) | ||
5394 | 5409 | L" 0x%04x\n", mb, c); |
5395 | 5410 | } |
5396 | 5411 | |
5412 | + // Unicode 文字 | |
5397 | 5413 | { |
5398 | 5414 | wchar_t *wcs = GetWCS(b); |
5399 | - wchar_t *codes_ptr; | |
5415 | + aswprintf(&unicode_char_str, | |
5416 | + L"Unicode char:\n" | |
5417 | + L" '%s'\n", wcs); | |
5418 | + free(wcs); | |
5419 | + } | |
5420 | + | |
5421 | + // Unicode UTF-16 文字コード | |
5422 | + { | |
5423 | + wchar_t *codes_ptr = NULL; | |
5424 | + wchar_t *code_str; | |
5400 | 5425 | int i; |
5401 | - size_t codes_len = 20 + 12 * (b->CombinationCharCount16 + 1); | |
5402 | - codes_ptr = malloc(sizeof(wchar_t) * codes_len); | |
5403 | - _snwprintf_s(codes_ptr, codes_len, _TRUNCATE, | |
5404 | - L"unicode:\n" | |
5405 | - L" '%s'\n" | |
5406 | - L" U+%06x", | |
5407 | - wcs, | |
5408 | - b->u32); | |
5409 | - for (i=0; i<b->CombinationCharCount32; i++) { | |
5410 | - wchar_t *code_str; | |
5411 | - aswprintf(&code_str, L" U+%06x", b->pCombinationChars16[i]); | |
5412 | - wcscat_s(codes_ptr, codes_len, L"\n"); | |
5413 | - wcscat_s(codes_ptr, codes_len, code_str); | |
5414 | - free(code_str); | |
5426 | + | |
5427 | + aswprintf(&code_str, | |
5428 | + L"Unicode UTF-16:\n" | |
5429 | + L" 0x%04x\n", | |
5430 | + b->wc2[0]); | |
5431 | + awcscat(&codes_ptr, code_str); | |
5432 | + free(code_str); | |
5433 | + if (b->wc2[1] != 0 ) { | |
5434 | + wchar_t buf[32]; | |
5435 | + swprintf(buf, _countof(buf), L" 0x%04x\n", b->wc2[1]); | |
5436 | + awcscat(&codes_ptr, buf); | |
5415 | 5437 | } |
5416 | - free(wcs); | |
5417 | - unicode_str = codes_ptr; | |
5438 | + for (i=0; i<b->CombinationCharCount16; i++) { | |
5439 | + wchar_t buf[32]; | |
5440 | + swprintf(buf, _countof(buf), L" 0x%04x\n", b->pCombinationChars16[i]); | |
5441 | + awcscat(&codes_ptr, buf); | |
5442 | + } | |
5443 | + unicode_utf16_str = codes_ptr; | |
5418 | 5444 | } |
5419 | 5445 | |
5420 | - UnlockBuffer(); | |
5446 | + // Unicode UTF-32 文字コード | |
5447 | + { | |
5448 | + wchar_t *codes_ptr = NULL; | |
5449 | + wchar_t *code_str; | |
5450 | + int i; | |
5451 | + | |
5452 | + aswprintf(&code_str, | |
5453 | + L"Unicode UTF-32:\n" | |
5454 | + L" U+%06X\n", | |
5455 | + b->u32); | |
5456 | + awcscat(&codes_ptr, code_str); | |
5457 | + free(code_str); | |
5458 | + for (i=0; i<b->CombinationCharCount32; i++) { | |
5459 | + wchar_t buf[32]; | |
5460 | + swprintf(buf, _countof(buf), L" U+%06X\n", b->pCombinationChars32[i]); | |
5461 | + awcscat(&codes_ptr, buf); | |
5462 | + } | |
5463 | + unicode_utf32_str = codes_ptr; | |
5464 | + } | |
5421 | 5465 | |
5422 | 5466 | str_ptr = NULL; |
5423 | 5467 | awcscat(&str_ptr, pos_str); |
5424 | 5468 | awcscat(&str_ptr, attr_str); |
5425 | 5469 | awcscat(&str_ptr, ansi_str); |
5426 | - awcscat(&str_ptr, unicode_str); | |
5470 | + awcscat(&str_ptr, unicode_char_str); | |
5471 | + awcscat(&str_ptr, unicode_utf16_str); | |
5472 | + awcscat(&str_ptr, unicode_utf32_str); | |
5427 | 5473 | free(pos_str); |
5428 | 5474 | free(attr_str); |
5429 | 5475 | free(ansi_str); |
5430 | - free(unicode_str); | |
5431 | - awcscat(&str_ptr, L"\n\nPress shift for sending to clipboard"); | |
5476 | + free(unicode_char_str); | |
5477 | + free(unicode_utf16_str); | |
5478 | + free(unicode_utf32_str); | |
5479 | + awcscat(&str_ptr, L"\nPress shift for sending to clipboard"); | |
5432 | 5480 | return str_ptr; |
5433 | 5481 | } |
5434 | 5482 |
@@ -39,7 +39,11 @@ public: | ||
39 | 39 | BOOL UseUnicodeApi; |
40 | 40 | CUnicodeDebugParam() |
41 | 41 | { |
42 | +#if _DEBUG | |
42 | 43 | CodePopupEnable = TRUE; |
44 | +#else | |
45 | + CodePopupEnable = FALSE; | |
46 | +#endif | |
43 | 47 | CodePopupKey1 = VK_CONTROL; |
44 | 48 | CodePopupKey2 = VK_CONTROL; |
45 | 49 | UseUnicodeApi = FALSE; |