{"id":13645120,"url":"https://github.com/magiblot/tvision","last_synced_at":"2025-05-14T06:12:36.130Z","repository":{"id":39222983,"uuid":"184303095","full_name":"magiblot/tvision","owner":"magiblot","description":"A modern port of Turbo Vision 2.0, the classical framework for text-based user interfaces. Now cross-platform and with Unicode support.","archived":false,"fork":false,"pushed_at":"2025-03-30T20:28:59.000Z","size":8649,"stargazers_count":2168,"open_issues_count":29,"forks_count":166,"subscribers_count":59,"default_branch":"master","last_synced_at":"2025-04-11T02:51:25.167Z","etag":null,"topics":["ascii","borland","borland-cpp","cpp","cpp14","cross-platform","linux","linux-console","ms-dos","msvc","ncurses","retrocomputing","retroprogramming","terminal","text-based","tui","turbo-vision","utf-8","utf8-everywhere","windows"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magiblot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-04-30T17:21:02.000Z","updated_at":"2025-04-10T04:44:03.000Z","dependencies_parsed_at":"2023-10-03T13:20:58.961Z","dependency_job_id":"ca4be666-c4d0-4420-9c21-bf51219065bd","html_url":"https://github.com/magiblot/tvision","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiblot%2Ftvision","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiblot%2Ftvision/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiblot%2Ftvision/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiblot%2Ftvision/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magiblot","download_url":"https://codeload.github.com/magiblot/tvision/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254080574,"owners_count":22011445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ascii","borland","borland-cpp","cpp","cpp14","cross-platform","linux","linux-console","ms-dos","msvc","ncurses","retrocomputing","retroprogramming","terminal","text-based","tui","turbo-vision","utf-8","utf8-everywhere","windows"],"created_at":"2024-08-02T01:02:27.962Z","updated_at":"2025-05-14T06:12:36.068Z","avatar_url":"https://github.com/magiblot.png","language":"C++","funding_links":[],"categories":["C++","Table of Contents"],"sub_categories":[],"readme":"# Turbo Vision\n\nA modern port of Turbo Vision 2.0, the classical framework for text-based user interfaces. Now cross-platform and with Unicode support.\n\n![tvedit in Konsole](https://user-images.githubusercontent.com/20713561/81506401-4fffdd80-92f6-11ea-8826-ee42612eb82a.png)\n\nI started this as a personal project at the very end of 2018. By May 2020 I considered it was very close to feature parity with the original, and decided to make it open.\n\nThe original goals of this project were:\n\n* Making Turbo Vision work on Linux by altering the legacy codebase as little as possible.\n* Keeping it functional on DOS/Windows.\n* Being as compatible as possible at the source code level with old Turbo Vision applications. This led me to implement some of the Borland C++ RTL functions, as explained below.\n\nAt one point I considered I had done enough, and that any attempts at revamping the library and overcoming its original limitations would require either extending the API or breaking backward compatibility, and that a major rewrite would be most likely necessary.\n\nHowever, between July and August 2020 I found the way to integrate full-fledged Unicode support into the existing architecture, wrote the [Turbo](https://github.com/magiblot/turbo) text editor and also made the new features available on Windows. So I am confident that Turbo Vision can now meet many of the expectations of modern users and programmers.\n\nThe original location of this project is https://github.com/magiblot/tvision.\n\n# Table of contents\n\n* [What is Turbo Vision good for?](#what-for)\n* [How do I use Turbo Vision?](#how-to)\n* [Releases and downloads](#downloads)\n* Build environment\n    * [Linux](#build-linux)\n    * [Windows (MSVC)](#build-msvc)\n    * [Windows (MinGW)](#build-mingw)\n    * [Windows/DOS (Borland C++)](#build-borland)\n    * [Vcpkg](#build-vcpkg)\n    * [Turbo Vision as a CMake dependency](#build-cmake)\n* [Features](#features)\n* [API changes](#apichanges)\n* [Applications using Turbo Vision](#applications)\n* [Unicode support](#unicode)\n* [Clipboard interaction](#clipboard)\n* [Extended color support](#color)\n\n\u003cdiv id=\"what-for\"\u003e\u003c/div\u003e\n\n## What is Turbo Vision good for?\n\nA lot has changed since Borland created Turbo Vision in the early 90's. Many GUI tools today separate appearance specification from behaviour specification, use safer or dynamic languages which do not segfault on error, and support either parallel or asynchronous programming, or both.\n\nTurbo Vision does not excel at any of those, but it certainly overcomes many of the issues programmers still face today when writing terminal applications:\n\n1. Forget about terminal capabilities and direct terminal I/O. When writing a Turbo Vision application, all you have to care about is what you want your application to behave and look like—there is no need to add workarounds in your code. Turbo Vision tries its best to produce the same results on all environments. For example: in order to get a bright background color on the Linux console, the *blink* attribute has to be set. Turbo Vision does this for you.\n\n2. Reuse what has already been done. Turbo Vision provides many widget classes (also known as *views*), including resizable, overlapping windows, pull-down menus, dialog boxes, buttons, scroll bars, input boxes, check boxes and radio buttons. You may use and extend these; but even if you prefer creating your own, Turbo Vision already handles event dispatching, display of fullwidth Unicode characters, etc.: you do not need to waste time rewriting any of that.\n\n3. Can you imagine writing a text-based interface that works both on Linux and Windows (and thus is cross-platform) out-of-the-box, with no `#ifdef`s? Turbo Vision makes this possible. First: Turbo Vision keeps on using `char` arrays instead of relying on the implementation-defined and platform-dependent `wchar_t` or `TCHAR`. Second: thanks to UTF-8 support in `setlocale` in [recent versions of Microsoft's RTL](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale#utf-8-support), code like the following will work as intended:\n    ```c++\n    std::ifstream f(\"コンピュータ.txt\"); // On Windows, the RTL converts this to the system encoding on-the-fly.\n    ```\n\n\u003cdiv id=\"how-to\"\u003e\u003c/div\u003e\n\n## How do I use Turbo Vision?\n\nYou can get started with the [Turbo Vision For C++ User's Guide](https://archive.org/details/BorlandTurboVisionForCUserSGuide/mode/1up), and look at the sample applications [`hello`](https://github.com/magiblot/tvision/blob/master/hello.cpp), [`tvdemo`](https://github.com/magiblot/tvision/tree/master/examples/tvdemo) and [`tvedit`](https://github.com/magiblot/tvision/tree/master/examples/tvedit). Once you grasp the basics,\nI suggest you take a look at the [Turbo Vision 2.0 Programming Guide](https://archive.org/details/bitsavers_borlandTurrogrammingGuide1992_25707423), which is, in my opinion, more intuitive and easier to understand, despite using Pascal. By then you will probably be interested in the [`palette`](https://github.com/magiblot/tvision/tree/master/examples/palette) example, which contains a detailed description of how palettes are used.\n\nDon't forget to check out the \u003ca href=\"#features\"\u003efeatures\u003c/a\u003e and \u003ca href=\"#apichanges\"\u003eAPI changes\u003c/a\u003e sections as well.\n\n\u003cdiv id=\"downloads\"\u003e\u003c/div\u003e\n\n## Releases and downloads\n\nThis project has no stable releases for the time being. If you are a developer, try to stick to the latest commit and report any issues you find while upgrading.\n\nIf you just want to test the demo applications:\n\n* Unix systems: you'll have to build Turbo Vision yourself. You may follow the [build instructions](#build-linux) below.\n* Windows: you can find up-to-date binaries in the [Actions](https://github.com/magiblot/tvision/actions?query=branch:master+event:push) section. Click on the first successful workflow (with a green tick) in the list. At the bottom of the workflow page, as long as you have logged in to GitHub, you'll find an *Artifacts* section with the following files:\n    * `examples-dos32.zip`: 32-bit executables built with Borland C++. No Unicode support.\n    * `examples-x86.zip`: 32-bit executables built with MSVC. Windows Vista or later required.\n    * `examples-x64.zip`: 64-bit executables built with MSVC. x64 Windows Vista or later required.\n\n## Build environment\n\n\u003cdiv id=\"build-linux\"\u003e\u003c/div\u003e\n\n### Linux\n\nTurbo Vision can be built as an static library with CMake and GCC/Clang.\n\n```sh\ncmake . -B ./build -DCMAKE_BUILD_TYPE=Release \u0026\u0026 # Could also be 'Debug', 'MinSizeRel' or 'RelWithDebInfo'.\ncmake --build ./build # or `cd ./build; make`\n```\n\nCMake versions older than 3.13 may not support the `-B` option. You can try the following instead:\n\n```sh\nmkdir -p build; cd build\ncmake .. -DCMAKE_BUILD_TYPE=Release \u0026\u0026\ncmake --build .\n```\n\nThe above produces the following files:\n\n* `libtvision.a`, which is the Turbo Vision library.\n* The demo applications `hello`, `tvdemo`, `tvedit`, `tvdir`, which were bundled with the original Turbo Vision (although some of them have a few improvements).\n* The demo applications `mmenu` and `palette` from Borland's Technical Support.\n* `tvhc`, the Turbo Vision Help Compiler.\n\nThe library and executables can be found in `./build`.\n\nThe build requirements are:\n\n* A compiler supporting C++14.\n* `libncursesw` (note the 'w').\n* `libgpm` for mouse support on the Linux console (optional).\n\nIf your distribution provides separate *devel* packages (e.g. `libncurses-dev`, `libgpm-dev` in Debian-based distros), install these too.\n\n\u003cdiv id=\"build-linux-runtime\"\u003e\u003c/div\u003e\n\nThe runtime requirements are:\n\n* `xsel` or `xclip` for clipboard support in X11 environments.\n* `wl-clipboard` for clipboard support in Wayland environments.\n\nThe minimal command line required to build a Turbo Vision application (e.g. `hello.cpp` with GCC) from this project's root is:\n\n```sh\ng++ -std=c++14 -o hello hello.cpp ./build/libtvision.a -Iinclude -lncursesw -lgpm\n```\n\nYou may also need:\n\n* `-Iinclude/tvision` if your application uses Turbo Vision 1.x includes (`#include \u003ctv.h\u003e` instead of `#include \u003ctvision/tv.h\u003e`).\n\n* `-Iinclude/tvision/compat/borland` if your application includes Borland headers (`dir.h`, `iostream.h`, etc.).\n\n* On Gentoo (and possibly others): `-ltinfow` if both `libtinfo.so` and `libtinfow.so` are available in your system. Otherwise, you may get a segmentation fault when running Turbo Vision applications ([#11](https://github.com/magiblot/tvision/issues/11)). Note that `tinfo` is bundled with `ncurses`.\n\n`-lgpm` is only necessary if Turbo Vision was built with `libgpm` support.\n\nThe backward-compatibility headers in `include/tvision/compat/borland` emulate the Borland C++ RTL. Turbo Vision's source code still depends on them, and they could be useful if porting old applications. This also means that including `tvision/tv.h` will bring several `std` names to the global namespace.\n\n\u003cdiv id=\"build-msvc\"\u003e\u003c/div\u003e\n\n### Windows (MSVC)\n\nThe build process with MSVC is slightly more complex, as there are more options to choose from. Note that you will need different build directories for different target architectures. For instance, to generate optimized binaries:\n\n```sh\ncmake . -B ./build \u0026\u0026 # Add '-A x64' (64-bit) or '-A Win32' (32-bit) to override the default platform.\ncmake --build ./build --config Release # Could also be 'Debug', 'MinSizeRel' or 'RelWithDebInfo'.\n```\n\nIn the example above, `tvision.lib` and the example applications will be placed at `./build/Release`.\n\nIf you wish to link Turbo Vision statically against Microsoft's run-time library (`/MT` instead of `/MD`), enable the `TV_USE_STATIC_RTL` option (`-DTV_USE_STATIC_RTL=ON` when calling `cmake`).\n\nIf you wish to link an application against Turbo Vision, note that MSVC won't allow you to mix `/MT` with `/MD` or debug with non-debug binaries. All components have to be linked against the RTL in the same way.\n\nIf you develop your own Turbo Vision application make sure to enable the following compiler flags, or else you will get compilation errors when including `\u003ctvision/tv.h\u003e`:\n\n```\n/permissive-\n/Zc:__cplusplus\n```\n\nIf you use [Turbo Vision as a CMake submodule](#build-cmake), these flags will be enabled automatically.\n\n**Note:** Turbo Vision uses `setlocale` to set the [RTL functions in UTF-8 mode](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale#utf-8-support). This won't work if you use an old version of the RTL.\n\nWith the RTL statically linked in, and if UTF-8 is supported in `setlocale`, Turbo Vision applications are portable and work by default on **Windows Vista and later**.\n\n\u003cdiv id=\"build-mingw\"\u003e\u003c/div\u003e\n\n### Windows (MinGW)\n\nOnce your MinGW environment is properly set up, build is done in a similar way to Linux:\n```sh\ncmake . -B ./build -G \"MinGW Makefiles\" -DCMAKE_BUILD_TYPE=Release \u0026\u0026\ncmake --build ./build\n```\nIn the example above, `libtvision.a` and all examples are in `./build` if `TV_BUILD_EXAMPLES` option is `ON` (the default).\n\nIf you wish to link an application against Turbo Vision, simply add `-L./build/lib -ltvision` to your linker and `-I./include` to your compiler\n\n\u003cdiv id=\"build-borland\"\u003e\u003c/div\u003e\n\n### Windows/DOS (Borland C++)\n\nTurbo Vision can still be built either as a DOS or Windows library with Borland C++. Obviously, there is no Unicode support here.\n\nI can confirm the build process works with:\n\n* Borland C++ 4.52 with the Borland PowerPack for DOS.\n* Turbo Assembler 4.0.\n\nYou may face different problems depending on your build environment. For instance, Turbo Assembler needs a patch to work under Windows 95. On Windows XP everything seems to work fine. On Windows 10, MAKE may emit the error `Fatal: Command arguments too long`, which can be fixed by upgrading MAKE to the one bundled with Borland C++ 5.x.\n\nYes, this works on 64-bit Windows 10. What won't work is the Borland C++ installer, which is a 16-bit application. You will have to run it on another environment or try your luck with [winevdm](https://github.com/otya128/winevdm).\n\nA Borland Makefile can be found in the `project` directory. Build can be done by doing:\n\n```sh\ncd project\nmake.exe \u003coptions\u003e\n```\n\nWhere `\u003coptions\u003e` can be:\n\n* `-DDOS32` for 32-bit DPMI applications (which still work on 64-bit Windows).\n* `-DWIN32` for 32-bit native Win32 applications (not possible for TVDEMO, which relies on `farcoreleft()` and other antiquities).\n* `-DDEBUG` to build debug versions of the application and the library.\n* `-DTVDEBUG` to link the applications with the debug version of the library.\n* `-DOVERLAY`, `-DALIGNMENT={2,4}`, `-DEXCEPTION`, `-DNO_STREAMABLE`, `-DNOTASM` for things I have nave never used but appeared in the original makefiles.\n\nThis will compile the library into a `LIB` directory next to `project`, and will compile executables for the demo applications in their respective `examples/*` directories.\n\nI'm sorry, the root makefile assumes it is executed from the `project` directory. You can still run the original makefiles directly (in `source/tvision` and `examples/*`) if you want to use different settings.\n\n\u003cdiv id=\"build-vcpkg\"\u003e\u003c/div\u003e\n\n### Vcpkg\n\nTurbo Vision can be built and installed using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:\n\n```sh\ngit clone https://github.com/Microsoft/vcpkg.git\ncd vcpkg\n./bootstrap-vcpkg.sh\n./vcpkg integrate install\n./vcpkg install tvision\n```\n\nThe `tvision` port in vcpkg is kept up to date by Microsoft team members and community contributors. If you find it to be out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) in the vcpkg repository.\n\n\u003cdiv id=\"build-cmake\"\u003e\u003c/div\u003e\n\n### Turbo Vision as a CMake dependency (not Borland C++)\n\nIf you choose the CMake build system for your application, there are two main ways to link against Turbo Vision:\n\n* Installing Turbo Vision and importing it with `find_package`. Installation depends on the generator type:\n\n    * First, decide an install prefix. The default one will work out-of-the-box, but usually requires admin privileges. On Unix systems, you can use `$HOME/.local` instead. On Windows, you can use any custom path you want but you'll have to add it to the `CMAKE_PREFIX_PATH` environment variable when building your application.\n    * For mono-config generators (`Unix Makefiles`, `Ninja`...), you only have to build and install once:\n\n        ```sh\n        cmake . -B ./build # '-DCMAKE_INSTALL_PREFIX=...' to override the install prefix.\n        cmake --build ./build\n        cmake --install ./build\n        ```\n    * For multi-config generators (`Visual Studio`, `Ninja Multi-Config`...) you should build and install all configurations:\n\n        ```sh\n        cmake . -B ./build # '-DCMAKE_INSTALL_PREFIX=...' to override the install prefix.\n        cmake --build ./build --config Release\n        cmake --build ./build --config Debug --target tvision\n        cmake --build ./build --config RelWithDebInfo --target tvision\n        cmake --build ./build --config MinSizeRel --target tvision\n        cmake --install ./build --config Release\n        cmake --install ./build --config Debug --component library\n        cmake --install ./build --config RelWithDebInfo --component library\n        cmake --install ./build --config MinSizeRel --component library\n        ```\n    Then, in your application's `CMakeLists.txt`, you may import it like this:\n    ```cmake\n    find_package(tvision CONFIG)\n    target_link_libraries(my_application tvision::tvision)\n    ```\n\n* Have Turbo Vision in a submodule in your repository and import it with `add_subdirectory`:\n\n\n    ```cmake\n    add_subdirectory(tvision) # Assuming Turbo Vision is in the 'tvision' directory.\n    target_link_libraries(my_application tvision)\n    ```\n\nIn either case, `\u003ctvision/tv.h\u003e` will be available in your application's include path during compilation, and your application will be linked against the necessary libraries (Ncurses, GPM...) automatically.\n\n\u003cdiv id=\"features\"\u003e\u003c/div\u003e\n\n## Features\n\n### Modern platforms (not Borland C++)\n\n* UTF-8 support. You can try it out in the `tvedit` application.\n* 24-bit color support (up from the original 16 colors).\n* 'Open File' dialogs accepts both Unix and Windows-style file paths and can expand `~/` into `$HOME`.\n* Redirection of `stdin`/`stdout`/`stderr` does not interfere with terminal I/O.\n* Compatibility with 32-bit help files.\n\nThere are a few environment variables that affect the behaviour of all Turbo Vision applications:\n\n* `TVISION_MAX_FPS`: maximum refresh rate, default `60`. This can help keep smoothness in terminal emulators with unefficient handling of box-drawing characters. Special values for this option are `0`, to disable refresh rate limiting, and `-1`, to actually draw to the terminal in every call to `THardwareInfo::screenWrite` (useful when debugging).\n\n* `TVISION_CODEPAGE`: the character set used internally by Turbo Vision to translate *extended ASCII* into Unicode. Valid values at the moment are `437` and `850`, with `437` being the default, although adding more takes very little effort.\n\n### Unix\n\n* Ncurses-based terminal support.\n* Extensive mouse and keyboard support:\n    * Support for X10 and SGR mouse encodings.\n    * Support for Xterm's [*modifyOtherKeys*](https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys).\n    * Support for Paul Evans' [*fixterms*](http://www.leonerd.org.uk/hacks/fixterms/) and Kitty's [keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/).\n    * Support for Conpty's [`win32-input-mode`](https://github.com/microsoft/terminal/blob/37b0cfd32ba0aa54e0fe50bb158154d906472a89/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md) (available in WSL).\n    * Support for [far2l](https://github.com/elfmz/far2l)'s terminal extensions.\n    * Support for key modifiers (via `TIOCLINUX`) and mouse (via GPM) in the Linux console.\n* Custom signal handler that restores the terminal state before the program crashes.\n* When `stderr` is a tty, messages written to it are redirected to a buffer to prevent them from messing up the display and are eventually printed to the console when exiting or suspending the application.\n    * The buffer used for this purpose has a limited size, so writes to `stderr` will fail once the buffer is full. If you wish to preserve all of `stderr`, just redirect it into a file from the command line with `2\u003e`.\n\nThe following environment variables are also taken into account:\n\n* `TERM`: Ncurses uses it to determine terminal capabilities. It is set automatically by the terminal emulator.\n* `COLORTERM`: when set to `truecolor` or `24bit`, Turbo Vision will assume the terminal emulator supports 24-bit color. It is set automatically by terminal emulators that support it.\n* `ESCDELAY`: the number of milliseconds to wait after receiving an ESC key press, default `10`. If another key is pressed during this delay, it will be interpreted as an Alt+Key combination. Using a larger value is useful when the terminal doesn't support the Alt key.\n* `TVISION_USE_STDIO`: when not empty, terminal I/O is performed through `stdin`/`stdout`, so that it can be redirected from the shell. By default, Turbo Vision performs terminal I/O through `/dev/tty`, allowing the user to redirect `stdin`, `stdout` and `stderr` for their needs, without affecting the application's stability.\n\n    For example, the following will leave `out.txt` empty:\n\n    ```sh\n    tvdemo | tee out.txt\n    ```\n\n    While the following will dump all the escape sequences and text printed by the application into `out.txt`:\n\n    ```sh\n    TVISION_USE_STDIO=1 tvdemo | tee out.txt\n    ```\n\n### Windows\n\n* Only compatible with the Win32 Console API. On terminal emulators that don't support this, Turbo Vision will automatically pop up a separate console window.\n* Applications fit the console window size instead of the buffer size (no scrollbars are visible) and the console buffer is restored when exiting or suspending Turbo Vision.\n\nThe following are not available when compiling with Borland C++:\n\n* The console's codepage is set to UTF-8 on startup and restored on exit.\n* Microsoft's C runtime functions are set automatically to UTF-8 mode, so you as a developer don't need to use the `wchar_t` variants.\n* If the console crashes, a new one is allocated automatically.\n\n**Note:** Turbo Vision writes UTF-8 text directly to the Windows console. If the console is set in legacy mode and the bitmap font is being used, Unicode characters will not be displayed properly ([photo](https://user-images.githubusercontent.com/20713561/91917174-7a1f4600-ecbf-11ea-8c7a-2ec80d31d2ca.png)). To avoid this, Turbo Vision detects this situation and tries to change the console font to `Consolas` or `Lucida Console`.\n\n### All platforms\n\nThe following are new features not available in Borland's release of Turbo Vision or in previous open source ports (Sigala, SET):\n\n* Middle mouse button and mouse wheel support.\n* Arbitrary screen size support (up to 32767 rows or columns) and graceful handling of screen resize events.\n* Windows can be resized from their bottom left corner.\n* Windows can be dragged from empty areas with the middle mouse button.\n* Improved usability of menus: they can be closed by clicking again on the parent menu item.\n* Improved usability of scrollbars: dragging them also scrolls the page. Clicking on an empty area of the scrollbar moves the thumb right under the cursor. They respond by default to mouse wheel events.\n* `TInputLine`s no longer scroll the text display on focus/unfocus, allowing relevant text to stay visible.\n* Support for LF line endings in `TFileViewer` (`tvdemo`) and `TEditor` (`tvedit`). `TEditor` preserves the line ending on file save but all newly created files use CRLF by default.\n* `TEditor`: context menu on right click.\n* `TEditor`: drag scroll with middle mouse button.\n* `TEditor`, `TInputLine`: delete whole words with `kbAltBack`, `kbCtrlBack` and `kbCtrlDel`.\n* `TEditor`: the Home key toggles between beginning of line and beginning of indented text.\n* `TEditor`: support for files bigger than 64 KiB on 32-bit or 64-bit builds.\n* `tvdemo`: event viewer applet useful for event debugging.\n* `tvdemo`: option to change the background pattern.\n\n\u003cdiv id=\"apichanges\"\u003e\u003c/div\u003e\n\n## API changes\n\n* Screen writes are buffered and are usually sent to the terminal once for every iteration of the active event loop (see also `TVISION_MAX_FPS`). If you need to update the screen during a busy loop, you may use `TScreen::flushScreen()`.\n* `TDrawBuffer` is no longer a fixed-length array and its methods prevent past-the-end array accesses. Therefore, old code containing comparisons against `sizeof(TDrawBuffer)/sizeof(ushort)` is no longer valid; such checks should be removed.\n* `TApplication` now provides `dosShell()`, `cascade()` and `tile()`, and handles `cmDosShell`, `cmCascade` and `cmTile` by default. These functions can be customized by overriding `getTileRect()` and `writeShellMsg()`. This is the same behaviour as in the Pascal version.\n* Mouse wheel support: new mouse event `evMouseWheel`. The wheel direction is specified in the new field `event.mouse.wheel`, whose possible values are `mwUp`, `mwDown`, `mwLeft` or `mwRight`.\n* Middle mouse button support: new mouse button flag `mbMiddleButton`.\n* The `buttons` field in `evMouseUp` events is no longer empty. It now indicates which button was released.\n* Triple-click support: new mouse event flag `meTripleClick`.\n* `TRect` methods `move`, `grow`, `intersect` and `Union` now return `TRect\u0026` instead of being `void` so that they can be chained.\n* `TOutlineViewer` now allows the root node to have siblings.\n* New function `ushort popupMenu(TPoint where, TMenuItem \u0026aMenu, TGroup *receiver=0)` which spawns a `TMenuPopup` on the desktop. See `source/tvision/popupmnu.cpp`.\n* New virtual method `TMenuItem\u0026 TEditor::initContextMenu(TPoint p)` that determines the entries of the right-click context menu in `TEditor`.\n* `fexpand` can now take a second parameter `relativeTo`.\n* New class `TStringView`, inspired by `std::string_view`.\n    * Many functions which originally had null-terminated string parameters now receive `TStringView` instead. `TStringView` is compatible with `std::string_view`, `std::string` and `const char *` (even `nullptr`).\n* New class `TSpan\u003cT\u003e`, inspired by `std::span`.\n* New classes `TDrawSurface` and `TSurfaceView`, see `\u003ctvision/surface.h\u003e`.\n* The system integration subsystems (`THardwareInfo`, `TScreen`, `TEventQueue`...) are now initialized when constructing a `TApplication` for the first time, rather than before `main`. They are still destroyed on exit from `main`.\n* New method `TVMemMgr::reallocateDiscardable()` which can be used along `allocateDiscardable` and `freeDiscardable`.\n* New method `TView::textEvent()` which allows receiving text in an efficient manner, see [Clipboard interaction](#clipboard).\n* New class `TClipboard`, see [Clipboard interaction](#clipboard).\n* Unicode support, see [Unicode](#unicode).\n* True Color support, see [extended colors](#color).\n* New method `static void TEventQueue::waitForEvents(int timeoutMs)` which may block for up to `timeoutMs` milliseconds waiting for input events. A negative `timeoutMs` can be used to wait undefinitely. If it blocks, it has the side effect of flushing screen updates (via `TScreen::flushScreen()`). It is invoked by `TProgram::getEvent()` with `static int TProgram::eventTimeoutMs` (default `20`) as argument so that the event loop does not turn into a busy loop consuming 100% CPU.\n* New method `static void TEventQueue::wakeUp()` which causes the event loop to resume execution if it is blocked at `TEventQueue::waitForEvents()`. This method is thread-safe, since its purpose is to unblock the event loop from secondary threads.\n* New method `void TView::getEvent(TEvent \u0026, int timeoutMs)` which allows waiting for an event with an user-provided timeout (instead of `TProgram::eventTimeoutMs`).\n* It is now possible to specify a maximum text width or maximum character count in `TInputLine`. This is done through a new parameter in `TInputLine`'s constructor, `ushort limitMode`, which controls how the second constructor parameter, `uint limit`, is to be treated. The `ilXXXX` constants define the possible values of `limitMode`:\n    * `ilMaxBytes` (the default): the text can be up to `limit` bytes long, including the null terminator.\n    * `ilMaxWidth`: the text can be up to `limit` columns wide.\n    * `ilMaxChars`: the text can contain up to `limit` non-combining characters or graphemes.\n* New functions which allow getting the names of Turbo Vision's constants at runtime (e.g. `evCommand`, `kbShiftIns`, etc.):\n    ```c++\n    void printKeyCode(ostream \u0026, ushort keyCode);\n    void printControlKeyState(ostream \u0026, ushort controlKeyState);\n    void printEventCode(ostream \u0026, ushort eventCode);\n    void printMouseButtonState(ostream \u0026, ushort buttonState);\n    void printMouseWheelState(ostream \u0026, ushort wheelState);\n    void printMouseEventFlags(ostream \u0026, ushort eventFlags);\n    ```\n* New class `TKey` which can be used to define new key combinations (e.g. `Shift+Alt+Up`) by specifying a key code and a mask of key modifiers:\n    ```c++\n    auto kbShiftAltUp = TKey(kbUp, kbShift | kbAltShift);\n    assert(kbCtrlA == TKey('A', kbCtrlShift));\n    assert(TKey(kbCtrlTab, kbShift) == TKey(kbTab, kbShift | kbCtrlShift));\n    // Create menu hotkeys.\n    new TMenuItem(\"~R~estart\", cmRestart, TKey(kbDel, kbCtrlShift | kbAltShift), hcNoContext, \"Ctrl-Alt-Del\")\n    // Examine KeyDown events:\n    if (event.keyDown == TKey(kbEnter, kbShift))\n        doStuff();\n    ```\n* New methods which allow using timed events:\n    ```c++\n    TTimerId TView::setTimer(uint timeoutMs, int periodMs = -1);\n    void TView::killTimer(TTimerId id);\n    ```\n    `setTimer` starts a timer that will first time out in `timeoutMs` milliseconds and then every `periodMs` milliseconds.\n\n    If `periodMs` is negative, the timer only times out a single time and is cleaned up automatically. Otherwise, it will keep timing out periodically until `killTimer` is invoked.\n\n    When a timer times out, an `evBroadcast` event with the command `cmTimerExpired` is emitted, and `message.infoPtr` is set to the `TTimerId` of the expired timer.\n\n    Timeout events are generated in `TProgram::idle()`. Therefore, they are only processed when no keyboard or mouse events are available.\n\n## Screenshots\n\nYou will find some screenshots [here](https://github.com/magiblot/tvision/issues/7). Feel free to add your own!\n\n## Contributing\n\nIf you know of any Turbo Vision applications whose source code has not been lost and that could benefit from this, let me know.\n\n\u003cdiv id=\"applications\"\u003e\u003c/div\u003e\n\n## Applications using Turbo Vision\n\nIf your application is based on this project and you'd like it to appear in the following list, just let me know.\n\n* [Turbo](https://github.com/magiblot/turbo) by [magiblot](https://github.com/magiblot), a proof-of-concept text editor.\n* [tvterm](https://github.com/magiblot/tvterm) by [magiblot](https://github.com/magiblot), a proof-of-concept terminal emulator.\n* [TMBASIC](https://github.com/electroly/tmbasic) by [Brian Luft](https://github.com/electroly), a programming language for creating console applications.\n\n\u003cdiv id=\"unicode\"\u003e\u003c/div\u003e\n\n# Unicode support\n\nThe Turbo Vision API has been extended to allow receiving Unicode input and displaying Unicode text. The supported encoding is UTF-8, for a number of reasons:\n\n* It is compatible with already present data types (`char *`), so it does not require intrusive modifications to existing code.\n* It is the same encoding used for terminal I/O, so redundant conversions are avoided.\n* Conformance to the [UTF-8 Everywhere Manifesto](http://utf8everywhere.org/), which exposes many other advantages.\n\nNote that when built with Borland C++, Turbo Vision does not support Unicode. However, this does not affect the way Turbo Vision applications are written, since the API extensions are designed to allow for encoding-agnostic code.\n\n## Reading Unicode input\n\nThe traditional way to get text from a key press event is as follows:\n\n```c++\n// 'ev' is a TEvent, and 'ev.what' equals 'evKeyDown'.\nswitch (ev.keyDown.keyCode) {\n    // Key shortcuts are usually checked first.\n    // ...\n    default: {\n        // The character is encoded in the current codepage\n        // (CP437 by default).\n        char c = ev.keyDown.charScan.charCode;\n        // ...\n    }\n}\n```\n\nSome of the existing Turbo Vision classes that deal with text input still depend on this methodology, which has not changed. Single-byte characters, when representable in the current codepage, continue to be available in `ev.keyDown.charScan.charCode`.\n\nUnicode support consists in two new fields in `ev.keyDown` (which is a `struct KeyDownEvent`):\n\n* `char text[4]`, which may contain whatever was read from the terminal: usually a UTF-8 sequence, but possibly any kind of raw data.\n* `uchar textLength`, which is the number of bytes of data available in `text`, from 0 to 4.\n\nNote that the `text` string is not null-terminated.\nYou can get a `TStringView` out of a `KeyDownEvent` with the `getText()` method.\n\nSo a Unicode character can be retrieved from `TEvent` in the following way:\n\n```c++\nswitch (ev.keyDown.keyCode) {\n    // ...\n    default: {\n        std::string_view sv = ev.keyDown.getText();\n        processText(sv);\n    }\n}\n```\n\nLet's see it from another perspective. If the user types `ñ`, a `TEvent` is generated with the following `keyDown` struct:\n\n```c++\nKeyDownEvent {\n    union {\n        .keyCode = 0xA4,\n        .charScan = CharScanType {\n            .charCode = 164 ('ñ'), // In CP437\n            .scanCode = 0\n        }\n    },\n    .controlKeyState = 0x200 (kbInsState),\n    .text = {'\\xC3', '\\xB1'}, // In UTF-8\n    .textLength = 2\n}\n```\nHowever, if they type `€` the following will happen:\n```c++\nKeyDownEvent {\n    union {\n        .keyCode = 0x0 (kbNoKey), // '€' not part of CP437\n        .charScan = CharScanType {\n            .charCode = 0,\n            .scanCode = 0\n        }\n    },\n    .controlKeyState = 0x200 (kbInsState),\n    .text = {'\\xE2', '\\x82', '\\xAC'}, // In UTF-8\n    .textLength = 3\n}\n```\nIf a key shortcut is pressed instead, `text` is empty:\n```c++\nKeyDownEvent {\n    union {\n        .keyCode = 0xB (kbCtrlK),\n        .charScan = CharScanType {\n            .charCode = 11 ('♂'),\n            .scanCode = 0\n        }\n    },\n    .controlKeyState = 0x20C (kbCtrlShift | kbInsState),\n    .text = {},\n    .textLength = 0\n}\n```\nSo, in short: views designed without Unicode input in mind will continue to work exactly as they did before, and views which want to be Unicode-aware will have no issues in being so.\n\n## Displaying Unicode text\n\nThe original design of Turbo Vision uses 16 bits to represent a *screen cell*—8 bit for a character and 8 bit for [BIOS color attributes](https://en.wikipedia.org/wiki/BIOS_color_attributes).\n\nA new `TScreenCell` type is defined in `\u003ctvision/scrncell.h\u003e` which is capable of holding a limited number of UTF-8 codepoints in addition to extended attributes (bold, underline, italic...). However, you should not write text into a `TScreenCell` directly but make use of Unicode-aware API functions instead.\n\n### Text display rules\n\nA character provided as argument to any of the Turbo Vision API functions that deal with displaying text is interpreted as follows:\n\n* Non-printable characters in the range `0x00` to `0xFF` are interpreted as characters in the active codepage. For instance, `0x7F` is displayed as `⌂` and `0xF0` as `≡` if using CP437. As an exception, `0x00` is always displayed as a regular space. These characters are all one column wide.\n* Character sequences which are not valid UTF-8 are interpreted as sequences of characters in the current codepage, as in the case above.\n* Valid UTF-8 sequences with a display width other than one are taken care of in a special way, see below.\n\nFor example, the string `\"╔[\\xFE]╗\"` may be displayed as `╔[■]╗`. This means that box-drawing characters can be mixed with UTF-8 in general, which is useful for backward compatibility. If you rely on this behaviour, though, you may get unexpected results: for instance, `\"\\xC4\\xBF\"` is a valid UTF-8 sequence and is displayed as `Ŀ` instead of `─┐`.\n\nOne of the issues of Unicode support is the existence of [double-width](https://convertcase.net/vaporwave-wide-text-generator/) characters and [combining](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) characters. This conflicts with Turbo Vision's original assumption that the screen is a grid of cells occupied by a single character each. Nevertheless, these cases are handled in the following way:\n\n* Double-width characters can be drawn anywhere on the screen and nothing bad happens if they overlap partially with other characters.\n* Zero-width characters overlay the previous character. For example, the sequence `में` consists of the single-width character `म` and the combining characters `े` and `ं`. In this case, three Unicode codepoints are fit into the same cell.\n\n    The `ZERO WIDTH JOINER` (`U+200D`) is always omitted, as it complicates things too much. For example, it can turn a string like `\"👩👦\"` (4 columns wide) into `\"👩‍👦\"` (2 columns wide). Not all terminal emulators respect the ZWJ, so, in order to produce predictable results, Turbo Vision will print both `\"👩👦\"` and `\"👩‍👦\"` as `👩👦`.\n* No notable graphical glitches will occur as long as your terminal emulator respects character widths as measured by `wcwidth`.\n\nHere is an example of such characters in the [Turbo](https://github.com/magiblot/turbo) text editor:\n![Wide character display](https://user-images.githubusercontent.com/20713561/103179253-51344980-488a-11eb-9a29-79b9acb1b4b9.png)\n\n### Unicode-aware API functions\n\nThe usual way of writing to the screen is by using `TDrawBuffer`. A few methods have been added and others have changed their meaning:\n\n```c++\nvoid TDrawBuffer::moveChar(ushort indent, char c, TColorAttr attr, ushort count);\nvoid TDrawBuffer::putChar(ushort indent, char c);\n```\n`c` is always interpreted as a character in the active codepage.\n\n```c++\nushort TDrawBuffer::moveStr(ushort indent, TStringView str, TColorAttr attr);\nushort TDrawBuffer::moveCStr(ushort indent, TStringView str, TAttrPair attrs);\n```\n`str` is interpreted according to the rules exposed previously.\n\n```c++\nushort TDrawBuffer::moveStr(ushort indent, TStringView str, TColorAttr attr, ushort maxWidth, ushort strOffset = 0); // New\nushort TDrawBuffer::moveCStr(ushort indent, TStringView str, TColorAttr attr, ushort maxWidth, ushort strOffset = 0); // New\n```\n`str` is interpreted according to the rules exposed previously, but:\n* `maxWidth` specifies the maximum amount of text that should be copied from `str`, measured in text width (not in bytes).\n* `strOffset` specifies the initial position in `str` where to copy from, measured in text width (not in bytes). This is useful for horizontal scrolling. If `strOffset` points to the middle of a double-width character, a space will be copied instead of the right half of the double-width character, since it is not possible to do such a thing.\n\nThe return values are the number of cells in the buffer that were actually filled with text (which is the same as the width of the copied text).\n\n```c++\nvoid TDrawBuffer::moveBuf(ushort indent, const void *source, TColorAttr attr, ushort count);\n```\nThe name of this function is misleading. Even in its original implementation, `source` is treated as a string. So it is equivalent to `moveStr(indent, TStringView((const char*) source, count), attr)`.\n\nThere are other useful Unicode-aware functions:\n\n```c++\nint cstrlen(TStringView s);\n```\nReturns the displayed length of `s` according to the aforementioned rules, discarding `~` characters.\n\n```c++\nint strwidth(TStringView s); // New\n```\nReturns the displayed length of `s`.\n\nOn Borland C++, these methods assume a single-byte encoding and all characters being one column wide. This makes it possible to write encoding-agnostic `draw()` and `handleEvent()` methods that work on both platforms without a single `#ifdef`.\n\nThe functions above are implemented using the functions from the `TText` namespace, another API extension. You will have to use them directly if you want to fill `TScreenCell` objects with text manually. To give an example, below are some of the `TText` functions. You can find all of them with complete descriptions in `\u003ctvision/ttext.h\u003e`.\n\n```c++\nsize_t TText::next(TStringView text);\nsize_t TText::prev(TStringView text, size_t index);\nvoid TText::drawChar(TSpan\u003cTScreenCell\u003e cells, char c);\nsize_t TText::drawStr(TSpan\u003cTScreenCell\u003e cells, size_t indent, TStringView text, int textIndent);\nbool TText::drawOne(TSpan\u003cTScreenCell\u003e cells, size_t \u0026i, TStringView text, size_t \u0026j);\n```\n\nFor drawing `TScreenCell` buffers into a view, the following methods are available:\n\n```c++\nvoid TView::writeBuf(short x, short y, short w, short h, const TScreenCell *b); // New\nvoid TView::writeLine(short x, short y, short w, short h, const TScreenCell *b); // New\n```\n\n### Example: Unicode text in menus and status bars\n\nIt's as simple as it can be. Let's modify `hello.cpp` as follows:\n\n```c++\nTMenuBar *THelloApp::initMenuBar( TRect r )\n{\n    r.b.y = r.a.y+1;\n    return new TMenuBar( r,\n      *new TSubMenu( \"~Ñ~ello\", kbAltH ) +\n        *new TMenuItem( \"階~毎~料入報最...\", GreetThemCmd, kbAltG ) +\n        *new TMenuItem( \"五劫~の~擦り切れ\", cmYes, kbNoKey, hcNoContext ) +\n        *new TMenuItem( \"העברית ~א~ינטרנט\", cmNo, kbNoKey, hcNoContext ) +\n         newLine() +\n        *new TMenuItem( \"E~x~it\", cmQuit, cmQuit, hcNoContext, \"Alt-X\" )\n        );\n}\n\nTStatusLine *THelloApp::initStatusLine( TRect r )\n{\n    r.a.y = r.b.y-1;\n    return new TStatusLine( r,\n        *new TStatusDef( 0, 0xFFFF ) +\n            *new TStatusItem( \"~Alt-Ç~ Exit\", kbAltX, cmQuit ) +\n            *new TStatusItem( 0, kbF10, cmMenu )\n            );\n}\n```\nHere is what it looks like:\n\n![Unicode Hello](https://user-images.githubusercontent.com/20713561/103179255-5396a380-488a-11eb-88ad-0192adbe233e.png)\n\n### Example: writing Unicode-aware `draw()` methods\n\nThe following is an excerpt from an old implementation of `TFileViewer::draw()` (part of the `tvdemo` application), which does not draw Unicode text properly:\n\n```c++\nif (delta.y + i \u003c fileLines-\u003egetCount()) {\n    char s[maxLineLength+1];\n    p = (char *)(fileLines-\u003eat(delta.y+i));\n    if (p == 0 || strlen(p) \u003c delta.x)\n        s[0] = EOS;\n    else\n        strnzcpy(s, p+delta.x, maxLineLength+1);\n    b.moveStr(0, s, c);\n}\nwriteBuf( 0, i, size.x, 1, b );\n```\nAll it does is move part of a string in `fileLines` into `b`, which is a `TDrawBuffer`. `delta` is a `TPoint` representing the scroll offset in the text view, and `i` is the index of the visible line being processed. `c` is the text color. A few issues are present:\n\n* `TDrawBuffer::moveStr(ushort, const char *, TColorAttr)` takes a null-terminated string. In order to pass a substring of the current line, a copy is made into the array `s`, at the risk of a [buffer overrun](https://github.com/magiblot/tvision/commit/8aa2bf4af4474b85e86e340b08d7c56081b68986). The case where the line does not fit into `s` is not handled, so at most `maxLineLenght` characters will be copied. What's more, a multibyte character near position `maxLineLength` could be copied incompletely and be displayed as garbage.\n* `delta.x` is the first visible column. With multibyte-encoded text, it is no longer true that such column begins at position `delta.x` in the string.\n\nBelow is a corrected version of the code above that handles Unicode properly:\n\n```c++\nif (delta.y + i \u003c fileLines-\u003egetCount()) {\n    p = (char *)(fileLines-\u003eat(delta.y+i));\n    if (p)\n        b.moveStr(0, p, c, size.x, delta.x);\n}\nwriteBuf( 0, i, size.x, 1, b );\n```\nThe overload of `moveStr` used here is `TDrawBuffer::moveStr(ushort indent, TStringView str, TColorAttr attr, ushort width, ushort begin)`. This function not only provides Unicode support, but also helps us write cleaner code and overcome some of the limitations previously present:\n\n* The intermediary copy is avoided, so the displayed text is not limited to `maxLineLength` bytes.\n* `moveStr` takes care of printing the string starting at column `delta.x`. We do not even need to worry about how many bytes correspond to `delta.x` columns.\n* Similarly, `moveStr` is instructed to copy at most `size.x` columns of text without us having to care about how many bytes that is nor dealing with edge cases. The code is written in an encoding-agnostic way and will work whether multibyte characters are being considered or not.\n* In case you hadn't realized yet, the intermediary copy in the previous version was completely unnecessary. It would have been necessary only if we had needed to trim the end of the line, but that was not the case: text occupies all of the view's width, and `TView::writeBuf` already takes care of not writing beyond it. Yet it is interesting to see how an unnecessary step not only was limiting functionality but also was prone to bugs.\n\n## Unicode support across standard views\n\nSupport for creating Unicode-aware views is in place, and most views in the original Turbo Vision library have been adapted to handle Unicode.\n\nThe following views can display Unicode text properly. Some of them also do horizontal scrolling or word wrapping; all of that should work fine.\n\n- [x] `TStaticText` ([`7b15d45d`](https://github.com/magiblot/tvision/commit/7b15d45da231f75f2677454021c2e34ad1149ca8)).\n- [x] `TFrame` ([`81066ee5`](https://github.com/magiblot/tvision/commit/81066ee5c05496612dfcd9cf75df5702cbfb9679)).\n- [x] `TStatusLine` ([`477b3ae9`](https://github.com/magiblot/tvision/commit/477b3ae91fd84eb1487dca18a87b3f7b8699c576)).\n- [x] `THistoryViewer` ([`81066ee5`](https://github.com/magiblot/tvision/commit/81066ee5c05496612dfcd9cf75df5702cbfb9679)).\n- [x] `THelpViewer` ([`81066ee5`](https://github.com/magiblot/tvision/commit/81066ee5c05496612dfcd9cf75df5702cbfb9679), [`8c7dac2a`](https://github.com/magiblot/tvision/commit/8c7dac2a61000f17e09cc31ebbb58b030f95c0e5), [`20f331e3`](https://github.com/magiblot/tvision/commit/20f331e362255d45859c36050ff75ffab078c3ab)).\n- [x] `TListViewer` ([`81066ee5`](https://github.com/magiblot/tvision/commit/81066ee5c05496612dfcd9cf75df5702cbfb9679)).\n- [x] `TMenuBox` ([`81066ee5`](https://github.com/magiblot/tvision/commit/81066ee5c05496612dfcd9cf75df5702cbfb9679)).\n- [x] `TTerminal` ([`ee821b69`](https://github.com/magiblot/tvision/commit/ee821b69c5dd81c565fe1add1ac6f0a2f8a96a01)).\n- [x] `TOutlineViewer` ([`6cc8cd38`](https://github.com/magiblot/tvision/commit/6cc8cd38da5841201544d6ba103f9662d7675213)).\n- [x] `TFileViewer` (from the `tvdemo` application) ([`068bbf7a`](https://github.com/magiblot/tvision/commit/068bbf7a0a13482bda91f9f3411ec614f9a1e6ff)).\n- [x] `TFilePane` (from the `tvdir` application) ([`9bcd897c`](https://github.com/magiblot/tvision/commit/9bcd897cb7cf010ef34d0281d42e9ea58345ce53)).\n\nThe following views can, in addition, process Unicode text or user input:\n\n- [x] `TInputLine` ([`81066ee5`](https://github.com/magiblot/tvision/commit/81066ee5c05496612dfcd9cf75df5702cbfb9679), [`cb489d42`](https://github.com/magiblot/tvision/commit/cb489d42d522f7515c870942bcaa8f0f3dea3f35)).\n- [x] `TEditor` ([`702114dc`](https://github.com/magiblot/tvision/commit/702114dc03a13ebce2b52504eb122c97f9892de9)). Instances are in UTF-8 mode by default. You may switch back to single-byte mode by pressing `Ctrl+P`. This only changes how the document is displayed and the encoding of user input; it does not alter the document. This class is used in the `tvedit` application; you may test it there.\n\nViews not in this list may not have needed any corrections or I simply forgot to fix them. Please submit an issue if you notice anything not working as expected.\n\nUse cases where Unicode is not supported (not an exhaustive list):\n\n- [ ] Highlighted key shortcuts, in general (e.g. `TMenuBox`, `TStatusLine`, `TButton`...).\n\n\u003cdiv id=\"clipboard\"\u003e\u003c/div\u003e\n\n# Clipboard interaction\n\nOriginally, Turbo Vision offered no integration with the system clipboard, since there was no such thing on MS-DOS.\n\nIt did offer the possibility of using an instance of `TEditor` as an internal clipboard, via the `TEditor::clipboard` static member. However, `TEditor` was the only class able to interact with this clipboard. It was not possible to use it with `TInputLine`, for example.\n\nTurbo Vision applications are now most likely to be ran in a graphical environment through a terminal emulator. In this context, it would be desirable to interact with the system clipboard in the same way as a regular GUI application would do.\n\nTo deal with this, a new class `TClipboard` has been added which allows accessing the system clipboard. If the system clipboard is not accessible, it will instead use an internal clipboard.\n\n## Enabling clipboard support\n\nOn Windows (including WSL) and macOS, clipboard integration is supported out-of-the-box.\n\nOn Unix systems other than macOS, it is necessary to install some external dependencies. See [runtime requirements](#build-linux-runtime).\n\nFor applications running remotely (e.g. through SSH), clipboard integration is supported in the following situations:\n\n* When X11 forwarding over SSH is enabled (`ssh -X`).\n* When your terminal emulator supports far2l's terminal extensions ([far2l](https://github.com/elfmz/far2l), [putty4far2l](https://github.com/ivanshatsky/putty4far2l)).\n* When your terminal emulator supports OSC 52 escape codes:\n    * [alacritty](https://github.com/alacritty/alacritty), [kitty](https://github.com/kovidgoyal/kitty), [foot](https://codeberg.org/dnkl/foot).\n    * [xterm](https://invisible-island.net/xterm/), if the `allowWindowOps` option is enabled.\n    * A few other terminals only support the Copy action.\n\nAdditionally, it is always possible to paste text using your terminal emulator's own Paste command (usually `Ctrl+Shift+V` or `Cmd+V`).\n\n## API usage\n\nTo use the `TClipboard` class, define the macro `Uses_TClipboard` before including `\u003ctvision/tv.h\u003e`.\n\n### Writing to the clipboard\n\n```c++\nstatic void TClipboard::setText(TStringView text);\n```\n\nSets the contents of the system clipboard to `text`. If the system clipboard is not accessible, an internal clipboard is used instead.\n\n### Reading the clipboard\n\n```c++\nstatic void TClipboard::requestText();\n```\n\nRequests the contents of the system clipboard asynchronously, which will be later received in the form of regular `evKeyDown` events. If the system clipboard is not accessible, an internal clipboard is used instead.\n\n### Processing Paste events\n\nA Turbo Vision application may receive a Paste event for two different reasons:\n\n* Because `TClipboard::requestText()` was invoked.\n* Because the user pasted text through the terminal.\n\nIn both cases the application will receive the clipboard contents in the form of regular `evKeyDown` events. These events will have a `kbPaste` flag in `keyDown.controlKeyState` so that they can be distinguished from regular key presses.\n\nTherefore, if your view can handle user input it will also handle Paste events by default. However, if the user pastes 5000 characters, the application will behave as if the user pressed the keyboard 5000 times. This involves drawing views, completing the event loop, updating the screen..., which is far from optimal if your view is a text editing component, for example.\n\nFor the purpose of dealing with this situation, another function has been added:\n\n```c++\nbool TView::textEvent(TEvent \u0026event, TSpan\u003cchar\u003e dest, size_t \u0026length);\n```\n\n`textEvent()` attempts to read text from consecutive `evKeyDown` events and stores it in a user-provided buffer `dest`. It returns `false` when no more events are available or if a non-text event is found, in which case this event is saved with `putEvent()` so that it can be processed in the next iteration of the event loop. Finally, it calls `clearEvent(event)`.\n\nThe exact number of bytes read is stored in the output parameter `length`, which will never be larger than `dest.size()`.\n\nHere is an example on how to use it:\n\n```c++\n// 'ev' is a TEvent, and 'ev.what' equals 'evKeyDown'.\n// If we received text from the clipboard...\nif (ev.keyDown.controlKeyState \u0026 kbPaste) {\n    char buf[512];\n    size_t length;\n    // Fill 'buf' with the text in 'ev' and in\n    // upcoming events from the input queue.\n    while (textEvent(ev, buf, length)) {\n        // Process 'length' bytes of text in 'buf'...\n    }\n}\n```\n\n### Enabling application-wide clipboard usage\n\nThe standard views `TEditor` and `TInputLine` react to the `cmCut`, `cmCopy` and `cmPaste` commands. However, your application first has to be set up to use these commands. For example:\n\n```c++\nTStatusLine *TMyApplication::initStatusLine( TRect r )\n{\n    r.a.y = r.b.y - 1;\n    return new TStatusLine( r,\n        *new TStatusDef( 0, 0xFFFF ) +\n            // ...\n            *new TStatusItem( 0, kbCtrlX, cmCut ) +\n            *new TStatusItem( 0, kbCtrlC, cmCopy ) +\n            *new TStatusItem( 0, kbCtrlV, cmPaste ) +\n            // ...\n    );\n}\n```\n\n`TEditor` and `TInputLine` automatically enable and disable these commands. For example, if a `TEditor` or `TInputLine` is focused, the `cmPaste` command will be enabled. If there is selected text, the `cmCut` and `cmCopy` commands will also be enabled. If no `TEditor` or `TInputLine`s are focused, then these commands will be disabled.\n\n\u003cdiv id=\"color\"\u003e\u003c/div\u003e\n\n# Extended color support\n\nThe Turbo Vision API has been extended to allow more than the original 16 colors.\n\nColors can be specified using any of the following formats:\n\n* [BIOS color attributes](https://en.wikipedia.org/wiki/BIOS_color_attributes) (4-bit), the format used originally on MS-DOS.\n* RGB (24-bit).\n* `xterm-256color` palette indices (8-bit).\n* The *terminal default* color. This is the color used by terminal emulators when no display attributes (bold, color...) are enabled (usually white for foreground and black for background).\n\nAlthough Turbo Vision applications are likely to be ran in a terminal emulator, the API makes no assumptions about the display device. That is to say, the complexity of dealing with terminal emulators is hidden from the programmer and managed by Turbo Vision itself.\n\nFor example: color support varies among terminals. If the programmer uses a color format not supported by the terminal emulator, Turbo Vision will quantize it to what the terminal can display. The following images represent the quantization of a 24-bit RGB picture to 256, 16 and 8 color palettes:\n\n| 24-bit color (original) | 256 colors |\n|:-:|:-:|\n|![mpv-shot0005](https://user-images.githubusercontent.com/20713561/111095336-7c4f4080-853d-11eb-8331-798898a2af68.png)|![mpv-shot0002](https://user-images.githubusercontent.com/20713561/111095333-7b1e1380-853d-11eb-8c4d-989fe24d0498.png)|\n\n| 16 colors | 8 colors (bold as bright) |\n|:-:|:-:|\n|![mpv-shot0003](https://user-images.githubusercontent.com/20713561/111095334-7bb6aa00-853d-11eb-9a3f-e7decc0bac7d.png)|![mpv-shot0004](https://user-images.githubusercontent.com/20713561/111095335-7bb6aa00-853d-11eb-9098-38d6f6c3c1da.png)|\n\nExtended color support basically comes down to the following:\n* Turbo Vision has originally used [BIOS color attributes](https://en.wikipedia.org/wiki/BIOS_color_attributes) stored in an `uchar`. `ushort` is used to represent attribute pairs. This is still the case when using Borland C++.\n* In modern platforms a new type `TColorAttr` has been added which replaces `uchar`. It specifies a foreground and background color and a style. Colors can be specified in different formats (BIOS color attributes, 24-bit RGB...). Styles are the typical ones (bold, italic, underline...). There's also `TAttrPair`, which replaces `ushort`.\n* `TDrawBuffer`'s methods, which used to take `uchar` or `ushort` parameters to specify color attributes, now take `TColorAttr` or `TAttrPair`.\n* `TPalette`, which used to contain an array of `uchar`, now contains an array of `TColorAttr`. The `TView::mapColor` method also returns `TColorAttr` instead of `uchar`.\n* `TView::mapColor` has been made virtual so that the palette system can be bypassed without having to rewrite any `draw` methods.\n* `TColorAttr` and `TAttrPair` can be initialized with and casted into `uchar` and `ushort` in a way such that legacy code still compiles out-of-the-box without any change in functionality.\n\nBelow is a more detailed explanation aimed at developers.\n\n## Data Types\n\nIn the first place we will explain the data types the programmer needs to know in order to take advantage of the extended color support. To get access to them, you may have to define the macro `Uses_TColorAttr` before including `\u003ctvision/tv.h\u003e`.\n\nAll the types described in this section are *trivial*. This means that they can be `memset`'d and `memcpy`'d. But variables of these types are *uninitialized* when declared without initializer, just like primitive types. So make sure you don't manipulate them before initializing them.\n\n### Color format types\n\nSeveral types are defined which represent different color formats.\nThe reason why these types exist is to allow distinguishing color formats using the type system. Some of them also have public fields which make it easier to manipulate individual bits.\n\n* `TColorBIOS` represents a BIOS color. It allows accessing the `r`, `g`, `b` and `bright` bits individually, and can be casted implicitly into/from `uint8_t`.\n\n    The memory layout is:\n\n    * Bit 0: Blue (field `b`).\n    * Bit 1: Green (field `g`).\n    * Bit 2: Red (field `r`).\n    * Bit 3: Bright (field `bright`).\n    * Bits 4-7: unused.\n\n    Examples of `TColorBIOS` usage:\n    ```c++\n    TColorBIOS bios = 0x4;  // 0x4: red.\n    bios.bright = 1;        // 0xC: light red.\n    bios.b = bios.r;        // 0xD: light magenta.\n    bios = bios ^ 3;        // 0xE: yellow.\n    uint8_t c = bios;       // Implicit conversion to integer types.\n    ```\n\n    In terminal emulators, BIOS colors are mapped to the basic 16 ANSI colors.\n\n* `TColorRGB` represents a color in 24-bit RGB. It allows accessing the `r`, `g` and `b` bit fields individually, and can be casted implicitly into/from `uint32_t`.\n\n    The memory layout is:\n\n    * Bits 0-7: Blue (field `b`).\n    * Bits 8-15: Green (field `g`).\n    * Bits 16-23: Red (field `r`).\n    * Bits 24-31: unused.\n\n    Examples of `TColorRGB` usage:\n    ```c++\n    TColorRGB rgb = 0x9370DB;   // 0xRRGGBB.\n    rgb = {0x93, 0x70, 0xDB};   // {R, G, B}.\n    rgb = rgb ^ 0xFFFFFF;       // Negated.\n    rgb.g = rgb.r \u0026 0x88;       // Access to individual components.\n    uint32_t c = rgb;           // Implicit conversion to integer types.\n    ```\n\n* `TColorXTerm` represents an index into the `xterm-256color` color palette. It can be casted into and from `uint8_t`.\n\n### `TColorDesired`\n\n`TColorDesired` represents a color which the programmer intends to show on screen, encoded in any of the supported color types.\n\nA `TColorDesired` can be initialized in the following ways:\n\n* As a BIOS color: with a `char` literal or a `TColorBIOS` object:\n\n    ```c++\n    TColorDesired bios1 = '\\xF';\n    TColorDesired bios2 = TColorBIOS(0xF);\n    ```\n* As a RGB color: with an `int` literal or a `TColorRGB` object:\n\n    ```c++\n    TColorDesired rgb1 = 0xFF7700; // 0xRRGGBB.\n    TColorDesired rgb2 = TColorRGB(0xFF, 0x77, 0x00); // {R, G, B}.\n    TColorDesired rgb3 = TColorRGB(0xFF7700); // 0xRRGGBB.\n    ```\n* As an XTerm palette index: with a `TColorXTerm` object.\n* As the *terminal default* color: through zero-initialization:\n\n    ```c++\n    TColorDesired def1 {};\n    // Or with 'memset':\n    TColorDesired def2;\n    memset(\u0026def2, 0, sizeof(def2));\n    ```\n\n`TColorDesired` has methods to query the contained color, but you will usually not need to use them. See the struct definition in `\u003ctvision/colors.h\u003e` for more information.\n\nTrivia: the name is inspired by [Scintilla](https://www.scintilla.org/index.html)'s `ColourDesired`.\n\n### `TColorAttr`\n\n`TColorAttr` describes the color attributes of a screen cell. This is the type you are most likely to interact with if you intend to change the colors in a view.\n\nA `TColorAttr` is composed of:\n\n* A foreground color, of type `TColorDesired`.\n* A background color, of type `TColorDesired`.\n* A style bitmask containing a combination of the following flags:\n\n    * `slBold`.\n    * `slItalic`.\n    * `slUnderline`.\n    * `slBlink`.\n    * `slReverse`.\n    * `slStrike`.\n\n    These flags are based on the basic display attributes selectable through [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters). The results may vary between terminal emulators. `slReverse` is probably the least reliable of them: prefer using the `TColorAttr reverseAttribute(TColorAttr attr)` free function over setting this flag.\n\nThe most straight-forward way to create a `TColorAttr` is by means of the `TColorAttr(TColorDesired fg, TColorDesired bg, ushort style=0)` and `TColorAttr(int bios)` constructors:\n\n```c++\n// Foreground: RGB 0x892312\n// Background: RGB 0x7F00BB\n// Style: Normal.\nTColorAttr a1 = {TColorRGB(0x89, 0x23, 0x12), TColorRGB(0x7F, 0x00, 0xBB)};\n\n// Foreground: BIOS 0x7.\n// Background: RGB 0x7F00BB.\n// Style: Bold, Italic.\nTColorAttr a2 = {'\\x7', 0x7F00BB, slBold | slItalic};\n\n// Foreground: Terminal default.\n// Background: BIOS 0xF.\n// Style: Normal.\nTColorAttr a3 = {{}, TColorBIOS(0xF)};\n\n// Foreground: Terminal default.\n// Background: Terminal default.\n// Style: Normal.\nTColorAttr a4 = {};\n\n// Foreground: BIOS 0x0\n// Background: BIOS 0x7\n// Style: Normal\nTColorAttr a5 = 0x70;\n```\n\nThe fields of a `TColorAttr` can be accessed with the following free functions:\n\n```c++\nTColorDesired getFore(const TColorAttr \u0026attr);\nTColorDesired getBack(const TColorAttr \u0026attr);\nushort getStyle(const TColorAttr \u0026attr);\nvoid setFore(TColorAttr \u0026attr, TColorDesired fg);\nvoid setBack(TColorAttr \u0026attr, TColorDesired bg);\nvoid setStyle(TColorAttr \u0026attr, ushort style);\n```\n\n### `TAttrPair`\n\n`TAttrPair` is a pair of `TColorAttr`, used by some API functions to pass two attributes at once.\n\nYou may initialize a `TAttrPair` with the `TAttrPair(const TColorAttrs \u0026lo, const TColorAttrs \u0026hi)` constructor:\n\n```c++\nTColorAttr cNormal = {0x234983, 0x267232};\nTColorAttr cHigh = {0x309283, 0x127844};\nTAttrPair attrs = {cNormal, cHigh};\nTDrawBuffer b;\nb.moveCStr(0, \"Normal text, ~Highlighted text~\", attrs);\n```\n\nThe attributes can be accessed with the `[0]` and `[1]` subindices:\n\n```c++\nTColorAttr lo = {0x892343, 0x271274};\nTColorAttr hi = '\\x93';\nTAttrPair attrs = {lo, hi};\nassert(lo == attrs[0]);\nassert(hi == attrs[1]);\n```\n\n## Changing the appearance of a `TView`\n\nViews are commonly drawn by means of a `TDrawBuffer`. Most `TDrawBuffer` member functions take color attributes by parameter. For example:\n\n```c++\nushort TDrawBuffer::moveStr(ushort indent, TStringView str, TColorAttr attr);\nushort TDrawBuffer::moveCStr(ushort indent, TStringView str, TAttrPair attrs);\nvoid TDrawBuffer::putAttribute(ushort indent, TColorAttr attr);\n```\n\nHowever, the views provided with Turbo Vision usually store their color information in palettes. A view's palette can be queried with the following member functions:\n\n```c++\nTColorAttr TView::mapColor(uchar index);\nTAttrPair TView::getColor(ushort indices);\n```\n\n* `mapColor` looks up a single color attribute in the view's palette, given an index into the palette. Remember that the palette indices for each view class can be found in the Turbo Vision headers. For example, `\u003ctvision/views.h\u003e` says the following about `TScrollBar`:\n\n    ```c++\n    /* ---------------------------------------------------------------------- */\n    /*      class TScrollBar                                                  */\n    /*                                                                        */\n    /*      Palette layout                                                    */\n    /*        1 = Page areas                                                  */\n    /*        2 = Arrows                                                      */\n    /*        3 = Indicator                                                   */\n    /* ---------------------------------------------------------------------- */\n    ```\n\n* `getColor` is a helper function that allows querying two cell attributes at once. Each byte in the `indices` parameter contains an index into the palette. The `TAttrPair` result contains the two cell attributes.\n\n    For example, the following can be found in the `draw` method of `TMenuBar`:\n\n    ```c++\n    TAttrPair cNormal = getColor(0x0301);\n    TAttrPair cSelect = getColor(0x0604);\n    ```\n\n    Which would be equivalent to this:\n\n    ```c++\n    TAttrPair cNormal = {mapColor(1), mapColor(3)};\n    TAttrPair cSelect = {mapColor(4), mapColor(6)};\n    ```\n\nAs an API extension, the `mapColor` method has been made `virtual`. This makes it possible to override Turbo Vision's hierarchical palette system with a custom solution without having to rewrite the `draw()` method.\n\nSo, in general, there are three ways to use extended colors in views:\n\n1. By returning extended color attributes from an overridden `mapColor` method:\n\n```c++\n// The 'TMyScrollBar' class inherits from 'TScrollBar' and overrides 'TView::mapColor'.\nTColorAttr TMyScrollBar::mapColor(uchar index) noexcept\n{\n    // In this example the values are hardcoded,\n    // but they could be stored elsewhere if desired.\n    switch (index)\n    {\n        case 1:     return {0x492983, 0x826124}; // Page areas.\n        case 2:     return {0x438939, 0x091297}; // Arrows.\n        case 3:     return {0x123783, 0x329812}; // Indicator.\n        default:    return errorAttr;\n    }\n}\n```\n\n2. By providing extended color attributes directly to `TDrawBuffer` methods, if the palette system is not being used. For example:\n\n    ```c++\n    // The 'TMyView' class inherits from 'TView' and overrides 'TView::draw'.\n    void TMyView::draw()\n    {\n        TDrawBuffer b;\n        TColorAttr color {0x1F1C1B, 0xFAFAFA, slBold};\n        b.moveStr(0, \"This is bold black text over a white background\", color);\n        /* ... */\n    }\n    ```\n\n3. By modifying the palettes. There are two ways to do this:\n\n    1. By modifying the application palette after it has been built. Note that the palette elements are `TColorAttr`. For example:\n\n    ```c++\n    void updateAppPalette()\n    {\n        TPalette \u0026pal = TProgram::application-\u003egetPalete();\n        pal[1] = {0x762892, 0x828712};              // TBackground.\n        pal[2] = {0x874832, 0x249838, slBold};      // TMenuView normal text.\n        pal[3] = {{}, {}, slItalic | slUnderline};  // TMenuView disabled text.\n        /* ... */\n    }\n    ```\n\n    2. By using extended color attributes in the application palette definition:\n\n    ```c++\n    static const TColorAttr cpMyApp[] =\n    {\n        {0x762892, 0x828712},               // TBackground.\n        {0x874832, 0x249838, slBold},       // TMenuView normal text.\n        {{}, {}, slItalic | slUnderline},   // TMenuView disabled text.\n        /* ... */\n    };\n\n    // The 'TMyApp' class inherits from 'TApplication' and overrides 'TView::getPalette'.\n    TPalette \u0026TMyApp::getPalette() const\n    {\n        static TPalette palette(cpMyApp);\n        return palette;\n    }\n    ```\n\n## Display capabilities\n\n`TScreen::screenMode` exposes some information about the display's color support:\n\n* If `(TScreen::screenMode \u0026 0xFF) == TDisplay::smMono`, the display is monocolor (only relevant in DOS).\n* If `(TScreen::screenMode \u0026 0xFF) == TDisplay::smBW80`, the display is grayscale (only relevant in DOS).\n* If `(TScreen::screenMode \u0026 0xFF) == TDisplay::smCO80`, the display supports at least 16 colors.\n    * If `TScreen::screenMode \u0026 TDisplay::smColor256`, the display supports at least 256 colors.\n    * If `TScreen::screenMode \u0026 TDisplay::smColorHigh`, the display supports even more colors (e.g. 24-bit color). `TDisplay::smColor256` is also set in this case.\n\n## Backward-compatibility of color types\n\nThe types defined previously represent concepts that are also important when developing for Borland C++:\n\n| Concept | Layout in Borland C++ | Layout in modern platforms |\n|:-:|:-:|:-:|\n| Color Attribute | `uchar`. A BIOS color attribute. | `struct TColorAttr`. |\n| Color | A 4-bit number. | `struct TColorDesired`. |\n| Attribute Pair | `ushort`. An attribute in each byte. | `struct TAttrPair`. |\n\nOne of this project's key principles is that the API should be used in the same way both in Borland C++ and modern platforms, that is to say, without the need for `#ifdef`s. Another principle is that legacy code should compile out-of-the-box, and adapting it to the new features should increase complexity as little as possible.\n\nBackward-compatibility is accomplished in the following way:\n\n* In Borland C++, `TColorAttr` and `TAttrPair` are `typedef`'d to `uchar` and `ushort`, respectively.\n* In modern platforms, `TColorAttr` and `TAttrPair` can be used in place of `uchar` and `ushort`, respectively, since they are able to hold any value that fits into them and can be casted implicitly into/from them.\n\n    A `TColorAttr` initialized with `uchar` represents a BIOS color attribute. When converting back to `uchar`, the following happens:\n\n    * If `fg` and `bg` are BIOS colors, and `style` is cleared, the resulting `uchar` represents the same BIOS color attribute contained in the `TColorAttr` (as in the code above).\n    * Otherwise, the conversion results in a color attribute that stands out, i.e. white on magenta, meaning that the programmer should consider replacing `uchar`/`ushort` with `TColorAttr`/`TAttrPair` if they intend to support the extended color attributes.\n\n    The same goes for `TAttrPair` and `ushort`, considering that it is composed of two `TColorAttr`.\n\nA use case of backward-compatibility within Turbo Vision itself is the `TPalette` class, core of the palette system. In its original design, it used a single data type (`uchar`) to represent different things: array length, palette indices or color attributes.\n\nThe new design simply replaces `uchar` with `TColorAttr`. This means there are no changes in the way `TPalette` is used, yet `TPalette` is now able to store extended color attributes.\n\n`TColorDialog` hasn't been remodeled, and thus it can't be used to pick extended color attributes at runtime.\n\n### Example: adding extended color support to legacy code\n\nThe following pattern of code is common across `draw` methods of views:\n\n```c++\nvoid TMyView::draw()\n{\n    ushort cFrame, cTitle;\n    if (state \u0026 sfDragging)\n    {\n        cFrame = 0x0505;\n        cTitle = 0x0005;\n    }\n    else\n    {\n        cFrame = 0x0503;\n        cTitle = 0x0004;\n    }\n    cFrame = getColor(cFrame);\n    cTitle = getColor(cTitle);\n    /* ... */\n}\n```\n\nIn this case, `ushort` is used both as a pair of palette indices and as a pair of color attributes. `getColor` now returns a `TAttrPair`, so even though this compiles out-of-the-box, extended attributes will be lost in the implicit conversion to `ushort`.\n\nThe code above still works just like it did originally. It's only non-BIOS color attributes that don't produce the expected result. Because of the compatibility between `TAttrPair` and `ushort`, the following is enough to enable support for extended color attributes:\n\n```diff\n-    ushort cFrame, cTitle;\n+    TAttrPair cFrame, cTitle;\n```\n\nNothing prevents you from using different variables for palette indices and color attributes, which is what should actually be done. The point of backward-compatibility is the ability to support new features without changing the program's logic, that is to say, minimizing the risk of increasing code complexity or introducing bugs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiblot%2Ftvision","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiblot%2Ftvision","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiblot%2Ftvision/lists"}