Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Newt Functions

Newt Functions

Introduction

This is a PHP language extension for RedHat Newt library, a terminal-based window and widget library for writing applications with user friendly interface. Once this extension is enabled in PHP it will provide the use of Newt widgets, such as windows, buttons, checkboxes, radiobuttons, labels, editboxes, scrolls, textareas, scales, etc. Use of this extension if very similar to the original Newt API of C programming language.

Requirements

This module uses the functions of the RedHat Newt library. You need libnewt version >= 0.51.0.

Installation

This ğ PECL extension is not bundled with PHP. Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: ğ http://pecl.php.net/package/newt.

In PHP 4 this PECL extensions source can be found in the ext/ directory within the PHP source or at the PECL link above. In order to use these functions you must compile CGI or CLI PHP with newt support by using the --with-newt[=DIR] configure option.

Note:

This extension is not available for Windows platform.

You may need also curses and slang libraries, in order to compile this extension. To specify locations of these libraries, use the following configuration options: --with-curses-dir=/path/to/libcurses --with-slang-dir=/path/to/libslang

Resource Types

This extension uses two resource types: "newt component" and "newt grid". Resource type "newt component" is returned by functions, which create common newt widgets (for example: newt_button()) Resource type "newt grid" is a special link identifier for components, returned by newt grid factory functions (for example: newt_create_grid())

Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

Newt form exit reasons

Table 208. Newt form exit reasons

constant meaning
NEWT_EXIT_HOTKEY hotkey defined by newt_form_add_hot_key() was pressed
NEWT_EXIT_COMPONENT some component has caused form to exit
NEWT_EXIT_FDREADY file descriptor specified in newt_form_watch_fd() is ready to be read or written to
NEWT_EXIT_TIMER time specified in newt_form_set_timer() has elapsed


Newt colorsets

Table 209. Newt colorsets

constant meaning
NEWT_COLORSET_ROOT  
NEWT_COLORSET_BORDER  
NEWT_COLORSET_WINDOW  
NEWT_COLORSET_SHADOW  
NEWT_COLORSET_TITLE  
NEWT_COLORSET_BUTTON  
NEWT_COLORSET_ACTBUTTON  
NEWT_COLORSET_CHECKBOX  
NEWT_COLORSET_ACTCHECKBOX  
NEWT_COLORSET_ENTRY  
NEWT_COLORSET_LABEL  
NEWT_COLORSET_LISTBOX  
NEWT_COLORSET_ACTLISTBOX  
NEWT_COLORSET_TEXTBOX  
NEWT_COLORSET_ACTTEXTBOX  
NEWT_COLORSET_HELPLINE  
NEWT_COLORSET_ROOTTEXT  
NEWT_COLORSET_ROOTTEXT  
NEWT_COLORSET_EMPTYSCALE  
NEWT_COLORSET_FULLSCALE  
NEWT_COLORSET_DISENTRY  
NEWT_COLORSET_COMPACTBUTTON  
NEWT_COLORSET_ACTSELLISTBOX  
NEWT_COLORSET_SELLISTBOX  


Newt argument flags

Table 210. Newt argument flags

constant meaning
NEWT_ARG_LAST  
NEWT_ARG_APPEND  


Newt Flags Sense

Table 211. Newt Flags Sense

constant meaning
NEWT_FLAGS_SET  
NEWT_FLAGS_RESET  
NEWT_FLAGS_TOGGLE  


Newt Components Flags

Table 212. Newt Components Flags

constant meaning
NEWT_FLAG_RETURNEXIT Exit form, when component is activated
NEWT_FLAG_HIDDEN Component is hidden
NEWT_FLAG_SCROLL Component is scrollable
NEWT_FLAG_DISABLED Component is disabled
NEWT_FLAG_BORDER  
NEWT_FLAG_WRAP Wrap text
NEWT_FLAG_NOF12 Don't exit form on pressing F12
NEWT_FLAG_MULTIPLE  
NEWT_FLAG_SELECTED Component is selected
NEWT_FLAG_CHECKBOX Component is checkbox
NEWT_FLAG_PASSWORD Entry component is password entry
NEWT_FLAG_SHOWCURSOR Show cursor


File Descriptor Flags

Table 213. File Descriptor Flags

constant meaning
NEWT_FD_READ  
NEWT_FD_WRITE  
NEWT_FD_EXCEPT  


Checkbox Tree Flags

