console.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #if defined(Hiro_Console)
  2. auto mConsole::allocate() -> pObject* {
  3. return new pConsole(*this);
  4. }
  5. //
  6. auto mConsole::backgroundColor() const -> Color {
  7. return state.backgroundColor;
  8. }
  9. auto mConsole::doActivate(string command) const -> void {
  10. if(state.onActivate) return state.onActivate(command);
  11. }
  12. auto mConsole::foregroundColor() const -> Color {
  13. return state.foregroundColor;
  14. }
  15. auto mConsole::onActivate(const function<void (string)>& callback) -> type& {
  16. state.onActivate = callback;
  17. return *this;
  18. }
  19. auto mConsole::print(const string& text) -> type& {
  20. signal(print, text);
  21. return *this;
  22. }
  23. auto mConsole::prompt() const -> string {
  24. return state.prompt;
  25. }
  26. auto mConsole::reset() -> type& {
  27. signal(reset);
  28. return *this;
  29. }
  30. auto mConsole::setBackgroundColor(Color color) -> type& {
  31. state.backgroundColor = color;
  32. signal(setBackgroundColor, color);
  33. return *this;
  34. }
  35. auto mConsole::setForegroundColor(Color color) -> type& {
  36. state.foregroundColor = color;
  37. signal(setForegroundColor, color);
  38. return *this;
  39. }
  40. auto mConsole::setPrompt(const string& prompt) -> type& {
  41. state.prompt = prompt;
  42. signal(setPrompt, prompt);
  43. return *this;
  44. }
  45. #endif