MCPcopy Create free account
hub / github.com/Rezonality/zep / UpdateTabs

Method UpdateTabs

src/editor.cpp:569–625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567}
568
569void ZepEditor::UpdateTabs()
570{
571 m_tabRegion->children.clear();
572 if (GetTabWindows().size() > 1)
573 {
574 // Tab region
575 for (auto& window : GetTabWindows())
576 {
577 if (window->GetActiveWindow() == nullptr)
578 continue;
579
580 // Show active buffer in tab as tab name
581 auto& buffer = window->GetActiveWindow()->GetBuffer();
582 std::string name = buffer.GetName();
583 if (m_config.shortTabNames)
584 {
585 auto pos = name.find_last_of('.');
586 if (pos != std::string::npos)
587 {
588 name = name.substr(0, pos);
589 }
590 }
591
592 auto tabColor = GetTheme().GetColor(ThemeColor::TabActive);
593 if (buffer.HasFileFlags(FileFlags::HasWarnings))
594 {
595 tabColor = GetTheme().GetColor(ThemeColor::Warning);
596 }
597
598 // Errors win for coloring
599 if (buffer.HasFileFlags(FileFlags::HasErrors))
600 {
601 tabColor = GetTheme().GetColor(ThemeColor::Error);
602 }
603
604 if (window != GetActiveTabWindow())
605 {
606 // Desaturate unselected ones
607 tabColor = tabColor * .55f;
608 tabColor.w = 1.0f;
609 }
610 auto tabLength = m_pDisplay->GetFont(ZepTextType::Text).GetTextSize((const uint8_t*)name.c_str()).x + DPI_X(textBorder) * 2;
611
612 auto spTabRegionTab = std::make_shared<TabRegionTab>();
613 spTabRegionTab->color = tabColor;
614 spTabRegionTab->name = name;
615 spTabRegionTab->pTabWindow = window;
616 spTabRegionTab->fixed_size = NVec2f(tabLength, 0.0f);
617 spTabRegionTab->layoutType = RegionLayoutType::HBox;
618 spTabRegionTab->padding = DPI_VEC2(NVec2f(textBorder, textBorder));
619 spTabRegionTab->flags = RegionFlags::Fixed;
620 m_tabRegion->children.push_back(spTabRegionTab);
621 spTabRegionTab->pParent = m_tabRegion.get();
622 }
623 }
624 LayoutRegion(*m_tabRegion);
625}
626

Callers 2

SetBufferMethod · 0.80
SetActiveWindowMethod · 0.80

Calls 10

LayoutRegionFunction · 0.85
GetActiveWindowMethod · 0.80
GetNameMethod · 0.80
HasFileFlagsMethod · 0.80
c_strMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
GetTextSizeMethod · 0.45
push_backMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected