コード例 #1
0
        //public void TryHideLayer()
        //{
        //this.layer.RemoveAdornmentsByTag(this.layerTag);
        //}

        private void Selection_SelectionChanged(object sender, EventArgs e)
        {
            ITextSelection textSection = sender as ITextSelection;
            this.wpfTextView = textSection.TextView as IWpfTextView;
            var keyProcessor = TextViewHelper.TryGetPropertie<FindInSolutionKeyProcessor>(this.wpfTextView);
            if (keyProcessor.IsEnable)
            {
                ITextStructureNavigator textStructureNavigator = textStructureNavigatorSelector.GetTextStructureNavigator(wpfTextView.TextBuffer);
                var pos = this.wpfTextView.Selection.ActivePoint.Position;
                var line = wpfTextView.TextViewLines.GetTextViewLineContainingBufferPosition(pos);
                TextExtent word = textStructureNavigator.GetExtentOfWord(pos);
                string searchPattern = string.Format("\".*?{0}.*?(\\.js|\\.css)\"", word.Span.GetText());
                FindData findData = new FindData(searchPattern, word.Span.Snapshot);
                findData.FindOptions = FindOptions.UseRegularExpressions;
                var result = textSearchService.FindNext(line.Start.Position, false, findData);
                if (result != null)
                {
                    string fullName = result.Value.GetText().Trim('"');
                    var pro = VSIHelper.DTE2.Solution.FindProjectItem(fullName.GetFileName());
                    if (pro != null)
                    {
                        
                        if (!pro.IsOpen) pro.Open();
                        
                        pro.ExpandView();
                        pro.Document.Activate();
                    }

                    //FindInSolution fs = new FindInSolution();
                    //fs.txtFileName.Text = fullName;
                    //Canvas.SetTop(fs, line.Top + line.Height);
                    //Canvas.SetLeft(fs, pos.Position - line.Start.Position);
                    //this.TryShowLayer(word.Span, this.layerTag, fs);
                }
                else
                {
                    //TryHideLayer();
                }
            }
            else
            {
                //TryHideLayer();
            }
        }
コード例 #2
0
ファイル: SearchServiceTest.cs プロジェクト: rride/VsVim
 private void AssertFindNext(
     SearchData data,
     string searchText,
     FindOptions options)
 {
     var isWrap = SearchKindUtil.IsWrap(data.Kind);
     var snapshot = MockObjectFactory.CreateTextSnapshot(10);
     var nav = _factory.Create<ITextStructureNavigator>();
     var findData = new FindData(searchText, snapshot.Object, options, nav.Object);
     _textSearch
         .Setup(x => x.FindNext(2, isWrap, findData))
         .Returns<SnapshotSpan?>(null)
         .Verifiable();
     _search.FindNext(data, new SnapshotPoint(snapshot.Object, 2), nav.Object);
     _factory.Verify();
 }
コード例 #3
0
ファイル: SearchServiceTest.cs プロジェクト: rride/VsVim
 public void FindNextMulitple5()
 {
     var tss = MockObjectFactory.CreateTextSnapshot(42).Object;
     var nav = _factory.Create<ITextStructureNavigator>();
     var data = new FindData("foo", tss, FindOptions.UseRegularExpressions | FindOptions.MatchCase, nav.Object);
     _textSearch
         .Setup(x => x.FindNext(10, true, data))
         .Returns(new SnapshotSpan(tss, 0, 3))
         .Verifiable();
     _textSearch
         .Setup(x => x.FindNext(3, true, data))
         .Returns(new SnapshotSpan(tss, 10, 3))
         .Verifiable();
     var searchData = new SearchData(SearchText.NewPattern("foo"), SearchKind.ForwardWithWrap, SearchOptions.None);
     var ret = _search.FindNextMultiple(searchData, new SnapshotPoint(tss, 10), nav.Object, 2);
     Assert.IsTrue(ret.IsSome());
     Assert.AreEqual(new SnapshotSpan(tss, 10, 3), ret.Value);
     _factory.Verify();
 }
