render.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef RENDER_H
  2. #define RENDER_H
  3. #include "terminal.h"
  4. #include <string>
  5. #include <vector>
  6. class Render {
  7. private:
  8. int speed;
  9. int effect;
  10. int fd;
  11. int overlimit;
  12. Terminal &term;
  13. std::vector<std::string> color_history;
  14. const char **image_data; // vector to hold multiple images -- just in case.
  15. int image_size;
  16. public:
  17. Render(int fd, Terminal &term);
  18. void reset(void);
  19. void sleep(void);
  20. int ms_sleep(unsigned int ms);
  21. void color(int color);
  22. void pos_goto(int x, int y);
  23. void send(char ch); // render_effect
  24. void send(std::string &string_out); // render
  25. // to change: Make this a vector (in the case we set multiple images)
  26. void set_image(const char **lines, int size); // render_image
  27. void reset_image(void);
  28. private:
  29. void process_trigger(std::string str, size_t &pos);
  30. int digit(std::string str, size_t &pos, int digits = 1);
  31. int send_image(int x, int y);
  32. int send_image(void);
  33. };
  34. struct render {
  35. int speed;
  36. int effect;
  37. };
  38. void reset_render(void);
  39. int ms_sleep(unsigned int ms);
  40. void render_sleep(void);
  41. void write_color(int fd, int color);
  42. void send_goto(int fd, int x, int y);
  43. /*
  44. int send_file(int fd, char *filename);
  45. int send_file(int fd, int x, int y, char *filename);
  46. */
  47. const char *process_trigger(int fd, const char *cp);
  48. void process_trigger(int fd, std::string str, size_t &pos);
  49. void render_effect(int fd, char ch);
  50. /*
  51. void render(int fd, const char *string_out, int len);
  52. */
  53. void render(int fd, std::string &string_out);
  54. void render_image(const char **lines, int size);
  55. // Use this in everything, so it is easily changed!
  56. #define TRIGGER "\x16"
  57. // "@" // "^" // "\x16"
  58. // Max limit we'll sleep before ignoring effects/speed.
  59. #define SLEEP_LIMIT 30
  60. #endif