Skip to content
Snippets Groups Projects
Commit 7362baae authored by rswindell's avatar rswindell
Browse files

Changed from menu to toolbar.

Changed Terminal cursor to reflect KeyboardActive status.
Terminal is now default ActiveControl.
parent e1118957
Branches
Tags
No related merge requests found
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "MainFormUnit.h" #include "MainFormUnit.h"
#include "SpyFormUnit.h" #include "SpyFormUnit.h"
#include "sbbsdefs.h"
#define SPYBUF_LEN 10000 #define SPYBUF_LEN 10000
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -58,60 +57,7 @@ __fastcall TSpyForm::TSpyForm(TComponent* Owner) ...@@ -58,60 +57,7 @@ __fastcall TSpyForm::TSpyForm(TComponent* Owner)
Terminal->Align=alClient; Terminal->Align=alClient;
Terminal->OnKeyPress=FormKeyPress; Terminal->OnKeyPress=FormKeyPress;
Terminal->OnMouseUp=FormMouseUp; Terminal->OnMouseUp=FormMouseUp;
} ActiveControl=Terminal;
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 */
default:
newstr[newlen++]=*p;
break;
}
if(*p==0)
break;
p++;
}
newstr[newlen]=0;
strcpy(str,newstr);
return(ff);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TSpyForm::SpyTimerTick(TObject *Sender) void __fastcall TSpyForm::SpyTimerTick(TObject *Sender)
...@@ -124,19 +70,10 @@ void __fastcall TSpyForm::SpyTimerTick(TObject *Sender) ...@@ -124,19 +70,10 @@ void __fastcall TSpyForm::SpyTimerTick(TObject *Sender)
rd=RingBufRead(*outbuf,buf,sizeof(buf)-1); rd=RingBufRead(*outbuf,buf,sizeof(buf)-1);
if(rd) { if(rd) {
#if 0
buf[rd]=0;
if(strip_ansi(buf))
Log->Lines->Clear();
Log->SelLength=0;
Log->SelStart=Log->Lines->Text.Length();
Log->SelText=AnsiString(buf);
#else
Terminal->WriteBuffer(buf,rd); Terminal->WriteBuffer(buf,rd);
#endif Timer->Interval=1;
Timer->Interval=100;
} else } else
Timer->Interval=500; Timer->Interval=250;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TSpyForm::FormShow(TObject *Sender) void __fastcall TSpyForm::FormShow(TObject *Sender)
...@@ -153,6 +90,7 @@ void __fastcall TSpyForm::FormShow(TObject *Sender) ...@@ -153,6 +90,7 @@ void __fastcall TSpyForm::FormShow(TObject *Sender)
Terminal->Clear(); Terminal->Clear();
Terminal->WriteStr("*** Synchronet Local Spy ***\r\n\r\n"); Terminal->WriteStr("*** Synchronet Local Spy ***\r\n\r\n");
Terminal->WriteStr("ANSI Terminal Emulation:"+CopyRight+"\r\n\r\n"); Terminal->WriteStr("ANSI Terminal Emulation:"+CopyRight+"\r\n\r\n");
KeyboardActiveClick(Sender);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -187,12 +125,17 @@ void __fastcall TSpyForm::FormKeyPress(TObject *Sender, char &Key) ...@@ -187,12 +125,17 @@ void __fastcall TSpyForm::FormKeyPress(TObject *Sender, char &Key)
{ {
if(KeyboardActive->Checked && inbuf!=NULL && *inbuf!=NULL) if(KeyboardActive->Checked && inbuf!=NULL && *inbuf!=NULL)
RingBufWrite(*inbuf,&Key,1); RingBufWrite(*inbuf,&Key,1);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TSpyForm::KeyboardActiveClick(TObject *Sender) void __fastcall TSpyForm::KeyboardActiveClick(TObject *Sender)
{ {
KeyboardActive->Checked=!KeyboardActive->Checked; KeyboardActive->Checked=!KeyboardActive->Checked;
if(KeyboardActive->Checked)
Terminal->Cursor=crIBeam;
else
Terminal->Cursor=crDefault;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
......
...@@ -37,7 +37,6 @@ object SpyForm: TSpyForm ...@@ -37,7 +37,6 @@ object SpyForm: TSpyForm
000FF800000FFC00001FFE00001FE0000001C000000180000001800000018000 000FF800000FFC00001FFE00001FE0000001C000000180000001800000018000
00018000000180000001FC00001FFC00001FFE00001FFC00000FF800000FF800 00018000000180000001FC00001FFC00001FFE00001FFC00000FF800000FF800
001FF800003FFC180C7FFE380EFFFFF80FFFFFF80FFFFFF80FFFFFFFFFFF} 001FF800003FFC180C7FFE380EFFFFF80FFFFFF80FFFFFF80FFFFFFFFFFF}
Menu = SpyMenu
OldCreateOrder = False OldCreateOrder = False
Position = poDefaultPosOnly Position = poDefaultPosOnly
OnClose = FormClose OnClose = FormClose
...@@ -46,6 +45,31 @@ object SpyForm: TSpyForm ...@@ -46,6 +45,31 @@ object SpyForm: TSpyForm
OnShow = FormShow OnShow = FormShow
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 13 TextHeight = 13
object ToolBar: TPanel
Left = 0
Top = 0
Width = 576
Height = 21
Align = alTop
BevelOuter = bvNone
TabOrder = 0
object FontButton: TSpeedButton
Left = 128
Top = 0
Width = 81
Height = 19
Action = ChangeFont
Flat = True
end
object KeyboardActiveCheckBox: TCheckBox
Left = 8
Top = 0
Width = 113
Height = 19
Action = KeyboardActive
TabOrder = 0
end
end
object Timer: TTimer object Timer: TTimer
Enabled = False Enabled = False
Interval = 500 Interval = 500
...@@ -196,19 +220,6 @@ object SpyForm: TSpyForm ...@@ -196,19 +220,6 @@ object SpyForm: TSpyForm
FFFFFFFF00000000FFFFFFFF905C3F0300000000000000000000000000000000 FFFFFFFF00000000FFFFFFFF905C3F0300000000000000000000000000000000
000000000000} 000000000000}
end end
object SpyMenu: TMainMenu
Left = 288
Top = 24
object SettingsMenuItem: TMenuItem
Caption = 'Settings'
object KeyboardActiveMenuItem: TMenuItem
Action = KeyboardActive
end
object FontMenuItem: TMenuItem
Action = ChangeFont
end
end
end
object PopupMenu: TPopupMenu object PopupMenu: TPopupMenu
Left = 80 Left = 80
Top = 104 Top = 104
...@@ -223,11 +234,13 @@ object SpyForm: TSpyForm ...@@ -223,11 +234,13 @@ object SpyForm: TSpyForm
Left = 328 Left = 328
Top = 24 Top = 24
object KeyboardActive: TAction object KeyboardActive: TAction
Caption = 'Keyboard Active' Caption = 'Active Keyboard'
Hint = 'Activate Local Keyboard'
OnExecute = KeyboardActiveClick OnExecute = KeyboardActiveClick
end end
object ChangeFont: TAction object ChangeFont: TAction
Caption = 'Font...' Caption = 'Change Font'
Hint = 'Change Font'
OnExecute = ChangeFontClick OnExecute = ChangeFontClick
end end
end end
......
...@@ -49,22 +49,22 @@ ...@@ -49,22 +49,22 @@
#include <ToolWin.hpp> #include <ToolWin.hpp>
#include <Menus.hpp> #include <Menus.hpp>
#include <ActnList.hpp> #include <ActnList.hpp>
#include <Buttons.hpp>
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
class TSpyForm : public TForm class TSpyForm : public TForm
{ {
__published: // IDE-managed Components __published: // IDE-managed Components
TTimer *Timer; TTimer *Timer;
TImageList *ImageList; TImageList *ImageList;
TMainMenu *SpyMenu;
TMenuItem *SettingsMenuItem;
TMenuItem *KeyboardActiveMenuItem;
TMenuItem *FontMenuItem;
TPopupMenu *PopupMenu; TPopupMenu *PopupMenu;
TMenuItem *KeyboardActivePopupMenuItem; TMenuItem *KeyboardActivePopupMenuItem;
TActionList *ActionList; TActionList *ActionList;
TAction *KeyboardActive; TAction *KeyboardActive;
TAction *ChangeFont; TAction *ChangeFont;
TMenuItem *FontPopupMenuItem; TMenuItem *FontPopupMenuItem;
TPanel *ToolBar;
TSpeedButton *FontButton;
TCheckBox *KeyboardActiveCheckBox;
void __fastcall SpyTimerTick(TObject *Sender); void __fastcall SpyTimerTick(TObject *Sender);
void __fastcall FormShow(TObject *Sender); void __fastcall FormShow(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action); void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment