Browse Source

Fixed SD2-1367: Templates ignore tab/indentation options

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2634 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
ab66ebb70c
  1. 4
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/PackageFilesView.cs
  2. 2
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs
  3. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs
  4. 6
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs
  5. 5
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/DefaultTextEditorProperties.cs
  6. 11
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/ITextEditorProperties.cs
  7. 10
      src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs
  8. 11
      src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs
  9. 1
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
  10. 2
      src/Main/Base/Project/Src/Project/Solution/AbstractSolutionFolder.cs
  11. 14
      src/Main/Base/Project/Src/Services/AmbienceService/CodeDOMGeneratorUtility.cs
  12. 34
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs
  13. 14
      src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/BehaviorTextEditorPanel.cs

4
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/PackageFilesView.cs

@ -113,7 +113,7 @@ namespace ICSharpCode.WixBinding @@ -113,7 +113,7 @@ namespace ICSharpCode.WixBinding
{
if (!UpdateOpenFile(document)) {
ITextEditorProperties properties = new SharpDevelopTextEditorProperties();
document.Save(properties.LineTerminator, properties.ConvertTabsToSpaces, properties.TabIndent);
document.Save(properties.LineTerminator, properties.ConvertTabsToSpaces, properties.IndentationSize);
}
IsDirty = false;
}
@ -304,7 +304,7 @@ namespace ICSharpCode.WixBinding @@ -304,7 +304,7 @@ namespace ICSharpCode.WixBinding
string GetWixXml(XmlElement element)
{
ITextEditorProperties properties = new SharpDevelopTextEditorProperties();
return WixDocument.GetXml(element, properties.LineTerminator, properties.ConvertTabsToSpaces, properties.TabIndent);
return WixDocument.GetXml(element, properties.LineTerminator, properties.ConvertTabsToSpaces, properties.IndentationSize);
}
/// <summary>

2
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs

@ -74,7 +74,7 @@ namespace ICSharpCode.WixBinding @@ -74,7 +74,7 @@ namespace ICSharpCode.WixBinding
}
// Get the replacement dialog xml.
ITextEditorProperties properties = view.TextEditorControl.TextEditorProperties;
string replacementXml = WixDocument.GetXml(dialogElement, properties.LineTerminator, properties.ConvertTabsToSpaces, properties.TabIndent);
string replacementXml = WixDocument.GetXml(dialogElement, properties.LineTerminator, properties.ConvertTabsToSpaces, properties.IndentationSize);
// Replace the xml and select the inserted text.
WixDocumentEditor editor = new WixDocumentEditor(view.TextEditorControl.ActiveTextAreaControl);

2
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs

