1 #ifndef REPLXX_PROMPT_HXX_INCLUDED
2 #define REPLXX_PROMPT_HXX_INCLUDED 1
3 
4 #include <cstdlib>
5 
6 #include "unicodestring.hxx"
7 #include "terminal.hxx"
8 
9 namespace replxx {
10 
11 class Prompt {           // a convenience struct for grouping prompt info
12 public:
13 	UnicodeString _text;   // our copy of the prompt text, edited
14 	int _characterCount;   // visible characters in _text
15 	int _extraLines;       // extra lines (beyond 1) occupied by prompt
16 	int _lastLinePosition; // index into _text where last line begins
17 	int _cursorRowOffset;  // where the cursor is relative to the start of the prompt
18 private:
19 	int _screenColumns;    // width of screen in columns [cache]
20 	Terminal& _terminal;
21 public:
22 	Prompt( Terminal& );
23 	void set_text( UnicodeString const& textPtr );
24 	void update_state();
25 	void update_screen_columns( void );
screen_columns() const26 	int screen_columns() const {
27 		return ( _screenColumns );
28 	}
29 	void write();
30 	int indentation() const;
31 };
32 
33 // changing prompt for "(reverse-i-search)`text':" etc.
34 //
35 struct DynamicPrompt : public Prompt {
36 	UnicodeString _searchText; // text we are searching for
37 	int _direction;            // current search _direction, 1=forward, -1=reverse
38 
39 	DynamicPrompt( Terminal&, int initialDirection );
40 	void updateSearchPrompt(void);
41 };
42 
43 }
44 
45 #endif
46