// Constructors public CIndentEngine (CFormattingPolicy policy) { if (policy == null) throw new ArgumentNullException ("policy"); this.policy = policy; stack = new IndentStack (this); linebuf = new StringBuilder (); Reset (); }
public CTextEditorIndentation () { IEnumerable<string> types = MonoDevelop.Ide.DesktopService.GetMimeTypeInheritanceChain (CFormatter.MimeType); policy = MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy<CFormattingPolicy> (types); }
public override void Initialize () { base.Initialize (); IEnumerable<string> types = MonoDevelop.Ide.DesktopService.GetMimeTypeInheritanceChain (CFormatter.MimeType); if (base.Document.Project != null && base.Document.Project.Policies != null) policy = base.Document.Project.Policies.Get<CFormattingPolicy> (types); textEditorData = Document.Editor; if (textEditorData != null) { textEditorData.VirtualSpaceManager = new IndentVirtualSpaceManager (textEditorData, new DocumentStateTracker<CIndentEngine> (new CIndentEngine (policy), textEditorData)); textEditorData.Caret.AllowCaretBehindLineEnd = true; textEditorData.Paste += TextEditorDataPaste; } InitTracker (); }
public CFormattingProfileDialog (CFormattingPolicy profile) { this.Build (); this.profile = profile; this.Title = profile.IsBuiltIn ? GettextCatalog.GetString ("Show built-in profile") : GettextCatalog.GetString ("Edit Profile"); notebookCategories.SwitchPage += delegate { TreeView treeView; switch (notebookCategories.Page) { case 0: treeView = treeviewIndentOptions; break; case 1: treeView = treeviewBracePositions; break; case 2: // Blank lines UpdateExample (blankLineExample); return; case 3: // white spaces treeView = treeviewInsertWhiteSpaceCategory; return; case 4: treeView = treeviewNewLines; break; default: return; } var model = treeView.Model; Gtk.TreeIter iter; if (treeView.Selection.GetSelected (out model, out iter)) UpdateExample (model, iter); }; notebookCategories.ShowTabs = false; comboboxCategories.AppendText (GettextCatalog.GetString ("Indentation")); comboboxCategories.AppendText (GettextCatalog.GetString ("Braces")); comboboxCategories.AppendText (GettextCatalog.GetString ("Blank lines")); comboboxCategories.AppendText (GettextCatalog.GetString ("White Space")); comboboxCategories.AppendText (GettextCatalog.GetString ("New Lines")); comboboxCategories.Changed += delegate(object sender, EventArgs e) { texteditor.Text = ""; notebookCategories.Page = comboboxCategories.Active; }; comboboxCategories.Active = 0; var options = MonoDevelop.SourceEditor.DefaultSourceEditorOptions.Instance; texteditor.Options.FontName = options.FontName; texteditor.Options.ColorScheme = options.ColorScheme; texteditor.Options.ShowFoldMargin = false; texteditor.Options.ShowIconMargin = false; texteditor.Options.ShowLineNumberMargin = false; texteditor.Options.ShowInvalidLines = false; texteditor.Document.ReadOnly = true; texteditor.Document.MimeType = CFormatter.MimeType; scrolledwindow.Child = texteditor; ShowAll (); #region Indent options indentOptions = new Gtk.TreeStore (typeof (string), typeof (string), typeof (string), typeof(bool), typeof(bool)); TreeViewColumn column = new TreeViewColumn (); // pixbuf column var pixbufCellRenderer = new CellRendererPixbuf (); column.PackStart (pixbufCellRenderer, false); column.SetCellDataFunc (pixbufCellRenderer, RenderIcon); // text column CellRendererText cellRendererText = new CellRendererText (); cellRendererText.Ypad = 1; column.PackStart (cellRendererText, true); column.SetAttributes (cellRendererText, "text", 1); treeviewIndentOptions.Model = indentOptions; treeviewIndentOptions.HeadersVisible = false; treeviewIndentOptions.Selection.Changed += TreeSelectionChanged; treeviewIndentOptions.AppendColumn (column); column = new TreeViewColumn (); CellRendererCombo cellRendererCombo = new CellRendererCombo (); cellRendererCombo.Ypad = 1; cellRendererCombo.Mode = CellRendererMode.Editable; cellRendererCombo.TextColumn = 1; cellRendererCombo.Model = comboBoxStore; cellRendererCombo.HasEntry = false; cellRendererCombo.Editable = !profile.IsBuiltIn; cellRendererCombo.Edited += new ComboboxEditedHandler (this, indentOptions).ComboboxEdited; column.PackStart (cellRendererCombo, false); column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn); column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc); CellRendererToggle cellRendererToggle = new CellRendererToggle (); cellRendererToggle.Ypad = 1; cellRendererToggle.Activatable = !profile.IsBuiltIn; cellRendererToggle.Toggled += new CellRendererToggledHandler (this, indentOptions).Toggled; column.PackStart (cellRendererToggle, false); column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn); column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc); treeviewIndentOptions.AppendColumn (column); var category = AddOption (indentOptions, null, GettextCatalog.GetString ("Declarations"), null); AddOption (indentOptions, category, "IndentNamespaceBody", GettextCatalog.GetString ("within namespaces"), "namespace Test { class AClass {}; }"); AddOption (indentOptions, category, "IndentClassBody", GettextCatalog.GetString ("within classes"), "class AClass { int aField; void AMethod () {} };"); AddOption (indentOptions, category, "IndentStructBody", GettextCatalog.GetString ("within structs"), "struct AStruct { int aField; void AMethod () {} };"); AddOption (indentOptions, category, "IndentEnumBody", GettextCatalog.GetString ("within enums"), "enum AEnum { A, B, C };"); AddOption (indentOptions, category, "IndentMethodBody", GettextCatalog.GetString ("within methods"), methodSpaceExample); category = AddOption (indentOptions, null, GettextCatalog.GetString ("Statements"), null); AddOption (indentOptions, category, "IndentBlocks", GettextCatalog.GetString ("within blocks"), spaceExample); AddOption (indentOptions, category, "IndentSwitchBody", GettextCatalog.GetString ("Indent 'switch' body"), spaceExample); AddOption (indentOptions, category, "IndentCaseBody", GettextCatalog.GetString ("Indent 'case' body"), spaceExample); AddOption (indentOptions, category, "IndentBreakStatements", GettextCatalog.GetString ("Indent 'break' statements"), spaceExample); AddOption (indentOptions, category, "AlignEmbeddedIfStatements", GettextCatalog.GetString ("Align embedded 'if' statements"), "class AClass { void AMethod () { if (a) if (b) { int c; } } };"); treeviewIndentOptions.ExpandAll (); #endregion #region Brace options bacePositionOptions = new Gtk.TreeStore (typeof (string), typeof (string), typeof (string), typeof(bool), typeof(bool)); column = new TreeViewColumn (); // pixbuf column column.PackStart (pixbufCellRenderer, false); column.SetCellDataFunc (pixbufCellRenderer, RenderIcon); // text column cellRendererText = new CellRendererText (); cellRendererText.Ypad = 1; column.PackStart (cellRendererText, true); column.SetAttributes (cellRendererText, "text", 1); treeviewBracePositions.Model = bacePositionOptions; treeviewBracePositions.HeadersVisible = false; treeviewBracePositions.Selection.Changed += TreeSelectionChanged; treeviewBracePositions.AppendColumn (column); column = new TreeViewColumn (); cellRendererCombo = new CellRendererCombo (); cellRendererCombo.Ypad = 1; cellRendererCombo.Mode = CellRendererMode.Editable; cellRendererCombo.TextColumn = 1; cellRendererCombo.Model = comboBoxStore; cellRendererCombo.HasEntry = false; cellRendererCombo.Editable = !profile.IsBuiltIn; cellRendererCombo.Edited += new ComboboxEditedHandler (this, bacePositionOptions).ComboboxEdited; column.PackStart (cellRendererCombo, false); column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn); column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc); cellRendererToggle = new CellRendererToggle (); cellRendererToggle.Activatable = !profile.IsBuiltIn; cellRendererToggle.Ypad = 1; cellRendererToggle.Toggled += new CellRendererToggledHandler (this, bacePositionOptions).Toggled; column.PackStart (cellRendererToggle, false); column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn); column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc); treeviewBracePositions.AppendColumn (column); AddOption (bacePositionOptions, "NamespaceBraceStyle", GettextCatalog.GetString ("Namespace declaration"), "namespace TestNameSpace {}"); AddOption (bacePositionOptions, "ClassBraceStyle", GettextCatalog.GetString ("Class declaration"), "class ClassDeclaration {};"); AddOption (bacePositionOptions, "StructBraceStyle", GettextCatalog.GetString ("Struct declaration"), "struct StructDeclaration {};"); AddOption (bacePositionOptions, "EnumBraceStyle", GettextCatalog.GetString ("Enum declaration"), "enum EnumDeclaration { A, B, C };"); AddOption (bacePositionOptions, "MethodBraceStyle", GettextCatalog.GetString ("Method declaration"), "class ClassDeclaration { void MyMethod () {} };"); AddOption (bacePositionOptions, "ConstructorBraceStyle", GettextCatalog.GetString ("Constructor declaration"), "class ClassDeclaration { ClassDeclaration () {} };"); AddOption (bacePositionOptions, "DestructorBraceStyle", GettextCatalog.GetString ("Destructor declaration"), "class ClassDeclaration { ~ClassDeclaration () {} };"); AddOption (bacePositionOptions, "StatementBraceStyle", GettextCatalog.GetString ("Statements"), spaceExample); category = AddOption (bacePositionOptions, null, GettextCatalog.GetString ("Brace forcement"), null); AddOption (bacePositionOptions, category, "IfElseBraceForcement", GettextCatalog.GetString ("'if...else' statement"), @"class ClassDeclaration { void Test () { if (true) { cout << ""Hello World!"" << endl; } if (true) cout << ""Hello World!"" << endl; } };"); AddOption (bacePositionOptions, category, "ForBraceForcement", GettextCatalog.GetString ("'for' statement"), @"class ClassDeclaration { void Test () { for (int i = 0; i < 10; i++) { cout << ""Hello World "" + i << endl; } for (int i = 0; i < 10; i++) cout << ""Hello World "" + i << endl; } };"); AddOption (bacePositionOptions, category, "WhileBraceForcement", GettextCatalog.GetString ("'while' statement"), @"class ClassDeclaration { void Test () { int i = 0; while (i++ < 10) { cout << ""Hello World "" + i << endl; } while (i++ < 20) cout << ""Hello World "" + i << endl; } };"); treeviewBracePositions.ExpandAll (); #endregion #region New line options newLineOptions = new Gtk.TreeStore (typeof (string), typeof (string), typeof (string), typeof(bool), typeof(bool)); column = new TreeViewColumn (); // pixbuf column column.PackStart (pixbufCellRenderer, false); column.SetCellDataFunc (pixbufCellRenderer, RenderIcon); // text column cellRendererText.Ypad = 1; column.PackStart (cellRendererText, true); column.SetAttributes (cellRendererText, "text", 1); treeviewNewLines.Model = newLineOptions; treeviewNewLines.HeadersVisible = false; treeviewNewLines.Selection.Changed += TreeSelectionChanged; treeviewNewLines.AppendColumn (column); column = new TreeViewColumn (); cellRendererCombo = new CellRendererCombo (); cellRendererCombo.Ypad = 1; cellRendererCombo.Mode = CellRendererMode.Editable; cellRendererCombo.TextColumn = 1; cellRendererCombo.Model = comboBoxStore; cellRendererCombo.HasEntry = false; cellRendererCombo.Editable = !profile.IsBuiltIn; cellRendererCombo.Edited += new ComboboxEditedHandler (this, newLineOptions).ComboboxEdited; column.PackStart (cellRendererCombo, false); column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn); column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc); cellRendererToggle = new CellRendererToggle (); cellRendererToggle.Activatable = !profile.IsBuiltIn; cellRendererToggle.Ypad = 1; cellRendererToggle.Toggled += new CellRendererToggledHandler (this, newLineOptions).Toggled; column.PackStart (cellRendererToggle, false); column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn); column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc); treeviewNewLines.AppendColumn (column); AddOption (newLineOptions, "PlaceElseOnNewLine", GettextCatalog.GetString ("Place 'else' on new line"), simpleIf); AddOption (newLineOptions, "PlaceElseIfOnNewLine", GettextCatalog.GetString ("Place 'else if' on new line"), simpleIf); AddOption (newLineOptions, "PlaceCatchOnNewLine", GettextCatalog.GetString ("Place 'catch' on new line"), simpleCatch); AddOption (newLineOptions, "PlaceFinallyOnNewLine", GettextCatalog.GetString ("Place 'finally' on new line"), simpleCatch); AddOption (newLineOptions, "PlaceWhileOnNewLine", GettextCatalog.GetString ("Place 'while' on new line"), simpleDoWhile); AddOption (newLineOptions, "PlaceArrayInitializersOnNewLine", GettextCatalog.GetString ("Place array initializers on new line"), simpleArrayInitializer); treeviewNewLines.ExpandAll (); #endregion #region White space options whiteSpaceOptions = new Gtk.TreeStore (typeof (string), typeof (string), typeof (string), typeof(bool), typeof(bool)); column = new TreeViewColumn (); // pixbuf column column.PackStart (pixbufCellRenderer, false); column.SetCellDataFunc (pixbufCellRenderer, RenderIcon); // text column cellRendererText.Ypad = 1; column.PackStart (cellRendererText, true); column.SetAttributes (cellRendererText, "text", 1); treeviewInsertWhiteSpaceCategory.Model = whiteSpaceOptions; treeviewInsertWhiteSpaceCategory.HeadersVisible = false; treeviewInsertWhiteSpaceCategory.Selection.Changed += TreeSelectionChanged; treeviewInsertWhiteSpaceCategory.AppendColumn (column); column = new TreeViewColumn (); cellRendererCombo = new CellRendererCombo (); cellRendererCombo.Ypad = 1; cellRendererCombo.Mode = CellRendererMode.Editable; cellRendererCombo.TextColumn = 1; cellRendererCombo.Model = comboBoxStore; cellRendererCombo.HasEntry = false; cellRendererCombo.Editable = !profile.IsBuiltIn; cellRendererCombo.Edited += new ComboboxEditedHandler (this, whiteSpaceOptions).ComboboxEdited; column.PackStart (cellRendererCombo, false); column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn); column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc); cellRendererToggle = new CellRendererToggle (); cellRendererToggle.Activatable = !profile.IsBuiltIn; cellRendererToggle.Ypad = 1; cellRendererToggle.Toggled += new CellRendererToggledHandler (this, whiteSpaceOptions).Toggled; column.PackStart (cellRendererToggle, false); column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn); column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc); treeviewInsertWhiteSpaceCategory.AppendColumn (column); string example = @"class Example { void Test () { } void Test (int a, int b, int c) { } };"; category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Declarations"), example); AddOption (whiteSpaceOptions, category, "BeforeMethodDeclarationParentheses", GettextCatalog.GetString ("before opening parenthesis"), example); AddOption (whiteSpaceOptions, category, "WithinMethodDeclarationParentheses", GettextCatalog.GetString ("within parenthesis"), example); AddOption (whiteSpaceOptions, category, "BetweenEmptyMethodDeclarationParentheses", GettextCatalog.GetString ("between empty parenthesis"), example); AddOption (whiteSpaceOptions, category, "BeforeMethodDeclarationParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example); AddOption (whiteSpaceOptions, category, "AfterMethodDeclarationParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example); example = @"class Example { int a, b, c; };"; category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Fields"), example); AddOption (whiteSpaceOptions, category, "BeforeFieldDeclarationComma", GettextCatalog.GetString ("before comma in multiple field declarations"), example); AddOption (whiteSpaceOptions, category, "AfterFieldDeclarationComma", GettextCatalog.GetString ("after comma in multiple field declarations"), example); example = @"class Example { Example () { } Example (int a, int b, int c) { } };"; category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Constructors"), example); AddOption (whiteSpaceOptions, category, "BeforeConstructorDeclarationParentheses", GettextCatalog.GetString ("before opening parenthesis"), example); AddOption (whiteSpaceOptions, category, "WithinConstructorDeclarationParentheses", GettextCatalog.GetString ("within parenthesis"), example); AddOption (whiteSpaceOptions, category, "BetweenEmptyConstructorDeclarationParentheses", GettextCatalog.GetString ("between empty parenthesis"), example); AddOption (whiteSpaceOptions, category, "BeforeConstructorDeclarationParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example); AddOption (whiteSpaceOptions, category, "AfterConstructorDeclarationParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example); var upperCategory = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Statements"), null); category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'if'"), simpleIf); AddOption (whiteSpaceOptions, category, "IfParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleIf); category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'while'"), simpleWhile); AddOption (whiteSpaceOptions, category, "WhileParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleWhile); category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'for'"), simpleFor); AddOption (whiteSpaceOptions, category, "ForParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleFor); AddOption (whiteSpaceOptions, category, "SpacesBeforeForSemicolon", GettextCatalog.GetString ("before semicolon"), simpleFor); AddOption (whiteSpaceOptions, category, "SpacesAfterForSemicolon", GettextCatalog.GetString ("after semicolon"), simpleFor); category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'catch'"), simpleCatch); AddOption (whiteSpaceOptions, category, "CatchParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleCatch); category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'switch'"), switchExample); AddOption (whiteSpaceOptions, category, "SwitchParentheses", GettextCatalog.GetString ("before opening parenthesis"), switchExample); upperCategory = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Expressions"), null); example = @"class Example { void Method (int a, int b, int c) { // Do Stuff } void Test () { Method(1,2,3); } };"; category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Method invocations"), example); AddOption (whiteSpaceOptions, category, "BeforeMethodCallParentheses", GettextCatalog.GetString ("before opening parenthesis"), example); AddOption (whiteSpaceOptions, category, "WithinMethodCallParentheses", GettextCatalog.GetString ("within parenthesis"), example); AddOption (whiteSpaceOptions, category, "BetweenEmptyMethodCallParentheses", GettextCatalog.GetString ("between empty parenthesis"), example); AddOption (whiteSpaceOptions, category, "BeforeMethodCallParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example); AddOption (whiteSpaceOptions, category, "AfterMethodCallParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example); example = @"class Example { void Test () { int a[5], b = 1; a[0] = b; } };"; category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Element access"), example); AddOption (whiteSpaceOptions, category, "SpacesBeforeBrackets", GettextCatalog.GetString ("before opening bracket"), example); AddOption (whiteSpaceOptions, category, "SpacesWithinBrackets", GettextCatalog.GetString ("within brackets"), example); AddOption (whiteSpaceOptions, category, "BeforeBracketComma", GettextCatalog.GetString ("before comma in brackets"), example); AddOption (whiteSpaceOptions, category, "AfterBracketComma", GettextCatalog.GetString ("after comma in brackets"), example); category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Parentheses"), operatorExample); AddOption (whiteSpaceOptions, category, "WithinParentheses", GettextCatalog.GetString ("within parenthesis"), operatorExample); example = @"class ClassDeclaration { void Test (char c) { int i = (int)c; } };"; category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Type cast"), example); AddOption (whiteSpaceOptions, category, "WithinCastParentheses", GettextCatalog.GetString ("within parenthesis"), example); AddOption (whiteSpaceOptions, category, "SpacesAfterTypecast", GettextCatalog.GetString ("after type cast"), example); example = @"class ClassDeclaration { void Test () { int i = sizeof (ClassDeclaration); } };"; category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'sizeof'"), example); AddOption (whiteSpaceOptions, category, "BeforeSizeOfParentheses", GettextCatalog.GetString ("before opening parenthesis"), example); AddOption (whiteSpaceOptions, category, "WithinSizeOfParentheses", GettextCatalog.GetString ("within parenthesis"), example); category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Around Operators"), operatorExample); AddOption (whiteSpaceOptions, category, "AroundAssignmentParentheses", GettextCatalog.GetString ("Assignment (=, +=, -=, ...)"), operatorExample); AddOption (whiteSpaceOptions, category, "AroundLogicalOperatorParentheses", GettextCatalog.GetString ("Logical (&&, ||) operators"), operatorExample); AddOption (whiteSpaceOptions, category, "AroundEqualityOperatorParentheses", GettextCatalog.GetString ("Equality (==, !=) operators"), operatorExample); AddOption (whiteSpaceOptions, category, "AroundRelationalOperatorParentheses", GettextCatalog.GetString ("Relational (<, >, <=, >=) operators"), operatorExample); AddOption (whiteSpaceOptions, category, "AroundBitwiseOperatorParentheses", GettextCatalog.GetString ("Bitwise (&, |, ^, ~) operators"), operatorExample); AddOption (whiteSpaceOptions, category, "AroundAdditiveOperatorParentheses", GettextCatalog.GetString ("Additive (+, -) operators"), operatorExample); AddOption (whiteSpaceOptions, category, "AroundMultiplicativeOperatorParentheses", GettextCatalog.GetString ("Multiplicative (*, /, %) operators"), operatorExample); AddOption (whiteSpaceOptions, category, "AroundShiftOperatorParentheses", GettextCatalog.GetString ("Shift (<<, >>) operators"), operatorExample); AddOption (whiteSpaceOptions, category, "AroundNullCoalescingOperator", GettextCatalog.GetString ("Null coalescing (??) operator"), operatorExample); category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Conditional Operator (?:)"), condOpExample); AddOption (whiteSpaceOptions, category, "ConditionalOperatorBeforeConditionSpace", GettextCatalog.GetString ("before '?'"), condOpExample); AddOption (whiteSpaceOptions, category, "ConditionalOperatorAfterConditionSpace", GettextCatalog.GetString ("after '?'"), condOpExample); AddOption (whiteSpaceOptions, category, "ConditionalOperatorBeforeSeparatorSpace", GettextCatalog.GetString ("before ':'"), condOpExample); AddOption (whiteSpaceOptions, category, "ConditionalOperatorAfterSeparatorSpace", GettextCatalog.GetString ("after ':'"), condOpExample); example = @"class ClassDeclaration { string[][] field; int[] test; }"; category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Array Declarations"), example); AddOption (whiteSpaceOptions, category, "SpacesBeforeArrayDeclarationBrackets", GettextCatalog.GetString ("before opening bracket"), condOpExample); /* whiteSpaceOptions= new ListStore (typeof (Option), typeof (bool), typeof (bool)); column = new TreeViewColumn (); // text column column.PackStart (cellRendererText, true); column.SetCellDataFunc (cellRendererText, delegate (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) { ((CellRendererText)cell).Text = ((Option)model.GetValue (iter, 0)).DisplayName; }); treeviewInsertWhiteSpaceOptions.AppendColumn (column); column = new TreeViewColumn (); cellRendererCombo = new CellRendererCombo (); cellRendererCombo.Ypad = 1; cellRendererCombo.Mode = CellRendererMode.Editable; cellRendererCombo.TextColumn = 1; cellRendererCombo.Model = comboBoxStore; cellRendererCombo.HasEntry = false; cellRendererCombo.Editable = !profile.IsBuiltIn; cellRendererCombo.Edited += delegate(object o, EditedArgs args) { TreeIter iter; var model = whiteSpaceOptions; if (model.GetIterFromString (out iter, args.Path)) { var option = (Option)model.GetValue (iter, 0); PropertyInfo info = GetPropertyByName (option.PropertyName); if (info == null) return; var value = Enum.Parse (info.PropertyType, args.NewText); info.SetValue (profile, value, null); UpdateExample (texteditor.Document.Text); } }; column.PackStart (cellRendererCombo, false); column.SetAttributes (cellRendererCombo, "visible", 2); column.SetCellDataFunc (cellRendererCombo, delegate (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) { ((CellRendererCombo)cell).Text = GetValue (((Option)model.GetValue (iter, 0)).PropertyName).ToString (); }); cellRendererToggle = new CellRendererToggle (); cellRendererToggle.Activatable = !profile.IsBuiltIn; cellRendererToggle.Ypad = 1; cellRendererToggle.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; var model = whiteSpaceOptions; if (model.GetIterFromString (out iter, args.Path)) { var option = (Option)model.GetValue (iter, 0); PropertyInfo info = GetPropertyByName (option.PropertyName); if (info == null || info.PropertyType != typeof(bool)) return; bool value = (bool)info.GetValue (this.profile, null); info.SetValue (profile, !value, null); UpdateExample (texteditor.Document.Text); } }; column.PackStart (cellRendererToggle, false); column.SetAttributes (cellRendererToggle, "visible", 1); column.SetCellDataFunc (cellRendererToggle, delegate (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) { ((CellRendererToggle)cell).Active = (bool)GetValue (((Option)model.GetValue (iter, 0)).PropertyName); }); treeviewInsertWhiteSpaceOptions.AppendColumn (column); treeviewInsertWhiteSpaceOptions.Model = whiteSpaceOptions;*/ treeviewInsertWhiteSpaceCategory.ExpandAll (); #endregion #region Blank line options entryBeforeFirstDeclaration.Text = profile.BlankLinesBeforeFirstDeclaration.ToString (); entryBetweenTypes.Text = profile.BlankLinesBetweenTypes.ToString (); entryBetweenFields.Text = profile.BlankLinesBetweenFields.ToString (); entryBetweenMembers.Text = profile.BlankLinesBetweenMembers.ToString (); entryBeforeFirstDeclaration.Changed += HandleBlankLinesChanged; entryBetweenTypes.Changed += HandleBlankLinesChanged; entryBetweenFields.Changed += HandleBlankLinesChanged; entryBetweenMembers.Changed += HandleBlankLinesChanged; #endregion }