public BindingAttribute (Gdk.Key key, Gdk.ModifierType mod, string handler, params object[] parms)
		{
			this.key = key;
			this.mod = mod;
			this.handler = handler;
			this.parms = parms;
		}
        /// <summary>
        /// Creates an item with the specified sub items. And the current
        /// Condition status for this item.
        /// </summary>
        public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
        {
            //FIXME: This code is *not* fully ported yet
            if (subItems.Count > 0) {
                throw new ApplicationException ("more than one level of edit actions don't make sense!");
            }

            IEditAction editAction = (IEditAction) AddIn.CreateObject (Class);

            Gdk.Key[] actionKeys = new Gdk.Key[keys.Length];
            for (int j = 0; j < keys.Length; ++j) {
                string[] keydescr = keys[j].Split (new char[] { '|' });
                //Keys key = (Keys)((System.Windows.Forms.Keys.Space.GetType()).InvokeMember(keydescr[0], BindingFlags.GetField, null, System.Windows.Forms.Keys.Space, new object[0]));
                //Console.Write (keydescr[0] + " -- ");
                for (int k = 1; k < keydescr.Length; ++k) {
                    //key |= (Keys)((System.Windows.Forms.Keys.Space.GetType()).InvokeMember(keydescr[k], BindingFlags.GetField, null, System.Windows.Forms.Keys.Space, new object[0]));
                    //Console.Write (keydescr[k] + " -- ");
                }
                //actionKeys[j] = key;
            }

            editAction.Keys = actionKeys;

            return editAction;
        }
		void HandleKeyPressEvent (object o, Gtk.KeyPressEventArgs args)
		{
			keyHandled = false;

			keyChar = (char)args.Event.Key;
			keyValue = args.Event.KeyValue;
			modifier = args.Event.State;
			key = args.Event.Key;

			if ((args.Event.Key == Gdk.Key.Down || args.Event.Key == Gdk.Key.Up)) {
				keyChar = '\0';
			}

			if (list != null)
				args.RetVal = keyHandled = CompletionWindowManager.PreProcessKeyEvent (KeyDescriptor.FromGtk (key, keyChar, modifier));
		}
        void HandleKeyPressEvent(object o, Gtk.KeyPressEventArgs args)
        {
            keyHandled = false;

            keyChar  = (char)args.Event.Key;
            keyValue = args.Event.KeyValue;
            modifier = args.Event.State;
            key      = args.Event.Key;

            if ((args.Event.Key == Gdk.Key.Down || args.Event.Key == Gdk.Key.Up))
            {
                keyChar = '\0';
            }

            if (list != null)
            {
                args.RetVal = keyHandled = CompletionWindowManager.PreProcessKeyEvent(key, keyChar, modifier);
            }
        }
Esempio n. 5
0
        static string GetKeyEquivalent(Gdk.Key key)
        {
            char c = (char)Gdk.Keyval.ToUnicode((uint)key);

            if (c != 0)
            {
                return(c.ToString());
            }

            var fk = GetFunctionKey(key);

            if (fk != 0)
            {
                return(((char)fk).ToString());
            }

            LoggingService.LogError("Mac menu cannot display key '{0}", key);
            return("");
        }
        public async Task TestIssue5025()
        {
            IdeApp.Preferences.AddImportedItemsToCompletionList.Value = true;
            await TestCompletion(@"
namespace console61
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            t$
        }
    }
}
",
                                 (doc, list) => {
                //var extEditor = doc.Editor.GetContent<SourceEditorView> ().TextEditor;
                var compExt = doc.GetContent <CSharpCompletionTextEditorExtension> ();
                CompletionWindowManager.StartPrepareShowWindowSession();
                //extEditor.EditorExtension = compExt;
                //extEditor.OnIMProcessedKeyPressEvent (Gdk.Key.BackSpace, '\0', Gdk.ModifierType.None);
                var listWindow = new CompletionListWindow();
                var widget     = new NamedArgumentCompletionTests.TestCompletionWidget(doc.Editor, doc.DocumentContext);
                listWindow.CompletionWidget      = widget;
                listWindow.CodeCompletionContext = widget.CurrentCodeCompletionContext;
                var item      = (RoslynCompletionData)list.FirstOrDefault(d => d.CompletionText == "MainClass");
                KeyActions ka = KeyActions.Process;
                Gdk.Key key   = Gdk.Key.Tab;
                item.InsertCompletionText(doc.Editor, doc.DocumentContext, ref ka, KeyDescriptor.FromGtk(key, (char)key, Gdk.ModifierType.None));
                Assert.AreEqual(@"
namespace console61
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            MainClass
        }
    }
}
", doc.Editor.Text);
            });
        }
