예제 #1
0
        static void LoadSettings_EndOfLine(CustomEditorOptions options, FileConfiguration config)
        {
            if (config.EndOfLine == null)
            {
                return;
            }

            string eolMarker = null;

            switch (config.EndOfLine.Value)
            {
            case EndOfLine.CR:
                eolMarker = "\r";
                break;

            case EndOfLine.LF:
                eolMarker = "\n";
                break;

            case EndOfLine.CRLF:
                eolMarker = "\r\n";
                break;
            }
            if (eolMarker == null)
            {
                return;
            }

            options.OverrideDocumentEolMarker = true;
            options.DefaultEolMarker          = eolMarker;
        }
예제 #2
0
        public static void LoadSettings(Document doc, FileConfiguration config)
        {
            if (doc == null)
            {
                return;
            }
            if (config == null)
            {
                return;
            }
            if (config.Properties.Count == 0)
            {
                return;
            }

            //Log.Info(Log.Target.Console,
            //         $"LoadSettings doc={doc} name=\"{doc.Name}\" props={config.Properties.Count}"
            //);

            TextEditor editor = doc.Editor;

            if (editor == null)
            {
                return;
            }

            CustomEditorOptions options = new CustomEditorOptions(editor.Options);

            LoadSettings_EndOfLine(options, config);
            LoadSettings_IndentStyle(options, config);
            LoadSettings_IndentSizeTabWidth(options, config);
            editor.Options = options;
        }
예제 #3
0
        public BlameWidget(VersionControlDocumentInfo info)
        {
            GtkWorkarounds.FixContainerLeak(this);

            this.info = info;
            var textView = info.Controller.GetContent <ITextView> ();

            vAdjustment          = new Adjustment(0, 0, 0, 0, 0, 0);
            vAdjustment.Changed += HandleAdjustmentChanged;

            vScrollBar = new VScrollbar(vAdjustment);
            AddChild(vScrollBar);

            hAdjustment          = new Adjustment(0, 0, 0, 0, 0, 0);
            hAdjustment.Changed += HandleAdjustmentChanged;

            hScrollBar = new HScrollbar(hAdjustment);
            AddChild(hScrollBar);

            var doc = new TextDocument(textView.TextSnapshot.GetText())
            {
                IsReadOnly = true,
                MimeType   = IdeServices.DesktopService.GetMimeTypeForContentType(textView.TextBuffer.ContentType)
            };
            var options = new CustomEditorOptions(DefaultSourceEditorOptions.Instance);

            options.TabsToSpaces = false;

            editor = new MonoTextEditor(doc, new SourceEditor.StyledSourceEditorOptions(options));

            AddChild(editor);
            editor.SetScrollAdjustments(hAdjustment, vAdjustment);

            overview = new BlameRenderer(this);
            AddChild(overview);

            this.DoubleBuffered          = true;
            editor.Painted              += HandleEditorExposeEvent;
            editor.EditorOptionsChanged += delegate {
                overview.OptionsChanged();
            };
            editor.Caret.PositionChanged += ComparisonWidget.CaretPositionChanged;
            editor.FocusInEvent          += ComparisonWidget.EditorFocusIn;
            editor.Document.Folded       += delegate {
                QueueDraw();
            };
            editor.Document.FoldTreeUpdated += delegate {
                QueueDraw();
            };
            editor.DoPopupMenu = ShowPopup;
            Show();
        }
예제 #4
0
        static void LoadSettings_IndentStyle(CustomEditorOptions options, FileConfiguration config)
        {
            if (config.IndentStyle == null)
            {
                return;
            }

            switch (config.IndentStyle.Value)
            {
            case EditorConfig.Core.IndentStyle.Tab:
                options.TabsToSpaces = false;
                break;

            case EditorConfig.Core.IndentStyle.Space:
                options.TabsToSpaces = true;
                break;
            }
        }
        public async Task TestBug16174_AutoIndent()
        {
            await Simulate("namespace Foo\n{\n\tpublic class Bar\n\t{\n$\t\tvoid Test()\n\t\t{\n\t\t}\n\t}\n}\n", (content, ext) => {
                var options         = new CustomEditorOptions();
                options.IndentStyle = IndentStyle.Auto;
                ext.Editor.Options  = options;
                EditActions.NewLine(ext.Editor);
                ext.KeyPress(KeyDescriptor.FromGtk(Gdk.Key.Return, '\n', Gdk.ModifierType.None));

                var newText = content.Text;

                var expected = "namespace Foo\n{\n\tpublic class Bar\n\t{\n\n\t\tvoid Test()\n\t\t{\n\t\t}\n\t}\n}\n";
                if (newText != expected)
                {
                    Console.WriteLine(newText);
                }
                Assert.AreEqual(expected, newText);
            });
        }
