You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following will place the Ascii art in the centre of your menu. Use these constants to alter the
456
456
alignment:
@@ -479,7 +479,7 @@ The third optional parameter to `addAsciiArt` is alternate text. If the ascii ar
479
479
it will not be displayed at all. However, if you pass a string to the third argument, in the case that the ascii art is too
480
480
wide for the terminal the alternate text will be displayed instead.
481
481
482
-
####Sub Menu Item
482
+
### Sub Menu Item
483
483
484
484
Sub Menus are really powerful! You can add Menus to Menus, whattttt?? You can have your main menu and then an options menu.
485
485
The options item will look like a normal item except when you hit it, you will enter to another menu, which
@@ -545,7 +545,7 @@ In this case `addSubMenu` will return the main menu builder, not the sub menu bu
545
545
The submenu menu item will be an instance of `\PhpSchool\CliMenu\MenuItem\MenuMenuItem`. If you need access to the submenu,
546
546
you can get it via `$menuMenuItem->getSubMenu()`.
547
547
548
-
####Disabling Items & Sub Menus
548
+
### Disabling Items & Sub Menus
549
549
550
550
In this example we are disabling certain items and a submenu but still having them shown in the output.
551
551
@@ -576,7 +576,7 @@ The third param on the `->addItem` call is what disables an item while the `->di
576
576
577
577
The outcome is a full menu with dimmed rows to denote them being disabled. When a user navigates these items are jumped over to the next available selectable item.
578
578
579
-
#####Item Markers
579
+
#### Item Markers
580
580
581
581
The marker displayed by the side of the currently active item can be modified, UTF-8 characters are supported.
582
582
The marker for un-selected items can also be modified. If you want to disable it, just set it to a space character.
@@ -591,7 +591,7 @@ $menu = (new CliMenuBuilder)
591
591
->build();
592
592
```
593
593
594
-
####Item Extra
594
+
### Item Extra
595
595
596
596
You can optionally display some arbitrary text on the right hand side of an item. You can customise this text and
597
597
you indicate which items to display it on. We use it to display `[COMPLETED]` on completed exercises, where the menu lists
@@ -606,12 +606,12 @@ $menu = (new CliMenuBuilder)
606
606
->build();
607
607
```
608
608
609
-
###Menu Methods
609
+
## Menu Methods
610
610
611
611
The next set of documentation applies to methods available directly on the `\PhpSchool\CliMenu\CliMenu` instance. Typically
612
612
you will invoke these methods whilst your menu is open in you action callbacks.
613
613
614
-
####Redrawing the Menu
614
+
### Redrawing the Menu
615
615
616
616
You can modify the menu and its style when executing an action and then you can redraw it! In this example we will toggle the background
617
617
colour in an action.
@@ -654,7 +654,7 @@ $menu = (new CliMenuBuilder)
654
654
$menu->open();
655
655
```
656
656
657
-
####Getting, Removing and Adding items
657
+
### Getting, Removing and Adding items
658
658
659
659
You can also interact with the menu items in an action. You can add, remove and replace items. If you do this, you
660
660
will likely want to redraw the menu as well so the new list is rendered.
@@ -692,7 +692,7 @@ $menu = (new CliMenuBuilder)
692
692
$menu->open();
693
693
```
694
694
695
-
####Custom Control Mapping
695
+
### Custom Control Mapping
696
696
697
697
This functionality allows to map custom key presses to a callable. For example we can set the key press "x" to close the menu:
Show a one line message over the top of the menu. It has a separate style object which is colored by default different
735
735
to the menu. It can be modified to suit your own style. The dialogue is dismissed with any key press. In the example
@@ -758,7 +758,7 @@ $menu = (new CliMenuBuilder)
758
758
$menu->open();
759
759
```
760
760
761
-
#####Confirm
761
+
#### Confirm
762
762
763
763
Prompts are very similar to flashes except that a button is shown which has to be selected to dismiss them. The button
764
764
text can be customised.
@@ -784,7 +784,7 @@ $menu = (new CliMenuBuilder)
784
784
785
785
$menu->open();
786
786
```
787
-
####Inputs
787
+
### Inputs
788
788
789
789
Inputs - added in version 3.0 of `cli-menu` allow to prompt the user for input and validate it. The following types are supported:
790
790
text, number and password. Inputs can be executed in any item callback. They have separate style objects which are colored by default different to the menu.
@@ -795,7 +795,7 @@ instance of the input you requested. To execute the prompt and wait for the inpu
795
795
call `ask()` on the input. When the input has been received and validated, `ask()` will return
796
796
an instance of `InputResult`. `InputResult` exposes the method `fetch` to grab the raw input.
797
797
798
-
#####Text Input
798
+
#### Text Input
799
799
800
800
The text input will prompt for a string and when the enter key is hit it will validate that
801
801
the string is not empty. As well as the style you can modify the prompt text (the default is 'Enter text:'), the
@@ -829,7 +829,7 @@ $menu->open();
829
829
830
830
```
831
831
832
-
#####Number Input
832
+
#### Number Input
833
833
834
834
The number input will prompt for an integer value (signed or not) and when the enter key is hit it will validate that
835
835
the input is actually a number (`/^-?\d+$/`). As well as the style you can modify the prompt text (the default is 'Enter a number:'), the
@@ -865,7 +865,7 @@ $menu->open();
865
865
866
866
```
867
867
868
-
#####Password Input
868
+
#### Password Input
869
869
870
870
The password input will prompt for a text value and when the enter key is hit it will validate that the input is 16 characters or longer.
871
871
As well as the style you can modify the prompt text (the default is 'Enter password:'), the
@@ -983,7 +983,7 @@ $menu->open();
983
983
984
984
```
985
985
986
-
#####Custom Input
986
+
#### Custom Input
987
987
988
988
If you need a new type of input which is not covered by the bundled selection then you can create your own by implementing
989
989
`\PhpSchool\CliMenu\Input\Input` - take a look at existing implementations to see how they are built. If all you need is some custom
@@ -1030,7 +1030,7 @@ $menu->open();
1030
1030
```
1031
1031
1032
1032
1033
-
####Dialogues & Input Styling
1033
+
### Dialogues & Input Styling
1034
1034
1035
1035
All of the dialogues and inputs expose a `getStyle()` method which you can use to customise the appearance of them. However, if
1036
1036
you want to create a consistent style for all your dialogues and inputs without configuring it for each one
@@ -1072,12 +1072,12 @@ Once you get going you might just end up with something that looks a little like
1072
1072
You can see the construction code here for more clarity on how to perform advanced configuration:
0 commit comments