-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add commands for character erasing/cursor movement
- Loading branch information
1 parent
1c5900c
commit 3ba087e
Showing
7 changed files
with
234 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace ConsoleBuffer.Commands | ||
{ | ||
using System; | ||
|
||
public sealed class CursorMove : ControlSequence | ||
{ | ||
public enum CursorDirection | ||
{ | ||
Up = 0, | ||
Down, | ||
Forward, | ||
Backward, | ||
} | ||
|
||
public CursorDirection Direction { get; private set; } | ||
public int Count { get; private set; } | ||
|
||
public CursorMove(string bufferData, char cmd) : base(bufferData) | ||
{ | ||
if (cmd < 'A' || cmd > 'D') | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(cmd)); | ||
} | ||
this.Direction = (CursorDirection)(cmd - 'A'); | ||
this.Count = this.ParameterToNumber(0, defaultValue: 1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace ConsoleBuffer.Commands | ||
{ | ||
public sealed class SetCursorPosition : ControlSequence | ||
{ | ||
/// <summary> | ||
/// Will be 0 for left-most position, -1 if X axis should not be applied. | ||
/// </summary> | ||
public int PosX { get; private set; } | ||
/// <summary> | ||
/// Will be 0 for top-most position, -1 if Y axis should not be applied. | ||
/// </summary> | ||
public int PosY { get; private set; } | ||
|
||
public SetCursorPosition(string bufferData, char cmd) : base(bufferData) | ||
{ | ||
this.PosX = this.PosY = -1; | ||
switch (cmd) | ||
{ | ||
case 'G': | ||
this.PosX = this.ParameterToNumber(0, defaultValue: 1) - 1; | ||
break; | ||
case 'd': | ||
this.PosY = this.ParameterToNumber(0, defaultValue: 1) - 1; | ||
break; | ||
case 'H': | ||
case 'f': | ||
this.PosY = this.ParameterToNumber(0, defaultValue: 1) - 1; | ||
this.PosX = this.ParameterToNumber(1, defaultValue: 1) - 1; | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.