private void OptionsForm_Load(object sender, EventArgs e) { // Populate the controls. themeBox.SelectedIndex = (int)config.Theme; preferredAliasExtensionBox.Text = config.PreferredAliasExtension; assumeMrcFilesCheckBox.Checked = config.AssumeMrcFilesAreRemote; previousAssume = config.AssumeMrcFilesAreRemote; mIRCInstanceLabelBox.Text = config.mIRCInstanceLabel; showLineNumbersCheckBox.Checked = config.ShowLineNumbers; indentationBox.Value = config.PreferredIndentationCount; defaultDialogSizeUnitBox.SelectedIndex = (int)config.DefaultDialogSizeUnit; // Set up the category list. treeView.ExpandAll(); treeView.SelectedNode = treeView.Nodes[0]; currentPage = generalPanel; // Set up the sample text box. applyTheme(); var document = new MslDocument(DocumentType.RemoteScript, "sample.mrc", false, false); editorColoursSampleTextBox.Tag = document; document.TextBox = editorColoursSampleTextBox; Rehighlight(document); }
internal void Rehighlight(MslDocument document, int startLine, bool force) { for (int i = startLine; i < document.TextBox.LinesCount; ++i) { var oldResult = document.GetLineInfo(i); var result = MslSyntaxHighlighter.Highlight(document.TextBox, i, document.Type); if (!force && result.Matches(oldResult)) { break; } // Skip past continued lines. while (i < document.TextBox.LinesCount && document.lineInfoTable.TryGetValue(document.TextBox[i].UniqueId, out result) && result.State == (byte)MslSyntaxHighlighter.ParseStateIndex.Continuation) { ++i; } } }
internal void Rehighlight(MslDocument document, int startLine) => Rehighlight(document, startLine, false);
internal void Rehighlight(MslDocument document) => Rehighlight(document, 0, true);
public static MslDocument FromFile(string path, DocumentType type, bool readOnly, IntPtr syncTarget) { bool INI = path.EndsWith(".ini"); // Open the file. StreamReader reader = new StreamReader(File.Open(path, FileMode.Open, FileAccess.Read)); var document = new MslDocument(type, path, INI, readOnly, syncTarget, true, String.Empty); var builder = new StringBuilder(); while (!reader.EndOfStream) { var line = reader.ReadLine(); if (INI && document.TextBox.LinesCount == 0) { // Read the INI section header. line = line.Trim(); if (line.Length != 0) { if (line[0] == '[' && line.EndsWith("]")) { line = line.Substring(1, line.Length - 2).Trim(); if (line.Equals("script", StringComparison.OrdinalIgnoreCase)) { type = DocumentType.RemoteScript; } else if (line.Equals("aliases", StringComparison.OrdinalIgnoreCase)) { type = DocumentType.AliasScript; } else if (line.Equals("popups", StringComparison.OrdinalIgnoreCase)) { type = DocumentType.Popup; } else if (line.Equals("users", StringComparison.OrdinalIgnoreCase)) { type = DocumentType.Users; } else if (line.Equals("vars", StringComparison.OrdinalIgnoreCase)) { type = DocumentType.Variables; } continue; } } } // Read the text. if (INI) { var delimiter = line.IndexOf('='); if (delimiter != -1) { line = line.Substring(delimiter + 1); } } builder.AppendLine(line); } document.TextBox.Text = builder.ToString(); document.TextBox.ClearUndo(); document.TextBox.IsChanged = false; // Finish up. reader.Close(); return(document); }
public MslDialog(string name, MslDocument document, MslBookmark bookmark) : base("pixels") { this.Name = name; this.Document = document; this.Bookmark = bookmark; }