SpyFormUnit.cpp 4.93 KiB
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "MainFormUnit.h"
#include "SpyFormUnit.h"
#include "sbbsdefs.h"
#define SPYBUF_LEN 10000
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Emulvt"
#pragma resource "*.dfm"
TSpyForm *SpyForm;
//---------------------------------------------------------------------------
__fastcall TSpyForm::TSpyForm(TComponent* Owner)
: TForm(Owner)
{
Width=MainForm->SpyTerminalWidth;
Height=MainForm->SpyTerminalHeight;
KeyboardActive->Checked=MainForm->SpyTerminalKeyboardActive;
Terminal = new TEmulVT(this);
Terminal->Parent=this;
Terminal->Align=alClient;
Terminal->OnKeyPress=FormKeyPress;
Terminal->OnMouseUp=FormMouseUp;
}
bool strip_ansi(char* str)
{
char* p=str;
char newstr[SPYBUF_LEN];
int newlen=0;
bool ff=false;
for(p=str;*p && newlen<(sizeof(newstr)-1);) {
switch(*p) {
case BEL: /* bell */
Beep();
break;
case BS: /* backspace */
if(newlen)
newlen--;
break;
case FF: /* form feed */
newlen=0;
ff=true;
break;
case ESC:
if(*(p+1)=='[') { /* ANSI */
p+=2;
if(!strncmp(p,"2J",2)) {
newlen=0;
ff=true;
}
while(*p && !isalpha(*p)) p++;
}
break;
case CR:
if(*(p+1)!=LF) {
while(newlen) {
newlen--;
if(newstr[newlen]==LF) {
newlen++;
break;
}
}
break;
} /* Fall through */