From 86160a8be03e85d00086f0ad5fbd9c44583243bb Mon Sep 17 00:00:00 2001 From: Asval Date: Sun, 18 Aug 2019 01:09:19 +0200 Subject: [PATCH] scintilla code folding --- FModel/MainWindow.Designer.cs | 11 ++++--- FModel/MainWindow.resx | 2 +- FModel/Methods/Scintilla/MyScintilla.cs | 39 +++++++++++++++++-------- FModel/Methods/Utilities/Utilities.cs | 4 +-- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/FModel/MainWindow.Designer.cs b/FModel/MainWindow.Designer.cs index d797ac3f..f67c4469 100644 --- a/FModel/MainWindow.Designer.cs +++ b/FModel/MainWindow.Designer.cs @@ -316,7 +316,7 @@ namespace FModel // saveImageToolStripMenuItem // this.saveImageToolStripMenuItem.Name = "saveImageToolStripMenuItem"; - this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(168, 22); this.saveImageToolStripMenuItem.Text = "Save Image"; this.saveImageToolStripMenuItem.Click += new System.EventHandler(this.saveImageToolStripMenuItem_Click); // @@ -324,18 +324,18 @@ namespace FModel // this.autoSaveImagesToolStripMenuItem.CheckOnClick = true; this.autoSaveImagesToolStripMenuItem.Name = "autoSaveImagesToolStripMenuItem"; - this.autoSaveImagesToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.autoSaveImagesToolStripMenuItem.Size = new System.Drawing.Size(168, 22); this.autoSaveImagesToolStripMenuItem.Text = "Auto Save Images"; // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(177, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(165, 6); // // mergeImagesToolStripMenuItem // this.mergeImagesToolStripMenuItem.Name = "mergeImagesToolStripMenuItem"; - this.mergeImagesToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.mergeImagesToolStripMenuItem.Size = new System.Drawing.Size(168, 22); this.mergeImagesToolStripMenuItem.Text = "Merge Images"; this.mergeImagesToolStripMenuItem.Click += new System.EventHandler(this.mergeImagesToolStripMenuItem_Click); // @@ -518,10 +518,13 @@ namespace FModel // // scintilla1 // + this.scintilla1.AutomaticFold = ((ScintillaNET.AutomaticFold)(((ScintillaNET.AutomaticFold.Show | ScintillaNET.AutomaticFold.Click) + | ScintillaNET.AutomaticFold.Change))); this.scintilla1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.scintilla1.CaretPeriod = 400; this.scintilla1.Dock = System.Windows.Forms.DockStyle.Fill; this.scintilla1.IndentationGuides = ScintillaNET.IndentView.Real; + this.scintilla1.Lexer = ScintillaNET.Lexer.Json; this.scintilla1.Location = new System.Drawing.Point(3, 3); this.scintilla1.Name = "scintilla1"; this.scintilla1.ScrollWidth = 496; diff --git a/FModel/MainWindow.resx b/FModel/MainWindow.resx index 63a0a6ab..ec1d5ad5 100644 --- a/FModel/MainWindow.resx +++ b/FModel/MainWindow.resx @@ -131,7 +131,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABa - CAAAAk1TRnQBSQFMAgEBAgEAATgBAgE4AQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CAAAAk1TRnQBSQFMAgEBAgEAAUABAgFAAQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/FModel/Methods/Scintilla/MyScintilla.cs b/FModel/Methods/Scintilla/MyScintilla.cs index cb94b749..b363572f 100644 --- a/FModel/Methods/Scintilla/MyScintilla.cs +++ b/FModel/Methods/Scintilla/MyScintilla.cs @@ -61,10 +61,6 @@ namespace FModel e.SuppressKeyPress = true; } } - private static void KeyPressed(object sender, KeyEventArgs e) - { - KeyDown(sender, e); - } /// /// Set styles to a ScintillaNET control and disable some keybinds @@ -73,13 +69,14 @@ namespace FModel public static void SetScintillaStyle(Scintilla theBox) { theBox.Styles[Style.Json.Default].ForeColor = Color.Silver; - theBox.Styles[Style.Json.BlockComment].ForeColor = Color.FromArgb(0, 128, 0); - theBox.Styles[Style.Json.LineComment].ForeColor = Color.FromArgb(0, 128, 0); - theBox.Styles[Style.Json.Number].ForeColor = Color.Green; - theBox.Styles[Style.Json.PropertyName].ForeColor = Color.SteelBlue; - theBox.Styles[Style.Json.String].ForeColor = Color.OrangeRed; - theBox.Styles[Style.Json.StringEol].BackColor = Color.OrangeRed; - theBox.Styles[Style.Json.Operator].ForeColor = Color.Black; + theBox.Styles[Style.Json.Number].ForeColor = Color.Goldenrod; + theBox.Styles[Style.Json.String].ForeColor = Color.RoyalBlue; + theBox.Styles[Style.Json.StringEol].ForeColor = Color.RoyalBlue; + theBox.Styles[Style.Json.PropertyName].ForeColor = Color.Crimson; + theBox.Styles[Style.Json.LineComment].ForeColor = Color.DarkGray; + theBox.Styles[Style.Json.BlockComment].ForeColor = Color.DarkGray; + theBox.Styles[Style.Json.Uri].ForeColor = Color.Peru; + theBox.Styles[Style.Json.CompactIRI].ForeColor = Color.Peru; theBox.Styles[Style.LineNumber].ForeColor = Color.DarkGray; var nums = theBox.Margins[1]; nums.Width = 30; @@ -87,9 +84,27 @@ namespace FModel nums.Sensitive = true; nums.Mask = 0; + theBox.SetProperty("fold", "1"); + theBox.SetProperty("fold.compact", "1"); + theBox.Margins[2].Type = MarginType.Symbol; + theBox.Margins[2].Mask = Marker.MaskFolders; + theBox.Margins[2].Sensitive = true; + theBox.Margins[2].Width = 20; + for (int i = 25; i <= 31; i++) + { + theBox.Markers[i].SetForeColor(SystemColors.ControlLightLight); + theBox.Markers[i].SetBackColor(SystemColors.ControlDark); + } + theBox.Markers[Marker.Folder].Symbol = MarkerSymbol.BoxPlus; + theBox.Markers[Marker.FolderOpen].Symbol = MarkerSymbol.BoxMinus; + theBox.Markers[Marker.FolderEnd].Symbol = MarkerSymbol.BoxPlusConnected; + theBox.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner; + theBox.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected; + theBox.Markers[Marker.FolderSub].Symbol = MarkerSymbol.VLine; + theBox.Markers[Marker.FolderTail].Symbol = MarkerSymbol.LCorner; + theBox.ClearCmdKey(Keys.Control | Keys.F); theBox.ClearCmdKey(Keys.Control | Keys.Z); - theBox.Lexer = Lexer.Json; } } } diff --git a/FModel/Methods/Utilities/Utilities.cs b/FModel/Methods/Utilities/Utilities.cs index dd8324fa..ae48e213 100644 --- a/FModel/Methods/Utilities/Utilities.cs +++ b/FModel/Methods/Utilities/Utilities.cs @@ -138,7 +138,7 @@ namespace FModel if (pak == toolstripmenuitem.Text) { toolstripmenuitem.Enabled = true; - toolstripmenuitem.BackColor = Color.FromArgb(50, 50, 92, 219); + toolstripmenuitem.BackColor = Color.FromArgb(25, 50, 92, 219); } } @@ -150,7 +150,7 @@ namespace FModel if (!string.IsNullOrEmpty(key) && pak == toolstripmenuitem.Text) { toolstripmenuitem.Enabled = true; - toolstripmenuitem.BackColor = Color.FromArgb(100, 50, 92, 219); + toolstripmenuitem.BackColor = Color.FromArgb(50, 50, 92, 219); } } }