コード例 #1
0
ファイル: TextEditors.cs プロジェクト: sahwar/astrogrep-1
        /// <summary>
        /// Edit file from given MatchResult at first match if available.
        /// </summary>
        /// <param name="match">Current MatchResult</param>
        /// <history>
        /// [Curtis_Beard]	   05/27/2015	FIX: 73, open text editor even when no first match (usually during file only search)
        /// </history>
        public static void EditFile(libAstroGrep.MatchResult match)
        {
            if (match != null)
            {
                // open the default editor at first match
                var lineNumber   = 1;
                var columnNumber = 1;
                var lineText     = string.Empty;

                var matchLine = match.GetFirstMatch();
                if (matchLine != null)
                {
                    lineNumber   = matchLine.LineNumber;
                    columnNumber = matchLine.ColumnNumber;
                    lineText     = matchLine.Line;
                }

                EditFile(match.File.FullName, lineNumber, columnNumber, lineText);
            }
        }
コード例 #2
0
ファイル: TextEditorOpener.cs プロジェクト: sahwar/AstroGrep
        /// <summary>
        /// Create a TextEditorOpener from a MatchResult object.
        /// </summary>
        /// <param name="match">Current match result object</param>
        /// <param name="searchText">Current search text</param>
        /// <returns>TextEditorOpener object</returns>
        /// <history>
        /// [Curtis_Beard]	   05/27/2015	FIX: 73, open text editor even when no first match (usually during file only search)
        /// [Curtis_Beard]	   08/16/2016	CHG: move to TextEditorOpener class
        /// </history>
        public static TextEditorOpener FromMatch(libAstroGrep.MatchResult match, string searchText)
        {
            var opener = new TextEditorOpener();

            if (match != null)
            {
                // open the default editor at first match
                var lineNumber   = 1;
                var columnNumber = 1;
                var lineText     = string.Empty;

                var matchLine = match.GetFirstMatch();
                if (matchLine != null)
                {
                    lineNumber   = matchLine.LineNumber;
                    columnNumber = matchLine.ColumnNumber;
                    lineText     = matchLine.Line;
                }

                opener = new TextEditorOpener(match.File.FullName, lineNumber, columnNumber, lineText, searchText);
            }

            return(opener);
        }