Table 214. Checkbox Tree Flags

constant meaning
NEWT_CHECKBOXTREE_UNSELECTABLE  
NEWT_CHECKBOXTREE_HIDE_BOX  
NEWT_CHECKBOXTREE_COLLAPSED  
NEWT_CHECKBOXTREE_EXPANDED  
NEWT_CHECKBOXTREE_UNSELECTED  
NEWT_CHECKBOXTREE_SELECTED  


Entry Flags

Table 215. Entry Flags

constant meaning
NEWT_ENTRY_SCROLL  
NEWT_ENTRY_HIDDEN  
NEWT_ENTRY_RETURNEXIT  
NEWT_ENTRY_DISABLED  


Listbox Flags

Table 216. Listbox Flags

constant meaning
NEWT_LISTBOX_RETURNEXIT  


Textbox Flags

Table 217. Textbox Flags

constant meaning
NEWT_TEXTBOX_WRAP Wrap text in the textbox
NEWT_TEXTBOX_SCROLL Scroll text in the textbox


Form Flags

Table 218. Form Flags

constant meaning
NEWT_FORM_NOF12 Don't exit form on F12 press


Newt Keys

Table 219. Newt Keys

constant meaning
NEWT_KEY_TAB  
NEWT_KEY_ENTER  
NEWT_KEY_SUSPEND  
NEWT_KEY_ESCAPE  
NEWT_KEY_RETURN  
NEWT_KEY_EXTRA_BASE  
NEWT_KEY_UP  
NEWT_KEY_DOWN  
NEWT_KEY_LEFT  
NEWT_KEY_RIGHT  
NEWT_KEY_BKSPC  
NEWT_KEY_DELETE  
NEWT_KEY_HOME  
NEWT_KEY_END  
NEWT_KEY_UNTAB  
NEWT_KEY_PGUP  
NEWT_KEY_PGDN  
NEWT_KEY_INSERT  
NEWT_KEY_F1  
NEWT_KEY_F2  
NEWT_KEY_F3  
NEWT_KEY_F4  
NEWT_KEY_F5  
NEWT_KEY_F6  
NEWT_KEY_F7  
NEWT_KEY_F8  
NEWT_KEY_F9  
NEWT_KEY_F10  
NEWT_KEY_F11  
NEWT_KEY_F12  
NEWT_KEY_RESIZE  


Newt Anchors

Table 220. Newt Anchors

constant meaning
NEWT_ANCHOR_LEFT  
NEWT_ANCHOR_RIGHT  
NEWT_ANCHOR_TOP  
NEWT_ANCHOR_BOTTOM  


Grid Flags

Table 221. Grid Flags

constant meaning
NEWT_GRID_FLAG_GROWX  
NEWT_GRID_FLAG_GROWY  
NEWT_GRID_EMPTY  
NEWT_GRID_COMPONENT  
NEWT_GRID_SUBGRID  


Examples

This example is a PHP port of RedHat 'setup' utility dialog, executed in text mode.

Example 1613. Newt Usage Example

<?php
   newt_init
();
   
newt_cls ();

   
newt_draw_root_text (0, 0, "Test Mode Setup Utility 1.12");
   
newt_push_help_line (null);
   
newt_draw_root_text (-30, 0, "(c) 1999-2002 RedHat, Inc");

   
newt_get_screen_size (&$rows, &$cols);

   
newt_open_window ($rows/2-17, $cols/2-10, 34, 17, "Choose a Tool");

   
$form = newt_form ();

   
$list = newt_listbox (3, 2, 10);

   foreach (array (
       
"Authentication configuration",
       
"Firewall configuration",
       
"Mouse configuration",
       
"Network configuration",
       
"Printer configuration",
       
"System services") as $l_item)
   {
       
newt_listbox_add_entry ($list, $l_item, $l_item);
   }

   
$b1 = newt_button (5, 12, "Run Tool");
   
$b2 = newt_button (21, 12, "Quit");

   
newt_form_add_component ($form, $list);
   
newt_form_add_components ($form, array($b1, $b2));

   
newt_refresh ();
   
newt_run_form ($form);

   
newt_pop_window ();
   
newt_pop_help_line ();
   
newt_finished ();
   
newt_form_destroy ($form);
?>


Table of Contents

