예제 #1
0
        protected VimTestBase()
        {
            _vim = CompositionContainer.GetExportedValue<IVim>();
            _vimBufferFactory = CompositionContainer.GetExportedValue<IVimBufferFactory>();
            _vimErrorDetector = CompositionContainer.GetExportedValue<IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue<ICommonOperationsFactory>();
            _wordUtilFactory = CompositionContainer.GetExportedValue<IWordUtilFactory>();
            _bufferTrackingService = CompositionContainer.GetExportedValue<IBufferTrackingService>();
            _foldManagerFactory = CompositionContainer.GetExportedValue<IFoldManagerFactory>();
            _bulkOperations = CompositionContainer.GetExportedValue<IBulkOperations>();
            _keyUtil = CompositionContainer.GetExportedValue<IKeyUtil>();

            _keyboardDevice = CompositionContainer.GetExportedValue<IKeyboardDevice>();
            _mouseDevice = CompositionContainer.GetExportedValue<IMouseDevice>();
            _clipboardDevice = CompositionContainer.GetExportedValue<IClipboardDevice>();
            _clipboardDevice.Text = String.Empty;

            // One setting we do differ on for a default is 'timeout'.  We don't want them interferring
            // with the reliability of tests.  The default is on but turn it off here to prevent any
            // problems
            _vim.GlobalSettings.Timeout = false;

            // Don't let the personal VimRc of the user interfere with the unit tests
            _vim.AutoLoadVimRc = false;

            // Don't show trace information in the unit tests.  It really clutters the output in an
            // xUnit run
            VimTrace.TraceSwitch.Level = TraceLevel.Off;
        }
예제 #2
0
        public void Focus(IInputElement control)
        {
            IInteractive current = this.Current as IInteractive;
            IInteractive next    = control as IInteractive;

            if (current != null)
            {
                current.RaiseEvent(new RoutedEventArgs
                {
                    RoutedEvent    = InputElement.LostFocusEvent,
                    Source         = current,
                    OriginalSource = current,
                });
            }

            this.Current = control;

            IKeyboardDevice keyboard = Locator.Current.GetService <IKeyboardDevice>();

            if (keyboard != null)
            {
                keyboard.FocusedElement = control;
            }

            if (next != null)
            {
                next.RaiseEvent(new RoutedEventArgs
                {
                    RoutedEvent    = InputElement.GotFocusEvent,
                    Source         = next,
                    OriginalSource = next,
                });
            }
        }
예제 #3
0
 public Player(IKeyboardDevice keyboard) : this()
 {
     //Setup input.
     this.keyboard     = keyboard;
     keyboard.KeyDown += OnKeyboardKeyDown;
     keyboard.KeyUp   += OnKeyboardKeyUp;
 }
예제 #4
0
        protected VimTestBase()
        {
            _vim = CompositionContainer.GetExportedValue <IVim>();
            _vimBufferFactory        = CompositionContainer.GetExportedValue <IVimBufferFactory>();
            _vimErrorDetector        = CompositionContainer.GetExportedValue <IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue <ICommonOperationsFactory>();
            _wordUtilFactory         = CompositionContainer.GetExportedValue <IWordUtilFactory>();
            _bufferTrackingService   = CompositionContainer.GetExportedValue <IBufferTrackingService>();
            _foldManagerFactory      = CompositionContainer.GetExportedValue <IFoldManagerFactory>();
            _bulkOperations          = CompositionContainer.GetExportedValue <IBulkOperations>();
            _keyUtil = CompositionContainer.GetExportedValue <IKeyUtil>();

            _keyboardDevice       = CompositionContainer.GetExportedValue <IKeyboardDevice>();
            _mouseDevice          = CompositionContainer.GetExportedValue <IMouseDevice>();
            _clipboardDevice      = CompositionContainer.GetExportedValue <IClipboardDevice>();
            _clipboardDevice.Text = String.Empty;

            // One setting we do differ on for a default is 'timeout'.  We don't want them interferring
            // with the reliability of tests.  The default is on but turn it off here to prevent any
            // problems
            _vim.GlobalSettings.Timeout = false;

            // Don't let the personal VimRc of the user interfere with the unit tests
            _vim.AutoLoadVimRc = false;

            // Don't show trace information in the unit tests.  It really clutters the output in an
            // xUnit run
            VimTrace.TraceSwitch.Level = TraceLevel.Off;
        }
예제 #5
0
 /// <summary>
 /// Signs that the device has been attached to the Spectrum virtual machine
 /// </summary>
 public override void OnAttachedToVm(ISpectrumVm hostVm)
 {
     base.OnAttachedToVm(hostVm);
     _screenDevice   = hostVm.ScreenDevice;
     _beeperDevice   = hostVm.BeeperDevice;
     _keyboardDevice = hostVm.KeyboardDevice;
     _tapeDevice     = hostVm.TapeDevice;
 }
예제 #6
0
 internal VimMouseProcessorProvider(
     IVim vim,
     IKeyboardDevice keyboardDevice,
     IProtectedOperations protectedOperations)
 {
     _vim                 = vim;
     _keyboardDevice      = keyboardDevice;
     _protectedOperations = protectedOperations;
 }
예제 #7
0
 /// <summary>
 /// Signs that the device has been attached to the Spectrum virtual machine
 /// </summary>
 public void OnAttachedToVm(ISpectrumVm hostVm)
 {
     HostVm          = hostVm;
     _cpu            = hostVm.Cpu;
     _borderDevice   = hostVm.BorderDevice;
     _beeperDevice   = hostVm.BeeperDevice;
     _keyboardDevice = hostVm.KeyboardDevice;
     _tapeDevice     = hostVm.TapeDevice;
 }