Esempio n. 7
0
        void MainWindow_KeyReleaseEvent(object o, KeyReleaseEventArgs e)
        {
            Gdk.Key key = e.Event.Key;
            pressed_keys.Remove(key);
            Logger.Log("Key release: " + key.ToString());

            if (key == Gdk.Key.Control_L || key == Gdk.Key.Control_R || key == Gdk.Key.Escape)
            {
                cmd_map.Off(true);
            }

            // Give the Canvas (and by extension the tools)
            // first shot at handling the event if
            // the mouse pointer is on the canvas
            if (IsMouseOnCanvas() || canvas_pad.Canvas.HasFocus)
            {
                canvas_pad.Canvas.DoKeyReleaseEvent(o, e);
            }
        }
        void OnEditKeyPress(object sender, KeyPressEventArgs args)
        {
            keyHandled = false;

            keyChar  = (char)args.Event.Key;
            keyValue = args.Event.KeyValue;
            modifier = args.Event.State;
            key      = args.Event.Key;

            if ((args.Event.Key == Gdk.Key.Down || args.Event.Key == Gdk.Key.Up))
            {
                keyChar = '\0';
            }

            if (currentCompletionData != null)
            {
                args.RetVal = keyHandled = CompletionWindowManager.PreProcessKeyEvent(KeyDescriptor.FromGtk(key, keyChar, modifier));
            }
        }
        public override bool KeyPress(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            updater.BeginUpdate();
            if (this.CompletionWidget != null)
            {
                switch (keyChar)
                {
                case '(':
                case ')':
                case ';':
                case ']':
                    ParameterInformationWindowManager.HideWindow(this, CompletionWidget);
                    break;

                default:
                    if (lastTriggerOffset >= 0 && char.IsDigit(keyChar))
                    {
                        bool containsDigitsOnly = true;

                        for (int offset = lastTriggerOffset; offset < CompletionWidget.CaretOffset; offset++)
                        {
                            if (!char.IsDigit(CompletionWidget.GetChar(offset)))
                            {
                                containsDigitsOnly = false;
                                break;
                            }
                        }

                        if (containsDigitsOnly)
                        {
                            CompletionWindowManager.HideWindow();
                        }
                    }
                    break;
                }
            }

            var ret = base.KeyPress(key, keyChar, modifier);

            updater.FinishUpdate();
            return(ret);
        }
        public override bool KeyPress(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            if (keyChar != '/')
            {
                return(base.KeyPress(key, keyChar, modifier));
            }

            LineSegment line = textEditorData.Document.GetLine(textEditorData.Caret.Line);
            string      text = textEditorData.Document.GetTextAt(line.Offset, line.EditableLength);

            if (!text.EndsWith("//"))
            {
                return(base.KeyPress(key, keyChar, modifier));
            }

            IMember member = GetMemberToDocument();

            if (member == null)
            {
                return(base.KeyPress(key, keyChar, modifier));
            }

            string documentation = GenerateDocumentation(member, textEditorData.Document.GetLineIndent(line));

            if (string.IsNullOrEmpty(documentation))
            {
                return(base.KeyPress(key, keyChar, modifier));
            }

            string documentationEmpty = GenerateEmptyDocumentation(member, textEditorData.Document.GetLineIndent(line));

            int offset = textEditorData.Caret.Offset;

            int insertedLength = textEditorData.Insert(offset, documentationEmpty);

            // important to set the caret position here for the undo step
            textEditorData.Caret.Offset = offset + insertedLength;

            insertedLength = textEditorData.Replace(offset, insertedLength, documentation);
            textEditorData.Caret.Offset = offset + insertedLength;
            return(false);
        }
