/// <summary>
        /// Returns a <see cref="System.String"/> that represents this Gdk key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        /// <remarks>
        /// This is taken from MonoDevelop's code.
        /// </remarks>
        public static string ToString(Key key)
        {
            // Pull out the unicode value for the key. If we have one, we use
            // that instead.
            var c = (char)Keyval.ToUnicode((uint)key);

            if (c != 0)
            {
                return(c == ' '
                                        ? "Space"
                                        : Char.ToUpper(c).ToString());
            }

            // Some keys do not convert directly because there are multiple
            // values for the enumeration. This is used to normalize the values.
            switch (key)
            {
            case Key.Next:
                return("Page_Down");

            case Key.L1:
                return("F11");

            case Key.L2:
                return("F12");
            }

            // Return the string representation of the key.
            return(key.ToString());
        }
Beispiel #2
0
        void OnInputKeyPressEvent(EventKey evnt)
        {
            if (im_context.FilterKeypress(evnt) || ((evnt.State & ModifierType.ControlMask) != 0))
            {
                return;
            }

            char c;

            if (evnt.Key == Key.Return)
            {
                c = '\n';
            }
            else
            {
                c = (char)Keyval.ToUnicode(evnt.KeyValue);
            }
            if (char.IsLetterOrDigit(c) ||
                char.IsPunctuation(c) ||
                c == '\n' ||
                (c == ' ' && SearchController.Query.Length > 0) ||
                char.IsSymbol(c))
            {
                SearchController.AddChar(c);
            }
        }
        public static bool CombinationValid(AccelKey accelKey)
        {
            char         key      = (char)Keyval.ToUnicode((uint)accelKey.Key);
            ModifierType modifier = GetAllowedModifier(accelKey.AccelMods);

            return(IsFunctional(accelKey.Key) || accelKey.Key == Key.Delete ||
                   (((modifier & ControlModifier) != 0 || (modifier & AltModifier) != 0) && (key != char.MinValue || accelKey.Key == Key.BackSpace)));
        }
        /// <summary>
        /// Breaks apart an event key into the individual and normalized key and
        /// any modifiers.
        /// </summary>
        /// <param name="evt">The evt.</param>
        /// <param name="key">The key.</param>
        /// <param name="modifiers">The mod.</param>
        public static void DecomposeKeys(
            EventKey evt,
            out Key key,
            out ModifierType modifiers)
        {
            // Use the keymap to decompose various elements of the hardware keys.
            uint keyval;
            int  effectiveGroup,
                 level;
            ModifierType consumedModifiers;

            keymap.TranslateKeyboardState(
                evt.HardwareKeycode,
                evt.State,
                evt.Group,
                out keyval,
                out effectiveGroup,
                out level,
                out consumedModifiers);

            // Break out the identified keys and modifiers.
            key       = (Key)keyval;
            modifiers = evt.State & ~consumedModifiers;

            // Normalize some of the keys that don't make sense.
            if (key == Key.ISO_Left_Tab)
            {
                key        = Key.Tab;
                modifiers |= ModifierType.ShiftMask;
            }

            // Check to see if we are a character and pull out the shift key if
            // it is a capital letter. This is used to normalize so all the
            // keys are uppercase with a shift modifier.
            bool shiftWasConsumed = ((evt.State ^ modifiers) & ModifierType.ShiftMask)
                                    != 0;
            var unicode = (char)Keyval.ToUnicode((uint)key);

            if (shiftWasConsumed && Char.IsUpper(unicode))
            {
                modifiers |= ModifierType.ShiftMask;
            }

            if (Char.IsLetter(unicode) &&
                Char.IsLower(unicode))
            {
                key = (Key)Char.ToUpper(unicode);
            }
        }
        public static bool KeyEqual(uint left, uint right)
        {
            KeymapKey [] eventKeys = left > 0 ? Keymap.Default.GetEntriesForKeyval(left) : new KeymapKey [0];
            if (eventKeys.Length < 1 || eventKeys.Length > 5)
            {
                return(false);
            }

            if (eventKeys [0].Keycode == Keyval.ToUpper(right))
            {
                return(true);
            }

            KeymapKey [] keys = right > 0 ? Keymap.Default.GetEntriesForKeyval(right) : new KeymapKey [0];
            return(keys.Length > 0 && eventKeys [0].Keycode == keys [0].Keycode);
        }
Beispiel #6
0
        /// <summary>
        /// Called when a key is pressed.
        /// </summary>
        /// <param name="eventKey">The event key.</param>
        /// <returns></returns>
        protected override bool OnKeyPressEvent(EventKey eventKey)
        {
            // If we don't have a line buffer, don't do anything.
            if (LineBuffer == null)
            {
                return(false);
            }

            // Decompose the key into its components.
            ModifierType modifier;
            Key          key;

            GdkUtility.DecomposeKeys(eventKey, out key, out modifier);

            // Get the unicode character for this key.
            uint unicodeChar = Keyval.ToUnicode(eventKey.KeyValue);

            // Pass it on to the controller.
            return(controller.HandleKeyPress(key, modifier, unicodeChar));
        }
        public static bool CombinationValidForItem(AccelKey accelKey)
        {
            char key = (char)Keyval.ToUnicode((uint)accelKey.Key);

            return(IsFunctional(accelKey.Key) || key != char.MinValue);
        }