예제 #8
0
 public RawTextInputEventArgs(
     IKeyboardDevice device,
     ulong timestamp,
     IInputRoot root,
     string text)
     : base(device, timestamp, root)
 {
     Text = text;
 }
예제 #9
0
        public WindowBaseImpl(AvaloniaNativePlatformOptions opts)
        {
            _gpu = opts.UseGpu;
            _deferredRendering = opts.UseDeferredRendering;

            _keyboard      = AvaloniaLocator.Current.GetService <IKeyboardDevice>();
            _mouse         = AvaloniaLocator.Current.GetService <IMouseDevice>();
            _cursorFactory = AvaloniaLocator.Current.GetService <IStandardCursorFactory>();
        }
예제 #10
0
 public HeadlessWindowImpl(bool isPopup)
 {
     IsPopup       = isPopup;
     Surfaces      = new object[] { this };
     _keyboard     = AvaloniaLocator.Current.GetService <IKeyboardDevice>();
     _mousePointer = new Pointer(Pointer.GetNextFreeId(), PointerType.Mouse, true);
     MouseDevice   = new MouseDevice(_mousePointer);
     ClientSize    = new Size(1024, 768);
 }
예제 #11
0
        internal WindowBaseImpl(AvaloniaNativePlatformOptions opts, GlPlatformFeature glFeature)
        {
            _gpu = opts.UseGpu && glFeature != null;
            _deferredRendering = opts.UseDeferredRendering;

            _keyboard      = AvaloniaLocator.Current.GetService <IKeyboardDevice>();
            _mouse         = new MouseDevice();
            _cursorFactory = AvaloniaLocator.Current.GetService <IStandardCursorFactory>();
        }
예제 #12
0
            public TopLevelView(TopLevelImpl tl)
            {
                _tl       = tl;
                _mouse    = AvaloniaLocator.Current.GetService <IMouseDevice>();
                _keyboard = AvaloniaLocator.Current.GetService <IKeyboardDevice>();

                RegisterForDraggedTypes(new string[] {
                    "public.data" // register for any kind of data.
                });
            }
예제 #13
0
 public RawTextInputEventArgs(
     IKeyboardDevice device,
     ulong timestamp,
     IInputRoot root,
     string text,
     RawInputModifiers modifiers)
     : base(device, timestamp, root)
 {
     Text      = text;
     Modifiers = modifiers;
 }
        internal WindowBaseImpl(IAvaloniaNativeFactory factory, AvaloniaNativePlatformOptions opts,
                                AvaloniaNativePlatformOpenGlInterface glFeature)
        {
            _factory           = factory;
            _gpu               = opts.UseGpu && glFeature != null;
            _deferredRendering = opts.UseDeferredRendering;

            _keyboard      = AvaloniaLocator.Current.GetService <IKeyboardDevice>();
            _mouse         = new MouseDevice();
            _cursorFactory = AvaloniaLocator.Current.GetService <ICursorFactory>();
        }
예제 #15
0
        public override void Initialize(IGameEngine engine)
        {
            base.Initialize(engine);

            // Get mouse device.
            Device = Engine.Systems.First <IInputDeviceSystem>().First(d => d is IKeyboardDevice)
                     as IKeyboardDevice;

            // Initialize manager.
            manager = new KeyboardInputManager(Device);
        }
예제 #16
0
 public RawKeyEventArgs(
     IKeyboardDevice device,
     uint timestamp,
     RawKeyEventType type,
     Key key, ModifierKeys modifiers)
     : base(device, timestamp)
 {
     Key = key;
     Type = type;
     Modifiers = modifiers;
 }
예제 #17
0
 public RawKeyEventArgs(
     IKeyboardDevice device,
     uint timestamp,
     RawKeyEventType type,
     Key key, InputModifiers modifiers)
     : base(device, timestamp)
 {
     Key       = key;
     Type      = type;
     Modifiers = modifiers;
 }
예제 #18
0
 public RawKeyEventArgs(
     IKeyboardDevice device, 
     uint timestamp,
     RawKeyEventType type, 
     Key key, 
     string text)
     : base(device, timestamp)
 {
     this.Key = key;
     this.Type = type;
     this.Text = text;
 }
예제 #19
0
 public RawKeyEventArgs(
     IKeyboardDevice device,
     ulong timestamp,
     IInputRoot root,
     RawKeyEventType type,
     Key key, RawInputModifiers modifiers)
     : base(device, timestamp, root)
 {
     Key       = key;
     Type      = type;
     Modifiers = modifiers;
 }
예제 #20
0
 /// <summary>
 /// Signs that the device has been attached to the Spectrum virtual machine
 /// </summary>
 public override void OnAttachedToVm(ISpectrumVm hostVm)
 {
     base.OnAttachedToVm(hostVm);
     _isUla3           = hostVm.UlaIssue == "3";
     _cpu              = hostVm.Cpu;
     _screenDevice     = hostVm.ScreenDevice;
     _beeperDevice     = hostVm.BeeperDevice;
     _keyboardDevice   = hostVm.KeyboardDevice;
     _tapeDevice       = hostVm.TapeDevice;
     _bit3LastValue    = true;
     _bit4LastValue    = true;
     _bit4ChangedFrom0 = 0;
     _bit4ChangedFrom1 = 0;
 }
