tab_console.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. function tab_console_draw(htab: zui_handle_t) {
  2. let ui: zui_t = ui_base_ui;
  3. let title: string = console_message_timer > 0 ? console_message + " " : tr("Console");
  4. let color: i32 = console_message_timer > 0 ? console_message_color : -1;
  5. let statush: i32 = config_raw.layout[layout_size_t.STATUS_H];
  6. if (zui_tab(htab, title, false, color) && statush > ui_status_default_status_h * zui_SCALE(ui)) {
  7. zui_begin_sticky();
  8. ///if (krom_windows || krom_linux || krom_darwin) // Copy
  9. if (config_raw.touch_ui) {
  10. let row: f32[] = [1 / 4, 1 / 4, 1 / 4];
  11. zui_row(row);
  12. }
  13. else {
  14. let row: f32[] = [1 / 14, 1 / 14, 1 / 14];
  15. zui_row(row);
  16. }
  17. ///else
  18. if (config_raw.touch_ui) {
  19. let row: f32[] = [1 / 4, 1 / 4];
  20. zui_row(row);
  21. }
  22. else {
  23. let row: f32[] = [1 / 14, 1 / 14];
  24. zui_row(row);
  25. }
  26. ///end
  27. if (zui_button(tr("Clear"))) {
  28. console_last_traces = [];
  29. }
  30. if (zui_button(tr("Export"))) {
  31. ui_files_show("txt", true, false, function (path: string) {
  32. let str: string = console_last_traces.join("\n");
  33. let f: string = ui_files_filename;
  34. if (f == "") {
  35. f = tr("untitled");
  36. }
  37. path = path + path_sep + f;
  38. if (!ends_with(path, ".txt")) {
  39. path += ".txt";
  40. }
  41. krom_file_save_bytes(path, sys_string_to_buffer(str));
  42. });
  43. }
  44. ///if (krom_windows || krom_linux || krom_darwin)
  45. if (zui_button(tr("Copy"))) {
  46. let str: string = console_last_traces.join("\n");
  47. krom_copy_to_clipboard(str);
  48. }
  49. ///end
  50. zui_end_sticky();
  51. let _font: g2_font_t = ui.ops.font;
  52. let _fontSize: i32 = ui.font_size;
  53. let f: g2_font_t = data_get_font("font_mono.ttf");
  54. zui_set_font(ui, f);
  55. ui.font_size = math_floor(15 * zui_SCALE(ui));
  56. for (let i: i32 = 0; i < console_last_traces.length; ++i) {
  57. let t: string = console_last_traces[i];
  58. zui_text(t);
  59. }
  60. zui_set_font(ui, _font);
  61. ui.font_size = _fontSize;
  62. }
  63. }