diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2016-04-06 20:30:44 +0300 |
---|---|---|
committer | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2016-04-06 20:32:54 +0300 |
commit | eeeb6c31f3185362dd09179c873365eb9130cf70 (patch) | |
tree | 12d3ffe8308d0f932ca70b2f01d9e5fe90389abf /main/src/core/Mono.Texteditor | |
parent | 732b7aa279b320cc93747da46607de87afd71b1d (diff) |
Revert "[Ide] Asynchronize OnTheFly formatting."
This reverts commit 90f9f7622057b998f802a58bb4c6aa0589a0a93e.
This introduced an issue with the completion widget, as it is not fully
async safe.
Diffstat (limited to 'main/src/core/Mono.Texteditor')
-rw-r--r-- | main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/MonoTextEditor.cs | 7 | ||||
-rw-r--r-- | main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs | 59 |
2 files changed, 31 insertions, 35 deletions
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/MonoTextEditor.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/MonoTextEditor.cs index 68d3b04152..381d056ea7 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/MonoTextEditor.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/MonoTextEditor.cs @@ -36,8 +36,7 @@ using Mono.TextEditor.Theatrics; using Gdk; using Gtk; -using System.Threading.Tasks;
-
+ namespace Mono.TextEditor { [System.ComponentModel.Category("Mono.TextEditor")] @@ -877,10 +876,10 @@ namespace Mono.TextEditor /// <remarks> /// The Key may be null if it has been handled by the IMContext. In such cases, the char is the value. /// </remarks> - protected internal virtual Task<bool> OnIMProcessedKeyPressEvent (Gdk.Key key, uint ch, Gdk.ModifierType state) + protected internal virtual bool OnIMProcessedKeyPressEvent (Gdk.Key key, uint ch, Gdk.ModifierType state) { SimulateKeyPress (key, ch, state); - return Task.FromResult (true); + return true; } public void SimulateKeyPress (Gdk.Key key, uint unicodeChar, ModifierType modifier) diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs index 0ae354d548..2f1fba8a8a 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs @@ -299,8 +299,6 @@ namespace Mono.TextEditor // This is required to properly handle resizing and rendering of children ResizeMode = ResizeMode.Queue; snooperID = Gtk.Key.SnooperInstall (TooltipKeySnooper); - - KeyPressEvent += OnKeyPress; } uint snooperID; @@ -599,7 +597,7 @@ namespace Mono.TextEditor } } - async void IMCommit (object sender, Gtk.CommitArgs ca) + void IMCommit (object sender, Gtk.CommitArgs ca) { if (!IsRealized || !IsFocus) return; @@ -616,9 +614,9 @@ namespace Mono.TextEditor //include the other pre-IM state *if* the post-IM char matches the pre-IM (key-mapped) one if (lastIMEventMappedChar == utf32Char && lastIMEventMappedChar == (uint)lastIMEventMappedKey) { - await editor.OnIMProcessedKeyPressEvent (lastIMEventMappedKey, lastIMEventMappedChar, lastIMEventMappedModifier); + editor.OnIMProcessedKeyPressEvent (lastIMEventMappedKey, lastIMEventMappedChar, lastIMEventMappedModifier); } else { - await editor.OnIMProcessedKeyPressEvent ((Gdk.Key)0, (uint)utf32Char, Gdk.ModifierType.None); + editor.OnIMProcessedKeyPressEvent ((Gdk.Key)0, (uint)utf32Char, Gdk.ModifierType.None); } } @@ -1017,53 +1015,52 @@ namespace Mono.TextEditor GdkWindow.Cursor = currentCursor = cursor; } - async void OnKeyPress (object sender, Gtk.KeyPressEventArgs args) + protected override bool OnKeyPressEvent (Gdk.EventKey evt) { - Gdk.EventKey evt = args.Event; - args.RetVal = true;
-
Gdk.Key key; Gdk.ModifierType mod; - KeyboardShortcut [] accels; - GtkWorkarounds.MapKeys (evt, out key, out mod, out accels);
- //HACK: we never call base.OnKeyPressEvent, so implement the popup key manually
+ KeyboardShortcut[] accels; + GtkWorkarounds.MapKeys (evt, out key, out mod, out accels); + //HACK: we never call base.OnKeyPressEvent, so implement the popup key manually if (key == Gdk.Key.Menu || (key == Gdk.Key.F10 && mod.HasFlag (ModifierType.ShiftMask))) { OnPopupMenu (); - return; + return true; } uint keyVal = (uint)key; CurrentMode.SelectValidShortcut (accels, out key, out mod); if (key == Gdk.Key.F1 && (mod & (ModifierType.ControlMask | ModifierType.ShiftMask)) == ModifierType.ControlMask) { var p = LocationToPoint (Caret.Location); ShowTooltip (Gdk.ModifierType.None, Caret.Offset, p.X, p.Y); - return; + return true; } if (key == Gdk.Key.F2 && textViewMargin.IsCodeSegmentPreviewWindowShown) { textViewMargin.OpenCodeSegmentEditor (); - return; - }
-
- //FIXME: why are we doing this?
+ return true; + } + + //FIXME: why are we doing this? if ((key == Gdk.Key.space || key == Gdk.Key.parenleft || key == Gdk.Key.parenright) && (mod & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask) - mod = Gdk.ModifierType.None;
-
- uint unicodeChar = Gdk.Keyval.ToUnicode (keyVal);
-
+ mod = Gdk.ModifierType.None; + + uint unicodeChar = Gdk.Keyval.ToUnicode (keyVal); + if (CurrentMode.WantsToPreemptIM || CurrentMode.PreemptIM (key, unicodeChar, mod)) { - ResetIMContext ();
- //FIXME: should call base.OnKeyPressEvent when SimulateKeyPress didn't handle the event
+ ResetIMContext (); + //FIXME: should call base.OnKeyPressEvent when SimulateKeyPress didn't handle the event SimulateKeyPress (key, unicodeChar, mod); - return; + return true; } bool filter = IMFilterKeyPress (evt, key, unicodeChar, mod); if (filter) - return;
-
- //FIXME: OnIMProcessedKeyPressEvent should return false when it didn't handle the event
- if (await editor.OnIMProcessedKeyPressEvent (key, unicodeChar, mod)) - return;
-
args.RetVal = false; + return true; + + //FIXME: OnIMProcessedKeyPressEvent should return false when it didn't handle the event + if (editor.OnIMProcessedKeyPressEvent (key, unicodeChar, mod)) + return true; + + return base.OnKeyPressEvent (evt); } + protected override bool OnKeyReleaseEvent (EventKey evnt) { |