Skip to content

Commit

Permalink
3.1.2 patch
Browse files Browse the repository at this point in the history
  • Loading branch information
dedouwe26 committed May 12, 2024
1 parent f0cb436 commit 5bd2248
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
12 changes: 12 additions & 0 deletions Terminal/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ public string ToForegroundANSI() {
/// </summary>
public static readonly Color Yellow = new(255, 255, 0);
/// <summary>
/// 255, 0, 255
/// </summary>
public static readonly Color Magenta = new(255, 0, 255);
/// <summary>
/// 0, 255, 255
/// </summary>
public static readonly Color Cyan = new(0, 255, 255);
/// <summary>
/// 255, 160, 0
/// </summary>
public static readonly Color Orange = new(255, 160, 0);
Expand All @@ -210,6 +218,10 @@ public string ToForegroundANSI() {
/// </summary>
public static readonly Color Gray = new(180, 180, 180);
/// <summary>
/// 64, 64, 64
/// </summary>
public static readonly Color DarkGray = new(64, 64, 64);
/// <summary>
/// 0, 0, 0
/// </summary>
public static readonly Color Black = new(0, 0, 0);
Expand Down
6 changes: 3 additions & 3 deletions Terminal/Style.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public struct Style {
/// <summary>
/// The text color.
/// </summary>
public Color foregroundColor = Colors.Default;
public Color ForegroundColor = Colors.Default;
/// <summary>
/// The color behind the text.
/// </summary>
public Color backgroundColor = Colors.Default;
public Color BackgroundColor = Colors.Default;

/// <summary>
/// Creates a basic style.
Expand All @@ -71,6 +71,6 @@ public readonly string ToANSI() {
(Striketrough ? ANSI.Styles.Striketrough : ANSI.Styles.ResetStriketrough) +
(DoubleUnderline ? ANSI.Styles.DoubleUnderline : "") +
((!(Underline||DoubleUnderline)) ? ANSI.Styles.ResetUnderline : "") +
backgroundColor.ToBackgroundANSI() + foregroundColor.ToForegroundANSI();
BackgroundColor.ToBackgroundANSI() + ForegroundColor.ToForegroundANSI();
}
}
10 changes: 4 additions & 6 deletions Terminal/Terminal.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using OxDED.Terminal.Logging;
using OxDED.Terminal.Window;

namespace OxDED.Terminal;
Expand Down Expand Up @@ -80,7 +78,7 @@ public static bool ListenForKeys {set {
/// </summary>
public static Encoding OutEncoding {get { return Console.OutputEncoding; } set {Console.OutputEncoding = value; }}
/// <summary>
/// Creates a new Terminal Window.
/// Creates a new Terminal Window (Experimental).
/// </summary>
/// <param name="title">The name of the window</param>
/// <returns></returns>
Expand Down Expand Up @@ -124,7 +122,7 @@ public static void WriteLine(Style? style = null) {
/// <param name="text">The text to write to the error output stream.</param>
/// <param name="style">The style to use (default: with red foreground).</param>
public static void WriteErrorLine<T>(T? text, Style? style = null) {
Error.WriteLine((style ?? new Style {foregroundColor = Colors.Red}).ToANSI()+text?.ToString()+ANSI.Styles.ResetAll);
Error.WriteLine((style ?? new Style {ForegroundColor = Colors.Red}).ToANSI()+text?.ToString()+ANSI.Styles.ResetAll);
}
/// <summary>
/// Writes a line to the error stream, with a style.
Expand All @@ -140,7 +138,7 @@ public static void WriteErrorLine(Style? style = null) {
/// <param name="text">The text to write to the error output stream.</param>
/// <param name="style">The style to use (default: with red foreground).</param>
public static void WriteError<T>(T? text, Style? style = null) {
Error.Write((style ?? new Style {foregroundColor = Colors.Red}).ToANSI()+text?.ToString()+ANSI.Styles.ResetAll);
Error.Write((style ?? new Style {ForegroundColor = Colors.Red}).ToANSI()+text?.ToString()+ANSI.Styles.ResetAll);
}
/// <summary>
/// Sets the cursor to that position.
Expand All @@ -150,7 +148,7 @@ public static void WriteError<T>(T? text, Style? style = null) {
public static void Goto((int x, int y) pos) {
if (pos.x >= Width || pos.x < 0) { throw new ArgumentOutOfRangeException(nameof(pos), "pos x is higher than the width or is lower than 0."); }
if (pos.y >= Height || pos.y < 0) { throw new ArgumentOutOfRangeException(nameof(pos), "pos y is higher than the height or is lower than 0."); }
Out.Write(ANSI.MoveCursor(pos.x, pos.y));
Out.Write(ANSI.MoveCursor(pos.x+1, pos.y+1));
}
/// <summary>
/// Gets the cursor position.
Expand Down
2 changes: 1 addition & 1 deletion Terminal/Terminal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PublishTrimmed>true</PublishTrimmed>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageId>0xDED.Terminal</PackageId>
<Version>3.1.1</Version>
<Version>3.1.2</Version>
<Authors>0xDED</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
4 changes: 2 additions & 2 deletions Terminal/Window/TerminalWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public virtual void WriteLine<T>(T? text, Style? style = null) {
/// <param name="text">The text to write to the error output stream.</param>
/// <param name="style">The style to use (default: with red foreground).</param>
public virtual void WriteErrorLine<T>(T? text, Style? style = null) {
Error.WriteLine((style ?? new Style {foregroundColor = Colors.Red}).ToANSI()+text?.ToString()+ANSI.Styles.ResetAll);
Error.WriteLine((style ?? new Style {ForegroundColor = Colors.Red}).ToANSI()+text?.ToString()+ANSI.Styles.ResetAll);
}
/// <summary>
/// Writes something (<see cref="object.ToString"/>) to the error stream, with a style.
Expand All @@ -83,7 +83,7 @@ public virtual void WriteErrorLine<T>(T? text, Style? style = null) {
/// <param name="text">The text to write to the error output stream.</param>
/// <param name="style">The style to use (default: with red foreground).</param>
public virtual void WriteError<T>(T? text, Style? style = null) {
Error.Write((style ?? new Style {foregroundColor = Colors.Red}).ToANSI()+text?.ToString()+ANSI.Styles.ResetAll);
Error.Write((style ?? new Style {ForegroundColor = Colors.Red}).ToANSI()+text?.ToString()+ANSI.Styles.ResetAll);
}
/// <summary>
/// Sets the cursor to that position.
Expand Down
2 changes: 1 addition & 1 deletion Terminal/Window/WinTerminalWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal struct KEY_EVENT_RECORD {
internal ushort wVirtualScanCode;
private ushort _uChar;
internal uint dwControlKeyState;
internal char uChar => (char)_uChar;
internal readonly char uChar => (char)_uChar;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct INPUT_RECORD {
Expand Down
2 changes: 1 addition & 1 deletion examples/Colors/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Program {
public static void Main(string[] args) {
// * Using style.
Terminal.WriteLine("Red", new Style{foregroundColor = Color.Red});
Terminal.WriteLine("Red", new Style{ForegroundColor = Color.Red});

// Will reset to default color (used many times).
string defaultColor = ((Color)Colors.Default).ToForegroundANSI();
Expand Down

0 comments on commit 5bd2248

Please sign in to comment.