用户:FutabaLRio/沙盒
一种基于输出或控制文本显示以进行人机交互的界面
![](http://upload.wikimedia.org/wikipedia/commons/thumb/b/b8/Midnight_Commander_%282005%29_en.png/300px-Midnight_Commander_%282005%29_en.png)
![](http://upload.wikimedia.org/wikipedia/commons/thumb/8/8c/Vim-%28logiciel%29-console.png/300px-Vim-%28logiciel%29-console.png)
在计算机科学领域,基于文本的用户界面(text-based user interfaces, TUI),或称文本用户界面、终端用户界面(terminal user interfaces,以此称呼来强调该人机交互方式对终端而不止文本的依赖)指一种常见于位图显示和现代图形用户界面(GUI)普及之前的、与传统命令行界面(CLI)相对的用户界面解决方案。文本用户界面与现代GUI部分相似,其也可以占据整个屏幕,部分支持鼠标、快捷键及其他输入方式。文本用户界面还支持彩色显示,并常用制表符(如╔、█等)来构建界面。文本用户界面的现代使用环境通常为终端模拟器。
文本用户界面的类别
编辑From text application's point of view, a text screen (and communications with it) can belong to one of three types (here ordered in order of decreasing accessibility):
- A genuine text mode display, controlled by a video adapter or the central processor itself. This is a normal condition for a locally running application on various types of personal computers and mobile devices. If not deterred by the operating system, a smart program may exploit the full power of a hardware text mode.
- A text mode emulator. Examples are xterm for X Window System and win32 console (in a window mode) for Microsoft Windows. This usually supports programs which expect a real text mode display, but may run considerably slower. Certain functions of an advanced text mode, such as an own font uploading, almost certainly become unavailable.
- A remote text terminal. The communication capabilities usually become reduced to a serial line or its emulation, possibly with few ioctl()s as an out-of-band channel in such cases as Telnet and Secure Shell. This is the worst case, because software restrictions hinder the use of capabilities of a remote display device.
Under Linux and other Unix-like systems, a program easily accommodates to any of the three cases because the same interface (namely, standard streams) controls the display and keyboard. See below for comparison to Windows.
Many TUI programming libraries are available to help developers build TUI applications.
在ANSI兼容终端上
编辑美国国家标准协会(ANSI)标准ANSI X3.64定义了一系列的标准转义序列,可以被用于驱动终端以绘制TUI界面。上文提到的所有三种情况都支持转义序列的使用,允许任意的光标移动与颜色更改。然而,并非所有终端都遵循此标准,并且存在许多不兼容但可提供平替功能的终端。
在DOS和Microsoft Windows系统上
编辑On IBM Personal Computers and compatibles, the Basic Input Output System (BIOS) and DOS system calls provide a way to write text on the screen, and the ANSI.SYS driver could process standard ANSI escape sequences. However, programmers soon learned that writing data directly to the screen buffer was far faster and simpler to program, and less error-prone; see VGA-compatible text mode for details. This change in programming methods resulted in many DOS TUI programs. The Windows console environment is notorious for its emulation of certain EGA/VGA text mode features, particularly random access to the text buffer, even if the application runs in a window. On the other hand, programs running under Windows (both native and DOS applications) have much less control of the display and keyboard than Linux and DOS programs can have, because of aforementioned Windows console layer.
Most often those programs used a blue background for the main screen, with white or yellow characters, although commonly they had also user color customization. They often used box-drawing characters in IBM's code page 437. Later, the interface became deeply influenced by graphical user interfaces (GUI), adding pull-down menus, overlapping windows, dialog boxes and GUI widgets operated by mnemonics or keyboard shortcuts. Soon mouse input was added – either at text resolution as a simple colored box or at graphical resolution thanks to the ability of the Enhanced Graphics Adapter (EGA) and Video Graphics Array (VGA) display adapters to redefine the text character shapes by software – providing additional functions.
Some notable programs of this kind were Microsoft Word, DOS Shell, WordPerfect, Norton Commander, Turbo Vision based Borland Turbo Pascal and Turbo C (the latter included the conio library), Lotus 1-2-3 and many others. Some of these interfaces survived even during the Microsoft Windows 3.1x period in the early 1990s. For example, the Microsoft C 6.0 compiler, used to write true GUI programs under 16-bit Windows, still has its own TUI.
Since its start, Microsoft Windows includes a console to display DOS software. Later versions added the Windows console as a native interface for command-line interface and TUI programs. The console usually opens in window mode, but it can be switched to full, true text mode screen and vice versa by pressing the Alt and Enter keys together. Full-screen mode is not available in Windows Vista and later, but may be used with some workarounds.[1]
Windows Terminal is a multi-tabbed terminal emulator that Microsoft has developed for Windows 10 and later[2] as a replacement for Windows Console.
The Windows Subsystem for Linux which was added to Windows by Microsoft in 2019, supports running Linux text-based apps on Windows, within Windows console, Windows Terminal, and other Windows-based terminals.
在类Unix系统上
编辑In Unix-like operating systems, TUIs are often constructed using the terminal control library curses, or ncurses (a mostly compatible library), or the alternative S-Lang library. The advent of the curses library with Berkeley Unix created a portable and stable API for which to write TUIs. The ability to talk to various text terminal types using the same interfaces led to more widespread use of "visual" Unix programs, which occupied the entire terminal screen instead of using a simple line interface. This can be seen in text editors such as vi, mail clients such as pine or mutt, system management tools such as SMIT, SAM, FreeBSD's Sysinstall and web browsers such as lynx. Some applications, such as w3m, and older versions of pine and vi use the less-able termcap library, performing many of the functions associated with curses within the application. Custom TUI applications based on widgets can be easily developed using the dialog program (based on ncurses), or the Whiptail program (based on S-Lang).
In addition, the rise in popularity of Linux brought many former DOS users to a Unix-like platform, which has fostered a DOS influence in many TUIs. The program minicom, for example, is modeled after the popular DOS program Telix. Some other TUI programs, such as the Twin desktop, were ported over.
Most Unix-like operating systems (Linux, FreeBSD, etc.) support virtual consoles, typically accessed through a Ctrl-Alt-F key combination. For example, under Linux up to 64 consoles may be accessed (12 via function keys), each displaying in full-screen text mode.
The free software program GNU Screen provides for managing multiple sessions inside a single TUI, and so can be thought of as being like a window manager for text-mode and command-line interfaces. Tmux can also do this.
The proprietary macOS text editor BBEdit includes a shell worksheet function that works as a full-screen shell window. The free Emacs text editor can run a shell inside of one of its buffers to provide similar functionality. There are several shell implementations in Emacs, but only ansi-term
is suitable for running TUI programs. The other common shell modes, shell
and eshell
only emulate command lines and TUI programs will complain "Terminal is not fully functional" or display a garbled interface. The free Vim and Neovim text editors have terminal windows (simulating xterm). The feature is intended for running jobs, parallel builds, or tests, but can also be used (with window splits and tab pages) as a lightweight terminal multiplexer.
OpenVMS
编辑VAX/VMS (later known as OpenVMS) had a similar facility to curses known as the Screen Management facility or SMG. This could be invoked from the command line or called from programs using the SMG$ library.[3]
Oberon
编辑Another kind of TUI is the primary interface of the Oberon operating system, first released in 1988 and still maintained. Unlike most other text-based user interfaces, Oberon does not use a text-mode console or terminal, but requires a large bit-mapped display, on which text is the primary target for mouse clicks. Commands in the format Module.Procedure parameters ~
can be activated with a middle-click, like hyperlinks. Text displayed anywhere on the screen can be edited, and if formatted with the required command syntax, can be middle-clicked and executed. Any text file containing suitably-formatted commands can be used as a so-called tool text, thus serving as a user-configurable menu. Even the output of a previous command can be edited and used as a new command. This approach is radically different from both conventional dialogue-oriented console menus or command-line interfaces.
Since it does not use graphical widgets, only plain text, but offers comparable functionality to a GUI with a tiling window manager, it is referred to as a Text User Interface or TUI. For a short introduction, see the 2nd paragraph on page four of the first published Report on the Oberon System.[4]
Oberon's UI influenced the design of the Acme text editor and email client for the Plan 9 from Bell Labs operating system.
In embedded systems
编辑Modern embedded systems are capable of displaying TUI on a monitor like personal computers. This functionality is usually implemented using specialized integrated circuits, modules, or using FPGA.
Video circuits or modules are usually controlled using VT100-compatible command set over UART,[来源请求] FPGA designs usually allow direct video memory access.[来源请求]
Other uses
编辑- The full screen editor of the Commodore 64 8-bit computers was advanced in its market segment for its time. Users could move the cursor over the entire screen area, entering and editing BASIC program lines, as well as direct mode commands. All Commodore 8-bit computers used the PETSCII character set, which included character glyphs suitable for making a TUI.
- Apple's Macintosh Programmer's Workshop programming environment included Commando, a TUI shell. It was the inspiration for BBEdit's shell worksheet.
- Later Apple II models included MouseText, a set of graphical glyphs used for making a TUI.
- The Corvus Concept computer of 1982 used a function key-based text interface on a full-page pivoting display.
See also
编辑- Command-line interface
- Console application
- Natural-language user interface
- Text-based game, a game using a TUI
- VGA text mode
- MDA
Examples of programming libraries
编辑- curses (programming library)
- ncurses
- CDK
- Newt, a widget-based toolkit
- S-Lang
- Turbo Vision
- Early versions of Visual Basic
References
编辑- ^ cmd prompt full screen in Windows 7. Social.technet.microsoft.com. Retrieved on 2013-06-15.
- ^ Warren, Tom. Microsoft unveils Windows Terminal, a new command line app for Windows. The Verge. May 6, 2019.
- ^ OpenVMS RTL Screen Management (SMG$) Manual. hpe.com. 2001 [2021-01-01].
- ^ Wirth, Niklaus; Gutknecht, Jürg. The Oberon System (PDF) (技术报告). ETH Eidgenössische Technische Hochschule Zürich, Institut für Informatik 88. 1988. doi:10.3929/ethz-a-000487176.
|