예제 #6
0
        static void LoadSettings_IndentSizeTabWidth(CustomEditorOptions options, FileConfiguration config)
        {
            if (config.IndentSize.UseTabWidth &&
                config.TabWidth == null &&
                config.IndentSize.NumberOfColumns == null)
            {
                return;
            }

            if (!config.IndentSize.UseTabWidth &&
                config.IndentSize.NumberOfColumns == null)
            {
                return;
            }

            //int size = options.IndentationSize;
            int size = options.TabSize;

            if (config.IndentSize.UseTabWidth)
            {
                if (config.TabWidth != null)
                {
                    size = config.TabWidth.Value;
                }
                else if (config.IndentSize.NumberOfColumns != null)
                {
                    size = config.IndentSize.NumberOfColumns.Value;
                }
            }
            else
            {
                size = config.IndentSize.NumberOfColumns.Value;
            }

            //options.IndentationSize = size;
            options.TabSize = size;
        }
        internal SignatureChangeDialog() : base(GettextCatalog.GetString("Change Signature"), IdeApp.Workbench.RootWindow, DialogFlags.Modal)
        {
            this.Build();

            previewEditor            = TextEditorFactory.CreateNewEditor(TextEditorFactory.CreateNewDocument());
            previewEditor.IsReadOnly = true;
            previewEditor.MimeType   = "text/x-csharp";
            var options = new CustomEditorOptions {
                ShowLineNumberMargin = false,
                ShowFoldMargin       = false,
                ShowIconMargin       = false,
                ShowRuler            = false,
                EditorTheme          = DefaultSourceEditorOptions.Instance.EditorTheme,
                FontName             = DefaultSourceEditorOptions.Instance.FontName
            };

            previewEditor.Options = options;
            vbox4.PackStart(previewEditor, true, true, 0);
            vbox4.ShowAll();

            var tr  = new CellRendererText();
            var col = this.treeviewParameterList.AppendColumn(GettextCatalog.GetString("Modifier"), tr);

            col.SetCellDataFunc(tr, new TreeCellDataFunc((column, cell, model, iter) => {
                var param = model.GetValue(iter, 0) as IParameterSymbol;
                if (param == parameters.ThisParameter)
                {
                    ((CellRendererText)cell).Text = "this";
                    return;
                }
                if (param == parameters.ParamsParameter)
                {
                    ((CellRendererText)cell).Text = "params";
                    return;
                }
                switch (param.RefKind)
                {
                case RefKind.Out:
                    ((CellRendererText)cell).Text = "out";
                    break;

                case RefKind.Ref:
                    ((CellRendererText)cell).Text = "ref";
                    break;

                default:
                    ((CellRendererText)cell).Text = "";
                    break;
                }
            }));

            col = this.treeviewParameterList.AppendColumn(GettextCatalog.GetString("Type"), tr);
            col.SetCellDataFunc(tr, new TreeCellDataFunc((column, cell, model, iter) => {
                var param = model.GetValue(iter, 0) as IParameterSymbol;
                ((CellRendererText)cell).Text = param.Type.ToDisplayString();
            }));

            col = this.treeviewParameterList.AppendColumn(GettextCatalog.GetString("Parameter"), tr);
            col.SetCellDataFunc(tr, new TreeCellDataFunc((column, cell, model, iter) => {
                var param = model.GetValue(iter, 0) as IParameterSymbol;
                ((CellRendererText)cell).Text = param.Name;
            }));

            col = this.treeviewParameterList.AppendColumn(GettextCatalog.GetString("Standard"), tr);
            col.SetCellDataFunc(tr, new TreeCellDataFunc((column, cell, model, iter) => {
                var param = model.GetValue(iter, 0) as IParameterSymbol;
                ((CellRendererText)cell).Text = param.HasExplicitDefaultValue ? param.ExplicitDefaultValue.ToString() : "";
            }));
            this.treeviewParameterList.Model              = store;
            this.treeviewParameterList.Selection.Changed += delegate {
                UpdateSensitivity();
            };

            this.buttonUp.Clicked += delegate {
                Gtk.TreeIter iter, iter2;
                if (!treeviewParameterList.Selection.GetSelected(out iter))
                {
                    return;
                }
                var path = store.GetPath(iter);
                if (!path.Prev())
                {
                    return;
                }
                if (!store.GetIter(out iter2, path))
                {
                    return;
                }
                store.MoveBefore(iter, iter2);
                UpdatePreview();
            };

            this.buttonDown.Clicked += delegate {
                Gtk.TreeIter iter, iter2;
                if (!treeviewParameterList.Selection.GetSelected(out iter))
                {
                    return;
                }
                var path = store.GetPath(iter);
                path.Next();
                if (!store.GetIter(out iter2, path))
                {
                    return;
                }
                store.MoveAfter(iter, iter2);
                UpdatePreview();
            };

            this.buttonRemove.Clicked += delegate {
                Gtk.TreeIter iter;
                if (!treeviewParameterList.Selection.GetSelected(out iter))
                {
                    return;
                }
                store.Remove(ref iter);
                UpdatePreview();
            };

            this.buttonRefresh.Clicked += delegate {
                Refresh();
            };
        }
