本文整理汇总了C#中ICSharpCode.TextEditor.Document.LineSegment类的典型用法代码示例。如果您正苦于以下问题:C# LineSegment类的具体用法?C# LineSegment怎么用?C# LineSegment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LineSegment类属于ICSharpCode.TextEditor.Document命名空间,在下文中一共展示了LineSegment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BookmarkDocumentChanged
void BookmarkDocumentChanged(object sender, EventArgs e)
{
if (bookmark.Document != null) {
line = bookmark.Document.GetLineSegment(Math.Min(bookmark.LineNumber, bookmark.Document.TotalNumberOfLines));
Text = positionText + bookmark.Document.GetText(line);
}
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:7,代码来源:BookmarkNode.cs
示例2: DrawableLine
public DrawableLine(IDocument document, LineSegment line, Font monospacedFont, Font boldMonospacedFont)
{
this.monospacedFont = monospacedFont;
this.boldMonospacedFont = boldMonospacedFont;
if (line.Words != null)
{
foreach (TextWord word in line.Words)
{
if (word.Type == TextWordType.Space)
{
words.Add(SimpleTextWord.Space);
}
else if (word.Type == TextWordType.Tab)
{
words.Add(SimpleTextWord.Tab);
}
else
{
words.Add(new SimpleTextWord(TextWordType.Word, word.Word, word.Bold, word.Color));
}
}
}
else
{
words.Add(new SimpleTextWord(TextWordType.Word, document.GetText(line), false, Color.Black));
}
}
开发者ID:KindDragon,项目名称:ICSharpCode.TextEditor.V4,代码行数:27,代码来源:DrawableLine.cs
示例3: IsInMultilineCommentOrStringLiteral
static bool IsInMultilineCommentOrStringLiteral(LineSegment line)
{
if (line.HighlightSpanStack == null || line.HighlightSpanStack.IsEmpty) {
return false;
}
return !line.HighlightSpanStack.Peek().StopEOL;
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:7,代码来源:CSharpAdvancedHighlighter.cs
示例4: TryHighlightAddedAndDeletedLines
protected override int TryHighlightAddedAndDeletedLines(IDocument document, int line, LineSegment lineSegment)
{
ProcessLineSegment(document, ref line, lineSegment, "++", AppSettings.DiffAddedColor);
ProcessLineSegment(document, ref line, lineSegment, "+ ", AppSettings.DiffAddedColor);
ProcessLineSegment(document, ref line, lineSegment, " +", AppSettings.DiffAddedColor);
ProcessLineSegment(document, ref line, lineSegment, "--", AppSettings.DiffRemovedColor);
ProcessLineSegment(document, ref line, lineSegment, "- ", AppSettings.DiffRemovedColor);
ProcessLineSegment(document, ref line, lineSegment, " -", AppSettings.DiffRemovedColor);
return line;
}
开发者ID:vbjay,项目名称:gitextensions,代码行数:10,代码来源:CombinedDiffHighlightService.cs
示例5:
/// <summary>
/// Get the object, which was inserted under the keyword (line, at offset, with length length),
/// returns null, if no such keyword was inserted.
/// </summary>
public object this[IDocument document, LineSegment line, int offset, int length]
{
get
{
if(length == 0)
{
return null;
}
Node next = root;
int wordOffset = line.Offset + offset;
if (casesensitive)
{
for (int i = 0; i < length; ++i)
{
int index = ((int)document.GetCharAt(wordOffset + i)) % 256;
next = next[index];
if (next == null)
{
return null;
}
if (next.color != null && TextUtility.RegionMatches(document, wordOffset, length, next.word))
{
return next.color;
}
}
}
else
{
for (int i = 0; i < length; ++i)
{
int index = ((int)Char.ToUpper(document.GetCharAt(wordOffset + i))) % 256;
next = next[index];
if (next == null)
{
return null;
}
if (next.color != null && TextUtility.RegionMatches(document, casesensitive, wordOffset, length, next.word))
{
return next.color;
}
}
}
return null;
}
}
开发者ID:KindDragon,项目名称:ICSharpCode.TextEditor.V4,代码行数:55,代码来源:LookupTable.cs
示例6: MarkWords
protected override void MarkWords(int lineNumber, LineSegment currentLine, List<TextWord> words)
{
if (IsInMultilineCommentOrStringLiteral(currentLine)) {
return;
}
ParseInformation parseInfo = ParserService.GetParseInformation(this.TextEditor.FileName);
if (parseInfo == null) return;
CSharpExpressionFinder finder = new CSharpExpressionFinder(parseInfo);
Func<string, int, ExpressionResult> findExpressionMethod;
IClass callingClass = parseInfo.MostRecentCompilationUnit.GetInnermostClass(lineNumber, 0);
if (callingClass != null) {
if (GetCurrentMember(callingClass, lineNumber, 0) != null) {
findExpressionMethod = finder.FindFullExpressionInMethod;
} else {
findExpressionMethod = finder.FindFullExpressionInTypeDeclaration;
}
} else {
findExpressionMethod = finder.FindFullExpression;
}
string lineText = this.Document.GetText(currentLine.Offset, currentLine.Length);
bool changedLine = false;
// now go through the word list:
foreach (TextWord word in words) {
if (word.IsWhiteSpace) continue;
if (char.IsLetter(lineText[word.Offset]) || lineText[word.Offset] == '_') {
ExpressionResult result = findExpressionMethod(lineText, word.Offset);
if (result.Expression != null) {
// result.Expression
if (ICSharpCode.NRefactory.Parser.CSharp.Keywords.IsNonIdentifierKeyword(result.Expression))
continue;
// convert text editor to DOM coordinates:
resolveCount++;
ResolveResult rr = ParserService.Resolve(result, lineNumber + 1, word.Offset + 1, this.TextEditor.FileName, this.TextEditor.Text);
if (rr is MixedResolveResult || rr is TypeResolveResult) {
changedLine = true;
word.SyntaxColor = this.Document.HighlightingStrategy.GetColorFor("TypeReference");
} else if (rr == null) {
changedLine = true;
word.SyntaxColor = this.Document.HighlightingStrategy.GetColorFor("UnknownEntity");
}
}
}
}
if (markingOutstanding && changedLine) {
this.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, lineNumber));
}
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:50,代码来源:CSharpAdvancedHighlighter.cs
示例7: TextWord
// TAB
public TextWord(IDocument document, LineSegment line, int offset, int length, HighlightColor color, bool hasDefaultColor)
{
if (document == null || line == null || color == null)
throw new Exception();
/*Debug.Assert(document != null);
Debug.Assert(line != null);
Debug.Assert(color != null);
*/
this.document = document;
this.line = line;
this.offset = offset;
this.length = length;
this.color = color;
this.hasDefaultColor = hasDefaultColor;
}
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:16,代码来源:TextWord.cs
示例8: SmartReplaceLine
/// <summary>
/// Replaces the text in a line.
/// If only whitespace at the beginning and end of the line was changed, this method
/// only adjusts the whitespace and doesn't replace the other text.
/// </summary>
public static void SmartReplaceLine(IDocument document, LineSegment line, string newLineText)
{
if (document == null)
throw new ArgumentNullException("document");
if (line == null)
throw new ArgumentNullException("line");
if (newLineText == null)
throw new ArgumentNullException("newLineText");
string newLineTextTrim = newLineText.Trim(whitespaceChars);
string oldLineText = document.GetText(line);
if (oldLineText == newLineText)
return;
int pos = oldLineText.IndexOf(newLineTextTrim);
if (newLineTextTrim.Length > 0 && pos >= 0)
{
document.UndoStack.StartUndoGroup();
try
{
// find whitespace at beginning
int startWhitespaceLength = 0;
while (startWhitespaceLength < newLineText.Length)
{
char c = newLineText[startWhitespaceLength];
if (c != ' ' && c != '\t')
break;
startWhitespaceLength++;
}
// find whitespace at end
int endWhitespaceLength = newLineText.Length - newLineTextTrim.Length - startWhitespaceLength;
// replace whitespace sections
int lineOffset = line.Offset;
document.Replace(lineOffset + pos + newLineTextTrim.Length, line.Length - pos - newLineTextTrim.Length, newLineText.Substring(newLineText.Length - endWhitespaceLength));
document.Replace(lineOffset, pos, newLineText.Substring(0, startWhitespaceLength));
}
finally
{
document.UndoStack.EndUndoGroup();
}
}
else
{
document.Replace(line.Offset, line.Length, newLineText);
}
}
开发者ID:KindDragon,项目名称:ICSharpCode.TextEditor.V4,代码行数:50,代码来源:DefaultFormattingStrategy.cs
示例9: MarkTokens
public void MarkTokens(IDocument document)
{
if (Rules.Count == 0) {
return;
}
int lineNumber = 0;
while (lineNumber < document.TotalNumberOfLines) {
LineSegment previousLine = (lineNumber > 0 ? document.GetLineSegment(lineNumber - 1) : null);
if (lineNumber >= document.LineSegmentCollection.Count) { // may be, if the last line ends with a delimiter
break; // then the last line is not in the collection :)
}
currentSpanStack = ((previousLine != null && previousLine.HighlightSpanStack != null) ? new Stack<Span>(previousLine.HighlightSpanStack.ToArray()) : null);
if (currentSpanStack != null) {
while (currentSpanStack.Count > 0 && ((Span)currentSpanStack.Peek()).StopEOL)
{
currentSpanStack.Pop();
}
if (currentSpanStack.Count == 0) currentSpanStack = null;
}
currentLine = (LineSegment)document.LineSegmentCollection[lineNumber];
if (currentLine.Length == -1) { // happens when buffer is empty !
return;
}
List<TextWord> words = ParseLine(document);
// Alex: clear old words
if (currentLine.Words != null) {
currentLine.Words.Clear();
}
currentLine.Words = words;
currentLine.HighlightSpanStack = (currentSpanStack==null || currentSpanStack.Count==0) ? null : currentSpanStack;
++lineNumber;
}
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
document.CommitUpdate();
currentLine = null;
}
开发者ID:viticm,项目名称:pap2,代码行数:44,代码来源:DefaultHighlightingStrategy.cs
示例10: TryDeclarationTypeInference
bool TryDeclarationTypeInference(SharpDevelopTextAreaControl editor, LineSegment curLine)
{
string lineText = editor.Document.GetText(curLine.Offset, curLine.Length);
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.CSharp, new System.IO.StringReader(lineText));
Token typeToken = lexer.NextToken();
if (typeToken.kind == CSTokens.Question) {
if (lexer.NextToken().kind == CSTokens.Identifier) {
Token t = lexer.NextToken();
if (t.kind == CSTokens.Assign) {
string expr = lineText.Substring(t.col);
LoggingService.Debug("DeclarationTypeInference: >" + expr + "<");
ResolveResult rr = ParserService.Resolve(new ExpressionResult(expr),
editor.ActiveTextAreaControl.Caret.Line + 1,
t.col, editor.FileName,
editor.Document.TextContent);
if (rr != null && rr.ResolvedType != null) {
ClassFinder context = new ClassFinder(editor.FileName, editor.ActiveTextAreaControl.Caret.Line, t.col);
if (CodeGenerator.CanUseShortTypeName(rr.ResolvedType, context))
CSharpAmbience.Instance.ConversionFlags = ConversionFlags.None;
else
CSharpAmbience.Instance.ConversionFlags = ConversionFlags.UseFullyQualifiedNames;
string typeName = CSharpAmbience.Instance.Convert(rr.ResolvedType);
editor.Document.Replace(curLine.Offset + typeToken.col - 1, 1, typeName);
editor.ActiveTextAreaControl.Caret.Column += typeName.Length - 1;
return true;
}
}
}
}
return false;
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:31,代码来源:CSharpCompletionBinding.cs
示例11: GetColor
HighlightColor GetColor(HighlightRuleSet ruleSet, IDocument document, LineSegment currentSegment, int currentOffset, int currentLength)
{
if (ruleSet != null) {
if (ruleSet.Reference != null) {
return ruleSet.Highlighter.GetColor(document, currentSegment, currentOffset, currentLength);
} else {
return (HighlightColor)ruleSet.KeyWords[document, currentSegment, currentOffset, currentLength];
}
}
return null;
}
开发者ID:viticm,项目名称:pap2,代码行数:11,代码来源:DefaultHighlightingStrategy.cs
示例12: SetSegmentLength
void SetSegmentLength(LineSegment segment, int newTotalLength)
{
int delta = newTotalLength - segment.TotalLength;
if (delta != 0) {
lineCollection.SetSegmentLength(segment, newTotalLength);
OnLineLengthChanged(new LineLengthChangeEventArgs(document, segment, delta));
}
}
开发者ID:umabiel,项目名称:WsdlUI,代码行数:8,代码来源:LineManager.cs
示例13: GetLogicalColumnInternal
int GetLogicalColumnInternal(Graphics g, LineSegment line, int start, int end, ref int drawingPos, int targetVisualPosX)
{
if (start == end)
return end;
Debug.Assert(start < end);
Debug.Assert(drawingPos < targetVisualPosX);
int tabIndent = Document.TextEditorProperties.TabIndent;
/*float spaceWidth = SpaceWidth;
float drawingPos = 0;
LineSegment currentLine = Document.GetLineSegment(logicalLine);
List<TextWord> words = currentLine.Words;
if (words == null) return 0;
int wordCount = words.Count;
int wordOffset = 0;
FontContainer fontContainer = TextEditorProperties.FontContainer;
*/
FontContainer fontContainer = TextEditorProperties.FontContainer;
List<TextWord> words = line.Words;
if (words == null) return 0;
int wordOffset = 0;
for (int i = 0; i < words.Count; i++) {
TextWord word = words[i];
if (wordOffset >= end) {
return wordOffset;
}
if (wordOffset + word.Length >= start) {
int newDrawingPos;
switch (word.Type) {
case TextWordType.Space:
newDrawingPos = drawingPos + spaceWidth;
if (newDrawingPos >= targetVisualPosX)
return IsNearerToAThanB(targetVisualPosX, drawingPos, newDrawingPos) ? wordOffset : wordOffset+1;
break;
case TextWordType.Tab:
// go to next tab position
drawingPos = (int)((drawingPos + MinTabWidth) / tabIndent / WideSpaceWidth) * tabIndent * WideSpaceWidth;
newDrawingPos = drawingPos + tabIndent * WideSpaceWidth;
if (newDrawingPos >= targetVisualPosX)
return IsNearerToAThanB(targetVisualPosX, drawingPos, newDrawingPos) ? wordOffset : wordOffset+1;
break;
case TextWordType.Word:
int wordStart = Math.Max(wordOffset, start);
int wordLength = Math.Min(wordOffset + word.Length, end) - wordStart;
string text = Document.GetText(line.Offset + wordStart, wordLength);
Font font = word.GetFont(fontContainer) ?? fontContainer.RegularFont;
newDrawingPos = drawingPos + MeasureStringWidth(g, text, font);
if (newDrawingPos >= targetVisualPosX) {
for (int j = 0; j < text.Length; j++) {
newDrawingPos = drawingPos + MeasureStringWidth(g, text[j].ToString(), font);
if (newDrawingPos >= targetVisualPosX) {
if (IsNearerToAThanB(targetVisualPosX, drawingPos, newDrawingPos))
return wordStart + j;
else
return wordStart + j + 1;
}
drawingPos = newDrawingPos;
}
return wordStart + text.Length;
}
break;
default:
throw new NotSupportedException();
}
drawingPos = newDrawingPos;
}
wordOffset += word.Length;
}
return wordOffset;
}
开发者ID:modulexcite,项目名称:FluentSharp_Fork.SharpDevelopEditor,代码行数:72,代码来源:TextView.cs
示例14: MeasurePrintingHeight
// btw. I hate source code duplication ... but this time I don't care !!!!
float MeasurePrintingHeight(Graphics g, LineSegment line, float maxWidth)
{
float xPos = 0;
float yPos = 0;
float fontHeight = Font.GetHeight(g);
// bool gotNonWhitespace = false;
curTabIndent = 0;
FontContainer fontContainer = TextEditorProperties.FontContainer;
foreach (TextWord word in line.Words) {
switch (word.Type) {
case TextWordType.Space:
Advance(ref xPos, ref yPos, maxWidth, primaryTextArea.TextArea.TextView.SpaceWidth, fontHeight);
// if (!gotNonWhitespace) {
// curTabIndent = xPos;
// }
break;
case TextWordType.Tab:
Advance(ref xPos, ref yPos, maxWidth, TabIndent * primaryTextArea.TextArea.TextView.WideSpaceWidth, fontHeight);
// if (!gotNonWhitespace) {
// curTabIndent = xPos;
// }
break;
case TextWordType.Word:
// if (!gotNonWhitespace) {
// gotNonWhitespace = true;
// curTabIndent += TabIndent * primaryTextArea.TextArea.TextView.GetWidth(' ');
// }
SizeF drawingSize = g.MeasureString(word.Word, word.GetFont(fontContainer), new SizeF(maxWidth, fontHeight * 100), printingStringFormat);
Advance(ref xPos, ref yPos, maxWidth, drawingSize.Width, fontHeight);
break;
}
}
return yPos + fontHeight;
}
开发者ID:JoeyEremondi,项目名称:tikzedt,代码行数:35,代码来源:TextEditorControl.cs
示例15: PrintWords
void PrintWords(LineSegment lineSegment, StringBuilder b)
{
string currentSpan = null;
foreach (TextWord word in lineSegment.Words) {
if (word.Type == TextWordType.Space) {
b.Append(' ');
} else if (word.Type == TextWordType.Tab) {
b.Append('\t');
} else {
string newSpan = GetStyle(word);
if (currentSpan != newSpan) {
if (currentSpan != null) b.Append("</span>");
if (newSpan != null) {
b.Append("<span");
WriteStyle(newSpan, b);
b.Append('>');
}
currentSpan = newSpan;
}
b.Append(HtmlEncode(word.Word));
}
}
if (currentSpan != null) b.Append("</span>");
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:24,代码来源:HtmlWriter.cs
示例16: LineEventArgs
public LineEventArgs(IDocument document, LineSegment lineSegment)
{
this.document = document;
this.lineSegment = lineSegment;
}
开发者ID:kurniawirawan,项目名称:ICSharpCode.TextEditor,代码行数:5,代码来源:LineManagerEventArgs.cs
示例17: MarkTokensInLine
bool MarkTokensInLine(IDocument document, int lineNumber, ref bool spanChanged)
{
bool processNextLine = false;
LineSegment previousLine = (lineNumber > 0 ? document.GetLineSegment(lineNumber - 1) : null);
currentSpanStack = ((previousLine != null && previousLine.HighlightSpanStack != null) ? new Stack<Span>(previousLine.HighlightSpanStack.ToArray()) : null);
if (currentSpanStack != null) {
while (currentSpanStack.Count > 0 && currentSpanStack.Peek().StopEOL) {
currentSpanStack.Pop();
}
if (currentSpanStack.Count == 0) {
currentSpanStack = null;
}
}
currentLine = (LineSegment)document.LineSegmentCollection[lineNumber];
if (currentLine.Length == -1) { // happens when buffer is empty !
return false;
}
List<TextWord> words = ParseLine(document);
if (currentSpanStack != null && currentSpanStack.Count == 0) {
currentSpanStack = null;
}
// Check if the span state has changed, if so we must re-render the next line
// This check may seem utterly complicated but I didn't want to introduce any function calls
// or alllocations here for perf reasons.
if(currentLine.HighlightSpanStack != currentSpanStack) {
if (currentLine.HighlightSpanStack == null) {
processNextLine = false;
foreach (Span sp in currentSpanStack) {
if (!sp.StopEOL) {
spanChanged = true;
processNextLine = true;
break;
}
}
} else if (currentSpanStack == null) {
processNextLine = false;
foreach (Span sp in currentLine.HighlightSpanStack) {
if (!sp.StopEOL) {
spanChanged = true;
processNextLine = true;
break;
}
}
} else {
IEnumerator<Span> e1 = currentSpanStack.GetEnumerator();
IEnumerator<Span> e2 = currentLine.HighlightSpanStack.GetEnumerator();
bool done = false;
while (!done) {
bool blockSpanIn1 = false;
while (e1.MoveNext()) {
if (!((Span)e1.Current).StopEOL) {
blockSpanIn1 = true;
break;
}
}
bool blockSpanIn2 = false;
while (e2.MoveNext()) {
if (!((Span)e2.Current).StopEOL) {
blockSpanIn2 = true;
break;
}
}
if (blockSpanIn1 || blockSpanIn2) {
if (blockSpanIn1 && blockSpanIn2) {
if (e1.Current != e2.Current) {
done = true;
processNextLine = true;
spanChanged = true;
}
} else {
spanChanged = true;
done = true;
processNextLine = true;
}
} else {
done = true;
processNextLine = false;
}
}
}
} else {
processNextLine = false;
}
//// Alex: remove old words
if (currentLine.Words!=null) currentLine.Words.Clear();
currentLine.Words = words;
currentLine.HighlightSpanStack = (currentSpanStack != null && currentSpanStack.Count > 0) ? currentSpanStack : null;
return processNextLine;
}
开发者ID:viticm,项目名称:pap2,代码行数:97,代码来源:DefaultHighlightingStrategy.cs
示例18: AddRemovedLine
public void AddRemovedLine(LineSegment line)
{
if (removedLines == null)
removedLines = new List<LineSegment>();
removedLines.Add(line);
}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:6,代码来源:DeferredEventList.cs
示例19: GetColor
public HighlightColor GetColor(IDocument document, LineSegment keyWord, int index, int length)
{
return baseStrategy.GetColor(document, keyWord, index, length);
}
开发者ID:mausch,项目名称:NHWorkbench,代码行数:4,代码来源:HqlAdvancedHighlightStrategy.cs
示例20: LineLengthChangeEventArgs
public LineLengthChangeEventArgs(IDocument document, LineSegment lineSegment, int moved)
: base(document, lineSegment)
{
this.lengthDelta = moved;
}
开发者ID:kurniawirawan,项目名称:ICSharpCode.TextEditor,代码行数:5,代码来源:LineManagerEventArgs.cs
注:本文中的ICSharpCode.TextEditor.Document.LineSegment类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论