@@ -51,8 +51,7 @@ internal sealed class TerminalFormatStrings
51
51
/// The dictionary of keystring to ConsoleKeyInfo.
52
52
/// Only some members of the ConsoleKeyInfo are used; in particular, the actual char is ignored.
53
53
/// </summary>
54
- public readonly Dictionary < ReadOnlyMemory < char > , ConsoleKeyInfo > KeyFormatToConsoleKey =
55
- new Dictionary < ReadOnlyMemory < char > , ConsoleKeyInfo > ( new ReadOnlyMemoryContentComparer ( ) ) ;
54
+ public readonly Dictionary < string , ConsoleKeyInfo > KeyFormatToConsoleKey = new ( StringComparer . Ordinal ) ;
56
55
57
56
/// <summary> Max key length </summary>
58
57
public readonly int MaxKeyFormatLength ;
@@ -164,7 +163,7 @@ public TerminalFormatStrings(TermInfo.Database? db)
164
163
MaxKeyFormatLength = int . MinValue ;
165
164
MinKeyFormatLength = int . MaxValue ;
166
165
167
- foreach ( KeyValuePair < ReadOnlyMemory < char > , ConsoleKeyInfo > entry in KeyFormatToConsoleKey )
166
+ foreach ( KeyValuePair < string , ConsoleKeyInfo > entry in KeyFormatToConsoleKey )
168
167
{
169
168
if ( entry . Key . Length > MaxKeyFormatLength )
170
169
{
@@ -229,8 +228,8 @@ private void AddKey(TermInfo.Database db, TermInfo.WellKnownStrings keyId, Conso
229
228
230
229
private void AddKey ( TermInfo . Database db , TermInfo . WellKnownStrings keyId , ConsoleKey key , bool shift , bool alt , bool control )
231
230
{
232
- ReadOnlyMemory < char > keyFormat = db . GetString ( keyId ) . AsMemory ( ) ;
233
- if ( ! keyFormat . IsEmpty )
231
+ string ? keyFormat = db . GetString ( keyId ) ;
232
+ if ( ! string . IsNullOrEmpty ( keyFormat ) )
234
233
KeyFormatToConsoleKey [ keyFormat ] = new ConsoleKeyInfo ( key == ConsoleKey . Enter ? '\r ' : '\0 ' , key , shift , alt , control ) ;
235
234
}
236
235
@@ -248,17 +247,8 @@ private void AddPrefixKey(TermInfo.Database db, string extendedNamePrefix, Conso
248
247
249
248
private void AddKey ( TermInfo . Database db , string extendedName , ConsoleKey key , bool shift , bool alt , bool control )
250
249
{
251
- ReadOnlyMemory < char > keyFormat = db . GetExtendedString ( extendedName ) . AsMemory ( ) ;
252
- if ( ! keyFormat . IsEmpty )
250
+ string ? keyFormat = db . GetExtendedString ( extendedName ) ;
251
+ if ( ! string . IsNullOrEmpty ( keyFormat ) )
253
252
KeyFormatToConsoleKey [ keyFormat ] = new ConsoleKeyInfo ( '\0 ' , key , shift , alt , control ) ;
254
253
}
255
-
256
- private sealed class ReadOnlyMemoryContentComparer : IEqualityComparer < ReadOnlyMemory < char > >
257
- {
258
- public bool Equals ( ReadOnlyMemory < char > x , ReadOnlyMemory < char > y ) =>
259
- x . Span . SequenceEqual ( y . Span ) ;
260
-
261
- public int GetHashCode ( ReadOnlyMemory < char > obj ) =>
262
- string . GetHashCode ( obj . Span ) ;
263
- }
264
254
}
0 commit comments