GetCurrentFilePath() публичный статический Метод

Gets the path of the current document.
public static GetCurrentFilePath ( ) : string
Результат string
Пример #1
0
        /// <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
        public static void DoNppDocumentSwitched(bool initiating = false)
        {
            // update current file info
            IsPreviousFileProgress = IsCurrentFileProgress;
            IsCurrentFileProgress  = Abl.IsCurrentProgressFile;
            CurrentFilePath        = Npp.GetCurrentFilePath();
            CurrentFileObject      = FilesInfo.GetFileInfo(CurrentFilePath);

            // accept advanced notifications only if the current file is a progress file
            CurrentFileAllowed = IsCurrentFileProgress;

            // update current scintilla
            Npp.UpdateScintilla();

            // Apply options to npp and scintilla depending if we are on a progress file or not
            ApplyOptionsForScintilla();

            // close popups..
            ClosePopups();

            // Update info on the current file
            FilesInfo.UpdateErrorsInScintilla();

            // refresh file explorer currently opened file
            FileExplorer.RedrawFileExplorerList();

            if (!initiating)
            {
                if (Config.Instance.CodeExplorerAutoHideOnNonProgressFile)
                {
                    CodeExplorer.Toggle(IsCurrentFileProgress);
                }
                if (Config.Instance.FileExplorerAutoHideOnNonProgressFile)
                {
                    FileExplorer.Toggle(IsCurrentFileProgress);
                }
            }
            else
            {
                // make sure to use the ProEnvironment and colorize the error counter
                FilesInfo.UpdateFileStatus();
                ProEnvironment.Current.ReComputeProPath();
            }

            if (IsCurrentFileProgress)
            {
                // Need to compute the propath again, because we take into account relative path
                ProEnvironment.Current.ReComputeProPath();

                // rebuild lines info (MANDATORY)
                Npp.RebuildLinesInfo();
            }

            // Parse the document
            ParserHandler.ParseCurrentDocument(true);

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