다음을 통해 공유


Console.CursorVisible 속성

정의

커서가 표시되는지를 나타내는 값을 가져오거나 설정합니다.

public:
 static property bool CursorVisible { bool get(); void set(bool value); };
public static bool CursorVisible { [System.Runtime.Versioning.SupportedOSPlatform("windows")] get; [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] set; }
public static bool CursorVisible { [System.Runtime.Versioning.SupportedOSPlatform("windows")] get; [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] [System.Runtime.Versioning.UnsupportedOSPlatform("android")] [System.Runtime.Versioning.UnsupportedOSPlatform("ios")] [System.Runtime.Versioning.UnsupportedOSPlatform("tvos")] set; }
public static bool CursorVisible { get; set; }
[<get: System.Runtime.Versioning.SupportedOSPlatform("windows")>]
[<set: System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.CursorVisible : bool with get, set
[<get: System.Runtime.Versioning.SupportedOSPlatform("windows")>]
[<set: System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<set: System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<set: System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<set: System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
member this.CursorVisible : bool with get, set
member this.CursorVisible : bool with get, set
Public Shared Property CursorVisible As Boolean

속성 값

Boolean

커서가 표시되면 true이고, 표시되지 않으면 false입니다.

특성

예외

사용자에게 이 작업을 수행할 권한이 없습니다.

I/O 오류가 발생했습니다.

가져오기 작업은 Windows 이외의 운영 체제에서 호출됩니다.

예제

이 예제에서는 속성을 보여 줍니다 CursorVisible . 이 예제에서는 입력의 첫 번째 열이 '+' 문자이거나 입력이 '-' 문자인 경우 보이지 않는 경우 커서를 표시합니다.

// This example demonstrates the Console.CursorVisible property.
using namespace System;

int main()
{
   String^ 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:";
   String^ s;
   bool saveCursorVisibile;
   int saveCursorSize;
   
   //
   Console::CursorVisible = true; // Initialize the cursor to visible.
   saveCursorVisibile = Console::CursorVisible;
   saveCursorSize = Console::CursorSize;
   Console::CursorSize = 100; // Emphasize the cursor.
   for ( ; ;  )
   {
      Console::WriteLine( m1, ((Console::CursorVisible == true) ? (String^)"VISIBLE" : "HIDDEN") );
      s = Console::ReadLine();
      if ( String::IsNullOrEmpty( s ) == false )
            if ( s[ 0 ] == '+' )
            Console::CursorVisible = true;
      else
      if ( s[ 0 ] == '-' )
            Console::CursorVisible = false;
      else
      if ( s[ 0 ] == 'x' )
            break;

   }
   Console::CursorVisible = saveCursorVisibile;
   Console::CursorSize = saveCursorSize;
}

/*
This example produces the following results. 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

*/
// This example demonstrates the Console.CursorVisible property.

using System;

class Sample
{
    public static void Main()
    {
    string 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:";
    string s;
    bool saveCursorVisibile;
    int  saveCursorSize;
//
    Console.CursorVisible = true; // Initialize the cursor to visible.
    saveCursorVisibile = Console.CursorVisible;
    saveCursorSize  = Console.CursorSize;
    Console.CursorSize = 100;     // Emphasize the cursor.

    while(true)
        {
        Console.WriteLine(m1,
                         ((Console.CursorVisible == true) ?
                           "VISIBLE" : "HIDDEN"));
        s = Console.ReadLine();
        if (String.IsNullOrEmpty(s) == false)
            if (s[0] == '+')
                Console.CursorVisible = true;
            else if (s[0] == '-')
                Console.CursorVisible = false;
            else if (s[0] == 'x')
                break;
        }
    Console.CursorVisible = saveCursorVisibile;
    Console.CursorSize    = saveCursorSize;
    }
}
/*
This example produces the following results. 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

*/
// This example demonstrates the Console.CursorVisible property.

open System

Console.CursorVisible <- true // Initialize the cursor to visible.
let saveCursorVisibile = Console.CursorVisible
let saveCursorSize = Console.CursorSize
Console.CursorSize <- 100     // Emphasize the cursor.

let mutable quit = false
while not quit do
    printfn $"""\nThe cursor is {if Console.CursorVisible then "VISIBLE" else "HIDDEN"}.\nType any text then press Enter. Type '+' in the first column to show 
the cursor, '-' to hide the cursor, or lowercase 'x' to quit:"""
    let s = Console.ReadLine()
    if not (String.IsNullOrEmpty s) then
        match s[0] with
        | '+' ->
            Console.CursorVisible <- true
        | '-' ->
            Console.CursorVisible <- false
        | 'x' -> 
            quit <- true
        | _ -> ()

Console.CursorVisible <- saveCursorVisibile
Console.CursorSize    <- saveCursorSize


// This example produces the following results. 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
' This example demonstrates the Console.CursorVisible property.
Class Sample
   Public Shared Sub Main()
      Dim m1 As String = vbCrLf & "The cursor is {0}." & _
                         vbCrLf & "Type any text then press Enter. " & _
                         "Type '+' in the first column to show " & _
                         vbCrLf & "the cursor, '-' to hide the cursor, " & _
                         "or lowercase 'x' to quit:"
      Dim s As String
      Dim saveCursorVisibile As Boolean
      Dim saveCursorSize As Integer
      '
      Console.CursorVisible = True ' Initialize the cursor to visible.
      saveCursorVisibile = Console.CursorVisible
      saveCursorSize = Console.CursorSize
      Console.CursorSize = 100 ' Emphasize the cursor.
      While True
         Console.WriteLine(m1, _
            IIf(Console.CursorVisible = True, "VISIBLE", "HIDDEN"))
         s = Console.ReadLine()
         If String.IsNullOrEmpty(s) = False Then
            If s(0) = "+"c Then
               Console.CursorVisible = True
            ElseIf s(0) = "-"c Then
               Console.CursorVisible = False
            ElseIf s(0) = "x"c Then
               Exit While
            End If
         End If
      End While
      Console.CursorVisible = saveCursorVisibile
      Console.CursorSize = saveCursorSize
   End Sub
End Class
'
'This example produces the following results. 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
'

적용 대상