Alien-uv
view release on metacpan or search on metacpan
libuv/include/uv/win.h view on Meta::CPAN
unsigned char last_key_offset; \
unsigned char last_key_len; \
WCHAR last_utf16_high_surrogate; \
INPUT_RECORD last_input_record; \
} rd; \
struct { \
/* Used for writable TTY handles */ \
/* utf8-to-utf16 conversion state */ \
unsigned int utf8_codepoint; \
unsigned char utf8_bytes_left; \
/* eol conversion state */ \
unsigned char previous_eol; \
/* ansi parser state */ \
unsigned char ansi_parser_state; \
unsigned char ansi_csi_argc; \
unsigned short ansi_csi_argv[4]; \
COORD saved_position; \
WORD saved_attributes; \
} wr; \
} tty;
#define UV_POLL_PRIVATE_FIELDS \
libuv/src/win/tty.c view on Meta::CPAN
tty->tty.rd.last_utf16_high_surrogate = 0;
memset(&tty->tty.rd.last_input_record, 0, sizeof tty->tty.rd.last_input_record);
} else {
/* TTY output specific fields. */
tty->flags |= UV_HANDLE_WRITABLE;
/* Init utf8-to-utf16 conversion state. */
tty->tty.wr.utf8_bytes_left = 0;
tty->tty.wr.utf8_codepoint = 0;
/* Initialize eol conversion state */
tty->tty.wr.previous_eol = 0;
/* Init ANSI parser state. */
tty->tty.wr.ansi_parser_state = ANSI_NORMAL;
}
return 0;
}
/* Set the default console text attributes based on how the console was
libuv/src/win/tty.c view on Meta::CPAN
} while (0)
#define ENSURE_BUFFER_SPACE(wchars_needed) \
if (wchars_needed > ARRAY_SIZE(utf16_buf) - utf16_buf_used) { \
FLUSH_TEXT(); \
}
/* Cache for fast access */
unsigned char utf8_bytes_left = handle->tty.wr.utf8_bytes_left;
unsigned int utf8_codepoint = handle->tty.wr.utf8_codepoint;
unsigned char previous_eol = handle->tty.wr.previous_eol;
unsigned char ansi_parser_state = handle->tty.wr.ansi_parser_state;
/* Store the error here. If we encounter an error, stop trying to do i/o but
* keep parsing the buffer so we leave the parser in a consistent state. */
*error = ERROR_SUCCESS;
utf16_buffer = utf16_buf;
uv_sem_wait(&uv_tty_output_lock);
libuv/src/win/tty.c view on Meta::CPAN
/* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the windows
* console doesn't really support UTF-16, so just emit the replacement
* character. */
if (utf8_codepoint > 0xffff) {
utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER;
}
if (utf8_codepoint == 0x0a || utf8_codepoint == 0x0d) {
/* EOL conversion - emit \r\n when we see \n. */
if (utf8_codepoint == 0x0a && previous_eol != 0x0d) {
/* \n was not preceded by \r; print \r\n. */
ENSURE_BUFFER_SPACE(2);
utf16_buf[utf16_buf_used++] = L'\r';
utf16_buf[utf16_buf_used++] = L'\n';
} else if (utf8_codepoint == 0x0d && previous_eol == 0x0a) {
/* \n was followed by \r; do not print the \r, since the source was
* either \r\n\r (so the second \r is redundant) or was \n\r (so the
* \n was processed by the last case and an \r automatically
* inserted). */
} else {
/* \r without \n; print \r as-is. */
ENSURE_BUFFER_SPACE(1);
utf16_buf[utf16_buf_used++] = (WCHAR) utf8_codepoint;
}
previous_eol = (char) utf8_codepoint;
} else if (utf8_codepoint <= 0xffff) {
/* Encode character into utf-16 buffer. */
ENSURE_BUFFER_SPACE(1);
utf16_buf[utf16_buf_used++] = (WCHAR) utf8_codepoint;
previous_eol = 0;
}
}
}
/* Flush remaining characters */
FLUSH_TEXT();
/* Copy cached values back to struct. */
handle->tty.wr.utf8_bytes_left = utf8_bytes_left;
handle->tty.wr.utf8_codepoint = utf8_codepoint;
handle->tty.wr.previous_eol = previous_eol;
handle->tty.wr.ansi_parser_state = ansi_parser_state;
uv_sem_post(&uv_tty_output_lock);
if (*error == STATUS_SUCCESS) {
return 0;
} else {
return -1;
}
( run in 1.719 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )