| 80 |
|
|
| 81 |
// save/restore cursor |
// save/restore cursor |
| 82 |
typedef struct { |
typedef struct { |
| 83 |
int CursorX, CursorY; |
int CursorX, CursorY; |
| 84 |
TCharAttr Attr; |
TCharAttr Attr; |
| 85 |
int Glr[2], Gn[4]; // G0-G3, GL & GR |
int Glr[2], Gn[4]; // G0-G3, GL & GR |
| 86 |
BOOL AutoWrapMode; |
BOOL AutoWrapMode; |
| 87 |
BOOL RelativeOrgMode; |
BOOL RelativeOrgMode; |
| 88 |
} TStatusBuff; |
} TStatusBuff; |
| 89 |
typedef TStatusBuff *PStatusBuff; |
typedef TStatusBuff *PStatusBuff; |
| 90 |
|
|
| 112 |
static int ChangeEmu; |
static int ChangeEmu; |
| 113 |
|
|
| 114 |
typedef struct tstack { |
typedef struct tstack { |
| 115 |
char *title; |
char *title; |
| 116 |
struct tstack *next; |
struct tstack *next; |
| 117 |
} TStack; |
} TStack; |
| 118 |
typedef TStack *PTStack; |
typedef TStack *PTStack; |
| 119 |
PTStack TitleStack = NULL; |
PTStack TitleStack = NULL; |
| 144 |
static BOOL MainCursor=TRUE; |
static BOOL MainCursor=TRUE; |
| 145 |
|
|
| 146 |
/* status for printer escape sequences */ |
/* status for printer escape sequences */ |
| 147 |
static BOOL PrintEX = TRUE; // printing extent |
static BOOL PrintEX = TRUE; // printing extent |
| 148 |
// (TRUE: screen, FALSE: scroll region) |
// (TRUE: screen, FALSE: scroll region) |
| 149 |
static BOOL AutoPrintMode = FALSE; |
static BOOL AutoPrintMode = FALSE; |
| 150 |
static BOOL PrinterMode = FALSE; |
static BOOL PrinterMode = FALSE; |
| 174 |
|
|
| 175 |
void ClearParams() |
void ClearParams() |
| 176 |
{ |
{ |
| 177 |
ICount = 0; |
ICount = 0; |
| 178 |
NParam = 1; |
NParam = 1; |
| 179 |
NSParam[1] = 0; |
NSParam[1] = 0; |
| 180 |
Param[1] = 0; |
Param[1] = 0; |
| 181 |
Prv = 0; |
Prv = 0; |
| 182 |
} |
} |
| 183 |
|
|
| 184 |
void ResetSBuffer(PStatusBuff sbuff) |
void ResetSBuffer(PStatusBuff sbuff) |
| 185 |
{ |
{ |
| 186 |
sbuff->CursorX = 0; |
sbuff->CursorX = 0; |
| 187 |
sbuff->CursorY = 0; |
sbuff->CursorY = 0; |
| 188 |
sbuff->Attr = DefCharAttr; |
sbuff->Attr = DefCharAttr; |
| 189 |
if (ts.Language==IdJapanese) |
if (ts.Language==IdJapanese) { |
| 190 |
{ |
sbuff->Gn[0] = IdASCII; |
| 191 |
sbuff->Gn[0] = IdASCII; |
sbuff->Gn[1] = IdKatakana; |
| 192 |
sbuff->Gn[1] = IdKatakana; |
sbuff->Gn[2] = IdKatakana; |
| 193 |
sbuff->Gn[2] = IdKatakana; |
sbuff->Gn[3] = IdKanji; |
| 194 |
sbuff->Gn[3] = IdKanji; |
sbuff->Glr[0] = 0; |
| 195 |
sbuff->Glr[0] = 0; |
if ((ts.KanjiCode==IdJIS) && (ts.JIS7Katakana==0)) |
| 196 |
if ((ts.KanjiCode==IdJIS) && |
sbuff->Glr[1] = 2; // 8-bit katakana |
| 197 |
(ts.JIS7Katakana==0)) |
else |
| 198 |
sbuff->Glr[1] = 2; // 8-bit katakana |
sbuff->Glr[1] = 3; |
| 199 |
else |
} |
| 200 |
sbuff->Glr[1] = 3; |
else { |
| 201 |
} |
sbuff->Gn[0] = IdASCII; |
| 202 |
else { |
sbuff->Gn[1] = IdSpecial; |
| 203 |
sbuff->Gn[0] = IdASCII; |
sbuff->Gn[2] = IdASCII; |
| 204 |
sbuff->Gn[1] = IdSpecial; |
sbuff->Gn[3] = IdASCII; |
| 205 |
sbuff->Gn[2] = IdASCII; |
sbuff->Glr[0] = 0; |
| 206 |
sbuff->Gn[3] = IdASCII; |
sbuff->Glr[1] = 0; |
| 207 |
sbuff->Glr[0] = 0; |
} |
| 208 |
sbuff->Glr[1] = 0; |
sbuff->AutoWrapMode = TRUE; |
| 209 |
} |
sbuff->RelativeOrgMode = FALSE; |
|
sbuff->AutoWrapMode = TRUE; |
|
|
sbuff->RelativeOrgMode = FALSE; |
|
| 210 |
} |
} |
| 211 |
|
|
| 212 |
void ResetAllSBuffers() |
void ResetAllSBuffers() |
| 213 |
{ |
{ |
| 214 |
ResetSBuffer(&SBuff1); |
ResetSBuffer(&SBuff1); |
| 215 |
// copy SBuff1 to SBuff2 |
// copy SBuff1 to SBuff2 |
| 216 |
SBuff2 = SBuff1; |
SBuff2 = SBuff1; |
| 217 |
SBuff3 = SBuff1; |
SBuff3 = SBuff1; |
| 218 |
} |
} |
| 219 |
|
|
| 220 |
void ResetCurSBuffer() |
void ResetCurSBuffer() |
| 221 |
{ |
{ |
| 222 |
PStatusBuff Buff; |
PStatusBuff Buff; |
| 223 |
|
|
| 224 |
if (AltScr) { |
if (AltScr) { |
| 225 |
Buff = &SBuff3; // Alternate screen buffer |
Buff = &SBuff3; // Alternate screen buffer |
| 226 |
} |
} |
| 227 |
else { |
else { |
| 228 |
Buff = &SBuff1; // Normal screen buffer |
Buff = &SBuff1; // Normal screen buffer |
| 229 |
} |
} |
| 230 |
ResetSBuffer(Buff); |
ResetSBuffer(Buff); |
| 231 |
SBuff2 = *Buff; |
SBuff2 = *Buff; |
| 232 |
} |
} |
| 233 |
|
|
| 234 |
void ResetTerminal() /*reset variables but don't update screen */ |
void ResetTerminal() /*reset variables but don't update screen */ |
| 235 |
{ |
{ |
| 236 |
DispReset(); |
DispReset(); |
| 237 |
BuffReset(); |
BuffReset(); |
| 238 |
|
|
| 239 |
/* Attribute */ |
/* Attribute */ |
| 240 |
CharAttr = DefCharAttr; |
CharAttr = DefCharAttr; |
| 241 |
Special = FALSE; |
Special = FALSE; |
| 242 |
BuffSetCurCharAttr(CharAttr); |
BuffSetCurCharAttr(CharAttr); |
| 243 |
|
|
| 244 |
/* Various modes */ |
/* Various modes */ |
| 245 |
InsertMode = FALSE; |
InsertMode = FALSE; |
| 246 |
LFMode = (ts.CRSend == IdCRLF); |
LFMode = (ts.CRSend == IdCRLF); |
| 247 |
AutoWrapMode = TRUE; |
AutoWrapMode = TRUE; |
| 248 |
AppliKeyMode = FALSE; |
AppliKeyMode = FALSE; |
| 249 |
AppliCursorMode = FALSE; |
AppliCursorMode = FALSE; |
| 250 |
AppliEscapeMode = FALSE; |
AppliEscapeMode = FALSE; |
| 251 |
AcceptWheelToCursor = ts.TranslateWheelToCursor; |
AcceptWheelToCursor = ts.TranslateWheelToCursor; |
| 252 |
RelativeOrgMode = FALSE; |
RelativeOrgMode = FALSE; |
| 253 |
ts.ColorFlag &= ~CF_REVERSEVIDEO; |
ts.ColorFlag &= ~CF_REVERSEVIDEO; |
| 254 |
AutoRepeatMode = TRUE; |
AutoRepeatMode = TRUE; |
| 255 |
FocusReportMode = FALSE; |
FocusReportMode = FALSE; |
| 256 |
MouseReportMode = IdMouseTrackNone; |
MouseReportMode = IdMouseTrackNone; |
| 257 |
MouseReportExtMode = IdMouseTrackExtNone; |
MouseReportExtMode = IdMouseTrackExtNone; |
| 258 |
DecLocatorFlag = 0; |
DecLocatorFlag = 0; |
| 259 |
ClearThenHome = FALSE; |
ClearThenHome = FALSE; |
| 260 |
|
|
| 261 |
ChangeTerminalID(); |
ChangeTerminalID(); |
| 262 |
|
|
| 263 |
LastX = 0; |
LastX = 0; |
| 264 |
LastY = 0; |
LastY = 0; |
| 265 |
ButtonStat = 0; |
ButtonStat = 0; |
| 266 |
|
|
| 267 |
if (CLocale == NULL) { |
if (CLocale == NULL) { |
| 268 |
CLocale = _create_locale(LC_ALL, "C"); |
CLocale = _create_locale(LC_ALL, "C"); |
| 269 |
} |
} |
| 270 |
|
|
| 271 |
/* Character sets */ |
/* Character sets */ |
| 272 |
ResetCharSet(); |
ResetCharSet(); |
| 273 |
|
|
| 274 |
/* ESC flag for device control sequence */ |
/* ESC flag for device control sequence */ |
| 275 |
ESCFlag = FALSE; |
ESCFlag = FALSE; |
| 276 |
/* for TEK sequence */ |
/* for TEK sequence */ |
| 277 |
JustAfterESC = FALSE; |
JustAfterESC = FALSE; |
| 278 |
|
|
| 279 |
/* Parse mode */ |
/* Parse mode */ |
| 280 |
ParseMode = ModeFirst; |
ParseMode = ModeFirst; |
| 281 |
|
|
| 282 |
/* Clear printer mode */ |
/* Clear printer mode */ |
| 283 |
PrinterMode = FALSE; |
PrinterMode = FALSE; |
| 284 |
|
|
| 285 |
// status buffers |
// status buffers |
| 286 |
ResetAllSBuffers(); |
ResetAllSBuffers(); |
| 287 |
|
|
| 288 |
// Alternate Screen Buffer |
// Alternate Screen Buffer |
| 289 |
AltScr = FALSE; |
AltScr = FALSE; |
| 290 |
|
|
| 291 |
// Left/Right Margin Mode |
// Left/Right Margin Mode |
| 292 |
LRMarginMode = FALSE; |
LRMarginMode = FALSE; |
| 293 |
|
|
| 294 |
// Bracketed Paste Mode |
// Bracketed Paste Mode |
| 295 |
BracketedPaste = FALSE; |
BracketedPaste = FALSE; |
| 296 |
|
|
| 297 |
// Saved IME Status |
// Saved IME Status |
| 298 |
IMEstat = FALSE; |
IMEstat = FALSE; |
| 299 |
|
|
| 300 |
// previous received character |
// previous received character |
| 301 |
PrevCharacter = -1; // none |
PrevCharacter = -1; // none |
| 302 |
PrevCRorLFGeneratedCRLF = FALSE; |
PrevCRorLFGeneratedCRLF = FALSE; |
| 303 |
|
|
| 304 |
// Beep over-used |
// Beep over-used |
| 305 |
BeepStartTime = GetTickCount(); |
BeepStartTime = GetTickCount(); |
| 306 |
BeepSuppressTime = BeepStartTime - ts.BeepSuppressTime * 1000; |
BeepSuppressTime = BeepStartTime - ts.BeepSuppressTime * 1000; |
| 307 |
BeepStartTime -= (ts.BeepOverUsedTime * 1000); |
BeepStartTime -= (ts.BeepOverUsedTime * 1000); |
| 308 |
BeepOverUsedCount = ts.BeepOverUsedCount; |
BeepOverUsedCount = ts.BeepOverUsedCount; |
| 309 |
} |
} |
| 310 |
|
|
| 311 |
void ResetCharSet() |
void ResetCharSet() |
| 312 |
{ |
{ |
| 313 |
if (ts.Language==IdJapanese) |
if (ts.Language==IdJapanese) { |
| 314 |
{ |
Gn[0] = IdASCII; |
| 315 |
Gn[0] = IdASCII; |
Gn[1] = IdKatakana; |
| 316 |
Gn[1] = IdKatakana; |
Gn[2] = IdKatakana; |
| 317 |
Gn[2] = IdKatakana; |
Gn[3] = IdKanji; |
| 318 |
Gn[3] = IdKanji; |
Glr[0] = 0; |
| 319 |
Glr[0] = 0; |
if ((ts.KanjiCode==IdJIS) && (ts.JIS7Katakana==0)) |
| 320 |
if ((ts.KanjiCode==IdJIS) && |
Glr[1] = 2; // 8-bit katakana |
| 321 |
(ts.JIS7Katakana==0)) |
else |
| 322 |
Glr[1] = 2; // 8-bit katakana |
Glr[1] = 3; |
| 323 |
else |
} |
| 324 |
Glr[1] = 3; |
else { |
| 325 |
} |
Gn[0] = IdASCII; |
| 326 |
else { |
Gn[1] = IdSpecial; |
| 327 |
Gn[0] = IdASCII; |
Gn[2] = IdASCII; |
| 328 |
Gn[1] = IdSpecial; |
Gn[3] = IdASCII; |
| 329 |
Gn[2] = IdASCII; |
Glr[0] = 0; |
| 330 |
Gn[3] = IdASCII; |
Glr[1] = 0; |
| 331 |
Glr[0] = 0; |
cv.SendCode = IdASCII; |
| 332 |
Glr[1] = 0; |
cv.SendKanjiFlag = FALSE; |
| 333 |
cv.SendCode = IdASCII; |
cv.EchoCode = IdASCII; |
| 334 |
cv.SendKanjiFlag = FALSE; |
cv.EchoKanjiFlag = FALSE; |
| 335 |
cv.EchoCode = IdASCII; |
} |
| 336 |
cv.EchoKanjiFlag = FALSE; |
/* Kanji flag */ |
| 337 |
} |
KanjiIn = FALSE; |
| 338 |
/* Kanji flag */ |
EUCkanaIn = FALSE; |
| 339 |
KanjiIn = FALSE; |
EUCsupIn = FALSE; |
| 340 |
EUCkanaIn = FALSE; |
SSflag = FALSE; |
| 341 |
EUCsupIn = FALSE; |
ConvJIS = FALSE; |
| 342 |
SSflag = FALSE; |
Fallbacked = FALSE; |
| 343 |
ConvJIS = FALSE; |
|
| 344 |
Fallbacked = FALSE; |
cv.Language = ts.Language; |
| 345 |
|
cv.CRSend = ts.CRSend; |
| 346 |
cv.Language = ts.Language; |
cv.KanjiCodeEcho = ts.KanjiCode; |
| 347 |
cv.CRSend = ts.CRSend; |
cv.JIS7KatakanaEcho = ts.JIS7Katakana; |
| 348 |
cv.KanjiCodeEcho = ts.KanjiCode; |
cv.KanjiCodeSend = ts.KanjiCodeSend; |
| 349 |
cv.JIS7KatakanaEcho = ts.JIS7Katakana; |
cv.JIS7KatakanaSend = ts.JIS7KatakanaSend; |
| 350 |
cv.KanjiCodeSend = ts.KanjiCodeSend; |
cv.KanjiIn = ts.KanjiIn; |
| 351 |
cv.JIS7KatakanaSend = ts.JIS7KatakanaSend; |
cv.KanjiOut = ts.KanjiOut; |
|
cv.KanjiIn = ts.KanjiIn; |
|
|
cv.KanjiOut = ts.KanjiOut; |
|
| 352 |
} |
} |
| 353 |
|
|
| 354 |
void ResetKeypadMode(BOOL DisabledModeOnly) |
void ResetKeypadMode(BOOL DisabledModeOnly) |
| 355 |
{ |
{ |
| 356 |
if (!DisabledModeOnly || ts.DisableAppKeypad) AppliKeyMode = FALSE; |
if (!DisabledModeOnly || ts.DisableAppKeypad) |
| 357 |
if (!DisabledModeOnly || ts.DisableAppCursor) AppliCursorMode = FALSE; |
AppliKeyMode = FALSE; |
| 358 |
|
if (!DisabledModeOnly || ts.DisableAppCursor) |
| 359 |
|
AppliCursorMode = FALSE; |
| 360 |
} |
} |
| 361 |
|
|
| 362 |
void MoveToMainScreen() |
void MoveToMainScreen() |
| 363 |
{ |
{ |
| 364 |
StatusX = CursorX; |
StatusX = CursorX; |
| 365 |
StatusWrap = Wrap; |
StatusWrap = Wrap; |
| 366 |
StatusCursor = IsCaretEnabled(); |
StatusCursor = IsCaretEnabled(); |
| 367 |
|
|
| 368 |
CursorTop = MainTop; |
CursorTop = MainTop; |
| 369 |
CursorBottom = MainBottom; |
CursorBottom = MainBottom; |
| 370 |
Wrap = MainWrap; |
Wrap = MainWrap; |
| 371 |
DispEnableCaret(MainCursor); |
DispEnableCaret(MainCursor); |
| 372 |
MoveCursor(MainX,MainY); // move to main screen |
MoveCursor(MainX, MainY); // move to main screen |
| 373 |
} |
} |
| 374 |
|
|
| 375 |
void MoveToStatusLine() |
void MoveToStatusLine() |
| 376 |
{ |
{ |
| 377 |
MainX = CursorX; |
MainX = CursorX; |
| 378 |
MainY = CursorY; |
MainY = CursorY; |
| 379 |
MainTop = CursorTop; |
MainTop = CursorTop; |
| 380 |
MainBottom = CursorBottom; |
MainBottom = CursorBottom; |
| 381 |
MainWrap = Wrap; |
MainWrap = Wrap; |
| 382 |
MainCursor = IsCaretEnabled(); |
MainCursor = IsCaretEnabled(); |
| 383 |
|
|
| 384 |
DispEnableCaret(StatusCursor); |
DispEnableCaret(StatusCursor); |
| 385 |
MoveCursor(StatusX,NumOfLines-1); // move to status line |
MoveCursor(StatusX, NumOfLines-1); // move to status line |
| 386 |
CursorTop = NumOfLines-1; |
CursorTop = NumOfLines-1; |
| 387 |
CursorBottom = CursorTop; |
CursorBottom = CursorTop; |
| 388 |
Wrap = StatusWrap; |
Wrap = StatusWrap; |
| 389 |
} |
} |
| 390 |
|
|
| 391 |
void HideStatusLine() |
void HideStatusLine() |
| 392 |
{ |
{ |
| 393 |
if (isCursorOnStatusLine) |
if (isCursorOnStatusLine) |
| 394 |
MoveToMainScreen(); |
MoveToMainScreen(); |
| 395 |
StatusX = 0; |
StatusX = 0; |
| 396 |
StatusWrap = FALSE; |
StatusWrap = FALSE; |
| 397 |
StatusCursor = TRUE; |
StatusCursor = TRUE; |
| 398 |
ShowStatusLine(0); //hide |
ShowStatusLine(0); //hide |
| 399 |
} |
} |
| 400 |
|
|
| 401 |
void ChangeTerminalSize(int Nx, int Ny) |
void ChangeTerminalSize(int Nx, int Ny) |
| 402 |
{ |
{ |
| 403 |
BuffChangeTerminalSize(Nx,Ny); |
BuffChangeTerminalSize(Nx, Ny); |
| 404 |
StatusX = 0; |
StatusX = 0; |
| 405 |
MainX = 0; |
MainX = 0; |
| 406 |
MainY = 0; |
MainY = 0; |
| 407 |
MainTop = 0; |
MainTop = 0; |
| 408 |
MainBottom = NumOfColumns-1; |
MainBottom = NumOfColumns-1; |
| 409 |
LRMarginMode = FALSE; |
LRMarginMode = FALSE; |
| 410 |
} |
} |
| 411 |
|
|
| 412 |
void SendCSIstr(char *str, int len) { |
void SendCSIstr(char *str, int len) { |
| 506 |
#ifndef NO_COPYLINE_FIX |
#ifndef NO_COPYLINE_FIX |
| 507 |
if (!ts.EnableContinuedLineCopy || logFlag) |
if (!ts.EnableContinuedLineCopy || logFlag) |
| 508 |
#endif /* NO_COPYLINE_FIX */ |
#endif /* NO_COPYLINE_FIX */ |
| 509 |
if (cv.HLogBuf!=0) Log1Byte(CR); |
if (cv.HLogBuf!=0) Log1Byte(CR); |
| 510 |
|
|
| 511 |
if (RelativeOrgMode || CursorX > CursorLeftM) |
if (RelativeOrgMode || CursorX > CursorLeftM) |
| 512 |
MoveCursor(CursorLeftM, CursorY); |
MoveCursor(CursorLeftM, CursorY); |
| 545 |
|
|
| 546 |
void Tab() |
void Tab() |
| 547 |
{ |
{ |
| 548 |
if (Wrap && !ts.VTCompatTab) { |
if (Wrap && !ts.VTCompatTab) { |
| 549 |
CarriageReturn(FALSE); |
CarriageReturn(FALSE); |
| 550 |
LineFeed(LF,FALSE); |
LineFeed(LF,FALSE); |
| 551 |
#ifndef NO_COPYLINE_FIX |
#ifndef NO_COPYLINE_FIX |
| 552 |
if (ts.EnableContinuedLineCopy) { |
if (ts.EnableContinuedLineCopy) { |
| 553 |
SetLineContinued(); |
SetLineContinued(); |
| 554 |
} |
} |
| 555 |
#endif /* NO_COPYLINE_FIX */ |
#endif /* NO_COPYLINE_FIX */ |
| 556 |
Wrap = FALSE; |
Wrap = FALSE; |
| 557 |
} |
} |
| 558 |
CursorForwardTab(1, AutoWrapMode); |
CursorForwardTab(1, AutoWrapMode); |
| 559 |
if (cv.HLogBuf!=0) Log1Byte(HT); |
if (cv.HLogBuf!=0) Log1Byte(HT); |
| 560 |
} |
} |
| 561 |
|
|
| 562 |
void PutChar(BYTE b) |
void PutChar(BYTE b) |
| 563 |
{ |
{ |
| 564 |
BOOL SpecialNew; |
BOOL SpecialNew; |
| 565 |
TCharAttr CharAttrTmp; |
TCharAttr CharAttrTmp; |
| 566 |
|
|
| 567 |
|
CharAttrTmp = CharAttr; |
| 568 |
|
|
| 569 |
CharAttrTmp = CharAttr; |
if (PrinterMode) { // printer mode |
| 570 |
|
WriteToPrnFile(b,TRUE); |
| 571 |
|
return; |
| 572 |
|
} |
| 573 |
|
|
| 574 |
if (PrinterMode) { // printer mode |
if (Wrap) { |
| 575 |
WriteToPrnFile(b,TRUE); |
CarriageReturn(FALSE); |
| 576 |
return; |
LineFeed(LF,FALSE); |
|
} |
|
|
|
|
|
if (Wrap) |
|
|
{ |
|
|
CarriageReturn(FALSE); |
|
|
LineFeed(LF,FALSE); |
|
| 577 |
#ifndef NO_COPYLINE_FIX |
#ifndef NO_COPYLINE_FIX |
| 578 |
CharAttrTmp.Attr |= ts.EnableContinuedLineCopy ? AttrLineContinued : 0; |
CharAttrTmp.Attr |= ts.EnableContinuedLineCopy ? AttrLineContinued : 0; |
| 579 |
#endif /* NO_COPYLINE_FIX */ |
#endif /* NO_COPYLINE_FIX */ |
| 580 |
} |
} |
| 581 |
|
|
| 582 |
// if (cv.HLogBuf!=0) Log1Byte(b); |
// if (cv.HLogBuf!=0) Log1Byte(b); |
| 583 |
// (2005.2.20 yutaka) |
// (2005.2.20 yutaka) |
| 584 |
if (ts.LogTypePlainText) { |
if (ts.LogTypePlainText) { |
| 585 |
if (__isascii(b) && !isprint(b)) { |
if (__isascii(b) && !isprint(b)) { |
| 586 |
// ASCII文字で、非表示な文字はログ採取しない。 |
// ASCII文字で、非表示な文字はログ採取しない。 |
| 587 |
} else { |
} else { |
| 588 |
|
if (cv.HLogBuf!=0) Log1Byte(b); |
| 589 |
|
} |
| 590 |
|
} else { |
| 591 |
if (cv.HLogBuf!=0) Log1Byte(b); |
if (cv.HLogBuf!=0) Log1Byte(b); |
| 592 |
} |
} |
| 593 |
} else { |
|
| 594 |
if (cv.HLogBuf!=0) Log1Byte(b); |
Wrap = FALSE; |
| 595 |
} |
|
| 596 |
|
SpecialNew = FALSE; |
| 597 |
Wrap = FALSE; |
if ((b>0x5F) && (b<0x80)) { |
| 598 |
|
if (SSflag) |
| 599 |
SpecialNew = FALSE; |
SpecialNew = (Gn[GLtmp]==IdSpecial); |
| 600 |
if ((b>0x5F) && (b<0x80)) |
else |
| 601 |
{ |
SpecialNew = (Gn[Glr[0]]==IdSpecial); |
| 602 |
if (SSflag) |
} |
| 603 |
SpecialNew = (Gn[GLtmp]==IdSpecial); |
else if (b>0xDF) { |
| 604 |
else |
if (SSflag) |
| 605 |
SpecialNew = (Gn[Glr[0]]==IdSpecial); |
SpecialNew = (Gn[GLtmp]==IdSpecial); |
| 606 |
} |
else |
| 607 |
else if (b>0xDF) |
SpecialNew = (Gn[Glr[1]]==IdSpecial); |
| 608 |
{ |
} |
| 609 |
if (SSflag) |
|
| 610 |
SpecialNew = (Gn[GLtmp]==IdSpecial); |
if (SpecialNew != Special) { |
| 611 |
else |
UpdateStr(); |
| 612 |
SpecialNew = (Gn[Glr[1]]==IdSpecial); |
Special = SpecialNew; |
| 613 |
} |
} |
| 614 |
|
|
| 615 |
if (SpecialNew != Special) |
if (Special) { |
| 616 |
{ |
b = b & 0x7F; |
| 617 |
UpdateStr(); |
CharAttrTmp.Attr |= AttrSpecial; |
| 618 |
Special = SpecialNew; |
} |
| 619 |
} |
else |
| 620 |
|
CharAttrTmp.Attr |= CharAttr.Attr; |
| 621 |
if (Special) |
|
| 622 |
{ |
BuffPutChar(b, CharAttrTmp, InsertMode); |
| 623 |
b = b & 0x7F; |
|
| 624 |
CharAttrTmp.Attr |= AttrSpecial; |
if (CursorX == CursorRightM || CursorX >= NumOfColumns-1) { |
| 625 |
} |
UpdateStr(); |
| 626 |
else |
Wrap = AutoWrapMode; |
| 627 |
CharAttrTmp.Attr |= CharAttr.Attr; |
} |
| 628 |
|
else { |
| 629 |
BuffPutChar(b, CharAttrTmp, InsertMode); |
MoveRight(); |
| 630 |
|
} |
|
if (CursorX == CursorRightM || CursorX >= NumOfColumns-1) { |
|
|
UpdateStr(); |
|
|
Wrap = AutoWrapMode; |
|
|
} |
|
|
else { |
|
|
MoveRight(); |
|
|
} |
|
| 631 |
} |
} |
| 632 |
|
|
| 633 |
void PutDecSp(BYTE b) |
void PutDecSp(BYTE b) |
| 634 |
{ |
{ |
| 635 |
TCharAttr CharAttrTmp; |
TCharAttr CharAttrTmp; |
| 636 |
|
|
| 637 |
CharAttrTmp = CharAttr; |
CharAttrTmp = CharAttr; |
| 638 |
|
|
| 639 |
if (PrinterMode) { // printer mode |
if (PrinterMode) { // printer mode |
| 640 |
WriteToPrnFile(b, TRUE); |
WriteToPrnFile(b, TRUE); |
| 641 |
return; |
return; |
| 642 |
} |
} |
| 643 |
|
|
| 644 |
if (Wrap) { |
if (Wrap) { |
| 645 |
CarriageReturn(FALSE); |
CarriageReturn(FALSE); |
| 646 |
LineFeed(LF, FALSE); |
LineFeed(LF, FALSE); |
| 647 |
#ifndef NO_COPYLINE_FIX |
#ifndef NO_COPYLINE_FIX |
| 648 |
CharAttrTmp.Attr |= ts.EnableContinuedLineCopy ? AttrLineContinued : 0; |
CharAttrTmp.Attr |= ts.EnableContinuedLineCopy ? AttrLineContinued : 0; |
| 649 |
#endif /* NO_COPYLINE_FIX */ |
#endif /* NO_COPYLINE_FIX */ |
| 650 |
} |
} |
| 651 |
|
|
| 652 |
if (cv.HLogBuf!=0) Log1Byte(b); |
if (cv.HLogBuf!=0) Log1Byte(b); |
| 653 |
/* |
/* |
| 654 |
if (ts.LogTypePlainText && __isascii(b) && !isprint(b)) { |
if (ts.LogTypePlainText && __isascii(b) && !isprint(b)) { |
| 655 |
// ASCII文字で、非表示な文字はログ採取しない。 |
// ASCII文字で、非表示な文字はログ採取しない。 |
| 656 |
} else { |
} else { |
| 657 |
if (cv.HLogBuf!=0) Log1Byte(b); |
if (cv.HLogBuf!=0) Log1Byte(b); |
| 658 |
} |
} |
| 659 |
*/ |
*/ |
| 660 |
|
|
| 661 |
Wrap = FALSE; |
Wrap = FALSE; |
| 662 |
|
|
| 663 |
|
if (!Special) { |
| 664 |
|
UpdateStr(); |
| 665 |
|
Special = TRUE; |
| 666 |
|
} |
| 667 |
|
|
| 668 |
if (!Special) { |
CharAttrTmp.Attr |= AttrSpecial; |
| 669 |
UpdateStr(); |
BuffPutChar(b, CharAttrTmp, InsertMode); |
| 670 |
Special = TRUE; |
|
| 671 |
} |
if (CursorX == CursorRightM || CursorX >= NumOfColumns-1) { |
| 672 |
|
UpdateStr(); |
| 673 |
CharAttrTmp.Attr |= AttrSpecial; |
Wrap = AutoWrapMode; |
| 674 |
BuffPutChar(b, CharAttrTmp, InsertMode); |
} |
| 675 |
|
else { |
| 676 |
if (CursorX == CursorRightM || CursorX >= NumOfColumns-1) { |
MoveRight(); |
| 677 |
UpdateStr(); |
} |
|
Wrap = AutoWrapMode; |
|
|
} |
|
|
else { |
|
|
MoveRight(); |
|
|
} |
|
| 678 |
} |
} |
| 679 |
|
|
| 680 |
void PutKanji(BYTE b) |
void PutKanji(BYTE b) |
| 681 |
{ |
{ |
| 682 |
int LineEnd; |
int LineEnd; |
| 683 |
#ifndef NO_COPYLINE_FIX |
#ifndef NO_COPYLINE_FIX |
| 684 |
TCharAttr CharAttrTmp; |
TCharAttr CharAttrTmp; |
| 685 |
|
|
| 686 |
CharAttrTmp = CharAttr; |
CharAttrTmp = CharAttr; |
| 687 |
#endif /* NO_COPYLINE_FIX */ |
#endif /* NO_COPYLINE_FIX */ |
| 688 |
Kanji = Kanji + b; |
Kanji = Kanji + b; |
| 689 |
|
|
| 690 |
|
if (PrinterMode && DirectPrn) { |
| 691 |
|
WriteToPrnFile(HIBYTE(Kanji),FALSE); |
| 692 |
|
WriteToPrnFile(LOBYTE(Kanji),TRUE); |
| 693 |
|
return; |
| 694 |
|
} |
| 695 |
|
|
| 696 |
|
if (ConvJIS) |
| 697 |
|
Kanji = JIS2SJIS((WORD)(Kanji & 0x7f7f)); |
| 698 |
|
|
| 699 |
|
if (PrinterMode) { // printer mode |
| 700 |
|
WriteToPrnFile(HIBYTE(Kanji),FALSE); |
| 701 |
|
WriteToPrnFile(LOBYTE(Kanji),TRUE); |
| 702 |
|
return; |
| 703 |
|
} |
| 704 |
|
|
| 705 |
|
if (CursorX > CursorRightM) |
| 706 |
|
LineEnd = NumOfColumns - 1; |
| 707 |
|
else |
| 708 |
|
LineEnd = CursorRightM; |
| 709 |
|
|
| 710 |
if (PrinterMode && DirectPrn) |
if (Wrap) { |
| 711 |
{ |
CarriageReturn(FALSE); |
| 712 |
WriteToPrnFile(HIBYTE(Kanji),FALSE); |
LineFeed(LF,FALSE); |
|
WriteToPrnFile(LOBYTE(Kanji),TRUE); |
|
|
return; |
|
|
} |
|
|
|
|
|
if (ConvJIS) |
|
|
Kanji = JIS2SJIS((WORD)(Kanji & 0x7f7f)); |
|
|
|
|
|
if (PrinterMode) { // printer mode |
|
|
WriteToPrnFile(HIBYTE(Kanji),FALSE); |
|
|
WriteToPrnFile(LOBYTE(Kanji),TRUE); |
|
|
return; |
|
|
} |
|
|
|
|
|
if (CursorX > CursorRightM) |
|
|
LineEnd = NumOfColumns - 1; |
|
|
else |
|
|
LineEnd = CursorRightM; |
|
|
|
|
|
if (Wrap) |
|
|
{ |
|
|
CarriageReturn(FALSE); |
|
|
LineFeed(LF,FALSE); |
|
| 713 |
#ifndef NO_COPYLINE_FIX |
#ifndef NO_COPYLINE_FIX |
| 714 |
if (ts.EnableContinuedLineCopy) |
if (ts.EnableContinuedLineCopy) |
| 715 |
CharAttrTmp.Attr |= AttrLineContinued; |
CharAttrTmp.Attr |= AttrLineContinued; |
| 716 |
#endif /* NO_COPYLINE_FIX */ |
#endif /* NO_COPYLINE_FIX */ |
| 717 |
} |
} |
| 718 |
else if (CursorX > LineEnd - 1) { |
else if (CursorX > LineEnd - 1) { |
| 719 |
if (AutoWrapMode) |
if (AutoWrapMode) { |
|
{ |
|
| 720 |
#ifndef NO_COPYLINE_FIX |
#ifndef NO_COPYLINE_FIX |
| 721 |
if (ts.EnableContinuedLineCopy) |
if (ts.EnableContinuedLineCopy) { |
| 722 |
{ |
CharAttrTmp.Attr |= AttrLineContinued; |
| 723 |
CharAttrTmp.Attr |= AttrLineContinued; |
if (CursorX == LineEnd) |
| 724 |
if (CursorX == LineEnd) |
BuffPutChar(0x20, CharAttr, FALSE); |
| 725 |
BuffPutChar(0x20, CharAttr, FALSE); |
} |
|
} |
|
| 726 |
#endif /* NO_COPYLINE_FIX */ |
#endif /* NO_COPYLINE_FIX */ |
| 727 |
CarriageReturn(FALSE); |
CarriageReturn(FALSE); |
| 728 |
LineFeed(LF,FALSE); |
LineFeed(LF,FALSE); |
| 729 |
} |
} |
| 730 |
else { |
else { |
| 731 |
return; |
return; |
| 732 |
} |
} |
| 733 |
} |
} |
| 734 |
|
|
| 735 |
Wrap = FALSE; |
Wrap = FALSE; |
| 736 |
|
|
| 737 |
if (cv.HLogBuf!=0) |
if (cv.HLogBuf!=0) { |
| 738 |
{ |
Log1Byte(HIBYTE(Kanji)); |
| 739 |
Log1Byte(HIBYTE(Kanji)); |
Log1Byte(LOBYTE(Kanji)); |
| 740 |
Log1Byte(LOBYTE(Kanji)); |
} |
| 741 |
} |
|
| 742 |
|
if (Special) { |
| 743 |
if (Special) |
UpdateStr(); |
| 744 |
{ |
Special = FALSE; |
| 745 |
UpdateStr(); |
} |
|
Special = FALSE; |
|
|
} |
|
| 746 |
|
|
| 747 |
#ifndef NO_COPYLINE_FIX |
#ifndef NO_COPYLINE_FIX |
| 748 |
BuffPutKanji(Kanji, CharAttrTmp, InsertMode); |
BuffPutKanji(Kanji, CharAttrTmp, InsertMode); |
| 749 |
#else |
#else |
| 750 |
BuffPutKanji(Kanji, CharAttr, InsertMode); |
BuffPutKanji(Kanji, CharAttr, InsertMode); |
| 751 |
#endif /* NO_COPYLINE_FIX */ |
#endif /* NO_COPYLINE_FIX */ |
| 752 |
|
|
| 753 |
if (CursorX < LineEnd - 1) { |
if (CursorX < LineEnd - 1) { |
| 754 |
MoveRight(); |
MoveRight(); |
| 755 |
MoveRight(); |
MoveRight(); |
| 756 |
} |
} |
| 757 |
else { |
else { |
| 758 |
UpdateStr(); |
UpdateStr(); |
| 759 |
Wrap = AutoWrapMode; |
Wrap = AutoWrapMode; |
| 760 |
} |
} |
| 761 |
} |
} |
| 762 |
|
|
| 763 |
void PutDebugChar(BYTE b) |
void PutDebugChar(BYTE b) |
| 820 |
|
|
| 821 |
void PrnParseControl(BYTE b) // printer mode |
void PrnParseControl(BYTE b) // printer mode |
| 822 |
{ |
{ |
| 823 |
switch (b) { |
switch (b) { |
| 824 |
case NUL: return; |
case NUL: |
| 825 |
case SO: |
return; |
| 826 |
if (! DirectPrn) |
case SO: |
| 827 |
{ |
if (! DirectPrn) { |
| 828 |
if ((ts.Language==IdJapanese) && |
if ((ts.Language==IdJapanese) && |
| 829 |
(ts.KanjiCode==IdJIS) && |
(ts.KanjiCode==IdJIS) && |
| 830 |
(ts.JIS7Katakana==1) && |
(ts.JIS7Katakana==1) && |
| 831 |
((ts.TermFlag & TF_FIXEDJIS)!=0)) |
((ts.TermFlag & TF_FIXEDJIS)!=0)) |
| 832 |
Gn[1] = IdKatakana; |
{ |
| 833 |
Glr[0] = 1; /* LS1 */ |
Gn[1] = IdKatakana; |
| 834 |
return; |
} |
| 835 |
} |
Glr[0] = 1; /* LS1 */ |
| 836 |
break; |
return; |
| 837 |
case SI: |
} |
| 838 |
if (! DirectPrn) |
break; |
| 839 |
{ |
case SI: |
| 840 |
Glr[0] = 0; /* LS0 */ |
if (! DirectPrn) { |
| 841 |
return; |
Glr[0] = 0; /* LS0 */ |
| 842 |
} |
return; |
| 843 |
break; |
} |
| 844 |
case DC1: |
break; |
| 845 |
case DC3: return; |
case DC1: |
| 846 |
case ESC: |
case DC3: |
| 847 |
ICount = 0; |
return; |
| 848 |
JustAfterESC = TRUE; |
case ESC: |
| 849 |
ParseMode = ModeESC; |
ICount = 0; |
| 850 |
WriteToPrnFile(0,TRUE); // flush prn buff |
JustAfterESC = TRUE; |
| 851 |
return; |
ParseMode = ModeESC; |
| 852 |
case CSI: |
WriteToPrnFile(0, TRUE); // flush prn buff |
| 853 |
if (! Accept8BitCtrl) { |
return; |
| 854 |
PutChar(b); /* Disp C1 char in VT100 mode */ |
case CSI: |
| 855 |
return; |
if (! Accept8BitCtrl) { |
| 856 |
} |
PutChar(b); /* Disp C1 char in VT100 mode */ |
| 857 |
ClearParams(); |
return; |
| 858 |
FirstPrm = TRUE; |
} |
| 859 |
ParseMode = ModeCSI; |
ClearParams(); |
| 860 |
WriteToPrnFile(0,TRUE); // flush prn buff |
FirstPrm = TRUE; |
| 861 |
WriteToPrnFile(b,FALSE); |
ParseMode = ModeCSI; |
| 862 |
return; |
WriteToPrnFile(0, TRUE); // flush prn buff |
| 863 |
} |
WriteToPrnFile(b, FALSE); |
| 864 |
/* send the uninterpreted character to printer */ |
return; |
| 865 |
WriteToPrnFile(b,TRUE); |
} |
| 866 |
|
/* send the uninterpreted character to printer */ |
| 867 |
|
WriteToPrnFile(b, TRUE); |
| 868 |
} |
} |
| 869 |
|
|
| 870 |
void ParseControl(BYTE b) |
void ParseControl(BYTE b) |
| 871 |
{ |
{ |
| 872 |
if (PrinterMode) { // printer mode |
if (PrinterMode) { // printer mode |
| 873 |
PrnParseControl(b); |
PrnParseControl(b); |
| 874 |
return; |
return; |
| 875 |
} |
} |
|
|
|
|
if (b>=0x80) /* C1 char */ |
|
|
{ |
|
|
/* English mode */ |
|
|
if (ts.Language==IdEnglish) |
|
|
{ |
|
|
if (!Accept8BitCtrl) { |
|
|
PutChar(b); /* Disp C1 char in VT100 mode */ |
|
|
return; |
|
|
} |
|
|
} |
|
|
else { /* Japanese mode */ |
|
|
if ((ts.TermFlag & TF_ACCEPT8BITCTRL)==0) |
|
|
return; /* ignore C1 char */ |
|
|
/* C1 chars are interpreted as C0 chars in VT100 mode */ |
|
|
if (VTlevel < 2) |
|
|
b = b & 0x7F; |
|
|
} |
|
|
} |
|
|
switch (b) { |
|
|
/* C0 group */ |
|
|
case ENQ: |
|
|
CommBinaryOut(&cv,&(ts.Answerback[0]),ts.AnswerbackLen); |
|
|
break; |
|
|
case BEL: |
|
|
if (ts.Beep != IdBeepOff) { |
|
|
RingBell(ts.Beep); |
|
|
} |
|
|
break; |
|
|
case BS: BackSpace(); break; |
|
|
case HT: Tab(); break; |
|
| 876 |
|
|
| 877 |
case LF: |
if (b>=0x80) { /* C1 char */ |
| 878 |
|
if (ts.Language==IdEnglish) { /* English mode */ |
| 879 |
|
if (!Accept8BitCtrl) { |
| 880 |
|
PutChar(b); /* Disp C1 char in VT100 mode */ |
| 881 |
|
return; |
| 882 |
|
} |
| 883 |
|
} |
| 884 |
|
else { /* Japanese mode */ |
| 885 |
|
if ((ts.TermFlag & TF_ACCEPT8BITCTRL)==0) { |
| 886 |
|
return; /* ignore C1 char */ |
| 887 |
|
} |
| 888 |
|
/* C1 chars are interpreted as C0 chars in VT100 mode */ |
| 889 |
|
if (VTlevel < 2) { |
| 890 |
|
b = b & 0x7F; |
| 891 |
|
} |
| 892 |
|
} |
| 893 |
|
} |
| 894 |
|
switch (b) { |
| 895 |
|
/* C0 group */ |
| 896 |
|
case ENQ: |
| 897 |
|
CommBinaryOut(&cv, &(ts.Answerback[0]), ts.AnswerbackLen); |
| 898 |
|
break; |
| 899 |
|
case BEL: |
| 900 |
|
if (ts.Beep != IdBeepOff) |
| 901 |
|
RingBell(ts.Beep); |
| 902 |
|
break; |
| 903 |
|
case BS: |
| 904 |
|
BackSpace(); |
| 905 |
|
break; |
| 906 |
|
case HT: |
| 907 |
|
Tab(); |
| 908 |
|
break; |
| 909 |
|
case LF: |
| 910 |
if (ts.CRReceive == IdLF) { |
if (ts.CRReceive == IdLF) { |
| 911 |
// 受信時の改行コードが LF の場合は、サーバから LF のみが送られてくると仮定し、 |
// 受信時の改行コードが LF の場合は、サーバから LF のみが送られてくると仮定し、 |
| 912 |
// CR+LFとして扱うようにする。 |
// CR+LFとして扱うようにする。 |
| 930 |
break; |
break; |
| 931 |
} |
} |
| 932 |
|
|
| 933 |
case VT: LineFeed(b,TRUE); break; |
case VT: |
| 934 |
|
LineFeed(b, TRUE); |
| 935 |
|
break; |
| 936 |
|
|
| 937 |
case FF: |
case FF: |
| 938 |
if ((ts.AutoWinSwitch>0) && JustAfterESC) |
if ((ts.AutoWinSwitch>0) && JustAfterESC) { |
| 939 |
{ |
CommInsert1Byte(&cv, b); |
| 940 |
CommInsert1Byte(&cv,b); |
CommInsert1Byte(&cv, ESC); |
| 941 |
CommInsert1Byte(&cv,ESC); |
ChangeEmu = IdTEK; /* Enter TEK Mode */ |
| 942 |
ChangeEmu = IdTEK; /* Enter TEK Mode */ |
} |
| 943 |
} |
else |
| 944 |
else |
LineFeed(b, TRUE); |
| 945 |
LineFeed(b,TRUE); |
break; |
| 946 |
break; |
case CR: |
| 947 |
case CR: |
if (ts.CRReceive == IdAUTO) { |
| 948 |
if (ts.CRReceive == IdAUTO) { |
// 9th Apr 2012: AUTO CR/LF mode (tentner) |
| 949 |
// 9th Apr 2012: AUTO CR/LF mode (tentner) |
// a CR or LF will generated a CR+LF, if the next character is the opposite, it will be ignored |
| 950 |
// a CR or LF will generated a CR+LF, if the next character is the opposite, it will be ignored |
if(PrevCharacter != LF || !PrevCRorLFGeneratedCRLF) { |
| 951 |
if(PrevCharacter != LF || !PrevCRorLFGeneratedCRLF) { |
CarriageReturn(TRUE); |
| 952 |
CarriageReturn(TRUE); |
LineFeed(b, TRUE); |
| 953 |
LineFeed(b, TRUE); |
PrevCRorLFGeneratedCRLF = TRUE; |
| 954 |
PrevCRorLFGeneratedCRLF = TRUE; |
} |
| 955 |
} |
else { |
| 956 |
else { |
PrevCRorLFGeneratedCRLF = FALSE; |
| 957 |
PrevCRorLFGeneratedCRLF = FALSE; |
} |
| 958 |
|
} |
| 959 |
|
else { |
| 960 |
|
CarriageReturn(TRUE); |
| 961 |
|
if (ts.CRReceive==IdCRLF) { |
| 962 |
|
CommInsert1Byte(&cv, LF); |
| 963 |
|
} |
| 964 |
|
} |
| 965 |
|
break; |
| 966 |
|
case SO: /* LS1 */ |
| 967 |
|
if ((ts.Language==IdJapanese) && |
| 968 |
|
(ts.KanjiCode==IdJIS) && |
| 969 |
|
(ts.JIS7Katakana==1) && |
| 970 |
|
((ts.TermFlag & TF_FIXEDJIS)!=0)) |
| 971 |
|
Gn[1] = IdKatakana; |
| 972 |
|
|
| 973 |
|
Glr[0] = 1; |
| 974 |
|
break; |
| 975 |
|
case SI: /* LS0 */ |
| 976 |
|
Glr[0] = 0; |
| 977 |
|
break; |
| 978 |
|
case DLE: |
| 979 |
|
if ((ts.FTFlag & FT_BPAUTO)!=0) |
| 980 |
|
ParseMode = ModeDLE; /* Auto B-Plus activation */ |
| 981 |
|
break; |
| 982 |
|
case CAN: |
| 983 |
|
if ((ts.FTFlag & FT_ZAUTO)!=0) |
| 984 |
|
ParseMode = ModeCAN; /* Auto ZMODEM activation */ |
| 985 |
|
// else if (ts.AutoWinSwitch>0) |
| 986 |
|
// ChangeEmu = IdTEK; /* Enter TEK Mode */ |
| 987 |
|
else |
| 988 |
|
ParseMode = ModeFirst; |
| 989 |
|
break; |
| 990 |
|
case SUB: |
| 991 |
|
ParseMode = ModeFirst; |
| 992 |
|
break; |
| 993 |
|
case ESC: |
| 994 |
|
ICount = 0; |
| 995 |
|
JustAfterESC = TRUE; |
| 996 |
|
ParseMode = ModeESC; |
| 997 |
|
break; |
| 998 |
|
case FS: |
| 999 |
|
case GS: |
| 1000 |
|
case RS: |
| 1001 |
|
case US: |
| 1002 |
|
if (ts.AutoWinSwitch>0) { |
| 1003 |
|
CommInsert1Byte(&cv, b); |
| 1004 |
|
ChangeEmu = IdTEK; /* Enter TEK Mode */ |
| 1005 |
|
} |
| 1006 |
|
break; |
| 1007 |
|
|
| 1008 |
|
/* C1 char */ |
| 1009 |
|
case IND: |
| 1010 |
|
LineFeed(0, TRUE); |
| 1011 |
|
break; |
| 1012 |
|
case NEL: |
| 1013 |
|
LineFeed(0, TRUE); |
| 1014 |
|
CarriageReturn(TRUE); |
| 1015 |
|
break; |
| 1016 |
|
case HTS: |
| 1017 |
|
if (ts.TabStopFlag & TABF_HTS8) |
| 1018 |
|
SetTabStop(); |
| 1019 |
|
break; |
| 1020 |
|
case RI: |
| 1021 |
|
CursorUpWithScroll(); |
| 1022 |
|
break; |
| 1023 |
|
case SS2: |
| 1024 |
|
GLtmp = 2; |
| 1025 |
|
SSflag = TRUE; |
| 1026 |
|
break; |
| 1027 |
|
case SS3: |
| 1028 |
|
GLtmp = 3; |
| 1029 |
|
SSflag = TRUE; |
| 1030 |
|
break; |
| 1031 |
|
case DCS: |
| 1032 |
|
ClearParams(); |
| 1033 |
|
ESCFlag = FALSE; |
| 1034 |
|
ParseMode = ModeDCS; |
| 1035 |
|
break; |
| 1036 |
|
case SOS: |
| 1037 |
|
ESCFlag = FALSE; |
| 1038 |
|
ParseMode = ModeIgnore; |
| 1039 |
|
break; |
| 1040 |
|
case CSI: |
| 1041 |
|
ClearParams(); |
| 1042 |
|
FirstPrm = TRUE; |
| 1043 |
|
ParseMode = ModeCSI; |
| 1044 |
|
break; |
| 1045 |
|
case OSC: |
| 1046 |
|
ClearParams(); |
| 1047 |
|
ParseMode = ModeXS; |
| 1048 |
|
break; |
| 1049 |
|
case PM: |
| 1050 |
|
case APC: |
| 1051 |
|
ESCFlag = FALSE; |
| 1052 |
|
ParseMode = ModeIgnore; |
| 1053 |
|
break; |
| 1054 |
} |
} |
|
} |
|
|
else { |
|
|
CarriageReturn(TRUE); |
|
|
if (ts.CRReceive==IdCRLF) { |
|
|
CommInsert1Byte(&cv,LF); |
|
|
} |
|
|
} |
|
|
break; |
|
|
case SO: |
|
|
if ((ts.Language==IdJapanese) && |
|
|
(ts.KanjiCode==IdJIS) && |
|
|
(ts.JIS7Katakana==1) && |
|
|
((ts.TermFlag & TF_FIXEDJIS)!=0)) |
|
|
Gn[1] = IdKatakana; |
|
|
|
|
|
Glr[0] = 1; /* LS1 */ |
|
|
break; |
|
|
case SI: Glr[0] = 0; break; /* LS0 */ |
|
|
case DLE: |
|
|
if ((ts.FTFlag & FT_BPAUTO)!=0) |
|
|
ParseMode = ModeDLE; /* Auto B-Plus activation */ |
|
|
break; |
|
|
case CAN: |
|
|
if ((ts.FTFlag & FT_ZAUTO)!=0) |
|
|
ParseMode = ModeCAN; /* Auto ZMODEM activation */ |
|
|
// else if (ts.AutoWinSwitch>0) |
|
|
// ChangeEmu = IdTEK; /* Enter TEK Mode */ |
|
|
else |
|
|
ParseMode = ModeFirst; |
|
|
break; |
|
|
case SUB: ParseMode = ModeFirst; break; |
|
|
case ESC: |
|
|
ICount = 0; |
|
|
JustAfterESC = TRUE; |
|
|
ParseMode = ModeESC; |
|
|
break; |
|
|
case FS: |
|
|
case GS: |
|
|
case RS: |
|
|
case US: |
|
|
if (ts.AutoWinSwitch>0) |
|
|
{ |
|
|
CommInsert1Byte(&cv,b); |
|
|
ChangeEmu = IdTEK; /* Enter TEK Mode */ |
|
|
} |
|
|
break; |
|
|
|
|
|
/* C1 char */ |
|
|
case IND: LineFeed(0,TRUE); break; |
|
|
case NEL: |
|
|
LineFeed(0,TRUE); |
|
|
CarriageReturn(TRUE); |
|
|
break; |
|
|
case HTS: if (ts.TabStopFlag & TABF_HTS8) SetTabStop(); break; |
|
|
case RI: CursorUpWithScroll(); break; |
|
|
case SS2: |
|
|
GLtmp = 2; |
|
|
SSflag = TRUE; |
|
|
break; |
|
|
case SS3: |
|
|
GLtmp = 3; |
|
|
SSflag = TRUE; |
|
|
break; |
|
|
case DCS: |
|
|
ClearParams(); |
|
|
ESCFlag = FALSE; |
|
|
ParseMode = ModeDCS; |
|
|
break; |
|
|
case SOS: |
|
|
ESCFlag = FALSE; |
|
|
ParseMode = ModeIgnore; |
|
|
break; |
|
|
case CSI: |
|
|
ClearParams(); |
|
|
FirstPrm = TRUE; |
|
|
ParseMode = ModeCSI; |
|
|
break; |
|
|
case OSC: |
|
|
ClearParams(); |
|
|
ParseMode = ModeXS; |
|
|
break; |
|
|
case PM: |
|
|
case APC: |
|
|
ESCFlag = FALSE; |
|
|
ParseMode = ModeIgnore; |
|
|
break; |
|
|
} |
|
| 1055 |
} |
} |
| 1056 |
|
|
| 1057 |
void SaveCursor() |
void SaveCursor() |
| 1058 |
{ |
{ |
| 1059 |
int i; |
int i; |
| 1060 |
PStatusBuff Buff; |
PStatusBuff Buff; |
| 1061 |
|
|
| 1062 |
|
if (isCursorOnStatusLine) |
| 1063 |
|
Buff = &SBuff2; // for status line |
| 1064 |
|
else if (AltScr) |
| 1065 |
|
Buff = &SBuff3; // for alternate screen |
| 1066 |
|
else |
| 1067 |
|
Buff = &SBuff1; // for main screen |
| 1068 |
|
|
| 1069 |
|
Buff->CursorX = CursorX; |
| 1070 |
|
Buff->CursorY = CursorY; |
| 1071 |
|
Buff->Attr = CharAttr; |
| 1072 |
|
|
| 1073 |
if (isCursorOnStatusLine) |
Buff->Glr[0] = Glr[0]; |
| 1074 |
Buff = &SBuff2; // for status line |
Buff->Glr[1] = Glr[1]; |
| 1075 |
else if (AltScr) |
for (i=0 ; i<=3; i++) |
| 1076 |
Buff = &SBuff3; // for alternate screen |
Buff->Gn[i] = Gn[i]; |
| 1077 |
else |
|
| 1078 |
Buff = &SBuff1; // for main screen |
Buff->AutoWrapMode = AutoWrapMode; |
| 1079 |
|
Buff->RelativeOrgMode = RelativeOrgMode; |
| 1080 |
Buff->CursorX = CursorX; |
} |
| 1081 |
Buff->CursorY = CursorY; |
|
| 1082 |
Buff->Attr = CharAttr; |
void RestoreCursor() |
| 1083 |
Buff->Glr[0] = Glr[0]; |
{ |
| 1084 |
Buff->Glr[1] = Glr[1]; |
int i; |
| 1085 |
for (i=0 ; i<=3; i++) |
PStatusBuff Buff; |
| 1086 |
Buff->Gn[i] = Gn[i]; |
|
| 1087 |
Buff->AutoWrapMode = AutoWrapMode; |
UpdateStr(); |
| 1088 |
Buff->RelativeOrgMode = RelativeOrgMode; |
|
| 1089 |
} |
if (isCursorOnStatusLine) |
| 1090 |
|
Buff = &SBuff2; // for status line |
| 1091 |
void RestoreCursor() |
else if (AltScr) |
| 1092 |
{ |
Buff = &SBuff3; // for alternate screen |
| 1093 |
int i; |
else |
| 1094 |
PStatusBuff Buff; |
Buff = &SBuff1; // for main screen |
| 1095 |
UpdateStr(); |
|
| 1096 |
|
if (Buff->CursorX > NumOfColumns-1) |
| 1097 |
if (isCursorOnStatusLine) |
Buff->CursorX = NumOfColumns-1; |
| 1098 |
Buff = &SBuff2; // for status line |
if (Buff->CursorY > NumOfLines-1-StatusLine) |
| 1099 |
else if (AltScr) |
Buff->CursorY = NumOfLines-1-StatusLine; |
| 1100 |
Buff = &SBuff3; // for alternate screen |
MoveCursor(Buff->CursorX, Buff->CursorY); |
| 1101 |
else |
|
| 1102 |
Buff = &SBuff1; // for main screen |
CharAttr = Buff->Attr; |
| 1103 |
|
BuffSetCurCharAttr(CharAttr); |
| 1104 |
if (Buff->CursorX > NumOfColumns-1) |
|
| 1105 |
Buff->CursorX = NumOfColumns-1; |
Glr[0] = Buff->Glr[0]; |
| 1106 |
if (Buff->CursorY > NumOfLines-1-StatusLine) |
Glr[1] = Buff->Glr[1]; |
| 1107 |
Buff->CursorY = NumOfLines-1-StatusLine; |
for (i=0 ; i<=3; i++) |
| 1108 |
MoveCursor(Buff->CursorX,Buff->CursorY); |
Gn[i] = Buff->Gn[i]; |
| 1109 |
CharAttr = Buff->Attr; |
|
| 1110 |
BuffSetCurCharAttr(CharAttr); |
AutoWrapMode = Buff->AutoWrapMode; |
| 1111 |
Glr[0] = Buff->Glr[0]; |
RelativeOrgMode = Buff->RelativeOrgMode; |
|
Glr[1] = Buff->Glr[1]; |
|
|
for (i=0 ; i<=3; i++) |
|
|
Gn[i] = Buff->Gn[i]; |
|
|
AutoWrapMode = Buff->AutoWrapMode; |
|
|
RelativeOrgMode = Buff->RelativeOrgMode; |
|
| 1112 |
} |
} |
| 1113 |
|
|
| 1114 |
void AnswerTerminalType() |
void AnswerTerminalType() |
| 1115 |
{ |
{ |
| 1116 |
char Tmp[50]; |
char Tmp[50]; |
| 1117 |
|
|
| 1118 |
if (ts.TerminalID<IdVT320 || !Send8BitMode) |
if (ts.TerminalID<IdVT320 || !Send8BitMode) |
| 1119 |
strncpy_s(Tmp, sizeof(Tmp),"\033[?", _TRUNCATE); |
strncpy_s(Tmp, sizeof(Tmp),"\033[?", _TRUNCATE); |
| 1120 |
else |
else |
| 1121 |
strncpy_s(Tmp, sizeof(Tmp),"\233?", _TRUNCATE); |
strncpy_s(Tmp, sizeof(Tmp),"\233?", _TRUNCATE); |
| 1122 |
|
|
| 1123 |
switch (ts.TerminalID) { |
switch (ts.TerminalID) { |
| 1124 |
case IdVT100: |
case IdVT100: |
| 1125 |
strncat_s(Tmp,sizeof(Tmp),"1;2",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"1;2",_TRUNCATE); |
| 1126 |
break; |
break; |
| 1127 |
case IdVT100J: |
case IdVT100J: |
| 1128 |
strncat_s(Tmp,sizeof(Tmp),"5;2",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"5;2",_TRUNCATE); |
| 1129 |
break; |
break; |
| 1130 |
case IdVT101: |
case IdVT101: |
| 1131 |
strncat_s(Tmp,sizeof(Tmp),"1;0",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"1;0",_TRUNCATE); |
| 1132 |
break; |
break; |
| 1133 |
case IdVT102: |
case IdVT102: |
| 1134 |
strncat_s(Tmp,sizeof(Tmp),"6",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"6",_TRUNCATE); |
| 1135 |
break; |
break; |
| 1136 |
case IdVT102J: |
case IdVT102J: |
| 1137 |
strncat_s(Tmp,sizeof(Tmp),"15",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"15",_TRUNCATE); |
| 1138 |
break; |
break; |
| 1139 |
case IdVT220J: |
case IdVT220J: |
| 1140 |
strncat_s(Tmp,sizeof(Tmp),"62;1;2;5;6;7;8",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"62;1;2;5;6;7;8",_TRUNCATE); |
| 1141 |
break; |
break; |
| 1142 |
case IdVT282: |
case IdVT282: |
| 1143 |
strncat_s(Tmp,sizeof(Tmp),"62;1;2;4;5;6;7;8;10;11",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"62;1;2;4;5;6;7;8;10;11",_TRUNCATE); |
| 1144 |
break; |
break; |
| 1145 |
case IdVT320: |
case IdVT320: |
| 1146 |
strncat_s(Tmp,sizeof(Tmp),"63;1;2;6;7;8",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"63;1;2;6;7;8",_TRUNCATE); |
| 1147 |
break; |
break; |
| 1148 |
case IdVT382: |
case IdVT382: |
| 1149 |
strncat_s(Tmp,sizeof(Tmp),"63;1;2;4;5;6;7;8;10;15",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"63;1;2;4;5;6;7;8;10;15",_TRUNCATE); |
| 1150 |
break; |
break; |
| 1151 |
case IdVT420: |
case IdVT420: |
| 1152 |
strncat_s(Tmp,sizeof(Tmp),"64;1;2;7;8;9;15;18;21",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"64;1;2;7;8;9;15;18;21",_TRUNCATE); |
| 1153 |
break; |
break; |
| 1154 |
case IdVT520: |
case IdVT520: |
| 1155 |
strncat_s(Tmp,sizeof(Tmp),"65;1;2;7;8;9;12;18;19;21;23;24;42;44;45;46",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"65;1;2;7;8;9;12;18;19;21;23;24;42;44;45;46",_TRUNCATE); |
| 1156 |
break; |
break; |
| 1157 |
case IdVT525: |
case IdVT525: |
| 1158 |
strncat_s(Tmp,sizeof(Tmp),"65;1;2;7;9;12;18;19;21;22;23;24;42;44;45;46",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"65;1;2;7;9;12;18;19;21;22;23;24;42;44;45;46",_TRUNCATE); |
| 1159 |
break; |
break; |
| 1160 |
} |
} |
| 1161 |
strncat_s(Tmp,sizeof(Tmp),"c",_TRUNCATE); |
strncat_s(Tmp,sizeof(Tmp),"c",_TRUNCATE); |
| 1162 |
|
|
| 1163 |
CommBinaryOut(&cv,Tmp,strlen(Tmp)); /* Report terminal ID */ |
CommBinaryOut(&cv,Tmp,strlen(Tmp)); /* Report terminal ID */ |
| 1164 |
} |
} |
| 1165 |
|
|
| 1166 |
void ESCSpace(BYTE b) |
void ESCSpace(BYTE b) |
| 1167 |
{ |
{ |
| 1168 |
switch (b) { |
switch (b) { |
| 1169 |
case 'F': // S7C1T |
case 'F': // S7C1T |
| 1170 |
Send8BitMode = FALSE; |
Send8BitMode = FALSE; |
| 1171 |
break; |
break; |
| 1172 |
case 'G': // S8C1T |
case 'G': // S8C1T |
| 1173 |
if (VTlevel >= 2) { |
if (VTlevel >= 2) { |
| 1174 |
Send8BitMode = TRUE; |
Send8BitMode = TRUE; |
| 1175 |
} |
} |
| 1176 |
break; |
break; |
| 1177 |
} |
} |
| 1178 |
} |
} |
| 1179 |
|
|
| 1180 |
void ESCSharp(BYTE b) |
void ESCSharp(BYTE b) |
| 1181 |
{ |
{ |
| 1182 |
switch (b) { |
switch (b) { |
| 1183 |
case '8': /* Fill screen with "E" (DECALN) */ |
case '8': /* Fill screen with "E" (DECALN) */ |
| 1184 |
BuffUpdateScroll(); |
BuffUpdateScroll(); |
| 1185 |
BuffFillWithE(); |
BuffFillWithE(); |
| 1186 |
CursorTop = 0; |
CursorTop = 0; |
| 1187 |
CursorBottom = NumOfLines-1-StatusLine; |
CursorBottom = NumOfLines-1-StatusLine; |
| 1188 |
CursorLeftM = 0; |
CursorLeftM = 0; |
| 1189 |
CursorRightM = NumOfColumns - 1; |
CursorRightM = NumOfColumns - 1; |
| 1190 |
MoveCursor(0,0); |
MoveCursor(0, 0); |
| 1191 |
ParseMode = ModeFirst; |
ParseMode = ModeFirst; |
| 1192 |
break; |
break; |
| 1193 |
} |
} |
| 1194 |
} |
} |
| 1195 |
|
|
| 1196 |
/* select double byte code set */ |
/* select double byte code set */ |
| 1197 |
void ESCDBCSSelect(BYTE b) |
void ESCDBCSSelect(BYTE b) |
| 1198 |
{ |
{ |
| 1199 |
int Dist; |
int Dist; |
| 1200 |
|
|
| 1201 |
if (ts.Language!=IdJapanese) return; |
if (ts.Language!=IdJapanese) return; |
| 1202 |
|
|
| 1203 |
switch (ICount) { |
switch (ICount) { |
| 1204 |
case 1: |
case 1: |
| 1205 |
if ((b=='@') || (b=='B')) |
if ((b=='@') || (b=='B')) |
| 1206 |
{ |
{ |
| 1207 |
Gn[0] = IdKanji; /* Kanji -> G0 */ |
Gn[0] = IdKanji; /* Kanji -> G0 */ |
| 1208 |
if ((ts.TermFlag & TF_AUTOINVOKE)!=0) |
if ((ts.TermFlag & TF_AUTOINVOKE)!=0) |
| 1209 |
Glr[0] = 0; /* G0->GL */ |
Glr[0] = 0; /* G0->GL */ |
| 1210 |
} |
} |
| 1211 |
break; |
break; |
| 1212 |
case 2: |
case 2: |
| 1213 |
/* Second intermediate char must be |
/* Second intermediate char must be |
| 1214 |
'(' or ')' or '*' or '+'. */ |
'(' or ')' or '*' or '+'. */ |
| 1215 |
Dist = (IntChar[2]-'(') & 3; /* G0 - G3 */ |
Dist = (IntChar[2]-'(') & 3; /* G0 - G3 */ |
| 1216 |
if ((b=='1') || (b=='3') || |
if ((b=='1') || (b=='3') || |
| 1217 |
(b=='@') || (b=='B')) |
(b=='@') || (b=='B')) |
| 1218 |
{ |
{ |
| 1219 |
Gn[Dist] = IdKanji; /* Kanji -> G0-3 */ |
Gn[Dist] = IdKanji; /* Kanji -> G0-3 */ |
| 1220 |
if (((ts.TermFlag & TF_AUTOINVOKE)!=0) && |
if (((ts.TermFlag & TF_AUTOINVOKE)!=0) && |
| 1221 |
(Dist==0)) |
(Dist==0)) |
| 1222 |
Glr[0] = 0; /* G0->GL */ |
Glr[0] = 0; /* G0->GL */ |
| 1223 |
} |
} |
| 1224 |
break; |
break; |
| 1225 |
} |
} |
| 1226 |
} |
} |
| 1227 |
|
|
| 1228 |
void ESCSelectCode(BYTE b) |
void ESCSelectCode(BYTE b) |
| 1229 |
{ |
{ |
| 1230 |
switch (b) { |
switch (b) { |
| 1231 |
case '0': |
case '0': |
| 1232 |
if (ts.AutoWinSwitch>0) |
if (ts.AutoWinSwitch>0) |
| 1233 |
ChangeEmu = IdTEK; /* enter TEK mode */ |
ChangeEmu = IdTEK; /* enter TEK mode */ |
| 1234 |
break; |
break; |
| 1235 |
} |
} |
| 1236 |
} |
} |
| 1237 |
|
|
| 1238 |
/* select single byte code set */ |
/* select single byte code set */ |
| 1239 |
void ESCSBCSSelect(BYTE b) |
void ESCSBCSSelect(BYTE b) |
| 1240 |
{ |
{ |
| 1241 |
int Dist; |
int Dist; |
| 1242 |
|
|
| 1243 |
|
/* Intermediate char must be '(' or ')' or '*' or '+'. */ |
| 1244 |
|
Dist = (IntChar[1]-'(') & 3; /* G0 - G3 */ |
| 1245 |
|
|
| 1246 |
/* Intermediate char must be |
switch (b) { |
| 1247 |
'(' or ')' or '*' or '+'. */ |
case '0': Gn[Dist] = IdSpecial; break; |
| 1248 |
Dist = (IntChar[1]-'(') & 3; /* G0 - G3 */ |
case '<': Gn[Dist] = IdASCII; break; |
| 1249 |
|
case '>': Gn[Dist] = IdASCII; break; |
| 1250 |
switch (b) { |
case 'A': Gn[Dist] = IdASCII; break; |
| 1251 |
case '0': Gn[Dist] = IdSpecial; break; |
case 'B': Gn[Dist] = IdASCII; break; |
| 1252 |
case '<': Gn[Dist] = IdASCII; break; |
case 'H': Gn[Dist] = IdASCII; break; |
| 1253 |
case '>': Gn[Dist] = IdASCII; break; |
case 'I': |
| 1254 |
case 'A': Gn[Dist] = IdASCII; break; |
if (ts.Language==IdJapanese) |
| 1255 |
case 'B': Gn[Dist] = IdASCII; break; |
Gn[Dist] = IdKatakana; |
| 1256 |
case 'H': Gn[Dist] = IdASCII; break; |
break; |
| 1257 |
case 'I': |
case 'J': Gn[Dist] = IdASCII; break; |
| 1258 |
if (ts.Language==IdJapanese) |
} |
| 1259 |
Gn[Dist] = IdKatakana; |
|
| 1260 |
break; |
if (((ts.TermFlag & TF_AUTOINVOKE)!=0) && (Dist==0)) |
| 1261 |
case 'J': Gn[Dist] = IdASCII; break; |
Glr[0] = 0; /* G0->GL */ |
|
} |
|
|
|
|
|
if (((ts.TermFlag & TF_AUTOINVOKE)!=0) && |
|
|
(Dist==0)) |
|
|
Glr[0] = 0; /* G0->GL */ |
|
| 1262 |
} |
} |
| 1263 |
|
|
| 1264 |
void PrnParseEscape(BYTE b) // printer mode |
void PrnParseEscape(BYTE b) // printer mode |
| 1265 |
{ |
{ |
| 1266 |
int i; |
int i; |
| 1267 |
|
|
| 1268 |
ParseMode = ModeFirst; |
ParseMode = ModeFirst; |
| 1269 |
switch (ICount) { |
switch (ICount) { |
| 1270 |
/* no intermediate char */ |
/* no intermediate char */ |
| 1271 |
case 0: |
case 0: |
| 1272 |
switch (b) { |
switch (b) { |
| 1273 |
case '[': /* CSI */ |
case '[': /* CSI */ |
| 1274 |
ClearParams(); |
ClearParams(); |
| 1275 |
FirstPrm = TRUE; |
FirstPrm = TRUE; |
| 1276 |
WriteToPrnFile(ESC,FALSE); |
WriteToPrnFile(ESC,FALSE); |
| 1277 |
WriteToPrnFile('[',FALSE); |
WriteToPrnFile('[',FALSE); |
| 1278 |
ParseMode = ModeCSI; |
ParseMode = ModeCSI; |
| 1279 |
return; |
return; |
| 1280 |
} /* end of case Icount=0 */ |
} /* end of case Icount=0 */ |
| 1281 |
break; |
break; |
| 1282 |
/* one intermediate char */ |
/* one intermediate char */ |
| 1283 |
case 1: |
case 1: |
| 1284 |
switch (IntChar[1]) { |
switch (IntChar[1]) { |
| 1285 |
case '$': |
case '$': |
| 1286 |
if (! DirectPrn) |
if (! DirectPrn) { |
| 1287 |
{ |
ESCDBCSSelect(b); |
| 1288 |
ESCDBCSSelect(b); |
return; |
| 1289 |
return; |
} |
| 1290 |
} |
break; |
| 1291 |
break; |
case '(': |
| 1292 |
case '(': |
case ')': |
| 1293 |
case ')': |
case '*': |
| 1294 |
case '*': |
case '+': |
| 1295 |
case '+': |
if (! DirectPrn) { |
| 1296 |
if (! DirectPrn) |
ESCSBCSSelect(b); |
| 1297 |
{ |
return; |
| 1298 |
ESCSBCSSelect(b); |
} |
| 1299 |
return; |
break; |
| 1300 |
} |
} |
| 1301 |
break; |
break; |
| 1302 |
} |
/* two intermediate char */ |
| 1303 |
break; |
case 2: |
| 1304 |
/* two intermediate char */ |
if ((! DirectPrn) && |
| 1305 |
case 2: |
(IntChar[1]=='$') && |
| 1306 |
if ((! DirectPrn) && |
('('<=IntChar[2]) && |
| 1307 |
(IntChar[1]=='$') && |
(IntChar[2]<='+')) |
| 1308 |
('('<=IntChar[2]) && |
{ |
| 1309 |
(IntChar[2]<='+')) |
ESCDBCSSelect(b); |
| 1310 |
{ |
return; |
| 1311 |
ESCDBCSSelect(b); |
} |
| 1312 |
return; |
break; |
| 1313 |
} |
} |
| 1314 |
break; |
// send the uninterpreted sequence to printer |
| 1315 |
} |
WriteToPrnFile(ESC,FALSE); |
| 1316 |
// send the uninterpreted sequence to printer |
for (i=1; i<=ICount; i++) |
| 1317 |
WriteToPrnFile(ESC,FALSE); |
WriteToPrnFile(IntChar[i],FALSE); |
| 1318 |
for (i=1; i<=ICount; i++) |
WriteToPrnFile(b,TRUE); |
|
WriteToPrnFile(IntChar[i],FALSE); |
|
|
WriteToPrnFile(b,TRUE); |
|
| 1319 |
} |
} |
| 1320 |
|
|
| 1321 |
void ParseEscape(BYTE b) /* b is the final char */ |
void ParseEscape(BYTE b) /* b is the final char */ |
| 1322 |
{ |
{ |
| 1323 |
if (PrinterMode) { // printer mode |
if (PrinterMode) { // printer mode |
| 1324 |
PrnParseEscape(b); |
PrnParseEscape(b); |
| 1325 |
return; |
return; |
| 1326 |
} |
} |
| 1327 |
|
|
| 1328 |
switch (ICount) { |
switch (ICount) { |
| 1329 |
/* no intermediate char */ |
case 0: /* no intermediate char */ |
| 1330 |
case 0: |
switch (b) { |
| 1331 |
switch (b) { |
case '6': // DECBI |
| 1332 |
case '6': // DECBI |
if (CursorY >= CursorTop && CursorY <= CursorBottom && |
| 1333 |
if (CursorY >= CursorTop && CursorY <= CursorBottom |
CursorX >= CursorLeftM && CursorX <= CursorRightM) { |
| 1334 |
&& CursorX >= CursorLeftM && CursorX <= CursorRightM) |
if (CursorX == CursorLeftM) |
| 1335 |
{ |
BuffScrollRight(1); |
| 1336 |
if (CursorX == CursorLeftM) |
else |
| 1337 |
BuffScrollRight(1); |
MoveCursor(CursorX-1, CursorY); |
| 1338 |
else |
} |
| 1339 |
MoveCursor(CursorX-1, CursorY); |
break; |
| 1340 |
} |
case '7': SaveCursor(); break; |
| 1341 |
break; |
case '8': RestoreCursor(); break; |
| 1342 |
case '7': SaveCursor(); break; |
case '9': // DECFI |
| 1343 |
case '8': RestoreCursor(); break; |
if (CursorY >= CursorTop && CursorY <= CursorBottom && |
| 1344 |
case '9': // DECFI |
CursorX >= CursorLeftM && CursorX <= CursorRightM) { |
| 1345 |
if (CursorY >= CursorTop && CursorY <= CursorBottom |
if (CursorX == CursorRightM) |
| 1346 |
&& CursorX >= CursorLeftM && CursorX <= CursorRightM) |
BuffScrollLeft(1); |
| 1347 |
{ |
else |
| 1348 |
if (CursorX == CursorRightM) |
MoveCursor(CursorX+1, CursorY); |
| 1349 |
BuffScrollLeft(1); |
} |
| 1350 |
else |
break; |
| 1351 |
MoveCursor(CursorX+1, CursorY); |
case '=': AppliKeyMode = TRUE; break; |
| 1352 |
} |
case '>': AppliKeyMode = FALSE; break; |
| 1353 |
break; |
case 'D': /* IND */ |
| 1354 |
case '=': AppliKeyMode = TRUE; break; |
LineFeed(0,TRUE); |
| 1355 |
case '>': AppliKeyMode = FALSE; break; |
break; |
| 1356 |
case 'D': /* IND */ |
case 'E': /* NEL */ |
| 1357 |
LineFeed(0,TRUE); |
MoveCursor(0,CursorY); |
| 1358 |
break; |
LineFeed(0,TRUE); |
| 1359 |
case 'E': /* NEL */ |
break; |
| 1360 |
MoveCursor(0,CursorY); |
case 'H': /* HTS */ |
| 1361 |
LineFeed(0,TRUE); |
if (ts.TabStopFlag & TABF_HTS7) |
| 1362 |
break; |
SetTabStop(); |
| 1363 |
case 'H': /* HTS */ |
break; |
| 1364 |
if (ts.TabStopFlag & TABF_HTS7) SetTabStop(); |
case 'M': /* RI */ |
| 1365 |
break; |
CursorUpWithScroll(); |
| 1366 |
case 'M': /* RI */ |
break; |
| 1367 |
CursorUpWithScroll(); |
case 'N': /* SS2 */ |
| 1368 |
break; |
GLtmp = 2; |
| 1369 |
case 'N': /* SS2 */ |
SSflag = TRUE; |
| 1370 |
GLtmp = 2; |
break; |
| 1371 |
SSflag = TRUE; |
case 'O': /* SS3 */ |
| 1372 |
break; |
GLtmp = 3; |
| 1373 |
case 'O': /* SS3 */ |
SSflag = TRUE; |
| 1374 |
GLtmp = 3; |
break; |
| 1375 |
SSflag = TRUE; |
case 'P': /* DCS */ |
| 1376 |
break; |
ClearParams(); |
| 1377 |
case 'P': /* DCS */ |
ESCFlag = FALSE; |
| 1378 |
ClearParams(); |
ParseMode = ModeDCS; |
| 1379 |
ESCFlag = FALSE; |
return; |
| 1380 |
ParseMode = ModeDCS; |
case 'X': /* SOS */ |
| 1381 |
return; |
case '^': /* APC */ |
| 1382 |
case 'X': /* SOS */ |
case '_': /* PM */ |
| 1383 |
case '^': /* APC */ |
ESCFlag = FALSE; |
| 1384 |
case '_': /* PM */ |
ParseMode = ModeIgnore; |
| 1385 |
ESCFlag = FALSE; |
return; |
| 1386 |
ParseMode = ModeIgnore; |
case 'Z': /* DECID */ |
| 1387 |
return; |
AnswerTerminalType(); |
| 1388 |
case 'Z': /* DECID */ |
break; |
| 1389 |
AnswerTerminalType(); |
case '[': /* CSI */ |
| 1390 |
break; |
ClearParams(); |
| 1391 |
case '[': /* CSI */ |
FirstPrm = TRUE; |
| 1392 |
ClearParams(); |
ParseMode = ModeCSI; |
| 1393 |
FirstPrm = TRUE; |
return; |
| 1394 |
ParseMode = ModeCSI; |
case '\\': break; /* ST */ |
| 1395 |
return; |
case ']': /* XTERM sequence (OSC) */ |
| 1396 |
case '\\': break; /* ST */ |
ClearParams(); |
| 1397 |
case ']': /* XTERM sequence (OSC) */ |
ParseMode = ModeXS; |
| 1398 |
ClearParams(); |
return; |
| 1399 |
ParseMode = ModeXS; |
case 'c': /* Hardware reset */ |
| 1400 |
return; |
HideStatusLine(); |
| 1401 |
case 'c': /* Hardware reset */ |
ResetTerminal(); |
| 1402 |
HideStatusLine(); |
ClearUserKey(); |
| 1403 |
ResetTerminal(); |
ClearBuffer(); |
| 1404 |
ClearUserKey(); |
if (ts.PortType==IdSerial) // reset serial port |
| 1405 |
ClearBuffer(); |
CommResetSerial(&ts, &cv, TRUE); |
| 1406 |
if (ts.PortType==IdSerial) // reset serial port |
break; |
| 1407 |
CommResetSerial(&ts, &cv, TRUE); |
case 'g': /* Visual Bell (screen original?) */ |
| 1408 |
break; |
RingBell(IdBeepVisual); |
| 1409 |
case 'g': /* Visual Bell (screen original?) */ |
break; |
| 1410 |
RingBell(IdBeepVisual); |
case 'n': Glr[0] = 2; break; /* LS2 */ |
| 1411 |
break; |
case 'o': Glr[0] = 3; break; /* LS3 */ |
| 1412 |
case 'n': Glr[0] = 2; break; /* LS2 */ |
case '|': Glr[1] = 3; break; /* LS3R */ |
| 1413 |
case 'o': Glr[0] = 3; break; /* LS3 */ |
case '}': Glr[1] = 2; break; /* LS2R */ |
| 1414 |
case '|': Glr[1] = 3; break; /* LS3R */ |
case '~': Glr[1] = 1; break; /* LS1R */ |
| 1415 |
case '}': Glr[1] = 2; break; /* LS2R */ |
} |
| 1416 |
case '~': Glr[1] = 1; break; /* LS1R */ |
break; |
| 1417 |
} /* end of case Icount=0 */ |
/* end of case Icount=0 */ |
| 1418 |
break; |
|
| 1419 |
/* one intermediate char */ |
case 1: /* one intermediate char */ |
| 1420 |
case 1: |
switch (IntChar[1]) { |
| 1421 |
switch (IntChar[1]) { |
case ' ': ESCSpace(b); break; |
| 1422 |
case ' ': ESCSpace(b); break; |
case '#': ESCSharp(b); break; |
| 1423 |
case '#': ESCSharp(b); break; |
case '$': ESCDBCSSelect(b); break; |
| 1424 |
case '$': ESCDBCSSelect(b); break; |
case '%': break; |
| 1425 |
case '%': break; |
case '(': |
| 1426 |
case '(': |
case ')': |
| 1427 |
case ')': |
case '*': |
| 1428 |
case '*': |
case '+': |
| 1429 |
case '+': |
ESCSBCSSelect(b); |
| 1430 |
ESCSBCSSelect(b); |
break; |
| 1431 |
break; |
} |
| 1432 |
} |
break; |
| 1433 |
break; |
|
| 1434 |
/* two intermediate char */ |
case 2: /* two intermediate char */ |
| 1435 |
case 2: |
if ((IntChar[1]=='$') && ('('<=IntChar[2]) && (IntChar[2]<='+')) |
| 1436 |
if ((IntChar[1]=='$') && |
ESCDBCSSelect(b); |
| 1437 |
('('<=IntChar[2]) && |
else if ((IntChar[1]=='%') && (IntChar[2]=='!')) |
| 1438 |
(IntChar[2]<='+')) |
ESCSelectCode(b); |
| 1439 |
ESCDBCSSelect(b); |
break; |
| 1440 |
else if ((IntChar[1]=='%') && |
} |
| 1441 |
(IntChar[2]=='!')) |
ParseMode = ModeFirst; |
|
ESCSelectCode(b); |
|
|
break; |
|
|
} |
|
|
ParseMode = ModeFirst; |
|
| 1442 |
} |
} |
| 1443 |
|
|
| 1444 |
void EscapeSequence(BYTE b) |
void EscapeSequence(BYTE b) |
| 3783 |
// Private Sequence |
// Private Sequence |
| 3784 |
case 'r': CSSetScrollRegion(); break; // DECSTBM |
case 'r': CSSetScrollRegion(); break; // DECSTBM |
| 3785 |
case 's': |
case 's': |
| 3786 |
if (LRMarginMode) |
if (LRMarginMode) |
| 3787 |
CSSetLRScrollRegion(); // DECSLRM |
CSSetLRScrollRegion(); // DECSLRM |
| 3788 |
else |
else |
| 3789 |
SaveCursor(); // SCP (Save cursor (ANSI.SYS/SCO?)) |
SaveCursor(); // SCP (Save cursor (ANSI.SYS/SCO?)) |
| 3790 |
break; |
break; |
| 3791 |
case 't': CSSunSequence(); break; // DECSLPP / Window manipulation(dtterm?) |
case 't': CSSunSequence(); break; // DECSLPP / Window manipulation(dtterm?) |
| 3792 |
case 'u': RestoreCursor(); break; // RCP (Restore cursor (ANSI.SYS/SCO)) |
case 'u': RestoreCursor(); break; // RCP (Restore cursor (ANSI.SYS/SCO)) |
| 3793 |
} |
} |
| 4910 |
|
|
| 4911 |
void DLESeen(BYTE b) |
void DLESeen(BYTE b) |
| 4912 |
{ |
{ |
| 4913 |
ParseMode = ModeFirst; |
ParseMode = ModeFirst; |
| 4914 |
if (((ts.FTFlag & FT_BPAUTO)!=0) && (b=='B')) |
if (((ts.FTFlag & FT_BPAUTO)!=0) && (b=='B')) |
| 4915 |
BPStart(IdBPAuto); /* Auto B-Plus activation */ |
BPStart(IdBPAuto); /* Auto B-Plus activation */ |
| 4916 |
ChangeEmu = -1; |
ChangeEmu = -1; |
| 4917 |
} |
} |
| 4918 |
|
|
| 4919 |
void CANSeen(BYTE b) |
void CANSeen(BYTE b) |
| 5302 |
unsigned char wchar[32]; |
unsigned char wchar[32]; |
| 5303 |
unsigned short cset = 0; |
unsigned short cset = 0; |
| 5304 |
|
|
|
#if 0 |
|
|
Kanji = code & 0xff00; |
|
|
PutKanji(code & 0x00ff); |
|
|
return; |
|
|
#else |
|
|
|
|
| 5305 |
wchar[0] = code & 0xff; |
wchar[0] = code & 0xff; |
| 5306 |
wchar[1] = (code >> 8) & 0xff; |
wchar[1] = (code >> 8) & 0xff; |
| 5307 |
|
|
| 5341 |
break; |
break; |
| 5342 |
} |
} |
| 5343 |
} |
} |
|
#endif |
|
| 5344 |
} |
} |
| 5345 |
|
|
| 5346 |
// UTF-8で受信データを処理する |
// UTF-8で受信データを処理する |
| 5486 |
BOOL ParseFirstRus(BYTE b) |
BOOL ParseFirstRus(BYTE b) |
| 5487 |
// returns if b is processed |
// returns if b is processed |
| 5488 |
{ |
{ |
| 5489 |
if (b>=128) |
if (b>=128) { |
| 5490 |
{ |
b = RussConv(ts.RussHost,ts.RussClient,b); |
| 5491 |
b = RussConv(ts.RussHost,ts.RussClient,b); |
PutChar(b); |
| 5492 |
PutChar(b); |
return TRUE; |
| 5493 |
return TRUE; |
} |
| 5494 |
} |
return FALSE; |
|
return FALSE; |
|
| 5495 |
} |
} |
| 5496 |
|
|
| 5497 |
void ParseFirst(BYTE b) |
void ParseFirst(BYTE b) |
| 5565 |
|
|
| 5566 |
int VTParse() |
int VTParse() |
| 5567 |
{ |
{ |
| 5568 |
BYTE b; |
BYTE b; |
| 5569 |
int c; |
int c; |
| 5570 |
|
|
| 5571 |
c = CommRead1Byte(&cv,&b); |
c = CommRead1Byte(&cv,&b); |
| 5572 |
|
|
| 5573 |
if (c==0) return 0; |
if (c==0) return 0; |
| 5574 |
|
|
| 5575 |
CaretOff(); |
CaretOff(); |
| 5576 |
UpdateCaretPosition(FALSE); // 非アクティブの場合のみ再描画する |
UpdateCaretPosition(FALSE); // 非アクティブの場合のみ再描画する |
| 5577 |
|
|
| 5578 |
ChangeEmu = 0; |
ChangeEmu = 0; |
| 5579 |
|
|
| 5580 |
/* Get Device Context */ |
/* Get Device Context */ |
| 5581 |
DispInitDC(); |
DispInitDC(); |
| 5582 |
|
|
| 5583 |
LockBuffer(); |
LockBuffer(); |
| 5584 |
|
|
| 5585 |
while ((c>0) && (ChangeEmu==0)) |
while ((c>0) && (ChangeEmu==0)) { |
| 5586 |
{ |
if (DebugFlag!=DEBUG_FLAG_NONE) |
| 5587 |
if (DebugFlag!=DEBUG_FLAG_NONE) |
PutDebugChar(b); |
| 5588 |
PutDebugChar(b); |
else { |
| 5589 |
else { |
switch (ParseMode) { |
| 5590 |
switch (ParseMode) { |
case ModeFirst: |
| 5591 |
case ModeFirst: ParseFirst(b); break; |
ParseFirst(b); |
| 5592 |
case ModeESC: EscapeSequence(b); break; |
break; |
| 5593 |
case ModeDCS: DeviceControl(b); break; |
case ModeESC: |
| 5594 |
case ModeDCUserKey: DCUserKey(b); break; |
EscapeSequence(b); |
| 5595 |
case ModeSOS: IgnoreString(b); break; |
break; |
| 5596 |
case ModeCSI: ControlSequence(b); break; |
case ModeDCS: |
| 5597 |
case ModeXS: XSequence(b); break; |
DeviceControl(b); |
| 5598 |
case ModeDLE: DLESeen(b); break; |
break; |
| 5599 |
case ModeCAN: CANSeen(b); break; |
case ModeDCUserKey: |
| 5600 |
case ModeIgnore: IgnoreString(b); break; |
DCUserKey(b); |
| 5601 |
default: |
break; |
| 5602 |
ParseMode = ModeFirst; |
case ModeSOS: |
| 5603 |
ParseFirst(b); |
IgnoreString(b); |
| 5604 |
} |
break; |
| 5605 |
} |
case ModeCSI: |
| 5606 |
|
ControlSequence(b); |
| 5607 |
|
break; |
| 5608 |
|
case ModeXS: |
| 5609 |
|
XSequence(b); |
| 5610 |
|
break; |
| 5611 |
|
case ModeDLE: |
| 5612 |
|
DLESeen(b); |
| 5613 |
|
break; |
| 5614 |
|
case ModeCAN: |
| 5615 |
|
CANSeen(b); |
| 5616 |
|
break; |
| 5617 |
|
case ModeIgnore: |
| 5618 |
|
IgnoreString(b); |
| 5619 |
|
break; |
| 5620 |
|
default: |
| 5621 |
|
ParseMode = ModeFirst; |
| 5622 |
|
ParseFirst(b); |
| 5623 |
|
} |
| 5624 |
|
} |
| 5625 |
|
|
| 5626 |
PrevCharacter = b; // memorize previous character for AUTO CR/LF-receive mode |
PrevCharacter = b; // memorize previous character for AUTO CR/LF-receive mode |
| 5627 |
|
|
| 5628 |
if (ChangeEmu==0) |
if (ChangeEmu==0) |
| 5629 |
c = CommRead1Byte(&cv,&b); |
c = CommRead1Byte(&cv,&b); |
| 5630 |
} |
} |
| 5631 |
|
|
| 5632 |
BuffUpdateScroll(); |
BuffUpdateScroll(); |
| 5633 |
|
|
| 5634 |
BuffSetCaretWidth(); |
BuffSetCaretWidth(); |
| 5635 |
UnlockBuffer(); |
UnlockBuffer(); |
| 5636 |
|
|
| 5637 |
/* release device context */ |
/* release device context */ |
| 5638 |
DispReleaseDC(); |
DispReleaseDC(); |
| 5639 |
|
|
| 5640 |
CaretOn(); |
CaretOn(); |
| 5641 |
|
|
| 5642 |
if (ChangeEmu > 0) ParseMode = ModeFirst; |
if (ChangeEmu > 0) |
| 5643 |
return ChangeEmu; |
ParseMode = ModeFirst; |
| 5644 |
|
|
| 5645 |
|
return ChangeEmu; |
| 5646 |
} |
} |
| 5647 |
|
|
| 5648 |
int MakeLocatorReportStr(char *buff, size_t buffsize, int event, int x, int y) { |
int MakeLocatorReportStr(char *buff, size_t buffsize, int event, int x, int y) { |
| 5649 |
if (x < 0) { |
if (x < 0) { |
| 5650 |
return _snprintf_s_l(buff, buffsize, _TRUNCATE, "%d;%d&w", CLocale, event, ButtonStat); |
return _snprintf_s_l(buff, buffsize, _TRUNCATE, "%d;%d&w", CLocale, event, ButtonStat); |
| 5651 |
} |
} |
| 5652 |
else { |
else { |
| 5653 |
return _snprintf_s_l(buff, buffsize, _TRUNCATE, "%d;%d;%d;%d;0&w", CLocale, event, ButtonStat, y, x); |
return _snprintf_s_l(buff, buffsize, _TRUNCATE, "%d;%d;%d;%d;0&w", CLocale, event, ButtonStat, y, x); |
| 5654 |
} |
} |
| 5655 |
} |
} |
| 5656 |
|
|
| 5657 |
BOOL DecLocatorReport(int Event, int Button) { |
BOOL DecLocatorReport(int Event, int Button) { |
| 5658 |
int x, y, MaxX, MaxY, len = 0; |
int x, y, MaxX, MaxY, len = 0; |
| 5659 |
char buff[24]; |
char buff[24]; |
| 5660 |
|
|
| 5661 |
|
if (DecLocatorFlag & DecLocatorPixel) { |
| 5662 |
|
x = LastX + 1; |
| 5663 |
|
y = LastY + 1; |
| 5664 |
|
DispConvScreenToWin(NumOfColumns+1, NumOfLines+1, &MaxX, &MaxY); |
| 5665 |
|
if (x < 1 || x > MaxX || y < 1 || y > MaxY) { |
| 5666 |
|
x = -1; |
| 5667 |
|
} |
| 5668 |
|
} |
| 5669 |
|
else { |
| 5670 |
|
DispConvWinToScreen(LastX, LastY, &x, &y, NULL); |
| 5671 |
|
x++; y++; |
| 5672 |
|
if (x < 1 || x > NumOfColumns || y < 1 || y > NumOfLines) { |
| 5673 |
|
x = -1; |
| 5674 |
|
} |
| 5675 |
|
} |
| 5676 |
|
|
| 5677 |
if (DecLocatorFlag & DecLocatorPixel) { |
switch (Event) { |
| 5678 |
x = LastX + 1; |
case IdMouseEventCurStat: |
| 5679 |
y = LastY + 1; |
if (MouseReportMode == IdMouseTrackDECELR) { |
| 5680 |
DispConvScreenToWin(NumOfColumns+1, NumOfLines+1, &MaxX, &MaxY); |
len = MakeLocatorReportStr(buff, sizeof(buff), 1, x, y); |
| 5681 |
if (x < 1 || x > MaxX || y < 1 || y > MaxY) { |
} |
| 5682 |
x = -1; |
else { |
| 5683 |
} |
len = _snprintf_s_l(buff, sizeof(buff), _TRUNCATE, "0&w", CLocale); |
| 5684 |
} |
} |
| 5685 |
else { |
break; |
| 5686 |
DispConvWinToScreen(LastX, LastY, &x, &y, NULL); |
|
| 5687 |
x++; y++; |
case IdMouseEventBtnDown: |
| 5688 |
if (x < 1 || x > NumOfColumns || y < 1 || y > NumOfLines) { |
if (DecLocatorFlag & DecLocatorButtonDown) { |
| 5689 |
x = -1; |
len = MakeLocatorReportStr(buff, sizeof(buff), Button*2+2, x, y); |
| 5690 |
} |
} |
| 5691 |
} |
break; |
| 5692 |
|
|
| 5693 |
switch (Event) { |
case IdMouseEventBtnUp: |
| 5694 |
case IdMouseEventCurStat: |
if (DecLocatorFlag & DecLocatorButtonUp) { |
| 5695 |
if (MouseReportMode == IdMouseTrackDECELR) { |
len = MakeLocatorReportStr(buff, sizeof(buff), Button*2+3, x, y); |
| 5696 |
len = MakeLocatorReportStr(buff, sizeof(buff), 1, x, y); |
} |
| 5697 |
} |
break; |
| 5698 |
else { |
|
| 5699 |
len = _snprintf_s_l(buff, sizeof(buff), _TRUNCATE, "0&w", CLocale); |
case IdMouseEventMove: |
| 5700 |
} |
if (DecLocatorFlag & DecLocatorFiltered) { |
| 5701 |
break; |
if (y < FilterTop || y > FilterBottom || x < FilterLeft || x > FilterRight) { |
| 5702 |
|
len = MakeLocatorReportStr(buff, sizeof(buff), 10, x, y); |
| 5703 |
case IdMouseEventBtnDown: |
DecLocatorFlag &= ~DecLocatorFiltered; |
| 5704 |
if (DecLocatorFlag & DecLocatorButtonDown) { |
} |
| 5705 |
len = MakeLocatorReportStr(buff, sizeof(buff), Button*2+2, x, y); |
} |
| 5706 |
} |
break; |
| 5707 |
break; |
} |
| 5708 |
|
|
| 5709 |
case IdMouseEventBtnUp: |
if (len == 0) { |
| 5710 |
if (DecLocatorFlag & DecLocatorButtonUp) { |
return FALSE; |
| 5711 |
len = MakeLocatorReportStr(buff, sizeof(buff), Button*2+3, x, y); |
} |
| 5712 |
} |
|
| 5713 |
break; |
SendCSIstr(buff, len); |
| 5714 |
|
|
| 5715 |
case IdMouseEventMove: |
if (DecLocatorFlag & DecLocatorOneShot) { |
| 5716 |
if (DecLocatorFlag & DecLocatorFiltered) { |
MouseReportMode = IdMouseTrackNone; |
| 5717 |
if (y < FilterTop || y > FilterBottom || x < FilterLeft || x > FilterRight) { |
} |
| 5718 |
len = MakeLocatorReportStr(buff, sizeof(buff), 10, x, y); |
return TRUE; |
|
DecLocatorFlag &= ~DecLocatorFiltered; |
|
|
} |
|
|
} |
|
|
break; |
|
|
} |
|
|
|
|
|
if (len == 0) { |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
SendCSIstr(buff, len); |
|
|
|
|
|
if (DecLocatorFlag & DecLocatorOneShot) { |
|
|
MouseReportMode = IdMouseTrackNone; |
|
|
} |
|
|
return TRUE; |
|
| 5719 |
} |
} |
| 5720 |
|
|
| 5721 |
#define MOUSE_POS_LIMIT (255 - 32) |
#define MOUSE_POS_LIMIT (255 - 32) |
| 5722 |
#define MOUSE_POS_EXT_LIMIT (2047 - 32) |
#define MOUSE_POS_EXT_LIMIT (2047 - 32) |
| 5723 |
|
|
| 5724 |
int MakeMouseReportStr(char *buff, size_t buffsize, int mb, int x, int y) { |
int MakeMouseReportStr(char *buff, size_t buffsize, int mb, int x, int y) { |
| 5725 |
char tmpx[3], tmpy[3]; |
char tmpx[3], tmpy[3]; |
| 5726 |
|
|
| 5727 |
|
switch (MouseReportExtMode) { |
| 5728 |
|
case IdMouseTrackExtNone: |
| 5729 |
|
if (x >= MOUSE_POS_LIMIT) x = MOUSE_POS_LIMIT; |
| 5730 |
|
if (y >= MOUSE_POS_LIMIT) y = MOUSE_POS_LIMIT; |
| 5731 |
|
return _snprintf_s_l(buff, buffsize, _TRUNCATE, "M%c%c%c", CLocale, mb+32, x+32, y+32); |
| 5732 |
|
break; |
| 5733 |
|
|
| 5734 |
|
case IdMouseTrackExtUTF8: |
| 5735 |
|
if (x >= MOUSE_POS_EXT_LIMIT) x = MOUSE_POS_EXT_LIMIT; |
| 5736 |
|
if (y >= MOUSE_POS_EXT_LIMIT) y = MOUSE_POS_EXT_LIMIT; |
| 5737 |
|
x += 32; |
| 5738 |
|
y += 32; |
| 5739 |
|
if (x < 128) { |
| 5740 |
|
tmpx[0] = x; |
| 5741 |
|
tmpx[1] = 0; |
| 5742 |
|
} |
| 5743 |
|
else { |
| 5744 |
|
tmpx[0] = (x >> 6) & 0x1f | 0xc0; |
| 5745 |
|
tmpx[1] = x & 0x3f | 0x80; |
| 5746 |
|
tmpx[2] = 0; |
| 5747 |
|
} |
| 5748 |
|
if (y < 128) { |
| 5749 |
|
tmpy[0] = y; |
| 5750 |
|
tmpy[1] = 0; |
| 5751 |
|
} |
| 5752 |
|
else { |
| 5753 |
|
tmpy[0] = (x >> 6) & 0x1f | 0xc0; |
| 5754 |
|
tmpy[1] = y & 0x3f | 0x80; |
| 5755 |
|
tmpy[2] = 0; |
| 5756 |
|
} |
| 5757 |
|
return _snprintf_s_l(buff, buffsize, _TRUNCATE, "M%c%s%s", CLocale, mb+32, tmpx, tmpy); |
| 5758 |
|
break; |
| 5759 |
|
|
| 5760 |
switch (MouseReportExtMode) { |
case IdMouseTrackExtSGR: |
| 5761 |
case IdMouseTrackExtNone: |
return _snprintf_s_l(buff, buffsize, _TRUNCATE, "<%d;%d;%d%c", CLocale, mb&0x7f, x, y, (mb&0x80)?'m':'M'); |
| 5762 |
if (x >= MOUSE_POS_LIMIT) x = MOUSE_POS_LIMIT; |
break; |
| 5763 |
if (y >= MOUSE_POS_LIMIT) y = MOUSE_POS_LIMIT; |
|
| 5764 |
return _snprintf_s_l(buff, buffsize, _TRUNCATE, "M%c%c%c", CLocale, mb+32, x+32, y+32); |
case IdMouseTrackExtURXVT: |
| 5765 |
break; |
return _snprintf_s_l(buff, buffsize, _TRUNCATE, "%d;%d;%dM", CLocale, mb+32, x, y); |
| 5766 |
|
break; |
| 5767 |
case IdMouseTrackExtUTF8: |
} |
| 5768 |
if (x >= MOUSE_POS_EXT_LIMIT) x = MOUSE_POS_EXT_LIMIT; |
buff[0] = 0; |
| 5769 |
if (y >= MOUSE_POS_EXT_LIMIT) y = MOUSE_POS_EXT_LIMIT; |
return 0; |
|
x += 32; |
|
|
y += 32; |
|
|
if (x < 128) { |
|
|
tmpx[0] = x; |
|
|
tmpx[1] = 0; |
|
|
} |
|
|
else { |
|
|
tmpx[0] = (x >> 6) & 0x1f | 0xc0; |
|
|
tmpx[1] = x & 0x3f | 0x80; |
|
|
tmpx[2] = 0; |
|
|
} |
|
|
if (y < 128) { |
|
|
tmpy[0] = y; |
|
|
tmpy[1] = 0; |
|
|
} |
|
|
else { |
|
|
tmpy[0] = (x >> 6) & 0x1f | 0xc0; |
|
|
tmpy[1] = y & 0x3f | 0x80; |
|
|
tmpy[2] = 0; |
|
|
} |
|
|
return _snprintf_s_l(buff, buffsize, _TRUNCATE, "M%c%s%s", CLocale, mb+32, tmpx, tmpy); |
|
|
break; |
|
|
|
|
|
case IdMouseTrackExtSGR: |
|
|
return _snprintf_s_l(buff, buffsize, _TRUNCATE, "<%d;%d;%d%c", CLocale, mb&0x7f, x, y, (mb&0x80)?'m':'M'); |
|
|
break; |
|
|
|
|
|
case IdMouseTrackExtURXVT: |
|
|
return _snprintf_s_l(buff, buffsize, _TRUNCATE, "%d;%d;%dM", CLocale, mb+32, x, y); |
|
|
break; |
|
|
} |
|
|
buff[0] = 0; |
|
|
return 0; |
|
| 5770 |
} |
} |
| 5771 |
|
|
| 5772 |
BOOL MouseReport(int Event, int Button, int Xpos, int Ypos) { |
BOOL MouseReport(int Event, int Button, int Xpos, int Ypos) { |
| 5773 |
char Report[32]; |
char Report[32]; |
| 5774 |
int x, y, len, modifier; |
int x, y, len, modifier; |
| 5775 |
static int LastSendX = -1, LastSendY = -1, LastButton = IdButtonRelease; |
static int LastSendX = -1, LastSendY = -1, LastButton = IdButtonRelease; |
|
|
|
|
len = 0; |
|
|
|
|
|
switch (Event) { |
|
|
case IdMouseEventBtnDown: |
|
|
ButtonStat |= (8>>(Button+1)); |
|
|
break; |
|
|
case IdMouseEventBtnUp: |
|
|
ButtonStat &= ~(8>>(Button+1)); |
|
|
break; |
|
|
} |
|
|
LastX = Xpos; |
|
|
LastY = Ypos; |
|
|
|
|
|
if (MouseReportMode == IdMouseTrackNone) |
|
|
return FALSE; |
|
|
|
|
|
if (ts.DisableMouseTrackingByCtrl && ControlKey()) |
|
|
return FALSE; |
|
|
|
|
|
if (MouseReportMode == IdMouseTrackDECELR) |
|
|
return DecLocatorReport(Event, Button); |
|
|
|
|
|
DispConvWinToScreen(Xpos, Ypos, &x, &y, NULL); |
|
|
x++; y++; |
|
|
|
|
|
if (x < 1) x = 1; |
|
|
if (y < 1) y = 1; |
|
|
|
|
|
if (ShiftKey()) |
|
|
modifier = 4; |
|
|
else |
|
|
modifier = 0; |
|
|
|
|
|
if (ControlKey()) |
|
|
modifier |= 8; |
|
|
|
|
|
if (AltKey()) |
|
|
modifier |= 16; |
|
|
|
|
|
modifier = (ShiftKey()?4:0) | (AltKey()?8:0) | (ControlKey()?16:0); |
|
|
|
|
|
switch (Event) { |
|
|
case IdMouseEventBtnDown: |
|
|
switch (MouseReportMode) { |
|
|
case IdMouseTrackX10: |
|
|
len = MakeMouseReportStr(Report, sizeof Report, Button, x, y); |
|
|
break; |
|
|
|
|
|
case IdMouseTrackVT200: |
|
|
case IdMouseTrackBtnEvent: |
|
|
case IdMouseTrackAllEvent: |
|
|
len = MakeMouseReportStr(Report, sizeof Report, Button | modifier, x, y); |
|
|
LastSendX = x; |
|
|
LastSendY = y; |
|
|
LastButton = Button; |
|
|
break; |
|
|
|
|
|
case IdMouseTrackNetTerm: |
|
|
len = _snprintf_s_l(Report, sizeof Report, _TRUNCATE, "\033}%d,%d\r", CLocale, y, x); |
|
|
CommBinaryOut(&cv, Report, len); |
|
|
return TRUE; |
|
| 5776 |
|
|
| 5777 |
case IdMouseTrackVT200Hl: /* not supported yet */ |
len = 0; |
|
default: |
|
|
return FALSE; |
|
|
} |
|
|
break; |
|
|
|
|
|
case IdMouseEventBtnUp: |
|
|
switch (MouseReportMode) { |
|
|
case IdMouseTrackVT200: |
|
|
case IdMouseTrackBtnEvent: |
|
|
case IdMouseTrackAllEvent: |
|
|
if (MouseReportExtMode == IdMouseTrackExtSGR) { |
|
|
modifier |= 128; |
|
|
} |
|
|
else { |
|
|
Button = IdButtonRelease; |
|
|
} |
|
|
len = MakeMouseReportStr(Report, sizeof Report, Button | modifier, x, y); |
|
|
LastSendX = x; |
|
|
LastSendY = y; |
|
|
LastButton = IdButtonRelease; |
|
|
break; |
|
|
|
|
|
case IdMouseTrackX10: /* nothing to do */ |
|
|
case IdMouseTrackNetTerm: /* nothing to do */ |
|
|
return TRUE; |
|
| 5778 |
|
|
| 5779 |
case IdMouseTrackVT200Hl: /* not supported yet */ |
switch (Event) { |
| 5780 |
default: |
case IdMouseEventBtnDown: |
| 5781 |
return FALSE; |
ButtonStat |= (8>>(Button+1)); |
| 5782 |
} |
break; |
| 5783 |
break; |
case IdMouseEventBtnUp: |
| 5784 |
|
ButtonStat &= ~(8>>(Button+1)); |
| 5785 |
case IdMouseEventMove: |
break; |
| 5786 |
switch (MouseReportMode) { |
} |
| 5787 |
case IdMouseTrackBtnEvent: |
LastX = Xpos; |
| 5788 |
if (LastButton == 3) { |
LastY = Ypos; |
| 5789 |
return FALSE; |
|
| 5790 |
} |
if (MouseReportMode == IdMouseTrackNone) |
| 5791 |
/* FALLTHROUGH */ |
return FALSE; |
| 5792 |
case IdMouseTrackAllEvent: |
|
| 5793 |
if (x == LastSendX && y == LastSendY) { |
if (ts.DisableMouseTrackingByCtrl && ControlKey()) |
| 5794 |
return FALSE; |
return FALSE; |
| 5795 |
} |
|
| 5796 |
len = MakeMouseReportStr(Report, sizeof Report, LastButton | modifier | 32, x, y); |
if (MouseReportMode == IdMouseTrackDECELR) |
| 5797 |
LastSendX = x; |
return DecLocatorReport(Event, Button); |
| 5798 |
LastSendY = y; |
|
| 5799 |
break; |
DispConvWinToScreen(Xpos, Ypos, &x, &y, NULL); |
| 5800 |
|
x++; y++; |
| 5801 |
case IdMouseTrackVT200Hl: /* not supported yet */ |
|
| 5802 |
case IdMouseTrackX10: /* nothing to do */ |
if (x < 1) x = 1; |
| 5803 |
case IdMouseTrackVT200: /* nothing to do */ |
if (y < 1) y = 1; |
| 5804 |
case IdMouseTrackNetTerm: /* nothing to do */ |
|
| 5805 |
default: |
if (ShiftKey()) |
| 5806 |
return FALSE; |
modifier = 4; |
| 5807 |
} |
else |
| 5808 |
break; |
modifier = 0; |
| 5809 |
|
|
| 5810 |
case IdMouseEventWheel: |
if (ControlKey()) |
| 5811 |
switch (MouseReportMode) { |
modifier |= 8; |
| 5812 |
case IdMouseTrackVT200: |
|
| 5813 |
case IdMouseTrackBtnEvent: |
if (AltKey()) |
| 5814 |
case IdMouseTrackAllEvent: |
modifier |= 16; |
| 5815 |
len = MakeMouseReportStr(Report, sizeof Report, Button | modifier | 64, x, y); |
|
| 5816 |
break; |
modifier = (ShiftKey()?4:0) | (AltKey()?8:0) | (ControlKey()?16:0); |
|
|
|
|
case IdMouseTrackX10: /* nothing to do */ |
|
|
case IdMouseTrackVT200Hl: /* not supported yet */ |
|
|
case IdMouseTrackNetTerm: /* nothing to do */ |
|
|
return FALSE; |
|
|
} |
|
|
break; |
|
|
} |
|
| 5817 |
|
|
| 5818 |
if (len == 0) |
switch (Event) { |
| 5819 |
return FALSE; |
case IdMouseEventBtnDown: |
| 5820 |
|
switch (MouseReportMode) { |
| 5821 |
|
case IdMouseTrackX10: |
| 5822 |
|
len = MakeMouseReportStr(Report, sizeof Report, Button, x, y); |
| 5823 |
|
break; |
| 5824 |
|
|
| 5825 |
|
case IdMouseTrackVT200: |
| 5826 |
|
case IdMouseTrackBtnEvent: |
| 5827 |
|
case IdMouseTrackAllEvent: |
| 5828 |
|
len = MakeMouseReportStr(Report, sizeof Report, Button | modifier, x, y); |
| 5829 |
|
LastSendX = x; |
| 5830 |
|
LastSendY = y; |
| 5831 |
|
LastButton = Button; |
| 5832 |
|
break; |
| 5833 |
|
|
| 5834 |
SendCSIstr(Report, len); |
case IdMouseTrackNetTerm: |
| 5835 |
return TRUE; |
len = _snprintf_s_l(Report, sizeof Report, _TRUNCATE, "\033}%d,%d\r", CLocale, y, x); |
| 5836 |
|
CommBinaryOut(&cv, Report, len); |
| 5837 |
|
return TRUE; |
| 5838 |
|
|
| 5839 |
|
case IdMouseTrackVT200Hl: /* not supported yet */ |
| 5840 |
|
default: |
| 5841 |
|
return FALSE; |
| 5842 |
|
} |
| 5843 |
|
break; |
| 5844 |
|
|
| 5845 |
|
case IdMouseEventBtnUp: |
| 5846 |
|
switch (MouseReportMode) { |
| 5847 |
|
case IdMouseTrackVT200: |
| 5848 |
|
case IdMouseTrackBtnEvent: |
| 5849 |
|
case IdMouseTrackAllEvent: |
| 5850 |
|
if (MouseReportExtMode == IdMouseTrackExtSGR) { |
| 5851 |
|
modifier |= 128; |
| 5852 |
|
} |
| 5853 |
|
else { |
| 5854 |
|
Button = IdButtonRelease; |
| 5855 |
|
} |
| 5856 |
|
len = MakeMouseReportStr(Report, sizeof Report, Button | modifier, x, y); |
| 5857 |
|
LastSendX = x; |
| 5858 |
|
LastSendY = y; |
| 5859 |
|
LastButton = IdButtonRelease; |
| 5860 |
|
break; |
| 5861 |
|
|
| 5862 |
|
case IdMouseTrackX10: /* nothing to do */ |
| 5863 |
|
case IdMouseTrackNetTerm: /* nothing to do */ |
| 5864 |
|
return TRUE; |
| 5865 |
|
|
| 5866 |
|
case IdMouseTrackVT200Hl: /* not supported yet */ |
| 5867 |
|
default: |
| 5868 |
|
return FALSE; |
| 5869 |
|
} |
| 5870 |
|
break; |
| 5871 |
|
|
| 5872 |
|
case IdMouseEventMove: |
| 5873 |
|
switch (MouseReportMode) { |
| 5874 |
|
case IdMouseTrackBtnEvent: |
| 5875 |
|
if (LastButton == 3) { |
| 5876 |
|
return FALSE; |
| 5877 |
|
} |
| 5878 |
|
/* FALLTHROUGH */ |
| 5879 |
|
case IdMouseTrackAllEvent: |
| 5880 |
|
if (x == LastSendX && y == LastSendY) { |
| 5881 |
|
return FALSE; |
| 5882 |
|
} |
| 5883 |
|
len = MakeMouseReportStr(Report, sizeof Report, LastButton | modifier | 32, x, y); |
| 5884 |
|
LastSendX = x; |
| 5885 |
|
LastSendY = y; |
| 5886 |
|
break; |
| 5887 |
|
|
| 5888 |
|
case IdMouseTrackVT200Hl: /* not supported yet */ |
| 5889 |
|
case IdMouseTrackX10: /* nothing to do */ |
| 5890 |
|
case IdMouseTrackVT200: /* nothing to do */ |
| 5891 |
|
case IdMouseTrackNetTerm: /* nothing to do */ |
| 5892 |
|
default: |
| 5893 |
|
return FALSE; |
| 5894 |
|
} |
| 5895 |
|
break; |
| 5896 |
|
|
| 5897 |
|
case IdMouseEventWheel: |
| 5898 |
|
switch (MouseReportMode) { |
| 5899 |
|
case IdMouseTrackVT200: |
| 5900 |
|
case IdMouseTrackBtnEvent: |
| 5901 |
|
case IdMouseTrackAllEvent: |
| 5902 |
|
len = MakeMouseReportStr(Report, sizeof Report, Button | modifier | 64, x, y); |
| 5903 |
|
break; |
| 5904 |
|
|
| 5905 |
|
case IdMouseTrackX10: /* nothing to do */ |
| 5906 |
|
case IdMouseTrackVT200Hl: /* not supported yet */ |
| 5907 |
|
case IdMouseTrackNetTerm: /* nothing to do */ |
| 5908 |
|
return FALSE; |
| 5909 |
|
} |
| 5910 |
|
break; |
| 5911 |
|
} |
| 5912 |
|
|
| 5913 |
|
if (len == 0) |
| 5914 |
|
return FALSE; |
| 5915 |
|
|
| 5916 |
|
SendCSIstr(Report, len); |
| 5917 |
|
return TRUE; |
| 5918 |
} |
} |
| 5919 |
|
|
| 5920 |
void FocusReport(BOOL focus) { |
void FocusReport(BOOL focus) { |
| 5921 |
if (!FocusReportMode) |
if (!FocusReportMode) |
| 5922 |
return; |
return; |
| 5923 |
|
|
| 5924 |
if (focus) { |
if (focus) { |
| 5925 |
// Focus In |
// Focus In |
| 5926 |
SendCSIstr("I", 0); |
SendCSIstr("I", 0); |
| 5927 |
} else { |
} else { |
| 5928 |
// Focus Out |
// Focus Out |
| 5929 |
SendCSIstr("O", 0); |
SendCSIstr("O", 0); |
| 5930 |
} |
} |
| 5931 |
} |
} |
| 5932 |
|
|
| 5933 |
void VisualBell() { |
void VisualBell() { |
| 5987 |
} |
} |
| 5988 |
|
|
| 5989 |
void ChangeTerminalID() { |
void ChangeTerminalID() { |
| 5990 |
switch (ts.TerminalID) { |
switch (ts.TerminalID) { |
| 5991 |
case IdVT220J: |
case IdVT220J: |
| 5992 |
case IdVT282: |
case IdVT282: |
| 5993 |
VTlevel = 2; |
VTlevel = 2; |
| 5994 |
break; |
break; |
| 5995 |
case IdVT320: |
case IdVT320: |
| 5996 |
case IdVT382: |
case IdVT382: |
| 5997 |
VTlevel = 3; |
VTlevel = 3; |
| 5998 |
break; |
break; |
| 5999 |
case IdVT420: |
case IdVT420: |
| 6000 |
VTlevel = 4; |
VTlevel = 4; |
| 6001 |
break; |
break; |
| 6002 |
case IdVT520: |
case IdVT520: |
| 6003 |
case IdVT525: |
case IdVT525: |
| 6004 |
VTlevel = 5; |
VTlevel = 5; |
| 6005 |
break; |
break; |
| 6006 |
default: |
default: |
| 6007 |
VTlevel = 1; |
VTlevel = 1; |
| 6008 |
} |
} |
| 6009 |
|
|
| 6010 |
if (VTlevel == 1) { |
if (VTlevel == 1) { |
| 6011 |
Send8BitMode = FALSE; |
Send8BitMode = FALSE; |
| 6012 |
} |
} |
| 6013 |
else { |
else { |
| 6014 |
Send8BitMode = ts.Send8BitCtrl; |
Send8BitMode = ts.Send8BitCtrl; |
| 6015 |
} |
} |
| 6016 |
} |
} |