TabConsole.hx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package arm.ui;
  2. import haxe.io.Bytes;
  3. import zui.Zui;
  4. import arm.sys.Path;
  5. import arm.Enums;
  6. class TabConsole {
  7. @:access(zui.Zui)
  8. public static function draw() {
  9. var ui = UISidebar.inst.ui;
  10. var title = Console.messageTimer > 0 ? Console.message + " " : tr("Console");
  11. var color = Console.messageTimer > 0 ? Console.messageColor : -1;
  12. var statush = Config.raw.layout[LayoutStatusH];
  13. if (ui.tab(UIStatus.inst.statustab, title, false, color) && statush > UIStatus.defaultStatusH * ui.SCALE()) {
  14. ui.beginSticky();
  15. #if (krom_windows || krom_linux || krom_darwin) // Copy
  16. if (Config.raw.touch_ui) {
  17. ui.row([1 / 4, 1 / 4, 1 / 4]);
  18. }
  19. else {
  20. ui.row([1 / 14, 1 / 14, 1 / 14]);
  21. }
  22. #else
  23. if (Config.raw.touch_ui) {
  24. ui.row([1 / 4, 1 / 4]);
  25. }
  26. else {
  27. ui.row([1 / 14, 1 / 14]);
  28. }
  29. #end
  30. if (ui.button(tr("Clear"))) {
  31. Console.lastTraces = [];
  32. }
  33. if (ui.button(tr("Export"))) {
  34. var str = Console.lastTraces.join("\n");
  35. UIFiles.show("txt", true, false, function(path: String) {
  36. var f = UIFiles.filename;
  37. if (f == "") f = tr("untitled");
  38. path = path + Path.sep + f;
  39. if (!path.endsWith(".txt")) path += ".txt";
  40. Krom.fileSaveBytes(path, Bytes.ofString(str).getData());
  41. });
  42. }
  43. #if (krom_windows || krom_linux || krom_darwin)
  44. if (ui.button(tr("Copy"))) {
  45. var str = Console.lastTraces.join("\n");
  46. Krom.copyToClipboard(str);
  47. }
  48. #end
  49. ui.endSticky();
  50. for (t in Console.lastTraces) {
  51. ui.text(t);
  52. }
  53. }
  54. }
  55. }