xtd 0.2.0
Loading...
Searching...
No Matches

◆ cursor_visible() [1/2]

static bool xtd::console::cursor_visible ( )
static

Gets a value indicating whether the cursor is visible.

Returns
true if the cursor is visible; otherwise, false.
Examples
This example demonstrates the cursor_visible property. The example makes the cursor visible if the first column of input is a '+' character or invisible if the input is a '-' character.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
auto m1 = "\nThe cursor is {0}.\nType any text then press Enter. "
"Type '+' in the first column to show \n"
"the cursor, '-' to hide the cursor, "
"or lowercase 'x' to quit:"_s;
auto save_cursor_visibile = console::cursor_visible();
auto save_cursor_size = console::cursor_size();
console::cursor_visible(true); // Initialize the cursor to visible.
console::cursor_size(100); // Emphasize the cursor.
while (true) {
console::write_line(m1, ((console::cursor_visible() == true) ? "VISIBLE" : "HIDDEN"));
if (string::is_empty(s) == false) {
if (s[0] == '+')
else if (s[0] == '-')
else if (s[0] == 'x')
break;
}
}
console::cursor_visible(save_cursor_visibile);
console::cursor_size(save_cursor_size);
}
// This code produces the following output. Note that these results
// cannot depict cursor visibility. You must run the example to see the
// cursor behavior:
//
// The cursor is VISIBLE.
// Type any text then press Enter. Type '+' in the first column to show
// the cursor, '-' to hide the cursor, or lowercase 'x' to quit:
// The quick brown fox
//
// The cursor is VISIBLE.
// Type any text then press Enter. Type '+' in the first column to show
// the cursor, '-' to hide the cursor, or lowercase 'x' to quit:
// -
//
// The cursor is HIDDEN.
// Type any text then press Enter. Type '+' in the first column to show
// the cursor, '-' to hide the cursor, or lowercase 'x' to quit:
// jumps over
//
// The cursor is HIDDEN.
// Type any text then press Enter. Type '+' in the first column to show
// the cursor, '-' to hide the cursor, or lowercase 'x' to quit:
// +
//
// The cursor is VISIBLE.
// Type any text then press Enter. Type '+' in the first column to show
// the cursor, '-' to hide the cursor, or lowercase 'x' to quit:
// the lazy dog.
//
// The cursor is VISIBLE.
// Type any text then press Enter. Type '+' in the first column to show
// the cursor, '-' to hide the cursor, or lowercase 'x' to quit:
// x
static const basic_string empty_string
Represents the empty basic_string.
Definition basic_string.h:124
bool is_empty() const noexcept
Indicates whether this basic_string is an empty basic_string ("").
Definition basic_string.h:1411
static xtd::string read_line()
Reads the next line of characters from the standard input stream.
static int32 cursor_size()
Gets or sets the height of the cursor within a character cell.
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
static bool cursor_visible()
Gets a value indicating whether the cursor is visible.
@ s
The S key.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10