Ejemplo n.º 1
0
        public Editor(TrueTypeFont font)
        {
            Font = font;

            Buffer  = new EditorBuffer();
            Options = new EditorOptions
            {
                HighlightCurrentLine = true,
                TabSize = 2
            };

            Hotkeys      = new List <Hotkey>();
            TextRenderer = new TextRenderer(this);
            Window       = new Window(this);

            ModeLine = new ModeLine(Font);
            Cursor   = new Cursor
            {
                ForceVisible = true
            };

            _ = new FileSystem(this);
            _ = new Modification(this);
            _ = new Navigation(this);
            _ = new StatusControl(this);
        }
Ejemplo n.º 2
0
        public void KeyPressed(KeyCode keyCode, KeyModifiers keyModifiers)
        {
            if (ModeLine.IsTakingInput)
            {
                ModeLine.KeyPressed(keyCode, keyModifiers);
                return;
            }

            foreach (var hotkey in Hotkeys.OrderByDescending(x => x.Precedence))
            {
                if (hotkey.IsDown())
                {
                    hotkey.Action();
                    return;
                }
            }

            if (keyCode == KeyCode.Backspace)
            {
                Backspace();
            }
            else if (keyCode == KeyCode.Delete)
            {
                Delete();
            }
            else if (keyCode == KeyCode.Return)
            {
                NewLine();
            }

            if (Options.TypingMode != TypingMode.Regular)
            {
                var dict = PetsciiControlCodes.PetsciiSymbolMappings;

                if (Options.TypingMode == TypingMode.PetsciiShifted)
                {
                    dict = PetsciiControlCodes.PetsciiSymbolMappingShifted;
                }

                if (dict.ContainsKey(keyCode))
                {
                    var petscii = dict[keyCode];

                    if (Font.CanRenderGlyph(petscii))
                    {
                        PrintableCharacter(petscii);
                    }
                }
            }

            ModeLine.PauseDynamicUpdates = false;
        }
Ejemplo n.º 3
0
        public void Draw(RenderContext context)
        {
            DrawBackdrop(context);
            TextRenderer.Draw(context);

            if (Options.HighlightCurrentLine)
            {
                DrawLineHighlight(context);
            }

            Cursor.Draw(context);
            ModeLine.Draw(context);
        }
Ejemplo n.º 4
0
        public void Update(float deltaTime)
        {
            Cursor.ColorMask = EditorColors.EditorCursorColor;
            Cursor.Update(deltaTime);

            ModeLine.Update(deltaTime);
            UpdateCursorPosition();

            TextRenderer.PushLines(Buffer.Lines);

            if (!ModeLine.IsTakingInput && !ModeLine.PauseDynamicUpdates)
            {
                UpdateModeLineStatusText();
            }
        }
Ejemplo n.º 5
0
        public void TextInput(char character)
        {
            if (char.IsControl(character))
            {
                return;
            }

            if (ModeLine.IsTakingInput)
            {
                ModeLine.TextInput(character);
                return;
            }

            if (Options.TypingMode != TypingMode.Regular)
            {
                return;
            }

            if (Font.CanRenderGlyph(character))
            {
                PrintableCharacter(character);
            }
        }