예제 #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Keyboard"/> class.
        /// </summary>
        /// <param name="keyboardDevice">The keyboard device.</param>
        /// <param name="scanCodeMap">The scan code map.</param>
        public Keyboard(IKeyboardDevice keyboardDevice, IScanCodeMap scanCodeMap)
        {
            this.keyboardDevice = keyboardDevice;
            this.scanCodeMap = scanCodeMap;
            ScrollLock = false;
            CapLock = false;
            NumLock = false;

            LeftControl = false;
            RightControl = false;
            LeftAlt = false;
            RightAlt = false;
            LeftShift = false;
            RightShift = false;
        }
예제 #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Keyboard"/> class.
        /// </summary>
        /// <param name="keyboardDevice">The keyboard device.</param>
        /// <param name="scanCodeMap">The scan code map.</param>
        public Keyboard(IKeyboardDevice keyboardDevice, IScanCodeMap scanCodeMap)
        {
            this.keyboardDevice = keyboardDevice;
            this.scanCodeMap    = scanCodeMap;
            ScrollLock          = false;
            CapLock             = false;
            NumLock             = false;

            LeftControl  = false;
            RightControl = false;
            LeftAlt      = false;
            RightAlt     = false;
            LeftShift    = false;
            RightShift   = false;
        }
예제 #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Keyboard"/> class.
        /// </summary>
        /// <param name="keyboardDevice">The keyboard device.</param>
        /// <param name="scanCodeMap">The scan code map.</param>
        public Keyboard(IKeyboardDevice keyboardDevice, IScanCodeMap scanCodeMap)
        {
            this.keyboardDevice = keyboardDevice;
            this.scanCodeMap    = scanCodeMap;
            scrollLock          = false;
            capLock             = false;
            numLock             = false;

            leftControl  = false;
            rightControl = false;
            leftAlt      = false;
            rightAlt     = false;
            leftShift    = false;
            rightShift   = false;
        }
예제 #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Keyboard"/> class.
        /// </summary>
        /// <param name="keyboardDevice">The keyboard device.</param>
        /// <param name="scanCodeMap">The scan code map.</param>
        public Keyboard(IKeyboardDevice keyboardDevice, IScanCodeMap scanCodeMap)
        {
            this.keyboardDevice = keyboardDevice;
            this.scanCodeMap = scanCodeMap;
            scrollLock = false;
            capLock = false;
            numLock = false;

            leftControl = false;
            rightControl = false;
            leftAlt = false;
            rightAlt = false;
            leftShift = false;
            rightShift = false;
        }
예제 #25
0
 internal VimMouseProcessor(
     IVimBuffer vimBuffer,
     IKeyboardDevice keyboardDevice,
     IProtectedOperations protectedOperations)
 {
     _vimBuffer      = vimBuffer;
     _keyboardDevice = keyboardDevice;
     _wpfTextView    = (IWpfTextView)_vimBuffer.TextView;
     _mouseDevice    = InputManager.Current.PrimaryMouseDevice;
     _mouseCaptured  = false;
     _scrollTimer    = new DispatcherTimer(
         new TimeSpan(0, 0, 0, 0, 1000 / s_linesPerSecond),
         DispatcherPriority.Normal,
         protectedOperations.GetProtectedEventHandler(OnScrollTimer),
         Dispatcher.CurrentDispatcher);
 }
예제 #26
0
        public WpfTopLevelImpl()
        {
            PresentationSource.AddSourceChangedHandler(this, OnSourceChanged);
            _hook     = WndProc;
            _ttl      = this;
            _surfaces = new object[] { new WritableBitmapSurface(this), new Direct2DImageSurface(this) };
            _mouse    = new WpfMouseDevice(this);
            _keyboard = AvaloniaLocator.Current.GetService <IKeyboardDevice>();

            ControlRoot         = new CustomControlRoot(this);
            SnapsToDevicePixels = true;
            Focusable           = true;
            DataContextChanged += delegate
            {
                ControlRoot.DataContext = DataContext;
            };
        }
예제 #27
0
        public VimEditorHost(CompositionContainer compositionContainer)
            : base(compositionContainer)
        {
            _vim = CompositionContainer.GetExportedValue<IVim>();
            _vimBufferFactory = CompositionContainer.GetExportedValue<IVimBufferFactory>();
            _vimErrorDetector = CompositionContainer.GetExportedValue<IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue<ICommonOperationsFactory>();
            _wordUtil = CompositionContainer.GetExportedValue<IWordUtil>();
            _bufferTrackingService = CompositionContainer.GetExportedValue<IBufferTrackingService>();
            _foldManagerFactory = CompositionContainer.GetExportedValue<IFoldManagerFactory>();
            _bulkOperations = CompositionContainer.GetExportedValue<IBulkOperations>();
            _keyUtil = CompositionContainer.GetExportedValue<IKeyUtil>();
            _vimProtectedOperations = CompositionContainer.GetExportedValue<IVimProtectedOperations>();

            _keyboardDevice = CompositionContainer.GetExportedValue<IKeyboardDevice>();
            _mouseDevice = CompositionContainer.GetExportedValue<IMouseDevice>();
            _clipboardDevice = CompositionContainer.GetExportedValue<IClipboardDevice>();
        }
