VirtualConsole.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #include "TTY.h"
  3. #include "Keyboard.h"
  4. #include "Console.h"
  5. class VirtualConsole final : public TTY, public KeyboardClient, public ConsoleImplementation {
  6. AK_MAKE_ETERNAL
  7. public:
  8. enum InitialContents { Cleared, AdoptCurrentVGABuffer };
  9. VirtualConsole(unsigned index, InitialContents = Cleared);
  10. virtual ~VirtualConsole() override;
  11. static void switch_to(unsigned);
  12. static void initialize();
  13. private:
  14. // ^KeyboardClient
  15. virtual void on_key_pressed(Keyboard::Key) override;
  16. // ^ConsoleImplementation
  17. virtual void on_sysconsole_receive(byte) override;
  18. // ^TTY
  19. virtual void on_tty_write(const byte*, size_t) override;
  20. virtual String tty_name() const override;
  21. void set_active(bool);
  22. void on_char(byte);
  23. void get_vga_cursor(byte& row, byte& column);
  24. void flush_vga_cursor();
  25. byte* m_buffer;
  26. unsigned m_index;
  27. bool m_active { false };
  28. void scroll_up();
  29. void set_cursor(unsigned row, unsigned column);
  30. void put_character_at(unsigned row, unsigned column, byte ch);
  31. void escape$A(const Vector<unsigned>&);
  32. void escape$H(const Vector<unsigned>&);
  33. void escape$J(const Vector<unsigned>&);
  34. void escape$m(const Vector<unsigned>&);
  35. void escape$s(const Vector<unsigned>&);
  36. void escape$u(const Vector<unsigned>&);
  37. void clear();
  38. byte m_cursor_row { 0 };
  39. byte m_cursor_column { 0 };
  40. byte m_saved_cursor_row { 0 };
  41. byte m_saved_cursor_column { 0 };
  42. byte m_current_attribute { 0x07 };
  43. void clear_vga_row(word row);
  44. void set_vga_start_row(word row);
  45. word m_vga_start_row { 0 };
  46. word m_current_vga_start_address { 0 };
  47. byte* m_current_vga_window { nullptr };
  48. void execute_escape_sequence(byte final);
  49. enum EscapeState {
  50. Normal,
  51. ExpectBracket,
  52. ExpectParameter,
  53. ExpectIntermediate,
  54. ExpectFinal,
  55. };
  56. EscapeState m_escape_state { Normal };
  57. Vector<byte> m_parameters;
  58. Vector<byte> m_intermediates;
  59. byte* m_horizontal_tabs { nullptr };
  60. };