PHP Class PhpSchool\CliMenu\CliMenu

Author: Michael Woodward ([email protected])
Afficher le fichier Open project: php-school/cli-menu Class Usage Examples

Protected Properties

Свойство Type Description
$items PhpSchool\CliMenu\MenuItem\MenuItemInterface[]
$open boolean
$parent CliMenu | null
$selectedItem integer
$style MenuStyle
$terminal PhpSchool\CliMenu\Terminal\TerminalInterface
$title string

Méthodes publiques

Méthode Description
__construct ( string $title, array $items, PhpSchool\CliMenu\Terminal\TerminalInterface $terminal = null, MenuStyle $style = null )
addItem ( PhpSchool\CliMenu\MenuItem\MenuItemInterface $item ) Add a new Item to the listing
close ( ) Close the menu
closeThis ( )
confirm ( string $text ) : Confirm
flash ( string $text ) : Flash
getCurrentFrame ( )
getItems ( ) : PhpSchool\CliMenu\MenuItem\MenuItemInterface[]
getParent ( ) : CliMenu | null
getSelectedItem ( ) : PhpSchool\CliMenu\MenuItem\MenuItemInterface
getStyle ( ) : MenuStyle
getTerminal ( ) : PhpSchool\CliMenu\Terminal\TerminalInterface
isOpen ( ) : boolean
open ( )
redraw ( ) Redraw the menu
removeItem ( PhpSchool\CliMenu\MenuItem\MenuItemInterface $item )
setParent ( CliMenu $parent )

Méthodes protégées

Méthode Description
configureTerminal ( ) Configure the terminal to work with CliMenu
draw ( ) Draw the menu to STDOUT
drawMenuItem ( PhpSchool\CliMenu\MenuItem\MenuItemInterface $item, boolean | false $selected = false ) : array Draw a menu item
executeCurrentItem ( ) Execute the current item
moveSelection ( $direction ) Move the selection in a given direction, up / down
tearDownTerminal ( ) Revert changes made to the terminal

Private Methods

Méthode Description
assertTerminalIsValidTTY ( )
display ( ) Display menu and capture input
selectFirstItem ( ) Set the selected pointer to the first selectable item

Method Details

__construct() public méthode

public __construct ( string $title, array $items, PhpSchool\CliMenu\Terminal\TerminalInterface $terminal = null, MenuStyle $style = null )
$title string
$items array
$terminal PhpSchool\CliMenu\Terminal\TerminalInterface
$style MenuStyle

addItem() public méthode

Add a new Item to the listing
public addItem ( PhpSchool\CliMenu\MenuItem\MenuItemInterface $item )
$item PhpSchool\CliMenu\MenuItem\MenuItemInterface

close() public méthode

Close the menu
public close ( )

closeThis() public méthode

public closeThis ( )

configureTerminal() protected méthode

Configure the terminal to work with CliMenu
protected configureTerminal ( )

confirm() public méthode

public confirm ( string $text ) : Confirm
$text string
Résultat PhpSchool\CliMenu\Dialogue\Confirm

draw() protected méthode

Draw the menu to STDOUT
protected draw ( )

drawMenuItem() protected méthode

Draw a menu item
protected drawMenuItem ( PhpSchool\CliMenu\MenuItem\MenuItemInterface $item, boolean | false $selected = false ) : array
$item PhpSchool\CliMenu\MenuItem\MenuItemInterface
$selected boolean | false
Résultat array

executeCurrentItem() protected méthode

Execute the current item
protected executeCurrentItem ( )

flash() public méthode

public flash ( string $text ) : Flash
$text string
Résultat PhpSchool\CliMenu\Dialogue\Flash

getCurrentFrame() public méthode

public getCurrentFrame ( )

getItems() public méthode

public getItems ( ) : PhpSchool\CliMenu\MenuItem\MenuItemInterface[]
Résultat PhpSchool\CliMenu\MenuItem\MenuItemInterface[]

getParent() public méthode

public getParent ( ) : CliMenu | null
Résultat CliMenu | null

getSelectedItem() public méthode

public getSelectedItem ( ) : PhpSchool\CliMenu\MenuItem\MenuItemInterface
Résultat PhpSchool\CliMenu\MenuItem\MenuItemInterface

getStyle() public méthode

public getStyle ( ) : MenuStyle
Résultat MenuStyle

getTerminal() public méthode

public getTerminal ( ) : PhpSchool\CliMenu\Terminal\TerminalInterface
Résultat PhpSchool\CliMenu\Terminal\TerminalInterface

isOpen() public méthode

public isOpen ( ) : boolean
Résultat boolean

moveSelection() protected méthode

Move the selection in a given direction, up / down
protected moveSelection ( $direction )
$direction

open() public méthode

public open ( )

redraw() public méthode

Redraw the menu
public redraw ( )

removeItem() public méthode

public removeItem ( PhpSchool\CliMenu\MenuItem\MenuItemInterface $item )
$item PhpSchool\CliMenu\MenuItem\MenuItemInterface

setParent() public méthode

public setParent ( CliMenu $parent )
$parent CliMenu

tearDownTerminal() protected méthode

Revert changes made to the terminal
protected tearDownTerminal ( )

Property Details

$items protected_oe property

protected MenuItemInterface[],PhpSchool\CliMenu\MenuItem $items
Résultat PhpSchool\CliMenu\MenuItem\MenuItemInterface[]

$open protected_oe property

protected bool $open
Résultat boolean

$parent protected_oe property

protected CliMenu,PhpSchool\CliMenu|null $parent
Résultat CliMenu | null

$selectedItem protected_oe property

protected int $selectedItem
Résultat integer

$style protected_oe property

protected MenuStyle,PhpSchool\CliMenu $style
Résultat MenuStyle

$terminal protected_oe property

protected TerminalInterface,PhpSchool\CliMenu\Terminal $terminal
Résultat PhpSchool\CliMenu\Terminal\TerminalInterface

$title protected_oe property

protected string $title
Résultat string