• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Tera Termの個人的な作業用リポジトリ


Commit MetaInfo

Revisãob94ee4637d9d99df57a894b82715a6cf58e7c0dd (tree)
Hora2020-11-30 00:26:40
Autorzmatsuo <zmatsuo@user...>
Commiterzmatsuo

Mensagem de Log

[ファイル]/[印刷]からの印刷をUnicodeに対応した

- 文字描画関数 DrawStrW(), DrawStrA() を vtdisp.c に追加

- 画面描画、印刷から利用
- vtwinで背景付きのとき描画が乱れていたのを修正

- DispStr(), PrnOutText() 内で描画時にキリル文字変換を行っていたのを削除

- RussConvStr()
- 従来も無効化していた
- 内部バッファに文字をUnicodeで保存したときに、表示に適したANSI文字コードに変換して保存している

git-svn-id: svn+ssh://svn.osdn.net/svnroot/ttssh2/trunk@9040 f5f01b69-1e22-0410-acbf-894ab4bd6246

Mudança Sumário

Diff

--- a/teraterm/teraterm/buffer.c
+++ b/teraterm/teraterm/buffer.c
@@ -118,6 +118,7 @@ static int SaveBuffY;
118118 static int CodePage = 932;
119119
120120 static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd);
121+static void BuffDrawLineIPrn(int SY, int IStart, int IEnd);
121122
122123 static void BuffSetChar2(buff_char_t *buff, char32_t u32, char property, BOOL half_width, char emoji)
123124 {
@@ -2030,8 +2031,8 @@ void BuffPrint(BOOL ScrollRegion)
20302031 {
20312032 int Id;
20322033 POINT PrintStart, PrintEnd;
2033- TCharAttr CurAttr, TempAttr;
2034- int i, j, count;
2034+ TCharAttr TempAttr;
2035+ int j;
20352036 int IStart, IEnd;
20362037 LONG TmpPtr;
20372038
@@ -2091,58 +2092,7 @@ void BuffPrint(BOOL ScrollRegion)
20912092 IEnd = NumOfColumns - 1;
20922093 }
20932094
2094- while ((IEnd>=IStart) &&
2095- (CodeBuffW[TmpPtr+IEnd].u32 == 0x20) &&
2096- (CodeBuffW[TmpPtr+IEnd].attr==AttrDefault) &&
2097- (CodeBuffW[TmpPtr+IEnd].attr2==AttrDefault)) {
2098- IEnd--;
2099- }
2100-
2101- i = IStart;
2102- while (i <= IEnd) {
2103- CurAttr.Attr = CodeBuffW[TmpPtr+i].attr & ~ AttrKanji;
2104- CurAttr.Attr2 = CodeBuffW[TmpPtr+i].attr2;
2105- CurAttr.Fore = CodeBuffW[TmpPtr+i].fg;
2106- CurAttr.Back = CodeBuffW[TmpPtr+i].bg;
2107-
2108- count = 1;
2109- while ((i+count <= IEnd) &&
2110- (CurAttr.Attr == (CodeBuffW[TmpPtr+i+count].attr & ~ AttrKanji)) &&
2111- (CurAttr.Attr2 == CodeBuffW[TmpPtr+i+count].attr2) &&
2112- (CurAttr.Fore == CodeBuffW[TmpPtr+i].fg) &&
2113- (CurAttr.Back == CodeBuffW[TmpPtr+i].bg) ||
2114- (i+count<NumOfColumns) &&
2115- ((CodeBuffW[TmpPtr+i+count-1].attr & AttrKanji) != 0)) {
2116- count++;
2117- }
2118-
2119- if (TCharAttrCmp(CurAttr, TempAttr) != 0) {
2120- PrnSetAttr(CurAttr);
2121- TempAttr = CurAttr;
2122- }
2123-
2124- // TODO とりあえず ANSI で実装
2125- {
2126- char bufA[TermWidthMax+1];
2127- int k;
2128- char *p = bufA;
2129- const buff_char_t *b = &CodeBuffW[TmpPtr + i];
2130-
2131- for (k = 0; k < count; b++,k++) {
2132- unsigned short c;
2133- if (IsBuffPadding(b)) {
2134- continue;
2135- }
2136- c = b->ansi_char;
2137- *p++ = (c & 0xff);
2138- if (c >= 0x100) {
2139- *p++ = ((c >> 8) & 0xff);
2140- }
2141- }
2142- PrnOutText(bufA, count);
2143- i = i+count;
2144- }
2145- }
2095+ BuffDrawLineIPrn(j, IStart, IEnd);
21462096 PrnNewLine();
21472097 TmpPtr = NextLinePtr(TmpPtr);
21482098 }
@@ -3083,16 +3033,21 @@ static BOOL CheckSelect(int x, int y)
30833033 /**
30843034 * 1行描画
30853035 *
3086- * @param DrawX,Y Clint領域描画位置(pixel)
30873036 * @param SY スクリーン上の位置(Charactor) !バッファ上の位置
30883037 * PageStart + YStart など
30893038 * @param IStart,IEnd スクリーン上の位置(Charactor)
30903039 * 指定した間を描画する
3040+ * @param disp_strW() wchar_t 文字を描画用関数 (Unicode用)
3041+ * @param disp_strA() char 文字を描画用関数 (ANSI用)
3042+ * @param disp_setup_dc() アトリビュート設定関数
3043+ * @param data disp_strW(A)() に渡されるデータ
30913044 */
3092-static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd)
3045+void BuffGetDrawInfoW(int SY, int IStart, int IEnd,
3046+ void (*disp_strW)(const wchar_t *bufW, const char *width_info, int count, void *data),
3047+ void (*disp_strA)(const char *buf, int count, void *data),
3048+ void (*disp_setup_dc)(TCharAttr Attr, BOOL Reverse),
3049+ void *data)
30933050 {
3094- int X = DrawX;
3095- int Y = DrawY;
30963051 const LONG TmpPtr = GetLinePtr(SY);
30973052 int istart = IStart;
30983053 char bufA[TermWidthMax+1];
@@ -3108,23 +3063,6 @@ static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd)
31083063 #if 0
31093064 OutputDebugPrintf("BuffDrawLineI(%d,%d, %d,%d-%d)\n", DrawX, DrawY, SY, IStart, IEnd);
31103065 #endif
3111- {
3112- // カーソル位置、表示開始位置から描画位置がわかるはず
3113- int X2 = IStart;
3114- int Y2 = SY - PageStart;
3115- if (! IsLineVisible(&X2, &Y2)) {
3116- // 描画不要行
3117- //assert(FALSE);
3118- return;
3119- }
3120- if (X != -1 && Y != -1) {
3121- assert(X == X2 && Y == Y2);
3122- }
3123- else {
3124- X = X2;
3125- Y = Y2;
3126- }
3127- }
31283066 if (IEnd >= NumOfColumns) {
31293067 IEnd = NumOfColumns - 1;
31303068 }
@@ -3140,7 +3078,8 @@ static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd)
31403078 // 最初の1文字目
31413079 int ptr = TmpPtr + istart + count;
31423080 if (IsBuffPadding(b)) {
3143- // 最初に表示しようとした文字が全角の右だった場合
3081+ // 最初に表示しようとした文字が2cellの右側だった場合
3082+ // assert(FALSE);
31443083 ptr--;
31453084 }
31463085 CurAttr.Attr = CodeBuffW[ptr].attr & ~ AttrKanji;
@@ -3152,7 +3091,7 @@ static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd)
31523091 }
31533092
31543093 if (IsBuffPadding(b)) {
3155- // 全角の次の文字,処理不要
3094+ // 2cellの次の文字,処理不要
31563095 } else {
31573096 if (count == 0) {
31583097 // 最初の1文字目
@@ -3235,12 +3174,12 @@ static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd)
32353174 OutputDebugPrintfW(L"W[%d] '%s'\n", lenW, bufW);
32363175 #endif
32373176
3238- DispSetupDC(CurAttr, CurSelected);
3177+ disp_setup_dc(CurAttr, CurSelected);
32393178 if (UseUnicodeApi) {
3240- DispStrW(bufW, bufWW, lenW, Y, &X);
3179+ disp_strW(bufW, bufWW, lenW, data);
32413180 }
32423181 else {
3243- DispStr(bufA, lenA, Y, &X);
3182+ disp_strA(bufA, lenA, data);
32443183 }
32453184
32463185 lenA = 0;
@@ -3254,6 +3193,89 @@ static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd)
32543193 }
32553194 }
32563195
3196+typedef struct {
3197+ int draw_x;
3198+ int draw_y;
3199+} disp_data_t;
3200+
3201+static void l_disp_strW(const wchar_t *bufW, const char *width_info, int count, void *data_)
3202+{
3203+ disp_data_t *data = (disp_data_t *)data_;
3204+ int x = data->draw_x;
3205+ int y = data->draw_y;
3206+ DispStrW(bufW, width_info, count, y, &x);
3207+ data->draw_x = x;
3208+}
3209+
3210+static void l_disp_strA(const char *buf, int count, void *data_)
3211+{
3212+ disp_data_t *data = (disp_data_t *)data_;
3213+ int x = data->draw_x;
3214+ int y = data->draw_y;
3215+ DispStr(buf, count, y, &x);
3216+ data->draw_x = x;
3217+}
3218+
3219+/**
3220+ * 1行描画 画面用
3221+ *
3222+ * @param DrawX,Y Clint領域描画位置(pixel)
3223+ * @param SY スクリーン上の位置(Charactor) !バッファ上の位置
3224+ * PageStart + YStart など
3225+ * @param IStart,IEnd スクリーン上の位置(Charactor)
3226+ * 指定した間を描画する
3227+ */
3228+static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd)
3229+{
3230+ int X = DrawX;
3231+ int Y = DrawY;
3232+ {
3233+ // カーソル位置、表示開始位置から描画位置がわかるはず
3234+ int X2 = IStart;
3235+ int Y2 = SY - PageStart;
3236+ if (! IsLineVisible(&X2, &Y2)) {
3237+ // 描画不要行
3238+ //assert(FALSE);
3239+ return;
3240+ }
3241+ if (X != -1 && Y != -1) {
3242+ assert(X == X2 && Y == Y2);
3243+ }
3244+ else {
3245+ X = X2;
3246+ Y = Y2;
3247+ }
3248+ }
3249+ if (IEnd >= NumOfColumns) {
3250+ IEnd = NumOfColumns - 1;
3251+ }
3252+
3253+ {
3254+ disp_data_t data;
3255+ data.draw_x = X;
3256+ data.draw_y = Y;
3257+
3258+ BuffGetDrawInfoW(SY, IStart, IEnd, l_disp_strW, l_disp_strA, DispSetupDC, &data);
3259+ }
3260+}
3261+
3262+/**
3263+ * 1行描画 プリンタ用
3264+ *
3265+ * @param SY スクリーン上の位置(Charactor) !バッファ上の位置
3266+ * PageStart + YStart など
3267+ * @param IStart,IEnd スクリーン上の位置(Charactor)
3268+ * 指定した間を描画する
3269+ */
3270+static void BuffDrawLineIPrn(int SY, int IStart, int IEnd)
3271+{
3272+ if (IEnd >= NumOfColumns) {
3273+ IEnd = NumOfColumns - 1;
3274+ }
3275+
3276+ BuffGetDrawInfoW(SY, IStart, IEnd, PrnOutTextW, PrnOutText, PrnSetupDC, NULL);
3277+}
3278+
32573279 void BuffUpdateRect
32583280 (int XStart, int YStart, int XEnd, int YEnd)
32593281 // Display text in a rectangular region in the screen
@@ -5279,7 +5301,7 @@ int BuffGetAnyLineDataW(int offset_y, wchar_t *buf, size_t bufsize)
52795301 return -1;
52805302
52815303 memset(buf, 0, bufsize * sizeof(wchar_t));
5282- copysize = min(NumOfColumns, bufsize - 1);
5304+ copysize = min((size_t)NumOfColumns, bufsize - 1);
52835305 Ptr = GetLinePtr(offset_y);
52845306 b = &CodeBuffW[Ptr];
52855307 idx = 0;
--- a/teraterm/teraterm/teraprn.cpp
+++ b/teraterm/teraterm/teraprn.cpp
@@ -38,7 +38,7 @@
3838 #include "commlib.h"
3939 #include "ttcommon.h"
4040 #include "ttlib.h"
41-//#include "win16api.h"
41+#include "vtdisp.h"
4242
4343 #include "tt_res.h"
4444 #include "tmfc.h"
@@ -58,7 +58,6 @@ static int PrnFW, PrnFH;
5858 static RECT Margin;
5959 static COLORREF White, Black;
6060 static int PrnX, PrnY;
61-static int PrnDx[256];
6261 static TCharAttr PrnAttr;
6362
6463 static BOOL Printing = FALSE;
@@ -73,6 +72,8 @@ static int PrnBuffCount = 0;
7372 static CPrnAbortDlg *PrnAbortDlg;
7473 static HWND HPrnAbortDlg;
7574
75+static void PrnSetAttr(TCharAttr Attr);
76+
7677 /* Print Abortion Call Back Function */
7778 static BOOL CALLBACK PrnAbortProc(HDC PDC, int Code)
7879 {
@@ -204,13 +205,7 @@ int VTPrintInit(int PrnFlag)
204205 TEXTMETRIC Metrics;
205206 POINT PPI, PPI2;
206207 HDC DC;
207- int i;
208- TCharAttr TempAttr = {
209- AttrDefault,
210- AttrDefault,
211- AttrDefaultFG,
212- AttrDefaultBG
213- };
208+ TCharAttr TempAttr = DefCharAttr;
214209 LOGFONTA Prnlf;
215210
216211 Sel = (PrnFlag & IdPrnSelectedText)!=0;
@@ -327,9 +322,6 @@ int VTPrintInit(int PrnFlag)
327322
328323 Black = RGB(0,0,0);
329324 White = RGB(255,255,255);
330- for (i = 0 ; i <= 255 ; i++) {
331- PrnDx[i] = PrnFW;
332- }
333325 PrnSetAttr(TempAttr);
334326
335327 PrnY = Margin.top;
@@ -349,7 +341,7 @@ int VTPrintInit(int PrnFlag)
349341 }
350342 }
351343
352-void PrnSetAttr(TCharAttr Attr)
344+static void PrnSetAttr(TCharAttr Attr)
353345 // Set text attribute of printing
354346 //
355347 {
@@ -366,79 +358,51 @@ void PrnSetAttr(TCharAttr Attr)
366358 }
367359 }
368360
369-void PrnOutText(PCHAR Buff, int Count)
370-// Print out text
371-// Buff: points text buffer
372-// Count: number of characters to be printed
361+void PrnSetupDC(TCharAttr Attr, BOOL reverse)
373362 {
374- int i;
375- RECT RText;
376- PCHAR Ptr, Ptr1, Ptr2;
377- char Buff2[256];
363+ (void)reverse;
364+ PrnSetAttr(Attr);
365+}
378366
379- if (Count<=0) {
380- return;
381- }
382- if (Count>(sizeof(Buff2)-1)) {
383- Count=sizeof(Buff2)-1;
367+/**
368+ * Print out text
369+ * Buff: points text buffer
370+ * Count: number of characters to be printed
371+ */
372+void PrnOutText(const char *StrA, int Count, void *data)
373+{
374+ if (PrnX+PrnFW > Margin.right) {
375+ /* new line */
376+ PrnX = Margin.left;
377+ PrnY = PrnY + PrnFH;
384378 }
385- memcpy(Buff2,Buff,Count);
386- Buff2[Count] = 0;
387- Ptr = Buff2;
388-
389- if (ts.Language==IdRussian) {
390- if (ts.PrnFont[0]==0) {
391- RussConvStr(ts.RussClient,ts.RussFont,Buff2,Count);
392- }
393- else {
394- RussConvStr(ts.RussClient,ts.RussPrint,Buff2,Count);
395- }
379+ if (PrnY+PrnFH > Margin.bottom) {
380+ /* next page */
381+ EndPage(PrintDC);
382+ StartPage(PrintDC);
383+ PrnSetAttr(PrnAttr);
384+ PrnY = Margin.top;
396385 }
397386
398- do {
399- if (PrnX+PrnFW > Margin.right) {
400- /* new line */
401- PrnX = Margin.left;
402- PrnY = PrnY + PrnFH;
403- }
404- if (PrnY+PrnFH > Margin.bottom) {
405- /* next page */
406- EndPage(PrintDC);
407- StartPage(PrintDC);
408- PrnSetAttr(PrnAttr);
409- PrnY = Margin.top;
410- }
411-
412- i = (Margin.right-PrnX) / PrnFW;
413- if (i==0) {
414- i=1;
415- }
416- if (i>Count) {
417- i=Count;
418- }
419-
420- if (i<Count) {
421- Ptr2 = Ptr;
422- do {
423- Ptr1 = Ptr2;
424- Ptr2 = CharNextA(Ptr1);
425- } while ((Ptr2!=NULL) && ((Ptr2-Ptr)<=i));
426- i = Ptr1-Ptr;
427- if (i<=0) {
428- i=1;
429- }
430- }
387+ DrawStrA(PrintDC, NULL, StrA, Count, PrnFW, PrnFH, PrnY, &PrnX);
388+}
431389
432- RText.left = PrnX;
433- RText.right = PrnX + i*PrnFW;
434- RText.top = PrnY;
435- RText.bottom = PrnY+PrnFH;
436- ExtTextOutA(PrintDC,PrnX,PrnY,6,&RText,Ptr,i,&PrnDx[0]);
437- PrnX = RText.right;
438- Count=Count-i;
439- Ptr = Ptr + i;
440- } while (Count>0);
390+void PrnOutTextW(const wchar_t *StrW, const char *WidthInfo, int Count, void *data)
391+{
392+ if (PrnX+PrnFW > Margin.right) {
393+ /* new line */
394+ PrnX = Margin.left;
395+ PrnY = PrnY + PrnFH;
396+ }
397+ if (PrnY+PrnFH > Margin.bottom) {
398+ /* next page */
399+ EndPage(PrintDC);
400+ StartPage(PrintDC);
401+ PrnSetAttr(PrnAttr);
402+ PrnY = Margin.top;
403+ }
441404
405+ DrawStrW(PrintDC, NULL, StrW, WidthInfo, Count, PrnFW, PrnFH, PrnY, &PrnX);
442406 }
443407
444408 void PrnNewLine()
@@ -548,7 +512,7 @@ static void PrintFile(void)
548512 }
549513 } while ((c>0) && (! CRFlag));
550514 if (i>0) {
551- PrnOutText(Buff, i);
515+ PrnOutText(Buff, i, NULL);
552516 }
553517 if (CRFlag) {
554518 PrnX = Margin.left;
--- a/teraterm/teraterm/teraprn.h
+++ b/teraterm/teraterm/teraprn.h
@@ -47,8 +47,9 @@ void PrnStop();
4747 #define IdPrnFile 8
4848
4949 int VTPrintInit(int PrnFlag);
50-void PrnSetAttr(TCharAttr Attr);
51-void PrnOutText(PCHAR Buff, int Count);
50+void PrnSetupDC(TCharAttr Attr, BOOL reverse);
51+void PrnOutText(const char *Buff, int Count, void *data);
52+void PrnOutTextW(const wchar_t *StrW, const char *WidthInfo, int Count, void *data);
5253 void PrnNewLine();
5354 void VTPrintEnd();
5455
@@ -61,4 +62,3 @@ void WriteToPrnFile(BYTE b, BOOL Write);
6162 #ifdef __cplusplus
6263 }
6364 #endif
64-
--- a/teraterm/teraterm/vtdisp.c
+++ b/teraterm/teraterm/vtdisp.c
@@ -46,6 +46,7 @@
4646 #include "vtdisp.h"
4747
4848 #define CurWidth 2
49+// #define DRAW_RED_BOX 1
4950
5051 static const BYTE DefaultColorTable[256][3] = {
5152 { 0, 0, 0}, {255, 0, 0}, { 0,255, 0}, {255,255, 0}, { 0, 0,255}, {255, 0,255}, { 0,255,255}, {255,255,255}, // 0 - 7
@@ -107,7 +108,6 @@ static BOOL SaveWinSize = FALSE;
107108 static int WinWidthOld, WinHeightOld;
108109 static HBRUSH Background;
109110 static COLORREF ANSIColor[256];
110-static int Dx[TermWidthMax];
111111
112112 // caret variables
113113 static int CaretStatus;
@@ -1963,9 +1963,6 @@ void ChangeFont()
19631963 VTFont[AttrSpecial | AttrBold] = VTFont[AttrSpecial];
19641964 VTFont[AttrSpecial | AttrBold | AttrUnder] = VTFont[AttrSpecial | AttrUnder];
19651965 }
1966-
1967- for (i = 0 ; i < TermWidthMax; i++)
1968- Dx[i] = FontWidth;
19691966 }
19701967
19711968 void ResetIME()
@@ -2716,185 +2713,191 @@ static void DrawTextBGImage(HDC hdcBGBuffer, int X, int Y, int width, int height
27162713 }
27172714 }
27182715
2719-// Display a string
2720-// Buff: points the string
2721-// Y: vertical position in window cordinate
2722-// *X: horizontal position
2723-// Return:
2724-// *X: horizontal position shifted by the width of the string
2725-void DispStr(PCHAR Buff, int Count, int Y, int* X)
2726-{
2727-#ifdef ALPHABLEND_TYPE2
2728- const BOOL draw_bg_enable = BGEnable;
2729-#else
2730- const BOOL draw_bg_enable = FALSE;
2716+// draw red box for debug
2717+#if DRAW_RED_BOX
2718+static void DrawRedBox(HDC DC, int sx, int sy, int width, int height)
2719+{
2720+ HPEN red_pen = CreatePen(PS_SOLID, 0, RGB(0xff, 0, 0));
2721+ HGDIOBJ old_pen = SelectObject(DC, red_pen);
2722+ MoveToEx(DC, sx, sy, NULL);
2723+ LineTo(DC, sx + width, sy);
2724+ LineTo(DC, sx + width, sy + height);
2725+ LineTo(DC, sx, sy + height);
2726+ LineTo(DC, sx, sy);
2727+ MoveToEx(DC, sx, sy, NULL);
2728+ LineTo(DC, sx + width, sy + height);
2729+ MoveToEx(DC, sx + width, sy, NULL);
2730+ LineTo(DC, sx, sy + height);
2731+ SelectObject(DC, old_pen);
2732+ DeleteObject(red_pen);
2733+}
27312734 #endif
27322735
2733-#if 0
2734- {
2735- char b[128];
2736- memcpy(b, Buff, Count);
2737- b[Count] = 0;
2738- OutputDebugPrintf("(%d,%d)'%s'\n", *X, Y, b);
2739- }
2740-#endif
2736+/**
2737+ * 1行描画 ANSI
2738+ */
2739+void DrawStrA(HDC DC, HDC BGDC, const char *StrA, int Count, int font_width, int font_height, int Y, int *X)
2740+{
2741+ int Dx[TermWidthMax];
2742+ int i;
2743+ int width;
2744+ int height;
27412745
2742-#if !UNICODE_INTERNAL_BUFF
2743- if ((ts.Language==IdRussian) &&
2744- (ts.RussClient!=ts.RussFont))
2745- RussConvStr(ts.RussClient,ts.RussFont,Buff,Count);
2746-#endif
2746+ for (i = 0; i < Count; i++) {
2747+ Dx[i] = font_width;
2748+ }
27472749
2748- if(!draw_bg_enable)
2749- {
2750+ // テキスト描画領域
2751+ width = Count * font_width;
2752+ height = font_height;
2753+ if (BGDC == NULL) {
27502754 RECT RText;
2751- RText.top = Y;
2752- RText.bottom = Y+FontHeight;
2753- RText.left = *X;
2754- RText.right = *X + Count*FontWidth;
2755-
2756- ExtTextOutA(VTDC,*X+ts.FontDX,Y+ts.FontDY,
2757- ETO_CLIPPED | ETO_OPAQUE,
2758- &RText,Buff,Count,&Dx[0]);
2755+ SetRect(&RText, *X, Y, *X + width, Y + height);
2756+
2757+ ExtTextOutA(DC, *X + ts.FontDX, Y + ts.FontDY, ETO_CLIPPED | ETO_OPAQUE, &RText, StrA, Count, &Dx[0]);
27592758 }
2760-#ifdef ALPHABLEND_TYPE2
27612759 else {
27622760 HFONT hPrevFont;
2763- RECT rect;
2764- int eto_options;
2765- const int width = Count*FontWidth;
2766- const int height = FontHeight;
2767- SetRect(&rect,0,0,width,height);
2761+ RECT rect;
2762+ int eto_options;
2763+
2764+ SetRect(&rect, 0, 0, 0 + width, 0 + height);
27682765
2769- //hdcBGBuffer の属性を設定
2770- hPrevFont = SelectObject(hdcBGBuffer,GetCurrentObject(VTDC,OBJ_FONT));
2771- SetTextColor(hdcBGBuffer,GetTextColor(VTDC));
2772- SetBkColor(hdcBGBuffer,GetBkColor(VTDC));
2766+ // BGDC の属性を設定
2767+ hPrevFont = SelectObject(BGDC, GetCurrentObject(DC, OBJ_FONT));
2768+ SetTextColor(BGDC, GetTextColor(DC));
2769+ SetBkColor(BGDC, GetBkColor(DC));
27732770
27742771 // 文字の背景を描画
2775- DrawTextBGImage(hdcBGBuffer, *X, Y, width, height);
2772+ DrawTextBGImage(BGDC, *X, Y, width, height);
27762773
27772774 // 文字を描画
27782775 eto_options = ETO_CLIPPED;
2779- if(BGReverseText == TRUE && BGReverseTextAlpha < 255) {
2776+ if (BGReverseText == TRUE && BGReverseTextAlpha < 255) {
27802777 eto_options |= ETO_OPAQUE;
27812778 }
2782- ExtTextOutA(hdcBGBuffer,ts.FontDX,ts.FontDY,eto_options,&rect,Buff,Count,&Dx[0]);
2779+ ExtTextOutA(BGDC, ts.FontDX, ts.FontDY, eto_options, &rect, StrA, Count, &Dx[0]);
27832780
27842781 // Windowに貼り付け
2785- BitBlt(VTDC,*X,Y,width,height,hdcBGBuffer,0,0,SRCCOPY);
2782+ BitBlt(DC, *X, Y, width, height, BGDC, 0, 0, SRCCOPY);
27862783
2787- SelectObject(hdcBGBuffer,hPrevFont);
2784+ SelectObject(BGDC, hPrevFont);
27882785 }
2789-#endif
2790-
2791- *X += Count*FontWidth;
27922786
2793-#if !UNICODE_INTERNAL_BUFF
2794- if ((ts.Language==IdRussian) && (ts.RussClient!=ts.RussFont))
2795- RussConvStr(ts.RussFont,ts.RussClient,Buff,Count);
2787+#if DRAW_RED_BOX
2788+ DrawRedBox(DC, *X, Y, width, height);
27962789 #endif
2790+
2791+ *X += width;
27972792 }
27982793
27992794 /**
2800- * DispStr() の wchar_t版
2795+ * 1行描画 Unicode
28012796 * Windows 95 にも ExtTextOutW() は存在するが
28022797 * 動作が異なるようだ
2798+ * TODO 文字間に対応していない?
28032799 */
2804-void DispStrW(const wchar_t *StrW, const char *WidthInfo, int Count, int Y, int* X)
2800+void DrawStrW(HDC DC, HDC BGDC, const wchar_t *StrW, const char *WidthInfo, int Count, int font_width, int font_height,
2801+ int Y, int *X)
28052802 {
2806-#ifdef ALPHABLEND_TYPE2
2807- const BOOL draw_bg_enable = BGEnable;
2808-#else
2809- const BOOL draw_bg_enable = FALSE;
2810-#endif
2811-
2812-#if 0
2813- {
2814- wchar_t b[TermWidthMax];
2815- memcpy(b, StrW, Count*sizeof(wchar_t));
2816- b[Count] = 0;
2817- OutputDebugPrintfW(L"(%d,%d)'%s'\n", *X, Y, b);
2818- OutputDebugPrintfW(L" '%hs'\n", WidthInfo);
2819- }
2820-#endif
2821-
2822- int Dx2[TermWidthMax];
2823- int dx3 = 0;
2803+ int Dx[TermWidthMax];
28242804 int HalfCharCount = 0;
28252805 int i;
2826- for(i=0; i<Count; i++) {
2806+ int width;
2807+ int height;
2808+
2809+ for (i = 0; i < Count; i++) {
28272810 if (WidthInfo[i] == 'H') {
28282811 HalfCharCount++;
2829- dx3++;
2830- Dx2[i] = FontWidth;
2831- } else if (WidthInfo[i] == '0') {
2812+ Dx[i] = font_width;
2813+ }
2814+ else if (WidthInfo[i] == '0') {
28322815 if (i == 0) {
2833- Dx2[i] = 0;
2834- } else {
2835- Dx2[i] = Dx2[i-1];
2836- Dx2[i-1] = 0;
2816+ Dx[i] = 0;
28372817 }
2838- } else {
2818+ else {
2819+ Dx[i] = Dx[i - 1];
2820+ Dx[i - 1] = 0;
2821+ }
2822+ }
2823+ else {
28392824 HalfCharCount += 2;
2840- Dx2[i] = FontWidth * 2;
2841- dx3 += 2;
2825+ Dx[i] = font_width * 2;
28422826 }
28432827 }
28442828
2845- if(!draw_bg_enable)
2846- {
2829+ // テキスト描画領域
2830+ width = HalfCharCount * font_width;
2831+ height = font_height;
2832+ if (BGDC == NULL) {
28472833 RECT RText;
2848- RText.top = Y;
2849- RText.bottom = Y+FontHeight;
2850- RText.left = *X;
2851- RText.right = *X + HalfCharCount * FontWidth;
2852- RText.right = *X + dx3 * FontWidth;
2853-
2854-#if 0
2855- ExtTextOutW(VTDC, *X + ts.FontDX, Y + ts.FontDY,
2856- ETO_CLIPPED | ETO_OPAQUE,
2857- &RText, Buff, Count, &Dx[0]);
2858-#endif
2859- ExtTextOutW(VTDC, *X + ts.FontDX, Y + ts.FontDY,
2860- ETO_CLIPPED | ETO_OPAQUE,
2861- &RText, StrW, Count, &Dx2[0]);
2834+ SetRect(&RText, *X, Y, *X + width, Y + height);
2835+
2836+ ExtTextOutW(DC, *X + ts.FontDX, Y + ts.FontDY, ETO_CLIPPED | ETO_OPAQUE, &RText, StrW, Count, &Dx[0]);
28622837 }
2863-#ifdef ALPHABLEND_TYPE2
28642838 else {
28652839 HFONT hPrevFont;
2866- RECT rect;
2867- int eto_options;
2868- const int width = Count*FontWidth*2;
2869- const int height = FontHeight;
2870- SetRect(&rect,0,0,width,height);
2840+ RECT rect;
2841+ int eto_options;
2842+
2843+ SetRect(&rect, 0, 0, 0 + width, 0 + height);
28712844
2872- //hdcBGBuffer の属性を設定
2873- hPrevFont = SelectObject(hdcBGBuffer,GetCurrentObject(VTDC,OBJ_FONT));
2874- SetTextColor(hdcBGBuffer,GetTextColor(VTDC));
2875- SetBkColor(hdcBGBuffer,GetBkColor(VTDC));
2845+ // BGDC の属性を設定
2846+ hPrevFont = SelectObject(BGDC, GetCurrentObject(DC, OBJ_FONT));
2847+ SetTextColor(BGDC, GetTextColor(DC));
2848+ SetBkColor(BGDC, GetBkColor(DC));
28762849
28772850 // 文字の背景を描画
2878- DrawTextBGImage(hdcBGBuffer, *X, Y, width, height);
2851+ DrawTextBGImage(BGDC, *X, Y, width, height);
28792852
28802853 // 文字を描画
28812854 eto_options = ETO_CLIPPED;
2882- if(BGReverseText == TRUE && BGReverseTextAlpha < 255) {
2855+ if (BGReverseText == TRUE && BGReverseTextAlpha < 255) {
28832856 eto_options |= ETO_OPAQUE;
28842857 }
2885-#if 0
2886- ExtTextOutW(hdcBGBuffer,ts.FontDX,ts.FontDY,eto_options,&rect, StrW,Count,&Dx[0]);
2887-#endif
2888- ExtTextOutW(hdcBGBuffer,ts.FontDX,ts.FontDY,eto_options,&rect, StrW,Count,&Dx2[0]);
2858+ ExtTextOutW(BGDC, ts.FontDX, ts.FontDY, eto_options, &rect, StrW, Count, &Dx[0]);
28892859
28902860 // Windowに貼り付け
2891- BitBlt(VTDC,*X,Y,width,height,hdcBGBuffer,0,0,SRCCOPY);
2861+ BitBlt(DC, *X, Y, width, height, BGDC, 0, 0, SRCCOPY);
28922862
2893- SelectObject(hdcBGBuffer,hPrevFont);
2863+ SelectObject(BGDC, hPrevFont);
28942864 }
2865+
2866+#if DRAW_RED_BOX
2867+ DrawRedBox(DC, *X, Y, width, height);
2868+#endif
2869+
2870+ *X += width;
2871+}
2872+
2873+/**
2874+ * Display a string
2875+ * @param Buff points the string
2876+ * @param Y vertical position in window cordinate
2877+ * @param[in] *X horizontal position
2878+ * @param[out] *X horizontal position shifted by the width of the string
2879+ */
2880+void DispStr(const char *Buff, int Count, int Y, int* X)
2881+{
2882+#ifdef ALPHABLEND_TYPE2
2883+ HDC BGDC = BGEnable ? hdcBGBuffer : NULL;
2884+#else
2885+ HDC BGDC = NULL;
28952886 #endif
2887+ DrawStrA(VTDC, BGDC, Buff, Count, FontWidth, FontHeight, Y, X);
2888+}
28962889
2897- *X += dx3 *FontWidth;
2890+/**
2891+ * DispStr() の wchar_t版
2892+ */
2893+void DispStrW(const wchar_t *StrW, const char *WidthInfo, int Count, int Y, int* X)
2894+{
2895+#ifdef ALPHABLEND_TYPE2
2896+ HDC BGDC = BGEnable ? hdcBGBuffer : NULL;
2897+#else
2898+ HDC BGDC = NULL;
2899+#endif
2900+ DrawStrW(VTDC, BGDC, StrW, WidthInfo, Count, FontWidth, FontHeight, Y, X);
28982901 }
28992902
29002903 void DispEraseCurToEnd(int YEnd)
--- a/teraterm/teraterm/vtdisp.h
+++ b/teraterm/teraterm/vtdisp.h
@@ -82,7 +82,7 @@ void DispChangeWin();
8282 void DispInitDC();
8383 void DispReleaseDC();
8484 void DispSetupDC(TCharAttr Attr, BOOL Reverse);
85-void DispStr(PCHAR Buff, int Count, int Y, int* X);
85+void DispStr(const char *Buff, int Count, int Y, int* X);
8686 void DispStrW(const wchar_t *StrW, const char *WidthInfo, int Count, int Y, int* X);
8787 void DispEraseCurToEnd(int YEnd);
8888 void DispEraseHomeToCur(int YHome);
@@ -120,6 +120,10 @@ void DispGetWindowSize(int *width, int *height, BOOL client);
120120 void DispGetRootWinSize(int *x, int *y, BOOL inPixels);
121121 int DispFindClosestColor(int red, int green, int blue);
122122 void UpdateBGBrush(void);
123+void DrawStrW(HDC DC, HDC BGDC, const wchar_t *StrW, const char *WidthInfo, int Count,
124+ int font_width, int font_height, int Y, int* X);
125+void DrawStrA(HDC DC, HDC BGDC, const char *StrA, int Count,
126+ int font_width, int font_height, int Y, int* X);
123127
124128 extern int WinWidth, WinHeight;
125129 extern HFONT VTFont[AttrFontMask+1];