コード例 #4
0
ファイル: TextSearchService.cs プロジェクト: 0xd4d/dnSpy
		public SnapshotSpan? FindNext(int startIndex, bool wraparound, FindData findData) {
			if (findData.TextSnapshotToSearch == null)
				throw new ArgumentException();
			if ((uint)startIndex > (uint)findData.TextSnapshotToSearch.Length)
				throw new ArgumentOutOfRangeException(nameof(startIndex));

			var searchRange = new SnapshotSpan(findData.TextSnapshotToSearch, 0, findData.TextSnapshotToSearch.Length);
			var startingPosition = new SnapshotPoint(findData.TextSnapshotToSearch, startIndex);
			var options = findData.FindOptions;
			if (wraparound)
				options |= FindOptions.Wrap;

			bool wholeWords = (findData.FindOptions & FindOptions.WholeWord) != 0;
			ITextStructureNavigator textStructureNavigator = null;
			if (wholeWords) {
				textStructureNavigator = textStructureNavigatorSelectorService.GetTextStructureNavigator(findData.TextSnapshotToSearch.TextBuffer);
				options &= ~FindOptions.WholeWord;
			}
			foreach (var res in FindAllCore(searchRange, startingPosition, findData.SearchString, options, null)) {
				if (!wholeWords || IsWholeWord(textStructureNavigator, findData.TextSnapshotToSearch, res))
					return new SnapshotSpan(findData.TextSnapshotToSearch, res.Position, res.Length);
			}

			return null;
		}
コード例 #5
0
ファイル: TextSearchService.cs プロジェクト: 0xd4d/dnSpy
		public Collection<SnapshotSpan> FindAll(FindData findData) {
			if (findData.TextSnapshotToSearch == null)
				throw new ArgumentException();

			var searchRange = new SnapshotSpan(findData.TextSnapshotToSearch, 0, findData.TextSnapshotToSearch.Length);
			var startingPosition = new SnapshotPoint(findData.TextSnapshotToSearch, 0);
			var options = findData.FindOptions;
			var coll = new Collection<SnapshotSpan>();

			bool wholeWords = (findData.FindOptions & FindOptions.WholeWord) != 0;
			ITextStructureNavigator textStructureNavigator = null;
			if (wholeWords) {
				textStructureNavigator = textStructureNavigatorSelectorService.GetTextStructureNavigator(findData.TextSnapshotToSearch.TextBuffer);
				options &= ~FindOptions.WholeWord;
			}
			foreach (var res in FindAllCore(searchRange, startingPosition, findData.SearchString, options, null)) {
				if (!wholeWords || IsWholeWord(textStructureNavigator, findData.TextSnapshotToSearch, res))
					coll.Add(new SnapshotSpan(findData.TextSnapshotToSearch, res.Position, res.Length));
			}

			return coll;
		}
コード例 #6
0
ファイル: NativeMethods.cs プロジェクト: zr40/steamdisksaver
 internal static extern bool FindNextFile(FindFilesHandle findFileHandle, out FindData findFileData);
コード例 #7
0
ファイル: NativeMethods.cs プロジェクト: zr40/steamdisksaver
 internal static extern FindFilesHandle FindFirstFile(string fileName, out FindData findFileData);
コード例 #8
0
ファイル: WebControl.cs プロジェクト: UIKit0/AwesomiumSharp
 /// <summary>
 /// Stops the last active search (started with <see cref="WebControl.Find"/>).
 /// </summary>
 /// <remarks>
 /// This will un-highlight all matches of a previous call to <see cref="WebControl.Find"/>.
 /// </remarks>
 /// <param name="clearSelection">
 /// True to also deselect the currently selected string. False otherwise.
 /// </param>
 /// <exception cref="InvalidOperationException">
 /// The member is called on an invalid <see cref="WebControl"/> instance
 /// (see <see cref="UIElement.IsEnabled"/>).
 /// </exception>
 public void StopFind( bool clearSelection )
 {
     VerifyLive();
     awe_webview_stop_find( Instance, clearSelection );
     findRequest = null;
 }
コード例 #9
0
ファイル: WebControl.cs プロジェクト: UIKit0/AwesomiumSharp
        /// <summary>
        /// Start finding a certain string on the current web-page.
        /// </summary>
        /// <remarks>
        /// All matches of the string will be highlighted on the page and you can jump to different 
        /// instances of the string by using the <see cref="FindNext"/> method.
        /// To get actual stats about a certain query, please see <see cref="FindResultsReceived"/>.
        /// </remarks>
        /// <param name="searchStr">
        /// The string to search for.
        /// </param>
        /// <param name="forward">
        /// True to search forward, down the page. False otherwise. The default is true.
        /// </param>
        /// <param name="caseSensitive">
        /// True to perform a case sensitive search. False otherwise. The default is false.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// The member is called on an invalid <see cref="WebControl"/> instance
        /// (see <see cref="UIElement.IsEnabled"/>).
        /// </exception>
        public void Find( string searchStr, bool forward = true, bool caseSensitive = false )
        {
            VerifyLive();

            if ( findRequest != null )
            {
                StopFind( true );
            }

            findRequest = new FindData( findRequestRandomizer.Next(), searchStr, caseSensitive );
            StringHelper searchCStr = new StringHelper( searchStr );
            awe_webview_find( Instance, findRequest.RequestID, searchCStr.Value, forward, caseSensitive, false );
        }
