Scrollable dump cell
I love Util.SyntaxColorText.
I often use it as a reportable property as below, but is it possible to make the cell that contains the dumped json scrollable so that very long json is contained?
void Main()
{
var json = """
{
"name": "John"
}
""";
new Thing()
{
SomeProperty = "Something",
RawJson = Util.SyntaxColorText(json.ToString(), SyntaxLanguageStyle.Json, autoFormat: true)
}.Dump();
}
public class Thing
{
public required string SomeProperty { get; set; }
public required LINQPad.SyntaxColoredText RawJson { get; set; }
}

Could there be some kind of LINQPad class like ScrollCell, something like this:
void Main()
{
var json = """
{
"name": "John"
}
""";
new Thing()
{
SomeProperty = "Something",
RawJson = new ScrollCell
{
VisibleLines = 3,
Content = Util.SyntaxColorText(json.ToString(), SyntaxLanguageStyle.Json, autoFormat: true)
}
}.Dump();
}
public class Thing
{
public required string SomeProperty { get; set; }
public required ScrollCell RawJson { get; set; }
}
public class ScrollCell
{
public int VisibleLines { get; set; }
public object Content { get; set; }
}
Best Answer
-
The easiest way to do this is with a
DumpContainer:new DumpContainer (code) { Style = "max-height: 200px; overflow:auto" }.Dump();(
Util.WithStyleshould also work, although it doesn't right now due to a bug/limitation when wrapping block elements. I'll see whether this is easy to fix.)For a more fancy solution, you could create a custom Control:
using LINQPad.Controls; class ScrollableControl : Control { public string MaxHeight { get => Styles["max-height"]; set => Styles["max-height"] = value; } public ScrollableControl (Control child, string maxHeight) : base ("div", child) { Styles["overflow"] = "auto"; MaxHeight = maxHeight; } public ScrollableControl (object content, string maxHeight) : this (new DumpContainer (content), maxHeight) { } public ScrollableControl WithBorder (string border = "solid 1pt #777") { Styles["border"] = border; return this; } public ScrollableControl WithPadding (string padding = "3pt") { Styles["padding"] = padding; return this; } }Note that you can ask AI to write such wrappers. The recent beta actually includes additional training for creating custom controls, so now it's pretty reliable. Press Ctrl+I and ask it, Write a LINQPad control that makes SyntaxColorText or another control scrollable.
Answers
-
That's great. Thanks very much Joe. I hadn't considered having a DumpContainer in a cell.
Will try out the beta as extra controls help has been on my wish list.

