NAME
TUI::Manual::02 - Getting Started with TUI::Vision
GETTING STARTED
This chapter introduces the basic steps required to create and run a TUI::Vision application.
Unlike the previous chapter, which focused on the history and design goals of the framework, the purpose of this chapter is entirely practical. By the end, you will have seen how a TUI::Vision application is installed, created and executed.
Installation
TUI::Vision is distributed through CPAN and can be installed using the standard Perl toolchain.
Using cpan:
cpan TUI::Vision
Using cpanm:
cpanm TUI::Vision
Once installed, all framework modules become available through the normal Perl module search path.
A Minimal Application
At its core, every TUI::Vision program is built around an instance of TApplication.
The smallest useful application consists of little more than the application object itself:
use TUI::App;
my $app = TApplication->new();
$app->run();
Although this example appears simple, it already demonstrates the basic structure shared by all TUI::Vision programs.
The application object acts as the central coordinator for the user interface and is responsible for creating and managing the framework's major components.
Running an Application
When the application is started, several things happen automatically.
First, the application object is created:
my $app = TApplication->new();
Execution then enters the application's main event loop:
$app->run();
While the event loop is active, TUI::Vision is responsible for receiving user input, updating views, processing commands and managing the application's windows and dialogs.
The application typically remains inside this loop until the user selects an action that terminates the program.
From a conceptual point of view, the life cycle can be represented as follows:
Application Startup
|
v
TApplication
|
v
run()
|
v
Event Loop
|
v
Application Exit
The event system itself is discussed in detail in a later chapter.
The Application Object
TApplication occupies a central position within the framework.
Most applications contain exactly one instance of TApplication, which acts as the root of the user interface hierarchy.
A typical application consists of the following permanent objects:
TApplication
|
+-- TMenuBar
|
+-- TDeskTop
|
+-- TStatusLine
These objects are created and managed by the application itself and remain available throughout the lifetime of the program.
The application object is also responsible for coordinating event processing, view management and application shutdown.
Later chapters examine each of these components in greater detail.
The Desktop
The desktop forms the central workspace of a TUI::Vision application.
Conceptually, the screen is divided into three areas:
┌────────────────────────────────────────────────────┐
| Menu Bar |
|░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|
|░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|
|░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|
|░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|
|░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|
|░░░░░░░░░░░░░░░░░░░░ TDeskTop ░░░░░░░░░░░░░░░░░░░░░░|
|░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|
|░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|
|░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|
|░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|
|░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|
|░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|
| Status Line |
└────────────────────────────────────────────────────┘
The desktop occupies the area between the menu bar and the status line.
Windows and dialogs are inserted into the desktop and operate within this workspace. Throughout the lifetime of the application, windows may appear, disappear, move or resize, while the desktop itself remains in place.
Understanding the role of the desktop is important because almost all visible application objects ultimately exist within its environment.
Conclusion
A TUI::Vision application begins with a TApplication object and executes within the framework's event-driven environment.
Although only a few lines of code are required to create a minimal program, several important framework objects already exist behind the scenes, including the desktop, menu bar and status line.
The next chapter examines the overall architecture of TUI::Vision and introduces the view hierarchy upon which the remainder of the framework is built.
next chapter.