예제 #8
0
        public BlameWidget(VersionControlDocumentInfo info)
        {
            GtkWorkarounds.FixContainerLeak(this);

            this.info = info;
            var sourceEditor = info.Document.GetContent <MonoDevelop.SourceEditor.SourceEditorView> ();

            vAdjustment = new Adjustment(
                sourceEditor.TextEditor.VAdjustment.Value,
                sourceEditor.TextEditor.VAdjustment.Lower,
                sourceEditor.TextEditor.VAdjustment.Upper,
                sourceEditor.TextEditor.VAdjustment.StepIncrement,
                sourceEditor.TextEditor.VAdjustment.PageIncrement,
                sourceEditor.TextEditor.VAdjustment.PageSize);
            vAdjustment.Changed += HandleAdjustmentChanged;

            vScrollBar = new VScrollbar(vAdjustment);
            AddChild(vScrollBar);

            hAdjustment = new Adjustment(
                sourceEditor.TextEditor.HAdjustment.Value,
                sourceEditor.TextEditor.HAdjustment.Lower,
                sourceEditor.TextEditor.HAdjustment.Upper,
                sourceEditor.TextEditor.HAdjustment.StepIncrement,
                sourceEditor.TextEditor.HAdjustment.PageIncrement,
                sourceEditor.TextEditor.HAdjustment.PageSize);
            hAdjustment.Changed += HandleAdjustmentChanged;

            hScrollBar = new HScrollbar(hAdjustment);
            AddChild(hScrollBar);

            var doc = new TextDocument(sourceEditor.TextEditor.Document.Text)
            {
                IsReadOnly = true,
                MimeType   = sourceEditor.TextEditor.Document.MimeType,
            };
            var options = new CustomEditorOptions(DefaultSourceEditorOptions.Instance);

            options.TabsToSpaces = false;

            editor = new MonoTextEditor(doc, new SourceEditor.StyledSourceEditorOptions(options));

            AddChild(editor);
            editor.SetScrollAdjustments(hAdjustment, vAdjustment);

            overview = new BlameRenderer(this);
            AddChild(overview);

            this.DoubleBuffered          = true;
            editor.Painted              += HandleEditorExposeEvent;
            editor.EditorOptionsChanged += delegate {
                overview.OptionsChanged();
            };
            editor.Caret.PositionChanged += ComparisonWidget.CaretPositionChanged;
            editor.FocusInEvent          += ComparisonWidget.EditorFocusIn;
            editor.Document.Folded       += delegate {
                QueueDraw();
            };
            editor.Document.FoldTreeUpdated += delegate {
                QueueDraw();
            };
            editor.DoPopupMenu = ShowPopup;
            Show();
        }