public ProvidedDocumentInformation(IDocument document, string fileName, int currentOffset) { this.document = document; this.textBuffer = document.TextBufferStrategy; this.fileName = fileName; this.endOffset = this.currentOffset = currentOffset; }
/// <summary> /// Creates a new document and loads the given file /// </summary> public IDocument CreateFromTextBuffer(ITextBufferStrategy textBuffer) { DefaultDocument doc = (DefaultDocument)CreateDocument(); doc.TextContent = textBuffer.GetText(0, textBuffer.Length); doc.TextBufferStrategy = textBuffer; return doc; }
public ProvidedDocumentInformation(IDocument document, string fileName) { this.document = document; this.textBuffer = document.TextBufferStrategy; this.fileName = fileName; // this.currentOffset = document.Caret.Offset; }
public IDocument CreateFromTextBuffer(ITextBufferStrategy textBuffer) { DefaultDocument text = (DefaultDocument)this.CreateDocument(); text.TextContent = textBuffer.GetText(0, textBuffer.Length); text.TextBufferStrategy = textBuffer; return(text); }
/// <summary> /// Creates a new document and loads the given file. /// </summary> /// <param name="textBuffer">The text buffer.</param> /// <returns>The document.</returns> public IDocument CreateFromTextBuffer(ITextBufferStrategy textBuffer) { DefaultDocument doc = (DefaultDocument)CreateDocument(); doc.TextContent = textBuffer.GetText(0, textBuffer.Length); doc.TextBufferStrategy = textBuffer; return(doc); }
public ProvidedDocumentInformation(IDocument document, string fileName, TextAreaControl textAreaControl) { this.document = document; this.textBuffer = document.TextBufferStrategy; this.fileName = fileName; this.textAreaControl = textAreaControl; this.endOffset = this.CurrentOffset; }
public ForwardTextIterator(ITextBufferStrategy textBuffer, int endOffset) { Debug.Assert(textBuffer != null); Debug.Assert(endOffset >= 0 && endOffset < textBuffer.Length); this.textBuffer = textBuffer; this.endOffset = endOffset; Reset(); }
bool MatchCaseInsensitive(ITextBufferStrategy document, int offset, string pattern) { for (int i = 0; i < pattern.Length; ++i) { if (offset + i >= document.Length || Char.ToUpper(document.GetCharAt(offset + i)) != pattern[i]) { return false; } } return true; }
public SearchReplace(EditSetBase editSet) { this.editSet = editSet; editor = editSet.editor; area = editor.ActiveTextAreaControl.TextArea; caret = editor.ActiveTextAreaControl.Caret; buffer = editor.Document.TextBufferStrategy; view = area.TextView; document = editor.Document; }
public ForwardTextIterator(ProvidedDocumentInformation info) { Debug.Assert(info != null); this.info = info; this.textBuffer = info.TextBuffer; this.position = info.CurrentOffset; this.endOffset = info.EndOffset; Reset(); }
bool MatchCaseInsensitive(ITextBufferStrategy document, int offset, string pattern) { for (int i = 0; i < pattern.Length; ++i) { if (offset + i >= document.Length || Char.ToUpper(document.GetCharAt(offset + i)) != pattern[i]) { return(false); } } return(true); }
public ForwardTextIterator(ProvidedDocumentInformation info) { if (info == null) throw new ArgumentNullException("info"); this.info = info; this.textBuffer = info.TextBuffer; this.position = info.CurrentOffset; this.endOffset = info.EndOffset; Reset(); }
bool Match(ITextBufferStrategy document, int offset, bool ignoreCase, int programStart) { int curOffset = offset; curMatchEndOffset = -1; for (int pc = programStart; pc < patternProgram.Count; ++pc) { if (curOffset >= document.Length) { return false; } char ch = ignoreCase ? Char.ToUpper(document.GetCharAt(curOffset)) : document.GetCharAt(curOffset); Command cmd = (Command)patternProgram[pc]; switch (cmd.CommandType) { case CommandType.Match: if (ch != cmd.SingleChar) { return false; } break; case CommandType.AnyZeroOrMore: if (ch == '\n') { return false; } return Match(document, curOffset, ignoreCase, pc + 1) || Match(document, curOffset + 1, ignoreCase, pc); case CommandType.AnySingle: break; case CommandType.AnyDigit: if (!Char.IsDigit(ch) && ch != '#') { return false; } break; case CommandType.AnyInList: if (cmd.CharList.IndexOf(ch) < 0) { return false; } break; case CommandType.NoneInList: if (cmd.CharList.IndexOf(ch) >= 0) { return false; } break; } ++curOffset; } curMatchEndOffset = curOffset; return true; }
public ForwardTextIterator(ProvidedDocumentInformation info) { if (info == null) { throw new ArgumentNullException("info"); } this.info = info; this.textBuffer = info.TextBuffer; this.position = info.CurrentOffset; this.endOffset = info.EndOffset; Reset(); }
public static ProvidedDocumentInformation GetDocumentInformation(string fileName) { foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) { if (content is ITextEditorControlProvider && FileUtility.IsEqualFileName(content.IsUntitled ? content.UntitledName : content.FileName, fileName)) { return(new ProvidedDocumentInformation(((ITextEditorControlProvider)content).TextEditorControl.Document, fileName, 0)); } } ITextBufferStrategy strategy = StringTextBufferStrategy.CreateTextBufferFromFile(fileName); return(new ProvidedDocumentInformation(strategy, fileName, 0)); }
public static ProvidedDocumentInformation GetDocumentInformation(string fileName) { OpenedFile file = FileService.GetOpenedFile(fileName); if (file != null) { IFileDocumentProvider documentProvider = file.CurrentView as IFileDocumentProvider; if (documentProvider != null) { IDocument document = documentProvider.GetDocumentForFile(file); if (document != null) { return(new ProvidedDocumentInformation(document, fileName, 0)); } } } ITextBufferStrategy strategy = StringTextBufferStrategy.CreateTextBufferFromFile(fileName); return(new ProvidedDocumentInformation(strategy, fileName, 0)); }
public void MarkSearchString(EditorSearchOption option, ITextBufferStrategy buffer) { int offset = 0; EditorSearchResult result = null; while (true) { result = util.TextUtil.SearchNext(option, offset, buffer); if (result == null || result.IsHit == false) { //ループを抜ける break; } this.Document.MarkerStrategy.AddMarker(new TextMarker(result.Offset, result.Length, TextMarkerType.SolidBlock, Color.Red)); offset = result.Offset + result.Length; } //更新 this.Refresh(); }
/// <summary> /// 検索にヒットするかどうかチェックする /// </summary> /// <param name="buff">検索される文字列</param> /// <param name="offset">現在のカーソル位置</param> /// <param name="pattern">検索する文字列</param> /// <param name="ignoreCase">大文字小文字を区別するかどうか</param> /// <returns>ヒットしたときtrue</returns> private static bool matchCaseString(ITextBufferStrategy buff, int offset, string pattern, bool ignoreCase) { char c; for (int i = 0; i < pattern.Length; ++i) { if (ignoreCase) { c = buff.GetCharAt(offset + i); } else { c = Char.ToUpper(buff.GetCharAt(offset + i)); } if (offset + i >= buff.Length || c != pattern[i]) { return(false); } } return(true); }
public void JustDecompileGenerated_set_TextBufferStrategy(ITextBufferStrategy value) { this.textBufferStrategy = value; }
public ProvidedDocumentInformation(ITextBufferStrategy textBuffer, string fileName, int currentOffset) { this.textBuffer = textBuffer; this.fileName = fileName; this.endOffset = this.currentOffset = currentOffset; }
bool IsWholeWordAt(ITextBufferStrategy document, int offset, int length) { return((offset - 1 < 0 || !Char.IsLetterOrDigit(document.GetCharAt(offset - 1))) && (offset + length + 1 >= document.Length || !Char.IsLetterOrDigit(document.GetCharAt(offset + length)))); }
/// <summary> /// 指定したオフセット位置の物が単語かどうかチェックする /// 単語の時はtrueを返す /// </summary> /// <param name="buff">検索される文字列</param> /// <param name="offset">カーソル位置</param> /// <param name="length">検索する文字列の長さ</param> /// <returns>単語の時はtrue</returns> private static bool isSearchWholeWordAt(ITextBufferStrategy buff, int offset, int length) { return((offset - 1 < 0 || !Char.IsLetterOrDigit(buff.GetCharAt(offset - 1))) && (offset + length + 1 >= buff.Length || !Char.IsLetterOrDigit(buff.GetCharAt(offset + length)))); }
/// <summary> /// 正規表現検索を行い、ヒットした位置を返す /// </summary> /// <param name="option"></param> /// <returns></returns> private static EditorSearchResult getSearchPosRegex(EditorSearchOption option, int offset, ITextBufferStrategy buffer) { EditorSearchResult result = new EditorSearchResult(); Regex regex = new Regex(option.SearchKeyword, getSearchRegexOptions(option)); Match match = regex.Match(buffer.GetText(0, buffer.Length), offset); while (match.Success) { if (option.WordUnit == false || isSearchWholeWordAt(buffer, match.Index, match.Value.Length)) { result.Offset = match.Index; result.Length = match.Value.Length; break; } match = match.NextMatch(); } return(result); }
bool Match(ITextBufferStrategy document, int offset, bool ignoreCase, int programStart) { int curOffset = offset; curMatchEndOffset = -1; for (int pc = programStart; pc < patternProgram.Count; ++pc) { if (curOffset >= document.Length) { return(false); } char ch = ignoreCase ? Char.ToUpper(document.GetCharAt(curOffset)) : document.GetCharAt(curOffset); Command cmd = (Command)patternProgram[pc]; switch (cmd.CommandType) { case CommandType.Match: if (ch != cmd.SingleChar) { return(false); } break; case CommandType.AnyZeroOrMore: if (ch == '\n') { return(false); } return(Match(document, curOffset, ignoreCase, pc + 1) || Match(document, curOffset + 1, ignoreCase, pc)); case CommandType.AnySingle: break; case CommandType.AnyDigit: if (!Char.IsDigit(ch) && ch != '#') { return(false); } break; case CommandType.AnyInList: if (cmd.CharList.IndexOf(ch) < 0) { return(false); } break; case CommandType.NoneInList: if (cmd.CharList.IndexOf(ch) >= 0) { return(false); } break; } ++curOffset; } curMatchEndOffset = curOffset; return(true); }
public static bool IsWholeWordAt(ITextBufferStrategy document, int offset, int length) { return (offset - 1 < 0 || Char.IsWhiteSpace(document.GetCharAt(offset - 1))) && (offset + length + 1 >= document.Length || Char.IsWhiteSpace(document.GetCharAt(offset + length))); }
/// <summary> /// 文字列検索を行いヒットした位置を返す /// </summary> /// <param name="option">検索オプション</param> /// <returns>ヒットした位置</returns> private static EditorSearchResult getSearchPosString(EditorSearchOption option, int offset, ITextBufferStrategy buffer) { EditorSearchResult result = new EditorSearchResult(); offset = getFirstSearchOffset(offset, option); //検索キーワードの設定 string keyword; if (option.IgnoreCase) { keyword = option.SearchKeyword; } else { keyword = option.SearchKeyword.ToUpper(); } //一つづつオフセットをずらしていきヒットするまで続ける while ((offset = getNextSearchOffset(offset, buffer.Length, option)) != -1) { if (matchCaseString(buffer, offset, keyword, option.IgnoreCase)) { if (option.WordUnit == false || isSearchWholeWordAt(buffer, offset, keyword.Length)) { result.Offset = offset; break; } } } if (offset == -1) { //ヒットしなかったとき result.Offset = -1; } result.Length = option.SearchKeyword.Length; return(result); }
public static bool IsWholeWordAt(ITextBufferStrategy document, int offset, int length) { return((offset - 1 < 0 || Char.IsWhiteSpace(document.GetCharAt(offset - 1))) && (offset + length + 1 >= document.Length || Char.IsWhiteSpace(document.GetCharAt(offset + length)))); }
bool IsWholeWordAt(ITextBufferStrategy document, int offset, int length) { return (offset - 1 < 0 || !Char.IsLetterOrDigit(document.GetCharAt(offset - 1))) && (offset + length + 1 >= document.Length || !Char.IsLetterOrDigit(document.GetCharAt(offset + length))); }
/// <summary> /// 次を検索し見つかったときは位置を返す /// </summary> /// <param name="option">検索オプション</param> /// <param name="startOffset">検索開始位置</param> /// <param name="buffer">検索する文字列バッファ</param> /// <returns>見つかった位置</returns> public static EditorSearchResult SearchNext(EditorSearchOption option, int startOffset, ITextBufferStrategy buffer) { EditorSearchResult result = null; if (option.Regex) { //正規表現で検索 result = getSearchPosRegex(option, startOffset, buffer); } else { //通常の文字列として検索 result = getSearchPosString(option, startOffset, buffer); } return(result); }