Script editor now is in a seperate tab

This commit is contained in:
Justin Marshall
2026-05-18 12:58:13 -07:00
parent 1c1f828271
commit 222cccc1f0
8 changed files with 5176 additions and 646 deletions
+123 -18
View File
@@ -31,43 +31,82 @@ If you have questions concerning this license or the applicable additional terms
#pragma once
#include "../comafx/CSyntaxRichEditCtrl.h"
class CScriptEditorCtrl;
// DialogScriptEditor dialog
class DialogScriptEditor : public CDialog {
//=============================================================================
// DialogScriptEditor
//
// Dockable Script Editor tab page. This version intentionally does not use
// the old syntax-rich edit control. The text editor is a custom dark-themed
// CWnd owned by DialogScriptEditor, with double-buffered manual drawing,
// caret/selection handling, syntax coloring, find/replace, virtual pk5 script
// opening, automatic incremental IntelliSense, signature help, and Save As/New
// file support.
//=============================================================================
class DialogScriptEditor : public CWnd {
DECLARE_DYNAMIC(DialogScriptEditor)
public:
DialogScriptEditor( CWnd* pParent = NULL ); // standard constructor
DialogScriptEditor( CWnd* pParent = NULL );
virtual ~DialogScriptEditor();
BOOL Create( CWnd *pParent, UINT nID );
BOOL Create( const RECT &rect, CWnd *pParent, UINT nID );
void OpenFile( const char *fileName );
bool SaveFile( void );
bool SaveFileAs( void );
bool ReloadFile( void );
void NewFile( void );
bool HasOpenFile( void ) const;
bool IsDirty( void ) const;
const char * GetFileName( void ) const;
void SetActive( BOOL bActive );
void FocusEditor( void );
void LayoutChildren( void );
void ShowIntelliSense( bool forced = false );
void HideIntelliSense( void );
static DialogScriptEditor *GetPrimaryEditor( void );
//{{AFX_VIRTUAL(DialogScriptEditor)
virtual BOOL OnInitDialog();
virtual void DoDataExchange( CDataExchange* pDX ); // DDX/DDV support
virtual BOOL PreTranslateMessage( MSG* pMsg );
virtual BOOL OnCmdMsg( UINT nID, int nCode, void *pExtra, AFX_CMDHANDLERINFO *pHandlerInfo );
//}}AFX_VIRTUAL
protected:
//{{AFX_MSG(DialogScriptEditor)
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnSetFocus( CWnd *pOldWnd );
afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
afx_msg void OnDestroy();
afx_msg void OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized );
afx_msg void OnMove( int x, int y );
afx_msg void OnSize( UINT nType, int cx, int cy );
afx_msg void OnSizing( UINT nSide, LPRECT lpRect );
afx_msg void OnSetFocus( CWnd *pOldWnd );
afx_msg void OnTimer( UINT_PTR nIDEvent );
afx_msg BOOL OnEraseBkgnd( CDC *pDC );
afx_msg HBRUSH OnCtlColor( CDC *pDC, CWnd *pWnd, UINT nCtlColor );
afx_msg void OnPaint();
afx_msg void OnDrawItem( int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct );
afx_msg void OnMeasureItem( int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct );
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnFileNew();
afx_msg void OnFileOpen();
afx_msg void OnFileSaveAs();
afx_msg void OnEditGoToLine();
afx_msg void OnEditFind();
afx_msg void OnEditFindNext();
afx_msg void OnEditReplace();
afx_msg void OnEditShowIntelliSense();
afx_msg LRESULT OnFindDialogMessage( WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnDeferredIntelliSense( WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnIntelliSenseKey( WPARAM wParam, LPARAM lParam );
afx_msg void OnEnChangeEdit( NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnEnInputEdit( NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnEditorSelectionChanged( NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnIntelliSenseDblClick();
afx_msg void OnIntelliSenseSelChange();
afx_msg void OnBnClickedOk();
afx_msg void OnBnClickedCancel();
//}}AFX_MSG
@@ -75,30 +114,96 @@ protected:
DECLARE_MESSAGE_MAP()
private:
//{{AFX_DATA(DialogScriptEditor)
enum { IDD = IDD_DIALOG_SCRIPTEDITOR };
CStatusBarCtrl statusBar;
CSyntaxRichEditCtrl scriptEdit;
CStatic m_titleLabel;
CStatic m_pathLabel;
CStatic m_statusLine;
CStatic m_languageLabel;
CStatic m_signatureHelp;
CScriptEditorCtrl *scriptEdit;
CListBox m_intellisenseList;
CButton newButton;
CButton openButton;
CButton saveAsButton;
CButton okButton;
CButton cancelButton;
//}}AFX_DATA
CButton findButton;
CButton replaceButton;
CButton goToButton;
CFont m_editorFont;
CFont m_uiFont;
CBrush m_backBrush;
CBrush m_panelBrush;
CBrush m_editBrush;
CBrush m_hotBrush;
static toolTip_t toolTips[];
static DialogScriptEditor *primaryEditor;
HACCEL m_hAccel;
CRect initialRect;
CFindReplaceDialog *findDlg;
CFindReplaceDialog *findDlg;
CString findStr;
CString replaceStr;
bool matchCase;
bool matchWholeWords;
bool searchForward;
idStr fileName;
int firstLine;
idStr loadedText;
int firstLine;
bool isDirty;
bool internalChange;
BOOL isActive;
bool m_intelliSenseReady;
bool m_intelliSenseCoreReady;
bool m_virtualFileListReady;
bool m_backgroundScanActive;
int m_backgroundScanNextFile;
UINT_PTR m_intelliSenseTimer;
int m_indexedScriptFiles;
int m_indexedSymbols;
private:
void InitScriptEvents( void );
void InitEditorChrome( void );
void ApplyDarkTheme( void );
void ConfigureEditorForFile( const char *fileName );
void EnsureIntelliSenseCore( void );
void EnsureVirtualScriptFileList( bool forceRebuild = false );
void StartIntelliSenseBackgroundScan( bool forceRebuild = false );
void IndexNextScriptFiles( int maxFiles );
void UpdateLiveCompletions( void );
void BuildIntelliSenseDatabase( bool forceRebuild = false );
void RebuildVirtualScriptFileList( void );
bool OpenFileFromDialog( void );
bool PromptSavePath( CString &selectedPath );
bool SaveFileAsDialog( void );
bool LoadTextFromFile( const char *path, idStr &text ) const;
bool WriteTextToFile( const char *path, const char *text, int textLength ) const;
bool IsNativeFilePath( const char *path ) const;
void SetDirty( bool dirty );
void UpdateTitle( void );
void UpdateStatusBar( void );
void UpdateLanguageLabel( const char *extension );
void SetEditorTextNormalized( const char *text );
bool GetEditorTextNormalized( idStr &text ) const;
bool ConfirmDiscardChanges( void );
bool HandleIntelliSenseKey( MSG *msg );
bool IsMemberCompletionContext( long wordStart ) const;
bool IsFunctionArgumentContext( void ) const;
void CompleteIntelliSense( void );
void PopulateIntelliSense( const CString &prefix, bool forced );
bool GetFunctionSignatureBeforeCaret( CString &functionName, CString &signature, int &argumentIndex ) const;
void ShowFunctionParameterHint( void );
void HideFunctionParameterHint( void );
void PositionParameterHint( void );
CString GetCurrentWord( long *wordStart = NULL, long *wordEnd = NULL ) const;
bool IsIdentifierChar( int ch ) const;
bool StartsWithNoCase( const CString &text, const CString &prefix ) const;
void InsertCompletion( const CString &completion );
void PositionIntelliSenseWindow( void );
};
DialogScriptEditor *ScriptEditorGetPrimaryEditor( void );
#endif /* !__DIALOGSCRIPTEDITOR_H__ */