The ZepTabWindow class represents a tab container that manages one or more ZepWindow instances. It handles window splitting, window navigation, layout management, and active window tracking. Tab windows allow users to view multiple buffers simultaneously with split layouts.
#include <zep/tab_window.h>#include <zep/window.h>#include <zep/editor.h>// Create tab windowZepTabWindow* pTab = editor.AddTabWindow();// Get or create a bufferZepBuffer* pBuffer = editor.GetFileBuffer("main.cpp");// Add first window to the tabZepWindow* pWindow = pTab->AddWindow(pBuffer);// Set as activepTab->SetActiveWindow(pWindow);// DisplaypTab->Display();
// Create first windowZepBuffer* pBuffer1 = editor.GetFileBuffer("main.cpp");ZepWindow* pWindow1 = pTab->AddWindow(pBuffer1);// Split horizontally (side by side)ZepBuffer* pBuffer2 = editor.GetFileBuffer("header.h");ZepWindow* pWindow2 = pTab->AddWindow(pBuffer2, pWindow1, RegionLayoutType::HBox);// Now pWindow1 and pWindow2 are side by side
// Create first windowZepBuffer* pBuffer1 = editor.GetFileBuffer("main.cpp");ZepWindow* pWindow1 = pTab->AddWindow(pBuffer1);// Split vertically (top and bottom)ZepBuffer* pBuffer2 = editor.GetFileBuffer("output.txt");ZepWindow* pWindow2 = pTab->AddWindow(pBuffer2, pWindow1, RegionLayoutType::VBox);// Now pWindow1 is on top, pWindow2 is on bottom
// Navigate between windowsZepWindow* pLeft = pTab->DoMotion(WindowMotion::Left);if (pLeft){ // Successfully moved to left window std::cout << "Now viewing: " << pLeft->GetBuffer().GetDisplayName();}ZepWindow* pDown = pTab->DoMotion(WindowMotion::Down);if (!pDown){ // No window below current position std::cout << "No window below";}
// Close specific windowZepWindow* pWindow = pTab->GetActiveWindow();if (pWindow){ pTab->RemoveWindow(pWindow);}// Or close the active window directlypTab->CloseActiveWindow();
// Define tab area (x, y, width, height)NRectf tabRect(0, 0, 1024, 768);pTab->SetDisplayRegion(tabRect);// Force recalculation of layoutpTab->SetDisplayRegion(tabRect, true);
// Editor maintains a list of tabsconst auto& tabs = editor.GetTabWindows();// Navigate between tabseditor.NextTabWindow();editor.PreviousTabWindow();// Set active tabeditor.SetCurrentTabWindow(pTab);// Get active tabZepTabWindow* pActiveTab = editor.GetActiveTabWindow();