From: Jean-Philippe Bruyère Date: Sat, 4 Nov 2017 13:27:19 +0000 (+0100) Subject: * SourceEditor.cs: mouse click folding X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=41b332d938dde8fa87c01e7a69a877752c21e543;p=jp%2Fcrowedit.git * SourceEditor.cs: mouse click folding * main.crow: * CrowEdit.csproj: * CrowEdit.cs: * EditorOptions.crow: editor options pannel --- diff --git a/CrowEdit.csproj b/CrowEdit.csproj index 0cad08b..3c197e1 100644 --- a/CrowEdit.csproj +++ b/CrowEdit.csproj @@ -48,7 +48,6 @@ - @@ -108,5 +107,7 @@ + + diff --git a/src/CrowEdit.cs b/src/CrowEdit.cs index 32b1d0e..a9af7dc 100644 --- a/src/CrowEdit.cs +++ b/src/CrowEdit.cs @@ -27,7 +27,7 @@ namespace CrowEdit { public class CrowEdit : CrowWindow { - public Command CMDNew, CMDOpen, CMDSave, CMDSaveAs, CMDQuit, CMDUndo, CMDRedo, CMDCut, CMDCopy, CMDPaste, CMDHelp, CMDAbout; + public Command CMDNew, CMDOpen, CMDSave, CMDSaveAs, CMDQuit, CMDUndo, CMDRedo, CMDCut, CMDCopy, CMDPaste, CMDHelp, CMDAbout, CMDOptions; string _curDir = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments); string _curFilePath = "unamed.txt"; @@ -85,6 +85,7 @@ namespace CrowEdit CMDCopy = new Command(new Action(() => Quit (null, null))) { Caption = "Copy", Icon = new SvgPicture("#CrowEdit.ui.icons.copy-file.svg"), CanExecute = false}; CMDPaste = new Command(new Action(() => Quit (null, null))) { Caption = "Paste", Icon = new SvgPicture("#CrowEdit.ui.icons.paste-on-document.svg"), CanExecute = false}; CMDHelp = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("help"))) { Caption = "Help", Icon = new SvgPicture("#CrowEdit.ui.icons.question.svg")}; + CMDOptions = new Command(new Action(() => openOptionsDialog())) { Caption = "Editor Options", Icon = new SvgPicture("#CrowEdit.ui.icons.tools.svg")}; } void newFile(){ @@ -124,6 +125,10 @@ namespace CrowEdit if (redoStack.Count == 0) CMDRedo.CanExecute = false; } + void openOptionsDialog(){ + GraphicObject ed = this.FindByName("editor"); + Load ("#CrowEdit.ui.EditorOptions.crow").DataSource = ed; + } void openFileDialog(){ Load ("#CrowEdit.ui.openFile.crow").DataSource = this; } @@ -188,7 +193,6 @@ namespace CrowEdit this.ValueChanged += CrowEdit_ValueChanged; initCommands (); - Load ("#CrowEdit.ui.main.crow").DataSource = this; NotifyValueChanged ("CurFileFullPath", CurFileFullPath); } diff --git a/src/SourceEditor.cs b/src/SourceEditor.cs index 511864e..2c53ba7 100644 --- a/src/SourceEditor.cs +++ b/src/SourceEditor.cs @@ -70,7 +70,7 @@ namespace Crow.Coding } #endregion - const int leftMarginGap = 2;//gap between items in margin and text + const int leftMarginGap = 5;//gap between items in margin and text const int foldSize = 9;//folding rectangles size #region private and protected fields @@ -99,7 +99,7 @@ namespace Crow.Coding void measureLeftMargin () { leftMargin = 0; if (PrintLineNumbers) - leftMargin += (int)Math.Ceiling((double)buffer.LineCount.ToString().Length * fe.MaxXAdvance); + leftMargin += (int)Math.Ceiling((double)buffer.LineCount.ToString().Length * fe.MaxXAdvance) +6; if (foldingEnabled) leftMargin += foldSize; if (leftMargin > 0) @@ -272,6 +272,7 @@ namespace Crow.Coding return; Configuration.Set ("PrintLineNumbers", value); NotifyValueChanged ("PrintLineNumbers", PrintLineNumbers); + measureLeftMargin (); RegisterForGraphicUpdate (); } } @@ -924,16 +925,20 @@ namespace Crow.Coding if (!this.Focusable) return; - base.onMouseDown (sender, e); + if (mouseLocalPos.X >= leftMargin) + base.onMouseDown (sender, e); if (doubleClicked) { doubleClicked = false; return; } - updateCurrentPos (); - SelBegin = SelRelease = CurrentPosition; - + if (mouseLocalPos.X < leftMargin) { + toogleFolding (parser.Tokens.IndexOf (PrintedLines[(int)Math.Max (0, Math.Floor (mouseLocalPos.Y / fe.Height))])); + } else { + updateCurrentPos (); + SelBegin = SelRelease = CurrentPosition; + } RegisterForRedraw(); } public override void onMouseUp (object sender, MouseButtonEventArgs e) diff --git a/ui/EditorOptions.crow b/ui/EditorOptions.crow new file mode 100644 index 0000000..bf2a2bc --- /dev/null +++ b/ui/EditorOptions.crow @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ui/main.crow b/ui/main.crow index 04ecc85..edad15d 100755 --- a/ui/main.crow +++ b/ui/main.crow @@ -9,12 +9,13 @@ - + +