Alien-uv
view release on metacpan or search on metacpan
libuv/README.md view on Meta::CPAN
* Full-featured event loop backed by epoll, kqueue, IOCP, event ports.
* Asynchronous TCP and UDP sockets
* Asynchronous DNS resolution
* Asynchronous file and file system operations
* File system events
* ANSI escape code controlled TTY
* IPC with socket sharing, using Unix domain sockets or named pipes (Windows)
* Child processes
* Thread pool
* Signal handling
* High resolution clock
libuv/docs/src/guide/utilities.rst view on Meta::CPAN
.. _shared libraries: http://en.wikipedia.org/wiki/Shared_library#Shared_libraries
TTY
---
Text terminals have supported basic formatting for a long time, with a `pretty
standardised`_ command set. This formatting is often used by programs to
improve the readability of terminal output. For example ``grep --colour``.
libuv provides the ``uv_tty_t`` abstraction (a stream) and related functions to
implement the ANSI escape codes across all platforms. By this I mean that libuv
converts ANSI codes to the Windows equivalent, and provides functions to get
terminal information.
.. _pretty standardised: http://en.wikipedia.org/wiki/ANSI_escape_sequences
The first thing to do is to initialize a ``uv_tty_t`` with the file descriptor
it reads/writes from. This is achieved with::
int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int unused)
The ``unused`` parameter is now auto-detected and ignored. It previously needed
to be set to use ``uv_read_start()`` on the stream.
It is then best to use ``uv_tty_set_mode`` to set the mode to *normal*
libuv/docs/src/guide/utilities.rst view on Meta::CPAN
Here is a simple example which prints white text on a red background:
.. rubric:: tty/main.c
.. literalinclude:: ../../code/tty/main.c
:linenos:
:emphasize-lines: 11-12,14,17,27
The final TTY helper is ``uv_tty_get_winsize()`` which is used to get the
width and height of the terminal and returns ``0`` on success. Here is a small
program which does some animation using the function and character position
escape codes.
.. rubric:: tty-gravity/main.c
.. literalinclude:: ../../code/tty-gravity/main.c
:linenos:
:emphasize-lines: 19,25,38
The escape codes are:
====== =======================
Code Meaning
====== =======================
*2* J Clear part of the screen, 2 is entire screen
H Moves cursor to certain position, default top-left
*n* B Moves cursor down by n lines
*n* C Moves cursor right by n columns
m Obeys string of display settings, in this case green background (40+2), white text (30+7)
====== =======================
libuv/docs/src/index.rst view on Meta::CPAN
Features
--------
* Full-featured event loop backed by epoll, kqueue, IOCP, event ports.
* Asynchronous TCP and UDP sockets
* Asynchronous DNS resolution
* Asynchronous file and file system operations
* File system events
* ANSI escape code controlled TTY
* IPC with socket sharing, using Unix domain sockets or named pipes (Windows)
* Child processes
* Thread pool
* Signal handling
* High resolution clock
* Threading and synchronization primitives
Documentation
-------------
libuv/src/win/process.c view on Meta::CPAN
if (arg_len == 0) {
err = GetLastError();
goto error;
}
if (verbatim_arguments) {
/* Copy verbatim. */
wcscpy(pos, temp_buffer);
pos += arg_len - 1;
} else {
/* Quote/escape, if needed. */
pos = quote_cmd_arg(temp_buffer, pos);
}
*pos++ = *(arg + 1) ? L' ' : L'\0';
}
uv__free(temp_buffer);
*dst_ptr = dst;
return 0;
libuv/src/win/tty.c view on Meta::CPAN
/* Patch buf offset so this character will be parsed again as a start
* byte. */
j--;
}
/* Maybe we need to parse more bytes to find a character. */
if (utf8_bytes_left != 0) {
continue;
}
/* Parse vt100/ansi escape codes */
if (ansi_parser_state == ANSI_NORMAL) {
switch (utf8_codepoint) {
case '\033':
ansi_parser_state = ANSI_ESCAPE_SEEN;
continue;
case 0233:
ansi_parser_state = ANSI_CSI;
handle->tty.wr.ansi_csi_argc = 0;
continue;
libuv/src/win/tty.c view on Meta::CPAN
case '^':
case '_':
case 'P':
case ']':
/* Not supported, but we'll have to parse until we see a stop code,
* e. g. ESC \ or BEL. */
ansi_parser_state = ANSI_ST_CONTROL;
continue;
case '\033':
/* Ignore double escape. */
continue;
case 'c':
/* Full console reset. */
FLUSH_TEXT();
uv_tty_reset(handle, error);
ansi_parser_state = ANSI_NORMAL;
continue;
case '7':
( run in 0.581 second using v1.01-cache-2.11-cpan-c21f80fb71c )