コード例 #10
0
ファイル: FileSystemEnumerator.cs プロジェクト: WELL-E/Wox
		/// <summary>
		///   Get an enumerator that returns all of the files that match the wildcards that
		///   are in any of the directories to be searched.
		/// </summary>
		/// <returns> An IEnumerable that returns all matching files one by one. </returns>
		/// <remarks>
		///   The enumerator that is returned finds files using a lazy algorithm that
		///   searches directories incrementally as matches are consumed.
		/// </remarks>
		public IEnumerable<FileInfo> Matches()
		{
			foreach (string rootPath in m_paths) {
				string path = rootPath.Trim();

				// we "recurse" into a new directory by jumping to this spot
				top:

				// check security - ensure that caller has rights to read this directory
				new FileIOPermission(FileIOPermissionAccess.PathDiscovery, Path.Combine(path, ".")).Demand();

				// now that security is checked, go read the directory
				FindData findData = new FindData();
				SafeFindHandle handle = SafeNativeMethods.FindFirstFile(Path.Combine(path, "*"), findData);
				m_scopes.Push(new SearchInfo(handle, path));
				bool restart = false;

				// we "return" from a sub-directory by jumping to this spot
				restart:
// ReSharper disable InvertIf
				if (!handle.IsInvalid) {
// ReSharper restore InvertIf
					do {
						// if we restarted the loop (unwound a recursion), fetch the next match
						if (restart) {
							restart = false;
							continue;
						}

						// don't match . or ..
						if (findData.fileName.Equals(@".") || findData.fileName.Equals(@"..")) continue;

						if ((findData.fileAttributes & (int)FileAttributes.Directory) != 0) {
							if (m_includeSubDirs) {
								// it's a directory - recurse into it
								path = Path.Combine(path, findData.fileName);
								goto top;
							}
						} else {
							// it's a file, see if any of the filespecs matches it
							foreach (Regex fileSpec in m_fileSpecs) {
								// if this spec matches, return this file's info
								if (fileSpec.IsMatch(findData.fileName)) yield return new FileInfo(Path.Combine(path, findData.fileName));
							}
						}
					} while (SafeNativeMethods.FindNextFile(handle, findData));

					// close this find handle
					handle.Close();

					// unwind the stack - are we still in a recursion?
					m_scopes.Pop();
					if (m_scopes.Count > 0) {
						SearchInfo si = m_scopes.Peek();
						handle = si.Handle;
						path = si.Path;
						restart = true;
						goto restart;
					}
				}
			}
		}