예제 #28
0
        public VimEditorHost(CompositionContainer compositionContainer) : base(compositionContainer)
        {
            _vim = CompositionContainer.GetExportedValue <IVim>();
            _vimBufferFactory        = CompositionContainer.GetExportedValue <IVimBufferFactory>();
            _vimErrorDetector        = CompositionContainer.GetExportedValue <IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue <ICommonOperationsFactory>();
            _bufferTrackingService   = CompositionContainer.GetExportedValue <IBufferTrackingService>();
            _foldManagerFactory      = CompositionContainer.GetExportedValue <IFoldManagerFactory>();
            _bulkOperations          = CompositionContainer.GetExportedValue <IBulkOperations>();
            _keyUtil             = CompositionContainer.GetExportedValue <IKeyUtil>();
            _protectedOperations = CompositionContainer.GetExportedValue <IProtectedOperations>();

            _keyboardDevice                 = CompositionContainer.GetExportedValue <IKeyboardDevice>();
            _mouseDevice                    = CompositionContainer.GetExportedValue <IMouseDevice>();
            _clipboardDevice                = CompositionContainer.GetExportedValue <IClipboardDevice>();
            _editorFormatMapService         = CompositionContainer.GetExportedValue <IEditorFormatMapService>();
            _classificationFormatMapService = CompositionContainer.GetExportedValue <IClassificationFormatMapService>();
        }
예제 #29
0
        /// <summary>
        /// Focuses a control.
        /// </summary>
        /// <param name="control">The control to focus.</param>
        public void Focus(IInputElement control)
        {
            Contract.Requires <ArgumentNullException>(control != null);

            var current = this.Current as IInteractive;
            var next    = control as IInteractive;
            var scope   = control.GetSelfAndVisualAncestors()
                          .OfType <IFocusScope>()
                          .FirstOrDefault();

            if (scope != null && control != current)
            {
                this.focusScopes[scope] = control;

                if (current != null)
                {
                    current.RaiseEvent(new RoutedEventArgs
                    {
                        RoutedEvent    = InputElement.LostFocusEvent,
                        Source         = current,
                        OriginalSource = current,
                    });
                }

                this.Current = control;

                IKeyboardDevice keyboard = Locator.Current.GetService <IKeyboardDevice>();

                if (keyboard != null)
                {
                    keyboard.FocusedElement = control;
                }

                if (next != null)
                {
                    next.RaiseEvent(new RoutedEventArgs
                    {
                        RoutedEvent    = InputElement.GotFocusEvent,
                        Source         = next,
                        OriginalSource = next,
                    });
                }
            }
        }
예제 #30
0
        public static Mock <IVim> CreateVim(
            IRegisterMap registerMap          = null,
            IMarkMap map                      = null,
            IVimGlobalSettings globalSettings = null,
            IVimGlobalAbbreviationMap globalAbbreviationMap = null,
            IVimGlobalKeyMap globalKeyMap = null,
            IVimHost host = null,
            IKeyboardDevice keyboardDevice = null,
            IMouseDevice mouseDevice       = null,
            IVimData vimData             = null,
            IMacroRecorder macroRecorder = null,
            ISearchService searchService = null,
            Dictionary <string, VariableValue> variableMap = null,
            MockRepository factory = null)
        {
            factory               = factory ?? new MockRepository(MockBehavior.Strict);
            registerMap           = registerMap ?? CreateRegisterMap().Object;
            map                   = map ?? new MarkMap(new BufferTrackingService());
            globalSettings        = globalSettings ?? new GlobalSettings();
            host                  = host ?? new MockVimHost();
            variableMap           = variableMap ?? new Dictionary <string, VariableValue>();
            globalKeyMap          = globalKeyMap ?? new GlobalKeyMap(variableMap);
            macroRecorder         = macroRecorder ?? CreateMacroRecorder(factory: factory).Object;
            searchService         = searchService ?? factory.Create <ISearchService>().Object;
            keyboardDevice        = keyboardDevice ?? (factory.Create <IKeyboardDevice>(MockBehavior.Loose)).Object;
            mouseDevice           = mouseDevice ?? (factory.Create <IMouseDevice>(MockBehavior.Loose)).Object;
            vimData               = vimData ?? VimUtil.CreateVimData();
            globalAbbreviationMap = globalAbbreviationMap ?? new GlobalAbbreviationMap();
            var mock = factory.Create <IVim>(MockBehavior.Strict);

            mock.SetupGet(x => x.RegisterMap).Returns(registerMap);
            mock.SetupGet(x => x.MarkMap).Returns(map);
            mock.SetupGet(x => x.GlobalSettings).Returns(globalSettings);
            mock.SetupGet(x => x.GlobalAbbreviationMap).Returns(globalAbbreviationMap);
            mock.SetupGet(x => x.GlobalKeyMap).Returns(globalKeyMap);
            mock.SetupGet(x => x.VimHost).Returns(host);
            mock.SetupGet(x => x.VimData).Returns(vimData);
            mock.SetupGet(x => x.MacroRecorder).Returns(macroRecorder);
            mock.SetupGet(x => x.SearchService).Returns(searchService);
            mock.SetupGet(x => x.VariableMap).Returns(variableMap);
            return(mock);
        }
예제 #31
0
파일: Ui.cs 프로젝트: Babelz/Fracture
        public Ui(string name,
                  IView view,
                  IStaticContainerControl root,
                  IMouseDevice mouse,
                  IKeyboardDevice keyboard)
        {
            Name = !string.IsNullOrEmpty(name) ? name : throw new ArgumentNullException(nameof(name));
            View = view ?? throw new ArgumentNullException(nameof(view));
            Root = root ?? throw new ArgumentNullException(nameof(root));

            this.mouse    = mouse ?? throw new ArgumentNullException(nameof(mouse));
            this.keyboard = keyboard ?? throw new ArgumentNullException(nameof(keyboard));

            var context = new ControlFocusManagerContext();

            mouseFocusManager    = new ControlMouseFocusManager(root, context);
            keyboardFocusManager = new ControlKeyboardFocusManager(root, context);

            UiCanvas.ScreenSizeChanged += UserInterfaceCanvas_ScreenSizeChanged;
        }