Esempio n. 11
0
            public bool PostProcessKey(CompletionListWindow listWindow, Gdk.Key key, char keyChar, Gdk.ModifierType modifier, out KeyActions keyAction)
            {
                keyAction = KeyActions.None;
                if (keyChar == '_')
                {
                    listWindow.PostProcessKey(key, keyChar, modifier);
                    return(true);
                }

                Mono.TextEditor.TextEditorData ed;
                if (keyChar == '.' && (ed = ext.document.Editor).GetCharAt(ed.Caret.Offset - 1) == '.')
                {
                    // optional: Distinguish whether we are in an an index/slice expression and do not close down the completion window if so..
                    keyAction = KeyActions.CloseWindow;
                    listWindow.PostProcessKey(key, keyChar, modifier);
                    return(true);
                }

                return(false);
            }
Esempio n. 12
0
        public bool CompleteWord(ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier)
        {
            if (SelectedItem == -1 || completionDataList == null)
            {
                return(false);
            }
            var item = completionDataList [SelectedItem];

            if (item == null)
            {
                return(false);
            }
            // first close the completion list, then insert the text.
            // this is required because that's the logical event chain, otherwise things could be messed up
            CloseCompletionList();
            ((CompletionData)item).InsertCompletionText(this, ref ka, closeChar, keyChar, modifier);
            AddWordToHistory(PartialWord, item.CompletionText);
            OnWordCompleted(new CodeCompletionContextEventArgs(CompletionWidget, CodeCompletionContext, item.CompletionText));
            return(true);
        }
Esempio n. 13
0
        /// <summary>Map raw GTK key input to work around platform bugs and decompose accelerator keys</summary>
        /// <param name='evt'>The raw key event</param>
        /// <param name='key'>The composed key</param>
        /// <param name='mod'>The composed modifiers</param>
        /// <param name='accels'>All the key/modifier decompositions that can be used as accelerators</param>
        public static void MapKeys(Gdk.EventKey evt, out Gdk.Key key, out Gdk.ModifierType state,
                                   out KeyboardShortcut[] accels)
        {
            //this uniquely identifies the raw key
            ulong id;

            unchecked {
                id = (((ulong)(uint)evt.State) | (((ulong)evt.HardwareKeycode) << 32) | (((ulong)evt.Group) << 48));
            }

            MappedKeys mapped;

            if (!mappedKeys.TryGetValue(id, out mapped))
            {
                mappedKeys[id] = mapped = MapKeys(evt);
            }
            accels = mapped.Accels;
            key    = mapped.Key;
            state  = mapped.State;
        }
Esempio n. 14
0
        static char TranslateKeyCharForIndenter(Gdk.Key key, char keyChar, char docChar)
        {
            switch (key)
            {
            case Gdk.Key.Return:
            case Gdk.Key.KP_Enter:
                return('\n');

            case Gdk.Key.Tab:
                return('\t');

            default:
                if (docChar == keyChar)
                {
                    return(keyChar);
                }
                break;
            }
            return('\0');
        }
		static string KeyToDisplayLabel (Gdk.Key key)
		{
			if (isMac) {
				char appl = AppleMapKeyToSymbol (key);
				if (appl != '\0') {
					return new string (appl, 1);
				}
			}
			
			switch (key) {
			case Gdk.Key.Page_Down:
			//Gdk.Key.Next:
				return "Page Down";
			case Gdk.Key.Page_Up:
			//case Gdk.Key.Prior:
				return "Page Up";
			}
			
			return KeyToString (key);
		}
Esempio n. 16
0
 public void ShellSend(Gdk.Key key)
 {
     if (UserInputMode)
     {
         LastKeyPress = key;
         userkeypress.Set();
     }
     else
     {
         if (LocalEcho)
         {
             Write(key.ToString());
         }
         if (shellStream != null && shellStream.CanWrite)
         {
             shellStream.WriteByte((byte)key);
             shellStream.Flush();
         }
     }
 }
        string Test(string input, string type, string member, Gdk.Key key = Gdk.Key.Return)
        {
            TestViewContent content;
            var             ext = Setup(input, out content);

            ListWindow.ClearHistory();
            var listWindow = new CompletionListWindow();
            var widget     = new TestCompletionWidget(ext.Document);

            listWindow.CompletionWidget      = widget;
            listWindow.CodeCompletionContext = widget.CurrentCodeCompletionContext;
            var t           = ext.Document.Compilation.FindType(new FullTypeName(type));
            var foundMember = t.GetMembers(m => m.Name == member).First();
            var data        = new MemberCompletionData(ext, foundMember, OutputFlags.ClassBrowserEntries);

            data.DisplayFlags |= ICSharpCode.NRefactory.Completion.DisplayFlags.NamedArgument;
            KeyActions ka = KeyActions.Process;

            data.InsertCompletionText(listWindow, ref ka, key, (char)key, Gdk.ModifierType.None, true, false);
            return(widget.CompletedWord);
        }
