mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2025-12-28 08:48:03 +01:00
Add link support for supported terminals
Also refactors the code quite a bit, to make it a bit more easier to add features like this in the future. Closes #75
This commit is contained in:
committed by
Patrik Svensson
parent
1601ef24b3
commit
504746c5dc
@@ -78,5 +78,28 @@ namespace Spectre.Console.Internal
|
||||
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
// https://andrewlock.net/why-is-string-gethashcode-different-each-time-i-run-my-program-in-net-core/
|
||||
public static int GetDeterministicHashCode(this string str)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hash1 = (5381 << 16) + 5381;
|
||||
var hash2 = hash1;
|
||||
|
||||
for (var i = 0; i < str.Length; i += 2)
|
||||
{
|
||||
hash1 = ((hash1 << 5) + hash1) ^ str[i];
|
||||
if (i == str.Length - 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
hash2 = ((hash2 << 5) + hash2) ^ str[i + 1];
|
||||
}
|
||||
|
||||
return hash1 + (hash2 * 1566083941);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user