예제 #32
0
        protected VimTestBase()
        {
            // Parts of the core editor in Vs2012 depend on there being an Application.Current value else
            // they will throw a NullReferenceException.  Create one here to ensure the unit tests successfully
            // pass
            if (Application.Current == null)
            {
                new Application();
            }

            _vim = CompositionContainer.GetExportedValue <IVim>();
            _vimBufferFactory        = CompositionContainer.GetExportedValue <IVimBufferFactory>();
            _vimErrorDetector        = CompositionContainer.GetExportedValue <IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue <ICommonOperationsFactory>();
            _wordUtilFactory         = CompositionContainer.GetExportedValue <IWordUtilFactory>();
            _bufferTrackingService   = CompositionContainer.GetExportedValue <IBufferTrackingService>();
            _foldManagerFactory      = CompositionContainer.GetExportedValue <IFoldManagerFactory>();
            _bulkOperations          = CompositionContainer.GetExportedValue <IBulkOperations>();
            _keyUtil = CompositionContainer.GetExportedValue <IKeyUtil>();
            _vimProtectedOperations = CompositionContainer.GetExportedValue <IVimProtectedOperations>();

            _keyboardDevice       = CompositionContainer.GetExportedValue <IKeyboardDevice>();
            _mouseDevice          = CompositionContainer.GetExportedValue <IMouseDevice>();
            _clipboardDevice      = CompositionContainer.GetExportedValue <IClipboardDevice>();
            _clipboardDevice.Text = String.Empty;

            // One setting we do differ on for a default is 'timeout'.  We don't want them interfering
            // with the reliability of tests.  The default is on but turn it off here to prevent any
            // problems
            _vim.GlobalSettings.Timeout = false;

            // Don't let the personal VimRc of the user interfere with the unit tests
            _vim.AutoLoadVimRc = false;

            // Don't show trace information in the unit tests.  It really clutters the output in an
            // xUnit run
            VimTrace.TraceSwitch.Level = TraceLevel.Off;
        }
예제 #33
0
 public static Mock<IVim> CreateVim(
     IRegisterMap registerMap = null,
     IMarkMap map = null,
     IVimGlobalSettings settings = null,
     IVimHost host = null,
     IKeyMap keyMap = null,
     IKeyboardDevice keyboardDevice = null,
     IMouseDevice mouseDevice = null,
     IVimData vimData = null,
     IMacroRecorder macroRecorder = null,
     ISearchService searchService = null,
     Dictionary<string, VariableValue> variableMap = null,
     MockRepository factory = null)
 {
     factory = factory ?? new MockRepository(MockBehavior.Strict);
     registerMap = registerMap ?? CreateRegisterMap().Object;
     map = map ?? new MarkMap(new BufferTrackingService());
     settings = settings ?? new GlobalSettings();
     host = host ?? new MockVimHost();
     keyMap = keyMap ?? (new KeyMap(settings, new Dictionary<string, VariableValue>()));
     macroRecorder = macroRecorder ?? CreateMacroRecorder(factory: factory).Object;
     searchService = searchService ?? factory.Create<ISearchService>().Object;
     keyboardDevice = keyboardDevice ?? (factory.Create<IKeyboardDevice>(MockBehavior.Loose)).Object;
     mouseDevice = mouseDevice ?? (factory.Create<IMouseDevice>(MockBehavior.Loose)).Object;
     vimData = vimData ?? VimUtil.CreateVimData();
     variableMap = variableMap ?? new Dictionary<string, VariableValue>();
     var mock = factory.Create<IVim>(MockBehavior.Strict);
     mock.SetupGet(x => x.RegisterMap).Returns(registerMap);
     mock.SetupGet(x => x.MarkMap).Returns(map);
     mock.SetupGet(x => x.GlobalSettings).Returns(settings);
     mock.SetupGet(x => x.VimHost).Returns(host);
     mock.SetupGet(x => x.KeyMap).Returns(keyMap);
     mock.SetupGet(x => x.VimData).Returns(vimData);
     mock.SetupGet(x => x.MacroRecorder).Returns(macroRecorder);
     mock.SetupGet(x => x.SearchService).Returns(searchService);
     mock.SetupGet(x => x.VariableMap).Returns(variableMap);
     return mock;
 }
예제 #34
0
        protected VimTestBase()
        {
            // Parts of the core editor in Vs2012 depend on there being an Application.Current value else
            // they will throw a NullReferenceException.  Create one here to ensure the unit tests successfully
            // pass
            if (Application.Current == null)
            {
                new Application();
            }

            _vim = CompositionContainer.GetExportedValue<IVim>();
            _vimBufferFactory = CompositionContainer.GetExportedValue<IVimBufferFactory>();
            _vimErrorDetector = CompositionContainer.GetExportedValue<IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue<ICommonOperationsFactory>();
            _wordUtil = CompositionContainer.GetExportedValue<IWordUtil>();
            _bufferTrackingService = CompositionContainer.GetExportedValue<IBufferTrackingService>();
            _foldManagerFactory = CompositionContainer.GetExportedValue<IFoldManagerFactory>();
            _bulkOperations = CompositionContainer.GetExportedValue<IBulkOperations>();
            _keyUtil = CompositionContainer.GetExportedValue<IKeyUtil>();
            _vimProtectedOperations = CompositionContainer.GetExportedValue<IVimProtectedOperations>();

            _keyboardDevice = CompositionContainer.GetExportedValue<IKeyboardDevice>();
            _mouseDevice = CompositionContainer.GetExportedValue<IMouseDevice>();
            _clipboardDevice = CompositionContainer.GetExportedValue<IClipboardDevice>();
            _clipboardDevice.Text = String.Empty;

            // One setting we do differ on for a default is 'timeout'.  We don't want them interfering
            // with the reliability of tests.  The default is on but turn it off here to prevent any
            // problems
            _vim.GlobalSettings.Timeout = false;

            // Don't let the personal VimRc of the user interfere with the unit tests
            _vim.AutoLoadVimRc = false;

            // Don't show trace information in the unit tests.  It really clutters the output in an
            // xUnit run
            VimTrace.TraceSwitch.Level = TraceLevel.Off;
        }