Esempio n. 18
0
        public static Perspex.Input.Key ConvertKey(Gdk.Key key)
        {
            // TODO: Don't use reflection for this! My eyes!!!
            if (key == Gdk.Key.BackSpace)
            {
                return(Perspex.Input.Key.Back);
            }
            else
            {
                var s = Enum.GetName(typeof(Gdk.Key), key);
                Perspex.Input.Key result;

                if (Enum.TryParse(s, true, out result))
                {
                    return(result);
                }
                else
                {
                    return(Perspex.Input.Key.None);
                }
            }
        }
 bool ExtensionKeyPress(Gdk.Key key, uint ch, Gdk.ModifierType state)
 {
     isInKeyStroke = true;
     try {
         if (needToAddLastExtension)
         {
             var ext = EditorExtension;
             while (ext.Next != null)
             {
                 ext = ext.Next;
             }
             ext.Next = new LastEditorExtension(this);
             needToAddLastExtension = false;
         }
         return(EditorExtension.KeyPress(KeyDescriptor.FromGtk(key, (char)ch, state)));
     } catch (Exception ex) {
         ReportExtensionError(ex);
     } finally {
         isInKeyStroke = false;
     }
     return(false);
 }
Esempio n. 20
0
        /// <summary>
        /// Fires a key press event to a widget. This is not something that should be used very often,
        /// but it provides a way to store a value of a cell being edited in a grid when the user closes the grid
        /// (e.g., by selecting a different view).
        /// I haven't been able to find any better way to do it.
        /// It's placed in this unit because there may be uses in other contexts.
        /// </summary>
        /// <param name="widget"></param>
        /// <param name="key"></param>
        public static void SendKeyEvent(Gtk.Widget widget, Gdk.Key key)
        {
            uint keyval = (uint)key;

            Gdk.Window      window = widget.GdkWindow;
            Gdk.KeymapKey[] keymap = Gdk.Keymap.Default.GetEntriesForKeyval(keyval);

            EventKeyStruct native = new EventKeyStruct();

            native.type             = Gdk.EventType.KeyPress;
            native.window           = window.Handle;
            native.send_event       = 1;
            native.state            = (uint)Gdk.EventMask.KeyPressMask;
            native.keyval           = keyval;
            native.length           = 0;
            native.str              = null;
            native.hardware_keycode = (ushort)keymap[0].Keycode;
            native.group            = (byte)keymap[0].Group;

            IntPtr ptr = GLib.Marshaller.StructureToPtrAlloc(native);

            try
            {
                Gdk.EventKey evnt = new Gdk.EventKey(ptr);
                Gdk.EventHelper.Put(evnt);
                // We need to process the event, or we won't be able
                // to safely free the unmanaged pointer
                // Using DoEvent for this fails on the Mac
                while (GLib.MainContext.Iteration())
                {
                    ;
                }
                // Gtk.Main.DoEvent(evnt);
            }
            finally
            {
                GLib.Marshaller.Free(ptr);
            }
        }
Esempio n. 21
0
 private int KeyToHex(Gdk.Key key)
 {
     if (key >= Gdk.Key.Key_0 && key <= Gdk.Key.Key_9)
     {
         return(key - Gdk.Key.Key_0);
     }
     else if (key >= Gdk.Key.A && key <= Gdk.Key.F)
     {
         return(key - Gdk.Key.A + 10);
     }
     else if (key >= Gdk.Key.a && key <= Gdk.Key.f)
     {
         return(key - Gdk.Key.a + 10);
     }
     else if (key >= Gdk.Key.KP_0 && key <= Gdk.Key.KP_9)
     {
         return(key - Gdk.Key.KP_0);
     }
     else
     {
         return(-1);
     }
 }
