public DocumentScript(IDocument document, CSharpFormattingOptions formattingOptions, TextEditorOptions options) : base(formattingOptions, options) { this.originalDocument = document.CreateDocumentSnapshot(); this.currentDocument = document; Debug.Assert(currentDocument.Version.CompareAge(originalDocument.Version) == 0); this.undoGroup = document.OpenUndoGroup(); }
/// <summary> /// Creates a new HtmlOptions instance that copies applicable options from the <see cref="TextEditorOptions"/>. /// </summary> public HtmlOptions(TextEditorOptions options) : this() { if (options == null) { throw new ArgumentNullException("options"); } this.TabSize = options.IndentationSize; }
static CacheIndentEngine CreateIndentEngine(IDocument document, TextEditorOptions options) { // TODO Use project-specific formatter settings. But how to get a project from here? var formattingOptions = CSharpFormattingOptionsPersistence.GlobalOptions; var engine = new CSharpIndentEngine(document, options, formattingOptions.OptionsContainer.GetEffectiveOptions()); return(new CacheIndentEngine(engine)); }
public LocalizationSettingWindow(Dictionary <string, XmlObjectsListWrapper> loadedListWrappers) { InitializeComponent(); Closing += new CancelEventHandler(LocalizatonSettingWindow_Closing); SetupExceptionHandling(); AddTooltips(); StartingMod = Properties.Settings.Default.ModTagSetting; WindowTitle = StartingMod.ToString(); this.Title = GetTitleForWindow(); this.LoadedListWrappers = loadedListWrappers; string pathToModLocalizationFile = XmlFileManager.ModConfigOutputPath + LocalizationFileObject.LOCALIZATION_FILE_NAME; ModLocalizationGridUserControl = new LocalizationGridUserControl(pathToModLocalizationFile); GridAsCSVAfterUpdate = ModLocalizationGridUserControl.Maingrid.GridAsCSV(); List <string> allCustomTagDirectories = XmlFileManager.GetCustomModFoldersInOutput(); foreach (string nextModTag in allCustomTagDirectories) { ModSelectionComboBox.AddUniqueValueTo(nextModTag); } ModSelectionComboBox.SelectedItem = Properties.Settings.Default.ModTagSetting; ModSelectionComboBox.LostFocus += ModSelectionComboBox_LostFocus; ModSelectionComboBox.PreviewKeyDown += ModSelectionComboBox_PreviewKeyDown; ModLocalizationScrollViewer.Content = ModLocalizationGridUserControl; string pathToGameLocalizationFile = XmlFileManager.LoadedFilesPath + LocalizationFileObject.LOCALIZATION_FILE_NAME; GameLocalizationFile = new LocalizationFileObject(pathToGameLocalizationFile); TextEditorOptions newOptions = new TextEditorOptions { EnableRectangularSelection = true, EnableTextDragDrop = true, HighlightCurrentLine = true, ShowTabs = true }; LocalizationPreviewBox.ShowLineNumbers = true; LocalizationPreviewBox.TextArea.Options = newOptions; LocalizationPreviewBox.Text = ModLocalizationGridUserControl.Maingrid.GridAsCSV(); LocalizationPreviewBox.LostFocus += LocalizationPreviewBox_LostFocus; SearchPanel.Install(LocalizationPreviewBox); ModLocalizationScrollViewer.GotFocus += Maingrid_GotOrLostFocus; ModLocalizationScrollViewer.LostFocus += Maingrid_GotOrLostFocus; SortedSet <string> gameFileKeysSorted = GameLocalizationFile.HeaderKeyToCommonValuesMap.GetValueOrDefault(GameLocalizationFile.KeyColumn); List <string> gameFileKeys = new List <string>(gameFileKeysSorted); GameKeySelectionComboBox.SetComboBox(gameFileKeys); GameKeySelectionComboBox.IsEditable = true; GameKeySelectionComboBox.DropDownClosed += GameKeySelectionComboBox_DropDownClosed; GameKeySelectionComboBox.PreviewKeyDown += GameKeySelectionComboBox_PreviewKeyDown; SetBackgroundColor(); }
public DocumentScript(IDocument document, CSharpFormattingOptions formattingOptions, TextEditorOptions options) : base(formattingOptions) { this.originalDocument = document.CreateDocumentSnapshot(); this.currentDocument = document; this.options = options; this.eolMarker = options.EolMarker; Debug.Assert(currentDocument.Version.CompareAge(originalDocument.Version) == 0); this.undoGroup = document.OpenUndoGroup(); }
static string FormattedString(string filePath) { var readed = File.ReadAllText(filePath); var option = FormattingOptionsFactory.CreateMono(); var textEditorOption = new TextEditorOptions(); var formatter = new CSharpFormatter(option, textEditorOption); return(formatter.Format(readed)); }
protected Script(CSharpFormattingOptions formattingOptions, TextEditorOptions options) { if (formattingOptions == null) throw new ArgumentNullException("formattingOptions"); if (options == null) throw new ArgumentNullException("options"); this.formattingOptions = formattingOptions; this.options = options; }
public OmniSharpConfiguration() { PathReplacements = new List <PathReplacement>(); Defines = new List <string>(); IgnoredCodeIssues = new List <string>(); TextEditorOptions = new TextEditorOptions(); TextEditorOptions.TabsToSpaces = true; CSharpFormattingOptions = FormattingOptionsFactory.CreateAllman(); }
public void AddNewTab(string fileName, bool switchToNew) { var textEditorOptions = new TextEditorOptions { AllowScrollBelowDocument = true, ConvertTabsToSpaces = true, CutCopyWholeLine = true, EnableEmailHyperlinks = true, EnableHyperlinks = true }; var textEditor = new TextEditor { Options = textEditorOptions, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, Width = NaN, Height = NaN, Background = new SolidColorBrush(Color.FromRgb(30, 30, 30)), Foreground = new SolidColorBrush(Color.FromRgb(190, 190, 190)), HorizontalScrollBarVisibility = ScrollBarVisibility.Auto, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, FontFamily = new FontFamily("Lucida Console"), FontSize = 12, ShowLineNumbers = true, Padding = new Thickness(3) }; var atlasTabItem = new AtlasTabItem { Header = "new", Content = textEditor }; if (!string.IsNullOrEmpty(fileName)) { try { textEditor.Text = File.ReadAllText(fileName); atlasTabItem.Header = Path.GetFileName(fileName); } catch { textEditor.Text = string.Empty; } } TabControl.Items.Add(atlasTabItem); if (switchToNew) { TabControl.SelectedIndex = TabControl.Items.Count - 1; textEditor.Focus(); } }
public CodeEditor() { FontFamily = new FontFamily("Consolas"); FontSize = 12; ShowLineNumbers = true; Options = new TextEditorOptions { ConvertTabsToSpaces = true }; }
public void IndentWithSingleTab() { var options = new TextEditorOptions { IndentationSize = 4, ConvertTabsToSpaces = false }; Assert.AreEqual("\t", options.IndentationString); Assert.AreEqual("\t", options.GetIndentationString(2)); Assert.AreEqual("\t", options.GetIndentationString(3)); Assert.AreEqual("\t", options.GetIndentationString(4)); Assert.AreEqual("\t", options.GetIndentationString(5)); Assert.AreEqual("\t", options.GetIndentationString(6)); }
public TextEditorEx() { FontSize = 12; FontFamily = new FontFamily("Consolas"); Options = new TextEditorOptions { IndentationSize = 3, ConvertTabsToSpaces = true }; }
/*public static string ApplyChanges (string text, List<TextReplaceAction> changes) * { * changes.Sort ((x, y) => y.Offset.CompareTo (x.Offset)); * StringBuilder b = new StringBuilder(text); * foreach (var change in changes) { * //Console.WriteLine ("---- apply:" + change); * // Console.WriteLine (adapter.Text); * if (change.Offset > b.Length) * continue; * b.Remove(change.Offset, change.RemovedChars); * b.Insert(change.Offset, change.InsertedText); * } * // Console.WriteLine ("---result:"); * // Console.WriteLine (adapter.Text); * return b.ToString(); * }*/ static TextEditorOptions GetActualOptions(TextEditorOptions options) { if (options == null) { options = new TextEditorOptions(); options.EolMarker = "\n"; options.WrapLineLength = 80; } return(options); }
/// <summary> /// Default constructor that configures the Completion form. /// </summary> public EditorView(ViewBase owner) : base(owner) { scroller = new ScrolledWindow(); textEditor = new TextEditor(); scroller.Add(textEditor); _mainWidget = scroller; TextEditorOptions options = new TextEditorOptions(); options.EnableSyntaxHighlighting = true; options.ColorScheme = "Visual Studio"; options.HighlightCaretLine = true; textEditor.Options = options; /* * CompletionForm = new Form(); * CompletionForm.TopLevel = false; * CompletionForm.FormBorderStyle = FormBorderStyle.None; * * CompletionView = new ListView(); * CompletionView.Dock = DockStyle.Fill; * CompletionForm.Controls.Add(this.CompletionView); * CompletionView.KeyDown += new KeyEventHandler(this.OnContextListKeyDown); * CompletionView.KeyUp += new KeyEventHandler(this.OnContextListKeyUp); * CompletionView.MouseDoubleClick += new MouseEventHandler(this.OnComtextListMouseDoubleClick); * CompletionForm.StartPosition = FormStartPosition.Manual; * CompletionView.Leave += new EventHandler(this.OnLeaveCompletion); * CompletionView.View = View.Details; * CompletionView.MultiSelect = false; * * // add some columns * ColumnHeader col1 = new ColumnHeader(); * col1.Text = "Item"; * col1.Width = 150; * CompletionView.Columns.Add(col1); * ColumnHeader col2 = new ColumnHeader(); * col2.Text = "Units"; * col2.Width = 50; * CompletionView.Columns.Add(col2); * ColumnHeader col3 = new ColumnHeader(); * col3.Text = "Type"; * col3.Width = 60; * CompletionView.Columns.Add(col3); * ColumnHeader col4 = new ColumnHeader(); * col4.Text = "Descr"; * col4.Width = 200; * CompletionView.Columns.Add(col4); * CompletionView.SmallImageList = imageList1; * * TextBox.ActiveTextAreaControl.TextArea.KeyPress += this.OnKeyPress; * TextBox.ActiveTextAreaControl.TextArea.KeyDown += this.OnKeyDown; * IntelliSenseChars = "."; * this.searchValue = string.Empty; * timer1.Interval = 3000; */ }
/// <summary> /// Default constructor to set up event handlers. /// </summary> public CodeEditor() { // Default options. FontSize = 12; FontFamily = new FontFamily("Consolas"); Options = new TextEditorOptions { IndentationSize = 3, ConvertTabsToSpaces = true }; }
public CodeEditorView(TextEditorOptions options) { _syncContext = SynchronizationContext.Current; Options = options ?? new TextEditorOptions { ConvertTabsToSpaces = true, AllowScrollBelowDocument = true, IndentationSize = 4, EnableEmailHyperlinks = false, }; ShowLineNumbers = true; MouseHover += OnMouseHover; MouseHoverStopped += OnMouseHoverStopped; TextArea.TextView.VisualLinesChanged += OnVisualLinesChanged; TextArea.TextEntering += OnTextEntering; TextArea.TextEntered += OnTextEntered; TextArea.MouseWheel += OnTextArea_MouseWheel; ToolTipService.SetInitialShowDelay(this, 0); // SearchReplacePanel.Install(this); var commandBindings = TextArea.CommandBindings; var deleteLineCommand = commandBindings.OfType <CommandBinding>().FirstOrDefault(x => x.Command == AvalonEditCommands.DeleteLine); if (deleteLineCommand != null) { commandBindings.Remove(deleteLineCommand); } _foldingManager = FoldingManager.Install(TextArea); AsyncToolTipRequest = AsyncToolTipRequestDefaultImpl; { // responsible for rendering brace matches _bracketHighlightRenderer = new BracketHighlightRenderer(TextArea.TextView); TextArea.Caret.PositionChanged += HighlightBrackets; } _textMarkerService = new TextMarkerService(this); // _errorMargin = new ErrorMargin { Visibility = Visibility.Collapsed, MarkerBrush = TryFindResource("ExceptionMarker") as Brush, Width = 10 }; TextArea.TextView.BackgroundRenderers.Add(_textMarkerService); TextArea.TextView.LineTransformers.Add(_textMarkerService); //this.TextArea.LeftMargins.Insert(0, _errorMargin); //this.PreviewMouseWheel += EditorOnPreviewMouseWheel; //this.TextArea.Caret.PositionChanged += CaretOnPositionChanged; ReferencesHighlightRenderer_Initialize(); BuildTextAreaContextMenu(); }
private JustEnoughVi.JustEnoughVi InitTest(string source) { var options = new TextEditorOptions { TabsToSpaces = true, }; var editor = Create(source, options); var plugin = new JustEnoughVi.JustEnoughVi(); plugin.Initialize(editor); return(plugin); }
/// <summary> /// Class constructor /// </summary> protected DocumentViewModel() { _Document = new TextDocument(string.Empty); var items = new ObservableCollection <UnitComboLib.Models.ListItem>(GenerateScreenUnitList()); SizeUnitLabel = UnitComboLib.UnitViewModeService.CreateInstance(items, new ScreenConverter(), 0); _FileEncoding = Encoding.Default; _TextOptions = new TextEditorOptions(); _TextOptions.AllowToggleOverstrikeMode = true; }
public SDRefactoringContext(ITextSource textSource, AlAstResolver resolver, TextLocation location, int selectionStart, int selectionLength, CancellationToken cancellationToken) : base(resolver, cancellationToken) { this.resolver = resolver; this.textSource = textSource; this.document = textSource as IDocument; this.selectionStart = selectionStart; this.selectionLength = selectionLength; this.location = location; this.editorOptions = SD.EditorControlService.GlobalOptions.ToEditorOptions(); InitializeServices(); }
void OnOptionsChanged(TextEditorOptions oldValue, TextEditorOptions newValue) { if (oldValue != null) { PropertyChangedWeakEventManager.RemoveListener(oldValue, this); } if (newValue != null) { PropertyChangedWeakEventManager.AddListener(newValue, this); } OnOptionChanged(new PropertyChangedEventArgs(null)); }
public void CustomizeEditorOptions(TextEditorOptions editorOptions) { int? indentationSize = GetEffectiveIndentationSize(); if (indentationSize.HasValue) { editorOptions.IndentSize = indentationSize.Value; editorOptions.TabSize = indentationSize.Value; editorOptions.ContinuationIndent = indentationSize.Value; } bool? convertTabsToSpaces = GetEffectiveConvertTabsToSpaces(); if (convertTabsToSpaces.HasValue) editorOptions.TabsToSpaces = convertTabsToSpaces.Value; }
/// <summary> /// Formats the specified part of the document. /// </summary> public static void Format(ITextEditor editor, int offset, int length, CSharpFormattingOptionsContainer optionsContainer) { TextEditorOptions editorOptions = editor.ToEditorOptions(); optionsContainer.CustomizeEditorOptions(editorOptions); var formatter = new CSharpFormatter(optionsContainer.GetEffectiveOptions(), editorOptions); formatter.AddFormattingRegion(new DomRegion(editor.Document.GetLocation(offset), editor.Document.GetLocation(offset + length))); var changes = formatter.AnalyzeFormatting(editor.Document, SyntaxTree.Parse(editor.Document)); changes.ApplyChanges(offset, length); }
public DrawingPage() { InitializeComponent(); _saveXaml = true; _wpfSettings = new WpfDrawingSettings(); _wpfSettings.CultureInfo = _wpfSettings.NeutralCultureInfo; _fileReader = new FileSvgReader(_wpfSettings); _fileReader.SaveXaml = _saveXaml; _fileReader.SaveZaml = false; _mouseHandlingMode = ZoomPanMouseHandlingMode.SelectPoint; //string workDir = Path.Combine(Path.GetDirectoryName( // System.Reflection.Assembly.GetExecutingAssembly().Location), TemporalDirName); string workDir = Path.Combine(Path.GetFullPath("..\\"), TemporalDirName); _workingDir = new DirectoryInfo(workDir); _embeddedImages = new List <EmbeddedImageSerializerArgs>(); _embeddedImageVisitor = new EmbeddedImageSerializerVisitor(true); _wpfSettings.Visitors.ImageVisitor = _embeddedImageVisitor; _embeddedImageVisitor.ImageCreated += OnEmbeddedImageCreated; textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"); TextEditorOptions options = textEditor.Options; if (options != null) { //options.AllowScrollBelowDocument = true; options.EnableHyperlinks = true; options.EnableEmailHyperlinks = true; options.EnableVirtualSpace = false; options.HighlightCurrentLine = true; options.ShowSpaces = true; options.ShowTabs = true; options.ShowEndOfLine = true; } textEditor.ShowLineNumbers = true; textEditor.WordWrap = true; _foldingManager = FoldingManager.Install(textEditor.TextArea); _foldingStrategy = new XmlFoldingStrategy(); this.Loaded += OnPageLoaded; this.Unloaded += OnPageUnloaded; this.SizeChanged += OnPageSizeChanged; }
public SDRefactoringContext(ITextEditor editor, AlAstResolver resolver, TextLocation location, CancellationToken cancellationToken = default(CancellationToken)) : base(resolver, cancellationToken) { this.resolver = resolver; this.editor = editor; this.textSource = editor.Document; this.document = editor.Document; this.selectionStart = editor.SelectionStart; this.selectionLength = editor.SelectionLength; this.location = location; this.editorOptions = editor.ToEditorOptions(); InitializeServices(); }
public void Test(string source, string keys, string expected, Type expectedMode) { var options = new TextEditorOptions(); options.TabsToSpaces = true; var editor = Create(source, options); var plugin = new JustEnoughVi.JustEnoughVi(); plugin.Initialize(editor); ProcessKeys(keys, plugin); Check(plugin, expected, expectedMode); }
public void IndentWith4Spaces() { var options = new TextEditorOptions { IndentationSize = 4, ConvertTabsToSpaces = true }; Assert.AreEqual(" ", options.IndentationString); Assert.AreEqual(" ", options.GetIndentationString(2)); Assert.AreEqual(" ", options.GetIndentationString(3)); Assert.AreEqual(" ", options.GetIndentationString(4)); Assert.AreEqual(" ", options.GetIndentationString(5)); Assert.AreEqual(" ", options.GetIndentationString(6)); }
protected Script(CSharpFormattingOptions formattingOptions, TextEditorOptions options) { if (formattingOptions == null) { throw new ArgumentNullException("formattingOptions"); } if (options == null) { throw new ArgumentNullException("options"); } this.formattingOptions = formattingOptions; this.options = options; }
public EditWindow() { InitializeComponent(); var options = new TextEditorOptions(); options.ShowColumnRuler = true; te_code.TextArea.Options = options; te_code.TextArea.TextEntered += te_code_TextEntered; te_code.TextArea.TextEntering += te_code_TextEntering; }
public VisualLineDrawingVisual(VisualLine visualLine, TextEditorOptions options) { this.VisualLine = visualLine; var drawingContext = RenderOpen(); double pos = 0; foreach (TextLine textLine in visualLine.TextLines) { textLine.Draw(drawingContext, new Point(0, pos + options.LinePadding.Top), InvertAxes.None); pos += Math.Ceiling(textLine.Height + options.LinePadding.Top + options.LinePadding.Bottom); } this.Height = pos; drawingContext.Close(); }
/// <summary> /// Raises the <see cref="OptionChanged"/> event. /// </summary> private static void OnOptionsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { EdiView view = d as EdiView; if (view != null && e != null) { TextEditorOptions newValue = e.NewValue as TextEditorOptions; if (newValue != null) { view.Options = newValue; } } }
static MainOutputWindowEx() { _options = new TextEditorOptions(); _options.AllowScrollBelowDocument = false; _options.CutCopyWholeLine = false; _options.EnableEmailHyperlinks = true; _options.EnableHyperlinks = true; _options.EnableImeSupport = false; _options.EnableRectangularSelection = false; _options.EnableTextDragDrop = false; _options.EnableVirtualSpace = false; _options.RequireControlModifierForHyperlinkClick = false; _options.ShowBoxForControlCharacters = false; }
public void TestBug53283() { var data = new TextEditorData(); var options = new TextEditorOptions(); options.TabsToSpaces = false; options.TabSize = 4; data.Options = options; data.Insert(0, "\t"); Assert.AreEqual("\t", data.Text); options.TabsToSpaces = true; options.TabSize = 4; data.Replace(0, data.Length, "\t"); Assert.AreEqual(" ", data.Text); }
public SvgPage() { InitializeComponent(); // string workingDir = PathUtils.Combine(Assembly.GetExecutingAssembly()); string workingDir = IoPath.GetFullPath("..\\"); _svgFilePath = IoPath.Combine(workingDir, SvgFileName); _xamlFilePath = IoPath.Combine(workingDir, XamlFileName); _backFilePath = IoPath.Combine(workingDir, BackFileName); _directoryInfo = new DirectoryInfo(workingDir); _wpfSettings = new WpfDrawingSettings(); _fileReader = new FileSvgReader(_wpfSettings); _fileReader.SaveXaml = true; _fileReader.SaveZaml = false; textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"); TextEditorOptions options = textEditor.Options; if (options != null) { //options.AllowScrollBelowDocument = true; options.EnableHyperlinks = true; options.EnableEmailHyperlinks = true; options.EnableVirtualSpace = false; options.HighlightCurrentLine = true; //options.ShowSpaces = true; //options.ShowTabs = true; //options.ShowEndOfLine = true; } textEditor.ShowLineNumbers = true; _foldingManager = FoldingManager.Install(textEditor.TextArea); _foldingStrategy = new XmlFoldingStrategy(); _searchPanel = SearchPanel.Install(textEditor); textEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); this.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display); this.Loaded += OnPageLoaded; this.SizeChanged += OnPageSizeChanged; }
void OnOptionsChanged(TextEditorOptions oldValue, TextEditorOptions newValue) { if (oldValue != null) { PropertyChangedWeakEventManager.RemoveListener(oldValue, this); } textView.Options = newValue; if (newValue != null) { PropertyChangedWeakEventManager.AddListener(newValue, this); } OnOptionChanged(new PropertyChangedEventArgs(null)); }
/// <summary> /// Creates a new CSharpIndentationStrategy and initializes the settings using the text editor options. /// </summary> public CSharpIndentationStrategy(TextEditorOptions options) { // Dirkster99 BugFix for binding options in VS2010 this.IndentationString = (options == null ? indentationString : options.IndentationString); }
void FetchOptions(TextEditorOptions options) { this.ShowSpaces = options.ShowSpaces; this.ShowTabs = options.ShowTabs; this.ShowBoxForControlCharacters = options.ShowBoxForControlCharacters; }
void IBuiltinElementGenerator.FetchOptions(TextEditorOptions options) { }
void IBuiltinElementGenerator.FetchOptions(TextEditorOptions options) { this.ShowSpaces = options.ShowSpaces; this.ShowTabs = options.ShowTabs; this.ShowBoxForControlCharacters = options.ShowBoxForControlCharacters; }
/// <summary> /// Creates a new CSharpIndentationStrategy and initializes the settings using the text editor options. /// </summary> public CSharpIndentationStrategy(TextEditorOptions options) { this.IndentationString = options.IndentationString; }
void IBuiltinElementGenerator.FetchOptions(TextEditorOptions options) { this.RequireControlModifierForClick = options.RequireControlModifierForHyperlinkClick; }
/// <summary> /// Creates a new HtmlOptions instance that copies applicable options from the <see cref="TextEditorOptions"/>. /// </summary> public HtmlOptions(TextEditorOptions options) : this() { if (options == null) throw new ArgumentNullException("options"); this.TabSize = options.IndentationSize; }