コード例 #11
0
ファイル: DiffView.cs プロジェクト: necora/ank_git
        public bool FindPrevious(FindData Data)
        {
            if (Data.Text.Length == 0)
            {
                Data.SearchUp = true;
                return Find(Data);
            }
            else
            {
                int iNumLines = LineCount;
                if (iNumLines > 0)
                {
                    string strText = Data.Text;
                    if (!Data.MatchCase)
                    {
                        strText = strText.ToUpper();
                    }

                    int iStartLine = m_Position.Line;
                    int iStartColumn = m_Position.Column;
                    for (int i = 0; i <= iNumLines; i++) // <= so we check the start line again from the end
                    {
                        //Use % so we wrap around at the end.
                        int iLine = (iStartLine - i + iNumLines) % iNumLines;
                        string strLine = GetLineText(iLine);

                        if (!Data.MatchCase)
                        {
                            strLine = strLine.ToUpper();
                        }

                        if (iStartColumn == -1)
                        {
                            iStartColumn = Math.Max(0, strLine.Length - 1);
                        }

                        int iIndex;
                        if (i == iNumLines) //We're rechecking the start line from the end.
                            iIndex = strLine.LastIndexOf(strText, iStartColumn, iStartColumn - m_Position.Column);
                        else
                            iIndex = strLine.LastIndexOf(strText, iStartColumn);
                        if (iIndex >= 0)
                        {
                            int iLength = strText.Length;
                            SetPosition(iLine, iIndex + iLength);
                            ExtendSelection(0, -iLength);
                            return true;
                        }

                        //On all lines but the first, we need to start at the end
                        iStartColumn = -1;
                    }
                }

                string strMsg = String.Format("'{0}' was not found.", Data.Text);
                MessageBox.Show(this, strMsg, "Find", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return false;
            }
        }
コード例 #12
0
ファイル: DiffView.cs プロジェクト: necora/ank_git
        public bool Find(FindData Data)
        {
            FindDlg Dlg = new FindDlg();

            //If text is selected on a single line, then use that for the new Find text.
            string strOriginalFindText = Data.Text;
            string strSelectedText;
            if (GetSingleLineSelectedText(out strSelectedText))
            {
                Data.Text = strSelectedText;
            }

            if (Dlg.Execute(this, Data))
            {
                if (Data.SearchUp)
                    return FindPrevious(Data);
                else
                    return FindNext(Data);
            }
            else
            {
                //Reset the Find text if the user cancelled.
                Data.Text = strOriginalFindText;
            }

            return false;
        }
コード例 #13
0
ファイル: HkDvr.cs プロジェクト: Strongc/sencond
        // 获取文件信息
        public void FindDvrFiles(int findHandle)
        {
            HCNetSDK.NET_DVR_FINDDATA_V30 fileData = new HCNetSDK.NET_DVR_FINDDATA_V30();

               fileData.struStartTime = new HCNetSDK.NET_DVR_TIME();
               fileData.struStopTime = new HCNetSDK.NET_DVR_TIME();
               fileData.byLocked = 0xFF;
               fileData.byRes = new byte[3];
               fileData.sFileName = "";//Encoding.ASCII.GetString(new byte[100]);
               fileData.dwFileSize = 0;
               fileData.sCardNum = ""; //Encoding.ASCII.GetString(new byte[32]);
               //fileData.
               int ret = -1;
               while (true)
               {
               ret = HCNetSDK.NET_DVR_FindNextFile_V30(findHandle, ref fileData);
               switch (ret)
               {
                   case HCNetSDK.NET_DVR_FILE_SUCCESS:
                       FindData data = new FindData();
                       data.StartTime = DvrTimeToDataTime(fileData.struStartTime);
                       data.StopTime = DvrTimeToDataTime(fileData.struStopTime);
                       data.FileName = fileData.sFileName;
                       data.FileSize = fileData.dwFileSize;
                       data.Locked   =  Convert.ToBoolean(fileData.byLocked);
                       _find_files.Add(data);
                       continue;
                   case HCNetSDK.NET_DVR_ISFINDING:
                       Thread.Sleep(1000);
                       continue;
                   case HCNetSDK.NET_DVR_FILE_NOFIND:
                   case HCNetSDK.NET_DVR_NOMOREFILE:
                       break;
                   case HCNetSDK.NET_DVR_FILE_EXCEPTION:
                       break;
                   default:
                       break;
               }
               break;
               }
               FindClose();
        }
コード例 #14
0
ファイル: Searcher.cs プロジェクト: xyandro/NeoEdit
		public Searcher(List<Tuple<Byte[], bool>> data)
		{
			var matchCaseFindData = new FindData((Byte[])null, true);
			var ignoreCaseFindData = new FindData((Byte[])null, false);
			for (var ctr = 0; ctr < data.Count; ++ctr)
			{
				var node = data[ctr].Item2 ? matchCaseFindData : ignoreCaseFindData;
				node.Add(data[ctr].Item1);
				MaxLen = Math.Max(MaxLen, data[ctr].Item1.Length);
			}

			var maxChars = Math.Max(matchCaseFindData.NumChars, ignoreCaseFindData.NumChars);

			matchCaseSearcher = new SearchData(matchCaseFindData, maxChars);
			ignoreCaseSearcher = new SearchData(ignoreCaseFindData, maxChars);

			for (var ctr = 0; ctr < data.Count; ++ctr)
			{
				var node = data[ctr].Item2 ? matchCaseSearcher : ignoreCaseSearcher;
				node.Add(data[ctr].Item1);
			}
		}
コード例 #15
0
ファイル: Searcher.cs プロジェクト: xyandro/NeoEdit
			public SearchData(FindData findData, int maxChars)
			{
				data = new SearchData[maxChars];
				this.findData = findData;
				this.maxChars = maxChars;
			}