You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

prompt.hxx 1.2KB

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