newt_bell — Send a beep to the terminal
newt_button_bar — This function returns a grid containing the buttons created.
newt_button — Create a new button
newt_centered_window — Open a centered window of the specified size
newt_checkbox_get_value — Retreives value of checkox resource
newt_checkbox_set_flags — Configures checkbox resource
newt_checkbox_set_value — Sets the value of the checkbox
newt_checkbox_tree_add_item — Adds new item to the checkbox tree
newt_checkbox_tree_find_item — Finds an item in the checkbox tree
newt_checkbox_tree_get_current — Returns checkbox tree selected item
newt_checkbox_tree_get_entry_value
newt_checkbox_tree_get_multi_selection
newt_checkbox_tree_get_selection
newt_checkbox_tree_multi
newt_checkbox_tree_set_current
newt_checkbox_tree_set_entry_value
newt_checkbox_tree_set_entry
newt_checkbox_tree_set_width
newt_checkbox_tree
newt_checkbox
newt_clear_key_buffer — Discards the contents of the terminal's input buffer without waiting for additional input
newt_cls
newt_compact_button
newt_component_add_callback
newt_component_takes_focus
newt_create_grid
newt_cursor_off
newt_cursor_on
newt_delay
newt_draw_form
newt_draw_root_text — Displays the string text at the position indicated
newt_entry_get_value
newt_entry_set_filter
newt_entry_set_flags
newt_entry_set
newt_entry
newt_finished — Uninitializes newt interface
newt_form_add_component — Adds a single component to the form
newt_form_add_components — Add several components to the form
newt_form_add_hot_key
newt_form_destroy — Destroys a form
newt_form_get_current
newt_form_run — Runs a form
newt_form_set_background
newt_form_set_height
newt_form_set_size
newt_form_set_timer
newt_form_set_width
newt_form_watch_fd
newt_form — Create a form
newt_get_screen_size — Fills in the passed references with the current size of the terminal
newt_grid_add_components_to_form
newt_grid_basic_window
newt_grid_free
newt_grid_get_size
newt_grid_h_close_stacked
newt_grid_h_stacked
newt_grid_place
newt_grid_set_field
newt_grid_simple_window
newt_grid_v_close_stacked
newt_grid_v_stacked
newt_grid_wrapped_window_at
newt_grid_wrapped_window
newt_init — Initialize newt
newt_label_set_text
newt_label
newt_listbox_append_entry
newt_listbox_clear_selection
newt_listbox_clear
newt_listbox_delete_entry
newt_listbox_get_current
newt_listbox_get_selection
newt_listbox_insert_entry
newt_listbox_item_count
newt_listbox_select_item
newt_listbox_set_current_by_key
newt_listbox_set_current
newt_listbox_set_data
newt_listbox_set_entry
newt_listbox_set_width
newt_listbox
newt_listitem_get_data
newt_listitem_set
newt_listitem
newt_open_window — Open a window of the specified size and position
newt_pop_help_line — Replaces the current help line with the one from the stack
newt_pop_window — Removes the top window from the display
newt_push_help_line — Saves the current help line on a stack, and displays the new line
newt_radio_get_current
newt_radiobutton
newt_redraw_help_line
newt_reflow_text
newt_refresh — Updates modified portions of the screen
newt_resize_screen
newt_resume — Resume using the newt interface after calling newt_suspend()
newt_run_form — Runs a form
newt_scale_set
newt_scale
newt_scrollbar_set
newt_set_help_callback
newt_set_suspend_callback — Set a callback function which gets invoked when user presses the suspend key
newt_suspend — Tells newt to return the terminal to its initial state
newt_textbox_get_num_lines
newt_textbox_reflowed
newt_textbox_set_height
newt_textbox_set_text
newt_textbox
newt_vertical_scrollbar
newt_wait_for_key — Doesn't return until a key has been pressed
newt_win_choice
newt_win_entries
newt_win_menu
newt_win_message
newt_win_messagev
newt_win_ternary

Change Language


