# rinsdr/tvision architecture

> Architecture diagram of the GitHub repository rinsdr/tvision, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rinsdr/tvision
- Repository: https://github.com/rinsdr/tvision

## Overview

##### Main Components
- User Application / Demo Layer: These are the “example” applications (e.g. hello.cpp, tvdemo, tvedit, mmenu, palette, etc.) that use the Turbo Vision library.
- Core UI Framework: This includes the library’s classes (the “tvision” classes such as TView, TApplication, TScreen, TDrawBuffer) found in source/tvision and the corresponding headers in include/tvision.
- Platform Abstraction Layer: Found in source/platform (files like ansidisp.cpp, terdisp.cpp, hardware.cpp, etc.), this layer isolates the OS–specific implementations—for instance using ncurses on Linux, Win32 Console API on Windows, and legacy support for Borland C++.
- Compatibility & Utility Code: Legacy support in include/tvision/compat (Borland C++ compatibility) and support modules such as palette, event handling (TKey, TEvent), and Unicode extensions.
- Build & Configuration: The CMakeLists.txt at the root (and within examples and source) along with project/makefile for Borland. Also include the GitHub workflows in .github/workflows that point to CI/CD.

- TApplication (event loop and application lifecycle)
- TView and derivative widgets (menus, dialogs, file viewers, etc.)
- TDrawBuffer & TScreen for drawing
- TKey, TEvent and related input handling modules
– Next, a “Platform Abstraction Layer” that shows the separation of OS–dependent implementations. Indicate that this layer is responsible for:
- Terminal I/O (using ncurses and Windows Console API)
- Event capturing and dispatching
- Low–level screen and input functions (as implemented in source/platform)
- Legacy Borland C++ compatibility (contents of include/tvision/compat)
- Additional modules like palette management and clipboard interaction.
– At the bottom or as a side block, include a “Build & Deployment” area that points to:
- The CMake build system (with CMakeLists.txt files in the root and subdirectories)
- The project/makefile for Borland
- CI/CD scripts from .github/workflows

##### Architectural Patterns and Key Design Principles
– Highlight the modular, layered design that cleanly separates UI logic from platform code (following a kind of “platform abstraction” pattern).
- Application-level code (e.g. demos, sample apps)
- Core framework components (e.g. TView, TApplication)
- Platform–specific implementations (system I/O, terminal handling)
- Build/CI components (scripts, makefiles, project directories)

##### Final Advice to the Principal Software Engineer
– Start by listing every main folder in a draft; map them to their runtime responsibilities. For example, note that “source/platform” implements the abstracted I/O while “source/tvision” holds the widget and UI core.
– Then, sketch the layers beginning with the demo applications at the top, linking into the core Turbo Vision library.
– Don’t forget to indicate the build channels (modern CMake builds plus legacy Borland-based makefiles).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Applications / Demos Layer
    subgraph "UI Applications / Demos"
        hello("hello (demo)"):::ui
        tvdemo("tvdemo"):::ui
        tvedit("tvedit"):::ui
        mmenu("mmenu"):::ui
        palette("palette"):::ui
        tvdir("tvdir"):::ui
        tvforms("tvforms"):::ui
        tvhc("tvhc"):::ui
    end

    %% Turbo Vision Core Library Layer
    subgraph "Turbo Vision Core Library"
        headers("Headers (tvision)"):::core
        impl("Implementation (tvision)"):::core
        app("TApplication (Event Loop)"):::core
        view("TView (Widget Base Class)"):::core
        render("TDrawBuffer & TScreen (Rendering Engine)"):::core
        input("TKey & TEvent (Input Handling)"):::core
        extended("Unicode & Extended Color Module"):::extended
    end

    %% Platform Abstraction Layer
    subgraph "Platform Abstraction Layer"
        platform("Platform Abstraction (source/platform)"):::platform
    end

    %% Compatibility & Utility Code
    subgraph "Compatibility & Utility Code"
        compat("Legacy Compatibility (Borland C++)"):::compat
        util("Utility Functions (tvision/util.h)"):::compat
    end

    %% Build & Deployment
    subgraph "Build & Deployment"
        cmake("CMake Build System"):::build
        makefile("Borland Makefile"):::build
        workflows("CI/CD (GitHub Workflows)"):::build
    end

    %% Relationships
    %% UI Applications call into the Turbo Vision Core Library
    hello -->|"calls"| app
    tvdemo -->|"calls"| app
    tvedit -->|"calls"| app
    mmenu -->|"calls"| app
    palette -->|"calls"| app
    tvdir -->|"calls"| app
    tvforms -->|"calls"| app
    tvhc -->|"calls"| app

    %% Core library interactions
    headers --> app
    impl --> app
    app -->|"delegates"| platform
    render -->|"rendersVia"| platform
    view -->|"integratesWith"| compat
    input -->|"utilizes"| util

    %% Build system connections (bidirectional linking to core)
    cmake --- app
    makefile --- app
    workflows --- app

    %% Click Events for UI Applications / Demo Layer
    click hello "https://github.com/rinsdr/tvision/blob/master/hello.cpp"
    click tvdemo "https://github.com/rinsdr/tvision/tree/master/examples/tvdemo"
    click tvedit "https://github.com/rinsdr/tvision/tree/master/examples/tvedit"
    click mmenu "https://github.com/rinsdr/tvision/tree/master/examples/mmenu"
    click palette "https://github.com/rinsdr/tvision/tree/master/examples/palette"
    click tvdir "https://github.com/rinsdr/tvision/tree/master/examples/tvdir"
    click tvforms "https://github.com/rinsdr/tvision/tree/master/examples/tvforms"
    click tvhc "https://github.com/rinsdr/tvision/tree/master/examples/tvhc"

    %% Click Events for Core UI Framework
    click headers "https://github.com/rinsdr/tvision/tree/master/include/tvision"
    click impl "https://github.com/rinsdr/tvision/tree/master/source/tvision"

    %% Click Event for Platform Abstraction Layer
    click platform "https://github.com/rinsdr/tvision/tree/master/source/platform"

    %% Click Events for Compatibility & Utility Code
    click compat "https://github.com/rinsdr/tvision/tree/master/include/tvision/compat"
    click util "https://github.com/rinsdr/tvision/blob/master/include/tvision/util.h"

    %% Click Events for Build & Deployment
    click cmake "https://github.com/rinsdr/tvision/blob/master/CMakeLists.txt"
    click makefile "https://github.com/rinsdr/tvision/tree/master/project/makefile"
    click workflows "https://github.com/rinsdr/tvision/tree/master/.github/workflows"

    %% Styles
    classDef ui fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef core fill:#aed6f1,stroke:#333,stroke-width:2px;
    classDef extended fill:#f7dc6f,stroke:#333,stroke-width:2px;
    classDef platform fill:#a9dfbf,stroke:#333,stroke-width:2px;
    classDef compat fill:#f5b7b1,stroke:#333,stroke-width:2px;
    classDef build fill:#d7bde2,stroke:#333,stroke-width:2px;
```
