tab_console.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. function tab_console_draw(htab: ui_handle_t) {
  2. let title: string = console_message_timer > 0 ? console_message + " " : tr("Console");
  3. let color: i32 = console_message_timer > 0 ? console_message_color : -1;
  4. let statush: i32 = config_raw.layout[layout_size_t.STATUS_H];
  5. if (ui_tab(htab, title, false, color) && statush > ui_status_default_status_h * UI_SCALE()) {
  6. ui_begin_sticky();
  7. ///if (arm_windows || arm_linux || arm_macos) // Copy
  8. if (config_raw.touch_ui) {
  9. let row: f32[] = [1 / 4, 1 / 4, 1 / 4];
  10. ui_row(row);
  11. }
  12. else {
  13. let row: f32[] = [1 / 14, 1 / 14, 1 / 14];
  14. ui_row(row);
  15. }
  16. ///else
  17. if (config_raw.touch_ui) {
  18. let row: f32[] = [1 / 4, 1 / 4];
  19. ui_row(row);
  20. }
  21. else {
  22. let row: f32[] = [1 / 14, 1 / 14];
  23. ui_row(row);
  24. }
  25. ///end
  26. if (ui_button(tr("Clear"))) {
  27. console_last_traces = [];
  28. }
  29. if (ui_button(tr("Export"))) {
  30. ui_files_show("txt", true, false, function (path: string) {
  31. let str: string = string_array_join(console_last_traces, "\n");
  32. let f: string = ui_files_filename;
  33. if (f == "") {
  34. f = tr("untitled");
  35. }
  36. path = path + path_sep + f;
  37. if (!ends_with(path, ".txt")) {
  38. path += ".txt";
  39. }
  40. iron_file_save_bytes(path, sys_string_to_buffer(str), 0);
  41. });
  42. }
  43. ///if (arm_windows || arm_linux || arm_macos)
  44. if (ui_button(tr("Copy"))) {
  45. let str: string = string_array_join(console_last_traces, "\n");
  46. iron_copy_to_clipboard(str);
  47. }
  48. ///end
  49. ui_end_sticky();
  50. let _font: draw_font_t = ui.ops.font;
  51. let _font_size: i32 = ui.font_size;
  52. let f: draw_font_t = data_get_font("font_mono.ttf");
  53. ui_set_font(ui, f);
  54. ui.font_size = math_floor(15 * UI_SCALE());
  55. for (let i: i32 = 0; i < console_last_traces.length; ++i) {
  56. let t: string = console_last_traces[i];
  57. ui_text(t);
  58. }
  59. ui_set_font(ui, _font);
  60. ui.font_size = _font_size;
  61. }
  62. }