예제 #35
0
        public static Mock <IVim> CreateVim(
            IRegisterMap registerMap       = null,
            IMarkMap map                   = null,
            IVimGlobalSettings settings    = null,
            IVimHost host                  = null,
            IKeyMap keyMap                 = null,
            IKeyboardDevice keyboardDevice = null,
            IMouseDevice mouseDevice       = null,
            IVimData vimData               = null,
            IMacroRecorder recorder        = null,
            ISearchService searchService   = null,
            MockRepository factory         = null)
        {
            factory        = factory ?? new MockRepository(MockBehavior.Strict);
            registerMap    = registerMap ?? CreateRegisterMap().Object;
            map            = map ?? new MarkMap(new TrackingLineColumnService());
            settings       = settings ?? new GlobalSettings();
            host           = host ?? new MockVimHost();
            keyMap         = keyMap ?? (new KeyMap());
            recorder       = recorder ?? CreateMacroRecorder(factory: factory).Object;
            searchService  = searchService ?? factory.Create <ISearchService>().Object;
            keyboardDevice = keyboardDevice ?? (factory.Create <IKeyboardDevice>(MockBehavior.Loose)).Object;
            mouseDevice    = mouseDevice ?? (factory.Create <IMouseDevice>(MockBehavior.Loose)).Object;
            vimData        = vimData ?? new VimData();
            var mock = factory.Create <IVim>(MockBehavior.Strict);

            mock.SetupGet(x => x.RegisterMap).Returns(registerMap);
            mock.SetupGet(x => x.MarkMap).Returns(map);
            mock.SetupGet(x => x.Settings).Returns(settings);
            mock.SetupGet(x => x.VimHost).Returns(host);
            mock.SetupGet(x => x.KeyMap).Returns(keyMap);
            mock.SetupGet(x => x.VimData).Returns(vimData);
            mock.SetupGet(x => x.MacroRecorder).Returns(recorder);
            mock.SetupGet(x => x.SearchService).Returns(searchService);
            return(mock);
        }
예제 #36
0
 internal VimMouseProcessorProvider(IVim vim, IKeyboardDevice keyboardDevice)
 {
     _vim            = vim;
     _keyboardDevice = keyboardDevice;
 }
예제 #37
0
        public X11Window(AvaloniaX11Platform platform, bool popup)
        {
            _platform = platform;
            _popup    = popup;
            _x11      = platform.Info;
            _mouse    = platform.MouseDevice;
            _keyboard = platform.KeyboardDevice;

            var glfeature             = AvaloniaLocator.Current.GetService <IWindowingPlatformGlFeature>();
            XSetWindowAttributes attr = new XSetWindowAttributes();
            var valueMask             = default(SetWindowValuemask);

            attr.backing_store = 1;
            attr.bit_gravity   = Gravity.NorthWestGravity;
            attr.win_gravity   = Gravity.NorthWestGravity;
            valueMask         |= SetWindowValuemask.BackPixel | SetWindowValuemask.BorderPixel
                                 | SetWindowValuemask.BackPixmap | SetWindowValuemask.BackingStore
                                 | SetWindowValuemask.BitGravity | SetWindowValuemask.WinGravity;

            if (popup)
            {
                attr.override_redirect = true;
                valueMask |= SetWindowValuemask.OverrideRedirect;
            }

            XVisualInfo?visualInfo = null;

            // OpenGL seems to be do weird things to it's current window which breaks resize sometimes
            _useRenderWindow = glfeature != null;

            var glx = glfeature as GlxGlPlatformFeature;

            if (glx != null)
            {
                visualInfo = *glx.Display.VisualInfo;
            }
            else if (glfeature == null)
            {
                visualInfo = _x11.TransparentVisualInfo;
            }

            var egl = glfeature as EglGlPlatformFeature;

            var visual = IntPtr.Zero;
            var depth  = 24;

            if (visualInfo != null)
            {
                visual        = visualInfo.Value.visual;
                depth         = (int)visualInfo.Value.depth;
                attr.colormap = XCreateColormap(_x11.Display, _x11.RootWindow, visualInfo.Value.visual, 0);
                valueMask    |= SetWindowValuemask.ColorMap;
            }

            _handle = XCreateWindow(_x11.Display, _x11.RootWindow, 10, 10, 300, 200, 0,
                                    depth,
                                    (int)CreateWindowArgs.InputOutput,
                                    visual,
                                    new UIntPtr((uint)valueMask), ref attr);

            if (_useRenderWindow)
            {
                _renderHandle = XCreateWindow(_x11.Display, _handle, 0, 0, 300, 200, 0, depth,
                                              (int)CreateWindowArgs.InputOutput,
                                              visual,
                                              new UIntPtr((uint)(SetWindowValuemask.BorderPixel | SetWindowValuemask.BitGravity |
                                                                 SetWindowValuemask.WinGravity | SetWindowValuemask.BackingStore)), ref attr);
            }
            else
            {
                _renderHandle = _handle;
            }

            Handle    = new PlatformHandle(_handle, "XID");
            _realSize = new PixelSize(300, 200);
            platform.Windows[_handle] = OnEvent;
            XEventMask ignoredMask = XEventMask.SubstructureRedirectMask
                                     | XEventMask.ResizeRedirectMask
                                     | XEventMask.PointerMotionHintMask;

            if (platform.XI2 != null)
            {
                ignoredMask |= platform.XI2.AddWindow(_handle, this);
            }
            var mask = new IntPtr(0xffffff ^ (int)ignoredMask);

            XSelectInput(_x11.Display, _handle, mask);
            var protocols = new[]
            {
                _x11.Atoms.WM_DELETE_WINDOW
            };

            XSetWMProtocols(_x11.Display, _handle, protocols, protocols.Length);
            XChangeProperty(_x11.Display, _handle, _x11.Atoms._NET_WM_WINDOW_TYPE, _x11.Atoms.XA_ATOM,
                            32, PropertyMode.Replace, new[] { _x11.Atoms._NET_WM_WINDOW_TYPE_NORMAL }, 1);

            if (platform.Options.WmClass != null)
            {
                SetWmClass(platform.Options.WmClass);
            }

            var surfaces = new List <object>
            {
                new X11FramebufferSurface(_x11.DeferredDisplay, _renderHandle,
                                          depth, () => Scaling)
            };

            if (egl != null)
            {
                surfaces.Insert(0,
                                new EglGlPlatformSurface((EglDisplay)egl.Display, egl.DeferredContext,
                                                         new SurfaceInfo(this, _x11.DeferredDisplay, _handle, _renderHandle)));
            }
            if (glx != null)
            {
                surfaces.Insert(0, new GlxGlPlatformSurface(glx.Display, glx.DeferredContext,
                                                            new SurfaceInfo(this, _x11.Display, _handle, _renderHandle)));
            }

            Surfaces = surfaces.ToArray();
            UpdateMotifHints();
            _xic = XCreateIC(_x11.Xim, XNames.XNInputStyle, XIMProperties.XIMPreeditNothing | XIMProperties.XIMStatusNothing,
                             XNames.XNClientWindow, _handle, IntPtr.Zero);
            XFlush(_x11.Display);
        }
