Exemple #1
0
        public void LoadKeywords(HspCmpDll hspCmpDll)
        {
            HashSet<string> hspTypes = new HashSet<string>() {
                "var", "array", "local",
                "int", "double", "float",
                "str", "wstr", "sptr", "wptr",
                "hwnd", "hdc", "hinst",
                "comobj", "pval", "bmscr", "prefstr", "pexinfo", "nullptr"
            };

            foreach (string hspType in hspTypes) {
                this.mKeywords.Add(hspType, new Keyword { mKeyword = hspType, mType = KeywordType.Type });
            }

            string keywordList = hspCmpDll.GetKeywordList();
            string[] keywordLines = keywordList.Split(new string[] { "\r\n", "\n" },
                StringSplitOptions.RemoveEmptyEntries);

            Regex regex = new Regex(@"^(?<Keyword>.+?)\s*,(?<Category>.+)$", RegexOptions.Compiled);
            Match match = null;
            KeywordType keywordType = KeywordType.None;

            foreach (string keywordLine in keywordLines) {
                match = regex.Match(keywordLine);
                if (match.Success) {
                    string keywordLower = match.Groups["Keyword"].Value.ToLower();

                    if (this.mKeywords.ContainsKey(keywordLower)) {
                        continue;
                    }

                    switch (match.Groups["Category"].Value) {
                        case "sys|macro":
                            keywordType = KeywordType.Macro;
                            break;
                        case "sys|func":
                        case "sys|func|1":
                        case "sys|func|2":
                            keywordType = KeywordType.Function;
                            break;
                        case "pre|func":
                            keywordType = KeywordType.Preprocessor;
                            break;
                    }

                    this.mKeywords.Add(keywordLower, new Keyword {
                        mKeyword = keywordLower, mType = keywordType
                    });
                }
            }
        }
Exemple #2
0
        public MainForm()
        {
            this.InitializeComponent();

            this.mDeserializeDockContent = new DeserializeDockContent(this.GetDockContentFromPersistString);

            this.LoadLayout();
            this.LoadSettings();

            this.mHspCmpDll = new HspCmpDll();

            if (Directory.Exists(this.mHspDirectory)) {
                this.mHspCmpDll.Load(this.mHspDirectory);
            } else {
                this.mHspCmpDll.Load(@"C:\hsp34"); // DEBUG
            }

            this.mHspLexer = new HspLexer();
            this.mHspLexer.LoadKeywords(this.mHspCmpDll);

            Application.Idle += this.OnApplicationIdle;

            this.mDockPanel.ActiveDocumentChanged += this.OnDockPanelActiveDocumentChanged;

            this.mMenuFileNew.Click += this.OnFileNew;
            this.mMenuFileOpen.Click += this.OnFileOpen;
            this.mMenuFileOpenFolderWithExplorer.Click += this.OnOpenFolderWithExplorer;
            this.mMenuFileOpenFolderWithCommandPrompt.Click += this.OnOpenFolderWithCommandPrompt;
            this.mMenuFileReopen.Click += this.OnReopen;
            this.mMenuFileSave.Click += this.OnSave;
            this.mMenuFileSaveAs.Click += this.OnSaveAs;
            this.mMenuFileSaveAll.Click += this.OnSaveAll;
            this.mMenuFileClose.Click += this.OnClose;
            this.mMenuFileCloseAll.Click += this.OnCloseAll;
            this.mMenuFileOpenAllMRUFiles.Click += this.OnOpenAllMRUFiles;
            this.mMenuFileClearMRUFiles.Click += this.OnClearMRUFiles;
            this.mMenuFileQuit.Click += this.OnQuit;

            this.mMenuEditUndo.Click += this.OnUndo;
            this.mMenuEditRedo.Click += this.OnRedo;
            this.mMenuEditCut.Click += this.OnCut;
            this.mMenuEditCopy.Click += this.OnCopy;
            this.mMenuEditPaste.Click += this.OnPaste;
            this.mMenuEditDelete.Click += this.OnDelete;
            this.mMenuEditSelectAll.Click += this.OnSelectAll;
            this.mMenuEditCopyFilePathToClipboard.Click += this.OnCopyFilePathToClipboard;
            this.mMenuEditCopyFileNameToClipboard.Click += this.OnCopyFileNameToClipboard;
            this.mMenuEditCopyFolderPathToClipboard.Click += this.OnCopyFolderPathToClipboard;
            this.mMenuEditIncreaseLineIndent.Click += this.OnIncreaseLineIndent;
            this.mMenuEditDecreaseLineIndent.Click += this.OnDecreaseLineIndent;
            this.mMenuEditToLower.Click += this.OnConvertToLowercase;
            this.mMenuEditToUpper.Click += this.OnConvertToUppercase;
            this.mMenuEditDuplicateCurrentLine.Click += this.OnDuplicateCurrentLine;
            this.mMenuEditSplitLines.Click += this.OnSplitLines;
            this.mMenuEditJoinLines.Click += this.OnJoinLines;
            this.mMenuEditMoveSelectedLinesUp.Click += this.OnMoveSelectedLinesUp;
            this.mMenuEditMoveSelectedLinesDown.Click += this.OnMoveSelectedLinesDown;
            this.mMenuEditRemoveEmptyLines.Click += this.OnRemoveEmptyLines;
            this.mMenuEditRemoveEmptyLinesWithBlank.Click += this.OnRemoveEmptyLinesWithBlank;
            this.mMenuEditFormatToCrLf.Click += this.OnFormatToCrLf;
            this.mMenuEditFormatToLf.Click += this.OnFormatToLf;
            this.mMenuEditFormatToCr.Click += this.OnFormatToCr;
            this.mMenuEditReadOnly.Click += this.OnReadOnly;

            this.mMenuSearchFind.Click += this.OnFind;
            this.mMenuSearchReplace.Click += this.OnReplace;

            this.mMenuViewToolBarMain.Click += this.OnViewToolBarMain;
            this.mMenuViewStatusBar.Click += this.OnViewStatusBarMain;

            this.mToolBarButtonNew.Click += this.OnFileNew;
            this.mToolBarButtonOpen.Click += this.OnFileOpen;
            this.mToolBarButtonSave.Click += this.OnSave;
            this.mToolBarButtonSaveAll.Click += this.OnSaveAll;

            this.mToolBarButtonCut.Click += this.OnCut;
            this.mToolBarButtonCopy.Click += this.OnCopy;
            this.mToolBarButtonPaste.Click += this.OnPaste;
            this.mToolBarButtonDelete.Click += this.OnDelete;
            this.mToolBarButtonUndo.Click += this.OnUndo;
            this.mToolBarButtonRedo.Click += this.OnRedo;
        }