public void FoldLine(int currentLine, int cmd) { pdoc.pbuffer.LexTo(pdoc.pbuffer.Length(), 0, false); IStyles foldLevels = pdoc.GetFolds(); int currentLevel = foldLevels.ValueAt(currentLine) & 0xFFFF; int line = currentLine; int level = currentLevel + 1; bool showing = cmd == fcShow; if (cmd == fcDiscover) { showing = !textArea.tv.fs.GetExpanded(currentLine); } textArea.tv.fs.SetExpanded(currentLine, showing); while (level > currentLevel) { line++; level = foldLevels.ValueAt(line) & 0xFFFF; if (level > currentLevel) { textArea.tv.fs.SetVisible(line, line, showing); } } textArea.Invalidate(); }
/// <summary> /// Initializes a new instance of the <see cref="MarkdownDifferenceUpdater"/> class. /// </summary> /// <param name="oldSourceText">The previous version of the source text.</param> /// <param name="oldDocument">The previous version of the parsed markdown document.</param> /// <param name="pipeline">The markdown pipeline used to process the source text.</param> /// <param name="styles">The markdown styles to be used for the rendering.</param> /// <param name="imageProvider">The image provider.</param> /// <param name="newSourceText">The new version of the source text.</param> /// <param name="newSourceTextUsn">The serial number of the new source text.</param> /// <param name="flowDocument">The flow document to render to.</param> /// <param name="dispatcher">The dispatcher (used here to process some actions in Gui context).</param> /// <param name="newDocumentSetter"> /// Action that is called at the end of the processing in Gui context. It is intended to set the new new document in the class that is calling this function. /// The arguments are: i) the new source text, ii) the serial number of the new source text, and iii) the parsed markdown document. /// </param> /// <param name="setFlowDocumentUpdateInProgressFlag"> /// Action that is called in Gui context. It is intended to signal the class that is calling this function exactly when the flow document is updated. /// This action is called twice: at the beginning of the update with the argument set to true, and at the end of the update with the argument set to false. /// Argument is a flag that tells if the update of the flow document is in progress now. /// </param> /// <param name="cancellationToken">Cancellation token that can be used to cancel the update, e.g. if the user has entered new text.</param> public MarkdownDifferenceUpdater(string oldSourceText, MarkdownDocument oldDocument, MarkdownPipeline pipeline, IStyles styles, IWpfImageProvider imageProvider, string newSourceText, long newSourceTextUsn, FlowDocument flowDocument, Dispatcher dispatcher, Action <string, long, MarkdownDocument> newDocumentSetter, Action <bool> setFlowDocumentUpdateInProgressFlag, CancellationToken cancellationToken) { OldSourceText = oldSourceText; OldDocument = oldDocument; Pipeline = pipeline; Styles = styles; ImageProvider = imageProvider; NewSourceText = newSourceText; NewSourceTextUsn = newSourceTextUsn; FlowDocument = flowDocument; Dispatcher = dispatcher; NewTextAndDocumentSetter = newDocumentSetter; SetFlowDocumentUpdateInProgressFlag = setFlowDocumentUpdateInProgressFlag; _cancellationToken = cancellationToken; }
public FormDivTagHelper(IHtmlGenerator generator, IStyles styles = null) : base(generator, styles) { }
public FormNewButtonTagHelper(IHtmlGenerator generator, IStyles styles = null) : base(generator, styles) { }
public static void Main(String[] args) { SWTest.WriteLine("Start test"); WordList wl = new WordList(false); Literal keywords = new Literal("alpha \u00a8theta gamma"); wl.Set(keywords.Data(), keywords.Length()); Literal alpha = new Literal("alpha"); Literal theta = new Literal("\u00a8theta"); Literal gamma = new Literal("gamma"); Literal delta = new Literal("delta"); Literal large = new Literal("\u00a0large"); if (wl.InList(alpha.Data(), 0, alpha.Length())) { SWTest.Write("Contains alpha"); } else { SWTest.Write("Does not contain alpha"); } SWTest.Write("\n"); if (wl.InList(theta.Data(), 0, theta.Length())) { SWTest.Write("Contains theta"); } else { SWTest.Write("Does not contain theta"); } SWTest.Write("\n"); if (wl.InList(gamma.Data(), 0, gamma.Length())) { SWTest.Write("Contains gamma"); } else { SWTest.Write("Does not contain beta"); } SWTest.Write("\n"); if (wl.InList(delta.Data(), 0, delta.Length())) { SWTest.Write("Contains delta"); } else { SWTest.Write("Does not contain delta"); } SWTest.Write("\n"); if (wl.InList(large.Data(), 0, large.Length())) { SWTest.Write("Contains large"); } else { SWTest.Write("Does not contain large"); } SWTest.Write("\n"); testUndoRedo(); SplitVector_1 buffer = new SplitVector_1(); buffer.Create(20, 100); SWTest.Assert(buffer.Length() == 0); Literal test = new Literal("abcde"); try { buffer.InsertString(1, test.Data(), 1); } catch (BadPositionException) { SWTest.Write("Caught\n"); } int lenTest = test.Length(); buffer.InsertString(0, test.Data(), lenTest); SWTest.Assert(buffer.Length() == lenTest); byte[] ret = new byte[3]; buffer.RetrieveString(1, ret, 3); for (int h = 0; h < 3; h++) { SWTest.Assert(ret[h] == test.CharAt(h + 1)); } for (int i = 0; i < lenTest; i++) { SWTest.Assert(test.CharAt(i) == buffer.CharAt(i)); SWTest.Write(i); SWTest.Write(":"); SWTest.Write(buffer.CharAt(i)); SWTest.Write(" "); } SWTest.Write("\n"); buffer.DeleteRange(1, 2); SWTest.Assert(buffer.Length() == lenTest - 2); //for (int j = -1; j < buffer.Length() + 1; j++) { for (int j = 0; j < buffer.Length(); j++) { SWTest.Write(j); SWTest.Write("="); SWTest.Write(buffer.CharAt(j)); SWTest.Write(" "); } SWTest.Write("\n"); Literal shortInsert = new Literal("bc"); buffer.InsertString(1, shortInsert.Data(), 2); SWTest.Assert(buffer.Length() == lenTest); for (int k = 0; k < lenTest; k++) { SWTest.Assert(test.CharAt(k) == buffer.CharAt(k)); SWTest.Write(k); SWTest.Write(":"); SWTest.Write(buffer.CharAt(k)); SWTest.Write(" "); } SWTest.Write("\n"); double st = SWTest.Now(); Literal longtest = new Literal("ghijklmnopqrstuvwxyz"); for (int l = 0; l < 10000; l++) { for (int m = 0; m < 20; m++) { buffer.InsertString(1, longtest.Data(), m + 1); } } SplitText pbuffer = new SplitText(); pbuffer.AttachStyles(SplitText.CreateStyles(1), null, 0); //pbuffer.DiscardLines(); SWTest.Assert(pbuffer.Length() == 0); //SWTest.Assert(pbuffer.Lines() == 1); pbuffer.InsertString(0, test.Data(), lenTest); SWTest.Assert(pbuffer.Length() == lenTest); for (int n = 0; n < lenTest; n++) { SWTest.Assert(test.CharAt(n) == pbuffer.CharAt(n)); SWTest.Write(n); SWTest.Write(":"); SWTest.Write(pbuffer.CharAt(n)); SWTest.Write(" "); } SWTest.Write("\n"); double t2 = SWTest.Now(); SWTest.Write(t2 - st); SWTest.Write(" seconds for Insertion test\n"); SplitText sbuffer = new SplitText(); IStyles sstyles = SplitText.CreateStyles(1); sbuffer.AttachStyles(sstyles, null, 0); //sbuffer.DiscardLines(); Literal prog = new Literal("//// A demonstration program\r\nint main() {\r\n\tprintf(\"hello world %d\\n\", 9);\r\n}\r\n"); int lenProg = prog.Length(); sbuffer.InsertString(0, prog.Data(), lenProg); //SWTest.Assert(sbuffer.Lines() == 5); Styler sa = new Styler(sbuffer, sstyles, 0, sbuffer.Length()); LexCPP lx = new LexCPP(); WordList wlCPP = new WordList(false); Literal keywordsCPP = new Literal( "abstract as base bool break byte case catch char " + "checked class const continue decimal default " + "delegate do double else enum event explicit " + "extern false finally fixed float for foreach goto " + "if implicit in int interface internal is lock long " + "namespace new null object operator out override " + "params private protected public readonly ref " + "return sbyte sealed short sizeof stackalloc " + "static string struct switch this throw true try " + "typeof uint ulong unchecked unsafe ushort " + "using virtual void while"); lx.SetKeyWords(0, keywordsCPP); lx.Colourise(sa); //DisplayHTML(sbuffer); // Start buffer as big as needed to avoid measuring allocation and copying SplitText bigbuffer = new SplitText(300000, 1024); IStyles bigstyles = SplitText.CreateStyles(1); bigbuffer.AttachStyles(bigstyles, null, 0); MarkerSet ms2 = new MarkerSet(); bigbuffer.AddPerLineData(ms2); //bigbuffer.DiscardLines(); // prog is about 80 characters so create a realistic large 120K document for (int q = 0; q < 3000; q++) { bigbuffer.InsertString(lenProg * (q / 2), prog.Data(), lenProg); } for (int q2 = 0; q2 < 1500; q2++) { bigbuffer.DeleteRange(lenProg * (q2 / 2), lenProg); } SWTest.Assert(bigbuffer.Length() == 1500 * lenProg); SWTest.Assert(bigbuffer.Lines() == 1500 * 4 + 1); double t3 = SWTest.Now(); SWTest.Write(t3 - t2); SWTest.Write(" seconds for Lines Insertion Deletion test\n"); // Run 50 times to get a large enough time to measure Colourise operation for (int p = 0; p < 50; p++) { Styler sabig = new Styler(bigbuffer, bigstyles, 0, bigbuffer.Length()); lx.Colourise(sabig); } double t31 = SWTest.Now(); SWTest.Write((t31 - t3) / 50.0); SWTest.Write(" seconds for Colourise test\n"); int biglength = bigbuffer.Length(); // Search for "printf" Literal printfs = new Literal("printf"); int lenPrintfs = printfs.Length(); for (int r = 0; r < 50; r++) { int count = 0; for (int s = 0; s < biglength; s++) { if (bigbuffer.CharAt(s) == printfs.CharAt(0)) { int found = 1; for (int t = 1; t < lenPrintfs && found == 1; t++) { if (bigbuffer.CharAt(s + t) != printfs.CharAt(t)) { found = 0; } } if (found == 1) { count++; } } } SWTest.Assert(count == 1500); } double t4 = SWTest.Now(); SWTest.Write((t4 - t31) / 50.0); SWTest.Write(" seconds for Search test\n"); // Search for "printf" and replace with "OutputTrace" // Then reverse the process so it can be done again Literal replace = new Literal("OutputTrace"); int lenReplace = replace.Length(); for (int u = 0; u < 50; u++) { int count = 0; for (int s = 0; s < biglength; s++) { if (bigbuffer.CharAt(s) == printfs.CharAt(0)) { int found = 1; for (int t = 1; t < lenPrintfs && found == 1; t++) { if (bigbuffer.CharAt(s + t) != printfs.CharAt(t)) { found = 0; } } if (found == 1) { count++; bigbuffer.DeleteRange(s, lenPrintfs); bigbuffer.InsertString(s, replace.Data(), lenReplace); biglength += lenReplace - lenPrintfs; } } } SWTest.Assert(count == 1500); count = 0; for (int s = 0; s < biglength; s++) { if (bigbuffer.CharAt(s) == replace.CharAt(0)) { int found = 1; for (int t = 1; t < lenReplace && found == 1; t++) { if (bigbuffer.CharAt(s + t) != replace.CharAt(t)) { found = 0; } } if (found == 1) { count++; bigbuffer.DeleteRange(s, lenReplace); bigbuffer.InsertString(s, printfs.Data(), lenPrintfs); biglength += lenPrintfs - lenReplace; } } } SWTest.Assert(count == 1500); } double en = SWTest.Now(); SWTest.Write((en - t4) / 100.0); SWTest.Write(" seconds for Replace test\n"); }
internal SubStyles(IStyles parentStyles, Selector parentSelector) { _parentStyles = parentStyles; _parentSelector = parentSelector; }
public FormBaseTagHelper(IHtmlGenerator generator, IStyles styles = null) { this.generator = generator; this.styles = styles ?? new Styles(); }
public FormDetailsTagHelper(IHtmlGenerator generator, IHtmlHelper htmlHelper, IStyles styles = null) : base(generator, styles) { this.htmlHelper = htmlHelper; }
public FormIndexFileTagHelper(IHtmlGenerator generator, IHtmlHelper htmlHelper, IStyles styles = null) : base(generator, htmlHelper, styles) { }
public FormValidationSummaryTagHelper(IHtmlGenerator generator, IStyles styles = null) : base(generator, styles) { }
public FormSubmitLinksTagHelper(IHtmlGenerator generator, IStyles styles = null) : base(generator, styles) { }
/// <summary> /// Converts a list of (top level) <see cref="MarkdownObject"/>s to a list of (top level) <see cref="TextElement"/>s. /// </summary> /// <param name="markdownObjects">List of top level markdown objects.</param> /// <param name="pipeline">The pipeline used for the conversion.</param> /// <returns>The list of (top level) <see cref="TextElement"/>s as the result of the conversion.</returns> /// <exception cref="System.ArgumentNullException">if markdown variable is null</exception> public static IList <TextElement> ListOfMarkdownObjectsToListOfTextElements(IList <MarkdownObject> markdownObjects, MarkdownPipeline pipeline, IStyles styles, IWpfImageProvider imageProvider) { var p = new Paragraph(); styles.ApplyParagraphStyle(p); var result = new TextElementList() { FontSize = p.FontSize }; var renderer = new Markdig.Renderers.WpfRenderer(result, styles) { ImageProvider = imageProvider }; pipeline.Setup(renderer); renderer.Render(markdownObjects); return(result); }