예제 #38
0
 internal VimMouseProcessor(IVimBuffer vimBuffer, IKeyboardDevice keyboardDevice)
 {
     _vimBuffer = vimBuffer;
     _keyboardDevice = keyboardDevice;
 }
예제 #39
0
 internal VimMouseProcessorProvider(IVim vim, IKeyboardDevice keyboardDevice)
 {
     _vim = vim;
     _keyboardDevice = keyboardDevice;
 }
예제 #40
0
 public static Mock<IVim> CreateVim(
     IRegisterMap registerMap = null,
     MarkMap map = null,
     IVimGlobalSettings settings = null,
     IVimHost host = null,
     IKeyMap keyMap = null,
     IChangeTracker changeTracker = null,
     IKeyboardDevice keyboardDevice = null,
     IMouseDevice mouseDevice = null)
 {
     registerMap = registerMap ?? CreateRegisterMap().Object;
     map = map ?? new MarkMap(new TrackingLineColumnService());
     settings = settings ?? new GlobalSettings();
     host = host ?? new MockVimHost();
     keyMap = keyMap ?? (new KeyMap());
     keyboardDevice = keyboardDevice ?? (new Mock<IKeyboardDevice>(MockBehavior.Loose)).Object;
     mouseDevice = mouseDevice ?? (new Mock<IMouseDevice>(MockBehavior.Loose)).Object;
     changeTracker = changeTracker ?? new ChangeTracker(new TextChangeTrackerFactory(keyboardDevice, mouseDevice));
     var mock = new Mock<IVim>(MockBehavior.Strict);
     mock.Setup(x => x.RegisterMap).Returns(registerMap);
     mock.Setup(x => x.MarkMap).Returns(map);
     mock.Setup(x => x.Settings).Returns(settings);
     mock.Setup(x => x.VimHost).Returns(host);
     mock.Setup(x => x.KeyMap).Returns(keyMap);
     mock.Setup(x => x.ChangeTracker).Returns(changeTracker);
     return mock;
 }
