Exemplo n.º 1
0
        /// <summary>
        /// Exit the menubar loop and clear all selections.
        /// </summary>
        static void Exit()
        {
            // Unselect old menubar selection
            UnfocusMenuBarItem();

            Console.ResetColor();
            FilePanel.Update();
            OffsetPanel.Initialize();
            inMenu = false;
        }
Exemplo n.º 2
0
        static void ReadKey()
        {
            ConsoleKeyInfo ck = Console.ReadKey(true);

            oldY = Y;
            oldX = X;

            switch (ck.Key)
            {
            case ConsoleKey.Escape:
                Exit();
                return;

            case ConsoleKey.UpArrow:
                MoveUp();
                break;

            case ConsoleKey.DownArrow:
                MoveDown();
                break;

            case ConsoleKey.LeftArrow:
                MoveLeft();
                Console.ResetColor();
                OffsetPanel.Draw();
                FilePanel.Update();
                DrawSubMenu();
                break;

            case ConsoleKey.RightArrow:
                MoveRight();
                Console.ResetColor();
                OffsetPanel.Draw();
                FilePanel.Update();
                DrawSubMenu();
                break;

            case ConsoleKey.Spacebar:
            case ConsoleKey.Enter:
                SelectItem();
                break;
            }

            /*
             * This 'if' is there due to calling Exit() from the item's
             * Action, the stack pointer goes back to SelectItem, which
             * then used to call Update(). So this is a sanity check.
             */
            if (inMenu)
            {
                Update();
            }
        }
Exemplo n.º 3
0
        public static void PromptOffset()
        {
            string c = GetUserInput("Hex, Dec, Oct?");

            if (c == null || c.Length < 1)
            {
                InfoPanel.Message("Canceled.");
                FilePanel.Update();
                return;
            }

            switch (c[0])
            {
            case 'H':
            case 'h':
                MainApp.OffsetView = OffsetView.Hex;
                OffsetPanel.Update();
                InfoPanel.Update();
                break;

            case 'O':
            case 'o':
                MainApp.OffsetView = OffsetView.Oct;
                OffsetPanel.Update();
                InfoPanel.Update();
                break;

            case 'D':
            case 'd':
                MainApp.OffsetView = OffsetView.Dec;
                OffsetPanel.Update();
                InfoPanel.Update();
                break;

            default:
                InfoPanel.Message("Invalid view mode!");
                break;
            }

            FilePanel.Update();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Update the data onscreen from <see cref="DisplayBuffer"/>.
        /// </summary>
        public static void Update()
        {
            int width = Console.WindowWidth - 1;

            long len = File.Length, pos = FileIO.Position;

            //TODO: Check if we can do a little pointer-play with the buffer.

            int d = 0, bpr = MainApp.BytesPerRow;

            StringBuilder
                line  = new StringBuilder(width),
                ascii = new StringBuilder(bpr);

            OffsetPanel.Update();

            Console.SetCursorPosition(0, StartPosition);
            for (int i = 0; i < DisplayBuffer.Length; i += bpr)
            {
                line.Clear();
                switch (MainApp.OffsetView)
                {
                default:
                    line.Append($"{pos + i:X8}  ");
                    break;

                case OffsetView.Dec:
                    line.Append($"{pos + i:D8}  ");
                    break;

                case OffsetView.Oct:
                    line.Append($"{MainApp.ToOct(pos + i, 8)}  ");
                    break;
                }

                ascii.Clear();
                if (pos + i + bpr < len)
                {
                    for (int bi = 0; bi < bpr; ++bi, ++d)
                    {
                        line.Append($"{DisplayBuffer[d]:X2} ");
                        ascii.Append(DisplayBuffer[d].ToAscii());
                    }

                    Console.Write(line.ToString());
                    Console.Write(' '); // In case of "over FFFF_FFFFh" padding
                    Console.Write(ascii.ToString());
                    Console.WriteLine(' ');
                }
                else
                {
                    long h = len - (pos + i);

                    for (int bi = 0; bi < h; ++bi, ++d)
                    {
                        line.Append($"{DisplayBuffer[d]:X2} ");
                        ascii.Append(DisplayBuffer[d].ToAscii());
                    }

                    Console.Write(line.ToString());
                    Console.SetCursorPosition(Console.WindowWidth - bpr - 5, Console.CursorTop);
                    Console.Write(ascii.ToString());
                    return;
                }
            }
        }