Beispiel #8
0
        protected void OnKeyRelease(object sender, KeyReleaseEventArgs args)
        {
            GtkKey key = (GtkKey)Keyval.ToLower((uint)args.Event.Key);

            _pressedKeys.Remove(key);
        }
Beispiel #9
0
        protected void OnKeyPress(object sender, KeyPressEventArgs args)
        {
            GtkKey key = (GtkKey)Keyval.ToLower((uint)args.Event.Key);

            _pressedKeys.Add(key);
        }
Beispiel #10
0
 public string NameFromKeyval(uint keyval)
 {
     return(Keyval.Name(keyval));
 }
Beispiel #11
0
 public uint KeyvalFromName(string name)
 {
     return(Keyval.FromName(name));
 }
        private bool OnCellKeyPressEvent(CellKeyPressEventArgs args)
        {
            if (eventLock)
            {
                return(true);
            }

            try {
                eventLock = true;
                if (cellsFucusable && args.Cell.IsValid)
                {
                    column_cache [args.Cell.Column].Column.ListCell.OnKeyPressEvent(args);
                }

                if (CellKeyPressEvent != null)
                {
                    CellKeyPressEvent(this, args);
                }

#if DEBUG_LISTVIEW
                Debug.WriteLine(string.Format("ListView received {0}", "OnCellKeyPressEvent"));
#endif

                bool ret;
                // Don't send arrow keys to the parent because the focus gets lost
                switch (args.GdkKey)
                {
                case Gdk.Key.Up:
                case Gdk.Key.KP_Up:
                case Gdk.Key.Down:
                case Gdk.Key.KP_Down:
                case Gdk.Key.Left:
                case Gdk.Key.Right:
                    ret = true;
                    break;

                default:
                    ret = base.OnKeyPressEvent(args.EventKey);
                    break;
                }

                switch (args.GdkKey)
                {
                case Gdk.Key.Up:
                case Gdk.Key.KP_Up:
                    if (!manualFucusChange)
                    {
                        return(KeyboardScroll(args.EventKey.State, -1));
                    }
                    break;

                case Gdk.Key.Down:
                case Gdk.Key.KP_Down:
                    if (!manualFucusChange)
                    {
                        return(KeyboardScroll(args.EventKey.State, 1));
                    }
                    break;

                case Gdk.Key.Left:
                    if (!manualFucusChange && cellsFucusable)
                    {
                        FocusCell(selection.FocusedCell.Column - 1, selection.FocusedCell.Row);
                        InvalidateList();
                    }
                    break;

                case Gdk.Key.Right:
                    if (!manualFucusChange && cellsFucusable)
                    {
                        FocusCell(selection.FocusedCell.Column + 1, selection.FocusedCell.Row);
                        InvalidateList();
                    }
                    break;

                case Gdk.Key.Page_Up:
                case Gdk.Key.KP_Page_Up:
                    if (!manualFucusChange)
                    {
                        return(KeyboardScroll(args.EventKey.State,
                                              (int)(-vadjustment.PageIncrement / RowHeight)));
                    }
                    break;

                case Gdk.Key.Page_Down:
                case Gdk.Key.KP_Page_Down:
                    if (!manualFucusChange)
                    {
                        return(KeyboardScroll(args.EventKey.State,
                                              (int)(vadjustment.PageIncrement / RowHeight)));
                    }
                    break;

                case Gdk.Key.Home:
                case Gdk.Key.KP_Home:
                    if (!manualFucusChange)
                    {
                        return(KeyboardScroll(args.EventKey.State, -10000000));
                    }
                    break;

                case Gdk.Key.End:
                case Gdk.Key.KP_End:
                    if (!manualFucusChange)
                    {
                        return(KeyboardScroll(args.EventKey.State, 10000000));
                    }
                    break;

                case Gdk.Key.Return:
                case Gdk.Key.KP_Enter:
                    ActivateRow();
                    break;

                default:
                    char keyChar = (char)Keyval.ToUnicode((uint)args.GdkKey);

                    if (char.ToLower(keyChar) == 'a' && (args.EventKey.State & KeyShortcuts.ControlModifier) != 0)
                    {
                        if (allowMultipleSelect)
                        {
                            if ((args.EventKey.State & ModifierType.ShiftMask) != 0)
                            {
                                selection.Clear();
                            }
                            else
                            {
                                selection.SelectAll();
                            }
                            QueueDraw();
                        }
                        return(ret);
                    }

                    if (!editedCell.IsValid)
                    {
                        if (keyChar != '\0')
                        {
                            if (char.ToLower(keyChar) == 'v' && (args.EventKey.State & KeyShortcuts.ControlModifier) != 0)
                            {
                                Clipboard clip = Clipboard.Get(Atom.Intern("CLIPBOARD", false));
                                SetAutoFilter(autoFilterValue + clip.WaitForText(), true);
                            }
                            else
                            {
                                SetAutoFilter(autoFilterValue + keyChar, true);
                            }
                        }
                        else if (args.GdkKey == Gdk.Key.BackSpace)
                        {
                            SetAutoFilter(autoFilterValue.Substring(0, Math.Max(0, autoFilterValue.Length - 1)), true);
                        }
                    }

                    break;
                }

                return(ret);
            } finally {
                eventLock = false;
            }
        }