예제 #41
0
파일: X11Window.cs 프로젝트: yatli/Avalonia
        public X11Window(AvaloniaX11Platform platform, IWindowImpl popupParent)
        {
            _platform = platform;
            _popup    = popupParent != null;
            _x11      = platform.Info;
            _mouse    = new MouseDevice();
            _touch    = new TouchDevice();
            _keyboard = platform.KeyboardDevice;

            var glfeature             = AvaloniaLocator.Current.GetService <IPlatformOpenGlInterface>();
            XSetWindowAttributes attr = new XSetWindowAttributes();
            var valueMask             = default(SetWindowValuemask);

            attr.backing_store = 1;
            attr.bit_gravity   = Gravity.NorthWestGravity;
            attr.win_gravity   = Gravity.NorthWestGravity;
            valueMask         |= SetWindowValuemask.BackPixel | SetWindowValuemask.BorderPixel
                                 | SetWindowValuemask.BackPixmap | SetWindowValuemask.BackingStore
                                 | SetWindowValuemask.BitGravity | SetWindowValuemask.WinGravity;

            if (_popup)
            {
                attr.override_redirect = true;
                valueMask |= SetWindowValuemask.OverrideRedirect;
            }

            XVisualInfo?visualInfo = null;

            // OpenGL seems to be do weird things to it's current window which breaks resize sometimes
            _useRenderWindow = glfeature != null;

            var glx = glfeature as GlxPlatformOpenGlInterface;

            if (glx != null)
            {
                visualInfo = *glx.Display.VisualInfo;
            }
            else if (glfeature == null)
            {
                visualInfo = _x11.TransparentVisualInfo;
            }

            var egl = glfeature as EglPlatformOpenGlInterface;

            var visual = IntPtr.Zero;
            var depth  = 24;

            if (visualInfo != null)
            {
                visual        = visualInfo.Value.visual;
                depth         = (int)visualInfo.Value.depth;
                attr.colormap = XCreateColormap(_x11.Display, _x11.RootWindow, visualInfo.Value.visual, 0);
                valueMask    |= SetWindowValuemask.ColorMap;
            }

            int defaultWidth = 0, defaultHeight = 0;

            if (!_popup && Screen != null)
            {
                var monitor = Screen.AllScreens.OrderBy(x => x.PixelDensity)
                              .FirstOrDefault(m => m.Bounds.Contains(Position));

                if (monitor != null)
                {
                    // Emulate Window 7+'s default window size behavior.
                    defaultWidth  = (int)(monitor.WorkingArea.Width * 0.75d);
                    defaultHeight = (int)(monitor.WorkingArea.Height * 0.7d);
                }
            }

            // check if the calculated size is zero then compensate to hardcoded resolution
            defaultWidth  = Math.Max(defaultWidth, 300);
            defaultHeight = Math.Max(defaultHeight, 200);

            _handle = XCreateWindow(_x11.Display, _x11.RootWindow, 10, 10, defaultWidth, defaultHeight, 0,
                                    depth,
                                    (int)CreateWindowArgs.InputOutput,
                                    visual,
                                    new UIntPtr((uint)valueMask), ref attr);

            if (_useRenderWindow)
            {
                _renderHandle = XCreateWindow(_x11.Display, _handle, 0, 0, defaultWidth, defaultHeight, 0, depth,
                                              (int)CreateWindowArgs.InputOutput,
                                              visual,
                                              new UIntPtr((uint)(SetWindowValuemask.BorderPixel | SetWindowValuemask.BitGravity |
                                                                 SetWindowValuemask.WinGravity | SetWindowValuemask.BackingStore)), ref attr);
            }
            else
            {
                _renderHandle = _handle;
            }

            Handle    = new PlatformHandle(_handle, "XID");
            _realSize = new PixelSize(defaultWidth, defaultHeight);
            platform.Windows[_handle] = OnEvent;
            XEventMask ignoredMask = XEventMask.SubstructureRedirectMask
                                     | XEventMask.ResizeRedirectMask
                                     | XEventMask.PointerMotionHintMask;

            if (platform.XI2 != null)
            {
                ignoredMask |= platform.XI2.AddWindow(_handle, this);
            }
            var mask = new IntPtr(0xffffff ^ (int)ignoredMask);

            XSelectInput(_x11.Display, _handle, mask);
            var protocols = new[]
            {
                _x11.Atoms.WM_DELETE_WINDOW
            };

            XSetWMProtocols(_x11.Display, _handle, protocols, protocols.Length);
            XChangeProperty(_x11.Display, _handle, _x11.Atoms._NET_WM_WINDOW_TYPE, _x11.Atoms.XA_ATOM,
                            32, PropertyMode.Replace, new[] { _x11.Atoms._NET_WM_WINDOW_TYPE_NORMAL }, 1);

            if (platform.Options.WmClass != null)
            {
                SetWmClass(platform.Options.WmClass);
            }

            var surfaces = new List <object>
            {
                new X11FramebufferSurface(_x11.DeferredDisplay, _renderHandle,
                                          depth, () => RenderScaling)
            };

            if (egl != null)
            {
                surfaces.Insert(0,
                                new EglGlPlatformSurface(egl,
                                                         new SurfaceInfo(this, _x11.DeferredDisplay, _handle, _renderHandle)));
            }
            if (glx != null)
            {
                surfaces.Insert(0, new GlxGlPlatformSurface(glx.Display, glx.DeferredContext,
                                                            new SurfaceInfo(this, _x11.Display, _handle, _renderHandle)));
            }

            Surfaces = surfaces.ToArray();
            UpdateMotifHints();
            UpdateSizeHints(null);
            _xic = XCreateIC(_x11.Xim, XNames.XNInputStyle, XIMProperties.XIMPreeditNothing | XIMProperties.XIMStatusNothing,
                             XNames.XNClientWindow, _handle, IntPtr.Zero);
            _transparencyHelper = new TransparencyHelper(_x11, _handle, platform.Globals);
            _transparencyHelper.SetTransparencyRequest(WindowTransparencyLevel.None);

            XFlush(_x11.Display);
            if (_popup)
            {
                PopupPositioner = new ManagedPopupPositioner(new ManagedPopupPositionerPopupImplHelper(popupParent, MoveResize));
            }
            if (platform.Options.UseDBusMenu)
            {
                NativeMenuExporter = DBusMenuExporter.TryCreate(_handle);
            }
            NativeControlHost = new X11NativeControlHost(_platform, this);
            DispatcherTimer.Run(() =>
            {
                Paint?.Invoke(default);
예제 #42
0
 public RawTextInputEventArgs(IKeyboardDevice device, uint timestamp, string text) : base(device, timestamp)
 {
     Text = text;
 }