Follow Navioo On Twitter
.NET Functions
Apache-specific Functions
Alternative PHP Cache
Advanced PHP debugger
Array Functions
Aspell functions [deprecated]
BBCode Functions
BCMath Arbitrary Precision Mathematics Functions
PHP bytecode Compiler
Bzip2 Compression Functions
Calendar Functions
CCVS API Functions [deprecated]
Class/Object Functions
Classkit Functions
ClibPDF Functions [deprecated]
COM and .Net (Windows)
Crack Functions
Character Type Functions
CURL
Cybercash Payment Functions
Credit Mutuel CyberMUT functions
Cyrus IMAP administration Functions
Date and Time Functions
DB++ Functions
Database (dbm-style) Abstraction Layer Functions
dBase Functions
DBM Functions [deprecated]
dbx Functions
Direct IO Functions
Directory Functions
DOM Functions
DOM XML Functions
enchant Functions
Error Handling and Logging Functions
Exif Functions
Expect Functions
File Alteration Monitor Functions
Forms Data Format Functions
Fileinfo Functions
filePro Functions
Filesystem Functions
Filter Functions
Firebird/InterBase Functions
Firebird/Interbase Functions (PDO_FIREBIRD)
FriBiDi Functions
FrontBase Functions
FTP Functions
Function Handling Functions
GeoIP Functions
Gettext Functions
GMP Functions
gnupg Functions
Net_Gopher
Haru PDF Functions
hash Functions
HTTP
Hyperwave Functions
Hyperwave API Functions
i18n Functions
IBM Functions (PDO_IBM)
IBM DB2
iconv Functions
ID3 Functions
IIS Administration Functions
Image Functions
Imagick Image Library
IMAP
Informix Functions
Informix Functions (PDO_INFORMIX)
Ingres II Functions
IRC Gateway Functions
PHP / Java Integration
JSON Functions
KADM5
LDAP Functions
libxml Functions
Lotus Notes Functions
LZF Functions
Mail Functions
Mailparse Functions
Mathematical Functions
MaxDB PHP Extension
MCAL Functions
Mcrypt Encryption Functions
MCVE (Monetra) Payment Functions
Memcache Functions
Mhash Functions
Mimetype Functions
Ming functions for Flash
Miscellaneous Functions
mnoGoSearch Functions
Microsoft SQL Server Functions
Microsoft SQL Server and Sybase Functions (PDO_DBLIB)
Mohawk Software Session Handler Functions
mSQL Functions
Multibyte String Functions
muscat Functions
MySQL Functions
MySQL Functions (PDO_MYSQL)
MySQL Improved Extension
Ncurses Terminal Screen Control Functions
Network Functions
Newt Functions
NSAPI-specific Functions
Object Aggregation/Composition Functions
Object property and method call overloading
Oracle Functions
ODBC Functions (Unified)
ODBC and DB2 Functions (PDO_ODBC)
oggvorbis
OpenAL Audio Bindings
OpenSSL Functions
Oracle Functions [deprecated]
Oracle Functions (PDO_OCI)
Output Control Functions
Ovrimos SQL Functions
Paradox File Access
Parsekit Functions
Process Control Functions
Regular Expression Functions (Perl-Compatible)
PDF Functions
PDO Functions
Phar archive stream and classes
PHP Options&Information
POSIX Functions
Regular Expression Functions (POSIX Extended)
PostgreSQL Functions
PostgreSQL Functions (PDO_PGSQL)
Printer Functions
Program Execution Functions
PostScript document creation
Pspell Functions
qtdom Functions
Radius
Rar Functions
GNU Readline
GNU Recode Functions
RPM Header Reading Functions
runkit Functions
SAM - Simple Asynchronous Messaging
Satellite CORBA client extension [deprecated]
SCA Functions
SDO Functions
SDO XML Data Access Service Functions
SDO Relational Data Access Service Functions
Semaphore
SESAM Database Functions
PostgreSQL Session Save Handler
Session Handling Functions
Shared Memory Functions
SimpleXML functions
SNMP Functions
SOAP Functions
Socket Functions
Standard PHP Library (SPL) Functions
SQLite Functions
SQLite Functions (PDO_SQLITE)
Secure Shell2 Functions
Statistics Functions
Stream Functions
String Functions
Subversion Functions
Shockwave Flash Functions
Swish Functions
Sybase Functions
TCP Wrappers Functions
Tidy Functions
Tokenizer Functions
Unicode Functions
URL Functions
Variable Handling Functions
Verisign Payflow Pro Functions
vpopmail Functions
W32api Functions
WDDX Functions
win32ps Functions
win32service Functions
xattr Functions
xdiff Functions
XML Parser Functions
XML-RPC Functions
XMLReader functions
XMLWriter Functions
XSL functions
XSLT Functions
YAZ Functions
YP/NIS Functions
Zip File Functions
Zlib Compression Functions
eXTReMe Tracker