Skip to content

Commit 2946f21

Browse files
committed
Move to gitlab.com
1 parent 4738051 commit 2946f21

27 files changed

+8
-5467
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

CHANGELOG-1.0.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

CHANGELOG-1.1.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

LICENSE

Lines changed: 0 additions & 9 deletions
This file was deleted.

README.md

Lines changed: 8 additions & 232 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
[![Build Status](https://api.travis-ci.org/zerustech/terminal.svg)](https://travis-ci.org/zerustech/terminal)
2-
3-
ZerusTech Terminal Component
4-
================================================
1+
# ZerusTech Terminal Component
52
The *ZerusTech Terminal Component* is a lightweight library for controlling
63
cursor, font styles as well as colors in PHP cli applications. It would be
7-
easier to use the [ncurses][3] library, however, we want to keep its
4+
easier to use the ncurses library, however, we want to keep its
85
dependencies as small as possible, so that it can be used on a broader range of
96
systems.
107

@@ -15,237 +12,16 @@ and other terminals, some tty related commands and topics that we barely touched
1512
before, the terminfo and termcap (which is not supported by this library) as
1613
well as how to parse terminal specifications from a compiled terminfo file.
1714

18-
> This library was inspired by the [hoa/console][1] project, which is great
19-
except that it overlaps [symfony/console][12] in may features and we'd much
15+
> This library was inspired by the hoa/console project, which is great
16+
except that it overlaps symfony/console in may features and we'd much
2017
prefer the latter for CLI application development. Therefore, we re-implemented
2118
the terminal functionalities that are missing from ``symfony/console`` into this
2219
library.
2320

24-
::: info-box note
25-
26-
This library does not support any Windows Platforms!
27-
28-
:::
29-
30-
Installation
31-
-------------
32-
33-
You can install this component in 2 different ways:
34-
35-
* Install it via Composer
36-
```bash
37-
$ cd <project-root-directory>
38-
$ composer require zerustech/terminal
39-
```
40-
41-
* Use the official Git repository (https://github.com/zerustech/terminal)
42-
43-
Examples
44-
-------------
45-
46-
### Creates a terminal instance ###
47-
48-
The terminal class is an abstract of the virtual terminal, so this is the entry
49-
point where you gain access to variant resources.
50-
51-
```php
52-
<?php
53-
54-
require_once __DIR__.'/vendor/autoload.php';
55-
56-
use ZerusTech\Component\Terminal\Terminal;
57-
58-
$terminal = Terminal::instance();
59-
60-
// Or creates a terminal instance for specific tty and terminal names
61-
// $terminal = Terminal::instance('/dev/ttys001', 'ansi');
62-
63-
```
64-
65-
### Cursor ###
66-
67-
Cursor is controlled by the cursor tool, which can be obtained from the terminal
68-
instance. Here is an example of how to manipulate cursor:
69-
70-
```php
71-
<?php
72-
73-
require_once __DIR__.'/vendor/autoload.php';
74-
75-
use ZerusTech\Component\Terminal\Terminal;
76-
77-
$terminal = Terminal::instance(); // Creates a terminal instance
78-
79-
$cursor = $terminal->getCursor(); // Obtains the cursor tool
80-
81-
$cursor->moveTo(30, 40); // Moves cursor to row 30 and column 40.
82-
83-
$position = $cursor->getPosition(); // ['row' => 30,'col' => 40]
84-
85-
$cursor->move('up');
86-
// Moves cursor 1 row upward: (29, 40)
87-
// Valid directions include:
88-
// up, right, down, left, home and bol (beginning of line)
89-
90-
$cursor->save(); // Saves current cursor position: (29, 40)
91-
92-
$cursor->move('up', 2); // Moves cursor 2 rows upward: (27, 40)
93-
94-
$cursor->restore(); // Restores cursor position: (29, 40)
95-
96-
$cursor->hide(); // Hides cursor
97-
98-
$cursor->show(); // Reveals cursor
99-
100-
// Method chaining is also supported
101-
$terminal
102-
->getCursor() // Obtains the cursor tool
103-
->moveTo(30, 40) // Moves to (30, 40)
104-
->move('up') // Moves 1 row upward
105-
->save() // Saves cursor position
106-
->move('up', 2) // Moves 2 rows upward
107-
->restore() // Restores cursor position
108-
->hide() // Hides cursor
109-
->show() // Reveals cursor
110-
->terminal(); // Obtains the terminal instance
111-
112-
```
113-
114-
::: info-box tip
115-
116-
Most methods in this component support method chaining for producing fluent code.
117-
118-
:::
119-
120-
121-
### Screen ###
122-
123-
Screen, font styles and colors are controlled by the screen tool in the terminal
124-
instance. Here is an example of how to use it:
125-
126-
```php
127-
<?php
128-
129-
require_once __DIR__.'/vendor/autoload.php';
130-
131-
use ZerusTech\Component\Terminal\Terminal;
132-
133-
$terminal = Terminal::instance();
134-
135-
$screen = $terminal->getScreen(); // Obtains the screen tool
136-
137-
$screen->clear(); // Clears the full screen.
138-
139-
$screen->clear('bol');
140-
// Clears characters from current cursor position to the beginning of line.
141-
// Valid parts of the clear() method include:
142-
// - all (the default value)
143-
// - bol (beginning of line)
144-
// - eol (end of line)
145-
// - eos (end of screen)
146-
147-
$screen->delete('line'); // Deletes 1 line upward.
148-
149-
$screen->delete('line', 2); // Deletes 2 lines upward.
150-
151-
$screen->delete('character'); // Deletes 1 character rightward.
152-
153-
$screen->delete('character', 2); // Deletes 2 characters rightward.
154-
155-
$screen->insert('line'); // Inserts 1 line upward.
156-
157-
$screen->insert('line', 2); // Inserts 2 lines upward.
158-
159-
$screen->mode('bold'); // Turns on bold font style.
160-
161-
$screen->mode('bold', false); // Turns off bold font style.
162-
163-
// Valid font styles include:
164-
// - none (resets all styles)
165-
// - hide
166-
// - bold
167-
// - underscore
168-
// - blink
169-
// - inverse
170-
171-
$screen->foregroundColor('red'); // Sets foreground color by alias.
172-
// Valid aliases include:
173-
// black, red, green, yellow, blue, magenta, cyan and white.
174-
175-
$screen->foregroundColor('87ff87'); // Sets foreground color by RGB
176-
177-
$screen->backgroundColor('blue'); // Sets background color by alias.
178-
179-
$screen->backgroundColor('d78700'); // Sets background color by RGB
180-
181-
```
182-
183-
### Terminfo ###
184-
185-
If you want to access the full terminal specifications (all boolean, string and number capabilities),
186-
you can obtain the terminfo object from the Terminal instance:
187-
188-
```php
189-
<?php
190-
191-
require_once __DIR__.'/vendor/autoload.php';
192-
193-
use ZerusTech\Component\Terminal\Terminal;
194-
195-
$terminal = Terminal::instance();
196-
197-
$terminfo = $terminal->getTerminfo();
198-
199-
$string = $terminfo->getString('cursor_home');
200-
// Gets the value of a string capability.
201-
202-
$boolean = $terminfo->getBoolean('auto_left_margin');
203-
// Gets the value of a boolean capability.
204-
205-
$number = $terminfo->getNumber('max_colors');
206-
// Gets the value of a numberic capability.
207-
208-
```
209-
210-
::: info-box tip
211-
212-
This component only supports the long capability names in terminfo (the termcap names are not supported).
213-
Refer to [terminfo(5)][5] for the full list of capability names, in alphabet
214-
order, in terminfo.
215-
216-
If you want to know the original order of each capability, refer to file
217-
``include/Caps`` in the latest [ncurses source code][4].
218-
219-
:::
21+
# Project Moved to GitLab
22+
This project has been moved to [GitLab][1].
22023

22124
References
222-
----------
223-
* [The term(5) man page][6]
224-
* [ANSI/VT100 terminal control escape sequences][7]
225-
* [The non-canonical mode of terminal][8]
226-
* [The stty(1) man page][9]
227-
* [The infocmp(1) man page][10]
228-
* [The xterm 256 color palette][11]
229-
* [The zerustech/io project][13]
230-
* [The zerustech/threaded project][14]
231-
* [The zerustech/terminal project][15]
232-
233-
[1]: https://github.com/hoaproject/Console "The hoa/console Project"
234-
[2]: https://opensource.org/licenses/MIT "The MIT License (MIT)"
235-
[3]: http://php.net/manual/en/intro.ncurses.php "Ncurses Terminal Screen Control"
236-
[4]: http://ftp.gnu.org/gnu/ncurses "The Source Code of Ncurses Library"
237-
[5]: https://www.freebsd.org/cgi/man.cgi?query=terminfo&sektion=5 "The terminfo(5) Man Page"
238-
[6]: http://linux.die.net/man/5/term "The term(5) Man Page"
239-
[7]: http://www.termsys.demon.co.uk/vtansi.htm "ANSI/VT100 Terminal Control Escape Sequences"
240-
[8]: http://pubs.opengroup.org/onlinepubs/009696799/basedefs/xbd_chap11.html#tag_11_01_06 "Non-Canonical Mode"
241-
[9]: http://linux.die.net/man/1/stty "The stty(1) Man Page"
242-
[10]: http://manpages.sgvulcan.com/infocmp.1m.php "The infocmp(1) Man Page"
243-
[11]: https://en.wikipedia.org/wiki/File:Xterm_256color_chart.svg "The Xterm 256 Color Palette"
244-
[12]: https://github.com/symfony/console "The Symfony Console Component"
245-
[13]: https://github.com/zerustech/io "The zerustech/io Project"
246-
[14]: https://github.com/zerustech/threaded "The zerustech/threaded Project"
247-
[15]: https://github.com/zerustech/terminal "The zerustech/terminal Project"
25+
* [zerustech/terminal][1]
24826

249-
License
250-
-------
251-
The *ZerusTech Terminal Component* is published under the [MIT License][2].
27+
[1]: https://gitlab.com/zerustech/terminal "zerustech/terminal"

Tests/Fixtures/input_01.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)