tab_console.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. function tab_console_draw(htab: ui_handle_t) {
  2. let ui: ui_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 (ui_tab(htab, title, false, color) && statush > ui_status_default_status_h * ui_SCALE(ui)) {
  7. ui_begin_sticky();
  8. ///if (arm_windows || arm_linux || arm_macos) // Copy
  9. if (config_raw.touch_ui) {
  10. let row: f32[] = [1 / 4, 1 / 4, 1 / 4];
  11. ui_row(row);
  12. }
  13. else {
  14. let row: f32[] = [1 / 14, 1 / 14, 1 / 14];
  15. ui_row(row);
  16. }
  17. ///else
  18. if (config_raw.touch_ui) {
  19. let row: f32[] = [1 / 4, 1 / 4];
  20. ui_row(row);
  21. }
  22. else {
  23. let row: f32[] = [1 / 14, 1 / 14];
  24. ui_row(row);
  25. }
  26. ///end
  27. if (ui_button(tr("Clear"))) {
  28. console_last_traces = [];
  29. }
  30. if (ui_button(tr("Export"))) {
  31. ui_files_show("txt", true, false, function (path: string) {
  32. let str: string = string_array_join(console_last_traces, "\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. iron_file_save_bytes(path, sys_string_to_buffer(str), 0);
  42. });
  43. }
  44. ///if (arm_windows || arm_linux || arm_macos)
  45. if (ui_button(tr("Copy"))) {
  46. let str: string = string_array_join(console_last_traces, "\n");
  47. iron_copy_to_clipboard(str);
  48. }
  49. ///end
  50. ui_end_sticky();
  51. let _font: draw_font_t = ui.ops.font;
  52. let _font_size: i32 = ui.font_size;
  53. let f: draw_font_t = data_get_font("font_mono.ttf");
  54. ui_set_font(ui, f);
  55. ui.font_size = math_floor(15 * ui_SCALE(ui));
  56. for (let i: i32 = 0; i < console_last_traces.length; ++i) {
  57. let t: string = console_last_traces[i];
  58. ui_text(t);
  59. }
  60. ui_set_font(ui, _font);
  61. ui.font_size = _font_size;
  62. }
  63. }