|
Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
|
Русская версия · Task guides · Documentation contents · Glossary
Widget gallery — previews, examples and control guides. Portals is a C++23 terminal UI library under development. The declarative ui API is the primary way to build an interface. This page is the short reading guide; the documentation contents contains the complete topic list and API reading paths.
These Markdown guides describe the current source branch. The published HTML help follows the latest stable release; PR checks also provide an HTML preview artifact.
The first application tutorial develops a quick-note form in four steps, from a runnable editor to a styled form with save and clear actions.
<portals/ui.hpp> provides scenes, recipes and event handlers. <portals/ui_style.hpp> adds the style operations used in this example.
The example describes a control tree and attaches style and event handlers with UI stages, which represent operations after each |. Here, ui::vbox(...) creates a recipe: a description of the controls to construct. ui::scene(...) stores that recipe in a scene, which manages preparation and running. The button appends text to the editor, and F10 requests an orderly exit.
The runner attempts terminal cleanup and reports failures. This compact form constructs the recipe before runApp; use the factory-based overload when construction also needs its checked error boundary. The exit command resolves the active scene inside a callback entered by the scene. An explicit SceneRef remains available when an action must target a named scene. Declarative composition explains callbacks, setup errors and the lower-level typed run() result.
For a local application, the complete example above can be saved as main.cpp in a directory named my-app; the following configuration belongs in CMakeLists.txt in the same directory:
From my-app, these commands configure the build, download the selected Portals revision and build the my_app executable:
On Windows, the build environment is an x64 Developer PowerShell for Visual Studio. On Linux, a compatible C++ compiler and standard library are required. The build uses Git, CMake 3.24+, Ninja and a toolchain supporting C99 and C++23, including the C++ library headers <expected> and <format>.
When my_app runs in a terminal, Add Hello appends text and F10 exits. On Windows the executable is build/my_app.exe; on Linux it is build/my_app. The commands above use the Ninja single-configuration generator.
GIT_TAG fixes the source revision for this example. When choosing a newer Portals version, this value can be updated. FetchContent integration is described in the CMake documentation.
When Portals sources are already in a portals subdirectory of the project, include(FetchContent) and both FetchContent_* calls can be replaced with add_subdirectory(portals). This uses the local sources without a download.
For an installed SDK, the same lines can be replaced with find_package(Portals CONFIG REQUIRED); its installation prefix goes in CMAKE_PREFIX_PATH during configuration. Every option uses target_link_libraries(my_app PRIVATE portals::core). See package setup for installation and toolchain compatibility.
These APIs are evolving. Limitations lists qualified platforms and the exact runtime boundaries.
Runnable examples link to guides with complete source programs. Release notes record changes by version.
Dependencies and licenses are listed separately.
Fine scene settings contains expandable examples of ownership budgets and input settings.