Esempio n. 22
0
        static void HandleKeyPress(object sender, KeyPressEventArgs args)
        {
            uint symbol = args.Event.Symbol;

            Gdk.Key key = (Gdk.Key)Enum.Parse(typeof(Gdk.Key), symbol.ToString());

            switch (key)
            {
            case Gdk.Key.s:
                timeline.Start();

                TestThreadData data    = new TestThreadData(count_label, timeline);
                ThreadWrapper  wrapper = new ThreadWrapper(data);

                Thread thread = new Thread(wrapper.ThreadMethod);
                thread.Start();
                break;

            case Gdk.Key.q:
                Clutter.Main.Quit();
                break;
            }
        }
Esempio n. 23
0
            public bool PostProcessKey(CompletionListWindow listWindow, Gdk.Key key, char keyChar, Gdk.ModifierType modifier, out KeyActions keyAction)
            {
                if (key == Gdk.Key.Return)
                {
                    keyAction = KeyActions.Complete;
                }
                else if (key == Gdk.Key.BackSpace)
                {
                    keyAction = KeyActions.None;
                    return(false);
                }
                else if (keyChar != '\0' && !D_Parser.Parser.Lexer.IsIdentifierPart(keyChar))
                {
                    keyAction = KeyActions.CloseWindow;
                }
                else
                {
                    keyAction = KeyActions.None;
                }

                listWindow.PostProcessKey(key, keyChar, modifier);
                return(true);
            }
        string Test(string input, string type, string member, Gdk.Key key = Gdk.Key.Return, bool isDelegateExpected = false)
        {
            TestViewContent content;
            var             ext = Setup(input, out content);

            ListWindow.ClearHistory();
            var listWindow = new CompletionListWindow();
            var widget     = new TestCompletionWidget(ext.Document);

            listWindow.CompletionWidget      = widget;
            listWindow.CodeCompletionContext = widget.CurrentCodeCompletionContext;

            var t      = ext.Document.Compilation.FindType(new FullTypeName(type));
            var method = member != null?t.GetMembers(m => m.Name == member).First() : t.GetConstructors().First();

            var data = new MemberCompletionData(ext, method, OutputFlags.ClassBrowserEntries);

            data.IsDelegateExpected = isDelegateExpected;
            KeyActions ka = KeyActions.Process;

            data.InsertCompletionText(listWindow, ref ka, key, (char)key, Gdk.ModifierType.None, true, false);
            return(widget.CompletedWord);
        }
Esempio n. 25
0
        async Task <string> Test(string input, string type, string member, Gdk.Key key = Gdk.Key.Return)
        {
            string result = null;

            await Setup(input, async testCase => {
                var ext        = testCase.Content.GetContent <CSharpCompletionTextEditorExtension> ();
                var listWindow = new CompletionListWindow();
                var widget     = new TestCompletionWidget(ext.Editor, ext.DocumentContext);
                listWindow.CompletionWidget      = widget;
                listWindow.CodeCompletionContext = widget.CurrentCodeCompletionContext;
                var sm = await ext.DocumentContext.AnalysisDocument.GetSemanticModelAsync();

                var t              = sm.Compilation.GetTypeByMetadataName(type);
                var foundMember    = t.GetMembers().First(m => m.Name == member);
                var data           = new CompletionData(foundMember.Name);
                data.DisplayFlags |= DisplayFlags.NamedArgument;
                KeyActions ka      = KeyActions.Process;
                data.InsertCompletionText(listWindow, ref ka, KeyDescriptor.FromGtk(key, (char)key, Gdk.ModifierType.None));
                result = widget.CompletedWord;
            });

            return(result);
        }