Beispiel #13
0
        // private MenuButton languageSelectorButton;


        public RoboPad(WindowType type, String[] args) : base(type)
        {
            noOfWindows++;
            SetDefaultSize(500, 500);
            Maximize();
            DeleteEvent += (sender, s) =>
            {
                if (!isChangeSaved)
                {
                    MessageDialog dialog = new MessageDialog(this, DialogFlags.DestroyWithParent,
                                                             MessageType.Warning, ButtonsType.OkCancel, "Changes Unsaved Are You Sure You Want To Exit ");
                    // Dialog dialog=new Dialog()
                    var response = dialog.Run();
                    noOfWindows--;
                    if (response == (int)Gtk.ResponseType.Ok)
                    {
                        if (noOfWindows <= 0)
                        {
                            Gtk.Application.Quit();
                        }
                    }
                    else
                    {
                        s.RetVal = true;
                    }
                    dialog.Dispose();
                }
                else
                {
                    noOfWindows--;
                    if (noOfWindows <= 0)
                    {
                        Gtk.Application.Quit();
                    }
                }
            };
            VBox vBox = new VBox();

            List <String> newTextList = new();
            var           lm          = LanguageManager.Default;

            sourceView = new();
            sourceView.Buffer.HighlightSyntax = true;
            sourceView.WrapMode        = WrapMode.Word;
            sourceView.AutoIndent      = true;
            sourceView.ShowLineNumbers = true;
            StyleSchemeManager schemeManager = StyleSchemeManager.Default;

            // StyleScheme styleScheme = schemeManager.GetScheme("pop-light");

            // sourceView.Buffer.StyleScheme = styleScheme;

            sourceView.KeyPressEvent += (o, eventArgs) =>
            {
                if (Keyval.Name(eventArgs.Event.KeyValue) == "s")
                {
                    saveFile(o, eventArgs);
                }
                else if (Keyval.Name(eventArgs.Event.KeyValue) == "S")
                {
                    saveAsFile(o, eventArgs);
                }
                else if (Keyval.Name(eventArgs.Event.KeyValue) == "o")
                {
                    openFile(o, eventArgs);
                }
            };


            headerBar = new HeaderBar();
            ScrolledWindow scrolledWindow = new ScrolledWindow();

            scrolledWindow.Add(sourceView);

            headerBar.ShowCloseButton = true;
            headerBar.Title           = "RoboPad";
            headerBarOringalText      = headerBar.Title;

            sourceView.Buffer.Changed += (sender, eventArgs) =>
            {
                headerBar.Title = "*" + headerBarOringalText;
                if (sourceView.Buffer.Text != previousText)
                {
                    isChangeSaved = false;
                }
                else
                {
                    isChangeSaved   = true;
                    headerBar.Title = headerBarOringalText;
                }
            };
            ToolButtonHandler toolbar = new ToolButtonHandler(this, sourceView);



            // Menu menu = new Menu();
            // MenuItem openItem = new RadioMenuItem("test");
            // menu.Add(openItem);
            //
            // menu.ShowAll();
            //



            PopOverMenuHandler popoverMenu = new(this);
            MenuButton         menuButton  = new MenuButton();

            menuButton.Popover = popoverMenu;
            Image image = Gtk.Image.NewFromIconName("view-more-symbolic", IconSize.LargeToolbar);

            menuButton.Image = image;
            headerBar.PackEnd(menuButton);

            Statusbar statusbar = new Statusbar();

            statusBarLabel = new("");
            statusbar.PackStart(statusBarLabel, false, false, 5);
            languageSelectorButton = new LanguageSelectorButton(sourceView);
            statusbar.PackEnd(languageSelectorButton, false, false, 5);



            // Box box = new Box(Gtk.Orientation.Vertical,2);

            Titlebar = headerBar;

            vBox.PackStart(toolbar, false, false, 0);
            vBox.PackStart(scrolledWindow, true, true, 0);
            vBox.PackStart(statusbar, false, false, 0);
            Add(vBox);

            ShowAll();

            Show();
            if (args != null)
            {
                if (args.Length >= 1)
                {
                    if (!String.IsNullOrWhiteSpace(args[0]))
                    {
                        openFileWithArgs(args[0]);
                    }
                }
            }
        }