From 1964d19c464d25fb1898a8ea38579f97b36fafd5 Mon Sep 17 00:00:00 2001 From: that Date: Thu, 7 Jan 2016 00:41:03 +0100 Subject: gui: add terminal emulator Emulates enough of a VT-100 to run busybox vi. Change-Id: I99c829c6c9de2246194ecb8b8b3cdf4ac34a0606 --- gui/objects.hpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'gui/objects.hpp') diff --git a/gui/objects.hpp b/gui/objects.hpp index 5e0960777..15ad1e6c2 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -81,6 +81,7 @@ public: virtual int SetPlacement(Placement placement) { mPlacement = placement; return 0; } // SetPageFocus - Notify when a page gains or loses focus + // TODO: This should be named NotifyPageFocus for consistency virtual void SetPageFocus(int inFocus __unused) { return; } protected: @@ -767,6 +768,43 @@ protected: int RenderConsole(void); }; +class TerminalEngine; +class GUITerminal : public GUIScrollList, public InputObject +{ +public: + GUITerminal(xml_node<>* node); + +public: + // Update - Update any UI component animations (called <= 30 FPS) + // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error + virtual int Update(void); + + // NotifyTouch - Notify of a touch event + // Return 0 on success, >0 to ignore remainder of touch, and <0 on error (Return error to allow other handlers) + virtual int NotifyTouch(TOUCH_STATE state, int x, int y); + + // NotifyKey - Notify of a key press + // Return 0 on success (and consume key), >0 to pass key to next handler, and <0 on error + virtual int NotifyKey(int key, bool down); + + // character input + virtual int NotifyCharInput(int ch); + + // SetPageFocus - Notify when a page gains or loses focus + virtual void SetPageFocus(int inFocus); + + // ScrollList interface + virtual size_t GetItemCount(); + virtual void RenderItem(size_t itemindex, int yPos, bool selected); + virtual void NotifySelect(size_t item_selected); +protected: + void InitAndResize(); + + TerminalEngine* engine; // non-visual parts of the terminal (text buffer etc.), not owned + int updateCounter; // to track if anything changed in the back-end + bool lastCondition; // to track if the condition became true and we might need to resize the terminal engine +}; + // GUIAnimation - Used for animations class GUIAnimation : public GUIObject, public RenderObject { -- cgit v1.2.3