xtd 0.2.0
Loading...
Searching...
No Matches
console.hpp
Go to the documentation of this file.
1
4#pragma once
8#include "console_color.hpp"
11#include "event.hpp"
12#include "static.hpp"
13#include "types.hpp"
14#include "string.hpp"
15
17namespace xtd {
19 class environment;
21
36 class console final static_ {
37 public:
39
42 static std::ostream error;
47 static std::istream in;
52 static std::ostream out;
54
56
60 static bool auto_flush_out();
63 static void auto_flush_out(bool value);
64
79 static void background_color(console_color color);
80
93 static void buffer_height(int32 height);
94
107 static void buffer_width(int32 width);
108
111 static bool caps_lock();
112
125 static void cursor_left(int32 left);
126
139 static void cursor_size(int32 size);
140
154 static void cursor_top(int32 top);
155
161 static bool cursor_visible();
167 static void cursor_visible(bool visible);
168
181 static bool foreground_color(console_color color);
182
214 static void input_code_page(int32 code_page);
215
218 static bool is_error_redirected();
221 static bool is_input_redirected();
224 static bool is_output_redirected();
225
230 static bool key_available();
231
238
241 static bool number_lock();
242
274 static void output_code_page(int32 code_page);
275
281 static void title(const xtd::string& title);
282
293
299 static void window_height(int32 height);
300
306 static void window_left(int32 left);
307
313 static void window_top(int32 top);
314
320 static void window_width(int32 width);
322
324
337
339
346 static void beep();
353 static void beep(uint32 frequency, uint32 duration);
354
365 static void clear();
366
371
375 static std::ostream open_standard_error();
379 static std::istream open_standard_input();
383 static std::ostream open_standard_output();
384
396 static int32 read();
397
404 static console_key_info read_key(bool intercept);
405
412 static xtd::string read_line(bool intercept);
413
416 static bool reset_color();
417
424 static void set_cursor_position(int32 left, int32 top);
425
430 static void set_error(const std::ostream& os);
435 static void set_in(const std::istream& is);
440 static void set_out(const std::ostream& os);
441
446 static void set_window_position(int32 left, int32 top);
447
456 static void set_window_size(int32 width, int32 height);
457
461 template<typename arg_t>
462 static void write(arg_t&& value) {write_(xtd::string::format("{}", value));}
463
465 template<typename type_t>
466 static void write(std::initializer_list<type_t>&& il) {write_(xtd::string::format("{}", il));}
468
473 template<typename ... args_t>
474 static void write(const xtd::string& fmt, args_t&& ... values) {write_(xtd::string::format(fmt, std::forward<args_t>(values)...));}
475
477 static void write_line();
478
482 template<typename arg_t>
483 static void write_line(arg_t&& value) {write_line_(xtd::string::format("{}", value));}
484
486 template<typename type_t>
487 static void write_line(const std::initializer_list<type_t>& il) {write_line_(xtd::string::format("{}", il));}
489
494 template<typename ... args_t>
495 static void write_line(const xtd::string& fmt, args_t&& ... values) {write_line_(xtd::string::format(fmt, std::forward<args_t>(values)...));}
497
498 private:
499 friend class xtd::environment;
500 static bool on_cancel_key_press(int32 special_key);
501 static void register_cancel_key_press();
502
503 static void write_(const string& value);
504 static void write_line_(const string& value);
505 };
506}
Represents text as a sequence of character units.
Definition basic_string.hpp:79
Specifies the standard keys on a console.
Definition console_key_info.hpp:24
Represents the standard input, output, and error streams for console applications.
Definition console.hpp:36
static xtd::string read_line()
Reads the next line of characters from the standard input stream.
static event< console, console_cancel_event_handler > cancel_key_press
Occurs when the Control modifier key (Ctrl) and either the ConsoleKey.C console key (C) or the Break ...
Definition console.hpp:335
static std::ostream error
Gets the error output stream. A std::basic_ostream<char_t> that represents the error output stream.
Definition console.hpp:42
static bool is_input_redirected()
Gets a value that indicates whether the input stream has been redirected from the standard input stre...
static xtd::string read_line(bool intercept)
Reads the next line of characters from the standard input stream.
static std::ostream open_standard_error()
Acquires the standard error stream.
static void cursor_top(int32 top)
Sets the row position of the cursor within the buffer area.
static void background_color(console_color color)
Sets the background color of the console.
static int32 buffer_height()
Gets the height of the buffer area.
static console_key_info read_key(bool intercept)
Obtains the next character or function key pressed by the user. The pressed key is optionally display...
static void set_error(const std::ostream &os)
Sets the error property to the specified std::ostream object.
static bool caps_lock()
Gets a value indicating whether the CAPS LOCK keyboard toggle is turned on or turned off.
static xtd::collections::generic::key_value_pair< int32, int32 > get_cursor_position()
Gets the position of the cursor.
static bool auto_flush_out()
Gets a value indicating whether the xtd::console::out will flush its buffer to the underlying stream ...
static int32 window_height()
Gets the height of the console window area.
static void window_height(int32 height)
Sets the height of the console window area.
static bool treat_control_c_as_input()
Gets a value indicating whether the combination of the Control modifier key and C console key (Ctrl+C...
static void buffer_height(int32 height)
Sets or sets the height of the buffer area.
static int32 input_code_page()
Gets the code page the console uses to read input.
static void input_code_page(int32 code_page)
Sets the code page the console uses to read input.
static void set_window_size(int32 width, int32 height)
Sets the height and width of the console window to the specified values.
static bool is_error_redirected()
Gets a value that indicates whether the error output stream has been redirected from the standard err...
static void cursor_size(int32 size)
Sets the height of the cursor within a character cell.
static void cursor_visible(bool visible)
Sets a value indicating whether the cursor is visible.
static void auto_flush_out(bool value)
Sets a value indicating whether the xtd::console::out will flush its buffer to the underlying stream ...
static void write(const xtd::string &fmt, args_t &&... values)
Writes the text representation of the specified list of values to the standard output stream using th...
Definition console.hpp:474
static std::istream open_standard_input()
Acquires the standard input stream.
static void write(arg_t &&value)
Writes the text representation of the specified value to the standard output stream.
Definition console.hpp:462
static void write_line(arg_t &&value)
Writes the text representation of the specified value, followed by the current line terminator,...
Definition console.hpp:483
static console_color background_color()
Gets the background color of the console.
static void window_left(int32 left)
Sets the left of the console window area.
static int32 output_code_page()
Gets the code page the console uses to write output.
static void window_width(int32 width)
Sets the width of the console window area.
static console_color foreground_color()
Gets the foreground color of the console.
static int32 cursor_top()
Gets the row position of the cursor within the buffer area.
static std::istream in
Gets the standard input stream. A std::basic_istream<char_t> that represents the standard input strea...
Definition console.hpp:47
static void treat_control_c_as_input(bool treat_control_c_as_input)
Sets a value indicating whether the combination of the Control modifier key and C console key (Ctrl+C...
static void set_out(const std::ostream &os)
Sets the out property to the specified std::ostream object.
static void window_top(int32 top)
Sets the top of the console window area.
static void clear()
Clears the console buffer and corresponding console window of display information.
static void beep(uint32 frequency, uint32 duration)
Plays the sound of a beep of a specified frequency and duration through the console speaker.
static void write_line(const xtd::string &fmt, args_t &&... values)
Writes the text representation of the specified list of values, followed by the current line terminat...
Definition console.hpp:495
static int32 cursor_size()
Gets or sets the height of the cursor within a character cell.
static std::ostream out
Gets the standard output stream. A std::basic_ostream<char_t> that represents the standard output str...
Definition console.hpp:52
static void buffer_width(int32 width)
Sets the width of the buffer area.
static int32 largest_window_height()
Gets the largest possible number of console window rows, based on the current font and screen resolut...
static bool number_lock()
Gets a value indicating whether the NUM LOCK keyboard toggle is turned on or turned off.
static bool reset_color()
Sets the foreground and background console colors to their defaults.
static void cursor_left(int32 left)
Sets the column position of the cursor within the buffer area.
static int32 largest_window_width()
Gets the largest possible number of console window columns, based on the current font and screen reso...
static void beep()
Plays the sound of a beep through the console speaker.
static int32 read()
Reads the next character from the standard input stream.
static bool foreground_color(console_color color)
Sets the foreground color of the console.
static console_key_info read_key()
Obtains the next character or function key pressed by the user. The pressed key is displayed in the c...
static std::ostream open_standard_output()
Acquires the standard output stream.
static void set_cursor_position(int32 left, int32 top)
Sets the position of the cursor.
static bool is_output_redirected()
Gets a value that indicates whether the output stream has been redirected from the standard output st...
static void set_window_position(int32 left, int32 top)
Sets the position of the console window relative to the screen buffer.
static xtd::string title()
Gets the title to display in the console title bar.
static int32 cursor_left()
Gets the column position of the cursor within the buffer area.
static void set_in(const std::istream &is)
Sets the int property to the specified std::istream object.
static bool key_available()
Gets a value indicating whether a key press is available in the input stream.
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
static int32 window_width()
Gets the width of the console window area.
static bool cursor_visible()
Gets a value indicating whether the cursor is visible.
static int32 window_left()
Gets the left of the console window area.
static void output_code_page(int32 code_page)
Sets the code page the console uses to write output.
static int32 buffer_width()
Gets the width of the buffer area.
static int32 window_top()
Gets the top of the console window area.
static void title(const xtd::string &title)
Sets the title to display in the console title bar.
The environment class.
Definition environment.hpp:67
Represents an event.
Definition event.hpp:21
Contains xtd::console_cancel_event_handler event handler.
Contains xtd::console_color enum class.
Contains xtd::console_key_info class.
Contains xtd::console_special_key enum class.
Contains xtd::event event.
static basic_string format(const basic_string< char > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
std::pair< key_t, value_t > key_value_pair
Defines a key/value pair that can be set or retrieved.
Definition key_value_pair.hpp:29
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:37
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
bool is(std::any value)
Checks if the result of an expression is compatible with a given type.
Definition is.hpp:365
console_color
Specifies constants that define foreground and background colors for the console.
Definition console_color.hpp:20
Contains xtd::collections::key_value_pair alias.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::static_object class.
Contains xtd::io::stream_writer class.
Contains xtd::string alias.
Contains xtd fundamental types.