Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ConsoleKeyInfo.cs
Go to the documentation of this file.
2
3namespace System;
4
5public readonly struct ConsoleKeyInfo : IEquatable<ConsoleKeyInfo>
6{
7 private readonly char _keyChar;
8
9 private readonly ConsoleKey _key;
10
11 private readonly ConsoleModifiers _mods;
12
13 public char KeyChar => _keyChar;
14
15 public ConsoleKey Key => _key;
16
18
19 public ConsoleKeyInfo(char keyChar, ConsoleKey key, bool shift, bool alt, bool control)
20 {
21 if (key < (ConsoleKey)0 || key > (ConsoleKey)255)
22 {
24 }
25 _keyChar = keyChar;
26 _key = key;
28 if (shift)
29 {
30 _mods |= ConsoleModifiers.Shift;
31 }
32 if (alt)
33 {
35 }
36 if (control)
37 {
38 _mods |= ConsoleModifiers.Control;
39 }
40 }
41
42 public override bool Equals([NotNullWhen(true)] object? value)
43 {
45 {
46 return Equals(obj);
47 }
48 return false;
49 }
50
52 {
53 if (obj._keyChar == _keyChar && obj._key == _key)
54 {
55 return obj._mods == _mods;
56 }
57 return false;
58 }
59
60 public static bool operator ==(ConsoleKeyInfo a, ConsoleKeyInfo b)
61 {
62 return a.Equals(b);
63 }
64
65 public static bool operator !=(ConsoleKeyInfo a, ConsoleKeyInfo b)
66 {
67 return !(a == b);
68 }
69
70 public override int GetHashCode()
71 {
72 return _keyChar | ((int)_key << 16) | ((int)_mods << 24);
73 }
74}
static string ArgumentOutOfRange_ConsoleKey
Definition SR.cs:62
Definition SR.cs:7
readonly ConsoleModifiers _mods
readonly ConsoleKey _key
ConsoleKeyInfo(char keyChar, ConsoleKey key, bool shift, bool alt, bool control)
override bool Equals([NotNullWhen(true)] object? value)
ConsoleModifiers Modifiers
static bool operator==(ConsoleKeyInfo a, ConsoleKeyInfo b)
bool Equals(ConsoleKeyInfo obj)
override int GetHashCode()
readonly char _keyChar
static bool operator!=(ConsoleKeyInfo a, ConsoleKeyInfo b)