Closed retailcoder closed 7 years ago
The settings form would actually replace the screenshot.
Do we want to make the settings look as close (layout wise) to the screenshot as possible?
Do we want a serializable version of the settings that can be passed to the actual RD configuration system? (Assuming this is possible.)
The RD settings page ViewModel creates an indenter instance every time it refreshes the preview box:
public string PreviewSampleCode
{
get
{
var indenter = new Indenter(null, GetCurrentSettings);
var lines = RubberduckUI.IndenterSettings_PreviewCode.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
lines = indenter.Indent(lines, "TestModule").ToArray();
return string.Join(Environment.NewLine, lines);
}
}
The GetCurrentSettings
method returns an IIndenterSettings
instance built off the current selected values:
private IIndenterSettings GetCurrentSettings()
{
return new SmartIndenter.IndenterSettings
{
AlignCommentsWithCode = AlignCommentsWithCode,
AlignContinuations = AlignContinuations,
AlignDimColumn = AlignDimColumn,
AlignDims = AlignDims,
EndOfLineCommentColumnSpaceAlignment = EndOfLineCommentColumnSpaceAlignment,
EndOfLineCommentStyle = EndOfLineCommentStyle,
ForceCompilerDirectivesInColumn1 = ForceCompilerDirectivesInColumn1,
ForceDebugStatementsInColumn1 = ForceDebugStatementsInColumn1,
IgnoreOperatorsInContinuations = IgnoreOperatorsInContinuations,
IndentCase = IndentCase,
IndentCompilerDirectives = IndentCompilerDirectives,
IndentEnumTypeAsProcedure = IndentEnumTypeAsProcedure,
IndentEntireProcedureBody = IndentEntireProcedureBody,
IndentFirstCommentBlock = IndentFirstCommentBlock,
IndentFirstDeclarationBlock = IndentFirstDeclarationBlock,
IndentSpaces = IndentSpaces
};
}
Simple as that!
TL;DR: you need to create a new SmartIndenter.IndenterSettings
anyway for it to work.
Beautiful.
Do we already have an import/export feature on settings? If not, I'll add an issue on the other project for it. That would definitely be a nice feature.
Ah, I see what you mean. Unfortunately that's not implemented (yet) in RD. I mean, the settings are serialized to XML, but there's much more to it than just the indenter settings.
We're talking about a feature that lets you export the indenter settings from the website and import them to your desktop rubberduck, right?
That's definitely a nice thing to add to the RD indenter settings!
Yes. It would be trivial to serialize and send them from web -> computer file, but if there's nothing to get them to go from file -> RD, then there's no point (yet) in creating that feature on the web side. We can still create the Indenter feature, just not the "Export Settings" feature.
Hold that thought, then. I think it's a good idea, but it would make more sense to implement it once we ship a RD build that includes that "import indenter settings from file" button.
@retailcoder - Open an RD issue for it so I don't forget - the groundwork is there in XmlPersistanceService<T>
, it just needs something to pass it a FilePath parameter.
Absolutely. I'll create the Smart Indenter on the website, but we'll hold off on the export feature until RD is ready to accept imports, then I'll look into the serialization of settings. Until then I'll make the web form layout as close to the form layout as possible, so settings are easy to copy/paste.
Similar to the inspections page, the indenter page needs a place to paste some code and click a button to apply indenter settings.
The indented code should update accordingly with the specified settings, as the user tweaks them - just like in the Rubberduck indenter settings page.