diff --git a/Src/VimMac/AlternateKeyUtil.cs b/Src/VimMac/AlternateKeyUtil.cs index d0e7f2d1e2..3bec25aeaa 100644 --- a/Src/VimMac/AlternateKeyUtil.cs +++ b/Src/VimMac/AlternateKeyUtil.cs @@ -116,19 +116,19 @@ internal static VimKeyModifiers ConvertToKeyModifiers(NSEventModifierMask keys) var res = VimKeyModifiers.None; if (keys.HasFlag(NSEventModifierMask.ShiftKeyMask)) { - res = res | VimKeyModifiers.Shift; + res |= VimKeyModifiers.Shift; } if (keys.HasFlag(NSEventModifierMask.AlternateKeyMask)) { - res = res | VimKeyModifiers.Alt; + res |= VimKeyModifiers.Alt; } if (keys.HasFlag(NSEventModifierMask.ControlKeyMask)) { - res = res | VimKeyModifiers.Control; + res |= VimKeyModifiers.Control; } if (keys.HasFlag(NSEventModifierMask.CommandKeyMask)) { - res = res | VimKeyModifiers.Command; + res |= VimKeyModifiers.Command; } return res; } @@ -138,19 +138,19 @@ internal static NSEventModifierMask ConvertToModifierKeys(VimKeyModifiers keys) NSEventModifierMask res = 0; if (0 != (keys & VimKeyModifiers.Shift)) { - res = res | NSEventModifierMask.ShiftKeyMask; + res |= NSEventModifierMask.ShiftKeyMask; } if (0 != (keys & VimKeyModifiers.Alt)) { - res = res | NSEventModifierMask.AlternateKeyMask; + res |= NSEventModifierMask.AlternateKeyMask; } if (0 != (keys & VimKeyModifiers.Control)) { - res = res | NSEventModifierMask.ControlKeyMask; + res |= NSEventModifierMask.ControlKeyMask; } if (0 != (keys & VimKeyModifiers.Command)) { - res = res | NSEventModifierMask.CommandKeyMask; + res |= NSEventModifierMask.CommandKeyMask; } return res; } @@ -196,7 +196,7 @@ bool IKeyUtil.TryConvertSpecialToKeyInput(NSEvent theEvent, out KeyInput keyInpu // correspond to an ASCII control key (like ), we need to convert it here. // This is needed because key combinations like won't be passed to // TextInput, because they can't be represented as system or control text. - // We just haijsshhhyuusdgdfve to be careful not to shadow any keys that produce text when + // We just have to be careful not to shadow any keys that produce text when // combined with the AltGr key. if (modifierKeys != 0 && modifierKeys != NSEventModifierMask.AlternateKeyMask @@ -249,63 +249,8 @@ private bool GetKeyInputFromKey(NSEvent theEvent, NSEventModifierMask modifierKe } keyInput = null; return false; - } - - private bool GetCharFromKey(NSKey key, NSEventModifierMask modifierKeys, out char unicodeChar) - { - - //// From the documentation for GetKeyboardState: - //// - If the high-order bit is 1, the key is down; otherwise, it is up. - //const byte keyIsDown = 0x80; - //const byte keyIsUp = 0x00; - - //// Use interop and pinvoke to get the scan code and keyboard layout. - //var virtualKey = (uint)KeyInterop.VirtualKeyFromKey(key); - //var scanCode = NativeMethods.MapVirtualKey(virtualKey, NativeMethods.MAPVK_VK_TO_VSC); - //StringBuilder stringBuilder = new StringBuilder(1); - //var keyboardLayout = NativeMethods.GetKeyboardLayout(0); - - //// Fail if the AltGr modifier is set and the key produces a character - //// when AltGr is pressed. We want to disambiguate Ctrl+Alt from AltGr. - //if (IsAltGr(modifierKeys)) - //{ - // // Mark control and alt (and their merged virtual keys) as pressed. - // // This is conceptually equivalent to passing in the modifier - // // keys control and alt. - // _keyboardState[NativeMethods.VK_LCONTROL] = keyIsDown; - // _keyboardState[NativeMethods.VK_LMENU] = keyIsDown; - // _keyboardState[NativeMethods.VK_CONTROL] = keyIsDown; - // _keyboardState[NativeMethods.VK_MENU] = keyIsDown; - // int altGrResult = NativeMethods.ToUnicodeEx(virtualKey, scanCode, - // _keyboardState, stringBuilder, stringBuilder.Capacity, 0, keyboardLayout); - // if (altGrResult == 1) - // { - // VimTrace.TraceInfo("AlternateKeyUtil::GetCharFromKey AltGr {0} -> {1}", - // key, stringBuilder[0]); - // unicodeChar = default(char); - // return false; - // } - //} - - //// Return the "base" key (or AltGr level 1) for the scan code. - //// This is the unicode character that would be produced if the - //// the key were pressed with no modifiers. - //// This is conceptually equivalent to passing in modifier keys none. - //_keyboardState[NativeMethods.VK_LCONTROL] = keyIsUp; - //_keyboardState[NativeMethods.VK_LMENU] = keyIsUp; - //_keyboardState[NativeMethods.VK_CONTROL] = keyIsUp; - //_keyboardState[NativeMethods.VK_MENU] = keyIsUp; - //int result = NativeMethods.ToUnicodeEx(virtualKey, scanCode, - // _keyboardState, stringBuilder, stringBuilder.Capacity, 0, keyboardLayout); - //if (result == 1) - //{ - // unicodeChar = stringBuilder[0]; - // return true; - //} - unicodeChar = default(char); - return false; - } - + } + #endregion } } diff --git a/Src/VimMac/VimHost.cs b/Src/VimMac/VimHost.cs index 3c4d3b4242..509540292d 100644 --- a/Src/VimMac/VimHost.cs +++ b/Src/VimMac/VimHost.cs @@ -105,7 +105,6 @@ public void CloseAllOtherWindows(ITextView textView) Dispatch(FileTabCommands.CloseAllButThis); } - //TODO: Same as WPF version (_except_ _textEditorFactoryService is an instance of ICocoaTextEditorFactoryService) /// /// Create a hidden ITextView. It will have no roles in order to keep it out of /// most plugins @@ -149,7 +148,7 @@ public void EnsureVisible(ITextView textView, SnapshotPoint point) } catch (Exception) { - // The ITextViewLine implementation canq throw if this code runs in the middle of + // The ITextViewLine implementation can throw if this code runs in the middle of // a layout or if the line believes itself to be invalid. Hard to completely guard // against this } diff --git a/Src/VimMac/WindowManagement.cs b/Src/VimMac/WindowManagement.cs index b4bec9c356..3704bbfda3 100644 --- a/Src/VimMac/WindowManagement.cs +++ b/Src/VimMac/WindowManagement.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; -using MonoDevelop.Ide; using System.Reflection; +using MonoDevelop.Ide; namespace Vim.Mac { @@ -37,22 +37,25 @@ private static Notebook ToNotebook(object obj) var children = (object[])childrenProperty.GetValue(obj); bool isActiveNotebook = false; int currentTab = 0; + if (children.Length > 0) { var tabstrip = children[0]; var tabstripType = tabstrip.GetType(); isActiveNotebook = (bool)tabstripType.GetProperty("IsActiveNotebook").GetValue(tabstrip); - } + currentTab = (int)notebookType.GetProperty("CurrentTabIndex", instanceFlags).GetValue(obj); var tabs = (IEnumerable)notebookType.GetProperty("Tabs", instanceFlags).GetValue(obj); + var files = tabs.Select(tab => { var tabType = tab.GetType(); var fileName = (string)tabType.GetProperty("Tooltip", instanceFlags).GetValue(tab); return fileName; }).ToImmutableArray(); + return new Notebook(isActiveNotebook, currentTab, files); }