if (cancel.IsCancellationRequested)
return;
- NotifyValueChanged("Exceptions", Exceptions);
+ /*NotifyValueChanged("Exceptions", Exceptions);
NotifyValueChanged ("SyntaxRootChildNodes", (object)null);
NotifyValueChanged ("SyntaxRootChildNodes", SyntaxRootChildNodes);
- Console.WriteLine("parse async finished");
+ Console.WriteLine("parse async finished");*/
}
}
}
\ No newline at end of file
Document currentDocument;
Editor currentEditor;
Project currentProject;
- public CommandGroup CommandsRoot, FileCommands, EditCommands, ViewCommands;
+ public CommandGroup CommandsRoot, FileCommands, EditCommands, ViewCommands, ToolBox;
public ObservableList<Document> OpenedDocuments = new ObservableList<Document> ();
public ObservableList<Service> Services = new ObservableList<Service> ();
public ObservableList<Plugin> Plugins = new ObservableList<Plugin> ();
//Debug.WriteLine ("Value changed: {0}->{1} = {2}", this, MemberName, _value);
ValueChanged.Raise (this, new ValueChangeEventArgs (MemberName, _value));
}
+ public void NotifyValueChanged (string MemberName, string _value)
+ {
+ //Debug.WriteLine ("Value changed: {0}->{1} = {2}", this, MemberName, _value);
+ ValueChanged.Raise (this, new ValueChangeEventArgs (MemberName, _value));
+ }
public void NotifyValueChanged (object _value, [CallerMemberName] string caller = null)
{
NotifyValueChanged (caller, _value);
using System.IO;
using System.Threading;
using Crow;
+using Glfw;
using static CrowEditBase.CrowEditBase;
namespace CrowEditBase
{
- public abstract class Document : CrowEditComponent {
+ public abstract class Document : CrowEditComponent, ICommandHost {
#region CTOR
public Document (string fullPath, string editorPath) {
initCommands ();
/// <value></value>
public string EditorPath { get; private set; }//the ressource path is used as an id for editor template selection.
public event EventHandler CloseEvent;
+ public event EventHandler<KeyEventArgs> KeyDown;
- protected ReaderWriterLockSlim documentRWLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
+ public bool OnKeyDown(object sender, KeyEventArgs e) {
+ if (KeyDown != null) {
+ KeyDown.Invoke (sender, e);
+ }
+
+ return e.Handled;
+ }
+
+ protected ReaderWriterLockSlim documentRWLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
public void EnterReadLock () => documentRWLock.EnterReadLock ();
public void ExitReadLock () => documentRWLock.ExitReadLock ();
public void EnterWriteLock () => documentRWLock.EnterWriteLock ();
fullPath = value;
NotifyValueChanged (fullPath);
- NotifyValueChanged ("FileName", (object)FileName);
- NotifyValueChanged ("FileDirectory", (object)Extension);
- NotifyValueChanged ("Extension", (object)Extension);
+ NotifyValueChanged ("FileName", FileName);
+ NotifyValueChanged ("FileDirectory", FileDirectory);
+ NotifyValueChanged ("Extension", Extension);
}
}
public string FileDirectory => System.IO.Path.GetDirectoryName (FullPath);
(DateTime.Compare (accessTime, System.IO.File.GetLastWriteTime (FullPath)) < 0) : false;
#region commands
- public Command CMDUndo, CMDRedo, CMDSave, CMDSaveAs;
Command CMDClose, CMDCloseOther;
+ public Command CMDUndo, CMDRedo, CMDSave, CMDSaveAs;
public CommandGroup TabCommands => new CommandGroup (
CMDClose, CMDCloseOther
);
protected virtual void initCommands () {
- CMDUndo = new ActionCommand ("Undo", undo, "#icons.reply.svg", false);
- CMDRedo = new ActionCommand ("Redo", redo, "#icons.share-arrow.svg", false);
- CMDSave = new ActionCommand ("save", Save, "#icons.inbox.svg", false);
+ CMDUndo = new ActionCommand (this, "Undo", Undo, "#icons.reply.svg", new KeyBinding(Key.Z, Modifier.Control), false);
+ CMDRedo = new ActionCommand (this, "Redo", Redo, "#icons.share-arrow.svg", new KeyBinding(Key.Z, Modifier.Control | Modifier.Shift), false);
+
+ CMDSave = new ActionCommand (this, "save", Save, "#icons.inbox.svg", new KeyBinding(Key.S, Modifier.Control), false);
CMDSaveAs = new ActionCommand ("Save As...", SaveAs, "#icons.inbox.svg");
+
CMDClose = new ActionCommand ("Close", () => App.CloseDocument (this), "#icons.sign-out.svg");
CMDCloseOther = new ActionCommand ("Close Others", () => App.CloseOthers (this), "#icons.inbox.svg");
}
public abstract void RegisterClient (object client, bool initialState = false);
public abstract void UnregisterClient (object client);
protected abstract void saveFileDialog_OkClicked (object sender, EventArgs e);
- protected abstract void undo();
- protected abstract void redo();
+ public abstract void Undo();
+ public abstract void Redo();
protected abstract void writeToDisk ();
protected abstract void readFromDisk ();
protected abstract void initNewFile ();
CMDCut = new ActionCommand (this, "Cut", Cut, "#icons.scissors.svg", new KeyBinding(Key.X, Modifier.Control), false);
CMDCopy = new ActionCommand (this, "Copy", Copy, "#icons.copy-file.svg", new KeyBinding(Key.C, Modifier.Control), false);
CMDPaste = new ActionCommand (this, "Paste", Paste, "#icons.paste-on-document.svg", new KeyBinding(Key.P, Modifier.Control), true);
-
ContextCommands = new CommandGroup (CMDCut, CMDCopy, CMDPaste);
}
}
protected override void onDraw (IContext gr)
{
- //base.onDraw (gr);
-
gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
gr.SetFontSize (Font.Size);
if (!e.Handled) {
TextSpan selection = Selection;
update (new TextChange (selection.Start, selection.Length, e.KeyChar.ToString ()));
-
e.Handled = true;
}
- /*Insert (e.KeyChar.ToString());
-
- SelRelease = -1;
- SelBegin = new Point(CurrentColumn, SelBegin.Y);
-
- RegisterForGraphicUpdate();*/
}
public override void onKeyDown (object sender, KeyEventArgs e) {
Key key = e.Key;
TextSpan selection = Selection;
- /*document.EnterReadLock();
- try {*/
- switch (key) {
+ if (document != null && document.OnKeyDown(sender, e))
+ return;
+
+ switch (key) {
case Key.Backspace:
if (selection.IsEmpty) {
if (selection.Start == 0)
default:
base.onKeyDown (sender, e);
return;
- }
- autoAdjustScroll = true;
- IFace.forceTextCursor();
- e.Handled = true;
- /*} finally {
- document.ExitReadLock ();
- }*/
+ }
+ autoAdjustScroll = true;
+ IFace.forceTextCursor();
+ e.Handled = true;
}
#endregion
#endregion
update (new TextChange (selection.Start, selection.Length, IFace.Clipboard));
}
+
+
protected virtual void update (TextChange change) {
if (!disableTextChangedEvent)
OnTextChanged (this, new TextChangeEventArgs (change));
writeToDisk ();
}
- protected override void undo () {
+ public override void Undo () {
documentRWLock.EnterWriteLock ();
try {
if (undoStack.TryPop (out TextChange tc)) {
documentRWLock.ExitWriteLock ();
}
}
- protected override void redo () {
+ public override void Redo () {
documentRWLock.EnterWriteLock ();
try {
if (redoStack.TryPop (out TextChange tc)) {
--- /dev/null
+<?xml version="1.0"?>
+<Button Command="{}" Width="Fit" BubbleEvents="All" MinimumSize="0,0">
+ <Template>
+ <Border Style="ButtonBorder" Width="Stretched" Height="Stretched" Margin="4" Background="{./Background}" CornerRadius="{../CornerRadius}">
+ <Image Path="{./Icon}" Tooltip="{./Caption}" Scaled="true" KeepProportions="true" Margin="0"/>
+ </Border>
+ </Template>
+</Button>
CMDEditMode.CanExecute = !value;
CMDRun.CanExecute = value;
NotifyValueChanged(value);
+ ForceDirtyState();
}
}
public double ZoomFactor {
if (IsRunning)
delUnlockRenderMutex();
}
- public bool GetDirtyState => IsRunning ? (bool)fiDbgIFace_IsDirty.GetValue (dbgIFace) : false;
+
+ bool dirtyState = false;
+ bool DirtyState {
+ get {
+ if (dirtyState) {
+ dirtyState = false;
+ return true;
+ } else
+ return false;
+ }
+ }
+ // force repaint of preview widget without debug interface update.
+ bool ForceDirtyState() => dirtyState = true;
+
+ public bool GetDirtyState => IsRunning ? (bool)fiDbgIFace_IsDirty.GetValue (dbgIFace) | DirtyState : false;
public bool DesignModeEnabled => IsRunning && ForeignWidgetContainer.fiWidget_design_id != null ? true : false;
public Type GetWidgetTypeFromeName(string typeName) {
if (!IsRunning)
designColumn = (int)fiWidget_design_column?.GetValue(instance);
designImlPath = (string)fiWidget_design_imlPath?.GetValue(instance);
- Console.WriteLine($"new ForeignWidgetContainer: {this} {parent}");
+ //Console.WriteLine($"new ForeignWidgetContainer: {this} {parent}");
}
}
}
public string TemplateContainerSource {
- get => conf.Get (nameof(TemplateContainerSource), "<Button/>");
+ get => conf.Get (nameof(TemplateContainerSource), "<Button>");
set {
if (TemplateContainerSource == value)
return;
saveWinConfigs ();
}
- public Command CMDSave, CMDSaveAs, CMDQuit, CMDHelp, CMDAbout, CMDOptions;
+ public Command CMDNew, CMDOpen, CMDSave, CMDSaveAs, CMDQuit, CMDHelp, CMDAbout, CMDOptions;
public Command CMDSyntaxTheme_Reload, CMDSyntaxTheme_Save, CMDSyntaxTheme_SaveAs;
void initCommands (){
+ CMDNew = new ActionCommand("New", createNewFile, "#icons.blank-file.svg");
+ CMDOpen = new ActionCommand("Open...", openFileDialog, "#icons.outbox.svg");
+ CMDSave = new ActionCommand ("save", default(Action), "#icons.inbox.svg", false);
FileCommands = new CommandGroup ("File",
- new ActionCommand("New", createNewFile, "#icons.blank-file.svg"),
- new ActionCommand("Open...", openFileDialog, "#icons.outbox.svg"),
- new ActionCommand ("save", default(Action), "#icons.inbox.svg", false),
+ CMDNew,
+ CMDOpen,
+ CMDSave,
new ActionCommand ("Save As...", default(Action), "#icons.inbox.svg", false),
new ActionCommand("Options", openOptionsDialog, "#icons.tools.svg"),
new ActionCommand("Quit", base.Quit, "#icons.sign-out.svg")
new CommandGroup ("Help", CMDHelp)
);
+ ToolBox = new CommandGroup (CMDNew, CMDOpen, EditCommands);
+
CMDSyntaxTheme_Reload = new ActionCommand ("Reload", () => reloadSyntaxTheme ());
CMDSyntaxTheme_Save = new ActionCommand ("Save", () => saveSyntaxTheme ());
CMDSyntaxTheme_SaveAs = new ActionCommand ("Save As...", () => saveSyntaxThemeAs ());
</MenuItem>
</ItemTemplate>
</Menu>
+ <Menu Data="{ToolBox}" IsVisible="{CMDShowToolBox}" Margin="1">
+ <ItemTemplate DataType="Crow.Command" Path="#ui.IconButton.template"/>
+ <ItemTemplate DataType="Crow.CommandGroup">
+ <MenuItem Data="{Commands}" Width="Fit" IsEnabled="{CanExecute}"
+ ItemTemplate="#ui.IconButton.template">
+ <Template>
+ <HorizontalStack Name="ItemsContainer" Margin="0"/>
+ </Template>
+ </MenuItem>
+ </ItemTemplate>
+ </Menu>
<DockStack Name="mainDock" RootDataLevel="true" Background="DarkGrey"/>
</VerticalStack>
<HorizontalStack Height="Fit" Spacing="5" Margin="0">
<Widget Width="Stretched"/>
<EnumSelector Caption="Filter:" EnumValue="{²../../log.Filter}" />
- <TextBox Background="Grey" Foreground="Black" Text="{²../../log.SearchString}" Width="200" KeyDown="../../log.onSearch" Font="${SmallUIFont}"/>
- <CheckBox Fit="true" Caption="Case Sensitive" IsChecked="{²../../log.CaseSensitiveSearch}" Font="${SmallUIFont}"/>
- <CheckBox Fit="true" Caption="All Word" IsChecked="{²../../log.AllWordSearch}" Font="${SmallUIFont}"/>
- <Menu Style="DockWinTitleBarMenu" Data="{../../log.SearchCommands}" Fit="true" Background="Transparent"/>
+ <HorizontalStack Height="Fit" Spacing="3" Margin="0" Background="Grey">
+ <TextBox Background="Transparent" Foreground="Black" Text="{²../../../log.SearchString}" Width="200" KeyDown="../../../log.onSearch" Font="${SmallUIFont}"/>
+ <CheckBox Fit="true" Caption="Case Sensitive" IsChecked="{²../../../log.CaseSensitiveSearch}" Font="${SmallUIFont}"/>
+ <CheckBox Fit="true" Caption="All Word" IsChecked="{²../../../log.AllWordSearch}" Font="${SmallUIFont}"/>
+ <Menu Style="DockWinTitleBarMenu" Data="{../../../log.SearchCommands}" Fit="true" Background="Transparent"/>
+ </HorizontalStack>
</HorizontalStack>
<HorizontalStack Spacing="0">
<LogViewerWidget Name="log" Logger="{}" Font="${SmallFont}" MaxScrollX="6000" ContextCommands="{Commands}" CurrentEntryIndex="{²SelectedIndex}"/>