Esempio n. 26
0
        public override bool KeyPress(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            if (key == Gdk.Key.Return)
            {
                string lastLine    = Editor.GetLineText(Editor.CursorLine);
                string trimmedLine = lastLine.Trim();
                bool   indent      = false;

                if (trimmedLine.EndsWith("{"))
                {
                    indent = true;
                }

                if (indent)
                {
                    base.KeyPress(key, keyChar, modifier);
                    Editor.InsertText(Editor.CursorPosition, "\t");
                    return(false);
                }
            }

            return(base.KeyPress(key, keyChar, modifier));
        }
        private void MatItemEditNext(int row, Gdk.Key keyCode)
        {
            if (keyCode == Gdk.Key.Tab)
            {
                MatCurrentColumnEvaluate();
                ProdEditGridField(0, colItem.Index);
                return;
            }

            if (codeQtty != 0)
            {
                MatQtyEvaluate(row, codeQtty);
            }

            if (barcodeUsed)
            {
                if (codeQtty == 0)
                {
                    MatQtyEvaluate(row, 1);
                }

                if (recipe.DetailsMat.Count <= row + 1)
                {
                    recipe.AddNewDetail();
                }

                MatEditGridField(row + 1, colItem.Index);
            }
            else if (colQuantity != null && colQuantity.ListCell.IsEditable)
            {
                MatEditGridField(row, colQuantity.Index);
            }
            else
            {
                MatQtyEditNext(row, keyCode);
            }
        }
        private void ProdItemEditNext(int row, Gdk.Key keyCode)
        {
            if (keyCode == Gdk.Key.Tab)
            {
                ProdCurrentColumnEvaluate();
                //btnOK.GrabFocus ();
                return;
            }

            if (!codeQtty.IsZero())
            {
                ProdQtyEvaluate(row, codeQtty);
            }

            if (barcodeUsed)
            {
                if (codeQtty.IsZero())
                {
                    ProdQtyEvaluate(row, 1);
                }

                if (recipe.DetailsProd.Count <= row + 1)
                {
                    recipe.AddNewAdditionalDetail();
                }

                ProdEditGridField(row + 1, colSecondItem.Index);
            }
            else if (colSecondQuantity != null && colSecondQuantity.ListCell.IsEditable)
            {
                ProdEditGridField(row, colSecondQuantity.Index);
            }
            else
            {
                ProdQtyEditNext(row, keyCode);
            }
        }
Esempio n. 29
0
        public override bool KeyPress(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            // If we are a keyword
            if (keyChar == ' ' && modifier == Gdk.ModifierType.None && CompletionWidget != null)
            {
                CompletionWindowManager.PreProcessKeyEvent(Gdk.Key.Tab, '\t', Gdk.ModifierType.None);
                CompletionWindowManager.PostProcessKeyEvent(Gdk.Key.Tab, '\t', Gdk.ModifierType.None);
                CompletionWidget.CurrentCodeCompletionContext.TriggerWordLength = 0;
            }

            bool ret = base.KeyPress(key, keyChar, modifier);

            {             // did we type a keyword?
                string line    = Editor.GetLineText(Editor.Caret.Line);
                string to_left = line.Substring(0, Math.Min(line.Length, Editor.Caret.Column));

                if (rx_is_keyword.IsMatch(to_left))
                {
                    CompletionWindowManager.HideWindow();
                }
            }

            return(ret);
        }
        private void OnKeyPressed(object o, KeyPressEventArgs args)
        {
            Gdk.Key          key             = args.Event.Key;
            Gdk.ModifierType modifier        = args.Event.State;
            Gdk.ModifierType controlModifier = Gdk.ModifierType.ControlMask;

            if ((modifier & controlModifier) == controlModifier) //Control was pressed
            {
                switch (key)
                {
                case Gdk.Key.Page_Up:
                    Core.Base.Ui.View.Selection.SelectPrevious();
                    GrabFocus();
                    args.RetVal = true;
                    break;

                case Gdk.Key.Page_Down:
                    Core.Base.Ui.View.Selection.SelectNext();
                    GrabFocus();
                    args.RetVal = true;
                    break;
                }
            }
        }
Esempio n. 31
0
        protected override bool ProcessKeyPressEvent(Gtk.KeyPressEventArgs args)
        {
            keyHandled = false;

            keyChar  = (char)args.Event.Key;
            keyValue = args.Event.KeyValue;
            modifier = args.Event.State;
            key      = args.Event.Key;

            if ((args.Event.Key == Gdk.Key.Down || args.Event.Key == Gdk.Key.Up))
            {
                keyChar = '\0';
            }

            if (currentCompletionData != null)
            {
                if ((keyHandled = CompletionWindowManager.PreProcessKeyEvent(KeyDescriptor.FromGtk(key, keyChar, modifier))))
                {
                    return(true);
                }
            }

            return(base.ProcessKeyPressEvent(args));
        }
