PHPackages                             wapmorgan/ncursesobjects - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wapmorgan/ncursesobjects

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wapmorgan/ncursesobjects
========================

This library implements ncurses functionality in OOP way.

0.9.7(9y ago)364597MITPHP

Since Jan 15Pushed 8y ago2 watchersCompare

[ Source](https://github.com/wapmorgan/NcursesObjects)[ Packagist](https://packagist.org/packages/wapmorgan/ncursesobjects)[ RSS](/packages/wapmorgan-ncursesobjects/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Ncurses Objects
===============

[](#ncurses-objects)

This is a php library that provides ncurses functionality in OOP interface.

[![Composer package](https://camo.githubusercontent.com/75213ba92a5d2b68702b1fab50be733918c0a47b78a5d2fb68441472523e1bd5/687474703a2f2f636f6d706f7365722e6e6574776f726b2f62616467652f7761706d6f7267616e2f6e6375727365736f626a65637473)](https://packagist.org/packages/wapmorgan/ncursesobjects)[![Latest Stable Version](https://camo.githubusercontent.com/192a1364ca078c318af7147cacd8b3a2eea4756259c475933e9e0614a5cd40c9/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f6e6375727365736f626a656374732f762f737461626c65)](https://packagist.org/packages/wapmorgan/ncursesobjects)[![Total Downloads](https://camo.githubusercontent.com/cce0804abd523dac81cab7374f360c897e96bbc2ceab5138125353f42429c2fe/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f6e6375727365736f626a656374732f646f776e6c6f616473)](https://packagist.org/packages/wapmorgan/ncursesobjects)[![License](https://camo.githubusercontent.com/4fcfea170ebef4a08a559f2f61fedda5c9d19c7f15848629cbe33f9c1e33c480/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f6e6375727365736f626a656374732f6c6963656e7365)](https://packagist.org/packages/wapmorgan/ncursesobjects)[![Latest Unstable Version](https://camo.githubusercontent.com/ea2c1204e6e1a6ed977cd66c4875ce21896cb30b54c6dc88c9cdd295c94f6517/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f6e6375727365736f626a656374732f762f756e737461626c65)](https://packagist.org/packages/wapmorgan/ncursesobjects)

1. Basics
2. Installation
3. Simple application example
4. API
5. Installation of ncurses binding

Basics
======

[](#basics)

[![Structure](Structure.png)](Structure.png)

1. There's 4 main classes:

    1. **Ncurses** - main object to act with Ncurses.
    2. **Window** - an object that represents a ncurses windows.
    3. **Panel** - an object that represents a window panels.
    4. **Terminal** - an object to act with Terminal

    And 4 additional classes:

    1. **Colors** - all colors available in Ncurses
    2. **Keys** - all keys
    3. **MouseEvents** - all events from Mouse
    4. **WindowStyle** - a helper to create style of windows
2. How it works:

    1. ncurses initiation
    2. windows making &amp; filling with text
    3. refresh() calling
    4. go to step **2**
3. Read comments and see examples
4. Ncurses in PHP tutorial:  ([on russian](http://habrahabr.ru/post/186570/)).
5. Ncurses tutorial: , docs:

Installation
============

[](#installation)

Install it via Composer:

```
composer require wapmorgan/ncursesobjects dev-master

```

Simple application example
==========================

[](#simple-application-example)

1. Create the main object and setup it

    ```
    $ncurses = new Ncurses;
    $ncurses
    	->setEchoState(false)
    	->setNewLineTranslationState(true)
    	->setCursorState(Ncurses::CURSOR_INVISIBLE)
    	->refresh();
    ```
2. Create the main window

    ```
    $mainWindow = new Window;
    $mainWindow
    	->border()
    	->title('Hello! Today is '.date('d.m.Y'))
    	->refresh();
    ```
3. Create a small window 10x10 in the center of the main window

    ```
    $window = Window::createCenteredOf($mainWindow, 10, 10);
    $window
    	->border()
    	->moveCursor(3, 4)
    	->drawStringHere('OK!')
    	->refresh();
    ```
4. Wait for input to see windows

    ```
    while (true) {
    	$ncurses->inputChar();
    sleep(1);
    }
    ```
5. Close ncurses session and clear the screen (you need do it manually if your script should show any data in normal mode)

    ```
    unset($ncurses);
    ```

API
===

[](#api)

Main classes
------------

[](#main-classes)

**Ncurses**

- **\_\_construct()** - Initializes Ncurses session
- **getTerminal()** - Returns an instance of Terminal
- **setEchoState(bool $state)** - Sets echo state
- **setNewLineTranslationState($state)** - Sets nl state
- **setCursorState($state)** - Sets cursor state. Applicable values are:
    - Ncurses::CURSOR\_INVISIBLE
    - Ncurses::CURSOR\_NORMAL
    - Ncurses::CURSOR\_VISIBLE
- **moveOutput($y, $x)** - Moves cursor
- **refresh()** - Refreshes main window
- **beep()** - Beep (makes terminal sound)\*\*
- **getCh()** - Reades a char from keyboard
- **unGetCh($ch)** - Reverse function
- **updatePanels()** - Refreshes the virtual screen to reflect the relations between panels in the stack
- **insertChar($char)** - Inserts a char at current position
- **insertDeleteLines($count)** - Inserts a dl-char
- **\_\_destruct()** - Ends Ncurses session

**Terminal**

- **hasKey($keycode)** - Checks for key
- **hasColors()** - Checks for colors support
- **hasIC()** - Check for insert- and delete-capabilities
- **hasIL()** - Check for line insert- and delete-capabilities
- **allAtributes()** - Returns all terminal attributes
- **termName()** - Returns short name of terminal
- **longName()** - Returns full name of terminal

**Window**

- **\_\_construct($columns = 0, $rows = 0, $x = 0, $y = 0)** - Creates a new window
- **static createCenteredOf(Window $parentWindow, $columns, $rows)** - Creates a new window placed in the center of another window
- **getWindow()** - Returns raw ncurses resource
- **getSize(&amp;$columns, &amp;$rows)** - Returns array with size and fill arguments with window size
- **border($left = 0, $right = 0, $top = 0, $bottom = 0, $tl\_corner = 0, $tr\_corner = 0, $bl\_corner = 0, $br\_corner = 0)** - Draws a border with different chars
- **borderStyle($style)** - Draws a border with one of styles
- **refresh()** - Refreshes window
- **title($title)** - Draws a window title
- **status($status)** - Draws a window status
- **erase()** - Erases window
- **moveCursor($x, $y)** - Moves cursor
- **drawStringHere($string, $attributes = 0)** - Draws string with attributes
- **makePanel()** - Creates a new panel of this window
- **getPanel()** - Returns panel of this window

**Panel**

- show() - Shows a panel
- hide() - Hides panel
- putOnTop() - Puts panel on top
- putOnBottom() - Puts panel on bottom

Additional classes
------------------

[](#additional-classes)

**Colors**

- **Colors::COLOR\_BLACK**
- **Colors::COLOR\_WHITE**
- **Colors::COLOR\_RED**
- **Colors::COLOR\_GREEN**
- **Colors::COLOR\_YELLOW**
- **Colors::COLOR\_BLUE**
- **Colors::COLOR\_CYAN**
- **Colors::COLOR\_MAGENTA**

**Keys**

- **Keys::KEY\_F1**
- **Keys::KEY\_F2**
- **Keys::KEY\_F3**
- **Keys::KEY\_F4**
- **Keys::KEY\_F5**
- **Keys::KEY\_F6**
- **Keys::KEY\_F7**
- **Keys::KEY\_F8**
- **Keys::KEY\_F9**
- **Keys::KEY\_F10**
- **Keys::KEY\_F11**
- **Keys::KEY\_F12**
- **Keys::KEY\_F13**
- **Keys::KEY\_F14**
- **Keys::KEY\_F15**
- **Keys::KEY\_F16**
- **Keys::KEY\_F17**
- **Keys::KEY\_F18**
- **Keys::KEY\_F19**
- **Keys::KEY\_F20**
- **Keys::KEY\_F21**
- **Keys::KEY\_F22**
- **Keys::KEY\_F23**
- **Keys::KEY\_F24**
- **Keys::KEY\_F25**
- **Keys::KEY\_F26**
- **Keys::KEY\_F27**
- **Keys::KEY\_F28**
- **Keys::KEY\_F29**
- **Keys::KEY\_F30**
- **Keys::KEY\_F31**
- **Keys::KEY\_F32**
- **Keys::KEY\_F33**
- **Keys::KEY\_F34**
- **Keys::KEY\_F35**
- **Keys::KEY\_F36**
- **Keys::KEY\_F37**
- **Keys::KEY\_F38**
- **Keys::KEY\_F39**
- **Keys::KEY\_F40**
- **Keys::KEY\_F41**
- **Keys::KEY\_F42**
- **Keys::KEY\_F43**
- **Keys::KEY\_F44**
- **Keys::KEY\_F45**
- **Keys::KEY\_F46**
- **Keys::KEY\_F47**
- **Keys::KEY\_F48**
- **Keys::KEY\_F49**
- **Keys::KEY\_F50**
- **Keys::KEY\_F51**
- **Keys::KEY\_F52**
- **Keys::KEY\_F53**
- **Keys::KEY\_F54**
- **Keys::KEY\_F55**
- **Keys::KEY\_F56**
- **Keys::KEY\_F57**
- **Keys::KEY\_F58**
- **Keys::KEY\_F59**
- **Keys::KEY\_F60**
- **Keys::KEY\_F61**
- **Keys::KEY\_F62**
- **Keys::KEY\_F63**
- **Keys::KEY\_F64**
- **Keys::KEY\_LEFT**
- **Keys::KEY\_RIGHT**
- **Keys::KEY\_HOME**
- **Keys::KEY\_BACKSPACE**
- **Keys::KEY\_DL**
- **Keys::KEY\_IL**
- **Keys::KEY\_DC**
- **Keys::KEY\_IC**
- **Keys::KEY\_EIC**
- **Keys::KEY\_CLEAR**
- **Keys::KEY\_EOS**
- **Keys::KEY\_EOL**
- **Keys::KEY\_SF**
- **Keys::KEY\_SR**
- **Keys::KEY\_NPAGE**
- **Keys::KEY\_PPAGE**
- **Keys::KEY\_STAB**
- **Keys::KEY\_CTAB**
- **Keys::KEY\_CATAB**
- **Keys::KEY\_SRESET**
- **Keys::KEY\_RESET**
- **Keys::KEY\_PRINT**
- **Keys::KEY\_LL**
- **Keys::KEY\_A1**
- **Keys::KEY\_A3**
- **Keys::KEY\_B2**
- **Keys::KEY\_C1**
- **Keys::KEY\_C3**
- **Keys::KEY\_BTAB**
- **Keys::KEY\_BEG**
- **Keys::KEY\_CANCEL**
- **Keys::KEY\_CLOSE**
- **Keys::KEY\_COMMAND**
- **Keys::KEY\_COPY**
- **Keys::KEY\_CREATE**
- **Keys::KEY\_END**
- **Keys::KEY\_EXIT**
- **Keys::KEY\_FIND**
- **Keys::KEY\_HELP**
- **Keys::KEY\_MARK**
- **Keys::KEY\_MESSAGE**
- **Keys::KEY\_MOVE**
- **Keys::KEY\_NEXT**
- **Keys::KEY\_OPEN**
- **Keys::KEY\_OPTIONS**
- **Keys::KEY\_PREVIOUS**
- **Keys::KEY\_REDO**
- **Keys::KEY\_REFERENCE**
- **Keys::KEY\_REFRESH**
- **Keys::KEY\_REPLACE**
- **Keys::KEY\_RESTART**
- **Keys::KEY\_RESUME**
- **Keys::KEY\_SAVE**
- **Keys::KEY\_SBEG**
- **Keys::KEY\_SCANCEL**
- **Keys::KEY\_SCOMMAND**
- **Keys::KEY\_SCOPY**
- **Keys::KEY\_SCREATE**
- **Keys::KEY\_SDC**
- **Keys::KEY\_SDL**
- **Keys::KEY\_SELECT**
- **Keys::KEY\_SEND**
- **Keys::KEY\_SEOL**
- **Keys::KEY\_SEXIT**
- **Keys::KEY\_SFIND**
- **Keys::KEY\_SHELP**
- **Keys::KEY\_SHOME**
- **Keys::KEY\_SIC**
- **Keys::KEY\_SLEFT**
- **Keys::KEY\_SMESSAGE**
- **Keys::KEY\_SMOVE**
- **Keys::KEY\_SNEXT**
- **Keys::KEY\_SOPTIONS**
- **Keys::KEY\_SPREVIOUS**
- **Keys::KEY\_SPRINT**
- **Keys::KEY\_SREDO**
- **Keys::KEY\_SREPLACE**
- **Keys::KEY\_SRIGHT**
- **Keys::KEY\_SRSUME**
- **Keys::KEY\_SSAVE**
- **Keys::KEY\_SSUSPEND**
- **Keys::KEY\_UNDO**
- **Keys::KEY\_MOUSE**
- **Keys::KEY\_MAX**
- **Keys::KEY\_LF**
- **Keys::KEY\_CR**
- **Keys::KEY\_ESC**
- **Keys::KEY\_TAB**

**MouseEvents**

- **MouseEvents::BUTTON1\_RELEASED**
- **MouseEvents::BUTTON2\_RELEASED**
- **MouseEvents::BUTTON3\_RELEASED**
- **MouseEvents::BUTTON4\_RELEASED**
- **MouseEvents::BUTTON1\_PRESSED**
- **MouseEvents::BUTTON2\_PRESSED**
- **MouseEvents::BUTTON3\_PRESSED**
- **MouseEvents::BUTTON4\_PRESSED**
- **MouseEvents::BUTTON1\_CLICKED**
- **MouseEvents::BUTTON2\_CLICKED**
- **MouseEvents::BUTTON3\_CLICKED**
- **MouseEvents::BUTTON4\_CLICKED**
- **MouseEvents::BUTTON1\_DOUBLE\_CLICKED**
- **MouseEvents::BUTTON2\_DOUBLE\_CLICKED**
- **MouseEvents::BUTTON3\_DOUBLE\_CLICKED**
- **MouseEvents::BUTTON4\_DOUBLE\_CLICKED**
- **MouseEvents::BUTTON1\_TRIPLE\_CLICKED**
- **MouseEvents::BUTTON2\_TRIPLE\_CLICKED**
- **MouseEvents::BUTTON3\_TRIPLE\_CLICKED**
- **MouseEvents::BUTTON4\_TRIPLE\_CLICKED**
- **MouseEvents::BUTTON\_CTRL**
- **MouseEvents::BUTTON\_SHIFT**
- **MouseEvents::BUTTON\_ALT**
- **MouseEvents::ALL\_MOUSE\_EVENTS**
- **MouseEvents::REPORT\_MOUSE\_POSITION**

Installation of ncurses binding
===============================

[](#installation-of-ncurses-binding)

1. Install pecl. It is in a package named `php5-dev` in Ubuntu (`php-pear` in ArchLinux)
2. Install the ncurses binding.

    ```
    sudo pecl install ncurses

    ```
3. Include the php extension. Add follows in your php.ini:

    ```
    extension=ncurses.so

    ```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3410d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6000618?v=4)[Sergey](/maintainers/wapmorgan)[@wapmorgan](https://github.com/wapmorgan)

---

Top Contributors

[![wapmorgan](https://avatars.githubusercontent.com/u/6000618?v=4)](https://github.com/wapmorgan "wapmorgan (16 commits)")

### Embed Badge

![Health badge](/badges/wapmorgan-ncursesobjects/health.svg)

```
[![Health](https://phpackages.com/badges/wapmorgan-ncursesobjects/health.svg)](https://phpackages.com/packages/wapmorgan-ncursesobjects)
```

###  Alternatives

[dholmes/bga-workbench

BoardGameArena Workbench

375.3k](/packages/dholmes-bga-workbench)[limingxinleo/x-phalcon-enum

a phalcon enum component

104.4k1](/packages/limingxinleo-x-phalcon-enum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
