// Get or create a tab windowZepTabWindow* pTabWindow = editor.GetActiveTabWindow();// Create a new window for a bufferZepBuffer* pBuffer = editor.GetFileBuffer("myfile.cpp");ZepWindow* pWindow = pTabWindow->AddWindow(pBuffer);// Set as the active windowpTabWindow->SetActiveWindow(pWindow);
// Create a new tab windowZepTabWindow* pTabWindow = new ZepTabWindow(editor);// Set the display region for the entire tabNRectf tabRegion(0, 0, 1024, 768);pTabWindow->SetDisplayRegion(tabRegion);// Display all windows in the tabpTabWindow->Display();
// Get the currently active windowZepWindow* pActive = pTabWindow->GetActiveWindow();// Switch to a different windowpTabWindow->SetActiveWindow(pWindow);// Close the active windowpTabWindow->CloseActiveWindow();
Customize window appearance and behavior with flags:
// Get current flagsuint32_t flags = pWindow->GetWindowFlags();// Modify flagsflags |= WindowFlags::ShowLineNumbers;flags |= WindowFlags::ShowIndicators;flags &= ~WindowFlags::HideScrollBar;// Apply new flagspWindow->SetWindowFlags(flags);// Or toggle a single flagpWindow->ToggleFlag(WindowFlags::ShowWhiteSpace);
// Change which buffer a window displaysZepBuffer* pNewBuffer = editor.GetFileBuffer("other.cpp");pWindow->SetBuffer(pNewBuffer);// Get the current bufferZepBuffer& buffer = pWindow->GetBuffer();
Every window must always have an active buffer. Never set a null buffer.
// Create two windows viewing the same bufferZepBuffer* pBuffer = editor.GetFileBuffer("shared.cpp");ZepWindow* pWindow1 = pTabWindow->AddWindow(pBuffer);ZepWindow* pWindow2 = pTabWindow->AddWindow( pBuffer, pWindow1, RegionLayoutType::HBox);// Each window has independent cursor positionpWindow1->SetBufferCursor(buffer.Begin());pWindow2->SetBufferCursor(buffer.End());
// Convert buffer position to display coordinatesNVec2i displayPos = pWindow->BufferToDisplay();// The coordinates are relative to the window's text regionfloat screenX = displayPos.x;float screenY = displayPos.y;
// Get maximum number of lines that can be displayedlong maxLines = pWindow->GetMaxDisplayLines();// Get actual number of displayed lineslong numDisplayed = pWindow->GetNumDisplayedLines();