Esempio n. 32
0
        private BaseTool FindNextTool(Gdk.Key shortcut)
        {
            string key = shortcut.ToString().ToUpperInvariant();

            // Begin looking at the tool after the current one
            for (int i = index + 1; i < Tools.Count; i++)
            {
                if (Tools[i].ShortcutKey.ToString().ToUpperInvariant() == key)
                {
                    return(Tools[i]);
                }
            }

            // Begin at the beginning and look up to the current tool
            for (int i = 0; i < index; i++)
            {
                if (Tools[i].ShortcutKey.ToString().ToUpperInvariant() == key)
                {
                    return(Tools[i]);
                }
            }

            return(null);
        }
        protected override void HandleKeypress(Gdk.Key key, uint unicodeKey, Gdk.ModifierType modifier)
        {
            switch (key)
            {
            case Gdk.Key.Up:
                if (CurIndex > 0)
                {
                    CurIndex--;
                }
                DocumentLocation loc = insertionPoints[CurIndex].Location;
                editor.CenterTo(loc.Line - 1, DocumentLocation.MinColumn);
                editor.QueueDraw();
                SetHelpWindowPosition();
                break;

            case Gdk.Key.Down:
                if (CurIndex < insertionPoints.Count - 1)
                {
                    CurIndex++;
                }
                loc = insertionPoints[CurIndex].Location;
                editor.CenterTo(loc.Line + 1, DocumentLocation.MinColumn);
                editor.QueueDraw();
                SetHelpWindowPosition();
                break;

            case Gdk.Key.KP_Enter:
            case Gdk.Key.Return:
                OnExited(new InsertionCursorEventArgs(true, insertionPoints[CurIndex]));
                break;

            case Gdk.Key.Escape:
                OnExited(new InsertionCursorEventArgs(false, null));
                break;
            }
        }
Esempio n. 34
0
 /// <summary>
 /// Creates a new instance of shortcut
 /// </summary>
 /// <param name="Value">Keycode</param>
 /// <param name="Control">Control needs to be pressed in order to execute this</param>
 /// <param name="Alt">Alt needs to be pressed in order to execute this</param>
 /// <param name="Shift">Shift needs to be pressed in order to execute this</param>
 /// <param name="Data"></param>
 public Shortcut(Gdk.Key Value, bool Control = false, bool Alt = false, bool Shift = false, string Data = "")
 {
     control = Control;
     shift = Shift;
     alt = Alt;
     data = Data;
     keys = Value;
 }
Esempio n. 35
0
		protected override bool ProcessKeyPressEvent (Gtk.KeyPressEventArgs args)
		{
			keyHandled = false;

			keyChar = (char) args.Event.Key;
			keyValue = args.Event.KeyValue;
			modifier = args.Event.State;
			key = args.Event.Key;

			if ((args.Event.Key == Gdk.Key.Down || args.Event.Key == Gdk.Key.Up)) {
				keyChar = '\0';
			}

			if (currentCompletionData != null) {
				if ((keyHandled = CompletionWindowManager.PreProcessKeyEvent (key, keyChar, modifier)))
					return true;
			}

			return base.ProcessKeyPressEvent (args);
		}
Esempio n. 36
0
 public Keystroke(Gdk.Key key, uint unicodeKey, Gdk.ModifierType modifier)
 {
     m_key = key;
     m_unicodeKey = unicodeKey;
     m_modifier = modifier;
 }
		void OnEditKeyPress (object sender, KeyPressEventArgs args)
		{
			keyHandled = false;

			keyChar = (char) args.Event.Key;
			keyValue = args.Event.KeyValue;
			modifier = args.Event.State;
			key = args.Event.Key;

			if ((args.Event.Key == Gdk.Key.Down || args.Event.Key == Gdk.Key.Up)) {
				keyChar = '\0';
			}

			if (currentCompletionData != null)
				args.RetVal = keyHandled = CompletionWindowManager.PreProcessKeyEvent (key, keyChar, modifier);
		}