robertsim007: Completed final file additions for the pre-apha release, 0.1 (a).
This commit is contained in:
parent
309ad3bf64
commit
5c448fff85
|
@ -31,7 +31,13 @@
|
|||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/stc/stc.h>
|
||||
#include <wx/config.h>
|
||||
#include <wx/filedlg.h>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/image.h>
|
||||
|
||||
// For Windows and OS/2, icon is a resource.
|
||||
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
|
||||
|
@ -43,10 +49,11 @@
|
|||
|
||||
#include "torqueideframe.h"
|
||||
#include "torqueideabout.h"
|
||||
#include "torqueidestc.h"
|
||||
|
||||
TorqueIDEFrame::TorqueIDEFrame(const wxString &title) : wxFrame ((wxFrame *)NULL, wxID_ANY, title, wxDefaultPosition, wxSize(750,550), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
||||
{
|
||||
scintilla = new wxStyledTextCtrl(this, -1); // Scintilla Edit
|
||||
scintilla = new TorqueIDESTC(this); // The other params default
|
||||
|
||||
// StatusBar
|
||||
InitStatusBar();
|
||||
|
@ -57,80 +64,10 @@ TorqueIDEFrame::TorqueIDEFrame(const wxString &title) : wxFrame ((wxFrame *)NULL
|
|||
// Menu
|
||||
InitMenu();
|
||||
|
||||
// Scintilla initialization
|
||||
scintilla->SetLexer(wxSTC_LEX_CPP); // use the C++ lexer since TorqueSCRIPT is almost C++.
|
||||
// CPP Lexer Properties
|
||||
scintilla->SetProperty("fold.comment", "1");
|
||||
scintilla->SetProperty("fold.preprocessor", "1");
|
||||
scintilla->SetProperty("fold.compact", "1");
|
||||
// Line Numbers
|
||||
// Margin for line numbers
|
||||
scintilla->SetMarginWidth(0, 30); // turn on the linenumbers margin, set width to 30pixels
|
||||
scintilla->SetMarginWidth(1, 0); // turn off the folding margin
|
||||
scintilla->SetMarginType(0, 1); // set margin type to linenumbers
|
||||
// Keywords
|
||||
scintilla->SetKeyWords(0, wxT("break case continue datablock default else false function if for new or package return switch switch$ true and while"));
|
||||
scintilla->SetKeyWords(1, wxT("OpenALInitDriver OpenALShutdownDriver OpenALRegisterExtensions"
|
||||
" alGetString alxCreateSource alxSourcef alxSource3f alxSourcei"
|
||||
" alxGetSourcef alxGetSource3f alxGetSourcei alxPlay alxStop"
|
||||
" alxStopAll alxIsPlaying alxListener alListener3f alxGetListenerf"
|
||||
" alxGetListener3f alxGetListeneri alxGetChannelVolume alxSetChannelVolume"
|
||||
" dumpConsoleClasses expandFilename strcmp stricmp strlen strstr"
|
||||
" strpos ltrim rtrim trim sripChars strlwr strupr strchr strreplace"
|
||||
" getSubStr getWord getWords setWord removeWord getWordCount"
|
||||
" getField getFields setField removeField getFieldCount getRecord"
|
||||
" getRecords setRecord removeRecord getRecordCount firstWord restWords"
|
||||
" detag getTag echo warn error expandEscape collapseEscape"
|
||||
" quit call compile exec export deleteVariables trace debug"
|
||||
" findFirstFile findNextFile getFileCount getFileCRC isFile"
|
||||
" isWriteableFileName fileExt fileBase fileName filePath nextToken"
|
||||
" setLogMode setEchoFileLoads backtrace isPackage activatePackage"
|
||||
" deactivatePackage nameToID isObject cancel isEventPending schedule"
|
||||
" deleteDataBlocks telnetSetParameters dbgSetParameters dnetSetLogging"
|
||||
" setNPatch toggleNPatch increaseNPatch decreaseNPatch setFSAA"
|
||||
" IncreaseFSAA decreaseFSAA setOpenGLMipReduction setOpenGLSkyMipReduction"
|
||||
" setOpenGLInteriorMipReduction setOpenGLTextureCompressionHint"
|
||||
" setOpenGLAnisotropy clearTextureHolds addMaterialMapping aiConnect"
|
||||
" aiAddPlayer setPowerAudioProfiles calcExplosionCoverage"
|
||||
" gotoWebPage deactivateDirectInput activateDirectInput strToPlayerName"
|
||||
" stripTrailingSpaces setDefaultFov setZoomSpeed setFov screenShot"
|
||||
" panoramaScreenShot purgeResources lightScene flushTextureCache"
|
||||
" dumpTextureStats dumpResourceStats getControlObjectAltitude"
|
||||
" getControlObjectSpeed containerFindFirst containerFindNext"
|
||||
" snapToggle getVersionNumber getVersionString getCompileTimeString"
|
||||
" getSimTime getRealTime setNetPort lockMouse rebuildModPaths"
|
||||
" setModPaths getModPaths createCanvas saveJournal playJournal"
|
||||
" addTaggedString removeTaggedString getTaggedString buildTaggedString"
|
||||
" commandToServer commandToClient allowConnections connect localConnect"
|
||||
" startRecord stopRecord playDemo isDemoRecording msg queryMasterServer"
|
||||
" cancelServerQuery stopServerQuery startHeartbeat stopHeartbeat"
|
||||
" getServerCount setServerInfo setShadowDetailLevel showShapeLoad showSequenceLoad"
|
||||
" showTurnLeft showTurnRight showUpdateThreadControl showSelectSequence"
|
||||
" showPlay showStop showSetScale showSetPos showNewThread showDeleteThread"
|
||||
" showToggleRoot showToggleStick showSetCamera showSetKeyboard showSetLightDirection"
|
||||
" showSetDetailSlider StripMLControlChars setInteriorRenderMode setInteriorFocusedDebug"
|
||||
" isPointInside VectorAdd VectorSub VectorScale VectorNormalize VectorDot"
|
||||
" VectorCross VectorDist VectorLen VectorOrthoBasis MatrixCreate"
|
||||
" MatrixMultiply MatrixMulVector MatrixMulPoint getBoxCenter"
|
||||
" setRandomSeed getRandomSeed getRandom MatrixCreateFromEuler mSolveQuadratic"
|
||||
" mSolveCubic mSolveQuartic mFloor mCeil mFloatLength mAbs mSqrt"
|
||||
" mPow mLog mSin mCos mTan mAsin mAcos mAtan mRadToDeg mDegToRad"
|
||||
" ValidateMemory FreeMemoryDump dumpMemSnapshot redbookOpen redbookClose"
|
||||
" redbookPlay redbookStop redbookGetTrackCount redbookGetVolume"
|
||||
" redbookSetVolume redbookGetDeviceCount redbookGetDeviceName redbookGetLastError"
|
||||
" videoSetGammaCorrection setDisplayDevice setScreenMode toggleFullScreen"
|
||||
" isFullScreen switchBitDepth prevResolution nextResolution getResolution"
|
||||
" setResolution setRes getDisplayDeviceList getResolutionList getVideoDriverInfo"
|
||||
" isDeviceFullScreenOnly setVerticalSync profilerMarkerEnable profilerEnable"
|
||||
" profilerDump profilerDumpToFile enableWinConsole isJoystickDetected"
|
||||
" getJoystickAxes enableMouse disableMouse echoInputState toggleInputState"
|
||||
" MathInit AddCardProfile addOSCardProfile getDesktopResolution activateKeyboard"
|
||||
" deactivateKeyboard GLEnableLogging GLEnableOutline GLEnableMetrics"
|
||||
" inputLog launchDedicatedServer isKoreanBuild debug_testx86unixmutex"
|
||||
" debug_debugbreak resetLighting getMaxFrameAllocation dumpNetStringTable"
|
||||
" InitContainerRadiusSearch ContainerSearchNext ContainerSearchCurrDist"
|
||||
" ContainerSearchCurrRadiusDist ContainerRayCast ContainerBoxEmpty"
|
||||
" pathOnMissionLoadDone makeTestTerrain getTerrainHeight")
|
||||
); //end scintilla->SetKeyWords()
|
||||
}
|
||||
|
||||
TorqueIDEFrame::~TorqueIDEFrame()
|
||||
|
@ -241,16 +178,15 @@ END_EVENT_TABLE()
|
|||
|
||||
void TorqueIDEFrame::OnMenuFileNew(wxCommandEvent &event)
|
||||
{
|
||||
wxLogMessage("File New Menu Selected");
|
||||
wxBell();
|
||||
}
|
||||
|
||||
void TorqueIDEFrame::OnMenuFileOpen(wxCommandEvent &event)
|
||||
{
|
||||
wxFileDialog *dlg = new wxFileDialog(this, "Open", "", "", "TorqueSCRIPT Files(*.cs)|*.cs|All files(*.*)|*.*", wxOPEN, wxDefaultPosition);
|
||||
if ( dlg->ShowModal() == wxID_OK )
|
||||
if(dlg->ShowModal() == wxID_OK)
|
||||
{
|
||||
scintilla->LoadFile(dlg->GetPath());
|
||||
scintilla->SetSavePoint();
|
||||
SetStatusText(dlg->GetFilename(), 1);
|
||||
}
|
||||
dlg->Destroy();
|
||||
|
@ -260,7 +196,7 @@ void TorqueIDEFrame::OnMenuFileSave(wxCommandEvent &event)
|
|||
{
|
||||
if(scintilla->GetModify())
|
||||
{
|
||||
wxLogMessage("File is modified!");
|
||||
scintilla->SaveFile();
|
||||
scintilla->SetSavePoint();
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +204,7 @@ void TorqueIDEFrame::OnMenuFileSave(wxCommandEvent &event)
|
|||
void TorqueIDEFrame::OnMenuFileSaveAs(wxCommandEvent &event)
|
||||
{
|
||||
wxFileDialog *dlg = new wxFileDialog(this, "Save As", "", "", "TorqueSCRIPT Files(*.cs)|*.cs|All files(*.*)|*.*", wxSAVE, wxDefaultPosition);
|
||||
if ( dlg->ShowModal() == wxID_OK )
|
||||
if(dlg->ShowModal() == wxID_OK)
|
||||
{
|
||||
scintilla->SaveFile(dlg->GetPath());
|
||||
scintilla->SetSavePoint();
|
||||
|
@ -279,7 +215,10 @@ void TorqueIDEFrame::OnMenuFileSaveAs(wxCommandEvent &event)
|
|||
|
||||
void TorqueIDEFrame::OnMenuFileQuit(wxCommandEvent &event)
|
||||
{
|
||||
Close(FALSE);
|
||||
if(!scintilla->GetModify())
|
||||
{
|
||||
Close(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void TorqueIDEFrame::OnMenuEditUndo(wxCommandEvent &event)
|
||||
|
@ -372,7 +311,7 @@ void TorqueIDEFrame::OnMenuSearchGoto(wxCommandEvent &event)
|
|||
|
||||
void TorqueIDEFrame::OnMenuHelpHelp(wxCommandEvent &event)
|
||||
{
|
||||
wxLogMessage("Help Help Menu Selected");
|
||||
wxBell();
|
||||
}
|
||||
|
||||
void TorqueIDEFrame::OnMenuHelpAbout(wxCommandEvent &event)
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
*/
|
||||
|
||||
#include <wx/frame.h>
|
||||
#include <wx/stc/stc.h>
|
||||
|
||||
#include "torqueidestc.h"
|
||||
|
||||
class TorqueIDEFrame : public wxFrame
|
||||
{
|
||||
|
@ -147,7 +148,7 @@ class TorqueIDEFrame : public wxFrame
|
|||
|
||||
private:
|
||||
// Editor
|
||||
wxStyledTextCtrl *scintilla;
|
||||
TorqueIDESTC *scintilla;
|
||||
|
||||
// Statusbar
|
||||
wxStatusBar *statusbar;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include "TorqueIDEPrefs.h"
|
||||
#include "torqueideprefs.h"
|
||||
|
||||
// Language Types
|
||||
const CommonInfo commonPrefs = {
|
||||
|
@ -45,7 +45,7 @@ const CommonInfo commonPrefs = {
|
|||
false, // readOnlyInitial
|
||||
false, // wrapModeInitial
|
||||
false, // displayEOLEnable
|
||||
false, // IndentGuideEnable
|
||||
true, // IndentGuideEnable
|
||||
true, // lineNumberEnable
|
||||
false, // longLineOnEnable
|
||||
false, // whiteSpaceEnable
|
||||
|
@ -115,7 +115,7 @@ wxChar* TorqueSCRIPTWordlist2 =
|
|||
const LanguageInfo languagePrefs [] = {
|
||||
// C++
|
||||
{_T("C++"),
|
||||
_T("*.c;*.cc;*.cpp;*.cxx;*.cs;*.h;*.hh;*.hpp;*.hxx;*.sma"),
|
||||
_T("*.c;*.cc;*.cpp;*.cxx;*.h;*.hh;*.hpp;*.hxx;*.sma"),
|
||||
wxSTC_LEX_CPP,
|
||||
{{TORQUEIDESTC_TYPE_DEFAULT, NULL},
|
||||
{TORQUEIDESTC_TYPE_COMMENT, NULL},
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <wx/stc/stc.h>
|
||||
|
||||
// STC Related Prefs
|
||||
#define DEFAULT_LANGUAGE _("<default>")
|
||||
#define DEFAULT_LANGUAGE _("*.*")
|
||||
#define STYLE_TYPES_COUNT 32
|
||||
|
||||
// General Style Types
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Torque Game Engine
|
||||
*
|
||||
* Copyright (C) 2005 Robert Pierce
|
||||
** Adapted from wxWidgets STC example
|
||||
*
|
||||
* Refer to the file CONTRIB.txt for the people who have helped.
|
||||
*
|
||||
|
@ -31,12 +32,328 @@
|
|||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/file.h>
|
||||
#include <wx/filename.h>
|
||||
|
||||
#include "torqueidestc.h"
|
||||
|
||||
TorqueIDESTC::TorqueIDESTC()
|
||||
TorqueIDESTC::TorqueIDESTC(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
|
||||
: wxStyledTextCtrl(parent, id, pos, size, style)
|
||||
{
|
||||
filename = _T("");
|
||||
|
||||
lineNumID = 0;
|
||||
dividerID = 1;
|
||||
foldingID = 2;
|
||||
|
||||
// initialize language
|
||||
language = NULL;
|
||||
|
||||
// default font for all styles
|
||||
SetViewEOL(commonPrefs.displayEOLEnable);
|
||||
SetIndentationGuides(commonPrefs.indentGuideEnable);
|
||||
SetEdgeMode(commonPrefs.longLineOnEnable? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE);
|
||||
SetViewWhiteSpace(commonPrefs.whiteSpaceEnable? wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE);
|
||||
SetOvertype(commonPrefs.overTypeInitial);
|
||||
SetReadOnly(commonPrefs.readOnlyInitial);
|
||||
SetWrapMode(commonPrefs.wrapModeInitial? wxSTC_WRAP_WORD: wxSTC_WRAP_NONE);
|
||||
wxFont font(10, wxMODERN, wxNORMAL, wxNORMAL);
|
||||
StyleSetFont(wxSTC_STYLE_DEFAULT, font);
|
||||
StyleSetForeground(wxSTC_STYLE_DEFAULT, wxColour (_T("BLACK")));
|
||||
StyleSetBackground(wxSTC_STYLE_DEFAULT, wxColour (_T("WHITE")));
|
||||
StyleSetForeground(wxSTC_STYLE_LINENUMBER, wxColour (_T("DARK GREY")));
|
||||
StyleSetBackground(wxSTC_STYLE_LINENUMBER, wxColour (_T("WHITE")));
|
||||
StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (_T("DARK GREY")));
|
||||
InitializePrefs(DEFAULT_LANGUAGE);
|
||||
|
||||
// set visibility
|
||||
SetVisiblePolicy(wxSTC_VISIBLE_STRICT|wxSTC_VISIBLE_SLOP, 1);
|
||||
SetXCaretPolicy(wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1);
|
||||
SetYCaretPolicy(wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1);
|
||||
|
||||
// markers
|
||||
MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_DOTDOTDOT, _T("BLACK"), _T("BLACK"));
|
||||
MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, _T("BLACK"), _T("BLACK"));
|
||||
MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY, _T("BLACK"), _T("BLACK"));
|
||||
MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_DOTDOTDOT, _T("BLACK"), _T("WHITE"));
|
||||
MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_ARROWDOWN, _T("BLACK"), _T("WHITE"));
|
||||
MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY, _T("BLACK"), _T("BLACK"));
|
||||
MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY, _T("BLACK"), _T("BLACK"));
|
||||
|
||||
// miscelaneous
|
||||
lineNumMargin = TextWidth(wxSTC_STYLE_LINENUMBER, _T("_999999"));
|
||||
foldingMargin = 16;
|
||||
CmdKeyClear(wxSTC_KEY_TAB, 0); // this is done by the menu accelerator key
|
||||
SetLayoutCache(wxSTC_CACHE_PAGE);
|
||||
}
|
||||
|
||||
TorqueIDESTC::~TorqueIDESTC()
|
||||
{
|
||||
}
|
||||
|
||||
wxString TorqueIDESTC::DeterminePrefs(const wxString &file)
|
||||
{
|
||||
LanguageInfo const* curInfo;
|
||||
|
||||
// Determine Language Filepatterns
|
||||
int languageNum;
|
||||
for (languageNum = 0; languageNum < languagePrefsSize; languageNum++) {
|
||||
curInfo = &languagePrefs[languageNum];
|
||||
wxString filepattern = curInfo->filepattern;
|
||||
filepattern.Lower();
|
||||
while (!filepattern.IsEmpty()) {
|
||||
wxString cur = filepattern.BeforeFirst (';');
|
||||
if ((cur == file) || (cur == (file.BeforeLast ('.') + _T(".*"))) || (cur == (_T("*.") + file.AfterLast ('.'))))
|
||||
{
|
||||
return curInfo->name;
|
||||
}
|
||||
filepattern = filepattern.AfterFirst (';');
|
||||
}
|
||||
}
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
bool TorqueIDESTC::InitializePrefs (const wxString &name)
|
||||
{
|
||||
// Init Styles
|
||||
StyleClearAll();
|
||||
LanguageInfo const* curInfo = NULL;
|
||||
|
||||
// Determine Language
|
||||
bool found = false;
|
||||
int languageNum;
|
||||
for(languageNum = 0; languageNum < languagePrefsSize; languageNum++) {
|
||||
curInfo = &languagePrefs[languageNum];
|
||||
if (curInfo->name == name) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set Lexer and Language
|
||||
SetLexer(curInfo->lexer);
|
||||
language = curInfo;
|
||||
|
||||
// Set Margin for Line Numbers
|
||||
SetMarginType(lineNumID, wxSTC_MARGIN_NUMBER);
|
||||
StyleSetForeground(wxSTC_STYLE_LINENUMBER, wxColour(_T("DARK GREY")));
|
||||
StyleSetBackground(wxSTC_STYLE_LINENUMBER, wxColour(_T("WHITE")));
|
||||
SetMarginWidth(lineNumID, 0); // Start out invisible
|
||||
|
||||
// Default Fonts for Styles
|
||||
int Num;
|
||||
for(Num = 0; Num < wxSTC_STYLE_LASTPREDEFINED; Num++) {
|
||||
wxFont font(10, wxMODERN, wxNORMAL, wxNORMAL);
|
||||
StyleSetFont(Num, font);
|
||||
}
|
||||
|
||||
// Set Common Styles
|
||||
StyleSetForeground(wxSTC_STYLE_DEFAULT, wxColour (_T("DARK GREY")));
|
||||
StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (_T("DARK GREY")));
|
||||
|
||||
// Init Settings
|
||||
if(commonPrefs.syntaxEnable) {
|
||||
int keywordNum = 0;
|
||||
for(Num = 0; Num < STYLE_TYPES_COUNT; Num++) {
|
||||
if(curInfo->styles[Num].type == -1) continue;
|
||||
const StyleInfo &curType = stylePrefs [curInfo->styles[Num].type];
|
||||
wxFont font(curType.fontsize, wxMODERN, wxNORMAL, wxNORMAL, false, curType.fontname);
|
||||
StyleSetFont(Num, font);
|
||||
if(curType.foreground) {
|
||||
StyleSetForeground(Num, wxColour (curType.foreground));
|
||||
}
|
||||
if(curType.background) {
|
||||
StyleSetBackground(Num, wxColour (curType.background));
|
||||
}
|
||||
StyleSetBold(Num, (curType.fontstyle & TORQUEIDESTC_STYLE_BOLD) > 0);
|
||||
StyleSetItalic(Num, (curType.fontstyle & TORQUEIDESTC_STYLE_ITALIC) > 0);
|
||||
StyleSetUnderline(Num, (curType.fontstyle & TORQUEIDESTC_STYLE_UNDERL) > 0);
|
||||
StyleSetVisible(Num, (curType.fontstyle & TORQUEIDESTC_STYLE_HIDDEN) == 0);
|
||||
StyleSetCase(Num, curType.lettercase);
|
||||
const wxChar *pwords = curInfo->styles[Num].words;
|
||||
if(pwords) {
|
||||
SetKeyWords(keywordNum, pwords);
|
||||
keywordNum += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set Margin as unused
|
||||
SetMarginType(dividerID, wxSTC_MARGIN_SYMBOL);
|
||||
SetMarginWidth(dividerID, 0);
|
||||
SetMarginSensitive(dividerID, false);
|
||||
|
||||
// Folding
|
||||
SetMarginType(foldingID, wxSTC_MARGIN_SYMBOL);
|
||||
SetMarginMask(foldingID, wxSTC_MASK_FOLDERS);
|
||||
StyleSetBackground(foldingID, wxColour (_T("WHITE")));
|
||||
SetMarginWidth(foldingID, 0);
|
||||
SetMarginSensitive(foldingID, false);
|
||||
if (commonPrefs.foldEnable) {
|
||||
SetMarginWidth(foldingID, curInfo->folds != 0? foldingMargin: 0);
|
||||
SetMarginSensitive(foldingID, curInfo->folds != 0);
|
||||
SetProperty(_T("fold"), curInfo->folds != 0? _T("1"): _T("0"));
|
||||
SetProperty(_T("fold.comment"), (curInfo->folds & TORQUEIDESTC_FOLD_COMMENT) > 0? _T("1"): _T("0"));
|
||||
SetProperty(_T("fold.compact"), (curInfo->folds & TORQUEIDESTC_FOLD_COMPACT) > 0? _T("1"): _T("0"));
|
||||
SetProperty(_T("fold.preprocessor"), (curInfo->folds & TORQUEIDESTC_FOLD_PREPROC) > 0? _T("1"): _T("0"));
|
||||
SetProperty(_T("fold.html"), (curInfo->folds & TORQUEIDESTC_FOLD_HTML) > 0? _T("1"): _T("0"));
|
||||
SetProperty(_T("fold.html.preprocessor"), (curInfo->folds & TORQUEIDESTC_FOLD_HTMLPREP) > 0? _T("1"): _T("0"));
|
||||
SetProperty(_T("fold.comment.python"), (curInfo->folds & TORQUEIDESTC_FOLD_COMMENTPY) > 0? _T("1"): _T("0"));
|
||||
SetProperty(_T("fold.quotes.python"), (curInfo->folds & TORQUEIDESTC_FOLD_QUOTESPY) > 0? _T("1"): _T("0"));
|
||||
}
|
||||
SetFoldFlags(wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED | wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED);
|
||||
|
||||
// Set Tabs and Indentation
|
||||
SetTabWidth(4);
|
||||
SetUseTabs(true);
|
||||
SetTabIndents(true);
|
||||
SetBackSpaceUnIndents(true);
|
||||
SetIndent(commonPrefs.indentEnable? 4: 0);
|
||||
|
||||
// Others
|
||||
SetViewEOL(commonPrefs.displayEOLEnable);
|
||||
SetIndentationGuides(commonPrefs.indentGuideEnable);
|
||||
SetEdgeColumn(80);
|
||||
SetEdgeMode(commonPrefs.longLineOnEnable? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE);
|
||||
SetViewWhiteSpace(commonPrefs.whiteSpaceEnable? wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE);
|
||||
SetOvertype(commonPrefs.overTypeInitial);
|
||||
SetReadOnly(commonPrefs.readOnlyInitial);
|
||||
SetWrapMode(commonPrefs.wrapModeInitial? wxSTC_WRAP_WORD: wxSTC_WRAP_NONE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TorqueIDESTC::LoadFile()
|
||||
{
|
||||
// Get Filename
|
||||
if (!filename)
|
||||
{
|
||||
wxFileDialog dlg (this, _T("Open file"), _T(""), _T(""), _T("Any file (*)|*"), wxOPEN | wxFILE_MUST_EXIST | wxCHANGE_DIR);
|
||||
if (dlg.ShowModal() != wxID_OK) return false;
|
||||
filename = dlg.GetPath();
|
||||
}
|
||||
|
||||
// Load File
|
||||
return LoadFile(filename);
|
||||
}
|
||||
|
||||
bool TorqueIDESTC::LoadFile(const wxString &file)
|
||||
{
|
||||
// Load File and clear undo
|
||||
if (!file.IsEmpty())
|
||||
{
|
||||
filename = file;
|
||||
}
|
||||
// wxFile file(filename);
|
||||
// if (!file.IsOpened()) return false;
|
||||
ClearAll();
|
||||
// long lng = file.Length ();
|
||||
// if (lng > 0) {
|
||||
// wxString buf;
|
||||
// wxChar *buff = buf.GetWriteBuf (lng);
|
||||
// file.Read (buff, lng);
|
||||
// buf.UngetWriteBuf ();
|
||||
// InsertText (0, buf);
|
||||
// }
|
||||
// file.Close();
|
||||
|
||||
wxStyledTextCtrl::LoadFile(file);
|
||||
|
||||
EmptyUndoBuffer();
|
||||
|
||||
// Determine Lexer Language
|
||||
wxFileName fname(file);
|
||||
InitializePrefs(DeterminePrefs(fname.GetFullName()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TorqueIDESTC::SaveFile()
|
||||
{
|
||||
// return if no change
|
||||
if (!Modified()) return true;
|
||||
|
||||
// Get Filename
|
||||
if (!filename) {
|
||||
wxFileDialog dlg (this, _T("Save file"), _T(""), _T(""), _T("Any file (*)|*"), wxSAVE | wxOVERWRITE_PROMPT);
|
||||
if (dlg.ShowModal() != wxID_OK) return false;
|
||||
filename = dlg.GetPath();
|
||||
}
|
||||
|
||||
// Save File
|
||||
return SaveFile(filename);
|
||||
}
|
||||
|
||||
bool TorqueIDESTC::SaveFile(const wxString &file)
|
||||
{
|
||||
// return if no change
|
||||
if (!Modified()) return true;
|
||||
|
||||
// // Save file and clear undo
|
||||
// if (!filename.IsEmpty()) m_filename = filename;
|
||||
// wxFile file (m_filename, wxFile::write);
|
||||
// if (!file.IsOpened()) return false;
|
||||
// wxString buf = GetText();
|
||||
// bool okay = file.Write (buf);
|
||||
// file.Close();
|
||||
// if (!okay) return false;
|
||||
// EmptyUndoBuffer();
|
||||
// SetSavePoint();
|
||||
|
||||
// return true;
|
||||
|
||||
return wxStyledTextCtrl::SaveFile(file);
|
||||
}
|
||||
|
||||
bool TorqueIDESTC::Modified ()
|
||||
{
|
||||
// Return Modified State
|
||||
|
||||
return(GetModify() && !GetReadOnly());
|
||||
}
|
||||
|
||||
/**
|
||||
* Events and Event Handlers
|
||||
*/
|
||||
BEGIN_EVENT_TABLE(TorqueIDESTC, wxStyledTextCtrl)
|
||||
EVT_SIZE(TorqueIDESTC::OnSize)
|
||||
EVT_STC_MARGINCLICK(wxID_ANY, TorqueIDESTC::OnMarginClick)
|
||||
EVT_STC_CHARADDED(wxID_ANY, TorqueIDESTC::OnCharAdded)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void TorqueIDESTC::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
int x = GetClientSize().x + (commonPrefs.lineNumberEnable? lineNumMargin: 0) + (commonPrefs.foldEnable? foldingMargin: 0);
|
||||
if (x > 0) SetScrollWidth(x);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void TorqueIDESTC::OnMarginClick(wxStyledTextEvent &event) {
|
||||
if(event.GetMargin() == 2) {
|
||||
int lineClick = LineFromPosition (event.GetPosition());
|
||||
int levelClick = GetFoldLevel (lineClick);
|
||||
if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0) {
|
||||
ToggleFold (lineClick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TorqueIDESTC::OnCharAdded(wxStyledTextEvent &event)
|
||||
{
|
||||
char chr = (char)event.GetKey();
|
||||
int currentLine = GetCurrentLine();
|
||||
// Change this if support for mac files with \r is needed
|
||||
if (chr == '\n') {
|
||||
int lineInd = 0;
|
||||
if(currentLine > 0) {
|
||||
lineInd = GetLineIndentation(currentLine - 1);
|
||||
}
|
||||
if(lineInd == 0) return;
|
||||
SetLineIndentation(currentLine, lineInd);
|
||||
GotoPos(PositionFromLine (currentLine) + lineInd);
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
* Torque Game Engine
|
||||
*
|
||||
* Copyright (C) 2005 Robert Pierce
|
||||
**Adapted from wxWidgets STC example
|
||||
*
|
||||
* Refer to the file CONTRIB.txt for the people who have helped.
|
||||
*
|
||||
|
@ -28,18 +29,58 @@
|
|||
|
||||
#include <wx/stc/stc.h>
|
||||
|
||||
#include "torqueideprefs.h"
|
||||
|
||||
class TorqueIDESTC : public wxStyledTextCtrl
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
TorqueIDESTC();
|
||||
TorqueIDESTC(wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint &pos = wxDefaultPosition,
|
||||
const wxSize &size = wxDefaultSize,
|
||||
long style = wxSUNKEN_BORDER|wxVSCROLL
|
||||
);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~TorqueIDESTC();
|
||||
|
||||
// Events
|
||||
void OnSize(wxSizeEvent &event);
|
||||
void OnMarginClick(wxStyledTextEvent &event);
|
||||
void OnCharAdded(wxStyledTextEvent &event);
|
||||
|
||||
|
||||
// Language/Lexer
|
||||
wxString DeterminePrefs(const wxString &file);
|
||||
bool InitializePrefs(const wxString &file);
|
||||
LanguageInfo const* GetLanguageInfo() {return language;};
|
||||
|
||||
// Loading/Saving
|
||||
bool LoadFile();
|
||||
bool LoadFile(const wxString &file);
|
||||
bool SaveFile();
|
||||
bool SaveFile(const wxString &file);
|
||||
bool Modified();
|
||||
wxString GetFilename() {return filename;};
|
||||
void SetFilename(const wxString &file) {filename = file;};
|
||||
|
||||
private:
|
||||
wxString filename;
|
||||
|
||||
LanguageInfo const* language;
|
||||
|
||||
// Margin Variables
|
||||
int lineNumID;
|
||||
int lineNumMargin;
|
||||
int foldingID;
|
||||
int foldingMargin;
|
||||
int dividerID;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif _TORQUEIDESCINTILLA_H
|
|
@ -1,2 +0,0 @@
|
|||
Robert Pierce :: Started project, main developer
|
||||
<INSERT NAME HERE> :: <INSERT WHAT YOU DID HERE>
|
|
@ -87,7 +87,19 @@ SOURCE=..\src\torqueideframe.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\torqueidescintilla.h
|
||||
SOURCE=..\src\torqueideprefs.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\torqueideprefs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\torqueidestc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\torqueidestc.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
|
@ -6,11 +6,33 @@
|
|||
--------------------Configuration: TorqueIDE - Win32 Release--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating temporary file "C:\DOCUME~1\robert\LOCALS~1\Temp\RSP19F.tmp" with contents
|
||||
[
|
||||
/nologo /MD /W4 /O2 /I "C:\programming\wxWindows/include" /I "C:\programming\wxWindows/contrib/include" /I "C:\programming\wxWindows/lib/vc_lib/msw" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /Fp"Release/TorqueIDE.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c
|
||||
"F:\torque-ide\src\torqueidestc.cpp"
|
||||
]
|
||||
Creating command line "cl.exe @C:\DOCUME~1\robert\LOCALS~1\Temp\RSP19F.tmp"
|
||||
Creating temporary file "C:\DOCUME~1\robert\LOCALS~1\Temp\RSP1A0.tmp" with contents
|
||||
[
|
||||
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib C:\programming\wxWindows/lib/vc_lib/wxbase25.lib C:\programming\wxWindows/lib/vc_lib/wxmsw25_core.lib C:\programming\wxWindows/lib/vc_lib/wxmsw25_stc.lib C:\programming\wxWindows/lib/vc_lib/wxzlib.lib C:\programming\wxWindows/lib/vc_lib/wxregex.lib C:\programming\wxWindows/lib/vc_lib/wxpng.lib C:\programming\wxWindows/lib/vc_lib/wxjpeg.lib C:\programming\wxWindows/lib/vc_lib/wxtiff.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/TorqueIDE.pdb" /machine:I386 /out:"Release/TorqueIDE.exe"
|
||||
".\Release\torqueideabout.obj"
|
||||
".\Release\torqueideapp.obj"
|
||||
".\Release\torqueideframe.obj"
|
||||
".\Release\torqueideprefs.obj"
|
||||
".\Release\torqueidestc.obj"
|
||||
".\Release\TorqueIDE.res"
|
||||
]
|
||||
Creating command line "link.exe @C:\DOCUME~1\robert\LOCALS~1\Temp\RSP1A0.tmp"
|
||||
<h3>Output Window</h3>
|
||||
Compiling...
|
||||
torqueidestc.cpp
|
||||
Linking...
|
||||
LINK : warning LNK4089: all references to "ADVAPI32.dll" discarded by /OPT:REF
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
TorqueIDE.exe - 0 error(s), 0 warning(s)
|
||||
TorqueIDE.exe - 0 error(s), 1 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue