translation_unit
comment "// Copyright (c) Microsoft Corporation.\r"
comment "// Licensed under the MIT license.\r"
preproc_include
#include "#include"
string_literal
" "\""
string_content "precomp.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "VtIo.hpp"
" "\""
preproc_include
#include "#include"
system_lib_string "<til/unicode.h>"
preproc_include
#include "#include"
string_literal
" "\""
string_content "directio.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "handle.h"
" "\""
comment "// LockConsole\r"
preproc_include
#include "#include"
string_literal
" "\""
string_content "output.h"
" "\""
comment "// CloseConsoleProcessState\r"
preproc_include
#include "#include"
string_literal
" "\""
string_content "../interactivity/inc/ServiceLocator.hpp"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "../renderer/base/renderer.hpp"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "../types/inc/CodepointWidthDetector.hpp"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "../types/inc/utils.hpp"
" "\""
using_declaration
using "using"
namespace "namespace"
qualified_identifier
namespace_identifier "Microsoft"
:: "::"
identifier "Console"
; ";"
using_declaration
using "using"
namespace "namespace"
qualified_identifier
namespace_identifier "Microsoft"
:: "::"
qualified_identifier
namespace_identifier "Console"
:: "::"
identifier "Render"
; ";"
using_declaration
using "using"
namespace "namespace"
qualified_identifier
namespace_identifier "Microsoft"
:: "::"
qualified_identifier
namespace_identifier "Console"
:: "::"
identifier "VirtualTerminal"
; ";"
using_declaration
using "using"
namespace "namespace"
qualified_identifier
namespace_identifier "Microsoft"
:: "::"
qualified_identifier
namespace_identifier "Console"
:: "::"
identifier "Types"
; ";"
using_declaration
using "using"
namespace "namespace"
qualified_identifier
namespace_identifier "Microsoft"
:: "::"
qualified_identifier
namespace_identifier "Console"
:: "::"
identifier "Utils"
; ";"
using_declaration
using "using"
namespace "namespace"
qualified_identifier
namespace_identifier "Microsoft"
:: "::"
qualified_identifier
namespace_identifier "Console"
:: "::"
identifier "Interactivity"
; ";"
function_definition (+281 nodes collapsed)
comment "// Routine Description:\r"
comment "// Tries to initialize this VtIo instance from the given pi"...
comment "// VtIoMode. The pipes should have been created already"...
comment "// conhost), in non-overlapped mode.\r"
comment "// The VtIoMode string can be the empty string as a default"...
comment "// Arguments:\r"
comment "// InHandle: a valid file handle. The console will\r"
comment "// read VT sequences from this pipe to generate INPUT_R"...
comment "// input events.\r"
comment "// OutHandle: a valid file handle. The console\r"
comment "// will be \"rendered\" to this pipe using VT sequences\r"
comment "// SignalHandle: an optional file handle that will be used "...
comment "// This represents the ability to send signals to a *ni"...
comment "// Return Value:\r"
comment "// S_OK if we initialized successfully, otherwise an approp"...
comment "// indicating failure.\r"
function_definition (+176 nodes collapsed)
comment "// Method Description:\r"
comment "// - Create the VtEngine and the VtInputThread for this cons"...
comment "// MUST BE DONE AFTER CONSOLE IS INITIALIZED, to make sure w"...
comment "// buffer size from the attached client application.\r"
comment "// Arguments:\r"
comment "// - <none>\r"
comment "// Return Value:\r"
comment "// S_OK if we initialized successfully,\r"
comment "// S_FALSE if VtIo hasn't been initialized (or we're not in"...
comment "// otherwise an appropriate HRESULT indicating failure.\r"
function_definition (+132 nodes collapsed)
function_definition
primitive_type "bool"
function_declarator
qualified_identifier
namespace_identifier "VtIo"
:: "::"
identifier "IsUsingVt"
parameter_list
( "("
) ")"
type_qualifier
const "const"
compound_statement
{ "{"
return_statement
return "return"
identifier "_initialized"
; ";"
} "}"
comment "// Routine Description:\r"
comment "// Potentially starts this VtIo's input thread and render e"...
comment "// If the VtIo hasn't yet been given pipes, then this f"...
comment "// silently do nothing. It's the responsibility of the "...
comment "// that the pipes are initialized first with VtIo::Init"...
comment "// Arguments:\r"
comment "// <none>\r"
comment "// Return Value:\r"
comment "// S_OK if we started successfully or had nothing to start,"...
comment "// appropriate HRESULT indicating failure.\r"
function_definition (+234 nodes collapsed)
function_definition (+38 nodes collapsed)
function_definition (+33 nodes collapsed)
comment "// Method Description:\r"
comment "// - Create our pseudo window. This is exclusively called by"...
comment "// ConsoleInputThreadProcWin32 on the console input thread"...
comment "// * It needs to be called on that thread, before any oth"...
comment "// LocatePseudoWindow, to make sure that the input thre"...
comment "// message thread.\r"
comment "// * It needs to be plumbed through the signal thread, be"...
comment "// thread knows if someone should be marked as the wind"...
comment "// VERY IMPORTANT that any initial owners are set up wh"...
comment "// first created.\r"
comment "// - Refer to GH#13066 for details.\r"
function_definition (+47 nodes collapsed)
comment "// Method Description:\r"
comment "// - Create and start the signal thread. The signal thread c"...
comment "// independent of the i/o threads, and doesn't require "...
comment "// attaching to the console. We need to create it first"...
comment "// because it's possible that a terminal application co"...
comment "// CreatePseudoConsole, then ClosePseudoConsole without"...
comment "// client. Should that happen, we still need to exit.\r"
comment "// Arguments:\r"
comment "// - <none>\r"
comment "// Return Value:\r"
comment "// - S_FALSE if we're not in VtIo mode,\r"
comment "// S_OK if we succeeded,\r"
comment "// otherwise an appropriate HRESULT indicating failure.\r"
function_definition (+117 nodes collapsed)
function_definition (+82 nodes collapsed)
comment "// Returns true for C0 characters and C1 [single-character] "...
comment "// A copy of isActionableFromGround() from stateMachine.cpp."...
function_definition (+57 nodes collapsed)
comment "// Formats the given console attributes to their closest VT "...
comment "// `out` must refer to at least `formatAttributesMaxLen` cha"...
comment "// Returns a pointer past the end.\r"
declaration
storage_class_specifier
static "static"
type_qualifier
constexpr "constexpr"
primitive_type "size_t"
init_declarator
identifier "formatAttributesMaxLen"
= "="
number_literal "16"
; ";"
function_definition (+316 nodes collapsed)
function_definition (+83 nodes collapsed)
function_definition (+129 nodes collapsed)
function_definition (+304 nodes collapsed)
function_definition (+48 nodes collapsed)
function_definition (+49 nodes collapsed)
function_definition (+29 nodes collapsed)
function_definition (+47 nodes collapsed)
function_definition (+38 nodes collapsed)
function_definition (+463 nodes collapsed)
function_definition (+60 nodes collapsed)
function_definition (+38 nodes collapsed)
function_definition
primitive_type "void"
function_declarator
qualified_identifier
namespace_identifier "VtIo"
:: "::"
qualified_identifier
namespace_identifier "Writer"
:: "::"
identifier "WriteUTF16"
parameter_list
( "("
parameter_declaration
qualified_identifier
namespace_identifier "std"
:: "::"
type_identifier "wstring_view"
identifier "str"
) ")"
type_qualifier
const "const"
compound_statement
{ "{"
if_statement
if "if"
condition_clause
( "("
call_expression
field_expression
identifier "str"
. "."
field_identifier "empty"
argument_list
( "("
) ")"
) ")"
compound_statement
{ "{"
return_statement
return "return"
; ";"
} "}"
declaration
type_qualifier
const "const"
placeholder_type_specifier
auto "auto"
init_declarator
identifier "existingUTF8Len"
= "="
call_expression
field_expression
field_expression
identifier "_io"
-> "->"
field_identifier "_back"
. "."
field_identifier "size"
argument_list
( "("
) ")"
; ";"
declaration
type_qualifier
const "const"
placeholder_type_specifier
auto "auto"
init_declarator
identifier "incomingUTF16Len"
= "="
call_expression
field_expression
identifier "str"
. "."
field_identifier "size"
argument_list
( "("
) ")"
; ";"
comment "// When converting from UTF-16 to UTF-8 the worst case is 3 "...
declaration
type_qualifier
const "const"
placeholder_type_specifier
auto "auto"
init_declarator
identifier "incomingUTF8Cap"
= "="
binary_expression
identifier "incomingUTF16Len"
* "*"
number_literal "3"
; ";"
declaration
type_qualifier
const "const"
placeholder_type_specifier
auto "auto"
init_declarator
identifier "totalUTF8Cap"
= "="
binary_expression
identifier "existingUTF8Len"
+ "+"
identifier "incomingUTF8Cap"
; ";"
comment "// Since WideCharToMultiByte() only supports `int` lengths, "...
comment "// We also check for an overflow of totalUTF8Cap just to be "...
if_statement (+48 nodes collapsed)
comment "// C++23's resize_and_overwrite is too valuable to not use.\r"
comment "// It reduce the CPU overhead by roughly half.\r"
preproc_if
#if "#if"
binary_expression
unary_expression
! "!"
preproc_defined
defined "defined"
( "("
identifier "_HAS_CXX23"
) ")"
|| "||"
unary_expression
! "!"
identifier "_HAS_CXX23"
"\n"
preproc_def
#define "#define"
identifier "resize_and_overwrite"
preproc_arg "_Resize_and_overwrite\r"
#endif "#endif"
comment "// NOTE: Throwing inside resize_and_overwrite invokes undefi"...
expression_statement (+126 nodes collapsed)
preproc_call
preproc_directive "#undef"
preproc_arg "resize_and_overwrite\r"
} "}"
comment "// When DISABLE_NEWLINE_AUTO_RETURN is not set (Bad! Don't d"...
comment "// That's the only difference of this function from WriteUTF"...
function_definition (+228 nodes collapsed)
comment "// Same as WriteUTF16, but replaces control characters with "...
comment "// We don't outright remove them because that would mess up "...
comment "// conhost traditionally assigned control chars a width of 1"...
function_definition (+150 nodes collapsed)
function_definition (+301 nodes collapsed)
comment "// CUP: Cursor Position\r"
function_definition (+73 nodes collapsed)
comment "// DECTCEM: Text Cursor Enable\r"
function_definition (+102 nodes collapsed)
comment "// SGR 1006: SGR Extended Mouse Mode\r"
function_definition (+102 nodes collapsed)
comment "// DECAWM: Autowrap Mode\r"
function_definition (+102 nodes collapsed)
comment "// ASB: Alternate Screen Buffer\r"
function_definition (+102 nodes collapsed)
function_definition (+91 nodes collapsed)
function_definition (+56 nodes collapsed)
function_definition (+38 nodes collapsed)
function_definition (+381 nodes collapsed)
function_definition (+551 nodes collapsed)