1
- using Rubberduck . Settings ;
1
+ using System ;
2
+ using Rubberduck . Settings ;
2
3
using Rubberduck . SmartIndenter ;
3
4
4
5
namespace Rubberduck . UI . Settings
@@ -7,22 +8,22 @@ public class IndenterSettingsViewModel : ViewModelBase, ISettingsViewModel
7
8
{
8
9
public IndenterSettingsViewModel ( Configuration config )
9
10
{
10
- AlignCommentsWithCode = config . UserSettings . IndenterSettings . AlignCommentsWithCode ;
11
- AlignContinuations = config . UserSettings . IndenterSettings . AlignContinuations ;
12
- AlignDimColumn = config . UserSettings . IndenterSettings . AlignDimColumn ;
13
- AlignDims = config . UserSettings . IndenterSettings . AlignDims ;
14
- EnableUndo = config . UserSettings . IndenterSettings . EnableUndo ;
15
- EndOfLineCommentColumnSpaceAlignment = config . UserSettings . IndenterSettings . EndOfLineCommentColumnSpaceAlignment ;
16
- EndOfLineCommentStyle = config . UserSettings . IndenterSettings . EndOfLineCommentStyle ;
17
- ForceCompilerDirectivesInColumn1 = config . UserSettings . IndenterSettings . ForceCompilerDirectivesInColumn1 ;
18
- ForceDebugStatementsInColumn1 = config . UserSettings . IndenterSettings . ForceDebugStatementsInColumn1 ;
19
- IgnoreOperatorsInContinuations = config . UserSettings . IndenterSettings . IgnoreOperatorsInContinuations ;
20
- IndentCase = config . UserSettings . IndenterSettings . IndentCase ;
21
- IndentCompilerDirectives = config . UserSettings . IndenterSettings . IndentCompilerDirectives ;
22
- IndentEntireProcedureBody = config . UserSettings . IndenterSettings . IndentEntireProcedureBody ;
23
- IndentFirstCommentBlock = config . UserSettings . IndenterSettings . IndentFirstCommentBlock ;
24
- IndentFirstDeclarationBlock = config . UserSettings . IndenterSettings . IndentFirstDeclarationBlock ;
25
- IndentSpaces = config . UserSettings . IndenterSettings . IndentSpaces ;
11
+ _alignCommentsWithCode = config . UserSettings . IndenterSettings . AlignCommentsWithCode ;
12
+ _alignContinuations = config . UserSettings . IndenterSettings . AlignContinuations ;
13
+ _alignDimColumn = config . UserSettings . IndenterSettings . AlignDimColumn ;
14
+ _alignDims = config . UserSettings . IndenterSettings . AlignDims ;
15
+ _enableUndo = config . UserSettings . IndenterSettings . EnableUndo ;
16
+ _endOfLineCommentColumnSpaceAlignment = config . UserSettings . IndenterSettings . EndOfLineCommentColumnSpaceAlignment ;
17
+ _endOfLineCommentStyle = config . UserSettings . IndenterSettings . EndOfLineCommentStyle ;
18
+ _forceCompilerDirectivesInColumn1 = config . UserSettings . IndenterSettings . ForceCompilerDirectivesInColumn1 ;
19
+ _forceDebugStatementsInColumn1 = config . UserSettings . IndenterSettings . ForceDebugStatementsInColumn1 ;
20
+ _ignoreOperatorsInContinuations = config . UserSettings . IndenterSettings . IgnoreOperatorsInContinuations ;
21
+ _indentCase = config . UserSettings . IndenterSettings . IndentCase ;
22
+ _indentCompilerDirectives = config . UserSettings . IndenterSettings . IndentCompilerDirectives ;
23
+ _indentEntireProcedureBody = config . UserSettings . IndenterSettings . IndentEntireProcedureBody ;
24
+ _indentFirstCommentBlock = config . UserSettings . IndenterSettings . IndentFirstCommentBlock ;
25
+ _indentFirstDeclarationBlock = config . UserSettings . IndenterSettings . IndentFirstDeclarationBlock ;
26
+ _indentSpaces = config . UserSettings . IndenterSettings . IndentSpaces ;
26
27
27
28
PropertyChanged += IndenterSettingsViewModel_PropertyChanged ;
28
29
}
@@ -262,14 +263,75 @@ public int IndentSpaces
262
263
}
263
264
264
265
// ReSharper disable once InconsistentNaming
265
- private const string _previewSampleCode = @"Sub Foo()
266
- ' Do something here
267
- ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ' comment here
268
- End Sub" ;
266
+ private const string _previewSampleCode =
267
+ @"' Example Procedure
268
+ Sub ExampleProc()
269
+
270
+ ' SMART INDENTER
271
+ ' Original VB6 code graciously offered to Rubberduck by Stephen Bullen & Rob Bovey
272
+ '@ 2016 by Rubberduck VBA.
273
+
274
+ Dim iCount As Integer
275
+ Static sName As String
276
+
277
+ If YouLikeRubberduck Then
278
+ ' Star us on GitHub http://github.com/rubberduck-vba/Rubberduck
279
+ ' Follow us on Twitter @rubberduck-vba/contributors
280
+ ' Visit http://rubberduckvba.com for news and updates
281
+
282
+ Select Case X
283
+ Case ""A""
284
+ ' If you have any comments or suggestions, _
285
+ or find valid VBA code that isn't indented correctly,
286
+
287
+ #If VBA6 Then
288
+ MsgBox ""Contact contact@rubberduck-vba.com""
289
+ #End If
290
+
291
+ Case ""Continued strings and parameters can be"" _
292
+ & ""lined up for easier reading, optionally ignoring"" _
293
+ , ""any operators (&+, etc) at the start of the line.""
294
+
295
+ Debug.Print ""X<>1""
296
+ End Select 'Case X
297
+ End If 'More Tools?
298
+
299
+ End Sub
300
+ " ;
269
301
270
302
public string PreviewSampleCode
271
303
{
272
- get { return _previewSampleCode ; /* SmartIndenter.Indent(_indenterData); */ }
304
+ get
305
+ {
306
+ var indenter = new Indenter ( null , GetCurrentSettings ) ;
307
+
308
+ var lines = _previewSampleCode . Split ( new [ ] { Environment . NewLine } , StringSplitOptions . None ) ;
309
+ indenter . Indent ( lines , "TestModule" , false ) ;
310
+ return string . Join ( Environment . NewLine , lines ) ;
311
+ }
312
+ }
313
+
314
+ private IIndenterSettings GetCurrentSettings ( )
315
+ {
316
+ return new SmartIndenter . IndenterSettings
317
+ {
318
+ AlignCommentsWithCode = AlignCommentsWithCode ,
319
+ AlignContinuations = AlignContinuations ,
320
+ AlignDimColumn = AlignDimColumn ,
321
+ AlignDims = AlignDims ,
322
+ EnableUndo = EnableUndo ,
323
+ EndOfLineCommentColumnSpaceAlignment = EndOfLineCommentColumnSpaceAlignment ,
324
+ EndOfLineCommentStyle = EndOfLineCommentStyle ,
325
+ ForceCompilerDirectivesInColumn1 = ForceCompilerDirectivesInColumn1 ,
326
+ ForceDebugStatementsInColumn1 = ForceDebugStatementsInColumn1 ,
327
+ IgnoreOperatorsInContinuations = IgnoreOperatorsInContinuations ,
328
+ IndentCase = IndentCase ,
329
+ IndentCompilerDirectives = IndentCompilerDirectives ,
330
+ IndentEntireProcedureBody = IndentEntireProcedureBody ,
331
+ IndentFirstCommentBlock = IndentFirstCommentBlock ,
332
+ IndentFirstDeclarationBlock = IndentFirstDeclarationBlock ,
333
+ IndentSpaces = IndentSpaces
334
+ } ;
273
335
}
274
336
275
337
#endregion
0 commit comments