Skip to main content

Overview

The ZepWindow class represents a single pane displaying a buffer. It manages the visual presentation of text, including cursor positioning, scrolling, line layout, syntax highlighting display, and user interactions like mouse events. Multiple windows can display the same buffer with independent cursor positions and scroll states.

Constructor

ZepWindow

ZepWindow(ZepTabWindow& window, ZepBuffer* buffer);
window
ZepTabWindow&
required
Parent tab window that contains this window
buffer
ZepBuffer*
required
Buffer to display in this window
Create a new window displaying the specified buffer.

Display Management

Display

virtual void Display();
Render the window content, including text, cursor, line numbers, scrollbars, and markers.

SetDisplayRegion

virtual void SetDisplayRegion(const NRectf& region);
region
const NRectf&
required
Rectangle defining the window’s display area
Set the screen region where this window should be displayed.

Buffer Management

GetBuffer

virtual ZepBuffer& GetBuffer() const;
Get the buffer displayed in this window.

SetBuffer

virtual void SetBuffer(ZepBuffer* pBuffer);
pBuffer
ZepBuffer*
required
New buffer to display
Change the buffer displayed in this window.

Cursor Management

GetBufferCursor

virtual GlyphIterator GetBufferCursor();
Get the current cursor position in buffer coordinates.

SetBufferCursor

virtual void SetBufferCursor(GlyphIterator location);
location
GlyphIterator
required
New cursor position in the buffer
Set the cursor to a specific buffer location. The window will scroll to make the cursor visible.

MoveCursorY

virtual void MoveCursorY(int yDistance, LineLocation clampLocation = LineLocation::LineLastNonCR);
yDistance
int
required
Number of lines to move (positive = down, negative = up)
clampLocation
LineLocation
Where to clamp cursor horizontally when moving between lines (default: LineLastNonCR)
Move the cursor vertically by the specified number of lines.

BufferToDisplay

virtual NVec2i BufferToDisplay();
Convert the current buffer cursor position to display coordinates. Returns the (x, y) position on screen.

Window Flags

SetWindowFlags

virtual void SetWindowFlags(uint32_t windowFlags);
windowFlags
uint32_t
required
Flags from WindowFlags enum:
  • None (0): No special flags
  • ShowWhiteSpace (1 << 0): Show whitespace characters
  • ShowCR (1 << 1): Show carriage return characters
  • ShowLineNumbers (1 << 2): Display line numbers
  • ShowIndicators (1 << 3): Show indicator column
  • HideScrollBar (1 << 4): Hide the scrollbar
  • Modal (1 << 5): Window is modal
  • WrapText (1 << 6): Enable text wrapping (experimental)
  • HideSplitMark (1 << 7): Hide split window marker
  • GridStyle (1 << 8): Use grid-style display
Set window display flags.

GetWindowFlags

virtual uint32_t GetWindowFlags() const;
Get the current window flags.

ToggleFlag

virtual void ToggleFlag(uint32_t flag);
flag
uint32_t
required
Flag to toggle
Toggle a specific window flag on or off.

Display Information

GetMaxDisplayLines

virtual long GetMaxDisplayLines();
Get the maximum number of lines that can be displayed in the window viewport.

GetNumDisplayedLines

virtual long GetNumDisplayedLines();
Get the actual number of lines currently being displayed.

Parent Tab Window

GetTabWindow

ZepTabWindow& GetTabWindow() const;
Get the parent tab window that contains this window.

Color and Theme

FilterActiveColor

NVec4f FilterActiveColor(const NVec4f& col, float atten = 1.0f);
col
const NVec4f&
required
Original RGBA color
atten
float
Attenuation factor (default: 1.0)
Filter a color based on whether this window is active. Inactive windows have dimmed colors.

Layout Management

DirtyLayout

void DirtyLayout();
Mark the window layout as needing recalculation. Call this when buffer content changes or window size changes.

Window Regions

The window is divided into several internal regions:

Cursor Types

Windows support different cursor display modes:
enum class CursorType
{
    None,        // No cursor displayed
    Normal,      // Normal mode cursor (block)
    Insert,      // Insert mode cursor (line)
    Visual,      // Visual mode cursor (selection)
    LineMarker   // Line marker cursor
};

Span Information

The window calculates SpanInfo structures for each displayed line:

Airline Status Bar

Windows can display an “airline” status bar showing buffer information:
struct Airline
{
    std::vector<AirBox> leftBoxes;  // Left-aligned status boxes
    std::vector<AirBox> rightBoxes; // Right-aligned status boxes
};

struct AirBox
{
    std::string text;       // Box text content
    NVec4f background;      // Box background color
};

Tool Tips

Windows support displaying tooltips for markers (errors, warnings, etc.):
struct ToolTipMessage : public ZepMessage
{
    ZepBuffer* pBuffer;         // Buffer containing the marker
    GlyphIterator location;     // Location in buffer
    std::shared_ptr<RangeMarker> spMarker; // The marker to display
};

Usage Example

#include <zep/window.h>
#include <zep/tab_window.h>
#include <zep/buffer.h>

// Create tab window and buffer
ZepTabWindow* pTabWindow = editor.AddTabWindow();
ZepBuffer* pBuffer = editor.GetFileBuffer("main.cpp");

// Create window
ZepWindow window(*pTabWindow, pBuffer);

// Configure window
window.SetWindowFlags(WindowFlags::ShowLineNumbers | 
                      WindowFlags::ShowIndicators |
                      WindowFlags::ShowWhiteSpace);

// Set display region
NRectf region(0, 0, 800, 600);
window.SetDisplayRegion(region);

// Set cursor position
GlyphIterator pos = pBuffer->Begin();
window.SetBufferCursor(pos);

// Move cursor down 10 lines
window.MoveCursorY(10);

// Display the window
window.Display();

// Check if window is active
if (editor.GetActiveWindow() == &window)
{
    // This window is active
}

// Toggle line numbers
window.ToggleFlag(WindowFlags::ShowLineNumbers);

Display Passes

The window renders in multiple passes:
  1. Background pass: Line backgrounds, selections, cursor line
  2. Text pass: Actual text with syntax highlighting
  3. Decoration pass: Whitespace indicators, special characters
  4. Overlay pass: Scrollbars, line numbers, markers
  5. Tooltip pass: Hover tooltips for errors/warnings

Performance Considerations

Build docs developers (and LLMs) love