RunView.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
  3. * All rights reserved. Distributed under the terms of the MIT license.
  4. */
  5. #include "RunView.h"
  6. #include <Cursor.h>
  7. #include <Locale.h>
  8. #include <MenuItem.h>
  9. #include <PopUpMenu.h>
  10. #include <TextView.h>
  11. #include <Window.h>
  12. const uint32 kSearchDdg = 'RVse';
  13. const uint32 kSearchDict = 'RVdc';
  14. RunView::RunView(const char* name)
  15. :
  16. UrlTextView(name),
  17. fLastStyled(false)
  18. {
  19. text_run run = { 0, BFont(), ui_color(B_PANEL_TEXT_COLOR) };
  20. fDefaultRun = { 1, {run} };
  21. }
  22. void
  23. RunView::Append(const char* text, rgb_color color, BFont font)
  24. {
  25. text_run run = { 0, font, color };
  26. text_run_array array = { 1, {run} };
  27. Insert(text, &array);
  28. fLastStyled = true;
  29. }
  30. void
  31. RunView::Append(const char* text, rgb_color color, uint16 fontFace)
  32. {
  33. BFont font;
  34. font.SetFace(fontFace);
  35. Append(text, color, font);
  36. }
  37. void
  38. RunView::Append(const char* text, rgb_color color)
  39. {
  40. Append(text, color, BFont());
  41. }
  42. void
  43. RunView::Append(const char* text)
  44. {
  45. if (fLastStyled == false)
  46. Insert(text);
  47. else
  48. Insert(text, &fDefaultRun);
  49. fLastStyled = false;
  50. }
  51. void
  52. RunView::ScrollToBottom()
  53. {
  54. ScrollToOffset(TextLength());
  55. }