public UserSettings(Settings s) { this._settings = s; this._font = (Font)this._settings["Font"]; this._theme = (ColorTheme)this._settings["Theme"]; _lightColors = (Hashtable)this._settings["LightColors"]; _darkColors = (Hashtable)this._settings["DarkColors"]; LoadColors(); _updateLocation = this._settings.GetString("UpdateLocation"); _enableUpdate = this._settings.GetBoolean("UpdateEnabled"); _autoFormatOnSave = this._settings.GetBoolean("AutoFormatOnSave"); _noByteOrderMark = this._settings.GetBoolean("NoByteOrderMark"); _indentLevel = this._settings.GetInteger("IndentLevel"); _indentChar = (IndentChar)this._settings["IndentChar"]; _newLineChars = this._settings.GetString("NewLineChars"); _language = this._settings.GetString("Language"); _maximumLineLength = this._settings.GetInteger("MaximumLineLength"); _autoFormatLongLines = this._settings.GetBoolean("AutoFormatLongLines"); _ignoreDTD = this._settings.GetBoolean("IgnoreDTD"); _enableXsltScripts = this._settings.GetBoolean("EnableXsltScripts"); _webBrowser = (this._settings.GetString("BrowserVersion") == "WebBrowser") ? WebBrowserVersion.WinformsWebBrowser : WebBrowserVersion.WebView2; this._xmlDiffIgnoreChildOrder = this._settings.GetBoolean("XmlDiffIgnoreChildOrder"); this._xmlDiffIgnoreComments = this._settings.GetBoolean("XmlDiffIgnoreComments"); this._xmlDiffIgnorePI = this._settings.GetBoolean("XmlDiffIgnorePI"); this._xmlDiffIgnoreWhitespace = this._settings.GetBoolean("XmlDiffIgnoreWhitespace"); this._xmlDiffIgnoreNamespaces = this._settings.GetBoolean("XmlDiffIgnoreNamespaces"); this._xmlDiffIgnorePrefixes = this._settings.GetBoolean("XmlDiffIgnorePrefixes"); this._xmlDiffIgnoreXmlDecl = this._settings.GetBoolean("XmlDiffIgnoreXmlDecl"); this._xmlDiffIgnoreDtd = this._settings.GetBoolean("XmlDiffIgnoreDtd"); this._allowAnalytics = this._settings.GetBoolean("AllowAnalytics"); this._textEditor = this._settings.GetString("TextEditor"); }
public UserSettings(Settings s) { this.settings = s; this.font = (Font)this.settings["Font"]; this.fontName = font.Name + " " + font.SizeInPoints + " " + font.Style.ToString(); this.theme = (ColorTheme)this.settings["Theme"]; lightColors = (Hashtable)this.settings["LightColors"]; darkColors = (Hashtable)this.settings["DarkColors"]; LoadColors(); updateLocation = (string)this.settings["UpdateLocation"]; enableUpdate = (bool)this.settings["UpdateEnabled"]; autoFormatOnSave = (bool)this.settings["AutoFormatOnSave"]; noByteOrderMark = (bool)this.settings["NoByteOrderMark"]; indentLevel = (int)this.settings["IndentLevel"]; indentChar = (IndentChar)this.settings["IndentChar"]; newLineChars = (string)this.settings["NewLineChars"]; language = (string)this.settings["Language"]; maximumLineLength = (int)this.settings["MaximumLineLength"]; autoFormatLongLines = (bool)this.settings["AutoFormatLongLines"]; ignoreDTD = (bool)this.settings["IgnoreDTD"]; this.xmlDiffIgnoreChildOrder = (bool)this.settings["XmlDiffIgnoreChildOrder"]; this.xmlDiffIgnoreComments = (bool)this.settings["XmlDiffIgnoreComments"]; this.xmlDiffIgnorePI = (bool)this.settings["XmlDiffIgnorePI"]; this.xmlDiffIgnoreWhitespace = (bool)this.settings["XmlDiffIgnoreWhitespace"]; this.xmlDiffIgnoreNamespaces = (bool)this.settings["XmlDiffIgnoreNamespaces"]; this.xmlDiffIgnorePrefixes = (bool)this.settings["XmlDiffIgnorePrefixes"]; this.xmlDiffIgnoreXmlDecl = (bool)this.settings["XmlDiffIgnoreXmlDecl"]; this.xmlDiffIgnoreDtd = (bool)this.settings["XmlDiffIgnoreDtd"]; this.allowAnalytics = (bool)this.settings["AllowAnalytics"]; }
public UserSettings(Settings s) { this.settings = s; this.font = (Font)this.settings["Font"]; this.fontName = font.Name + " " + font.SizeInPoints + " " + font.Style.ToString(); Hashtable colors = (Hashtable)this.settings["Colors"]; elementColor = (Color)colors["Element"]; commentColor = (Color)colors["Comment"]; attributeColor = (Color)colors["Attribute"]; piColor = (Color)colors["PI"]; textColor = (Color)colors["Text"]; cdataColor = (Color)colors["CDATA"]; backgroundColor = (Color)colors["Background"]; updateLocation = (string)this.settings["UpdateLocation"]; enableUpdate = (bool)this.settings["UpdateEnabled"]; autoFormatOnSave = (bool)this.settings["AutoFormatOnSave"]; noByteOrderMark = (bool)this.settings["NoByteOrderMark"]; indentLevel = (int)this.settings["IndentLevel"]; indentChar = (IndentChar)this.settings["IndentChar"]; newLineChars = (string)this.settings["NewLineChars"]; language = (string)this.settings["Language"]; maximumLineLength = (int)this.settings["MaximumLineLength"]; autoFormatLongLines = (bool)this.settings["AutoFormatLongLines"]; ignoreDTD = (bool)this.settings["IgnoreDTD"]; }
private void WriteIndent(bool withLineBreak) { if (withLineBreak) { WriteNewLine(); } for (int i = 0; i < Top; i++) { base.WriteRaw(IndentChar.ToString()); } }
public void Reset() { this.font = new Font("Courier New", 10, FontStyle.Regular); elementColor = Color.FromArgb(0, 64, 128); commentColor = Color.Green; attributeColor = Color.Maroon; piColor = Color.Purple; textColor = Color.Black; cdataColor = Color.Gray; backgroundColor = Color.White; updateLocation = "http://download.microsoft.com/download/6/e/e/6eef2361-33d4-48a2-b52e-5827c7f2ad68/Updates.xml"; enableUpdate = true; autoFormatOnSave = true; indentLevel = 2; indentChar = IndentChar.Space; newLineChars = Escape("\r\n"); }
public void Reset() { this.font = new Font("Courier New", 10, FontStyle.Regular); elementColor = Color.FromArgb(0, 64, 128); commentColor = Color.Green; attributeColor = Color.Maroon; piColor = Color.Purple; textColor = Color.Black; cdataColor = Color.Gray; backgroundColor = Color.White; updateLocation = "http://www.lovettsoftware.com/downloads/xmlnotepad/Updates.xml"; enableUpdate = true; autoFormatOnSave = true; noByteOrderMark = false; indentLevel = 2; indentChar = IndentChar.Space; newLineChars = Escape("\r\n"); language = ""; this.maximumLineLength = 10000; }
public void Reset() { this.font = new Font("Courier New", 10, FontStyle.Regular); this.theme = ColorTheme.Light; this.lightColors = GetDefaultColors(ColorTheme.Light); this.darkColors = GetDefaultColors(ColorTheme.Dark); this.LoadColors(); updateLocation = "http://www.lovettsoftware.com/downloads/xmlnotepad/Updates.xml"; enableUpdate = true; autoFormatOnSave = true; noByteOrderMark = false; indentLevel = 2; indentChar = IndentChar.Space; newLineChars = Escape("\r\n"); language = ""; this.maximumLineLength = 10000; this.maximumValueLength = short.MaxValue; ignoreDTD = false; }
public void Reset() { this.font = new Font("Courier New", 10, FontStyle.Regular); this.theme = ColorTheme.Light; this.lightColors = GetDefaultColors(ColorTheme.Light); this.darkColors = GetDefaultColors(ColorTheme.Dark); this.LoadColors(); updateLocation = DefaultUpdateLocation; enableUpdate = true; autoFormatOnSave = true; noByteOrderMark = false; indentLevel = 2; indentChar = IndentChar.Space; newLineChars = Escape("\r\n"); language = ""; this.maximumLineLength = 10000; this.maximumValueLength = short.MaxValue; ignoreDTD = false; this.allowAnalytics = false; }
public void Reset() { this._font = new Font("Courier New", 10, FontStyle.Regular); this._theme = ColorTheme.Light; this._lightColors = this._settings.GetDefaultColors(ColorTheme.Light); this._darkColors = this._settings.GetDefaultColors(ColorTheme.Dark); this.LoadColors(); _updateLocation = Settings.DefaultUpdateLocation; _enableUpdate = true; _autoFormatOnSave = true; _noByteOrderMark = false; _indentLevel = 2; _indentChar = IndentChar.Space; _newLineChars = Utilities.Escape("\r\n"); _language = ""; this._maximumLineLength = 10000; this._maximumValueLength = short.MaxValue; _ignoreDTD = false; this._allowAnalytics = false; }
public static void InitializeWriterSettings(XmlWriterSettings settings, IServiceProvider sp) { settings.CheckCharacters = false; settings.Indent = true; settings.IndentChars = " "; settings.NewLineChars = "\r\n"; settings.NewLineHandling = NewLineHandling.Replace; if (sp != null) { Settings s = (Settings)sp.GetService(typeof(Settings)); if (s != null) { settings.Indent = (bool)s["AutoFormatOnSave"]; IndentChar indentChar = (IndentChar)s["IndentChar"]; int indentLevel = (int)s["IndentLevel"]; char ch = (indentChar == IndentChar.Space) ? ' ' : '\t'; settings.IndentChars = new string(ch, indentLevel); settings.NewLineChars = UserSettings.Unescape((string)s["NewLineChars"]); } } }
public UserSettings(Settings s) { this.settings = s; this.font = (Font)this.settings["Font"]; this.fontName = font.Name + " " + font.SizeInPoints + " " + font.Style.ToString(); Hashtable colors = (Hashtable)this.settings["Colors"]; elementColor = (Color)colors["Element"]; commentColor = (Color)colors["Comment"]; attributeColor = (Color)colors["Attribute"]; piColor = (Color)colors["PI"]; textColor = (Color)colors["Text"]; cdataColor = (Color)colors["CDATA"]; backgroundColor = (Color)colors["Background"]; updateLocation = (string)this.settings["UpdateLocation"]; enableUpdate = (bool)this.settings["UpdateEnabled"]; autoFormatOnSave = (bool)this.settings["AutoFormatOnSave"]; indentLevel = (int)this.settings["IndentLevel"]; indentChar = (IndentChar)this.settings["IndentChar"]; newLineChars = Escape((string)this.settings["NewLineChars"]); }
static Script ParseLines(RawLine[] lines, IndentChar indent_enum = IndentChar.Auto, bool ignore_unsupported_renpy = false) { var lines_text = lines.Select(x => x.Text).ToArray(); char indent; if (indent_enum == IndentChar.Auto) { indent = InferIndent(lines_text); } else if (indent_enum == IndentChar.Tab) { indent = TAB; } else if (indent_enum == IndentChar.Whitespace) { indent = WHITESPACE; } else { throw new Exception("Invalid indent character!"); } var depths = GetLineDepths(lines_text, indent); var indent_values = depths.Distinct().OrderBy(x => x).ToArray(); // 1. Is it a tree? if (indent_values.Length < 2) { throw new Exception("No indentation!"); } var min_indent = 1; if (indent == WHITESPACE) { min_indent = indent_values.FirstOrDefault(x => x > 0); // indent_values[0] == 0 ? indent_values[1] : indent_values[0]; if (min_indent < 1) { min_indent = 1; } // 2. Are all indents multiples of the indentation unit? if (indent_values.Any(x => x % min_indent != 0)) { throw new Exception("Irregular indentation!"); } } var diffs = Diff(depths); for (int i = 0; i < lines.Length - 1; i++) { if (diffs[i] > min_indent) { throw new Exception(string.Format("Unexpected indentation in {0}!", lines[i].ExceptionString)); } } //if (diffs.Any(x => x > min_indent)) throw new Exception("Unexpected indentation!"); // 3. Get label blocks var line = string.Empty; var labels = new List <string>(); var top_lines_indices = depths.FindAllIndexOf(0); int[] label_lines_indices; var label_lines_indices_tmp = new List <int>(); var tm = new TextManager(); foreach (var i in top_lines_indices) { var raw_line = lines[i]; line = raw_line.Text.Trim(); //n = line.Length; /*if (line[n - 1] != COLON) * throw new Exception(string.Format("Missing colon at line '{0}'!", line));*/ if (unsupported_renpy_block_re.IsMatch(line)) { Logger.Log(string.Format("Ignoring top-level Ren'Py block '{0}'", line)); continue; } //var label_tokens = line.Substring(0, n - 1).Split(WHITESPACE); if (line.StartsWith(DEFINE)) { var definition = GetDefinition(line, ref tm); if (definition == null) { throw new Exception(string.Format("Invalid definition in {0}!", raw_line.ExceptionString)); } if (!tm.TryAddDefinition(definition.Key, definition.Value)) { throw new Exception(string.Format("Variable '{0}' already initialized in {1}!", definition.Key, raw_line.ExceptionString)); } } else if (line.StartsWith(LABEL)) { var block = tokens2TopLevel(line.Split(WHITESPACE)) as VGPBlock; if (block == null) { throw new Exception(string.Format("Invalid label in {0}!", raw_line.ExceptionString)); } labels.Add(block.Label); label_lines_indices_tmp.Add(i); } else { throw new Exception(string.Format("Invalid top-level statement in {0}!", raw_line.ExceptionString)); } } if (labels.GroupBy(x => x).Any(g => g.Count() > 1)) { throw new Exception("Duplicate labels!"); } label_lines_indices = label_lines_indices_tmp.ToArray(); // 4. Fill label blocks Utils.LogArray("Labels", labels.ToArray(), Logger); Utils.LogArray("Block line indices", label_lines_indices, Logger); Node.IndentSpan = min_indent; var tree = renpy2tree(lines, label_lines_indices, indent, print: true); // 5. Create script var script = tree2script(tree, ref tm, ignore_unsupported_renpy); return(script); }
public static Script ParseSource(string path, bool recursive = false, IndentChar indent = IndentChar.Auto, bool ignore_unsupported_renpy = false) { var lines = LoadRawLines(path, recursive, ignore_unsupported_renpy); return(ParseLines(lines, indent, ignore_unsupported_renpy)); }