From c2f795e4ef2fd3165880262ff58f5d77b4edb75b Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sat, 19 Jan 2019 18:31:46 +0100 Subject: [PATCH] ide, launcher: Move to new directory --- BlitzBasicIDE/about.cpp | 118 -- BlitzBasicIDE/blitzide.dsp | 262 ---- BlitzBasicIDE/blitzide.vcxproj | 261 ---- BlitzBasicIDE/blitzide.vcxproj.filters | 87 -- BlitzBasicIDE/funclist.cpp | 72 -- BlitzBasicIDE/htmlhelp.cpp | 38 - BlitzBasicIDE/libs.cpp | 124 -- BlitzBasicIDE/mainframe.cpp | 939 -------------- BlitzBasicIDE/prefs.cpp | 195 --- BlitzBasicIDE/tabber.cpp | 163 --- BlitzBasicLauncher/bblaunch.cpp | 80 -- BlitzBasicLauncher/bblaunch.dsp | 179 --- BlitzBasicLauncher/bblaunch.vcxproj | 252 ---- BlitzBasicLauncher/checkdx.cpp | 343 ------ BlitzBasicLauncher/checkie.cpp | 24 - .../IDE (logo, no code) 32.ico | Bin ide/about.cpp | 123 ++ {BlitzBasicIDE => ide}/about.h | 0 {BlitzBasicIDE => ide}/b3dlogo.bmp | Bin {BlitzBasicIDE => ide}/blitzide.cpp | 31 +- {BlitzBasicIDE => ide}/blitzide.h | 0 {BlitzBasicIDE => ide}/blitzide.rc | 0 {BlitzBasicIDE => ide}/editor.cpp | 679 ++++++---- {BlitzBasicIDE => ide}/editor.h | 0 ide/funclist.cpp | 78 ++ {BlitzBasicIDE => ide}/funclist.h | 0 ide/htmlhelp.cpp | 40 + {BlitzBasicIDE => ide}/htmlhelp.h | 0 ide/libs.cpp | 137 +++ {BlitzBasicIDE => ide}/libs.h | 0 ide/mainframe.cpp | 1096 +++++++++++++++++ {BlitzBasicIDE => ide}/mainframe.h | 0 ide/prefs.cpp | 227 ++++ {BlitzBasicIDE => ide}/prefs.h | 0 {BlitzBasicIDE => ide}/resource.h | 0 {BlitzBasicIDE => ide}/stdafx.cpp | 1 - {BlitzBasicIDE => ide}/stdafx.h | 0 ide/tabber.cpp | 211 ++++ {BlitzBasicIDE => ide}/tabber.h | 0 launcher/bblaunch.cpp | 87 ++ {BlitzBasicLauncher => launcher}/bblaunch.ico | Bin {BlitzBasicLauncher => launcher}/bblaunch.rc | 0 .../blitzide.prefs | 0 launcher/checkdx.cpp | 336 +++++ {BlitzBasicLauncher => launcher}/checkdx.h | 0 launcher/checkie.cpp | 26 + {BlitzBasicLauncher => launcher}/checkie.h | 0 {BlitzBasicLauncher => launcher}/demo.html | 0 {BlitzBasicLauncher => launcher}/resource.h | 0 stdutil/stdutil.hpp | 4 +- 50 files changed, 2797 insertions(+), 3416 deletions(-) delete mode 100644 BlitzBasicIDE/about.cpp delete mode 100644 BlitzBasicIDE/blitzide.dsp delete mode 100644 BlitzBasicIDE/blitzide.vcxproj delete mode 100644 BlitzBasicIDE/blitzide.vcxproj.filters delete mode 100644 BlitzBasicIDE/funclist.cpp delete mode 100644 BlitzBasicIDE/htmlhelp.cpp delete mode 100644 BlitzBasicIDE/libs.cpp delete mode 100644 BlitzBasicIDE/mainframe.cpp delete mode 100644 BlitzBasicIDE/prefs.cpp delete mode 100644 BlitzBasicIDE/tabber.cpp delete mode 100644 BlitzBasicLauncher/bblaunch.cpp delete mode 100644 BlitzBasicLauncher/bblaunch.dsp delete mode 100644 BlitzBasicLauncher/bblaunch.vcxproj delete mode 100644 BlitzBasicLauncher/checkdx.cpp delete mode 100644 BlitzBasicLauncher/checkie.cpp rename {BlitzBasicIDE => ide}/IDE (logo, no code) 32.ico (100%) create mode 100644 ide/about.cpp rename {BlitzBasicIDE => ide}/about.h (100%) rename {BlitzBasicIDE => ide}/b3dlogo.bmp (100%) rename {BlitzBasicIDE => ide}/blitzide.cpp (51%) rename {BlitzBasicIDE => ide}/blitzide.h (100%) rename {BlitzBasicIDE => ide}/blitzide.rc (100%) rename {BlitzBasicIDE => ide}/editor.cpp (56%) rename {BlitzBasicIDE => ide}/editor.h (100%) create mode 100644 ide/funclist.cpp rename {BlitzBasicIDE => ide}/funclist.h (100%) create mode 100644 ide/htmlhelp.cpp rename {BlitzBasicIDE => ide}/htmlhelp.h (100%) create mode 100644 ide/libs.cpp rename {BlitzBasicIDE => ide}/libs.h (100%) create mode 100644 ide/mainframe.cpp rename {BlitzBasicIDE => ide}/mainframe.h (100%) create mode 100644 ide/prefs.cpp rename {BlitzBasicIDE => ide}/prefs.h (100%) rename {BlitzBasicIDE => ide}/resource.h (100%) rename {BlitzBasicIDE => ide}/stdafx.cpp (98%) rename {BlitzBasicIDE => ide}/stdafx.h (100%) create mode 100644 ide/tabber.cpp rename {BlitzBasicIDE => ide}/tabber.h (100%) create mode 100644 launcher/bblaunch.cpp rename {BlitzBasicLauncher => launcher}/bblaunch.ico (100%) rename {BlitzBasicLauncher => launcher}/bblaunch.rc (100%) rename {BlitzBasicLauncher => launcher}/blitzide.prefs (100%) create mode 100644 launcher/checkdx.cpp rename {BlitzBasicLauncher => launcher}/checkdx.h (100%) create mode 100644 launcher/checkie.cpp rename {BlitzBasicLauncher => launcher}/checkie.h (100%) rename {BlitzBasicLauncher => launcher}/demo.html (100%) rename {BlitzBasicLauncher => launcher}/resource.h (100%) diff --git a/BlitzBasicIDE/about.cpp b/BlitzBasicIDE/about.cpp deleted file mode 100644 index 04be734..0000000 --- a/BlitzBasicIDE/about.cpp +++ /dev/null @@ -1,118 +0,0 @@ - -#include "stdafx.h" -#include "prefs.h" -#include "libs.h" -#include "resource.h" - -#include - -char _credits[]= -"\r\n" -"Programming and design: Mark Sibly\r\n\r\n" -"Documentation: Mark Sibly, Simon Harrison, Paul Gerfen, Shane Monroe and the Blitz Doc Team\r\n\r\n" -"Testing and support: James Boyd, Simon Armstrong and the Blitz Dev Team\r\n\r\n" -"Image loader courtesy of FreeImage by Floris van den berg\r\n\r\n" -"Please visit www.blitzbasic.com for all your Blitz related needs!"; - -/* -char _credits[]= -"\r\n" -"Programming and Design: Mark Sibly\r\n\r\n" -"Documentation: Simon Harrison; Simon Armstrong; Mark Sibly\r\n\r\n" -"Many thanks to: Claire Foley; Janet Sibly; Rick, Kay and Robbie Keam; " -"James Boyd; the Blitz Dev Team\r\n\r\n" -"Image loader courtesy of FreeImage by Floris van den Berg\r\n\r\n" -"Please visit www.blitzbasic.com for all your Blitz related needs!"; -*/ - -class Dialog : public CDialog{ - bool _quit; -public: - Dialog():_quit(false){} - - afx_msg void OnOK(){ - _quit=true; - } - - void wait(){ - _quit=false; - MSG msg; - while( !_quit && GetMessage( &msg,0,0,0 ) ){ - if( !AfxGetApp()->PreTranslateMessage(&msg) ){ - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } - } - EndDialog(0); - } - - void wait( int n ){ - int _expire=(int)timeGetTime()+n; - for(;;){ - int tm=_expire-(int)timeGetTime(); - if( tm<0 ) tm=0; - MsgWaitForMultipleObjects( 0,0,false,tm,QS_ALLEVENTS ); - - MSG msg; - if( PeekMessage( &msg,0,0,0,PM_REMOVE ) ){ - if( !AfxGetApp()->PreTranslateMessage(&msg) ){ - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } - } - if( !tm ) return; - } - } -}; - -void aboutBlitz( bool delay ){ - - AfxGetMainWnd()->EnableWindow(0); - - Dialog about; - - about.Create( IDD_ABOUT ); - - string credits; - - credits+=_credits; - - about.GetDlgItem( IDC_CREDITS )->SetWindowText( credits.c_str() ); - - int ide_ver=VERSION&0xffff; - int lnk_ver=linker_ver&0xffff; - int run_ver=runtime_ver&0xffff; - string ide_v=itoa(ide_ver/1000)+"."+itoa(ide_ver%1000); - string lnk_v=itoa(lnk_ver/1000)+"."+itoa(lnk_ver%1000); - string run_v=itoa(run_ver/1000)+"."+itoa(run_ver%1000); - - string t=""; - - t+="BlitzNext"; - - about.GetDlgItem( IDC_PRODUCT )->SetWindowText( t.c_str() ); - - t="IDE V"+ide_v+" Linker V"+lnk_v+" Runtime V"+run_v; - - about.GetDlgItem( IDC_VERSION )->SetWindowText( t.c_str() ); - -#ifdef DEMO - - if( delay ){ - about.GetDlgItem( IDOK )->ShowWindow( SW_HIDE ); - about.GetDlgItem( IDC_PROGRESS1 )->ShowWindow( SW_SHOW ); - for( int k=0;k<100;++k ){ - ((CProgressCtrl*)about.GetDlgItem( IDC_PROGRESS1 ))->SetPos( k+1 ); - about.wait( 50 ); - } - about.GetDlgItem( IDOK )->ShowWindow( SW_SHOW ); - } - -#endif - - about.GetDlgItem( IDC_PROGRESS1 )->ShowWindow( SW_HIDE ); - about.wait(); - about.EndDialog(0); - AfxGetMainWnd()->EnableWindow(1); -} - diff --git a/BlitzBasicIDE/blitzide.dsp b/BlitzBasicIDE/blitzide.dsp deleted file mode 100644 index 56a751f..0000000 --- a/BlitzBasicIDE/blitzide.dsp +++ /dev/null @@ -1,262 +0,0 @@ -# Microsoft Developer Studio Project File - Name="blitzide" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=blitzide - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "blitzide.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "blitzide.mak" CFG="blitzide - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "blitzide - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "blitzide - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE "blitzide - Win32 Blitz3DRelease" (based on "Win32 (x86) Application") -!MESSAGE "blitzide - Win32 Blitz2DRelease" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "blitzide - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 1 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O1 /Ob2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 winmm.lib /nologo /subsystem:windows /machine:I386 /force /out:"..\blitzbasic\bin\ide.exe" -# SUBTRACT LINK32 /debug /nodefaultlib - -!ELSEIF "$(CFG)" == "blitzide - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 1 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c -# SUBTRACT CPP /Gy -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ddraw.lib dinput.lib dsound.lib dplayx.lib dxguid.lib winmm.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /nodefaultlib:"afxmem.obj" /force /out:"..\blitzbasic\bin\ide.exe" /fixed:no -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "blitzide - Win32 Blitz3DRelease" - -# PROP BASE Use_MFC 1 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "blitzide___Win32_Blitz3DRelease" -# PROP BASE Intermediate_Dir "blitzide___Win32_Blitz3DRelease" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 1 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "blitzide___Win32_Blitz3DRelease" -# PROP Intermediate_Dir "blitzide___Win32_Blitz3DRelease" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O1 /Ob2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /G6 /Gz /MT /W3 /GX /O1 /D "_WINDOWS" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "PRO" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" /d "PRO" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 winmm.lib /nologo /subsystem:windows /machine:I386 /force /out:"..\blitzbasic\bin\ide.exe" -# SUBTRACT BASE LINK32 /debug /nodefaultlib -# ADD LINK32 winmm.lib /nologo /subsystem:windows /machine:I386 /force /out:"../_release/bin/ide.exe" -# SUBTRACT LINK32 /debug /nodefaultlib - -!ELSEIF "$(CFG)" == "blitzide - Win32 Blitz2DRelease" - -# PROP BASE Use_MFC 1 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "blitzide___Win32_Blitz2DRelease" -# PROP BASE Intermediate_Dir "blitzide___Win32_Blitz2DRelease" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 1 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "blitzide___Win32_Blitz2DRelease" -# PROP Intermediate_Dir "blitzide___Win32_Blitz2DRelease" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O1 /Ob2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 winmm.lib /nologo /subsystem:windows /machine:I386 /force /out:"..\..\release\blitz3drelease\bin\ide.exe" -# SUBTRACT BASE LINK32 /debug /nodefaultlib -# ADD LINK32 winmm.lib /nologo /subsystem:windows /machine:I386 /force /out:"..\..\release\blitz2drelease\bin\ide.exe" -# SUBTRACT LINK32 /debug /nodefaultlib - -!ENDIF - -# Begin Target - -# Name "blitzide - Win32 Release" -# Name "blitzide - Win32 Debug" -# Name "blitzide - Win32 Blitz3DRelease" -# Name "blitzide - Win32 Blitz2DRelease" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\about.cpp -# End Source File -# Begin Source File - -SOURCE=.\blitzide.cpp -# End Source File -# Begin Source File - -SOURCE=.\blitzide.rc -# End Source File -# Begin Source File - -SOURCE=.\editor.cpp -# End Source File -# Begin Source File - -SOURCE=.\funclist.cpp -# End Source File -# Begin Source File - -SOURCE=.\htmlhelp.cpp -# End Source File -# Begin Source File - -SOURCE=.\libs.cpp -# End Source File -# Begin Source File - -SOURCE=.\mainframe.cpp -# End Source File -# Begin Source File - -SOURCE=.\prefs.cpp -# End Source File -# Begin Source File - -SOURCE=.\stdafx.cpp -# ADD CPP /Yc"stdafx.h" -# End Source File -# Begin Source File - -SOURCE=.\tabber.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\about.h -# End Source File -# Begin Source File - -SOURCE=.\blitzide.h -# End Source File -# Begin Source File - -SOURCE=.\editor.h -# End Source File -# Begin Source File - -SOURCE=.\funclist.h -# End Source File -# Begin Source File - -SOURCE=.\htmlhelp.h -# End Source File -# Begin Source File - -SOURCE=.\libs.h -# End Source File -# Begin Source File - -SOURCE=.\mainframe.h -# End Source File -# Begin Source File - -SOURCE=.\prefs.h -# End Source File -# Begin Source File - -SOURCE=.\stdafx.h -# End Source File -# Begin Source File - -SOURCE=.\tabber.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\b3dlogo.bmp -# End Source File -# Begin Source File - -SOURCE=.\bplogo.bmp -# End Source File -# Begin Source File - -SOURCE=".\IDE (logo, no code) 32.ico" -# End Source File -# End Target -# End Project diff --git a/BlitzBasicIDE/blitzide.vcxproj b/BlitzBasicIDE/blitzide.vcxproj deleted file mode 100644 index 0b2e1a5..0000000 --- a/BlitzBasicIDE/blitzide.vcxproj +++ /dev/null @@ -1,261 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - RelWithDebInfo - Win32 - - - - - - MFCProj - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D} - IDE - 10.0.17763.0 - - - - Application - v141 - false - MultiByte - true - - - Application - v140_xp - false - MultiByte - - - Application - v140_xp - false - MultiByte - - - - - - - - - - - - - - - - - - - ..\#Build\$(ProjectName)\$(Configuration)-$(PlatformTarget)\ - ..\#Intermediate\$(ProjectName)\$(Configuration)-$(PlatformTarget)\ - false - C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;$(IncludePath) - C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86;$(LibraryPath) - - - ..\#Build\$(ProjectName)\$(Configuration)-$(PlatformTarget)\ - ..\#Intermediate\$(ProjectName)\$(Configuration)-$(PlatformTarget)\ - false - C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;$(IncludePath) - C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86;$(LibraryPath) - - - ..\#Build\$(ProjectName)\$(Configuration)-$(PlatformTarget)\ - ..\#Intermediate\$(ProjectName)\$(Configuration)-$(PlatformTarget)\ - false - C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;$(IncludePath) - C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86;$(LibraryPath) - - - - MultiThreadedDebugDLL - false - true - true - _AFXDLL;_CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) - Default - false - Level3 - StdCall - Async - false - - - true - _DEBUG;%(PreprocessorDefinitions) - .\Debug\blitzide.tlb - true - Win32 - - - 0x0409 - _DEBUG;%(PreprocessorDefinitions) - - - true - .\Debug\blitzide.bsc - - - true - true - Windows - afxmem.obj;%(IgnoreSpecificDefaultLibraries) - ..\blitzbasic\bin\ide.exe - /FIXED:NO - ddraw.lib;dinput.lib;dsound.lib;dplayx.lib;dxguid.lib;winmm.lib;%(AdditionalDependencies) - - - - - MultiThreadedDLL - false - true - Level3 - _AFXDLL;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) - true - false - StdCall - Async - false - Full - AnySuitable - true - Speed - true - true - 4Bytes - false - true - StreamingSIMDExtensions2 - Fast - false - ProgramDatabase - false - - - false - true - - - true - NDEBUG;%(PreprocessorDefinitions) - .\Release\blitzide.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\Release\blitzide.bsc - - - true - false - Windows - false - ..\blitzbasic\bin\ide.exe - winmm.lib;%(AdditionalDependencies) - - - - - MultiThreadedDLL - false - true - Level3 - _AFXDLL;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) - true - false - StdCall - Async - false - - - true - NDEBUG;%(PreprocessorDefinitions) - .\Release\blitzide.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\Release\blitzide.bsc - - - true - false - Windows - false - ..\blitzbasic\bin\ide.exe - winmm.lib;%(AdditionalDependencies) - - - - - - - - - - - - - Create - stdafx.h - Create - Create - stdafx.h - stdafx.h - - - - - - - - - - - - - - - - - - - - - - - - - - {3e355353-96d8-4aaf-bf95-8e6ca0d4b1ba} - false - - - - - - \ No newline at end of file diff --git a/BlitzBasicIDE/blitzide.vcxproj.filters b/BlitzBasicIDE/blitzide.vcxproj.filters deleted file mode 100644 index 37d85ba..0000000 --- a/BlitzBasicIDE/blitzide.vcxproj.filters +++ /dev/null @@ -1,87 +0,0 @@ - - - - - {9c2049a6-f32f-4502-857f-a4ae3ffa8d7d} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {a084b10a-802f-4ff7-b0fa-c89f7b661e28} - h;hpp;hxx;hm;inl - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - \ No newline at end of file diff --git a/BlitzBasicIDE/funclist.cpp b/BlitzBasicIDE/funclist.cpp deleted file mode 100644 index 59a5f7e..0000000 --- a/BlitzBasicIDE/funclist.cpp +++ /dev/null @@ -1,72 +0,0 @@ - -#include "stdafx.h" -#include "funclist.h" - -IMPLEMENT_DYNAMIC( FuncList,CListCtrl ) -BEGIN_MESSAGE_MAP( FuncList,CListCtrl ) - ON_WM_CREATE() - ON_NOTIFY_REFLECT( NM_CLICK,nm_click ) -END_MESSAGE_MAP() - -FuncList::FuncList(): -listener(0){ -} - -void FuncList::setListener( FuncListListener *l ){ - listener=l; -} - -int FuncList::OnCreate( LPCREATESTRUCT cs ){ - CListCtrl::OnCreate( cs ); - - return 0; -} - -void FuncList::nm_click( NMHDR *nmhdr,LRESULT *result ){ - NMLISTVIEW *lv=(NMLISTVIEW*)nmhdr; - - int k=0; - Funcs::iterator it; - for( it=funcs.begin();it!=funcs.end() && kiItem;++k,++it ){ - } - if( it!=funcs.end() ){ - listener->funcSelected( *it ); - } - *result=0; -} - -void FuncList::clear(){ - funcs.clear(); - DeleteAllItems(); -} - -void FuncList::insert( int line,const string &func ){ - int n=0; - Funcs::iterator it; - for( it=funcs.begin();it!=funcs.end() && line>*it;++n,++it ){ - } - if( it!=funcs.end() && line==*it ){ - SetItemText( n,0,func.c_str() ); - return; - } - it=funcs.insert( it,line ); - InsertItem( n,func.c_str() ); -} - -void FuncList::remove( int begin,int end ){ - int n=0; - Funcs::iterator it; - for( it=funcs.begin();it!=funcs.end() && *it=begin ) *it+=offset; - } -} diff --git a/BlitzBasicIDE/htmlhelp.cpp b/BlitzBasicIDE/htmlhelp.cpp deleted file mode 100644 index 5f5a2cb..0000000 --- a/BlitzBasicIDE/htmlhelp.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -#include "stdafx.h" -#include "htmlhelp.h" -#include "mainframe.h" -#include "libs.h" - -IMPLEMENT_DYNAMIC( HtmlHelp, CHtmlView ) -BEGIN_MESSAGE_MAP( HtmlHelp, CHtmlView ) - ON_WM_ERASEBKGND() -END_MESSAGE_MAP() - -string HtmlHelp::getTitle(){ - return title; -} - -void HtmlHelp::OnTitleChange( LPCTSTR t ){ - listener->helpTitleChange( this,title=t ); -} - -void HtmlHelp::OnBeforeNavigate2( LPCTSTR url,DWORD flags,LPCTSTR target,CByteArray& posted,LPCTSTR headers,BOOL* cancel ){ - string t( url ); - int attr=GetFileAttributes( url );if( attr==-1 ) attr=0; - if( (attr & FILE_ATTRIBUTE_DIRECTORY) || - (t.rfind( ".bb" )+3==t.size()) || - (isMediaFile( t )) ){ - - listener->helpOpen( this,t ); - *cancel=true; - return; - - } - *cancel=false; -} - -BOOL HtmlHelp::OnEraseBkgnd( CDC *dc ){ - return true; -} - diff --git a/BlitzBasicIDE/libs.cpp b/BlitzBasicIDE/libs.cpp deleted file mode 100644 index f172200..0000000 --- a/BlitzBasicIDE/libs.cpp +++ /dev/null @@ -1,124 +0,0 @@ - -#include "stdafx.h" -#include "libs.h" -#include "editor.h" -#include "blitzide.h" - -static map keyhelps; - -int linker_ver,runtime_ver; - -static string execProc( const string &proc ){ - HANDLE rd,wr; - - SECURITY_ATTRIBUTES sa={sizeof(sa),0,true}; - - if( CreatePipe( &rd,&wr,&sa,0 ) ){ - STARTUPINFO si={sizeof(si)}; - si.dwFlags=STARTF_USESTDHANDLES; - si.hStdOutput=si.hStdError=wr; - PROCESS_INFORMATION pi={0}; - if( CreateProcess( 0,(char*)proc.c_str(),0,0,true,DETACHED_PROCESS,0,0,&si,&pi ) ){ - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - CloseHandle( wr ); - - string t; - char *buf=new char[1024]; - for(;;){ - unsigned long sz; - int n=ReadFile( rd,buf,1024,&sz,0 ); - if( !n && GetLastError()==ERROR_BROKEN_PIPE ) break; - if( !n ){ t="";break; } - if( !sz ) break; - t+=string( buf,sz ); - } - delete[] buf; - CloseHandle(rd); - return t; - } - CloseHandle( rd ); - CloseHandle( wr ); - } - AfxMessageBox( (proc+" failed").c_str() ); - ExitProcess(0); - return ""; -} - -int version( string vers,string t ){ - t+=" version:"; - int n=vers.find( t );n+=t.size(); - int maj=atoi( vers.substr(n) );n=vers.find( '.',n )+1; - int min=atoi( vers.substr(n) ); - return maj*100+min; -} - -void initLibs(){ - - string valid=execProc( prefs.homeDir+"/bin/blitzcc -q" ); - if( valid.size() ){ - AfxMessageBox( ("Compiler environment error: "+valid).c_str() ); - ExitProcess(0); - } - - string vers=tolower( execProc( prefs.homeDir+"/bin/blitzcc -v" ) ); - linker_ver=version( vers,"linker" ); - runtime_ver=version( vers,"runtime" ); - - //generate keywords! - string kws=execProc( prefs.homeDir+"/bin/blitzcc +k" ); - - if( !kws.size() ){ - AfxMessageBox( "Error generating keywords" ); - ExitProcess(0); - } - - int pos=0,n; - while( (n=kws.find( '\n',pos ))!=string::npos ){ - string t=kws.substr( pos,n-pos-1 ); - for( int q=0;(q=t.find('\r',q))!=string::npos; ) t=t.replace( q,1,"" ); - - string help=t; - int i=t.find(' '); - if( i!=string::npos ){ - t=t.substr(0,i);if( !t.size() ){ - AfxMessageBox( "Error in keywords" ); - ExitProcess(0); - } - if( !isalnum(t[t.size()-1]) ) t=t.substr(0,t.size()-1); - } - - Editor::addKeyword(t); - keyhelps[t]=help; - pos=n+1; - } -} - -string quickHelp( const string &kw ){ - map::const_iterator it=keyhelps.find(kw); - return it==keyhelps.end() ? "" : it->second; -} - -bool isMediaFile( const string &f ){ - -#ifndef PRO - return false; -#endif - - static char *exts[]={ - "bmp","jpg","png","tga","iff","pcx", - "wav","mid","mp3","mod","s3m","xm","it","rmi","sgt", - "x","3ds",0 - }; - - int i=f.rfind( '.' ); - if( i==string::npos || i+1==f.size() ) return false; - string ext=f.substr( i+1 ); - char **p=exts; - while( const char *e=*p++ ){ - string t(e); - if( i+t.size()+1!=f.size() ) continue; - if( ext==t ) return true; - } - return false; -} diff --git a/BlitzBasicIDE/mainframe.cpp b/BlitzBasicIDE/mainframe.cpp deleted file mode 100644 index 6435af9..0000000 --- a/BlitzBasicIDE/mainframe.cpp +++ /dev/null @@ -1,939 +0,0 @@ - -#include "stdafx.h" -#include "resource.h" -#include "mainframe.h" -#include "about.h" -#include "blitzide.h" -#include "libs.h" - -#include - -#include -#include - -IMPLEMENT_DYNAMIC( MainFrame,CFrameWnd ) -BEGIN_MESSAGE_MAP( MainFrame,CFrameWnd ) - ON_WM_CREATE() - ON_WM_CLOSE() - ON_WM_DESTROY() - ON_WM_ERASEBKGND() - ON_WM_SIZE() - ON_WM_ACTIVATE() - - ON_COMMAND( Inew,fileNew ) - ON_COMMAND( ID_OPEN,fileOpen ) - ON_COMMAND( ID_SAVE,fileSave ) - ON_COMMAND( ID_SAVEAS,fileSaveAs ) - ON_COMMAND( ID_SAVEALL,fileSaveAll ) - ON_COMMAND( ID_PRINT,filePrint ) - ON_COMMAND( ID_CLOSE,fileClose ) - ON_COMMAND( ID_CLOSEALL,fileCloseAll ) - ON_COMMAND( ID_EXIT,fileExit ) - ON_COMMAND_RANGE( 333,343,fileRecent ) - ON_COMMAND( ID_CUT,editCut ) - ON_COMMAND( ID_COPY,editCopy ) - ON_COMMAND( ID_PASTE,editPaste ) - ON_COMMAND( ID_SELECTALL,editSelectAll ) - ON_COMMAND( ID_FIND,editFind ) - ON_COMMAND( ID_FINDNEXT,editFindNext ) - ON_COMMAND( ID_REPLACE,editReplace ) - ON_COMMAND( ID_CTRLTAB,ctrlTab ) - ON_COMMAND( ID_CTRLSHIFTTAB,ctrlShiftTab ) - ON_COMMAND( ID_ESCAPE,escape ) - ON_COMMAND( ID_QUICKHELP,quick_Help ) - - ON_COMMAND( ID_EXECUTE,programExecute ) - ON_COMMAND( ID_REEXECUTE,programReExecute ) - ON_COMMAND( ID_COMPILE,programCompile ) - ON_COMMAND( ID_PUBLISH,programPublish ) - ON_COMMAND( ID_COMMANDLINE,programCommandLine ) - ON_COMMAND( ID_DEBUG,programDebug ) - - ON_COMMAND( ID_HOME,helpHome ) - ON_COMMAND( ID_BACK,helpBack ) - ON_COMMAND( ID_FORWARD,helpForward ) - ON_COMMAND( ID_ABOUT,helpAbout ) - - ON_UPDATE_COMMAND_UI( Inew,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_OPEN,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_SAVE,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_SAVEAS,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_SAVEALL,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_PRINT,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_CLOSE,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_CLOSEALL,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_CUT,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_COPY,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_PASTE,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_SELECTALL,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_FIND,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_FINDNEXT,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_REPLACE,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_EXECUTE,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_REEXECUTE,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_COMPILE,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_PUBLISH,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_COMMANDLINE,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_DEBUG,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_HOME,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_BACK,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_FORWARD,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_ESCAPE,updateCmdUI ) - ON_UPDATE_COMMAND_UI( ID_QUICKHELP,updateCmdUI ) - ON_UPDATE_COMMAND_UI_RANGE( 333,343,updateCmdUIRange ) -END_MESSAGE_MAP() - -enum{ - TAB_INVALID,TAB_EDITOR,TAB_HTMLHELP,TAB_DEBUGLOG -}; - -static string getFile( const string &f ){ - int n; - string t=f; - n=t.rfind( '/' );if( n!=string::npos ) t=t.substr(n+1); - n=t.rfind( '\\' );if( n!=string::npos ) t=t.substr(n+1); - return t; -} - -static string getPath( const string &f ){ - int n; - string t=f; - n=t.rfind( '/' );if( n!=string::npos ) t=t.substr(0,n ); - n=t.rfind( '\\' );if( n!=string::npos ) t=t.substr(0,n); - return t; -} - -MainFrame::MainFrame():exit_flag(false){ -} - -int MainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct ){ - CFrameWnd::OnCreate( lpCreateStruct ); - - static HBITMAP toolbmp; - static SIZE imgsz,butsz; - static UINT toolbuts[]={ - Inew,ID_OPEN,ID_SAVE,ID_CLOSE,ID_SEPARATOR, - ID_CUT,ID_COPY,ID_PASTE,ID_SEPARATOR, - ID_FIND,ID_SEPARATOR, - ID_EXECUTE,ID_SEPARATOR, - ID_HOME,ID_BACK,ID_FORWARD }; - static int toolcnt=sizeof(toolbuts)/sizeof(UINT); - - if( !toolbmp ){ - BITMAP bm; - string t=prefs.homeDir+"/cfg/ide_toolbar.bmp"; - toolbmp=(HBITMAP)LoadImage( 0,t.c_str(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_LOADMAP3DCOLORS ); - if( !toolbmp ){ - AfxMessageBox( "toolbar bitmap failed to load!" ); - ExitProcess(0); - } - GetObject( toolbmp,sizeof(bm),&bm ); - int n=0; - for( int k=0;kGetSubMenu( 0 ); - file->InsertMenu( 12,MF_BYPOSITION|MF_ENABLED|MF_POPUP,(UINT)menu.m_hMenu,"&Recent Files" ); - menu.Detach(); - - helpHome(); - - trackmem( true ); - - if( blitzIDE.m_lpCmdLine[0] ){ - string t=string( blitzIDE.m_lpCmdLine ); - if( t[0]=='\"' ) t=t.substr( 1,t.size()-2 ); - open( t ); - }else{ - SetCurrentDirectory( (prefs.homeDir+"/samples").c_str() ); - } - - return 0; -} - -void MainFrame::OnDestroy(){ - trackmem( false ); - WINDOWPLACEMENT wp={sizeof(wp)}; - if( GetWindowPlacement( &wp ) ){ - prefs.win_rect=wp.rcNormalPosition; - if( wp.showCmd==SW_SHOWMAXIMIZED ){ - prefs.win_maximized=true; - }else{ - prefs.win_maximized=false; - } - } -} - -void MainFrame::setTitle( const string &s ){ - SetWindowText( ("Blitz3D - "+s ).c_str() ); - return; -} - -void MainFrame::OnClose(){ - bool exit_flag=true; - for( int k=tabber.size()-1;k>=0;--k ){ - exit_flag=close( k ); - if( !exit_flag ) break; - } - if( exit_flag ) DestroyWindow(); -} - -BOOL MainFrame::OnEraseBkgnd( CDC *dc ){ - return true; -} - -void MainFrame::OnSize( UINT type,int sw,int sh ){ - CFrameWnd::OnSize( type,sw,sh ); - - CRect r,t;GetClientRect( &r ); - int x=r.left,y=r.top,w=r.Width(),h=r.Height(); - - if( !prefs.win_notoolbar ){ - statusBar.GetWindowRect( &t );h-=t.Height(); - toolBar.GetWindowRect( &t );y+=t.Height();h-=t.Height(); - } - - tabber.MoveWindow( x,y,w,h ); -} - -static char *bbFilter= - -"Blitz Basic files (.bb)|*.bb|" - -"Image files (.bmp,.jpg,.png,.tga,.iff,.pcx)|*.bmp;*.jpg;*.png;*.tga;*.iff;*.pcx|" -"Audio files (.wav,.mid,.mod,.mp3,.s3m,.xm,.it,.rmi,.sgt)|*.wav;*.mid;*.mod;*.mp3;*.s3m;*.xm;*.it;*.rmi;*.sgt|" -"3D Mesh files (.x,.3ds,.md2)|*.x;*.3ds;*.md2|" - -"All files|*.*||"; - -Editor *MainFrame::getEditor(){ - return getEditor( tabber.getCurrent() ); -} - -Editor *MainFrame::getEditor( int n ){ - map::iterator it=editors.find( tabber.getTabWnd( n ) ); - return it==editors.end() ? 0 : it->second; -} - -HtmlHelp *MainFrame::getHelp( int n ){ - map::iterator it=helps.find( tabber.getTabWnd( n ) ); - return it==helps.end() ? 0 : it->second; -} - -HtmlHelp *MainFrame::getHelp(){ - return getHelp( tabber.getCurrent() ); -} - -HtmlHelp *MainFrame::findHelp(){ - int n; - HtmlHelp *h; - for( n=0;nCreate( 0,"Help",WS_CHILD|WS_BORDER,CRect( 0,0,0,0 ),&tabber,1 ); - helps[h]=h; - tabber.insert( n,h,"Help" ); - } - tabber.setCurrent( n ); - return h; -} - -void MainFrame::cursorMoved( Editor *editor ){ - if( editor!=getEditor() ) return; - int row,col; - editor->getCursor( &row,&col ); - char mod=editor->getModified() ? '*' : ' '; - char str[64];sprintf( str,"Row:%i Col:%i %c",row,col,mod ); - statusBar.SetPaneText( 1,str ); -} - -void MainFrame::currentSet( Tabber *tabber,int index ){ - if( Editor *e=getEditor() ){ - string t=e->getName(); - if( !t.size() ) t=""; - setTitle( t ); - cursorMoved( e ); - }else if( HtmlHelp *h=getHelp() ){ - setTitle( h->getTitle() ); - statusBar.SetPaneText( 1,"" ); - }else{ - setTitle( "no file" ); - statusBar.SetPaneText( 1,"" ); - } -} - -void MainFrame::helpOpen( HtmlHelp *help,const string &file ){ - open( file ); -} - -void MainFrame::helpTitleChange( HtmlHelp *help,const string &title ){ - if( HtmlHelp *h=getHelp() ) setTitle( h->getTitle() ); -} - -void MainFrame::insertRecent( const string &file ){ - //check recent files - if( CMenu *list=GetMenu()->GetSubMenu( 0 )->GetSubMenu( 12 ) ){ - vector::iterator it; - vector &f=prefs.recentFiles; - for( it=f.begin();it!=f.end();++it ){ - if( tolower( *it )==tolower( file ) ) break; - } - if( it!=f.end() ){ - //move to top - string t=*it; - f.erase( it ); - f.insert( f.begin(),t ); - }else{ - //insert - if( f.size()==10 ){ - f.pop_back(); - list->RemoveMenu( 9,MF_BYPOSITION ); - } - f.insert( f.begin(),file ); - list->InsertMenu( 0,MF_BYPOSITION|MF_ENABLED,333,file.c_str() ); - } - //renumber menu items - for( int k=0;kModifyMenu( k,MF_BYPOSITION|MF_ENABLED,333+k,f[k].c_str() ); - } - } -} - -void MainFrame::newed( const string &t ){ - - CRect r( 0,0,0,0 ); - - Editor *e=new Editor( this ); - e->Create( 0,"Editor",WS_CHILD,r,&tabber,1 ); - e->setName( t ); - editors[e]=e; - int n=tabber.size(); - string s=t.size() ? getFile( t ) : ""; - tabber.insert( n,e,s.c_str() ); - tabber.setCurrent( n ); -} - -bool MainFrame::open( const string &f ){ - - string file=f,filter="*.bb"; - - int n=f.find( "*." ); - if( n!=string::npos ){ - file=f.substr( 0,n ); - filter=f.substr( n ); - } - - int attr=GetFileAttributes( file.c_str() );if( attr==-1 ) attr=0; - if( !file.size() || (attr & FILE_ATTRIBUTE_DIRECTORY) ){ - - int n=OFN_NOCHANGEDIR|OFN_FILEMUSTEXIST; - CFileDialog fd( true,"bb",filter.c_str(),n,bbFilter ); - char *i_dir=strdup( file.c_str() ); - fd.m_ofn.lpstrInitialDir=i_dir; - fd.m_ofn.lpstrTitle="Open Blitz Basic File..."; - int nn=fd.DoModal();free( i_dir ); - if( nn==IDCANCEL ) return false; - - file=fd.GetPathName(); - - }else{ - - char buff[MAX_PATH],*p; - if( GetFullPathName( file.c_str(),MAX_PATH,buff,&p ) ) file=buff; - else file=f; - } - - if( isMediaFile( tolower( file ) ) ){ - string t=prefs.homeDir+"/bin/mediaview.exe"; - if( (int)ShellExecute( ::GetDesktopWindow(),0,t.c_str(),file.c_str(),0,SW_SHOW )>32 ){ - } - return false; - } - - //is file already open? - int k; - for( k=0;kgetName() )==tolower( file ) ){ - tabber.setCurrent( k ); - return true; - } - } - } - //open new file - ifstream in( file.c_str() ); - if( !in.good() ){ - string e="Error reading file \""+f+"\""; - AfxMessageBox( e.c_str(),MB_ICONWARNING ); - return false; - } - newed( file ); - tabber.UpdateWindow(); - Editor *e=getEditor(); - e->setText( in ); - e->setName( file ); - e->setModified( false ); - insertRecent( file ); - cursorMoved( e ); - return true; -} - -bool MainFrame::close( int n ){ - if( Editor *e=getEditor( n ) ){ - if( e->getModified() ){ - tabber.setCurrent( n ); - string t="File "+e->getName()+" has been modified!\nSave changes before closing?"; - int rt=AfxMessageBox( t.c_str(),MB_YESNOCANCEL|MB_ICONWARNING ); - if( rt==IDYES ) return save( n ); - if( rt==IDCANCEL ) return false; - } - tabber.remove( n ); - e->DestroyWindow(); - editors.erase( e ); - delete e; - }else if( HtmlHelp *h=getHelp( n ) ){ - } - return true; -} - -bool MainFrame::save( int n ){ - - Editor *e=getEditor( n ); - if( !e ) return true; - string t=e->getName(); - if( !t.size() ){ - tabber.setCurrent( n ); - int df=OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_EXPLORER|OFN_OVERWRITEPROMPT; - CFileDialog fd( false,"bb","*.bb",df,bbFilter ); - fd.m_ofn.lpstrTitle="Save Blitz Basic program as..."; - if( fd.DoModal()==IDCANCEL ) return false; - t=fd.GetPathName(); - tabber.setTabText( n,getFile( t ) ); - e->setName( t ); - insertRecent( t ); - } - //Do backups! - if( prefs.edit_backup ){ - for( int k=prefs.edit_backup;k>1;--k ){ - CopyFile( (t+"_bak"+itoa(k-1)).c_str(),(t+"_bak"+itoa(k)).c_str(),false ); - } - CopyFile( t.c_str(),(t+"_bak1").c_str(),false ); - } - int om=ios_base::binary|ios_base::out|ios_base::trunc; - ofstream out( t.c_str(),om ); - if( !out.good() ){ - string e="Error writing file \""+t+"\""; - AfxMessageBox( e.c_str(),MB_ICONWARNING ); - return false; - } - e->getText( out ); - out.close(); - e->setModified( false ); - cursorMoved( e ); - return true; -} - -void MainFrame::fileNew(){ - newed( "" ); -} - -void MainFrame::fileOpen(){ - open( "" ); -} - -void MainFrame::fileSave(){ - save( tabber.getCurrent() ); -} - -void MainFrame::fileSaveAs(){ - if( Editor *e=getEditor() ){ - string t=e->getName(); - e->setName( "" ); - if( !save( tabber.getCurrent() ) ) e->setName( t ); - currentSet( &tabber,tabber.getCurrent() ); - } -} - -void MainFrame::fileSaveAll(){ - for( int k=tabber.size()-1;k>=0;--k ){ - if( !save( k ) ) return; - } -} - -void MainFrame::filePrint(){ - if( Editor *e=getEditor() ) e->print(); -} - -void MainFrame::fileClose(){ - close( tabber.getCurrent() ); -} - -void MainFrame::fileCloseAll(){ - for( int k=tabber.size()-1;k>=0;--k ){ - if( !close( k ) ) return; - } -} - -void MainFrame::fileExit(){ - PostMessage( WM_CLOSE ); -} - -void MainFrame::fileRecent( UINT id ){ - id-=333; - if( id<0 || id>=prefs.recentFiles.size() ) return; - open( prefs.recentFiles[id] ); -} - -void MainFrame::editCut(){ - if( Editor *e=getEditor() ) e->cut(); -} - -void MainFrame::editCopy(){ - if( Editor *e=getEditor() ) e->copy(); -} - -void MainFrame::editPaste(){ - if( Editor *e=getEditor() ) e->paste(); -} - -void MainFrame::editSelectAll(){ - if( Editor *e=getEditor() ) e->selectAll(); -} - -void MainFrame::editFind(){ - if( Editor *e=getEditor() ) e->find(); -} - -void MainFrame::editFindNext(){ - if( Editor *e=getEditor() ) e->findNext( true ); -} - -void MainFrame::editReplace(){ - if( Editor *e=getEditor() ) e->replace(); -} - -static HANDLE startProc( const string &proc ){ - HANDLE rd,wr; - - SECURITY_ATTRIBUTES sa={sizeof(sa),0,true}; - - if( CreatePipe( &rd,&wr,&sa,0 ) ){ - STARTUPINFO si={sizeof(si)}; - si.dwFlags=STARTF_USESTDHANDLES; - si.hStdOutput=si.hStdError=wr; - PROCESS_INFORMATION pi={0}; - if( CreateProcess( 0,(char*)proc.c_str(),0,0,true,DETACHED_PROCESS,0,0,&si,&pi ) ){ - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - CloseHandle( wr ); - return rd; - } - CloseHandle( rd ); - CloseHandle( wr ); - } - return 0; -} - -class PDialog : public CDialog{ -public: - void OnOk(){} - void OnCancel(){} -}; - -void MainFrame::compile( const string &cmd ){ - - CDialog compiling; - compiling.Create( IDD_COMPILING ); - - CProgressCtrl *cp=(CProgressCtrl*)compiling.GetDlgItem( IDC_COMPILEPROGRESS ); - cp->SetStep(20); - - putenv( "blitzide=1" ); - - HANDLE rd=startProc( cmd ); - - if( !rd ){ - putenv( "blitzide" ); - compiling.DestroyWindow(); - AfxMessageBox( "Error launching compiler",MB_ICONWARNING|MB_OK ); - return; - } - - string line,err; - - //OK....here we go! - for(;;){ - char buff; - unsigned long sz; - int n=ReadFile( rd,&buff,1,&sz,0 ); - - if( n && !sz ) break; //EOF! - if( !n && GetLastError()==ERROR_BROKEN_PIPE ) break; //PROC END! - if( !n ){ err="Internal Error";break; } - - if( buff=='\r' ) continue; - if( buff!='\n' ){ line+=buff;continue; } - if( !line.size() ) continue; - - if( line[0]=='\"' ){ - err=line; - int n=line.find( "\"",1 ); - if( n==string::npos ) break; - if( ++n==line.size() || line[n]!=':' ) break; - string file=line.substr( 1,n-2 );line=line.substr(n+1); - n=line.find( ':' );if( !n || n==string::npos ) break; - int row1=atoi(line.substr(0,n));line=line.substr(n+1); - n=line.find( ':' );if( !n || n==string::npos ) break; - int col1=atoi(line.substr(0,n));line=line.substr(n+1); - n=line.find( ':' );if( !n || n==string::npos ) break; - int row2=atoi(line.substr(0,n));line=line.substr(n+1); - n=line.find( ':' );if( !n || n==string::npos ) break; - int col2=atoi(line.substr(0,n));line=line.substr(n+1); - - int pos=((row1-1)<<16)|(col1-1); - - if( !open( file ) ) return; - if( Editor *e=getEditor() ) e->setCursor( pos ); - - err=line; - break; - }else if( line.find( "..." )!=line.size()-3 ){ - err=line;break; - } - - if( line.find( "Executing" )==0 ){ - //OK, we're running! - break; - } - - cp->StepIt(); - line=""; - } - - compiling.DestroyWindow(); - - CloseHandle( rd ); - putenv( "blitzide" ); - - if( !err.size() ) return; - - AfxMessageBox( err.c_str(),MB_ICONWARNING|MB_OK ); -} - -void MainFrame::build( bool exec,bool publish ){ - Editor *e=getEditor(); - if( !e ) return; - - string src_file=e->getName(); - - for( int k=tabber.size()-1;k>=0;--k ){ - if( Editor *e=getEditor( k ) ){ - if( e->getModified() && e->getName().size() ){ - if( !save(k) ) return; - } - } - } - - string opts=" "; - - if( prefs.prg_debug ) opts+="-d "; - - if( publish ){ - string exe=src_file; - if( exe.size() ){ - int n=exe.find( '.' ); - if( n!=string::npos ) exe=exe.substr( 0,n ); - }else{ - exe="untitled"; - } - - static char *exeFilter="Executable files (*.exe)|*.exe||"; - int t=OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST|OFN_OVERWRITEPROMPT; - CFileDialog fd( false,"exe",exe.c_str(),t,exeFilter ); - fd.m_ofn.lpstrTitle="Select executable filename"; - fd.m_ofn.lpstrInitialDir="./"; - if( fd.DoModal()==IDCANCEL ) return; - - opts+="-o \""+string( fd.GetPathName() )+"\" "; - }else if( !exec ){ - opts+="-c "; - } - - string src=src_file; - - if( !src.size() ){ - src=prefs.homeDir+"\\tmp\\tmp.bb"; - int om=ios_base::binary|ios_base::out|ios_base::trunc; - ofstream out( src.c_str(),om ); - if( !out.good() ){ - string e="Error writing file \""+src+"\""; - AfxMessageBox( e.c_str(),MB_ICONWARNING ); - return; - } - e->getText( out ); - out.close(); - e->setName( src ); - }else{ - prefs.prg_lastbuild=e->getName(); - } - - compile( prefs.homeDir+"/bin/blitzcc -q "+opts+" \""+src+"\" "+prefs.cmd_line ); - - if( !src_file.size() ) e->setName( "" ); -} - -void MainFrame::programExecute(){ - build( true,false ); -} - -void MainFrame::programReExecute(){ - if( prefs.prg_lastbuild.size() && open( prefs.prg_lastbuild ) ){ - build( true,false ); - } -} - -void MainFrame::programCompile(){ - build( false,false ); -} - -void MainFrame::programPublish(){ -#ifdef DEMO - MessageBox( "Create Executable unavailable in demo version","Sorry!",MB_TOPMOST|MB_SETFOREGROUND|MB_ICONINFORMATION ); - return; -#endif - Editor *e=getEditor();if( !e ) return; - if( prefs.prg_debug ){ - string t= - "You currently have the debugging feature enabled!\n\n" - "This will result in slower executables - continue anyway?"; - if( MessageBox( t.c_str(),0,MB_OKCANCEL )==IDCANCEL ) return; - } - build( false,true ); -} - -struct CmdLineDialog : public CDialog{ - CmdLineDialog():CDialog( IDD_COMMANDLINE ){ - } - - BOOL OnInitDialog(){ - CDialog::OnInitDialog(); - SetDlgItemText( IDC_CMDLINE,prefs.cmd_line.c_str() ); - return TRUE; - } - - void OnOK(){ - CString c_str; - GetDlgItemText( IDC_CMDLINE,c_str ); - prefs.cmd_line=c_str; - CDialog::OnOK(); - } -}; - -void MainFrame::programCommandLine(){ - CmdLineDialog d; - d.DoModal(); -} - -void MainFrame::programDebug(){ - prefs.prg_debug=!prefs.prg_debug; -} - -void MainFrame::helpHome(){ - HtmlHelp *h=findHelp(); - string t; - t="index.html"; - h->Navigate( (prefs.homeDir+"/help/"+t).c_str() ); -} - -void MainFrame::helpAutodoc(){ - HtmlHelp *h=findHelp(); - h->Navigate( (prefs.homeDir+"/help/autodoc.html").c_str() ); -} - -void MainFrame::helpBack(){ - if( HtmlHelp *h=findHelp() ) h->GoBack(); -} - -void MainFrame::helpForward(){ - if( HtmlHelp *h=findHelp() ) h->GoForward(); -} - -void MainFrame::helpAbout(){ - aboutBlitz( false ); -} - -void MainFrame::ctrlTab(){ - int n=tabber.getCurrent()+1; - if( n>=tabber.size() ) n-=tabber.size(); - tabber.setCurrent( n ); -} - -void MainFrame::ctrlShiftTab(){ - int n=tabber.getCurrent()-1; - if( n<0 ) n+=tabber.size(); - tabber.setCurrent( n ); -} - -void MainFrame::escape(){ - if( !prefs.win_notoolbar ){ - toolBar.ShowWindow( SW_HIDE ); - statusBar.ShowWindow( SW_HIDE ); - prefs.win_notoolbar=true; - }else{ - toolBar.ShowWindow( SW_SHOW ); - statusBar.ShowWindow( SW_SHOW ); - prefs.win_notoolbar=false; - } - RECT r;GetClientRect( &r ); - int w=r.right-r.left,h=r.bottom-r.top; - int n=prefs.win_maximized ? SIZE_MAXIMIZED : SIZE_RESTORED; - PostMessage( WM_SIZE,n,(h<<16)|w ); -} - -void MainFrame::updateCmdUIRange( CCmdUI *ui ){ - int n=ui->m_nID-333; - if( n>=0 && nEnable( true ); - }else{ - ui->Enable( false ); - } -} - -void MainFrame::updateCmdUI( CCmdUI *ui ){ - int k; - - Editor *e=getEditor(); - - switch( ui->m_nID ){ - case Inew:case ID_OPEN:case ID_HOME: - ui->Enable( true ); - break; - case ID_DEBUG: - ui->SetCheck( prefs.prg_debug );ui->Enable( true ); - break; - case ID_CLOSE:case ID_PRINT: - ui->Enable( !!e ); - break; - case ID_CLOSEALL: - for( k=0;kEnable( kEnable( e->canCutCopy() ); - }else ui->Enable( false ); - break; - case ID_PASTE: - if( !!e ){ - ui->Enable( e->canPaste() ); - }else ui->Enable( false ); - break; - case ID_SELECTALL:case ID_QUICKHELP: - case ID_FIND:case ID_FINDNEXT:case ID_REPLACE: - case ID_EXECUTE:case ID_COMPILE:case ID_PUBLISH: - ui->Enable( !!e ); - break; - case ID_REEXECUTE: - ui->Enable( prefs.prg_lastbuild.size() ); - break; - case ID_COMMANDLINE: - ui->Enable( true ); - break; - case ID_SAVE:case ID_SAVEAS: - ui->Enable( !!e ); - break; - case ID_SAVEALL: - for( k=0;kEnable( kEnable( getHelp()!=0 ); - break; - case ID_ESCAPE: - ui->SetCheck( !prefs.win_notoolbar ); - break; - default: - ui->Enable( false ); - } -} - -static string commandURL( const string &t ){ - - static char *dirs[]={ - "help\\commands\\2d_commands\\", - "help\\commands\\3d_commands\\", - 0 - }; - - char **dir_p=dirs; - - while( char *dir=*dir_p++ ){ - WIN32_FIND_DATA fd; - string path=prefs.homeDir+"/"+dir+t+".htm"; - HANDLE h=FindFirstFile( path.c_str(),&fd ); - if( h==INVALID_HANDLE_VALUE ) continue; - FindClose( h ); - return path; - } - return ""; -} - -void MainFrame::quick_Help(){ - if( Editor *e=getEditor() ){ - //look for keyword at cursor... - string t=e->getKeyword();if( !t.size() ) return; - statusBar.SetPaneText( 0,quickHelp( t ).c_str() ); - if( t!=last_quick_help ){ - last_quick_help=t; - return; - } - string url=commandURL( t ); - if( !url.size() ){ - string ex="Unable to open help file for \""+t+"\""; - AfxMessageBox( ex.c_str(),MB_ICONWARNING ); - return; - } - if( HtmlHelp *h=findHelp() ){ - h->Navigate( url.c_str(),0,0 ); - } - } -} - -void MainFrame::OnActivate( UINT state,CWnd *other,BOOL min ){ - CFrameWnd::OnActivate( state,other,min ); - - if( Editor *e=getEditor() ){ - if( state!=WA_ACTIVE && state!=WA_CLICKACTIVE ) return; - e->SetFocus(); - } -} diff --git a/BlitzBasicIDE/prefs.cpp b/BlitzBasicIDE/prefs.cpp deleted file mode 100644 index 3508f33..0000000 --- a/BlitzBasicIDE/prefs.cpp +++ /dev/null @@ -1,195 +0,0 @@ - -#include "stdafx.h" -#include -#include -#include "resource.h" -#include "prefs.h" - -#define SWAPRB(x) ( (((x)>>16)&0xff) | ((x)&0xff00) | (((x)&0xff)<<16) ) - -Prefs prefs; - -void Prefs::open(){ - - char *p=getenv( "blitzpath" ); - if( !p ){ - AfxMessageBox( "blitzpath environment variable not found!",MB_TOPMOST|MB_SETFOREGROUND|MB_ICONINFORMATION ); - ExitProcess(0); - } - - homeDir=p; - - AddFontResource( (homeDir+"/cfg/blitz.fon").c_str() ); - - setDefault(); - - bool prg_windowed; - - ifstream in( (homeDir+"/cfg/blitzide.prefs").c_str() ); - if( !in.good() ) return; - - while( !in.eof() ){ - string t;in>>t; - if( !t.size() ) continue; - while( in.peek()=='\t' ) in.ignore(); - if( t=="prg_debug" ) in>>prg_debug; - else if( t=="prg_lastbuild" ) getline( in,prg_lastbuild ); - else if( t=="prg_windowed" ) in>>prg_windowed; - else if( t=="win_maximized" ) in>>win_maximized; - else if( t=="win_notoolbar" ) in>>win_notoolbar; - else if( t=="win_rect" ){ - in>>win_rect.left;in>>win_rect.top; - in>>win_rect.right;in>>win_rect.bottom; - }else if( t.substr( 0,5 )=="font_" ){ - string s;int h;in>>s;in>>h; - t=t.substr( 5 ); - if( t=="editor" ){ - font_editor=s;font_editor_height=h; - }else if( t=="tabs" ){ - font_tabs=s;font_tabs_height=h; - }else if( t=="debug" ){ - font_debug=s;font_debug_height=h; - } - }else if( t.substr( 0,4 )=="rgb_" ){ - t=t.substr(4); - string s;in>>s;int rgb=0; - for( int k=0;k>edit_tabs; - }else if( t=="edit_blkcursor" ){ - in>>edit_blkcursor; - }else if( t=="edit_backup" ){ - in>>edit_backup; - }else if( t=="img_toolbar" ){ - getline( in,img_toolbar ); - }else if( t=="cmd_line" ){ - getline( in,cmd_line ); - }else if( t=="file_recent" ){ - string l;getline( in,l ); - if( recentFiles.size()<10 ) recentFiles.push_back( l ); - }else{ - string s="Unrecognized option '"+t+"' in blitzide.prefs"; - AfxMessageBox( "Error in preferences file" ); - setDefault(); - return; - } - } - createFonts(); -} - -void Prefs::close(){ - - ofstream out( (homeDir+"/cfg/blitzide.prefs").c_str() ); - if( !out.good() ) return; - - out<<"prg_debug\t"<r.right ) r.right=c.right; - if( c.topr.bottom ) r.bottom=c.bottom; - } - return r; -} - -CRect Tabber::getInnerRect(){ - CRect r; - GetClientRect( &r ); - int x=2,y=2,w=r.Width()-4,h=r.Height()-4; - - r=tabsRect( *this ); - h-=r.Height();y+=r.Height(); - - r.left=x;r.top=y;r.right=x+w;r.bottom=y+h; - return r; -} - -Tabber::Tabber(): -listener(0),curr(-1){ -} - -Tabber::~Tabber(){ - for( ;tabs.size();tabs.pop_back() ) delete tabs.back(); -} - -void Tabber::OnSize( UINT type,int w,int h ){ - CTabCtrl::OnSize( type,w,h ); - refresh(); -} - -BOOL Tabber::OnEraseBkgnd( CDC *dc ){ - CRect c;GetClientRect( &c ); - - HBRUSH hb=(HBRUSH)GetClassLong( m_hWnd,GCL_HBRBACKGROUND ); - CBrush br;br.Attach( hb ); - - if( curr<0 ) dc->FillRect( &c,&br ); - else{ - CRect i=getInnerRect(); - CRect t( c.left,c.top,i.right,i.top );dc->FillRect( &t,&br ); - CRect r( i.right,c.top,c.right,i.bottom );dc->FillRect( &r,&br ); - CRect b( i.left,i.bottom,c.right,c.bottom );dc->FillRect( &b,&br ); - CRect l( c.left,i.top,i.left,c.bottom );dc->FillRect( &l,&br ); - } - return true; -} - -void Tabber::setListener( TabberListener *l ){ - listener=l; -} - -void Tabber::refresh(){ - if( curr<0 ) return; - - CRect r=getInnerRect(); - CWnd *wnd=getTabWnd( curr ); - wnd->MoveWindow( r.left,r.top,r.Width(),r.Height() ); - wnd->ShowWindow( SW_SHOW ); - wnd->SetFocus(); -} - -Tabber::Tab *Tabber::getTab( int index )const{ - if( index<0 || index>=tabs.size() ) return 0; - Tabs::const_iterator it=tabs.begin(); - while( index-- ) ++it; - return *it; -} - -void Tabber::tcn_selChange( NMHDR *p,LRESULT *result ){ - setCurrent( GetCurSel() ); -} - -void Tabber::insert( int index,CWnd *w,const string &t ){ - if( index<0 || index>tabs.size() ) return; - - Tabs::iterator it=tabs.begin(); - for( int k=0;k=tabs.size() ) return; - - CWnd *w=getTabWnd( index ); - - Tabs::iterator it=tabs.begin(); - for( int k=0;k=tabs.size() ) curr=tabs.size()-1; - - refresh(); - if( curr>=0 ) SetCurSel( curr ); - if( w ) w->ShowWindow( SW_HIDE ); - if( listener ) listener->currentSet( this,curr ); -} - -void Tabber::setCurrent( int index ){ - if( index<0 || index>=tabs.size() ) return; - - if( index!=curr ){ - CWnd *w=getTabWnd( curr ); - curr=index; - - refresh(); - SetCurSel( curr ); - if( w ) w->ShowWindow( SW_HIDE ); - } - - if( listener ) listener->currentSet( this,curr ); -} - -void Tabber::setTabText( int index,const string &t ){ - if( index<0 || index>=tabs.size() ) return; - - string s=t+'\0'; - TCITEM tc={ TCIF_TEXT }; - tc.pszText=(char*)s.data(); - SetItem( index,&tc ); -} - -int Tabber::size()const{ - return tabs.size(); -} - -int Tabber::getCurrent()const{ - return curr; -} - -CWnd *Tabber::getTabWnd( int index )const{ - Tab *t=getTab( index ); - return t ? t->wnd : 0; -} - -string Tabber::getTabText( int index )const{ - Tab *t=getTab( index ); - return t ? t->text : ""; -} \ No newline at end of file diff --git a/BlitzBasicLauncher/bblaunch.cpp b/BlitzBasicLauncher/bblaunch.cpp deleted file mode 100644 index c43e2b9..0000000 --- a/BlitzBasicLauncher/bblaunch.cpp +++ /dev/null @@ -1,80 +0,0 @@ - -#include -#include - -#include "checkdx.h" -#include "checkie.h" - -using namespace std; - -static const char *dx_err= -"You must have DirectX version 7 installed to run Blitz Basic.\n\n" -"DirectX 7 is provided on the Blitz Basic CD in the DirectX7 folder.\n\n" -"The latest version of DirectX is available from www.microsoft.com"; - -static const char *ie_err= -"You must have Internet Explorer version 4 installed to run Blitz Basic.\n\n" -"Internet Explorer 5 is provided on the Blitz Basic CD in the IExplorer5 folder.\n\n" -"The latest version of Internet Explorer is available from www.microsoft.com"; - -static const char *bb_err= -"Unable to run Blitz Basic"; - -static const char *md_err= -"Your desktop must be in high-colour mode to use Blitz Basic.\n\n" -"You can change your display settings from the control panel."; - -static string getAppDir(){ - char buff[MAX_PATH]; - if( GetModuleFileName( 0,buff,MAX_PATH ) ){ - string t=buff; - int n=t.find_last_of( '\\' ); - if( n!=string::npos ) t=t.substr( 0,n ); - return t; - } - return ""; -} - -static void fail( const char *p ){ - ::MessageBox( 0,p,"Blitz Basic Error",MB_SETFOREGROUND|MB_TOPMOST|MB_ICONERROR ); - ExitProcess(-1); -} - -static int desktopDepth(){ - HDC hdc=GetDC( GetDesktopWindow() ); - return GetDeviceCaps( hdc,BITSPIXEL ); -} - -int _stdcall WinMain( HINSTANCE inst,HINSTANCE prev,char *cmd,int show ){ - - if( desktopDepth()<16 ) fail( md_err ); - -#ifndef PLUS - if( getDXVersion()<7 ) fail( dx_err ); -#endif - - if( getIEVersion()<4 ) fail( ie_err ); - - //Ugly hack to get application dir... - string blitzIdePath=getAppDir(); - _putenv( ("blitzpath="+blitzIdePath).c_str() ); - SetCurrentDirectory( blitzIdePath.c_str() ); - blitzIdePath=blitzIdePath+"\\bin\\ide.exe "+cmd; - - STARTUPINFO si; - PROCESS_INFORMATION pi; - ZeroMemory(&si,sizeof(si));si.cb=sizeof(si); - if( !CreateProcess( 0,(char*)blitzIdePath.c_str(),0,0,0,0,0,0,&si,&pi ) ){ - ::MessageBox( 0,bb_err,"Blitz Basic Error",MB_SETFOREGROUND|MB_TOPMOST|MB_ICONERROR ); - ExitProcess(-1); - } - - //wait for BB to start - WaitForInputIdle( pi.hProcess,INFINITE ); - - // Close process and thread handles. - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - - return 0; -} diff --git a/BlitzBasicLauncher/bblaunch.dsp b/BlitzBasicLauncher/bblaunch.dsp deleted file mode 100644 index 81b6a80..0000000 --- a/BlitzBasicLauncher/bblaunch.dsp +++ /dev/null @@ -1,179 +0,0 @@ -# Microsoft Developer Studio Project File - Name="bblaunch" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=bblaunch - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "bblaunch.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "bblaunch.mak" CFG="bblaunch - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "bblaunch - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "bblaunch - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE "bblaunch - Win32 Blitz3DRelease" (based on "Win32 (x86) Application") -!MESSAGE "bblaunch - Win32 Blitz2DRelease" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "bblaunch - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O1 /Ob2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"..\blitzbasic\blitzbasic.exe" - -!ELSEIF "$(CFG)" == "bblaunch - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /out:"..\blitzbasic\blitzbasic.exe" /fixed:no -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "bblaunch - Win32 Blitz3DRelease" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "bblaunch___Win32_Blitz3DRelease" -# PROP BASE Intermediate_Dir "bblaunch___Win32_Blitz3DRelease" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "bblaunch___Win32_Blitz3DRelease" -# PROP Intermediate_Dir "bblaunch___Win32_Blitz3DRelease" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O1 /Ob2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /Gz /MT /W3 /GX /O1 /D "_WINDOWS" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "PRO" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"..\blitzbasic\blitzbasic.exe" -# ADD LINK32 dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"../_release/Blitz3D.exe" - -!ELSEIF "$(CFG)" == "bblaunch - Win32 Blitz2DRelease" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "bblaunch___Win32_Blitz2DRelease" -# PROP BASE Intermediate_Dir "bblaunch___Win32_Blitz2DRelease" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "bblaunch___Win32_Blitz2DRelease" -# PROP Intermediate_Dir "bblaunch___Win32_Blitz2DRelease" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O1 /Ob2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"..\..\release\blitz3drelease\Blitz3D.exe" -# ADD LINK32 dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"..\..\release\blitz2drelease\BlitzBasic.exe" - -!ENDIF - -# Begin Target - -# Name "bblaunch - Win32 Release" -# Name "bblaunch - Win32 Debug" -# Name "bblaunch - Win32 Blitz3DRelease" -# Name "bblaunch - Win32 Blitz2DRelease" -# Begin Source File - -SOURCE=.\bblaunch.cpp -# End Source File -# Begin Source File - -SOURCE=.\bblaunch.ico -# End Source File -# Begin Source File - -SOURCE=.\bblaunch.rc -# End Source File -# Begin Source File - -SOURCE=.\checkdx.cpp -# End Source File -# Begin Source File - -SOURCE=.\checkdx.h -# End Source File -# Begin Source File - -SOURCE=.\checkie.cpp -# End Source File -# Begin Source File - -SOURCE=.\checkie.h -# End Source File -# End Target -# End Project diff --git a/BlitzBasicLauncher/bblaunch.vcxproj b/BlitzBasicLauncher/bblaunch.vcxproj deleted file mode 100644 index 5d9c4e9..0000000 --- a/BlitzBasicLauncher/bblaunch.vcxproj +++ /dev/null @@ -1,252 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - RelWithDebInfo - Win32 - - - - - - {C74A383E-81B0-4679-AAC9-535C94C92EA5} - BlitzBasicLauncher - 10.0.17763.0 - - - - Application - v141 - false - MultiByte - true - - - Application - v140_xp - false - MultiByte - - - Application - v140_xp - false - MultiByte - - - - - - - - - - - - - - - - - - - ..\#Build\$(ProjectName)\$(Configuration)-$(PlatformTarget)\ - ..\#Intermediate\$(ProjectName)\$(Configuration)-$(PlatformTarget)\ - false - C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;$(IncludePath) - C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86;$(LibraryPath) - - - ..\#Build\$(ProjectName)\$(Configuration)-$(PlatformTarget)\ - ..\#Intermediate\$(ProjectName)\$(Configuration)-$(PlatformTarget)\ - false - C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;$(IncludePath) - C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86;$(LibraryPath) - - - ..\#Build\$(ProjectName)\$(Configuration)-$(PlatformTarget)\ - ..\#Intermediate\$(ProjectName)\$(Configuration)-$(PlatformTarget)\ - false - C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;$(IncludePath) - C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86;$(LibraryPath) - - - - MultiThreadedDebugDLL - false - true - true - _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) - Default - false - Level3 - StdCall - Async - false - - - true - _DEBUG;%(PreprocessorDefinitions) - .\Debug\bblaunch.tlb - true - Win32 - - - 0x0409 - _DEBUG;%(PreprocessorDefinitions) - - - true - .\Debug\bblaunch.bsc - - - true - true - Windows - /FIXED:NO - dxguid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreadedDLL - false - true - Level3 - _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) - true - false - StdCall - Async - false - Full - AnySuitable - true - Speed - true - true - 4Bytes - false - true - StreamingSIMDExtensions2 - Fast - false - ProgramDatabase - false - - - false - true - - - true - NDEBUG;%(PreprocessorDefinitions) - .\Release\bblaunch.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\Release\bblaunch.bsc - - - true - Windows - dxguid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreadedDLL - false - true - Level3 - _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) - true - false - StdCall - Async - false - - - true - NDEBUG;%(PreprocessorDefinitions) - .\Release\bblaunch.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\Release\bblaunch.bsc - - - true - Windows - dxguid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - {be0ba538-6215-4836-9227-1d3627e40d61} - false - - - {c23af61e-9509-411f-933e-17db18884b21} - false - - - {d884a075-e3b8-44e1-838d-74f28b33391b} - false - - - {3e355353-96d8-4aaf-bf95-8e6ca0d4b1ba} - false - - - {4132c330-95d9-4f68-a51a-3b90381587c5} - false - - - {ff2d8bf7-1930-4cab-bc48-05cd33b7dc18} - false - - - {6bcfc5ca-ea71-4ae9-8b96-28b8701f939e} - false - - - - - - \ No newline at end of file diff --git a/BlitzBasicLauncher/checkdx.cpp b/BlitzBasicLauncher/checkdx.cpp deleted file mode 100644 index 94b651e..0000000 --- a/BlitzBasicLauncher/checkdx.cpp +++ /dev/null @@ -1,343 +0,0 @@ - -//----------------------------------------------------------------------------- -// File: GetDXVer.cpp -// -// Desc: Demonstrates how applications can detect what version of DirectX -// is installed. -// -// (C) Copyright 1995-1997 Microsoft Corp. All rights reserved. -//----------------------------------------------------------------------------- -#include -#include -#include -#define DIRECTINPUT_VERSION 0x0700 -#include -//#include - -typedef HRESULT(WINAPI * DIRECTDRAWCREATE)( GUID*, LPDIRECTDRAW*, IUnknown* ); -typedef HRESULT(WINAPI * DIRECTDRAWCREATEEX)( GUID*, VOID**, REFIID, IUnknown* ); -typedef HRESULT(WINAPI * DIRECTINPUTCREATE)( HINSTANCE, DWORD, LPDIRECTINPUT*, - IUnknown* ); - - - -//----------------------------------------------------------------------------- -// Name: GetDXVersion() -// Desc: This function returns two arguments: -// dwDXVersion: -// 0x0000 = No DirectX installed -// 0x0100 = DirectX version 1 installed -// 0x0200 = DirectX 2 installed -// 0x0300 = DirectX 3 installed -// 0x0500 = At least DirectX 5 installed. -// 0x0600 = At least DirectX 6 installed. -// 0x0601 = At least DirectX 6.1 installed. -// 0x0700 = At least DirectX 7 installed. -// dwDXPlatform: -// 0 = Unknown (This is a failure case) -// VER_PLATFORM_WIN32_WINDOWS = Windows 9X platform -// VER_PLATFORM_WIN32_NT = Windows NT platform -// -// Please note that this code is intended as a general guideline. Your -// app will probably be able to simply query for functionality (via -// QueryInterface) for one or two components. -// -// Please also note: -// "if (dxVer != 0x500) return FALSE;" is BAD. -// "if (dxVer < 0x500) return FALSE;" is MUCH BETTER. -// to ensure your app will run on future releases of DirectX. -//----------------------------------------------------------------------------- -VOID GetDXVersion( DWORD* pdwDXVersion, DWORD* pdwDXPlatform ) -{ - *pdwDXVersion = 0x0700; - *pdwDXPlatform = VER_PLATFORM_WIN32_NT; - // HRESULT hr; - // HINSTANCE DDHinst = 0; - // HINSTANCE DIHinst = 0; - // LPDIRECTDRAW pDDraw = 0; - // LPDIRECTDRAW2 pDDraw2 = 0; - // DIRECTDRAWCREATE DirectDrawCreate = 0; - // DIRECTDRAWCREATEEX DirectDrawCreateEx = 0; - // DIRECTINPUTCREATE DirectInputCreate = 0; - // OSVERSIONINFO osVer; - // LPDIRECTDRAWSURFACE pSurf = 0; - // LPDIRECTDRAWSURFACE3 pSurf3 = 0; - // LPDIRECTDRAWSURFACE4 pSurf4 = 0; - - // // First get the windows platform - // osVer.dwOSVersionInfoSize = sizeof(osVer); - // if( !GetVersionEx( &osVer ) ) - // { - // (*pdwDXPlatform) = 0; - // (*pdwDXVersion) = 0; - // return; - // } - - // if( osVer.dwPlatformId == VER_PLATFORM_WIN32_NT ) - // { - // (*pdwDXPlatform) = VER_PLATFORM_WIN32_NT; - - // // NT is easy... NT 4.0 is DX2, 4.0 SP3 is DX3, 5.0 is DX5 - // // and no DX on earlier versions. - // if( osVer.dwMajorVersion < 4 ) - // { - // (*pdwDXVersion) = 0; // No DX on NT3.51 or earlier - // return; - // } - - // if( osVer.dwMajorVersion == 4 ) - // { - // // NT4 up to SP2 is DX2, and SP3 onwards is DX3, so we are at least DX2 - // (*pdwDXVersion) = 0x200; - - // // We're not supposed to be able to tell which SP we're on, so check for dinput - // DIHinst = LoadLibrary( "DINPUT.DLL" ); - // if( DIHinst == 0 ) - // { - // // No DInput... must be DX2 on NT 4 pre-SP3 - // OutputDebugString( "Couldn't LoadLibrary DInput\r\n" ); - // return; - // } - - // DirectInputCreate = (DIRECTINPUTCREATE)GetProcAddress( DIHinst, - // "DirectInputCreateA" ); - // FreeLibrary( DIHinst ); - - // if( DirectInputCreate == 0 ) - // { - // // No DInput... must be pre-SP3 DX2 - // OutputDebugString( "Couldn't GetProcAddress DInputCreate\r\n" ); - // return; - // } - - // // It must be NT4, DX2 - // (*pdwDXVersion) = 0x300; // DX3 on NT4 SP3 or higher - // return; - // } - // // Else it's NT5 or higher, and it's DX5a or higher: Drop through to - // // Win9x tests for a test of DDraw (DX6 or higher) - // } - // else - // { - // // Not NT... must be Win9x - // (*pdwDXPlatform) = VER_PLATFORM_WIN32_WINDOWS; - // } - - // // Now we know we are in Windows 9x (or maybe 3.1), so anything's possible. - // // First see if DDRAW.DLL even exists. - // DDHinst = LoadLibrary( "DDRAW.DLL" ); - // if( DDHinst == 0 ) - // { - // (*pdwDXVersion) = 0; - // (*pdwDXPlatform) = 0; - // FreeLibrary( DDHinst ); - // return; - // } - - // // See if we can create the DirectDraw object. - // DirectDrawCreate = (DIRECTDRAWCREATE)GetProcAddress( DDHinst, "DirectDrawCreate" ); - // if( DirectDrawCreate == 0 ) - // { - // (*pdwDXVersion) = 0; - // (*pdwDXPlatform) = 0; - // FreeLibrary( DDHinst ); - // OutputDebugString( "Couldn't LoadLibrary DDraw\r\n" ); - // return; - // } - - // hr = DirectDrawCreate( NULL, &pDDraw, NULL ); - // if( FAILED(hr) ) - // { - // (*pdwDXVersion) = 0; - // (*pdwDXPlatform) = 0; - // FreeLibrary( DDHinst ); - // OutputDebugString( "Couldn't create DDraw\r\n" ); - // return; - // } - - // // So DirectDraw exists. We are at least DX1. - // (*pdwDXVersion) = 0x100; - - // // Let's see if IID_IDirectDraw2 exists. - // hr = pDDraw->QueryInterface( IID_IDirectDraw2, (VOID**)&pDDraw2 ); - // if( FAILED(hr) ) - // { - // // No IDirectDraw2 exists... must be DX1 - // pDDraw->Release(); - // FreeLibrary( DDHinst ); - // OutputDebugString( "Couldn't QI DDraw2\r\n" ); - // return; - // } - - // // IDirectDraw2 exists. We must be at least DX2 - // pDDraw2->Release(); - // (*pdwDXVersion) = 0x200; - - - // /////////////////////////////////////////////////////////////////////////// - // // DirectX 3.0 Checks - // /////////////////////////////////////////////////////////////////////////// - - // // DirectInput was added for DX3 - // DIHinst = LoadLibrary( "DINPUT.DLL" ); - // if( DIHinst == 0 ) - // { - // // No DInput... must not be DX3 - // OutputDebugString( "Couldn't LoadLibrary DInput\r\n" ); - // pDDraw->Release(); - // FreeLibrary( DDHinst ); - // return; - // } - - // DirectInputCreate = (DIRECTINPUTCREATE)GetProcAddress( DIHinst, - // "DirectInputCreateA" ); - // if( DirectInputCreate == 0 ) - // { - // // No DInput... must be DX2 - // FreeLibrary( DIHinst ); - // FreeLibrary( DDHinst ); - // pDDraw->Release(); - // OutputDebugString( "Couldn't GetProcAddress DInputCreate\r\n" ); - // return; - // } - - // // DirectInputCreate exists. We are at least DX3 - // (*pdwDXVersion) = 0x300; - // FreeLibrary( DIHinst ); - - // // Can do checks for 3a vs 3b here - - - // /////////////////////////////////////////////////////////////////////////// - // // DirectX 5.0 Checks - // /////////////////////////////////////////////////////////////////////////// - - // // We can tell if DX5 is present by checking for the existence of - // // IDirectDrawSurface3. First, we need a surface to QI off of. - // DDSURFACEDESC ddsd; - // ZeroMemory( &ddsd, sizeof(ddsd) ); - // ddsd.dwSize = sizeof(ddsd); - // ddsd.dwFlags = DDSD_CAPS; - // ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - - // hr = pDDraw->SetCooperativeLevel( NULL, DDSCL_NORMAL ); - // if( FAILED(hr) ) - // { - // // Failure. This means DDraw isn't properly installed. - // pDDraw->Release(); - // FreeLibrary( DDHinst ); - // (*pdwDXVersion) = 0; - // OutputDebugString( "Couldn't Set coop level\r\n" ); - // return; - // } - - // hr = pDDraw->CreateSurface( &ddsd, &pSurf, NULL ); - // if( FAILED(hr) ) - // { - // // Failure. This means DDraw isn't properly installed. - // pDDraw->Release(); - // FreeLibrary( DDHinst ); - // *pdwDXVersion = 0; - // OutputDebugString( "Couldn't CreateSurface\r\n" ); - // return; - // } - - // // Query for the IDirectDrawSurface3 interface - // if( FAILED( pSurf->QueryInterface( IID_IDirectDrawSurface3, - // (VOID**)&pSurf3 ) ) ) - // { - // pDDraw->Release(); - // FreeLibrary( DDHinst ); - // return; - // } - - // // QI for IDirectDrawSurface3 succeeded. We must be at least DX5 - // (*pdwDXVersion) = 0x500; - - - // /////////////////////////////////////////////////////////////////////////// - // // DirectX 6.0 Checks - // /////////////////////////////////////////////////////////////////////////// - - // // The IDirectDrawSurface4 interface was introduced with DX 6.0 - // if( FAILED( pSurf->QueryInterface( IID_IDirectDrawSurface4, - // (VOID**)&pSurf4 ) ) ) - // { - // pDDraw->Release(); - // FreeLibrary( DDHinst ); - // return; - // } - - // // IDirectDrawSurface4 was create successfully. We must be at least DX6 - // (*pdwDXVersion) = 0x600; - // pSurf->Release(); - // pDDraw->Release(); - - - // /////////////////////////////////////////////////////////////////////////// - // // DirectX 6.1 Checks - // /////////////////////////////////////////////////////////////////////////// - - //// FIX: DirectMusic is deprecated. - // //// Check for DMusic, which was introduced with DX6.1 - // //LPDIRECTMUSIC pDMusic = NULL; - // //CoInitialize( NULL ); - // //hr = CoCreateInstance( CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, - // // IID_IDirectMusic, (VOID**)&pDMusic ); - // //if( FAILED(hr) ) - // //{ - // // OutputDebugString( "Couldn't create CLSID_DirectMusic\r\n" ); - // // FreeLibrary( DDHinst ); - // // return; - // //} - - // //// DirectMusic was created successfully. We must be at least DX6.1 - // //(*pdwDXVersion) = 0x601; - // //pDMusic->Release(); - // //CoUninitialize(); - // - - // /////////////////////////////////////////////////////////////////////////// - // // DirectX 7.0 Checks - // /////////////////////////////////////////////////////////////////////////// - - // // Check for DirectX 7 by creating a DDraw7 object - // LPDIRECTDRAW7 pDD7; - // DirectDrawCreateEx = (DIRECTDRAWCREATEEX)GetProcAddress( DDHinst, - // "DirectDrawCreateEx" ); - // if( NULL == DirectDrawCreateEx ) - // { - // FreeLibrary( DDHinst ); - // return; - // } - - // if( FAILED( DirectDrawCreateEx( NULL, (VOID**)&pDD7, IID_IDirectDraw7, - // NULL ) ) ) - // { - // FreeLibrary( DDHinst ); - // return; - // } - - // // DDraw7 was created successfully. We must be at least DX7.0 - // (*pdwDXVersion) = 0x700; - // pDD7->Release(); - - // - // /////////////////////////////////////////////////////////////////////////// - // // End of checks - // /////////////////////////////////////////////////////////////////////////// - - // // Close open libraries and return - // FreeLibrary( DDHinst ); - // - return; -} - -int getDXVersion(){ - DWORD version,platform; - - GetDXVersion( &version,&platform ); - - return (version>>8)&0xff; -} - diff --git a/BlitzBasicLauncher/checkie.cpp b/BlitzBasicLauncher/checkie.cpp deleted file mode 100644 index 8c65532..0000000 --- a/BlitzBasicLauncher/checkie.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -#include "checkie.h" -#include - -int getIEVersion(){ - int version=0; - - HKEY key=HKEY_LOCAL_MACHINE; - if( RegOpenKey( key,"Software\\Microsoft\\Internet Explorer",&key )==ERROR_SUCCESS ){ - char buff[MAX_PATH];DWORD type,sz=MAX_PATH; - if( RegQueryValueEx( key,"Version",0,&type,(PBYTE)buff,&sz )==ERROR_SUCCESS ){ - version=4; - /* - char temp[4]; - if( isdigit(buff[0]) && buff[1]=='.' && isdigit(buff[2]) && isdigit(buff[3]) && buff[4]=='.' ){ - temp[0]=buff[0];temp[1]=buff[2];temp[2]=buff[3];temp[3]=0; - if( atoi(temp)>=471 ) version=4; - } - */ - } - RegCloseKey( key ); - } - return version; -} \ No newline at end of file diff --git a/BlitzBasicIDE/IDE (logo, no code) 32.ico b/ide/IDE (logo, no code) 32.ico similarity index 100% rename from BlitzBasicIDE/IDE (logo, no code) 32.ico rename to ide/IDE (logo, no code) 32.ico diff --git a/ide/about.cpp b/ide/about.cpp new file mode 100644 index 0000000..10de725 --- /dev/null +++ b/ide/about.cpp @@ -0,0 +1,123 @@ + +#include "libs.h" +#include "prefs.h" +#include "resource.h" +#include "stdafx.h" + +#include + +char _credits[] = + "\r\n" + "Programming and design: Mark Sibly\r\n\r\n" + "Documentation: Mark Sibly, Simon Harrison, Paul Gerfen, Shane Monroe and the Blitz Doc Team\r\n\r\n" + "Testing and support: James Boyd, Simon Armstrong and the Blitz Dev Team\r\n\r\n" + "Image loader courtesy of FreeImage by Floris van den berg\r\n\r\n" + "Please visit www.blitzbasic.com for all your Blitz related needs!"; + +/* +char _credits[]= +"\r\n" +"Programming and Design: Mark Sibly\r\n\r\n" +"Documentation: Simon Harrison; Simon Armstrong; Mark Sibly\r\n\r\n" +"Many thanks to: Claire Foley; Janet Sibly; Rick, Kay and Robbie Keam; " +"James Boyd; the Blitz Dev Team\r\n\r\n" +"Image loader courtesy of FreeImage by Floris van den Berg\r\n\r\n" +"Please visit www.blitzbasic.com for all your Blitz related needs!"; +*/ + +class Dialog : public CDialog { + bool _quit; + + public: + Dialog() : _quit(false) {} + + afx_msg void OnOK() + { + _quit = true; + } + + void wait() + { + _quit = false; + MSG msg; + while (!_quit && GetMessage(&msg, 0, 0, 0)) { + if (!AfxGetApp()->PreTranslateMessage(&msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + EndDialog(0); + } + + void wait(int n) + { + int _expire = (int)timeGetTime() + n; + for (;;) { + int tm = _expire - (int)timeGetTime(); + if (tm < 0) + tm = 0; + MsgWaitForMultipleObjects(0, 0, false, tm, QS_ALLEVENTS); + + MSG msg; + if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { + if (!AfxGetApp()->PreTranslateMessage(&msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + if (!tm) + return; + } + } +}; + +void aboutBlitz(bool delay) +{ + AfxGetMainWnd()->EnableWindow(0); + + Dialog about; + + about.Create(IDD_ABOUT); + + string credits; + + credits += _credits; + + about.GetDlgItem(IDC_CREDITS)->SetWindowText(credits.c_str()); + + int ide_ver = VERSION & 0xffff; + int lnk_ver = linker_ver & 0xffff; + int run_ver = runtime_ver & 0xffff; + string ide_v = itoa(ide_ver / 1000) + "." + itoa(ide_ver % 1000); + string lnk_v = itoa(lnk_ver / 1000) + "." + itoa(lnk_ver % 1000); + string run_v = itoa(run_ver / 1000) + "." + itoa(run_ver % 1000); + + string t = ""; + + t += "BlitzNext"; + + about.GetDlgItem(IDC_PRODUCT)->SetWindowText(t.c_str()); + + t = "IDE V" + ide_v + " Linker V" + lnk_v + " Runtime V" + run_v; + + about.GetDlgItem(IDC_VERSION)->SetWindowText(t.c_str()); + +#ifdef DEMO + + if (delay) { + about.GetDlgItem(IDOK)->ShowWindow(SW_HIDE); + about.GetDlgItem(IDC_PROGRESS1)->ShowWindow(SW_SHOW); + for (int k = 0; k < 100; ++k) { + ((CProgressCtrl*)about.GetDlgItem(IDC_PROGRESS1))->SetPos(k + 1); + about.wait(50); + } + about.GetDlgItem(IDOK)->ShowWindow(SW_SHOW); + } + +#endif + + about.GetDlgItem(IDC_PROGRESS1)->ShowWindow(SW_HIDE); + about.wait(); + about.EndDialog(0); + AfxGetMainWnd()->EnableWindow(1); +} diff --git a/BlitzBasicIDE/about.h b/ide/about.h similarity index 100% rename from BlitzBasicIDE/about.h rename to ide/about.h diff --git a/BlitzBasicIDE/b3dlogo.bmp b/ide/b3dlogo.bmp similarity index 100% rename from BlitzBasicIDE/b3dlogo.bmp rename to ide/b3dlogo.bmp diff --git a/BlitzBasicIDE/blitzide.cpp b/ide/blitzide.cpp similarity index 51% rename from BlitzBasicIDE/blitzide.cpp rename to ide/blitzide.cpp index 7f6ead6..76aed2c 100644 --- a/BlitzBasicIDE/blitzide.cpp +++ b/ide/blitzide.cpp @@ -1,18 +1,18 @@ -#include "stdafx.h" -#include "resource.h" #include "blitzide.h" -#include "mainframe.h" -#include "prefs.h" #include "about.h" #include "libs.h" +#include "mainframe.h" +#include "prefs.h" +#include "resource.h" +#include "stdafx.h" BlitzIDE blitzIDE; -BOOL BlitzIDE::InitInstance(){ - +BOOL BlitzIDE::InitInstance() +{ #ifdef _DEBUG - AfxEnableMemoryTracking( true ); + AfxEnableMemoryTracking(true); #endif AfxInitRichEdit(); @@ -21,25 +21,26 @@ BOOL BlitzIDE::InitInstance(){ initLibs(); - mainFrame=new MainFrame(); + mainFrame = new MainFrame(); m_pMainWnd = mainFrame; #ifdef DEMO - aboutBlitz( true ); + aboutBlitz(true); #endif - mainFrame->LoadFrame( IDR_MAINFRAME ); - mainFrame->MoveWindow( CRect( prefs.win_rect ) ); - mainFrame->ShowWindow( m_nCmdShow ); + mainFrame->LoadFrame(IDR_MAINFRAME); + mainFrame->MoveWindow(CRect(prefs.win_rect)); + mainFrame->ShowWindow(m_nCmdShow); mainFrame->UpdateWindow(); - if( prefs.win_maximized ) mainFrame->ShowWindow( SW_SHOWMAXIMIZED ); + if (prefs.win_maximized) + mainFrame->ShowWindow(SW_SHOWMAXIMIZED); return TRUE; } -int BlitzIDE::ExitInstance(){ - +int BlitzIDE::ExitInstance() +{ prefs.close(); return 0; diff --git a/BlitzBasicIDE/blitzide.h b/ide/blitzide.h similarity index 100% rename from BlitzBasicIDE/blitzide.h rename to ide/blitzide.h diff --git a/BlitzBasicIDE/blitzide.rc b/ide/blitzide.rc similarity index 100% rename from BlitzBasicIDE/blitzide.rc rename to ide/blitzide.rc diff --git a/BlitzBasicIDE/editor.cpp b/ide/editor.cpp similarity index 56% rename from BlitzBasicIDE/editor.cpp rename to ide/editor.cpp index 93bcc63..90e55ce 100644 --- a/BlitzBasicIDE/editor.cpp +++ b/ide/editor.cpp @@ -1,7 +1,7 @@ -#include "stdafx.h" -#include "blitzide.h" #include "editor.h" +#include "blitzide.h" +#include "stdafx.h" static bool locked; @@ -15,102 +15,122 @@ static const UINT wm_Find = RegisterWindowMessage(FINDMSGSTRING); IMPLEMENT_DYNAMIC(Editor, CWnd) BEGIN_MESSAGE_MAP(Editor, CWnd) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_SETFOCUS() - ON_WM_KILLFOCUS() - ON_WM_PAINT() - ON_WM_MOUSEMOVE() - ON_WM_LBUTTONDOWN() - ON_WM_LBUTTONUP() - ON_CONTROL(EN_CHANGE, 1, en_change) - ON_CONTROL(EN_UPDATE, 1, en_update) - ON_NOTIFY(EN_SELCHANGE, 1, en_selchange) - ON_NOTIFY(EN_PROTECTED, 1, en_protected) - ON_NOTIFY(EN_MSGFILTER, 1, en_msgfilter) - ON_REGISTERED_MESSAGE(wm_Find, onFind) +ON_WM_CREATE() +ON_WM_SIZE() +ON_WM_SETFOCUS() +ON_WM_KILLFOCUS() +ON_WM_PAINT() +ON_WM_MOUSEMOVE() +ON_WM_LBUTTONDOWN() +ON_WM_LBUTTONUP() +ON_CONTROL(EN_CHANGE, 1, en_change) +ON_CONTROL(EN_UPDATE, 1, en_update) +ON_NOTIFY(EN_SELCHANGE, 1, en_selchange) +ON_NOTIFY(EN_PROTECTED, 1, en_protected) +ON_NOTIFY(EN_MSGFILTER, 1, en_msgfilter) +ON_REGISTERED_MESSAGE(wm_Find, onFind) END_MESSAGE_MAP() -static int blink; -static set keyWordSet; +static int blink; +static set keyWordSet; static map keyWordMap; -static bool isid(int c) { +static bool isid(int c) +{ return isalnum(c) || c == '_'; } -static bool isfmt(int ch, int nxt) { +static bool isfmt(int ch, int nxt) +{ return ch == ';' || ch == '\"' || isalpha(ch) || isdigit(ch) || (ch == '$' && isxdigit(nxt)); } -static string rtfbgr(int bgr) { +static string rtfbgr(int bgr) +{ return "\\red" + itoa(bgr & 0xff) + "\\green" + itoa((bgr >> 8) & 0xff) + "\\blue" + itoa((bgr >> 16) & 0xff) + ';'; } -DWORD Editor::streamIn(LPBYTE buff, LONG cnt, LONG *done) { +DWORD Editor::streamIn(LPBYTE buff, LONG cnt, LONG* done) +{ int n = 0; while (n < cnt) { if (is_curs == is_line.size()) { - if (is_stream->peek() == EOF) break; - is_curs = 0; is_line = ""; int c = 0; + if (is_stream->peek() == EOF) + break; + is_curs = 0; + is_line = ""; + int c = 0; for (;;) { c = is_stream->get(); - if (c == '\r' || c == '\n' || c == EOF) break; - if (c == '\\' || c == '{' || c == '}') is_line += '\\'; + if (c == '\r' || c == '\n' || c == EOF) + break; + if (c == '\\' || c == '{' || c == '}') + is_line += '\\'; is_line += (char)c; } - formatStreamLine(); ++is_linenum; - if (c == '\r' && is_stream->peek() == '\n') is_stream->get(); - if (is_stream->peek() == EOF) is_line += '}'; + formatStreamLine(); + ++is_linenum; + if (c == '\r' && is_stream->peek() == '\n') + is_stream->get(); + if (is_stream->peek() == EOF) + is_line += '}'; } int sz = is_line.size() - is_curs; - if (n + sz > cnt) sz = cnt - n; + if (n + sz > cnt) + sz = cnt - n; memcpy(buff + n, is_line.data() + is_curs, sz); - is_curs += sz; n += sz; + is_curs += sz; + n += sz; } *done = n; return 0; } -DWORD CALLBACK Editor::streamIn(DWORD cookie, LPBYTE buff, LONG cnt, LONG *done) { - Editor *e = (Editor*)cookie; +DWORD CALLBACK Editor::streamIn(DWORD cookie, LPBYTE buff, LONG cnt, LONG* done) +{ + Editor* e = (Editor*)cookie; return e->streamIn(buff, cnt, done); } -DWORD CALLBACK Editor::streamOut(DWORD cookie, LPBYTE buff, LONG cnt, LONG *done) { - ostream *out = (ostream*)cookie; +DWORD CALLBACK Editor::streamOut(DWORD cookie, LPBYTE buff, LONG cnt, LONG* done) +{ + ostream* out = (ostream*)cookie; out->write((char*)buff, cnt); - *done = cnt; return 0; + *done = cnt; + return 0; } -Editor::Editor(EditorListener *l) : - listener(l), sizing(false), tabber_width(170), - fmtBusy(false), findOnly(false), found(false), - finder(0), selStart(0), selEnd(0), - findFlags(0), lineToFmt(-1) { +Editor::Editor(EditorListener* l) + : listener(l), sizing(false), tabber_width(170), fmtBusy(false), findOnly(false), found(false), finder(0), + selStart(0), selEnd(0), findFlags(0), lineToFmt(-1) +{ findBuff[0] = replaceBuff[0] = 0; - if (!blink) blink = GetCaretBlinkTime(); + if (!blink) + blink = GetCaretBlinkTime(); funcList.setListener(this); typeList.setListener(this); labsList.setListener(this); } -Editor::~Editor() { -} +Editor::~Editor() {} -void Editor::resized() { +void Editor::resized() +{ CRect r; GetClientRect(&r); int x = 0, y = 0, w = r.Width(), h = r.Height(); if (w) { - if (tabber_width < 4) tabber_width = 4; - else if (w - 64 > 0 && tabber_width > w - 64) tabber_width = w - 64; + if (tabber_width < 4) + tabber_width = 4; + else if (w - 64 > 0 && tabber_width > w - 64) + tabber_width = w - 64; } editCtrl.MoveWindow(x, y, w - tabber_width - 4, y + h); tabber.MoveWindow(w - tabber_width + 4, y, tabber_width - 4, y + h); } -void Editor::OnPaint() { +void Editor::OnPaint() +{ CPaintDC dc(this); CRect r; @@ -121,7 +141,7 @@ void Editor::OnPaint() { w = 8; CBrush br(GetSysColor(COLOR_3DFACE)); - CRect tr(x, y, x + w, y + h); + CRect tr(x, y, x + w, y + h); dc.FillRect(&tr, &br); // CRect ar( x,y,x+w,y+w ); @@ -132,7 +152,8 @@ void Editor::OnPaint() { dc.DrawEdge(&dr, EDGE_RAISED, BF_RECT); } -void Editor::OnMouseMove(UINT flags, CPoint p) { +void Editor::OnMouseMove(UINT flags, CPoint p) +{ CWnd::OnMouseMove(flags, p); CRect r; @@ -140,7 +161,8 @@ void Editor::OnMouseMove(UINT flags, CPoint p) { if (sizing) { int dx = p.x - point.x, dy = p.y - point.y; tabber_width -= dx; - resized(); Invalidate(); + resized(); + Invalidate(); point = p; } else if (abs(p.x - (r.Width() - tabber_width)) < 4) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEWE)); @@ -149,14 +171,15 @@ void Editor::OnMouseMove(UINT flags, CPoint p) { } } -void Editor::OnSize(UINT type, int sw, int sh) { +void Editor::OnSize(UINT type, int sw, int sh) +{ CWnd::OnSize(type, sw, sh); resized(); } -void Editor::OnLButtonDown(UINT flags, CPoint p) { - +void Editor::OnLButtonDown(UINT flags, CPoint p) +{ CRect r; GetClientRect(&r); @@ -168,7 +191,8 @@ void Editor::OnLButtonDown(UINT flags, CPoint p) { } } -void Editor::OnLButtonUp(UINT flags, CPoint p) { +void Editor::OnLButtonUp(UINT flags, CPoint p) +{ if (sizing) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); ReleaseCapture(); @@ -177,35 +201,38 @@ void Editor::OnLButtonUp(UINT flags, CPoint p) { SetFocus(); } -int Editor::OnCreate(LPCREATESTRUCT cs) { +int Editor::OnCreate(LPCREATESTRUCT cs) +{ CWnd::OnCreate(cs); - CHARFORMAT fmt; fmt.cbSize = sizeof(fmt); - fmt.dwMask = CFM_COLOR | CFM_PROTECTED; - fmt.dwEffects = CFE_PROTECTED; + CHARFORMAT fmt; + fmt.cbSize = sizeof(fmt); + fmt.dwMask = CFM_COLOR | CFM_PROTECTED; + fmt.dwEffects = CFE_PROTECTED; fmt.crTextColor = prefs.rgb_default; PARAFORMAT pf; memset(&pf, 0, sizeof(pf)); - pf.cbSize = sizeof(pf); - pf.dwMask = PFM_TABSTOPS; + pf.cbSize = sizeof(pf); + pf.dwMask = PFM_TABSTOPS; pf.cTabCount = MAX_TAB_STOPS; int tabTwips = 1440 * 8 / GetDeviceCaps(::GetDC(0), LOGPIXELSX) * prefs.edit_tabs; - for (int k = 0; k < MAX_TAB_STOPS; ++k) pf.rgxTabs[k] = k*tabTwips; + for (int k = 0; k < MAX_TAB_STOPS; ++k) + pf.rgxTabs[k] = k * tabTwips; CRect r(0, 0, 0, 0); - editCtrl.Create( - WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER | - ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_NOHIDESEL, - r, this, 1); + editCtrl.Create(WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER | ES_MULTILINE | ES_AUTOHSCROLL + | ES_AUTOVSCROLL | ES_NOHIDESEL, + r, this, 1); editCtrl.SetFont(&prefs.editFont); editCtrl.SetBackgroundColor(false, prefs.rgb_bkgrnd); editCtrl.SetDefaultCharFormat(fmt); editCtrl.SetEventMask(ENM_CHANGE | ENM_PROTECTED | ENM_KEYEVENTS | ENM_MOUSEEVENTS | ENM_SELCHANGE); editCtrl.SetParaFormat(pf); editCtrl.LimitText(TEXTLIMIT); - if (editCtrl.GetLimitText() != TEXTLIMIT) AfxMessageBox("Unable to set editor text Limit"); + if (editCtrl.GetLimitText() != TEXTLIMIT) + AfxMessageBox("Unable to set editor text Limit"); editCtrl.SetModify(false); tabber.Create(WS_CHILD | WS_VISIBLE | TCS_BUTTONS | TCS_HOTTRACK, r, this, 2); @@ -248,22 +275,24 @@ int Editor::OnCreate(LPCREATESTRUCT cs) { /************************************************* PUBLIC ***********************************************/ -void Editor::setName(const string &n) { +void Editor::setName(const string& n) +{ name = n; } -bool Editor::setText(istream &in) { +bool Editor::setText(istream& in) +{ // editCtrl.HideCaret(); fmtBusy = true; EDITSTREAM es; - es.dwCookie = (DWORD)this; - es.dwError = 0; + es.dwCookie = (DWORD)this; + es.dwError = 0; es.pfnCallback = streamIn; - is_line = "{{\\colortbl;" + rtfbgr(prefs.rgb_string) + rtfbgr(prefs.rgb_ident) + - rtfbgr(prefs.rgb_keyword) + rtfbgr(prefs.rgb_comment) + rtfbgr(prefs.rgb_digit) + - rtfbgr(prefs.rgb_default) + "}"; + is_line = "{{\\colortbl;" + rtfbgr(prefs.rgb_string) + rtfbgr(prefs.rgb_ident) + rtfbgr(prefs.rgb_keyword) + + rtfbgr(prefs.rgb_comment) + rtfbgr(prefs.rgb_digit) + rtfbgr(prefs.rgb_default) + "}"; int tabTwips = 1440 * 8 / GetDeviceCaps(::GetDC(0), LOGPIXELSX) * prefs.edit_tabs; - for (int k = 0; k < MAX_TAB_STOPS; ++k) is_line += "\\tx" + itoa(k*tabTwips) + ' '; + for (int k = 0; k < MAX_TAB_STOPS; ++k) + is_line += "\\tx" + itoa(k * tabTwips) + ' '; is_stream = ∈ is_curs = is_linenum = 0; funcList.clear(); @@ -276,56 +305,68 @@ bool Editor::setText(istream &in) { return es.dwError == 0; } -void Editor::setModified(bool n) { +void Editor::setModified(bool n) +{ editCtrl.SetModify(n); } -void Editor::setCursor(int n) { +void Editor::setCursor(int n) +{ int row = (n >> 16) & 0xffff, col = n & 0xffff; int pos = editCtrl.LineIndex(row) + col; editCtrl.SetSel(pos, pos); } -string Editor::getName()const { +string Editor::getName() const +{ return name; } -bool Editor::getText(ostream &out) { +bool Editor::getText(ostream& out) +{ fixFmt(true); EDITSTREAM es; - es.dwCookie = (DWORD)&out; - es.dwError = 0; + es.dwCookie = (DWORD)&out; + es.dwError = 0; es.pfnCallback = streamOut; editCtrl.StreamOut(SF_TEXT, es); return es.dwError == 0; } -void Editor::cut() { +void Editor::cut() +{ editCtrl.Cut(); } -void Editor::copy() { +void Editor::copy() +{ editCtrl.Copy(); } -void Editor::paste() { +void Editor::paste() +{ editCtrl.PasteSpecial(CF_TEXT, 0); } -bool Editor::canCutCopy() { - getSel(); return selStart != selEnd; +bool Editor::canCutCopy() +{ + getSel(); + return selStart != selEnd; } -bool Editor::canPaste() { +bool Editor::canPaste() +{ return editCtrl.CanPaste() ? true : false; } -void Editor::print() { - - static const int MARG = 720; //1440=1 inch +void Editor::print() +{ + static const int MARG = 720; //1440=1 inch CPrintDialog dlg(false); - int e = dlg.DoModal(); if (e == IDCANCEL) return; + int e = dlg.DoModal(); + if (e == IDCANCEL) + return; HDC hdc = dlg.GetPrinterDC(); if (!hdc) { @@ -338,34 +379,37 @@ void Editor::print() { SetMapMode(hdc, MM_TEXT); - FORMATRANGE fr = { 0 }; + FORMATRANGE fr = {0}; fr.hdc = fr.hdcTarget = hdc; fr.rcPage.left = fr.rcPage.top = 0; - fr.rcPage.right = (hr / px) * 1440; - fr.rcPage.bottom = (vr / py) * 1440; + fr.rcPage.right = (hr / px) * 1440; + fr.rcPage.bottom = (vr / py) * 1440; //margins - fr.rc.left = fr.rcPage.left + MARG; - fr.rc.top = fr.rcPage.top + MARG; - fr.rc.right = fr.rcPage.right - MARG; + fr.rc.left = fr.rcPage.left + MARG; + fr.rc.top = fr.rcPage.top + MARG; + fr.rc.right = fr.rcPage.right - MARG; fr.rc.bottom = fr.rcPage.bottom - MARG; char buff[MAX_PATH]; strcpy(buff, name.c_str()); - DOCINFO di = { sizeof(di) }; + DOCINFO di = {sizeof(di)}; di.lpszDocName = buff; getSel(); int start = selStart, end = selEnd; - if (start == end) { start = 0; end = editCtrl.GetTextLength(); } + if (start == end) { + start = 0; + end = editCtrl.GetTextLength(); + } StartDoc(hdc, &di); while (start < end) { StartPage(hdc); fr.chrg.cpMin = start; fr.chrg.cpMax = end; - start = editCtrl.FormatRange(&fr, true); + start = editCtrl.FormatRange(&fr, true); EndPage(hdc); } EndDoc(hdc); @@ -374,33 +418,39 @@ void Editor::print() { DeleteDC(hdc); } -void Editor::find() { - if (finder) return; - finder = new CFindReplaceDialog(); - finder->m_fr.lpstrFindWhat = findBuff; - finder->m_fr.wFindWhatLen = 256; +void Editor::find() +{ + if (finder) + return; + finder = new CFindReplaceDialog(); + finder->m_fr.lpstrFindWhat = findBuff; + finder->m_fr.wFindWhatLen = 256; finder->m_fr.lpstrReplaceWith = replaceBuff; - finder->m_fr.wReplaceWithLen = 256; + finder->m_fr.wReplaceWithLen = 256; finder->Create(findOnly = true, 0, 0, FR_HIDEUPDOWN, this); found = false; } -void Editor::replace() { - if (finder) return; - finder = new CFindReplaceDialog(); - finder->m_fr.lpstrFindWhat = findBuff; - finder->m_fr.wFindWhatLen = 256; +void Editor::replace() +{ + if (finder) + return; + finder = new CFindReplaceDialog(); + finder->m_fr.lpstrFindWhat = findBuff; + finder->m_fr.wFindWhatLen = 256; finder->m_fr.lpstrReplaceWith = replaceBuff; - finder->m_fr.wReplaceWithLen = 256; + finder->m_fr.wReplaceWithLen = 256; finder->Create(findOnly = false, 0, 0, FR_HIDEUPDOWN, this); found = false; } -bool Editor::canFind() { +bool Editor::canFind() +{ return finder == 0; } -bool Editor::findNext(bool wrap) { +bool Editor::findNext(bool wrap) +{ long start, end; editCtrl.GetSel(start, end); @@ -408,80 +458,101 @@ bool Editor::findNext(bool wrap) { memset(&t, 0, sizeof(t)); t.chrg.cpMin = end; t.chrg.cpMax = -1; - t.lpstrText = findBuff; + t.lpstrText = findBuff; if (editCtrl.FindText(findFlags, &t) >= 0) { editCtrl.SetSel(t.chrgText.cpMin, t.chrgText.cpMax); return true; } - if (!wrap) return false; + if (!wrap) + return false; t.chrg.cpMin = 0; t.chrg.cpMax = end; if (editCtrl.FindText(findFlags, &t) >= 0) { editCtrl.SetSel(t.chrgText.cpMin, t.chrgText.cpMax); return true; } - string s("Can't find \""); s += findBuff; s += '\"'; + string s("Can't find \""); + s += findBuff; + s += '\"'; MessageBox(s.c_str(), "Text not found"); - if (finder) finder->SetFocus(); + if (finder) + finder->SetFocus(); return false; } -void Editor::hilight(int pos) { +void Editor::hilight(int pos) +{ int row = (pos >> 16) & 0xffff, col = pos & 0xffff; pos = editCtrl.LineIndex(row) + col; editCtrl.HideSelection(true, false); getSel(); bool quote = false; - int end = pos, len = editCtrl.GetTextLength(); + int end = pos, len = editCtrl.GetTextLength(); while (end < len) { char temp[8]; editCtrl.SetSel(end, end + 1); auto txt = editCtrl.GetSelText(); - if (txt[0] == '\"') quote = !quote; - if (!quote && (txt[0] == ':' || !isprint(txt[0]))) break; + if (txt[0] == '\"') + quote = !quote; + if (!quote && (txt[0] == ':' || !isprint(txt[0]))) + break; ++end; } editCtrl.HideSelection(false, false); editCtrl.SetSel(pos, end); } -void Editor::selectAll() { +void Editor::selectAll() +{ editCtrl.SetSel(0, -1); } -void Editor::lock() { +void Editor::lock() +{ locked = true; } -void Editor::unlock() { +void Editor::unlock() +{ locked = false; } -string Editor::getKeyword() { +string Editor::getKeyword() +{ fixFmt(true); getSel(); - int ln = editCtrl.LineFromChar(selStart); - int pos = selStart - editCtrl.LineIndex(ln); - string line = getLine(ln); if (pos > line.size()) return ""; + int ln = editCtrl.LineFromChar(selStart); + int pos = selStart - editCtrl.LineIndex(ln); + string line = getLine(ln); + if (pos > line.size()) + return ""; //ok, scan back until we have an isapha char preceded by a nonalnum/non '_' char for (;;) { - while (pos > 0 && (!isalpha(line[pos]) || isid(line[pos - 1]))) --pos; - if (!isalpha(line[pos])) return ""; - int end = pos; while (end < line.size() && isid(line[end])) ++end; + while (pos > 0 && (!isalpha(line[pos]) || isid(line[pos - 1]))) + --pos; + if (!isalpha(line[pos])) + return ""; + int end = pos; + while (end < line.size() && isid(line[end])) + ++end; string t = line.substr(pos, end - pos); - if (keyWordSet.find(t) != keyWordSet.end()) return t; - if (!pos) return ""; + if (keyWordSet.find(t) != keyWordSet.end()) + return t; + if (!pos) + return ""; --pos; } } -bool Editor::getModified() { +bool Editor::getModified() +{ return editCtrl.GetModify() ? true : false; } -int Editor::getCursor() { +int Editor::getCursor() +{ long start, end; editCtrl.GetSel(start, end); int row, col; @@ -490,42 +561,53 @@ int Editor::getCursor() { return ((row) << 16) | (col); } -void Editor::getCursor(int *row, int *col) { +void Editor::getCursor(int* row, int* col) +{ long start, end; editCtrl.GetSel(start, end); *row = editCtrl.LineFromChar(end); *col = end - editCtrl.LineIndex(*row); } -void Editor::addKeyword(const string &s) { +void Editor::addKeyword(const string& s) +{ keyWordSet.insert(s); string t = s; - for (int k = 0; k < t.size(); ++k) t[k] = tolower(t[k]); + for (int k = 0; k < t.size(); ++k) + t[k] = tolower(t[k]); keyWordMap[t] = s; } /************************************************* PRIVATE ***********************************************/ -void Editor::endFind() { - if (!finder) return; +void Editor::endFind() +{ + if (!finder) + return; finder->DestroyWindow(); finder = 0; } -LRESULT Editor::onFind(WPARAM w, LPARAM l) { - if (!finder) return 0; +LRESULT Editor::onFind(WPARAM w, LPARAM l) +{ + if (!finder) + return 0; findFlags = 0; - if (finder->MatchCase()) findFlags |= FR_MATCHCASE; - if (finder->MatchWholeWord()) findFlags |= FR_WHOLEWORD; + if (finder->MatchCase()) + findFlags |= FR_MATCHCASE; + if (finder->MatchWholeWord()) + findFlags |= FR_WHOLEWORD; strcpy(findBuff, finder->GetFindString()); strcpy(replaceBuff, finder->GetReplaceString()); if (finder->FindNext()) { found = findNext(true); - if (found && findOnly) endFind(); + if (found && findOnly) + endFind(); } else if (finder->ReplaceCurrent()) { - if (found) editCtrl.ReplaceSel(replaceBuff, true); + if (found) + editCtrl.ReplaceSel(replaceBuff, true); found = findNext(true); } else if (finder->ReplaceAll()) { int cnt = 0; @@ -536,96 +618,115 @@ LRESULT Editor::onFind(WPARAM w, LPARAM l) { ++cnt; } endFind(); - char buff[32]; itoa(cnt, buff, 10); - string s(buff); s += " occurances replaced"; + char buff[32]; + itoa(cnt, buff, 10); + string s(buff); + s += " occurances replaced"; MessageBox(s.c_str(), "Replace All Done"); editCtrl.HideSelection(false, false); } - if (finder && finder->IsTerminating()) endFind(); + if (finder && finder->IsTerminating()) + endFind(); return 0; } -void Editor::caret() { - if (!prefs.edit_blkcursor) return; +void Editor::caret() +{ + if (!prefs.edit_blkcursor) + return; long start, end; editCtrl.GetSel(start, end); if (start == end) { editCtrl.CreateSolidCaret(8, 13); editCtrl.ShowCaret(); - } else editCtrl.HideCaret(); + } else + editCtrl.HideCaret(); } -void Editor::OnSetFocus(CWnd *wnd) { - if (prefs.edit_blkcursor) SetCaretBlinkTime(200); +void Editor::OnSetFocus(CWnd* wnd) +{ + if (prefs.edit_blkcursor) + SetCaretBlinkTime(200); editCtrl.SetFocus(); caret(); } -void Editor::OnKillFocus(CWnd *wnd) { +void Editor::OnKillFocus(CWnd* wnd) +{ CWnd::OnKillFocus(wnd); fixFmt(true); } -string Editor::getLine(int line) { +string Editor::getLine(int line) +{ int idx1 = editCtrl.LineIndex(line); - int idx2 = editCtrl.LineIndex(line + 1); if (idx2 == -1) idx2 = editCtrl.GetTextLength(); - int len = idx2 - idx1; - char *buff = new char[len > 3 ? len + 1 : 4]; + int idx2 = editCtrl.LineIndex(line + 1); + if (idx2 == -1) + idx2 = editCtrl.GetTextLength(); + int len = idx2 - idx1; + char* buff = new char[len > 3 ? len + 1 : 4]; *(int*)buff = len; - int out = editCtrl.GetLine(line, buff); - buff[len] = 0; - string t = string(buff); + int out = editCtrl.GetLine(line, buff); + buff[len] = 0; + string t = string(buff); delete[] buff; return t; } -void Editor::funcSelected(int line) { +void Editor::funcSelected(int line) +{ int pos = editCtrl.LineIndex(line); editCtrl.SetSel(editCtrl.GetTextLength() - 1, editCtrl.GetTextLength() - 1); editCtrl.SetSel(pos, pos); SetFocus(); } -void Editor::currentSet(Tabber *tabber, int index) { +void Editor::currentSet(Tabber* tabber, int index) +{ SetFocus(); } -void Editor::cursorMoved() { +void Editor::cursorMoved() +{ listener->cursorMoved(this); } -void Editor::en_update() { +void Editor::en_update() +{ caret(); } -void Editor::en_msgfilter(NMHDR *nmhdr, LRESULT *result) { - if (locked || fmtBusy) { *result = 1; return; } +void Editor::en_msgfilter(NMHDR* nmhdr, LRESULT* result) +{ + if (locked || fmtBusy) { + *result = 1; + return; + } *result = 0; getSel(); - MSGFILTER *msg = (MSGFILTER*)nmhdr; - + MSGFILTER* msg = (MSGFILTER*)nmhdr; if (msg->msg == WM_RBUTTONDOWN) { - CPoint p(LOWORD(msg->lParam), HIWORD(msg->lParam)); ClientToScreen(&p); - CMenu *menu = blitzIDE.mainFrame->GetMenu(); + CMenu* menu = blitzIDE.mainFrame->GetMenu(); - CMenu *edit = menu->GetSubMenu(1); + CMenu* edit = menu->GetSubMenu(1); edit->TrackPopupMenu(TPM_LEFTALIGN, p.x, p.y, blitzIDE.mainFrame); } else if (msg->msg == WM_CHAR) { if (msg->wParam == '\t') { int lineStart = editCtrl.LineFromChar(selStart); - int lineEnd = editCtrl.LineFromChar(selEnd); - if (lineEnd <= lineStart) return; + int lineEnd = editCtrl.LineFromChar(selEnd); + if (lineEnd <= lineStart) + return; editCtrl.HideSelection(true, false); if (GetAsyncKeyState(VK_SHIFT) & 0x80000000) { char buff[4]; @@ -633,25 +734,32 @@ void Editor::en_msgfilter(NMHDR *nmhdr, LRESULT *result) { int n = editCtrl.LineIndex(line); editCtrl.SetSel(n, n + 1); auto txt = editCtrl.GetSelText(); - if (txt[0] == '\t') editCtrl.ReplaceSel("", true); + if (txt[0] == '\t') + editCtrl.ReplaceSel("", true); } } else { for (int line = lineStart; line < lineEnd; ++line) { int n = editCtrl.LineIndex(line); - editCtrl.SetSel(n, n); editCtrl.ReplaceSel("\t", true); + editCtrl.SetSel(n, n); + editCtrl.ReplaceSel("\t", true); } } selStart = editCtrl.LineIndex(lineStart); - selEnd = editCtrl.LineIndex(lineEnd); - setSel(); *result = 1; + selEnd = editCtrl.LineIndex(lineEnd); + setSel(); + *result = 1; editCtrl.HideSelection(false, false); } else if (msg->wParam == 13) { - if (selStart != selEnd) return; - int k; - int ln = editCtrl.LineFromChar(selStart); - int pos = selStart - editCtrl.LineIndex(ln); - string line = getLine(ln); if (pos > line.size()) return; - for (k = 0; k < pos && line[k] == '\t'; ++k) {} + if (selStart != selEnd) + return; + int k; + int ln = editCtrl.LineFromChar(selStart); + int pos = selStart - editCtrl.LineIndex(ln); + string line = getLine(ln); + if (pos > line.size()) + return; + for (k = 0; k < pos && line[k] == '\t'; ++k) { + } line = "\r\n" + line.substr(0, k) + '\0'; editCtrl.ReplaceSel(line.data(), true); *result = 1; @@ -660,30 +768,37 @@ void Editor::en_msgfilter(NMHDR *nmhdr, LRESULT *result) { caret(); } -void Editor::en_selchange(NMHDR *nmhdr, LRESULT *result) { - if (!fmtBusy) fixFmt(false); +void Editor::en_selchange(NMHDR* nmhdr, LRESULT* result) +{ + if (!fmtBusy) + fixFmt(false); cursorMoved(); caret(); } -void Editor::en_protected(NMHDR *nmhdr, LRESULT *result) { - *result = 0; if (fmtBusy) return; +void Editor::en_protected(NMHDR* nmhdr, LRESULT* result) +{ + *result = 0; + if (fmtBusy) + return; fmtLineCount = editCtrl.GetLineCount(); - found = false; + found = false; } -void Editor::en_change() { - if (fmtBusy) return; +void Editor::en_change() +{ + if (fmtBusy) + return; fmtBusy = true; editCtrl.HideSelection(true, false); getSel(); int begin = editCtrl.LineFromChar(selStart); - int end = begin + 1; + int end = begin + 1; int lineCount = editCtrl.GetLineCount(); - int delta = lineCount - fmtLineCount; + int delta = lineCount - fmtLineCount; if (delta > 0) { begin -= delta; @@ -707,18 +822,21 @@ void Editor::en_change() { labsList.remove(begin, end); } - for (int n = begin; n < end; ++n) formatLine(n); + for (int n = begin; n < end; ++n) + formatLine(n); - setSel(); editCtrl.HideSelection(false, false); + setSel(); + editCtrl.HideSelection(false, false); fmtBusy = false; cursorMoved(); } -void Editor::setFormat(int from, int to, int color, const string &s) { +void Editor::setFormat(int from, int to, int color, const string& s) +{ editCtrl.SetSel(from, to); if (s.size()) { - char buff[256]; - CString txt = editCtrl.GetSelText(); + char buff[256]; + CString txt = editCtrl.GetSelText(); txt[to - from] = 0; if (string(buff) != s) { editCtrl.ReplaceSel(s.c_str()); @@ -727,46 +845,59 @@ void Editor::setFormat(int from, int to, int color, const string &s) { } CHARFORMAT fmt; fmt.cbSize = sizeof(fmt); - DWORD t = editCtrl.GetSelectionCharFormat(fmt); - if ((t&CFM_COLOR) && fmt.crTextColor == color) return; - fmt.dwMask = CFM_COLOR | CFM_PROTECTED; - fmt.dwEffects = CFE_PROTECTED; + DWORD t = editCtrl.GetSelectionCharFormat(fmt); + if ((t & CFM_COLOR) && fmt.crTextColor == color) + return; + fmt.dwMask = CFM_COLOR | CFM_PROTECTED; + fmt.dwEffects = CFE_PROTECTED; fmt.crTextColor = color; editCtrl.SetSelectionCharFormat(fmt); } -void Editor::formatStreamLine() { +void Editor::formatStreamLine() +{ string out; - char cf = '0'; - for (int k = 0; k < is_line.size(); ) { - int from = k; - char pf = cf; - int c = is_line[k], is_sz = is_line.size(); + char cf = '0'; + for (int k = 0; k < is_line.size();) { + int from = k; + char pf = cf; + int c = is_line[k], is_sz = is_line.size(); if (!isgraph(c)) { - for (++k; k < is_sz && !isgraph(is_line[k]); ++k) {} + for (++k; k < is_sz && !isgraph(is_line[k]); ++k) { + } } else if (!isfmt(c, k + 1 < is_sz ? is_line[k + 1] : 0)) { - for (++k; k < is_sz && !isfmt(is_line[k], k + 1 < is_sz ? is_line[k + 1] : 0); ++k) {} + for (++k; k < is_sz && !isfmt(is_line[k], k + 1 < is_sz ? is_line[k + 1] : 0); ++k) { + } cf = '6'; - } else if (c == ';') { //comment? - k = is_sz; + } else if (c == ';') { //comment? + k = is_sz; cf = '4'; - } else if (c == '\"') { //string const? - for (++k; k < is_sz && is_line[k] != '\"'; ++k) {} - if (k < is_sz) ++k; + } else if (c == '\"') { //string const? + for (++k; k < is_sz && is_line[k] != '\"'; ++k) { + } + if (k < is_sz) + ++k; cf = '1'; - } else if (isalpha(c)) { //ident? - for (++k; k < is_sz && isid(is_line[k]); ++k) {} - if (keyWordSet.find(is_line.substr(from, k - from)) == keyWordSet.end()) cf = '2'; - else cf = '3'; + } else if (isalpha(c)) { //ident? + for (++k; k < is_sz && isid(is_line[k]); ++k) { + } + if (keyWordSet.find(is_line.substr(from, k - from)) == keyWordSet.end()) + cf = '2'; + else + cf = '3'; } else if (c == '$') { - for (++k; k < is_sz && isxdigit(is_line[k]); ++k) {} + for (++k; k < is_sz && isxdigit(is_line[k]); ++k) { + } cf = '5'; - } else if (isdigit(c)) { //numeric const? - for (++k; k < is_sz && isdigit(is_line[k]); ++k) {} + } else if (isdigit(c)) { //numeric const? + for (++k; k < is_sz && isdigit(is_line[k]); ++k) { + } cf = '5'; } if (cf != pf) { - out += "\\cf"; out += cf; out += ' '; + out += "\\cf"; + out += cf; + out += ' '; } out += is_line.substr(from, k - from); } @@ -774,7 +905,8 @@ void Editor::formatStreamLine() { for (int k = 8; k < is_line.size(); ++k) { if (isalpha(is_line[k])) { int start = k; - for (++k; k < is_line.size() && isid(is_line[k]); ++k) {} + for (++k; k < is_line.size() && isid(is_line[k]); ++k) { + } funcList.insert(is_linenum, is_line.substr(start, k - start)); break; } @@ -783,7 +915,8 @@ void Editor::formatStreamLine() { for (int k = 4; k < is_line.size(); ++k) { if (isalpha(is_line[k])) { int start = k; - for (++k; k < is_line.size() && isid(is_line[k]); ++k) {} + for (++k; k < is_line.size() && isid(is_line[k]); ++k) { + } typeList.insert(is_linenum, is_line.substr(start, k - start)); break; } @@ -792,7 +925,8 @@ void Editor::formatStreamLine() { for (int k = 1; k < is_line.size(); ++k) { if (isalpha(is_line[k])) { int start = k; - for (++k; k < is_line.size() && isid(is_line[k]); ++k) {} + for (++k; k < is_line.size() && isid(is_line[k]); ++k) { + } labsList.insert(is_linenum, is_line.substr(start, k - start)); break; } @@ -801,65 +935,86 @@ void Editor::formatStreamLine() { is_line = out + "\\line "; } -void Editor::fixFmt(bool fmt) { - if (lineToFmt < 0 || fmtBusy) return; +void Editor::fixFmt(bool fmt) +{ + if (lineToFmt < 0 || fmtBusy) + return; fmtBusy = true; - editCtrl.HideSelection(true, false); getSel(); - long start = selStart; if (fmt) selStart = -1; + editCtrl.HideSelection(true, false); + getSel(); + long start = selStart; + if (fmt) + selStart = -1; formatLine(lineToFmt); - selStart = start; setSel(); editCtrl.HideSelection(false, false); + selStart = start; + setSel(); + editCtrl.HideSelection(false, false); fmtBusy = false; } -void Editor::formatLine(int ln) { - if (ln < 0 || ln >= editCtrl.GetLineCount()) return; +void Editor::formatLine(int ln) +{ + if (ln < 0 || ln >= editCtrl.GetLineCount()) + return; - lineToFmt = -1; - int pos = editCtrl.LineIndex(ln); + lineToFmt = -1; + int pos = editCtrl.LineIndex(ln); string tline = getLine(ln); - string line = tolower(tline); + string line = tolower(tline); - int *cf = 0; + int* cf = 0; string rep; - for (int k = 0; k < line.size(); ) { + for (int k = 0; k < line.size();) { rep.resize(0); - int *pf = cf; - int from = k, c = line[k], sz = line.size(); + int* pf = cf; + int from = k, c = line[k], sz = line.size(); if (!isgraph(c)) { - for (++k; k < sz && !isgraph(line[k]); ++k) {} + for (++k; k < sz && !isgraph(line[k]); ++k) { + } } else if (!isfmt(c, k + 1 < sz ? line[k + 1] : 0)) { - for (++k; k < sz && !isfmt(line[k], k + 1 < sz ? line[k + 1] : 0); ++k) {} + for (++k; k < sz && !isfmt(line[k], k + 1 < sz ? line[k + 1] : 0); ++k) { + } cf = &prefs.rgb_default; - } else if (c == ';') { //comment? - k = sz; + } else if (c == ';') { //comment? + k = sz; cf = &prefs.rgb_comment; - } else if (c == '\"') { //string const? - for (++k; k < sz && line[k] != '\"'; ++k) {} - if (k < sz) ++k; + } else if (c == '\"') { //string const? + for (++k; k < sz && line[k] != '\"'; ++k) { + } + if (k < sz) + ++k; cf = &prefs.rgb_string; - } else if (isalpha(c)) { //ident? - for (++k; k < sz && isid(line[k]); ++k) {} - cf = &prefs.rgb_ident; pf = 0; + } else if (isalpha(c)) { //ident? + for (++k; k < sz && isid(line[k]); ++k) { + } + cf = &prefs.rgb_ident; + pf = 0; if (selStart <= pos + from || selStart > pos + k) { map::iterator it = keyWordMap.find(line.substr(from, k - from)); if (it != keyWordMap.end()) { - rep = it->second; cf = &prefs.rgb_keyword; + rep = it->second; + cf = &prefs.rgb_keyword; } - } else lineToFmt = ln; + } else + lineToFmt = ln; } else if (c == '$' && k + 1 < sz && isxdigit(line[k + 1])) { - for (++k; k < sz && isxdigit(line[k]); ++k) {} + for (++k; k < sz && isxdigit(line[k]); ++k) { + } cf = &prefs.rgb_digit; - } else if (isdigit(c)) { //numeric const? - for (++k; k < sz && isdigit(line[k]); ++k) {} + } else if (isdigit(c)) { //numeric const? + for (++k; k < sz && isdigit(line[k]); ++k) { + } cf = &prefs.rgb_digit; } - if (cf != pf) setFormat(pos + from, pos + k, *cf, rep); + if (cf != pf) + setFormat(pos + from, pos + k, *cf, rep); } if (line[0] == 'f' && line.find("function") == 0) { for (int k = 8; k < line.size(); ++k) { if (isalpha(line[k])) { int start = k; - for (++k; k < line.size() && isid(line[k]); ++k) {} + for (++k; k < line.size() && isid(line[k]); ++k) { + } funcList.insert(ln, tline.substr(start, k - start)); break; } @@ -868,7 +1023,8 @@ void Editor::formatLine(int ln) { for (int k = 4; k < line.size(); ++k) { if (isalpha(line[k])) { int start = k; - for (++k; k < line.size() && isid(line[k]); ++k) {} + for (++k; k < line.size() && isid(line[k]); ++k) { + } typeList.insert(ln, tline.substr(start, k - start)); break; } @@ -877,7 +1033,8 @@ void Editor::formatLine(int ln) { for (int k = 1; k < line.size(); ++k) { if (isalpha(line[k])) { int start = k; - for (++k; k < line.size() && isid(line[k]); ++k) {} + for (++k; k < line.size() && isid(line[k]); ++k) { + } labsList.insert(ln, tline.substr(start, k - start)); break; } diff --git a/BlitzBasicIDE/editor.h b/ide/editor.h similarity index 100% rename from BlitzBasicIDE/editor.h rename to ide/editor.h diff --git a/ide/funclist.cpp b/ide/funclist.cpp new file mode 100644 index 0000000..3352fb2 --- /dev/null +++ b/ide/funclist.cpp @@ -0,0 +1,78 @@ + +#include "funclist.h" +#include "stdafx.h" + +IMPLEMENT_DYNAMIC(FuncList, CListCtrl) +BEGIN_MESSAGE_MAP(FuncList, CListCtrl) +ON_WM_CREATE() +ON_NOTIFY_REFLECT(NM_CLICK, nm_click) +END_MESSAGE_MAP() + +FuncList::FuncList() : listener(0) {} + +void FuncList::setListener(FuncListListener* l) +{ + listener = l; +} + +int FuncList::OnCreate(LPCREATESTRUCT cs) +{ + CListCtrl::OnCreate(cs); + + return 0; +} + +void FuncList::nm_click(NMHDR* nmhdr, LRESULT* result) +{ + NMLISTVIEW* lv = (NMLISTVIEW*)nmhdr; + + int k = 0; + Funcs::iterator it; + for (it = funcs.begin(); it != funcs.end() && k < lv->iItem; ++k, ++it) { + } + if (it != funcs.end()) { + listener->funcSelected(*it); + } + *result = 0; +} + +void FuncList::clear() +{ + funcs.clear(); + DeleteAllItems(); +} + +void FuncList::insert(int line, const string& func) +{ + int n = 0; + Funcs::iterator it; + for (it = funcs.begin(); it != funcs.end() && line > *it; ++n, ++it) { + } + if (it != funcs.end() && line == *it) { + SetItemText(n, 0, func.c_str()); + return; + } + it = funcs.insert(it, line); + InsertItem(n, func.c_str()); +} + +void FuncList::remove(int begin, int end) +{ + int n = 0; + Funcs::iterator it; + for (it = funcs.begin(); it != funcs.end() && *it < begin; ++n, ++it) { + } + while (it != funcs.end() && *it < end) { + funcs.erase(it++); + DeleteItem(n); + } +} + +void FuncList::relocate(int begin, int offset) +{ + Funcs::iterator it; + for (it = funcs.begin(); it != funcs.end(); ++it) { + if (*it >= begin) + *it += offset; + } +} diff --git a/BlitzBasicIDE/funclist.h b/ide/funclist.h similarity index 100% rename from BlitzBasicIDE/funclist.h rename to ide/funclist.h diff --git a/ide/htmlhelp.cpp b/ide/htmlhelp.cpp new file mode 100644 index 0000000..04d0e8e --- /dev/null +++ b/ide/htmlhelp.cpp @@ -0,0 +1,40 @@ + +#include "htmlhelp.h" +#include "libs.h" +#include "mainframe.h" +#include "stdafx.h" + +IMPLEMENT_DYNAMIC(HtmlHelp, CHtmlView) +BEGIN_MESSAGE_MAP(HtmlHelp, CHtmlView) +ON_WM_ERASEBKGND() +END_MESSAGE_MAP() + +string HtmlHelp::getTitle() +{ + return title; +} + +void HtmlHelp::OnTitleChange(LPCTSTR t) +{ + listener->helpTitleChange(this, title = t); +} + +void HtmlHelp::OnBeforeNavigate2(LPCTSTR url, DWORD flags, LPCTSTR target, CByteArray& posted, LPCTSTR headers, + BOOL* cancel) +{ + string t(url); + int attr = GetFileAttributes(url); + if (attr == -1) + attr = 0; + if ((attr & FILE_ATTRIBUTE_DIRECTORY) || (t.rfind(".bb") + 3 == t.size()) || (isMediaFile(t))) { + listener->helpOpen(this, t); + *cancel = true; + return; + } + *cancel = false; +} + +BOOL HtmlHelp::OnEraseBkgnd(CDC* dc) +{ + return true; +} diff --git a/BlitzBasicIDE/htmlhelp.h b/ide/htmlhelp.h similarity index 100% rename from BlitzBasicIDE/htmlhelp.h rename to ide/htmlhelp.h diff --git a/ide/libs.cpp b/ide/libs.cpp new file mode 100644 index 0000000..73009f7 --- /dev/null +++ b/ide/libs.cpp @@ -0,0 +1,137 @@ + +#include "libs.h" +#include "blitzide.h" +#include "editor.h" +#include "stdafx.h" + +static map keyhelps; + +int linker_ver, runtime_ver; + +static string execProc(const string& proc) +{ + HANDLE rd, wr; + + SECURITY_ATTRIBUTES sa = {sizeof(sa), 0, true}; + + if (CreatePipe(&rd, &wr, &sa, 0)) { + STARTUPINFO si = {sizeof(si)}; + si.dwFlags = STARTF_USESTDHANDLES; + si.hStdOutput = si.hStdError = wr; + PROCESS_INFORMATION pi = {0}; + if (CreateProcess(0, (char*)proc.c_str(), 0, 0, true, DETACHED_PROCESS, 0, 0, &si, &pi)) { + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + CloseHandle(wr); + + string t; + char* buf = new char[1024]; + for (;;) { + unsigned long sz; + int n = ReadFile(rd, buf, 1024, &sz, 0); + if (!n && GetLastError() == ERROR_BROKEN_PIPE) + break; + if (!n) { + t = ""; + break; + } + if (!sz) + break; + t += string(buf, sz); + } + delete[] buf; + CloseHandle(rd); + return t; + } + CloseHandle(rd); + CloseHandle(wr); + } + AfxMessageBox((proc + " failed").c_str()); + ExitProcess(0); + return ""; +} + +int version(string vers, string t) +{ + t += " version:"; + int n = vers.find(t); + n += t.size(); + int maj = atoi(vers.substr(n)); + n = vers.find('.', n) + 1; + int min = atoi(vers.substr(n)); + return maj * 100 + min; +} + +void initLibs() +{ + string valid = execProc(prefs.homeDir + "/bin/blitzcc -q"); + if (valid.size()) { + AfxMessageBox(("Compiler environment error: " + valid).c_str()); + ExitProcess(0); + } + + string vers = tolower(execProc(prefs.homeDir + "/bin/blitzcc -v")); + linker_ver = version(vers, "linker"); + runtime_ver = version(vers, "runtime"); + + //generate keywords! + string kws = execProc(prefs.homeDir + "/bin/blitzcc +k"); + + if (!kws.size()) { + AfxMessageBox("Error generating keywords"); + ExitProcess(0); + } + + int pos = 0, n; + while ((n = kws.find('\n', pos)) != string::npos) { + string t = kws.substr(pos, n - pos - 1); + for (int q = 0; (q = t.find('\r', q)) != string::npos;) + t = t.replace(q, 1, ""); + + string help = t; + int i = t.find(' '); + if (i != string::npos) { + t = t.substr(0, i); + if (!t.size()) { + AfxMessageBox("Error in keywords"); + ExitProcess(0); + } + if (!isalnum(t[t.size() - 1])) + t = t.substr(0, t.size() - 1); + } + + Editor::addKeyword(t); + keyhelps[t] = help; + pos = n + 1; + } +} + +string quickHelp(const string& kw) +{ + map::const_iterator it = keyhelps.find(kw); + return it == keyhelps.end() ? "" : it->second; +} + +bool isMediaFile(const string& f) +{ +#ifndef PRO + return false; +#endif + + static char* exts[] = {"bmp", "jpg", "png", "tga", "iff", "pcx", "wav", "mid", "mp3", + "mod", "s3m", "xm", "it", "rmi", "sgt", "x", "3ds", 0}; + + int i = f.rfind('.'); + if (i == string::npos || i + 1 == f.size()) + return false; + string ext = f.substr(i + 1); + char** p = exts; + while (const char* e = *p++) { + string t(e); + if (i + t.size() + 1 != f.size()) + continue; + if (ext == t) + return true; + } + return false; +} diff --git a/BlitzBasicIDE/libs.h b/ide/libs.h similarity index 100% rename from BlitzBasicIDE/libs.h rename to ide/libs.h diff --git a/ide/mainframe.cpp b/ide/mainframe.cpp new file mode 100644 index 0000000..be278bc --- /dev/null +++ b/ide/mainframe.cpp @@ -0,0 +1,1096 @@ + +#include "mainframe.h" +#include "about.h" +#include "blitzide.h" +#include "libs.h" +#include "resource.h" +#include "stdafx.h" + +#include + +#include +#include + +IMPLEMENT_DYNAMIC(MainFrame, CFrameWnd) +BEGIN_MESSAGE_MAP(MainFrame, CFrameWnd) +ON_WM_CREATE() +ON_WM_CLOSE() +ON_WM_DESTROY() +ON_WM_ERASEBKGND() +ON_WM_SIZE() +ON_WM_ACTIVATE() + +ON_COMMAND(Inew, fileNew) +ON_COMMAND(ID_OPEN, fileOpen) +ON_COMMAND(ID_SAVE, fileSave) +ON_COMMAND(ID_SAVEAS, fileSaveAs) +ON_COMMAND(ID_SAVEALL, fileSaveAll) +ON_COMMAND(ID_PRINT, filePrint) +ON_COMMAND(ID_CLOSE, fileClose) +ON_COMMAND(ID_CLOSEALL, fileCloseAll) +ON_COMMAND(ID_EXIT, fileExit) +ON_COMMAND_RANGE(333, 343, fileRecent) +ON_COMMAND(ID_CUT, editCut) +ON_COMMAND(ID_COPY, editCopy) +ON_COMMAND(ID_PASTE, editPaste) +ON_COMMAND(ID_SELECTALL, editSelectAll) +ON_COMMAND(ID_FIND, editFind) +ON_COMMAND(ID_FINDNEXT, editFindNext) +ON_COMMAND(ID_REPLACE, editReplace) +ON_COMMAND(ID_CTRLTAB, ctrlTab) +ON_COMMAND(ID_CTRLSHIFTTAB, ctrlShiftTab) +ON_COMMAND(ID_ESCAPE, escape) +ON_COMMAND(ID_QUICKHELP, quick_Help) + +ON_COMMAND(ID_EXECUTE, programExecute) +ON_COMMAND(ID_REEXECUTE, programReExecute) +ON_COMMAND(ID_COMPILE, programCompile) +ON_COMMAND(ID_PUBLISH, programPublish) +ON_COMMAND(ID_COMMANDLINE, programCommandLine) +ON_COMMAND(ID_DEBUG, programDebug) + +ON_COMMAND(ID_HOME, helpHome) +ON_COMMAND(ID_BACK, helpBack) +ON_COMMAND(ID_FORWARD, helpForward) +ON_COMMAND(ID_ABOUT, helpAbout) + +ON_UPDATE_COMMAND_UI(Inew, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_OPEN, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_SAVE, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_SAVEAS, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_SAVEALL, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_PRINT, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_CLOSE, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_CLOSEALL, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_CUT, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_COPY, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_PASTE, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_SELECTALL, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_FIND, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_FINDNEXT, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_REPLACE, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_EXECUTE, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_REEXECUTE, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_COMPILE, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_PUBLISH, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_COMMANDLINE, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_DEBUG, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_HOME, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_BACK, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_FORWARD, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_ESCAPE, updateCmdUI) +ON_UPDATE_COMMAND_UI(ID_QUICKHELP, updateCmdUI) +ON_UPDATE_COMMAND_UI_RANGE(333, 343, updateCmdUIRange) +END_MESSAGE_MAP() + +enum { TAB_INVALID, TAB_EDITOR, TAB_HTMLHELP, TAB_DEBUGLOG }; + +static string getFile(const string& f) +{ + int n; + string t = f; + n = t.rfind('/'); + if (n != string::npos) + t = t.substr(n + 1); + n = t.rfind('\\'); + if (n != string::npos) + t = t.substr(n + 1); + return t; +} + +static string getPath(const string& f) +{ + int n; + string t = f; + n = t.rfind('/'); + if (n != string::npos) + t = t.substr(0, n); + n = t.rfind('\\'); + if (n != string::npos) + t = t.substr(0, n); + return t; +} + +MainFrame::MainFrame() : exit_flag(false) {} + +int MainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + CFrameWnd::OnCreate(lpCreateStruct); + + static HBITMAP toolbmp; + static SIZE imgsz, butsz; + static UINT toolbuts[] = {Inew, ID_OPEN, ID_SAVE, ID_CLOSE, ID_SEPARATOR, ID_CUT, + ID_COPY, ID_PASTE, ID_SEPARATOR, ID_FIND, ID_SEPARATOR, ID_EXECUTE, + ID_SEPARATOR, ID_HOME, ID_BACK, ID_FORWARD}; + static int toolcnt = sizeof(toolbuts) / sizeof(UINT); + + if (!toolbmp) { + BITMAP bm; + string t = prefs.homeDir + "/cfg/ide_toolbar.bmp"; + toolbmp = (HBITMAP)LoadImage(0, t.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_LOADMAP3DCOLORS); + if (!toolbmp) { + AfxMessageBox("toolbar bitmap failed to load!"); + ExitProcess(0); + } + GetObject(toolbmp, sizeof(bm), &bm); + int n = 0; + for (int k = 0; k < toolcnt; ++k) + if (toolbuts[k] != ID_SEPARATOR) + ++n; + imgsz.cx = bm.bmWidth / n; + imgsz.cy = bm.bmHeight; + butsz.cx = imgsz.cx + 7; + butsz.cy = imgsz.cy + 6; + } + toolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS); + toolBar.SetBitmap(toolbmp); + toolBar.SetSizes(butsz, imgsz); + toolBar.SetButtons(toolbuts, toolcnt); + + int style; + style = WS_CHILD | WS_VISIBLE | CBRS_ALIGN_BOTTOM; + statusBar.CreateEx(this, 0, style); + UINT IDS[] = {ID_STATUSTEXT, ID_COLROWTEXT}; + statusBar.SetIndicators(IDS, 2); + statusBar.SetPaneInfo(0, ID_STATUSTEXT, SBPS_NOBORDERS | SBPS_STRETCH, 0); + statusBar.SetPaneInfo(1, ID_COLROWTEXT, 0, 128); + statusBar.SetPaneText(0, ""); + statusBar.SetPaneText(1, ""); + + tabber.Create(WS_VISIBLE | WS_CHILD | TCS_HOTTRACK, CRect(0, 0, 0, 0), this, 1); + tabber.SetFont(&prefs.tabsFont); + tabber.setListener(this); + + prefs.win_notoolbar = !prefs.win_notoolbar; + escape(); + + //create recent file list + CMenu menu; + menu.CreatePopupMenu(); + for (int k = 0; k < prefs.recentFiles.size(); ++k) { + menu.InsertMenu(k, MF_BYPOSITION | MF_ENABLED, 333 + k, prefs.recentFiles[k].c_str()); + } + CMenu* file = GetMenu()->GetSubMenu(0); + file->InsertMenu(12, MF_BYPOSITION | MF_ENABLED | MF_POPUP, (UINT)menu.m_hMenu, "&Recent Files"); + menu.Detach(); + + helpHome(); + + trackmem(true); + + if (blitzIDE.m_lpCmdLine[0]) { + string t = string(blitzIDE.m_lpCmdLine); + if (t[0] == '\"') + t = t.substr(1, t.size() - 2); + open(t); + } else { + SetCurrentDirectory((prefs.homeDir + "/samples").c_str()); + } + + return 0; +} + +void MainFrame::OnDestroy() +{ + trackmem(false); + WINDOWPLACEMENT wp = {sizeof(wp)}; + if (GetWindowPlacement(&wp)) { + prefs.win_rect = wp.rcNormalPosition; + if (wp.showCmd == SW_SHOWMAXIMIZED) { + prefs.win_maximized = true; + } else { + prefs.win_maximized = false; + } + } +} + +void MainFrame::setTitle(const string& s) +{ + SetWindowText(("Blitz3D - " + s).c_str()); + return; +} + +void MainFrame::OnClose() +{ + bool exit_flag = true; + for (int k = tabber.size() - 1; k >= 0; --k) { + exit_flag = close(k); + if (!exit_flag) + break; + } + if (exit_flag) + DestroyWindow(); +} + +BOOL MainFrame::OnEraseBkgnd(CDC* dc) +{ + return true; +} + +void MainFrame::OnSize(UINT type, int sw, int sh) +{ + CFrameWnd::OnSize(type, sw, sh); + + CRect r, t; + GetClientRect(&r); + int x = r.left, y = r.top, w = r.Width(), h = r.Height(); + + if (!prefs.win_notoolbar) { + statusBar.GetWindowRect(&t); + h -= t.Height(); + toolBar.GetWindowRect(&t); + y += t.Height(); + h -= t.Height(); + } + + tabber.MoveWindow(x, y, w, h); +} + +static char* bbFilter = + + "Blitz Basic files (.bb)|*.bb|" + + "Image files (.bmp,.jpg,.png,.tga,.iff,.pcx)|*.bmp;*.jpg;*.png;*.tga;*.iff;*.pcx|" + "Audio files (.wav,.mid,.mod,.mp3,.s3m,.xm,.it,.rmi,.sgt)|*.wav;*.mid;*.mod;*.mp3;*.s3m;*.xm;*.it;*.rmi;*.sgt|" + "3D Mesh files (.x,.3ds,.md2)|*.x;*.3ds;*.md2|" + + "All files|*.*||"; + +Editor* MainFrame::getEditor() +{ + return getEditor(tabber.getCurrent()); +} + +Editor* MainFrame::getEditor(int n) +{ + map::iterator it = editors.find(tabber.getTabWnd(n)); + return it == editors.end() ? 0 : it->second; +} + +HtmlHelp* MainFrame::getHelp(int n) +{ + map::iterator it = helps.find(tabber.getTabWnd(n)); + return it == helps.end() ? 0 : it->second; +} + +HtmlHelp* MainFrame::getHelp() +{ + return getHelp(tabber.getCurrent()); +} + +HtmlHelp* MainFrame::findHelp() +{ + int n; + HtmlHelp* h; + for (n = 0; n < tabber.size(); ++n) { + if (h = getHelp(n)) + break; + } + if (n == tabber.size()) { + h = new HtmlHelp(this); + h->Create(0, "Help", WS_CHILD | WS_BORDER, CRect(0, 0, 0, 0), &tabber, 1); + helps[h] = h; + tabber.insert(n, h, "Help"); + } + tabber.setCurrent(n); + return h; +} + +void MainFrame::cursorMoved(Editor* editor) +{ + if (editor != getEditor()) + return; + int row, col; + editor->getCursor(&row, &col); + char mod = editor->getModified() ? '*' : ' '; + char str[64]; + sprintf(str, "Row:%i Col:%i %c", row, col, mod); + statusBar.SetPaneText(1, str); +} + +void MainFrame::currentSet(Tabber* tabber, int index) +{ + if (Editor* e = getEditor()) { + string t = e->getName(); + if (!t.size()) + t = ""; + setTitle(t); + cursorMoved(e); + } else if (HtmlHelp* h = getHelp()) { + setTitle(h->getTitle()); + statusBar.SetPaneText(1, ""); + } else { + setTitle("no file"); + statusBar.SetPaneText(1, ""); + } +} + +void MainFrame::helpOpen(HtmlHelp* help, const string& file) +{ + open(file); +} + +void MainFrame::helpTitleChange(HtmlHelp* help, const string& title) +{ + if (HtmlHelp* h = getHelp()) + setTitle(h->getTitle()); +} + +void MainFrame::insertRecent(const string& file) +{ + //check recent files + if (CMenu* list = GetMenu()->GetSubMenu(0)->GetSubMenu(12)) { + vector::iterator it; + vector& f = prefs.recentFiles; + for (it = f.begin(); it != f.end(); ++it) { + if (tolower(*it) == tolower(file)) + break; + } + if (it != f.end()) { + //move to top + string t = *it; + f.erase(it); + f.insert(f.begin(), t); + } else { + //insert + if (f.size() == 10) { + f.pop_back(); + list->RemoveMenu(9, MF_BYPOSITION); + } + f.insert(f.begin(), file); + list->InsertMenu(0, MF_BYPOSITION | MF_ENABLED, 333, file.c_str()); + } + //renumber menu items + for (int k = 0; k < f.size(); ++k) { + list->ModifyMenu(k, MF_BYPOSITION | MF_ENABLED, 333 + k, f[k].c_str()); + } + } +} + +void MainFrame::newed(const string& t) +{ + CRect r(0, 0, 0, 0); + + Editor* e = new Editor(this); + e->Create(0, "Editor", WS_CHILD, r, &tabber, 1); + e->setName(t); + editors[e] = e; + int n = tabber.size(); + string s = t.size() ? getFile(t) : ""; + tabber.insert(n, e, s.c_str()); + tabber.setCurrent(n); +} + +bool MainFrame::open(const string& f) +{ + string file = f, filter = "*.bb"; + + int n = f.find("*."); + if (n != string::npos) { + file = f.substr(0, n); + filter = f.substr(n); + } + + int attr = GetFileAttributes(file.c_str()); + if (attr == -1) + attr = 0; + if (!file.size() || (attr & FILE_ATTRIBUTE_DIRECTORY)) { + int n = OFN_NOCHANGEDIR | OFN_FILEMUSTEXIST; + CFileDialog fd(true, "bb", filter.c_str(), n, bbFilter); + char* i_dir = strdup(file.c_str()); + fd.m_ofn.lpstrInitialDir = i_dir; + fd.m_ofn.lpstrTitle = "Open Blitz Basic File..."; + int nn = fd.DoModal(); + free(i_dir); + if (nn == IDCANCEL) + return false; + + file = fd.GetPathName(); + + } else { + char buff[MAX_PATH], *p; + if (GetFullPathName(file.c_str(), MAX_PATH, buff, &p)) + file = buff; + else + file = f; + } + + if (isMediaFile(tolower(file))) { + string t = prefs.homeDir + "/bin/mediaview.exe"; + if ((int)ShellExecute(::GetDesktopWindow(), 0, t.c_str(), file.c_str(), 0, SW_SHOW) > 32) { + } + return false; + } + + //is file already open? + int k; + for (k = 0; k < tabber.size(); ++k) { + if (Editor* e = getEditor(k)) { + if (tolower(e->getName()) == tolower(file)) { + tabber.setCurrent(k); + return true; + } + } + } + //open new file + ifstream in(file.c_str()); + if (!in.good()) { + string e = "Error reading file \"" + f + "\""; + AfxMessageBox(e.c_str(), MB_ICONWARNING); + return false; + } + newed(file); + tabber.UpdateWindow(); + Editor* e = getEditor(); + e->setText(in); + e->setName(file); + e->setModified(false); + insertRecent(file); + cursorMoved(e); + return true; +} + +bool MainFrame::close(int n) +{ + if (Editor* e = getEditor(n)) { + if (e->getModified()) { + tabber.setCurrent(n); + string t = "File " + e->getName() + " has been modified!\nSave changes before closing?"; + int rt = AfxMessageBox(t.c_str(), MB_YESNOCANCEL | MB_ICONWARNING); + if (rt == IDYES) + return save(n); + if (rt == IDCANCEL) + return false; + } + tabber.remove(n); + e->DestroyWindow(); + editors.erase(e); + delete e; + } else if (HtmlHelp* h = getHelp(n)) { + } + return true; +} + +bool MainFrame::save(int n) +{ + Editor* e = getEditor(n); + if (!e) + return true; + string t = e->getName(); + if (!t.size()) { + tabber.setCurrent(n); + int df = OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_OVERWRITEPROMPT; + CFileDialog fd(false, "bb", "*.bb", df, bbFilter); + fd.m_ofn.lpstrTitle = "Save Blitz Basic program as..."; + if (fd.DoModal() == IDCANCEL) + return false; + t = fd.GetPathName(); + tabber.setTabText(n, getFile(t)); + e->setName(t); + insertRecent(t); + } + //Do backups! + if (prefs.edit_backup) { + for (int k = prefs.edit_backup; k > 1; --k) { + CopyFile((t + "_bak" + itoa(k - 1)).c_str(), (t + "_bak" + itoa(k)).c_str(), false); + } + CopyFile(t.c_str(), (t + "_bak1").c_str(), false); + } + int om = ios_base::binary | ios_base::out | ios_base::trunc; + ofstream out(t.c_str(), om); + if (!out.good()) { + string e = "Error writing file \"" + t + "\""; + AfxMessageBox(e.c_str(), MB_ICONWARNING); + return false; + } + e->getText(out); + out.close(); + e->setModified(false); + cursorMoved(e); + return true; +} + +void MainFrame::fileNew() +{ + newed(""); +} + +void MainFrame::fileOpen() +{ + open(""); +} + +void MainFrame::fileSave() +{ + save(tabber.getCurrent()); +} + +void MainFrame::fileSaveAs() +{ + if (Editor* e = getEditor()) { + string t = e->getName(); + e->setName(""); + if (!save(tabber.getCurrent())) + e->setName(t); + currentSet(&tabber, tabber.getCurrent()); + } +} + +void MainFrame::fileSaveAll() +{ + for (int k = tabber.size() - 1; k >= 0; --k) { + if (!save(k)) + return; + } +} + +void MainFrame::filePrint() +{ + if (Editor* e = getEditor()) + e->print(); +} + +void MainFrame::fileClose() +{ + close(tabber.getCurrent()); +} + +void MainFrame::fileCloseAll() +{ + for (int k = tabber.size() - 1; k >= 0; --k) { + if (!close(k)) + return; + } +} + +void MainFrame::fileExit() +{ + PostMessage(WM_CLOSE); +} + +void MainFrame::fileRecent(UINT id) +{ + id -= 333; + if (id < 0 || id >= prefs.recentFiles.size()) + return; + open(prefs.recentFiles[id]); +} + +void MainFrame::editCut() +{ + if (Editor* e = getEditor()) + e->cut(); +} + +void MainFrame::editCopy() +{ + if (Editor* e = getEditor()) + e->copy(); +} + +void MainFrame::editPaste() +{ + if (Editor* e = getEditor()) + e->paste(); +} + +void MainFrame::editSelectAll() +{ + if (Editor* e = getEditor()) + e->selectAll(); +} + +void MainFrame::editFind() +{ + if (Editor* e = getEditor()) + e->find(); +} + +void MainFrame::editFindNext() +{ + if (Editor* e = getEditor()) + e->findNext(true); +} + +void MainFrame::editReplace() +{ + if (Editor* e = getEditor()) + e->replace(); +} + +static HANDLE startProc(const string& proc) +{ + HANDLE rd, wr; + + SECURITY_ATTRIBUTES sa = {sizeof(sa), 0, true}; + + if (CreatePipe(&rd, &wr, &sa, 0)) { + STARTUPINFO si = {sizeof(si)}; + si.dwFlags = STARTF_USESTDHANDLES; + si.hStdOutput = si.hStdError = wr; + PROCESS_INFORMATION pi = {0}; + if (CreateProcess(0, (char*)proc.c_str(), 0, 0, true, DETACHED_PROCESS, 0, 0, &si, &pi)) { + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + CloseHandle(wr); + return rd; + } + CloseHandle(rd); + CloseHandle(wr); + } + return 0; +} + +class PDialog : public CDialog { + public: + void OnOk() {} + void OnCancel() {} +}; + +void MainFrame::compile(const string& cmd) +{ + CDialog compiling; + compiling.Create(IDD_COMPILING); + + CProgressCtrl* cp = (CProgressCtrl*)compiling.GetDlgItem(IDC_COMPILEPROGRESS); + cp->SetStep(20); + + putenv("blitzide=1"); + + HANDLE rd = startProc(cmd); + + if (!rd) { + putenv("blitzide"); + compiling.DestroyWindow(); + AfxMessageBox("Error launching compiler", MB_ICONWARNING | MB_OK); + return; + } + + string line, err; + + //OK....here we go! + for (;;) { + char buff; + unsigned long sz; + int n = ReadFile(rd, &buff, 1, &sz, 0); + + if (n && !sz) + break; //EOF! + if (!n && GetLastError() == ERROR_BROKEN_PIPE) + break; //PROC END! + if (!n) { + err = "Internal Error"; + break; + } + + if (buff == '\r') + continue; + if (buff != '\n') { + line += buff; + continue; + } + if (!line.size()) + continue; + + if (line[0] == '\"') { + err = line; + int n = line.find("\"", 1); + if (n == string::npos) + break; + if (++n == line.size() || line[n] != ':') + break; + string file = line.substr(1, n - 2); + line = line.substr(n + 1); + n = line.find(':'); + if (!n || n == string::npos) + break; + int row1 = atoi(line.substr(0, n)); + line = line.substr(n + 1); + n = line.find(':'); + if (!n || n == string::npos) + break; + int col1 = atoi(line.substr(0, n)); + line = line.substr(n + 1); + n = line.find(':'); + if (!n || n == string::npos) + break; + int row2 = atoi(line.substr(0, n)); + line = line.substr(n + 1); + n = line.find(':'); + if (!n || n == string::npos) + break; + int col2 = atoi(line.substr(0, n)); + line = line.substr(n + 1); + + int pos = ((row1 - 1) << 16) | (col1 - 1); + + if (!open(file)) + return; + if (Editor* e = getEditor()) + e->setCursor(pos); + + err = line; + break; + } else if (line.find("...") != line.size() - 3) { + err = line; + break; + } + + if (line.find("Executing") == 0) { + //OK, we're running! + break; + } + + cp->StepIt(); + line = ""; + } + + compiling.DestroyWindow(); + + CloseHandle(rd); + putenv("blitzide"); + + if (!err.size()) + return; + + AfxMessageBox(err.c_str(), MB_ICONWARNING | MB_OK); +} + +void MainFrame::build(bool exec, bool publish) +{ + Editor* e = getEditor(); + if (!e) + return; + + string src_file = e->getName(); + + for (int k = tabber.size() - 1; k >= 0; --k) { + if (Editor* e = getEditor(k)) { + if (e->getModified() && e->getName().size()) { + if (!save(k)) + return; + } + } + } + + string opts = " "; + + if (prefs.prg_debug) + opts += "-d "; + + if (publish) { + string exe = src_file; + if (exe.size()) { + int n = exe.find('.'); + if (n != string::npos) + exe = exe.substr(0, n); + } else { + exe = "untitled"; + } + + static char* exeFilter = "Executable files (*.exe)|*.exe||"; + int t = OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; + CFileDialog fd(false, "exe", exe.c_str(), t, exeFilter); + fd.m_ofn.lpstrTitle = "Select executable filename"; + fd.m_ofn.lpstrInitialDir = "./"; + if (fd.DoModal() == IDCANCEL) + return; + + opts += "-o \"" + string(fd.GetPathName()) + "\" "; + } else if (!exec) { + opts += "-c "; + } + + string src = src_file; + + if (!src.size()) { + src = prefs.homeDir + "\\tmp\\tmp.bb"; + int om = ios_base::binary | ios_base::out | ios_base::trunc; + ofstream out(src.c_str(), om); + if (!out.good()) { + string e = "Error writing file \"" + src + "\""; + AfxMessageBox(e.c_str(), MB_ICONWARNING); + return; + } + e->getText(out); + out.close(); + e->setName(src); + } else { + prefs.prg_lastbuild = e->getName(); + } + + compile(prefs.homeDir + "/bin/blitzcc -q " + opts + " \"" + src + "\" " + prefs.cmd_line); + + if (!src_file.size()) + e->setName(""); +} + +void MainFrame::programExecute() +{ + build(true, false); +} + +void MainFrame::programReExecute() +{ + if (prefs.prg_lastbuild.size() && open(prefs.prg_lastbuild)) { + build(true, false); + } +} + +void MainFrame::programCompile() +{ + build(false, false); +} + +void MainFrame::programPublish() +{ +#ifdef DEMO + MessageBox("Create Executable unavailable in demo version", "Sorry!", + MB_TOPMOST | MB_SETFOREGROUND | MB_ICONINFORMATION); + return; +#endif + Editor* e = getEditor(); + if (!e) + return; + if (prefs.prg_debug) { + string t = + "You currently have the debugging feature enabled!\n\n" + "This will result in slower executables - continue anyway?"; + if (MessageBox(t.c_str(), 0, MB_OKCANCEL) == IDCANCEL) + return; + } + build(false, true); +} + +struct CmdLineDialog : public CDialog { + CmdLineDialog() : CDialog(IDD_COMMANDLINE) {} + + BOOL OnInitDialog() + { + CDialog::OnInitDialog(); + SetDlgItemText(IDC_CMDLINE, prefs.cmd_line.c_str()); + return TRUE; + } + + void OnOK() + { + CString c_str; + GetDlgItemText(IDC_CMDLINE, c_str); + prefs.cmd_line = c_str; + CDialog::OnOK(); + } +}; + +void MainFrame::programCommandLine() +{ + CmdLineDialog d; + d.DoModal(); +} + +void MainFrame::programDebug() +{ + prefs.prg_debug = !prefs.prg_debug; +} + +void MainFrame::helpHome() +{ + HtmlHelp* h = findHelp(); + string t; + t = "index.html"; + h->Navigate((prefs.homeDir + "/help/" + t).c_str()); +} + +void MainFrame::helpAutodoc() +{ + HtmlHelp* h = findHelp(); + h->Navigate((prefs.homeDir + "/help/autodoc.html").c_str()); +} + +void MainFrame::helpBack() +{ + if (HtmlHelp* h = findHelp()) + h->GoBack(); +} + +void MainFrame::helpForward() +{ + if (HtmlHelp* h = findHelp()) + h->GoForward(); +} + +void MainFrame::helpAbout() +{ + aboutBlitz(false); +} + +void MainFrame::ctrlTab() +{ + int n = tabber.getCurrent() + 1; + if (n >= tabber.size()) + n -= tabber.size(); + tabber.setCurrent(n); +} + +void MainFrame::ctrlShiftTab() +{ + int n = tabber.getCurrent() - 1; + if (n < 0) + n += tabber.size(); + tabber.setCurrent(n); +} + +void MainFrame::escape() +{ + if (!prefs.win_notoolbar) { + toolBar.ShowWindow(SW_HIDE); + statusBar.ShowWindow(SW_HIDE); + prefs.win_notoolbar = true; + } else { + toolBar.ShowWindow(SW_SHOW); + statusBar.ShowWindow(SW_SHOW); + prefs.win_notoolbar = false; + } + RECT r; + GetClientRect(&r); + int w = r.right - r.left, h = r.bottom - r.top; + int n = prefs.win_maximized ? SIZE_MAXIMIZED : SIZE_RESTORED; + PostMessage(WM_SIZE, n, (h << 16) | w); +} + +void MainFrame::updateCmdUIRange(CCmdUI* ui) +{ + int n = ui->m_nID - 333; + if (n >= 0 && n < prefs.recentFiles.size()) { + ui->Enable(true); + } else { + ui->Enable(false); + } +} + +void MainFrame::updateCmdUI(CCmdUI* ui) +{ + int k; + + Editor* e = getEditor(); + + switch (ui->m_nID) { + case Inew: + case ID_OPEN: + case ID_HOME: + ui->Enable(true); + break; + case ID_DEBUG: + ui->SetCheck(prefs.prg_debug); + ui->Enable(true); + break; + case ID_CLOSE: + case ID_PRINT: + ui->Enable(!!e); + break; + case ID_CLOSEALL: + for (k = 0; k < tabber.size() && !getEditor(k); ++k) { + } + ui->Enable(k < tabber.size()); + break; + case ID_CUT: + case ID_COPY: + if (!!e) { + ui->Enable(e->canCutCopy()); + } else + ui->Enable(false); + break; + case ID_PASTE: + if (!!e) { + ui->Enable(e->canPaste()); + } else + ui->Enable(false); + break; + case ID_SELECTALL: + case ID_QUICKHELP: + case ID_FIND: + case ID_FINDNEXT: + case ID_REPLACE: + case ID_EXECUTE: + case ID_COMPILE: + case ID_PUBLISH: + ui->Enable(!!e); + break; + case ID_REEXECUTE: + ui->Enable(prefs.prg_lastbuild.size()); + break; + case ID_COMMANDLINE: + ui->Enable(true); + break; + case ID_SAVE: + case ID_SAVEAS: + ui->Enable(!!e); + break; + case ID_SAVEALL: + for (k = 0; k < tabber.size() && !getEditor(k); ++k) { + } + ui->Enable(k < tabber.size()); + break; + case ID_BACK: + case ID_FORWARD: + ui->Enable(getHelp() != 0); + break; + case ID_ESCAPE: + ui->SetCheck(!prefs.win_notoolbar); + break; + default: + ui->Enable(false); + } +} + +static string commandURL(const string& t) +{ + static char* dirs[] = {"help\\commands\\2d_commands\\", "help\\commands\\3d_commands\\", 0}; + + char** dir_p = dirs; + + while (char* dir = *dir_p++) { + WIN32_FIND_DATA fd; + string path = prefs.homeDir + "/" + dir + t + ".htm"; + HANDLE h = FindFirstFile(path.c_str(), &fd); + if (h == INVALID_HANDLE_VALUE) + continue; + FindClose(h); + return path; + } + return ""; +} + +void MainFrame::quick_Help() +{ + if (Editor* e = getEditor()) { + //look for keyword at cursor... + string t = e->getKeyword(); + if (!t.size()) + return; + statusBar.SetPaneText(0, quickHelp(t).c_str()); + if (t != last_quick_help) { + last_quick_help = t; + return; + } + string url = commandURL(t); + if (!url.size()) { + string ex = "Unable to open help file for \"" + t + "\""; + AfxMessageBox(ex.c_str(), MB_ICONWARNING); + return; + } + if (HtmlHelp* h = findHelp()) { + h->Navigate(url.c_str(), 0, 0); + } + } +} + +void MainFrame::OnActivate(UINT state, CWnd* other, BOOL min) +{ + CFrameWnd::OnActivate(state, other, min); + + if (Editor* e = getEditor()) { + if (state != WA_ACTIVE && state != WA_CLICKACTIVE) + return; + e->SetFocus(); + } +} diff --git a/BlitzBasicIDE/mainframe.h b/ide/mainframe.h similarity index 100% rename from BlitzBasicIDE/mainframe.h rename to ide/mainframe.h diff --git a/ide/prefs.cpp b/ide/prefs.cpp new file mode 100644 index 0000000..74c829a --- /dev/null +++ b/ide/prefs.cpp @@ -0,0 +1,227 @@ + +#include "prefs.h" +#include +#include +#include "resource.h" +#include "stdafx.h" + +#define SWAPRB(x) ((((x) >> 16) & 0xff) | ((x)&0xff00) | (((x)&0xff) << 16)) + +Prefs prefs; + +void Prefs::open() +{ + char* p = getenv("blitzpath"); + if (!p) { + AfxMessageBox("blitzpath environment variable not found!", MB_TOPMOST | MB_SETFOREGROUND | MB_ICONINFORMATION); + ExitProcess(0); + } + + homeDir = p; + + AddFontResource((homeDir + "/cfg/blitz.fon").c_str()); + + setDefault(); + + bool prg_windowed; + + ifstream in((homeDir + "/cfg/blitzide.prefs").c_str()); + if (!in.good()) + return; + + while (!in.eof()) { + string t; + in >> t; + if (!t.size()) + continue; + while (in.peek() == '\t') + in.ignore(); + if (t == "prg_debug") + in >> prg_debug; + else if (t == "prg_lastbuild") + getline(in, prg_lastbuild); + else if (t == "prg_windowed") + in >> prg_windowed; + else if (t == "win_maximized") + in >> win_maximized; + else if (t == "win_notoolbar") + in >> win_notoolbar; + else if (t == "win_rect") { + in >> win_rect.left; + in >> win_rect.top; + in >> win_rect.right; + in >> win_rect.bottom; + } else if (t.substr(0, 5) == "font_") { + string s; + int h; + in >> s; + in >> h; + t = t.substr(5); + if (t == "editor") { + font_editor = s; + font_editor_height = h; + } else if (t == "tabs") { + font_tabs = s; + font_tabs_height = h; + } else if (t == "debug") { + font_debug = s; + font_debug_height = h; + } + } else if (t.substr(0, 4) == "rgb_") { + t = t.substr(4); + string s; + in >> s; + int rgb = 0; + for (int k = 0; k < s.size(); ++k) { + int n = s[k]; + rgb = (rgb << 4) | (n <= '9' ? n - '0' : (n & 31) + 9); + } + rgb = SWAPRB(rgb); + + if (t == "bkgrnd") + rgb_bkgrnd = rgb; + else if (t == "string") + rgb_string = rgb; + else if (t == "ident") + rgb_ident = rgb; + else if (t == "keyword") + rgb_keyword = rgb; + else if (t == "comment") + rgb_comment = rgb; + else if (t == "digit") + rgb_digit = rgb; + else if (t == "default") + rgb_default = rgb; + } else if (t == "edit_tabs") { + in >> edit_tabs; + } else if (t == "edit_blkcursor") { + in >> edit_blkcursor; + } else if (t == "edit_backup") { + in >> edit_backup; + } else if (t == "img_toolbar") { + getline(in, img_toolbar); + } else if (t == "cmd_line") { + getline(in, cmd_line); + } else if (t == "file_recent") { + string l; + getline(in, l); + if (recentFiles.size() < 10) + recentFiles.push_back(l); + } else { + string s = "Unrecognized option '" + t + "' in blitzide.prefs"; + AfxMessageBox("Error in preferences file"); + setDefault(); + return; + } + } + createFonts(); +} + +void Prefs::close() +{ + ofstream out((homeDir + "/cfg/blitzide.prefs").c_str()); + if (!out.good()) + return; + + out << "prg_debug\t" << prg_debug << endl; + out << "prg_lastbuild\t" << prg_lastbuild << endl; + out << "win_maximized\t" << win_maximized << endl; + out << "win_notoolbar\t" << win_notoolbar << endl; + out << "win_rect\t" << win_rect.left << ' ' << win_rect.top << ' ' << win_rect.right << ' ' << win_rect.bottom + << endl; + out << "font_editor\t" << font_editor << ' ' << font_editor_height << endl; + out << "font_tabs\t" << font_tabs << ' ' << font_tabs_height << endl; + out << "font_debug\t" << font_debug << ' ' << font_debug_height << endl; + out << hex; + out << "rgb_bkgrnd\t" << SWAPRB(rgb_bkgrnd) << endl; + out << "rgb_string\t" << SWAPRB(rgb_string) << endl; + out << "rgb_ident\t" << SWAPRB(rgb_ident) << endl; + out << "rgb_keyword\t" << SWAPRB(rgb_keyword) << endl; + out << "rgb_comment\t" << SWAPRB(rgb_comment) << endl; + out << "rgb_digit\t" << SWAPRB(rgb_digit) << endl; + out << "rgb_default\t" << SWAPRB(rgb_default) << endl; + out << "edit_tabs\t" << edit_tabs << endl; + out << "edit_blkcursor\t" << edit_blkcursor << endl; + out << "edit_backup\t" << edit_backup << endl; + out << "img_toolbar\t" << img_toolbar << endl; + out << "cmd_line\t" << cmd_line << endl; + for (int k = 0; k < recentFiles.size(); ++k) { + out << "file_recent\t" << recentFiles[k] << endl; + } + out << dec; + + RemoveFontResource((homeDir + "/cfg/blitz.fon").c_str()); +} + +void Prefs::setDefault() +{ + prg_debug = true; + + win_rect.left = win_rect.top = 0; + win_rect.right = 640; + win_rect.bottom = 480; + win_maximized = false; + win_notoolbar = false; +#ifdef PLUS + font_editor = "courier"; + font_editor_height = 10; +#else + font_editor = "Consolas"; + font_editor_height = 10; +#endif + font_tabs = "verdana"; + font_tabs_height = 8; + font_debug = "verdana"; + font_debug_height = 8; + +#ifdef PRO + rgb_bkgrnd = RGB(0x22, 0x55, 0x88); + rgb_string = RGB(0x00, 0xff, 0x66); + rgb_ident = RGB(0xff, 0xff, 0xff); + rgb_keyword = RGB(0xaa, 0xff, 0xff); + rgb_comment = RGB(0xff, 0xee, 0x00); + rgb_digit = RGB(0x33, 0xff, 0xdd); + rgb_default = RGB(0xee, 0xee, 0xee); +#else +#ifdef PLUS + rgb_bkgrnd = SWAPRB(0x225577); + rgb_string = SWAPRB(0x00ffff); + rgb_ident = SWAPRB(0xffffff); + rgb_keyword = SWAPRB(0xffff00); + rgb_comment = SWAPRB(0x00ff00); + rgb_digit = SWAPRB(0x00ffff); + rgb_default = SWAPRB(0xffffff); +#else + rgb_bkgrnd = RGB(32, 96, 96); + rgb_string = RGB(0, 255, 0); + rgb_ident = RGB(255, 255, 255); + rgb_keyword = RGB(255, 231, 95); + rgb_comment = RGB(0, 255, 255); + rgb_digit = RGB(200, 240, 255); + rgb_default = RGB(255, 240, 200); +#endif +#endif + + edit_tabs = 4; + edit_blkcursor = false; + edit_backup = 2; + + img_toolbar = "toolbar.bmp"; + + recentFiles.clear(); + + createFonts(); +} + +void Prefs::createFonts() +{ + editFont.Detach(); + tabsFont.Detach(); + debugFont.Detach(); + conFont.Detach(); + + editFont.CreatePointFont(font_editor_height * 10, font_editor.c_str()); + tabsFont.CreatePointFont(font_tabs_height * 10, font_tabs.c_str()); + debugFont.CreatePointFont(font_debug_height * 10, font_debug.c_str()); + conFont.CreatePointFont(80, "courier"); +} diff --git a/BlitzBasicIDE/prefs.h b/ide/prefs.h similarity index 100% rename from BlitzBasicIDE/prefs.h rename to ide/prefs.h diff --git a/BlitzBasicIDE/resource.h b/ide/resource.h similarity index 100% rename from BlitzBasicIDE/resource.h rename to ide/resource.h diff --git a/BlitzBasicIDE/stdafx.cpp b/ide/stdafx.cpp similarity index 98% rename from BlitzBasicIDE/stdafx.cpp rename to ide/stdafx.cpp index b0e06dd..1809cb4 100644 --- a/BlitzBasicIDE/stdafx.cpp +++ b/ide/stdafx.cpp @@ -2,4 +2,3 @@ #include "stdafx.h" #include "../stdutil/stdutil.cpp" - diff --git a/BlitzBasicIDE/stdafx.h b/ide/stdafx.h similarity index 100% rename from BlitzBasicIDE/stdafx.h rename to ide/stdafx.h diff --git a/ide/tabber.cpp b/ide/tabber.cpp new file mode 100644 index 0000000..29f87ad --- /dev/null +++ b/ide/tabber.cpp @@ -0,0 +1,211 @@ + +#include "tabber.h" +#include "stdafx.h" + +IMPLEMENT_DYNAMIC(Tabber, CTabCtrl) +BEGIN_MESSAGE_MAP(Tabber, CTabCtrl) +ON_WM_SIZE() +ON_WM_ERASEBKGND() +ON_NOTIFY_REFLECT(TCN_SELCHANGE, tcn_selChange) +END_MESSAGE_MAP() + +static CRect tabsRect(CTabCtrl& t) +{ + CRect r(0, 0, 0, 0); + int n = t.GetItemCount(); + for (int k = 0; k < n; ++k) { + CRect c; + t.GetItemRect(k, &c); + if (c.left < r.left) + r.left = c.left; + if (c.right > r.right) + r.right = c.right; + if (c.top < r.top) + r.top = c.top; + if (c.bottom > r.bottom) + r.bottom = c.bottom; + } + return r; +} + +CRect Tabber::getInnerRect() +{ + CRect r; + GetClientRect(&r); + int x = 2, y = 2, w = r.Width() - 4, h = r.Height() - 4; + + r = tabsRect(*this); + h -= r.Height(); + y += r.Height(); + + r.left = x; + r.top = y; + r.right = x + w; + r.bottom = y + h; + return r; +} + +Tabber::Tabber() : listener(0), curr(-1) {} + +Tabber::~Tabber() +{ + for (; tabs.size(); tabs.pop_back()) + delete tabs.back(); +} + +void Tabber::OnSize(UINT type, int w, int h) +{ + CTabCtrl::OnSize(type, w, h); + refresh(); +} + +BOOL Tabber::OnEraseBkgnd(CDC* dc) +{ + CRect c; + GetClientRect(&c); + + HBRUSH hb = (HBRUSH)GetClassLong(m_hWnd, GCL_HBRBACKGROUND); + CBrush br; + br.Attach(hb); + + if (curr < 0) + dc->FillRect(&c, &br); + else { + CRect i = getInnerRect(); + CRect t(c.left, c.top, i.right, i.top); + dc->FillRect(&t, &br); + CRect r(i.right, c.top, c.right, i.bottom); + dc->FillRect(&r, &br); + CRect b(i.left, i.bottom, c.right, c.bottom); + dc->FillRect(&b, &br); + CRect l(c.left, i.top, i.left, c.bottom); + dc->FillRect(&l, &br); + } + return true; +} + +void Tabber::setListener(TabberListener* l) +{ + listener = l; +} + +void Tabber::refresh() +{ + if (curr < 0) + return; + + CRect r = getInnerRect(); + CWnd* wnd = getTabWnd(curr); + wnd->MoveWindow(r.left, r.top, r.Width(), r.Height()); + wnd->ShowWindow(SW_SHOW); + wnd->SetFocus(); +} + +Tabber::Tab* Tabber::getTab(int index) const +{ + if (index < 0 || index >= tabs.size()) + return 0; + Tabs::const_iterator it = tabs.begin(); + while (index--) + ++it; + return *it; +} + +void Tabber::tcn_selChange(NMHDR* p, LRESULT* result) +{ + setCurrent(GetCurSel()); +} + +void Tabber::insert(int index, CWnd* w, const string& t) +{ + if (index < 0 || index > tabs.size()) + return; + + Tabs::iterator it = tabs.begin(); + for (int k = 0; k < index; ++k) + ++it; + Tab* tab = new Tab(w, t); + tabs.insert(it, tab); + + InsertItem(index, t.c_str()); + if (curr < 0) + setCurrent(index); +} + +void Tabber::remove(int index) +{ + if (index < 0 || index >= tabs.size()) + return; + + CWnd* w = getTabWnd(index); + + Tabs::iterator it = tabs.begin(); + for (int k = 0; k < index; ++k) + ++it; + delete *it; + tabs.erase(it); + DeleteItem(index); + + if (curr >= tabs.size()) + curr = tabs.size() - 1; + + refresh(); + if (curr >= 0) + SetCurSel(curr); + if (w) + w->ShowWindow(SW_HIDE); + if (listener) + listener->currentSet(this, curr); +} + +void Tabber::setCurrent(int index) +{ + if (index < 0 || index >= tabs.size()) + return; + + if (index != curr) { + CWnd* w = getTabWnd(curr); + curr = index; + + refresh(); + SetCurSel(curr); + if (w) + w->ShowWindow(SW_HIDE); + } + + if (listener) + listener->currentSet(this, curr); +} + +void Tabber::setTabText(int index, const string& t) +{ + if (index < 0 || index >= tabs.size()) + return; + + string s = t + '\0'; + TCITEM tc = {TCIF_TEXT}; + tc.pszText = (char*)s.data(); + SetItem(index, &tc); +} + +int Tabber::size() const +{ + return tabs.size(); +} + +int Tabber::getCurrent() const +{ + return curr; +} + +CWnd* Tabber::getTabWnd(int index) const +{ + Tab* t = getTab(index); + return t ? t->wnd : 0; +} + +string Tabber::getTabText(int index) const +{ + Tab* t = getTab(index); + return t ? t->text : ""; +} \ No newline at end of file diff --git a/BlitzBasicIDE/tabber.h b/ide/tabber.h similarity index 100% rename from BlitzBasicIDE/tabber.h rename to ide/tabber.h diff --git a/launcher/bblaunch.cpp b/launcher/bblaunch.cpp new file mode 100644 index 0000000..655c5fc --- /dev/null +++ b/launcher/bblaunch.cpp @@ -0,0 +1,87 @@ + +#include +#include + +#include "checkdx.h" +#include "checkie.h" + +using namespace std; + +static const char* dx_err = + "You must have DirectX version 7 installed to run Blitz Basic.\n\n" + "DirectX 7 is provided on the Blitz Basic CD in the DirectX7 folder.\n\n" + "The latest version of DirectX is available from www.microsoft.com"; + +static const char* ie_err = + "You must have Internet Explorer version 4 installed to run Blitz Basic.\n\n" + "Internet Explorer 5 is provided on the Blitz Basic CD in the IExplorer5 folder.\n\n" + "The latest version of Internet Explorer is available from www.microsoft.com"; + +static const char* bb_err = "Unable to run Blitz Basic"; + +static const char* md_err = + "Your desktop must be in high-colour mode to use Blitz Basic.\n\n" + "You can change your display settings from the control panel."; + +static string getAppDir() +{ + char buff[MAX_PATH]; + if (GetModuleFileName(0, buff, MAX_PATH)) { + string t = buff; + int n = t.find_last_of('\\'); + if (n != string::npos) + t = t.substr(0, n); + return t; + } + return ""; +} + +static void fail(const char* p) +{ + ::MessageBox(0, p, "Blitz Basic Error", MB_SETFOREGROUND | MB_TOPMOST | MB_ICONERROR); + ExitProcess(-1); +} + +static int desktopDepth() +{ + HDC hdc = GetDC(GetDesktopWindow()); + return GetDeviceCaps(hdc, BITSPIXEL); +} + +int _stdcall WinMain(HINSTANCE inst, HINSTANCE prev, char* cmd, int show) +{ + if (desktopDepth() < 16) + fail(md_err); + +#ifndef PLUS + if (getDXVersion() < 7) + fail(dx_err); +#endif + + if (getIEVersion() < 4) + fail(ie_err); + + //Ugly hack to get application dir... + string blitzIdePath = getAppDir(); + _putenv(("blitzpath=" + blitzIdePath).c_str()); + SetCurrentDirectory(blitzIdePath.c_str()); + blitzIdePath = blitzIdePath + "\\bin\\ide.exe " + cmd; + + STARTUPINFO si; + PROCESS_INFORMATION pi; + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + if (!CreateProcess(0, (char*)blitzIdePath.c_str(), 0, 0, 0, 0, 0, 0, &si, &pi)) { + ::MessageBox(0, bb_err, "Blitz Basic Error", MB_SETFOREGROUND | MB_TOPMOST | MB_ICONERROR); + ExitProcess(-1); + } + + //wait for BB to start + WaitForInputIdle(pi.hProcess, INFINITE); + + // Close process and thread handles. + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + + return 0; +} diff --git a/BlitzBasicLauncher/bblaunch.ico b/launcher/bblaunch.ico similarity index 100% rename from BlitzBasicLauncher/bblaunch.ico rename to launcher/bblaunch.ico diff --git a/BlitzBasicLauncher/bblaunch.rc b/launcher/bblaunch.rc similarity index 100% rename from BlitzBasicLauncher/bblaunch.rc rename to launcher/bblaunch.rc diff --git a/BlitzBasicLauncher/blitzide.prefs b/launcher/blitzide.prefs similarity index 100% rename from BlitzBasicLauncher/blitzide.prefs rename to launcher/blitzide.prefs diff --git a/launcher/checkdx.cpp b/launcher/checkdx.cpp new file mode 100644 index 0000000..4e2d535 --- /dev/null +++ b/launcher/checkdx.cpp @@ -0,0 +1,336 @@ + +//----------------------------------------------------------------------------- +// File: GetDXVer.cpp +// +// Desc: Demonstrates how applications can detect what version of DirectX +// is installed. +// +// (C) Copyright 1995-1997 Microsoft Corp. All rights reserved. +//----------------------------------------------------------------------------- +#include +#include +#include +#define DIRECTINPUT_VERSION 0x0700 +#include +//#include + +typedef HRESULT(WINAPI* DIRECTDRAWCREATE)(GUID*, LPDIRECTDRAW*, IUnknown*); +typedef HRESULT(WINAPI* DIRECTDRAWCREATEEX)(GUID*, VOID**, REFIID, IUnknown*); +typedef HRESULT(WINAPI* DIRECTINPUTCREATE)(HINSTANCE, DWORD, LPDIRECTINPUT*, IUnknown*); + +//----------------------------------------------------------------------------- +// Name: GetDXVersion() +// Desc: This function returns two arguments: +// dwDXVersion: +// 0x0000 = No DirectX installed +// 0x0100 = DirectX version 1 installed +// 0x0200 = DirectX 2 installed +// 0x0300 = DirectX 3 installed +// 0x0500 = At least DirectX 5 installed. +// 0x0600 = At least DirectX 6 installed. +// 0x0601 = At least DirectX 6.1 installed. +// 0x0700 = At least DirectX 7 installed. +// dwDXPlatform: +// 0 = Unknown (This is a failure case) +// VER_PLATFORM_WIN32_WINDOWS = Windows 9X platform +// VER_PLATFORM_WIN32_NT = Windows NT platform +// +// Please note that this code is intended as a general guideline. Your +// app will probably be able to simply query for functionality (via +// QueryInterface) for one or two components. +// +// Please also note: +// "if (dxVer != 0x500) return FALSE;" is BAD. +// "if (dxVer < 0x500) return FALSE;" is MUCH BETTER. +// to ensure your app will run on future releases of DirectX. +//----------------------------------------------------------------------------- +VOID GetDXVersion(DWORD* pdwDXVersion, DWORD* pdwDXPlatform) +{ + *pdwDXVersion = 0x0700; + *pdwDXPlatform = VER_PLATFORM_WIN32_NT; + // HRESULT hr; + // HINSTANCE DDHinst = 0; + // HINSTANCE DIHinst = 0; + // LPDIRECTDRAW pDDraw = 0; + // LPDIRECTDRAW2 pDDraw2 = 0; + // DIRECTDRAWCREATE DirectDrawCreate = 0; + // DIRECTDRAWCREATEEX DirectDrawCreateEx = 0; + // DIRECTINPUTCREATE DirectInputCreate = 0; + // OSVERSIONINFO osVer; + // LPDIRECTDRAWSURFACE pSurf = 0; + // LPDIRECTDRAWSURFACE3 pSurf3 = 0; + // LPDIRECTDRAWSURFACE4 pSurf4 = 0; + + // // First get the windows platform + // osVer.dwOSVersionInfoSize = sizeof(osVer); + // if( !GetVersionEx( &osVer ) ) + // { + // (*pdwDXPlatform) = 0; + // (*pdwDXVersion) = 0; + // return; + // } + + // if( osVer.dwPlatformId == VER_PLATFORM_WIN32_NT ) + // { + // (*pdwDXPlatform) = VER_PLATFORM_WIN32_NT; + + // // NT is easy... NT 4.0 is DX2, 4.0 SP3 is DX3, 5.0 is DX5 + // // and no DX on earlier versions. + // if( osVer.dwMajorVersion < 4 ) + // { + // (*pdwDXVersion) = 0; // No DX on NT3.51 or earlier + // return; + // } + + // if( osVer.dwMajorVersion == 4 ) + // { + // // NT4 up to SP2 is DX2, and SP3 onwards is DX3, so we are at least DX2 + // (*pdwDXVersion) = 0x200; + + // // We're not supposed to be able to tell which SP we're on, so check for dinput + // DIHinst = LoadLibrary( "DINPUT.DLL" ); + // if( DIHinst == 0 ) + // { + // // No DInput... must be DX2 on NT 4 pre-SP3 + // OutputDebugString( "Couldn't LoadLibrary DInput\r\n" ); + // return; + // } + + // DirectInputCreate = (DIRECTINPUTCREATE)GetProcAddress( DIHinst, + // "DirectInputCreateA" ); + // FreeLibrary( DIHinst ); + + // if( DirectInputCreate == 0 ) + // { + // // No DInput... must be pre-SP3 DX2 + // OutputDebugString( "Couldn't GetProcAddress DInputCreate\r\n" ); + // return; + // } + + // // It must be NT4, DX2 + // (*pdwDXVersion) = 0x300; // DX3 on NT4 SP3 or higher + // return; + // } + // // Else it's NT5 or higher, and it's DX5a or higher: Drop through to + // // Win9x tests for a test of DDraw (DX6 or higher) + // } + // else + // { + // // Not NT... must be Win9x + // (*pdwDXPlatform) = VER_PLATFORM_WIN32_WINDOWS; + // } + + // // Now we know we are in Windows 9x (or maybe 3.1), so anything's possible. + // // First see if DDRAW.DLL even exists. + // DDHinst = LoadLibrary( "DDRAW.DLL" ); + // if( DDHinst == 0 ) + // { + // (*pdwDXVersion) = 0; + // (*pdwDXPlatform) = 0; + // FreeLibrary( DDHinst ); + // return; + // } + + // // See if we can create the DirectDraw object. + // DirectDrawCreate = (DIRECTDRAWCREATE)GetProcAddress( DDHinst, "DirectDrawCreate" ); + // if( DirectDrawCreate == 0 ) + // { + // (*pdwDXVersion) = 0; + // (*pdwDXPlatform) = 0; + // FreeLibrary( DDHinst ); + // OutputDebugString( "Couldn't LoadLibrary DDraw\r\n" ); + // return; + // } + + // hr = DirectDrawCreate( NULL, &pDDraw, NULL ); + // if( FAILED(hr) ) + // { + // (*pdwDXVersion) = 0; + // (*pdwDXPlatform) = 0; + // FreeLibrary( DDHinst ); + // OutputDebugString( "Couldn't create DDraw\r\n" ); + // return; + // } + + // // So DirectDraw exists. We are at least DX1. + // (*pdwDXVersion) = 0x100; + + // // Let's see if IID_IDirectDraw2 exists. + // hr = pDDraw->QueryInterface( IID_IDirectDraw2, (VOID**)&pDDraw2 ); + // if( FAILED(hr) ) + // { + // // No IDirectDraw2 exists... must be DX1 + // pDDraw->Release(); + // FreeLibrary( DDHinst ); + // OutputDebugString( "Couldn't QI DDraw2\r\n" ); + // return; + // } + + // // IDirectDraw2 exists. We must be at least DX2 + // pDDraw2->Release(); + // (*pdwDXVersion) = 0x200; + + // /////////////////////////////////////////////////////////////////////////// + // // DirectX 3.0 Checks + // /////////////////////////////////////////////////////////////////////////// + + // // DirectInput was added for DX3 + // DIHinst = LoadLibrary( "DINPUT.DLL" ); + // if( DIHinst == 0 ) + // { + // // No DInput... must not be DX3 + // OutputDebugString( "Couldn't LoadLibrary DInput\r\n" ); + // pDDraw->Release(); + // FreeLibrary( DDHinst ); + // return; + // } + + // DirectInputCreate = (DIRECTINPUTCREATE)GetProcAddress( DIHinst, + // "DirectInputCreateA" ); + // if( DirectInputCreate == 0 ) + // { + // // No DInput... must be DX2 + // FreeLibrary( DIHinst ); + // FreeLibrary( DDHinst ); + // pDDraw->Release(); + // OutputDebugString( "Couldn't GetProcAddress DInputCreate\r\n" ); + // return; + // } + + // // DirectInputCreate exists. We are at least DX3 + // (*pdwDXVersion) = 0x300; + // FreeLibrary( DIHinst ); + + // // Can do checks for 3a vs 3b here + + // /////////////////////////////////////////////////////////////////////////// + // // DirectX 5.0 Checks + // /////////////////////////////////////////////////////////////////////////// + + // // We can tell if DX5 is present by checking for the existence of + // // IDirectDrawSurface3. First, we need a surface to QI off of. + // DDSURFACEDESC ddsd; + // ZeroMemory( &ddsd, sizeof(ddsd) ); + // ddsd.dwSize = sizeof(ddsd); + // ddsd.dwFlags = DDSD_CAPS; + // ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + // hr = pDDraw->SetCooperativeLevel( NULL, DDSCL_NORMAL ); + // if( FAILED(hr) ) + // { + // // Failure. This means DDraw isn't properly installed. + // pDDraw->Release(); + // FreeLibrary( DDHinst ); + // (*pdwDXVersion) = 0; + // OutputDebugString( "Couldn't Set coop level\r\n" ); + // return; + // } + + // hr = pDDraw->CreateSurface( &ddsd, &pSurf, NULL ); + // if( FAILED(hr) ) + // { + // // Failure. This means DDraw isn't properly installed. + // pDDraw->Release(); + // FreeLibrary( DDHinst ); + // *pdwDXVersion = 0; + // OutputDebugString( "Couldn't CreateSurface\r\n" ); + // return; + // } + + // // Query for the IDirectDrawSurface3 interface + // if( FAILED( pSurf->QueryInterface( IID_IDirectDrawSurface3, + // (VOID**)&pSurf3 ) ) ) + // { + // pDDraw->Release(); + // FreeLibrary( DDHinst ); + // return; + // } + + // // QI for IDirectDrawSurface3 succeeded. We must be at least DX5 + // (*pdwDXVersion) = 0x500; + + // /////////////////////////////////////////////////////////////////////////// + // // DirectX 6.0 Checks + // /////////////////////////////////////////////////////////////////////////// + + // // The IDirectDrawSurface4 interface was introduced with DX 6.0 + // if( FAILED( pSurf->QueryInterface( IID_IDirectDrawSurface4, + // (VOID**)&pSurf4 ) ) ) + // { + // pDDraw->Release(); + // FreeLibrary( DDHinst ); + // return; + // } + + // // IDirectDrawSurface4 was create successfully. We must be at least DX6 + // (*pdwDXVersion) = 0x600; + // pSurf->Release(); + // pDDraw->Release(); + + // /////////////////////////////////////////////////////////////////////////// + // // DirectX 6.1 Checks + // /////////////////////////////////////////////////////////////////////////// + + //// FIX: DirectMusic is deprecated. + // //// Check for DMusic, which was introduced with DX6.1 + // //LPDIRECTMUSIC pDMusic = NULL; + // //CoInitialize( NULL ); + // //hr = CoCreateInstance( CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, + // // IID_IDirectMusic, (VOID**)&pDMusic ); + // //if( FAILED(hr) ) + // //{ + // // OutputDebugString( "Couldn't create CLSID_DirectMusic\r\n" ); + // // FreeLibrary( DDHinst ); + // // return; + // //} + + // //// DirectMusic was created successfully. We must be at least DX6.1 + // //(*pdwDXVersion) = 0x601; + // //pDMusic->Release(); + // //CoUninitialize(); + // + + // /////////////////////////////////////////////////////////////////////////// + // // DirectX 7.0 Checks + // /////////////////////////////////////////////////////////////////////////// + + // // Check for DirectX 7 by creating a DDraw7 object + // LPDIRECTDRAW7 pDD7; + // DirectDrawCreateEx = (DIRECTDRAWCREATEEX)GetProcAddress( DDHinst, + // "DirectDrawCreateEx" ); + // if( NULL == DirectDrawCreateEx ) + // { + // FreeLibrary( DDHinst ); + // return; + // } + + // if( FAILED( DirectDrawCreateEx( NULL, (VOID**)&pDD7, IID_IDirectDraw7, + // NULL ) ) ) + // { + // FreeLibrary( DDHinst ); + // return; + // } + + // // DDraw7 was created successfully. We must be at least DX7.0 + // (*pdwDXVersion) = 0x700; + // pDD7->Release(); + + // + // /////////////////////////////////////////////////////////////////////////// + // // End of checks + // /////////////////////////////////////////////////////////////////////////// + + // // Close open libraries and return + // FreeLibrary( DDHinst ); + // + return; +} + +int getDXVersion() +{ + DWORD version, platform; + + GetDXVersion(&version, &platform); + + return (version >> 8) & 0xff; +} diff --git a/BlitzBasicLauncher/checkdx.h b/launcher/checkdx.h similarity index 100% rename from BlitzBasicLauncher/checkdx.h rename to launcher/checkdx.h diff --git a/launcher/checkie.cpp b/launcher/checkie.cpp new file mode 100644 index 0000000..395a060 --- /dev/null +++ b/launcher/checkie.cpp @@ -0,0 +1,26 @@ + +#include "checkie.h" +#include + +int getIEVersion() +{ + int version = 0; + + HKEY key = HKEY_LOCAL_MACHINE; + if (RegOpenKey(key, "Software\\Microsoft\\Internet Explorer", &key) == ERROR_SUCCESS) { + char buff[MAX_PATH]; + DWORD type, sz = MAX_PATH; + if (RegQueryValueEx(key, "Version", 0, &type, (PBYTE)buff, &sz) == ERROR_SUCCESS) { + version = 4; + /* + char temp[4]; + if( isdigit(buff[0]) && buff[1]=='.' && isdigit(buff[2]) && isdigit(buff[3]) && buff[4]=='.' ){ + temp[0]=buff[0];temp[1]=buff[2];temp[2]=buff[3];temp[3]=0; + if( atoi(temp)>=471 ) version=4; + } + */ + } + RegCloseKey(key); + } + return version; +} \ No newline at end of file diff --git a/BlitzBasicLauncher/checkie.h b/launcher/checkie.h similarity index 100% rename from BlitzBasicLauncher/checkie.h rename to launcher/checkie.h diff --git a/BlitzBasicLauncher/demo.html b/launcher/demo.html similarity index 100% rename from BlitzBasicLauncher/demo.html rename to launcher/demo.html diff --git a/BlitzBasicLauncher/resource.h b/launcher/resource.h similarity index 100% rename from BlitzBasicLauncher/resource.h rename to launcher/resource.h diff --git a/stdutil/stdutil.hpp b/stdutil/stdutil.hpp index 4167338..33eb844 100644 --- a/stdutil/stdutil.hpp +++ b/stdutil/stdutil.hpp @@ -24,7 +24,7 @@ std::string filenamepath(const std::string& t); std::string filenamefile(const std::string& t); //lazy version of auto_ptr -template +/*template class a_ptr { public: a_ptr(T* t = 0) : t(t) {} @@ -62,7 +62,7 @@ class a_ptr { private: T* t; -}; +};*/ //Speed-up for SLOW sstream class qstreambuf : public std::streambuf {