RunCommand() 공개 정적인 메소드

Allows to execute one of Npp's command
public static RunCommand ( NppMenuCmd cmd ) : void
cmd NppMenuCmd
리턴 void
예제 #1
0
파일: Plug.cs 프로젝트: devjerome/3P
        /// <summary>
        /// Called when the user switches tab document,
        /// no matter if the document is a Progress file or not
        /// </summary>
        public static void DoNppBufferActivated(bool initiating = false)
        {
            // if the file has just been opened
            var currentFile = Npp.GetCurrentFilePath();

            if (!_openedFileList.Contains(currentFile))
            {
                _openedFileList.Add(currentFile);

                // need to auto change encoding?
                if (Config.Instance.AutoSwitchEncodingTo != NppEncodingFormat._Automatic_default && !string.IsNullOrEmpty(Config.Instance.AutoSwitchEncodingForFilePatterns))
                {
                    if (Npp.GetCurrentFilePath().TestAgainstListOfPatterns(Config.Instance.AutoSwitchEncodingForFilePatterns))
                    {
                        NppMenuCmd cmd;
                        if (Enum.TryParse(((int)Config.Instance.AutoSwitchEncodingTo).ToString(), true, out cmd))
                        {
                            Npp.RunCommand(cmd);
                        }
                    }
                }
            }

            // deactivate show space for conf files
            if (ShareExportConf.IsFileExportedConf(CurrentFilePath))
            {
                if (Npp.ViewWhitespace != WhitespaceMode.Invisible && !Npp.ViewEol)
                {
                    Npp.ViewWhitespace = _whitespaceMode;
                }
            }

            DoNppDocumentSwitched(initiating);

            // activate show space for conf files
            if (ShareExportConf.IsFileExportedConf(CurrentFilePath))
            {
                Npp.ViewWhitespace = WhitespaceMode.VisibleAlways;
            }
        }
예제 #2
0
        /// <summary>
        /// Called when the user switches tab document
        /// You can use Npp.CurrentFile and Npp.PreviousFile in this method
        /// </summary>
        public static void DoNppBufferActivated(bool initiating = false)
        {
            // Apply options to npp and scintilla depending if we are on a progress file or not
            ApplyOptionsForScintilla();

            // if the file has just been opened
            if (!_openedFileList.Contains(Npp.CurrentFileInfo.Path))
            {
                _openedFileList.Add(Npp.CurrentFileInfo.Path);

                // need to auto change encoding?
                if (Config.Instance.AutoSwitchEncodingTo != NppEncodingFormat._Automatic_default && !string.IsNullOrEmpty(Config.Instance.AutoSwitchEncodingForFilePatterns))
                {
                    if (Npp.CurrentFileInfo.Path.TestAgainstListOfPatterns(Config.Instance.AutoSwitchEncodingForFilePatterns))
                    {
                        NppMenuCmd cmd;
                        if (Enum.TryParse(((int)Config.Instance.AutoSwitchEncodingTo).ToString(), true, out cmd))
                        {
                            Npp.RunCommand(cmd);
                        }
                    }
                }
            }

            // activate show space for conf files / deactivate if coming from a conf file
            if (ShareExportConf.IsFileExportedConf(Npp.PreviousFileInfo.Path))
            {
                if (Sci.ViewWhitespace != WhitespaceMode.Invisible && !Sci.ViewEol)
                {
                    Sci.ViewWhitespace = _whitespaceMode;
                }
            }
            if (ShareExportConf.IsFileExportedConf(Npp.CurrentFileInfo.Path))
            {
                Sci.ViewWhitespace = WhitespaceMode.VisibleAlways;
            }

            // close popups..
            ClosePopups();

            if (initiating)
            {
                // make sure to use the ProEnvironment and colorize the error counter
                OpenedFilesInfo.UpdateFileStatus();
            }
            else
            {
                if (Config.Instance.CodeExplorerAutoHideOnNonProgressFile)
                {
                    CodeExplorer.Instance.Toggle(Npp.CurrentFileInfo.IsProgress);
                }
                if (Config.Instance.FileExplorerAutoHideOnNonProgressFile)
                {
                    FileExplorer.Instance.Toggle(Npp.CurrentFileInfo.IsProgress);
                }
            }

            // Update info on the current file
            OpenedFilesInfo.UpdateErrorsInScintilla();
            ProEnvironment.Current.ReComputeProPath();

            AutoCompletion.SetStaticItems();

            // Parse the document
            ParserHandler.ParseDocumentNow();

            // publish the event
            if (OnDocumentChangedEnd != null)
            {
                OnDocumentChangedEnd();
            }
        }