public void EmitText(string text, RichTextInlineStyle style) { var iterEnd = EndIter; var m = CreateMark(null, iterEnd, true); Insert(ref iterEnd, text); var iterStart = GetIterAtMark(m); if ((style & RichTextInlineStyle.Bold) != 0) { ApplyTag("bold", iterStart, iterEnd); } if ((style & RichTextInlineStyle.Italic) != 0) { ApplyTag("italic", iterStart, iterEnd); } if ((style & RichTextInlineStyle.Monospace) != 0) { ApplyTag("tt", iterStart, iterEnd); } DeleteMark(m); }
public void EmitText(string text, RichTextInlineStyle style) { //FIXME: it would be nice to have real styled text in a link, but for now short circuit it if (openLinks.Count != 0) { var link = openLinks.Pop(); link.Text += text; openLinks.Push(link); return; } var iterEnd = EndIter; var m = CreateMark(null, iterEnd, true); Insert(ref iterEnd, text); var iterStart = GetIterAtMark(m); if ((style & RichTextInlineStyle.Bold) != 0) { ApplyTag("bold", iterStart, iterEnd); } if ((style & RichTextInlineStyle.Italic) != 0) { ApplyTag("italic", iterStart, iterEnd); } if ((style & RichTextInlineStyle.Monospace) != 0) { ApplyTag("tt", iterStart, iterEnd); } DeleteMark(m); }
public void EmitText(string text, RichTextInlineStyle style) { if (String.IsNullOrEmpty(text)) { return; } bool haveStyle = true; switch (style) { case RichTextInlineStyle.Bold: xmlWriter.WriteStartElement("strong"); break; case RichTextInlineStyle.Italic: xmlWriter.WriteStartElement("em"); break; case RichTextInlineStyle.Monospace: xmlWriter.WriteStartElement("tt"); break; default: haveStyle = false; break; } bool first = true; foreach (string line in text.Split(lineSplitChars, StringSplitOptions.None)) { if (!first) { xmlWriter.WriteStartElement("br"); xmlWriter.WriteEndElement(); } else { first = false; } xmlWriter.WriteString(line); } if (haveStyle) { xmlWriter.WriteEndElement(); } }
public void EmitText(string text, RichTextInlineStyle style) { switch (style) { case RichTextInlineStyle.Bold: case RichTextInlineStyle.Italic: writer.WriteStartElement(style.ToString()); EmitText(text); break; case RichTextInlineStyle.Monospace: writer.WriteStartElement("Run"); writer.WriteAttributeString("FontFamily", "Global Monospace"); writer.WriteString(text); break; default: EmitText(text); return; } writer.WriteEndElement(); }
static void ParseText(IRichTextBuffer buffer, string line, RichTextInlineStyle style = RichTextInlineStyle.Normal) { var match = styles.Match(line); int currentIndex = 0; while (match.Success) { var escaped = match.Index != 0 && line [match.Index - 1] == '\\'; if (!escaped) { var text = line.Substring(currentIndex, match.Index - currentIndex); if (!string.IsNullOrEmpty(text)) { EmitText(buffer, text, style); } if (match.Groups["bold"].Success) { ParseText(buffer, match.Groups["bold"].Value, style | RichTextInlineStyle.Bold); } else if (match.Groups["italic"].Success) { ParseText(buffer, match.Groups["italic"].Value, style | RichTextInlineStyle.Italic); } else { EmitText(buffer, match.Groups["code"].Value, style | RichTextInlineStyle.Monospace); } currentIndex = match.Index + match.Length; } match = match.NextMatch(); } // Add remaining text EmitText(buffer, line.Substring(currentIndex), style); }
public void EmitText(string text, RichTextInlineStyle style) { InlineCollection block; var inlineCreated = GetOrCreateInline(out block); switch (style) { case RichTextInlineStyle.Bold: var bold = new Bold(); blockStack.Push(bold.Inlines); EmitText(text); blockStack.Pop(); break; case RichTextInlineStyle.Italic: var italic = new Italic(); blockStack.Push(italic.Inlines); EmitText(text); blockStack.Pop(); break; case RichTextInlineStyle.Monospace: var run = new Run(text); run.FontFamily = new FontFamily("Global Monospace"); block.Add(run); break; default: EmitText(text); return; } if (inlineCreated) { EmitEndParagraph(); } }
public void EmitText(string text, RichTextInlineStyle style) { switch (style) { case RichTextInlineStyle.Bold: case RichTextInlineStyle.Italic: writer.WriteStartElement (style.ToString ()); EmitText (text); break; case RichTextInlineStyle.Monospace: writer.WriteStartElement ("Run"); writer.WriteAttributeString ("FontFamily", "Global Monospace"); writer.WriteString (text); break; default: EmitText (text); return; } writer.WriteEndElement (); }
public void EmitText(string text, RichTextInlineStyle style) { var iterEnd = EndIter; var m = CreateMark (null, iterEnd, true); Insert (ref iterEnd, text); var iterStart = GetIterAtMark (m); if ((style & RichTextInlineStyle.Bold) != 0) ApplyTag ("bold", iterStart, iterEnd); if ((style & RichTextInlineStyle.Italic) != 0) ApplyTag ("italic", iterStart, iterEnd); if ((style & RichTextInlineStyle.Monospace) != 0) ApplyTag ("tt", iterStart, iterEnd); DeleteMark (m); }
public void EmitText(string text, RichTextInlineStyle style) { //FIXME: it would be nice to have real styled text in a link, but for now short circuit it if (openLinks.Count != 0) { var link = openLinks.Pop (); link.Text += text; openLinks.Push (link); return; } var iterEnd = EndIter; var m = CreateMark (null, iterEnd, true); Insert (ref iterEnd, text); var iterStart = GetIterAtMark (m); if ((style & RichTextInlineStyle.Bold) != 0) ApplyTag ("bold", iterStart, iterEnd); if ((style & RichTextInlineStyle.Italic) != 0) ApplyTag ("italic", iterStart, iterEnd); if ((style & RichTextInlineStyle.Monospace) != 0) ApplyTag ("tt", iterStart, iterEnd); DeleteMark (m); }
static void EmitText (IRichTextBuffer buffer, string text, RichTextInlineStyle style) { text = escape.Replace (text, m => m.Groups["next"].Value); buffer.EmitText (text, style); }
static void ParseText (IRichTextBuffer buffer, string line, RichTextInlineStyle style = RichTextInlineStyle.Normal) { var match = styles.Match (line); int currentIndex = 0; while (match.Success) { var escaped = match.Index != 0 && line [match.Index - 1] == '\\'; if (!escaped) { var text = line.Substring (currentIndex, match.Index - currentIndex); if (!string.IsNullOrEmpty (text)) EmitText (buffer, text, style); if (match.Groups["bold"].Success) ParseText (buffer, match.Groups["bold"].Value, style | RichTextInlineStyle.Bold); else if (match.Groups["italic"].Success) ParseText (buffer, match.Groups["italic"].Value, style | RichTextInlineStyle.Italic); else EmitText (buffer, match.Groups["code"].Value, style | RichTextInlineStyle.Monospace); currentIndex = match.Index + match.Length; } match = match.NextMatch (); } // Add remaining text EmitText (buffer, line.Substring (currentIndex), style); }
static void EmitText(IRichTextBuffer buffer, string text, RichTextInlineStyle style) { text = escape.Replace(text, m => m.Groups["next"].Value); buffer.EmitText(text, style); }