@ -1001,7 +1001,7 @@ namespace ICSharpCode.XmlEditor @@ -1001,7 +1001,7 @@ namespace ICSharpCode.XmlEditor
{
XmlTextWriter writer = new XmlTextWriter(textWriter);
if (xmlEditor.TextEditorProperties.ConvertTabsToSpaces) {
writer.Indentation = xmlEditor.TextEditorProperties.TabIndent;
writer.Indentation = xmlEditor.TextEditorProperties.IndentationSize;
writer.IndentChar = ' ';
} else {
writer.Indentation = 1;

6
src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.TextEditor.Actions @@ -25,7 +25,7 @@ namespace ICSharpCode.TextEditor.Actions
StringBuilder indent = new StringBuilder();
if (document.TextEditorProperties.ConvertTabsToSpaces) {
int tabIndent = document.TextEditorProperties.TabIndent;
int tabIndent = document.TextEditorProperties.IndentationSize;
if (textArea != null) {
int column = textArea.TextView.GetVisualColumn(textArea.Caret.Line, textArea.Caret.Column);
indent.Append(new String(' ', tabIndent - column % tabIndent));
@ -149,7 +149,7 @@ namespace ICSharpCode.TextEditor.Actions @@ -149,7 +149,7 @@ namespace ICSharpCode.TextEditor.Actions
charactersToRemove = 1;
} else if(document.GetCharAt(line.Offset) == ' ') {
int leadingSpaces = 1;
int tabIndent = document.TextEditorProperties.TabIndent;
int tabIndent = document.TextEditorProperties.IndentationSize;
for (leadingSpaces = 1; leadingSpaces < line.Length && document.GetCharAt(line.Offset + leadingSpaces) == ' '; leadingSpaces++) {
// deliberately empty
}
@ -204,7 +204,7 @@ namespace ICSharpCode.TextEditor.Actions @@ -204,7 +204,7 @@ namespace ICSharpCode.TextEditor.Actions
// column is updated to that column.
LineSegment line = textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset);
string startOfLine = textArea.Document.GetText(line.Offset,textArea.Caret.Offset - line.Offset);
int tabIndent = textArea.Document.TextEditorProperties.TabIndent;
int tabIndent = textArea.Document.TextEditorProperties.IndentationSize;
int currentColumn = textArea.Caret.Column;
int remainder = currentColumn % tabIndent;
if (remainder == 0) {

5
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/DefaultTextEditorProperties.cs

@ -19,6 +19,7 @@ namespace ICSharpCode.TextEditor.Document @@ -19,6 +19,7 @@ namespace ICSharpCode.TextEditor.Document
public class DefaultTextEditorProperties : ITextEditorProperties
{
int tabIndent = 4;
int indentationSize = 4;
IndentStyle indentStyle = IndentStyle.Smart;
DocumentSelectionMode documentSelectionMode = DocumentSelectionMode.Normal;
Encoding encoding = System.Text.Encoding.UTF8;
@ -73,6 +74,10 @@ namespace ICSharpCode.TextEditor.Document @@ -73,6 +74,10 @@ namespace ICSharpCode.TextEditor.Document
}
}
public int IndentationSize {
get { return indentationSize; }
set { indentationSize = value; }
}
public IndentStyle IndentStyle {
get {

11
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/ITextEditorProperties.cs

@ -128,11 +128,22 @@ namespace ICSharpCode.TextEditor.Document @@ -128,11 +128,22 @@ namespace ICSharpCode.TextEditor.Document
set;
}
/// <summary>
/// The width of a tab.
/// </summary>
int TabIndent { // is wrapped in text editor control
get;
set;
}
/// <summary>
/// The amount of spaces a tab is converted to if ConvertTabsToSpaces is true.
/// </summary>
int IndentationSize {
get;
set;
}
IndentStyle IndentStyle { // is wrapped in text editor control
get;
set;

10
src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.TextEditor.Document;
using System;
using System.Collections;
using System.Collections.Generic;
@ -12,8 +13,8 @@ using System.Drawing; @@ -12,8 +13,8 @@ using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Gui.XmlForms;
using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project;
@ -372,6 +373,13 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -372,6 +373,13 @@ namespace ICSharpCode.SharpDevelop.Gui
// Parse twice so that tags used in included standard header are parsed
string parsedContent = StringParser.Parse(StringParser.Parse(content));
if (parsedContent != null) {
if (SharpDevelopTextEditorProperties.IndentationString != "\t") {
parsedContent = parsedContent.Replace("\t", SharpDevelopTextEditorProperties.IndentationString);
}
}
// when newFile.Name is "${Path}/${FileName}", there might be a useless '/' in front of the file name
// if the file is created when no project is opened. So we remove single '/' or '\', but not double
// '\\' (project is saved on network share).

11
src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs

@ -5,17 +5,16 @@ @@ -5,17 +5,16 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using Import = System.Collections.Generic.KeyValuePair<System.String, System.String>;
using MSBuild = Microsoft.Build.BuildEngine;
using Import = System.Collections.Generic.KeyValuePair<string, string>;
namespace ICSharpCode.SharpDevelop.Internal.Templates
{
@ -357,7 +356,11 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates @@ -357,7 +356,11 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
} else {
// Textual content
StreamWriter sr = new StreamWriter(File.Create(fileName), ParserService.DefaultFileEncoding);
sr.Write(StringParser.Parse(StringParser.Parse(file.Content, new string[,] { {"ProjectName", projectCreateInformation.ProjectName}, {"FileName", fileName}})));
string fileContent = StringParser.Parse(file.Content, new string[,] { {"ProjectName", projectCreateInformation.ProjectName}, {"FileName", fileName}});
if (SharpDevelopTextEditorProperties.IndentationString != "\t") {
fileContent = fileContent.Replace("\t", SharpDevelopTextEditorProperties.IndentationString);
}
sr.Write(fileContent);
sr.Close();
}
} catch (Exception ex) {

1
src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

@ -326,6 +326,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -326,6 +326,7 @@ namespace ICSharpCode.SharpDevelop.Project
return property;
}
}
location = PropertyStorageLocations.Unknown;
group = null;
return null;

2
src/Main/Base/Project/Src/Project/Solution/AbstractSolutionFolder.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -26,7 +26,7 @@ namespace ICSharpCode.SharpDevelop.Project
/// <summary>
/// Gets the object used for thread-safe synchronization.
/// All members lock on this object, but if you manipulate underlying structures
/// Thread-safe members lock on this object, but if you manipulate underlying structures
/// (such as the MSBuild project for MSBuildBasedProjects) directly, you will have to lock on this object.
/// </summary>
[Browsable(false)]

14
src/Main/Base/Project/Src/Services/AmbienceService/CodeDOMGeneratorUtility.cs

@ -5,12 +5,12 @@ @@ -5,12 +5,12 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.Text;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop
@ -24,18 +24,8 @@ namespace ICSharpCode.SharpDevelop @@ -24,18 +24,8 @@ namespace ICSharpCode.SharpDevelop
options.BracingStyle = AmbienceService.CodeGenerationProperties.Get("StartBlockOnSameLine", true) ? "Block" : "C";
options.ElseOnClosing = AmbienceService.CodeGenerationProperties.Get("ElseOnClosing", true);
options.IndentString = SharpDevelopTextEditorProperties.IndentationString;
Properties docProperties = ((Properties)PropertyService.Get("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new Properties()));
if ((bool)docProperties.Get("TabsToSpaces", false)) {
StringBuilder indentationString = new StringBuilder();
for (int i = 0; i < (int)docProperties.Get("IndentationSize", 4); ++i) {
indentationString.Append(' ');
}
options.IndentString = indentationString.ToString();
} else {
options.IndentString = "\t";
}
return options;
}
}

34
src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs

@ -40,14 +40,39 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -40,14 +40,39 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
public int TabIndent {
get {
return properties.Get("TabIndent", 4);
}
get { return properties.Get("TabIndent", 4); }
set {
// FIX: don't allow to set tab size to zero as this will cause divide by zero exceptions in the text control.
// Zero isn't a setting that makes sense, anyway.
if (value < 1) value = 1;
properties.Set("TabIndent", value);
}
}
public int IndentationSize {
get { return properties.Get("IndentationSize", 4); }
set {
if (value < 1) value = 1;
properties.Set("IndentationSize", value);
indentationString = null;
}
}
static string indentationString;
public static string IndentationString {
get {
if (indentationString == null) {
SharpDevelopTextEditorProperties p = new SharpDevelopTextEditorProperties();
if (p.ConvertTabsToSpaces)
return new string(' ', p.IndentationSize);
else
return "\t";
}
return indentationString;
}
}
public IndentStyle IndentStyle {
get {
return (IndentStyle)properties.Get("IndentStyle", IndentStyle.Smart);
@ -169,6 +194,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -169,6 +194,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
set {
properties.Set("TabsToSpaces", value);
indentationString = null;
}
}
public bool UseAntiAliasedFont {

14
src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/BehaviorTextEditorPanel.cs

@ -48,7 +48,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels @@ -48,7 +48,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels
public override bool StorePanelContents()
{
((Properties)CustomizationObject).Set("TabsToSpaces", ((CheckBox)ControlDictionary["convertTabsToSpacesCheckBox"]).Checked);
SharpDevelopTextEditorProperties prop = new SharpDevelopTextEditorProperties();
prop.ConvertTabsToSpaces = ((CheckBox)ControlDictionary["convertTabsToSpacesCheckBox"]).Checked;
((Properties)CustomizationObject).Set("MouseWheelScrollDown", ((ComboBox)ControlDictionary["mouseWhellDirectionComboBox"]).SelectedIndex == 0);
((Properties)CustomizationObject).Set("AutoInsertCurlyBracket", ((CheckBox)ControlDictionary["autoinsertCurlyBraceCheckBox"]).Checked);
@ -59,19 +60,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels @@ -59,19 +60,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels
((Properties)CustomizationObject).Set("IndentStyle", (IndentStyle)((ComboBox)ControlDictionary["indentStyleComboBox"]).SelectedIndex);
try {
int tabSize = Int32.Parse(ControlDictionary["tabSizeTextBox"].Text);
// FIX: don't allow to set tab size to zero as this will cause divide by zero exceptions in the text control.
// Zero isn't a setting that makes sense, anyway.
if (tabSize > 0) {
((Properties)CustomizationObject).Set("TabIndent", tabSize);
}
prop.TabIndent = Int32.Parse(ControlDictionary["tabSizeTextBox"].Text);
} catch (Exception) {
}
try {
((Properties)CustomizationObject).Set("IndentationSize", Int32.Parse(ControlDictionary["indentSizeTextBox"].Text));
prop.IndentationSize = Int32.Parse(ControlDictionary["indentSizeTextBox"].Text);
} catch (Exception) {
}

Loading…
Cancel
Save