Beispiel #1
0
 /// <summary>
 /// Changing syntax theme
 /// </summary>
 private void CbSyntaxSelectedIndexChanged(object sender, EventArgs eventArgs)
 {
     Style.Current = Style.GetThemesList[cbSyntax.SelectedIndex];
     Config.Instance.SyntaxHighlightThemeId = cbSyntax.SelectedIndex;
     if (Plug.IsCurrentFileProgress)
     {
         Style.SetSyntaxStyles();
         Plug.ApplyOptionsForScintilla();
         FilesInfo.UpdateFileStatus();
     }
 }
Beispiel #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.CurrentFile.Path))
            {
                _openedFileList.Add(Npp.CurrentFile.Path);

                // need to auto change encoding?
                if (Config.Instance.AutoSwitchEncodingTo != NppEncodingFormat._Automatic_default && !string.IsNullOrEmpty(Config.Instance.AutoSwitchEncodingForFilePatterns))
                {
                    if (Npp.CurrentFile.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.PreviousFile.Path))
            {
                if (Sci.ViewWhitespace != WhitespaceMode.Invisible && !Sci.ViewEol)
                {
                    Sci.ViewWhitespace = _whitespaceMode;
                }
            }
            if (ShareExportConf.IsFileExportedConf(Npp.CurrentFile.Path))
            {
                Sci.ViewWhitespace = WhitespaceMode.VisibleAlways;
            }

            // close popups..
            ClosePopups();

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

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

            AutoCompletion.SetStaticItems();

            // Parse the document
            ParserHandler.ParseDocumentNow();

            // publish the event
            if (OnDocumentChangedEnd != null)
            {
                OnDocumentChangedEnd();
            }
        }
Beispiel #3
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();
            }
        }