Tera Termの個人的な作業用リポジトリ
Revisão | b94ee4637d9d99df57a894b82715a6cf58e7c0dd (tree) |
---|---|
Hora | 2020-11-30 00:26:40 |
Autor | zmatsuo <zmatsuo@user...> |
Commiter | zmatsuo |
[ファイル]/[印刷]からの印刷をUnicodeに対応した
- 文字描画関数 DrawStrW(), DrawStrA() を vtdisp.c に追加
- DispStr(), PrnOutText() 内で描画時にキリル文字変換を行っていたのを削除
git-svn-id: svn+ssh://svn.osdn.net/svnroot/ttssh2/trunk@9040 f5f01b69-1e22-0410-acbf-894ab4bd6246
@@ -118,6 +118,7 @@ static int SaveBuffY; | ||
118 | 118 | static int CodePage = 932; |
119 | 119 | |
120 | 120 | static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd); |
121 | +static void BuffDrawLineIPrn(int SY, int IStart, int IEnd); | |
121 | 122 | |
122 | 123 | static void BuffSetChar2(buff_char_t *buff, char32_t u32, char property, BOOL half_width, char emoji) |
123 | 124 | { |
@@ -2030,8 +2031,8 @@ void BuffPrint(BOOL ScrollRegion) | ||
2030 | 2031 | { |
2031 | 2032 | int Id; |
2032 | 2033 | POINT PrintStart, PrintEnd; |
2033 | - TCharAttr CurAttr, TempAttr; | |
2034 | - int i, j, count; | |
2034 | + TCharAttr TempAttr; | |
2035 | + int j; | |
2035 | 2036 | int IStart, IEnd; |
2036 | 2037 | LONG TmpPtr; |
2037 | 2038 |
@@ -2091,58 +2092,7 @@ void BuffPrint(BOOL ScrollRegion) | ||
2091 | 2092 | IEnd = NumOfColumns - 1; |
2092 | 2093 | } |
2093 | 2094 | |
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); | |
2146 | 2096 | PrnNewLine(); |
2147 | 2097 | TmpPtr = NextLinePtr(TmpPtr); |
2148 | 2098 | } |
@@ -3083,16 +3033,21 @@ static BOOL CheckSelect(int x, int y) | ||
3083 | 3033 | /** |
3084 | 3034 | * 1行描画 |
3085 | 3035 | * |
3086 | - * @param DrawX,Y Clint領域描画位置(pixel) | |
3087 | 3036 | * @param SY スクリーン上の位置(Charactor) !バッファ上の位置 |
3088 | 3037 | * PageStart + YStart など |
3089 | 3038 | * @param IStart,IEnd スクリーン上の位置(Charactor) |
3090 | 3039 | * 指定した間を描画する |
3040 | + * @param disp_strW() wchar_t 文字を描画用関数 (Unicode用) | |
3041 | + * @param disp_strA() char 文字を描画用関数 (ANSI用) | |
3042 | + * @param disp_setup_dc() アトリビュート設定関数 | |
3043 | + * @param data disp_strW(A)() に渡されるデータ | |
3091 | 3044 | */ |
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) | |
3093 | 3050 | { |
3094 | - int X = DrawX; | |
3095 | - int Y = DrawY; | |
3096 | 3051 | const LONG TmpPtr = GetLinePtr(SY); |
3097 | 3052 | int istart = IStart; |
3098 | 3053 | char bufA[TermWidthMax+1]; |
@@ -3108,23 +3063,6 @@ static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd) | ||
3108 | 3063 | #if 0 |
3109 | 3064 | OutputDebugPrintf("BuffDrawLineI(%d,%d, %d,%d-%d)\n", DrawX, DrawY, SY, IStart, IEnd); |
3110 | 3065 | #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 | - } | |
3128 | 3066 | if (IEnd >= NumOfColumns) { |
3129 | 3067 | IEnd = NumOfColumns - 1; |
3130 | 3068 | } |
@@ -3140,7 +3078,8 @@ static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd) | ||
3140 | 3078 | // 最初の1文字目 |
3141 | 3079 | int ptr = TmpPtr + istart + count; |
3142 | 3080 | if (IsBuffPadding(b)) { |
3143 | - // 最初に表示しようとした文字が全角の右だった場合 | |
3081 | + // 最初に表示しようとした文字が2cellの右側だった場合 | |
3082 | + // assert(FALSE); | |
3144 | 3083 | ptr--; |
3145 | 3084 | } |
3146 | 3085 | CurAttr.Attr = CodeBuffW[ptr].attr & ~ AttrKanji; |
@@ -3152,7 +3091,7 @@ static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd) | ||
3152 | 3091 | } |
3153 | 3092 | |
3154 | 3093 | if (IsBuffPadding(b)) { |
3155 | - // 全角の次の文字,処理不要 | |
3094 | + // 2cellの次の文字,処理不要 | |
3156 | 3095 | } else { |
3157 | 3096 | if (count == 0) { |
3158 | 3097 | // 最初の1文字目 |
@@ -3235,12 +3174,12 @@ static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd) | ||
3235 | 3174 | OutputDebugPrintfW(L"W[%d] '%s'\n", lenW, bufW); |
3236 | 3175 | #endif |
3237 | 3176 | |
3238 | - DispSetupDC(CurAttr, CurSelected); | |
3177 | + disp_setup_dc(CurAttr, CurSelected); | |
3239 | 3178 | if (UseUnicodeApi) { |
3240 | - DispStrW(bufW, bufWW, lenW, Y, &X); | |
3179 | + disp_strW(bufW, bufWW, lenW, data); | |
3241 | 3180 | } |
3242 | 3181 | else { |
3243 | - DispStr(bufA, lenA, Y, &X); | |
3182 | + disp_strA(bufA, lenA, data); | |
3244 | 3183 | } |
3245 | 3184 | |
3246 | 3185 | lenA = 0; |
@@ -3254,6 +3193,89 @@ static void BuffDrawLineI(int DrawX, int DrawY, int SY, int IStart, int IEnd) | ||
3254 | 3193 | } |
3255 | 3194 | } |
3256 | 3195 | |
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 | + | |
3257 | 3279 | void BuffUpdateRect |
3258 | 3280 | (int XStart, int YStart, int XEnd, int YEnd) |
3259 | 3281 | // Display text in a rectangular region in the screen |
@@ -5279,7 +5301,7 @@ int BuffGetAnyLineDataW(int offset_y, wchar_t *buf, size_t bufsize) | ||
5279 | 5301 | return -1; |
5280 | 5302 | |
5281 | 5303 | memset(buf, 0, bufsize * sizeof(wchar_t)); |
5282 | - copysize = min(NumOfColumns, bufsize - 1); | |
5304 | + copysize = min((size_t)NumOfColumns, bufsize - 1); | |
5283 | 5305 | Ptr = GetLinePtr(offset_y); |
5284 | 5306 | b = &CodeBuffW[Ptr]; |
5285 | 5307 | idx = 0; |
@@ -38,7 +38,7 @@ | ||
38 | 38 | #include "commlib.h" |
39 | 39 | #include "ttcommon.h" |
40 | 40 | #include "ttlib.h" |
41 | -//#include "win16api.h" | |
41 | +#include "vtdisp.h" | |
42 | 42 | |
43 | 43 | #include "tt_res.h" |
44 | 44 | #include "tmfc.h" |
@@ -58,7 +58,6 @@ static int PrnFW, PrnFH; | ||
58 | 58 | static RECT Margin; |
59 | 59 | static COLORREF White, Black; |
60 | 60 | static int PrnX, PrnY; |
61 | -static int PrnDx[256]; | |
62 | 61 | static TCharAttr PrnAttr; |
63 | 62 | |
64 | 63 | static BOOL Printing = FALSE; |
@@ -73,6 +72,8 @@ static int PrnBuffCount = 0; | ||
73 | 72 | static CPrnAbortDlg *PrnAbortDlg; |
74 | 73 | static HWND HPrnAbortDlg; |
75 | 74 | |
75 | +static void PrnSetAttr(TCharAttr Attr); | |
76 | + | |
76 | 77 | /* Print Abortion Call Back Function */ |
77 | 78 | static BOOL CALLBACK PrnAbortProc(HDC PDC, int Code) |
78 | 79 | { |
@@ -204,13 +205,7 @@ int VTPrintInit(int PrnFlag) | ||
204 | 205 | TEXTMETRIC Metrics; |
205 | 206 | POINT PPI, PPI2; |
206 | 207 | HDC DC; |
207 | - int i; | |
208 | - TCharAttr TempAttr = { | |
209 | - AttrDefault, | |
210 | - AttrDefault, | |
211 | - AttrDefaultFG, | |
212 | - AttrDefaultBG | |
213 | - }; | |
208 | + TCharAttr TempAttr = DefCharAttr; | |
214 | 209 | LOGFONTA Prnlf; |
215 | 210 | |
216 | 211 | Sel = (PrnFlag & IdPrnSelectedText)!=0; |
@@ -327,9 +322,6 @@ int VTPrintInit(int PrnFlag) | ||
327 | 322 | |
328 | 323 | Black = RGB(0,0,0); |
329 | 324 | White = RGB(255,255,255); |
330 | - for (i = 0 ; i <= 255 ; i++) { | |
331 | - PrnDx[i] = PrnFW; | |
332 | - } | |
333 | 325 | PrnSetAttr(TempAttr); |
334 | 326 | |
335 | 327 | PrnY = Margin.top; |
@@ -349,7 +341,7 @@ int VTPrintInit(int PrnFlag) | ||
349 | 341 | } |
350 | 342 | } |
351 | 343 | |
352 | -void PrnSetAttr(TCharAttr Attr) | |
344 | +static void PrnSetAttr(TCharAttr Attr) | |
353 | 345 | // Set text attribute of printing |
354 | 346 | // |
355 | 347 | { |
@@ -366,79 +358,51 @@ void PrnSetAttr(TCharAttr Attr) | ||
366 | 358 | } |
367 | 359 | } |
368 | 360 | |
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) | |
373 | 362 | { |
374 | - int i; | |
375 | - RECT RText; | |
376 | - PCHAR Ptr, Ptr1, Ptr2; | |
377 | - char Buff2[256]; | |
363 | + (void)reverse; | |
364 | + PrnSetAttr(Attr); | |
365 | +} | |
378 | 366 | |
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; | |
384 | 378 | } |
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; | |
396 | 385 | } |
397 | 386 | |
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 | +} | |
431 | 389 | |
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 | + } | |
441 | 404 | |
405 | + DrawStrW(PrintDC, NULL, StrW, WidthInfo, Count, PrnFW, PrnFH, PrnY, &PrnX); | |
442 | 406 | } |
443 | 407 | |
444 | 408 | void PrnNewLine() |
@@ -548,7 +512,7 @@ static void PrintFile(void) | ||
548 | 512 | } |
549 | 513 | } while ((c>0) && (! CRFlag)); |
550 | 514 | if (i>0) { |
551 | - PrnOutText(Buff, i); | |
515 | + PrnOutText(Buff, i, NULL); | |
552 | 516 | } |
553 | 517 | if (CRFlag) { |
554 | 518 | PrnX = Margin.left; |
@@ -47,8 +47,9 @@ void PrnStop(); | ||
47 | 47 | #define IdPrnFile 8 |
48 | 48 | |
49 | 49 | 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); | |
52 | 53 | void PrnNewLine(); |
53 | 54 | void VTPrintEnd(); |
54 | 55 |
@@ -61,4 +62,3 @@ void WriteToPrnFile(BYTE b, BOOL Write); | ||
61 | 62 | #ifdef __cplusplus |
62 | 63 | } |
63 | 64 | #endif |
64 | - |
@@ -46,6 +46,7 @@ | ||
46 | 46 | #include "vtdisp.h" |
47 | 47 | |
48 | 48 | #define CurWidth 2 |
49 | +// #define DRAW_RED_BOX 1 | |
49 | 50 | |
50 | 51 | static const BYTE DefaultColorTable[256][3] = { |
51 | 52 | { 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; | ||
107 | 108 | static int WinWidthOld, WinHeightOld; |
108 | 109 | static HBRUSH Background; |
109 | 110 | static COLORREF ANSIColor[256]; |
110 | -static int Dx[TermWidthMax]; | |
111 | 111 | |
112 | 112 | // caret variables |
113 | 113 | static int CaretStatus; |
@@ -1963,9 +1963,6 @@ void ChangeFont() | ||
1963 | 1963 | VTFont[AttrSpecial | AttrBold] = VTFont[AttrSpecial]; |
1964 | 1964 | VTFont[AttrSpecial | AttrBold | AttrUnder] = VTFont[AttrSpecial | AttrUnder]; |
1965 | 1965 | } |
1966 | - | |
1967 | - for (i = 0 ; i < TermWidthMax; i++) | |
1968 | - Dx[i] = FontWidth; | |
1969 | 1966 | } |
1970 | 1967 | |
1971 | 1968 | void ResetIME() |
@@ -2716,185 +2713,191 @@ static void DrawTextBGImage(HDC hdcBGBuffer, int X, int Y, int width, int height | ||
2716 | 2713 | } |
2717 | 2714 | } |
2718 | 2715 | |
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 | +} | |
2731 | 2734 | #endif |
2732 | 2735 | |
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; | |
2741 | 2745 | |
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 | + } | |
2747 | 2749 | |
2748 | - if(!draw_bg_enable) | |
2749 | - { | |
2750 | + // テキスト描画領域 | |
2751 | + width = Count * font_width; | |
2752 | + height = font_height; | |
2753 | + if (BGDC == NULL) { | |
2750 | 2754 | 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]); | |
2759 | 2758 | } |
2760 | -#ifdef ALPHABLEND_TYPE2 | |
2761 | 2759 | else { |
2762 | 2760 | 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); | |
2768 | 2765 | |
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)); | |
2773 | 2770 | |
2774 | 2771 | // 文字の背景を描画 |
2775 | - DrawTextBGImage(hdcBGBuffer, *X, Y, width, height); | |
2772 | + DrawTextBGImage(BGDC, *X, Y, width, height); | |
2776 | 2773 | |
2777 | 2774 | // 文字を描画 |
2778 | 2775 | eto_options = ETO_CLIPPED; |
2779 | - if(BGReverseText == TRUE && BGReverseTextAlpha < 255) { | |
2776 | + if (BGReverseText == TRUE && BGReverseTextAlpha < 255) { | |
2780 | 2777 | eto_options |= ETO_OPAQUE; |
2781 | 2778 | } |
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]); | |
2783 | 2780 | |
2784 | 2781 | // Windowに貼り付け |
2785 | - BitBlt(VTDC,*X,Y,width,height,hdcBGBuffer,0,0,SRCCOPY); | |
2782 | + BitBlt(DC, *X, Y, width, height, BGDC, 0, 0, SRCCOPY); | |
2786 | 2783 | |
2787 | - SelectObject(hdcBGBuffer,hPrevFont); | |
2784 | + SelectObject(BGDC, hPrevFont); | |
2788 | 2785 | } |
2789 | -#endif | |
2790 | - | |
2791 | - *X += Count*FontWidth; | |
2792 | 2786 | |
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); | |
2796 | 2789 | #endif |
2790 | + | |
2791 | + *X += width; | |
2797 | 2792 | } |
2798 | 2793 | |
2799 | 2794 | /** |
2800 | - * DispStr() の wchar_t版 | |
2795 | + * 1行描画 Unicode | |
2801 | 2796 | * Windows 95 にも ExtTextOutW() は存在するが |
2802 | 2797 | * 動作が異なるようだ |
2798 | + * TODO 文字間に対応していない? | |
2803 | 2799 | */ |
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) | |
2805 | 2802 | { |
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]; | |
2824 | 2804 | int HalfCharCount = 0; |
2825 | 2805 | int i; |
2826 | - for(i=0; i<Count; i++) { | |
2806 | + int width; | |
2807 | + int height; | |
2808 | + | |
2809 | + for (i = 0; i < Count; i++) { | |
2827 | 2810 | if (WidthInfo[i] == 'H') { |
2828 | 2811 | 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') { | |
2832 | 2815 | if (i == 0) { |
2833 | - Dx2[i] = 0; | |
2834 | - } else { | |
2835 | - Dx2[i] = Dx2[i-1]; | |
2836 | - Dx2[i-1] = 0; | |
2816 | + Dx[i] = 0; | |
2837 | 2817 | } |
2838 | - } else { | |
2818 | + else { | |
2819 | + Dx[i] = Dx[i - 1]; | |
2820 | + Dx[i - 1] = 0; | |
2821 | + } | |
2822 | + } | |
2823 | + else { | |
2839 | 2824 | HalfCharCount += 2; |
2840 | - Dx2[i] = FontWidth * 2; | |
2841 | - dx3 += 2; | |
2825 | + Dx[i] = font_width * 2; | |
2842 | 2826 | } |
2843 | 2827 | } |
2844 | 2828 | |
2845 | - if(!draw_bg_enable) | |
2846 | - { | |
2829 | + // テキスト描画領域 | |
2830 | + width = HalfCharCount * font_width; | |
2831 | + height = font_height; | |
2832 | + if (BGDC == NULL) { | |
2847 | 2833 | 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]); | |
2862 | 2837 | } |
2863 | -#ifdef ALPHABLEND_TYPE2 | |
2864 | 2838 | else { |
2865 | 2839 | 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); | |
2871 | 2844 | |
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)); | |
2876 | 2849 | |
2877 | 2850 | // 文字の背景を描画 |
2878 | - DrawTextBGImage(hdcBGBuffer, *X, Y, width, height); | |
2851 | + DrawTextBGImage(BGDC, *X, Y, width, height); | |
2879 | 2852 | |
2880 | 2853 | // 文字を描画 |
2881 | 2854 | eto_options = ETO_CLIPPED; |
2882 | - if(BGReverseText == TRUE && BGReverseTextAlpha < 255) { | |
2855 | + if (BGReverseText == TRUE && BGReverseTextAlpha < 255) { | |
2883 | 2856 | eto_options |= ETO_OPAQUE; |
2884 | 2857 | } |
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]); | |
2889 | 2859 | |
2890 | 2860 | // Windowに貼り付け |
2891 | - BitBlt(VTDC,*X,Y,width,height,hdcBGBuffer,0,0,SRCCOPY); | |
2861 | + BitBlt(DC, *X, Y, width, height, BGDC, 0, 0, SRCCOPY); | |
2892 | 2862 | |
2893 | - SelectObject(hdcBGBuffer,hPrevFont); | |
2863 | + SelectObject(BGDC, hPrevFont); | |
2894 | 2864 | } |
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; | |
2895 | 2886 | #endif |
2887 | + DrawStrA(VTDC, BGDC, Buff, Count, FontWidth, FontHeight, Y, X); | |
2888 | +} | |
2896 | 2889 | |
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); | |
2898 | 2901 | } |
2899 | 2902 | |
2900 | 2903 | void DispEraseCurToEnd(int YEnd) |
@@ -82,7 +82,7 @@ void DispChangeWin(); | ||
82 | 82 | void DispInitDC(); |
83 | 83 | void DispReleaseDC(); |
84 | 84 | 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); | |
86 | 86 | void DispStrW(const wchar_t *StrW, const char *WidthInfo, int Count, int Y, int* X); |
87 | 87 | void DispEraseCurToEnd(int YEnd); |
88 | 88 | void DispEraseHomeToCur(int YHome); |
@@ -120,6 +120,10 @@ void DispGetWindowSize(int *width, int *height, BOOL client); | ||
120 | 120 | void DispGetRootWinSize(int *x, int *y, BOOL inPixels); |
121 | 121 | int DispFindClosestColor(int red, int green, int blue); |
122 | 122 | 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); | |
123 | 127 | |
124 | 128 | extern int WinWidth, WinHeight; |
125 | 129 | extern HFONT VTFont[AttrFontMask+1]; |