| 543 | } |
| 544 | |
| 545 | void CodeEditorUI::DrawTextEditor(const std::string& windowName, TextEditor* tEdit) |
| 546 | { |
| 547 | if (tEdit) { |
| 548 | int i = 0; |
| 549 | for (; i < m_editor.size(); i++) |
| 550 | if (m_editor[i] == tEdit) |
| 551 | break; |
| 552 | |
| 553 | // add error markers if needed |
| 554 | auto msgs = m_data->Messages.GetMessages(); |
| 555 | int groupMsg = 0; |
| 556 | TextEditor::ErrorMarkers groupErrs; |
| 557 | for (int j = 0; j < msgs.size(); j++) { |
| 558 | ed::MessageStack::Message* msg = &msgs[j]; |
| 559 | |
| 560 | if (groupErrs.count(msg->Line)) |
| 561 | continue; |
| 562 | |
| 563 | if (m_items[i] != nullptr && msg->Line > 0 && msg->Group == m_items[i]->Name && msg->Shader == m_shaderStage[i]) |
| 564 | groupErrs[msg->Line] = msg->Text; |
| 565 | } |
| 566 | tEdit->SetErrorMarkers(groupErrs); |
| 567 | |
| 568 | bool statusbar = Settings::Instance().Editor.StatusBar; |
| 569 | |
| 570 | // render code |
| 571 | ImGui::PushFont(m_font); |
| 572 | m_editor[i]->Render(windowName.c_str(), ImVec2(0, -statusbar * STATUSBAR_HEIGHT)); |
| 573 | if (ImGui::IsItemHovered() && ImGui::GetIO().KeyCtrl && ImGui::GetIO().MouseWheel != 0.0f) { |
| 574 | Settings::Instance().Editor.FontSize = Settings::Instance().Editor.FontSize + ImGui::GetIO().MouseWheel; |
| 575 | this->SetFont(Settings::Instance().Editor.Font, Settings::Instance().Editor.FontSize); |
| 576 | } |
| 577 | ImGui::PopFont(); |
| 578 | |
| 579 | // status bar |
| 580 | if (statusbar) { |
| 581 | auto cursor = m_editor[i]->GetCursorPosition(); |
| 582 | |
| 583 | ImGui::Separator(); |
| 584 | ImGui::Text("Line %d\tCol %d\tType: %s\tPath: %s", cursor.mLine, cursor.mColumn, m_editor[i]->GetLanguageDefinition().mName.c_str(), m_paths[i].c_str()); |
| 585 | } |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | void CodeEditorUI::LoadSnippets() |
| 590 | { |