-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fernando Cerqueira
committed
Oct 6, 2023
1 parent
e454e56
commit 3de47f6
Showing
17 changed files
with
442 additions
and
17 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
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
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,70 @@ | ||
// *************************************************************************************** | ||
// MIT LICENCE | ||
// The maintenance and evolution is maintained by the PromptPlus project under MIT license | ||
// *************************************************************************************** | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using PPlus.Drivers; | ||
|
||
namespace PPlus | ||
{ | ||
internal class AppendTextControl : IAppendText | ||
{ | ||
private readonly List<Segment> _segments = new(); | ||
|
||
public IAppendText And(string text) | ||
{ | ||
if (!string.IsNullOrEmpty(text)) | ||
{ | ||
_segments.Add(new Segment(text, new Style(Style.Default.Foreground, Style.Default.Background, Style.Default.OverflowStrategy))); | ||
} | ||
return this; | ||
} | ||
|
||
public IAppendText And(string text, Style style) | ||
{ | ||
if (!string.IsNullOrEmpty(text)) | ||
{ | ||
_segments.Add(new Segment(text, style)); | ||
} | ||
return this; | ||
} | ||
|
||
public IAppendText And(string text, Color color) | ||
{ | ||
if (!string.IsNullOrEmpty(text)) | ||
{ | ||
_segments.Add(new Segment(text, new Style(color,Style.Default.Background,Style.Default.OverflowStrategy))); | ||
} | ||
return this; | ||
} | ||
|
||
public void Write() | ||
{ | ||
WriteSegments(false); | ||
} | ||
|
||
public void WriteLine() | ||
{ | ||
WriteSegments(true); | ||
} | ||
|
||
private void WriteSegments(bool newline) | ||
{ | ||
if (_segments.Count == 0) | ||
{ | ||
return; | ||
} | ||
PromptPlus.Write(_segments[0].Text, _segments[0].Style, true); | ||
for (int i = 1; i < _segments.Count; i++) | ||
{ | ||
PromptPlus.Write(_segments[i].Text, _segments[i].Style, false); | ||
} | ||
if (newline) | ||
{ | ||
PromptPlus.Write(Environment.NewLine, clearrestofline:false); | ||
} | ||
} | ||
} | ||
} |
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,46 @@ | ||
// *************************************************************************************** | ||
// MIT LICENCE | ||
// The maintenance and evolution is maintained by the PromptPlus project under MIT license | ||
// *************************************************************************************** | ||
|
||
namespace PPlus.Drivers | ||
{ | ||
/// <summary> | ||
/// Represents the interface with all Methods of the Conteole Append control | ||
/// </summary> | ||
public interface IAppendText | ||
{ | ||
/// <summary> | ||
/// Add text to the recording buffer | ||
/// </summary> | ||
/// <param name="text">Text to write</param> | ||
/// <returns><see cref="IAppendText"/></returns> | ||
IAppendText And(string text); | ||
|
||
/// <summary> | ||
/// Add text to the recording buffer with <see cref="Style"/> | ||
/// </summary> | ||
/// <param name="text">Text to write</param> | ||
/// <param name="style">The <see cref="Style"/></param> | ||
/// <returns><see cref="IAppendText"/></returns> | ||
IAppendText And(string text, Style style); | ||
|
||
/// <summary> | ||
/// Add text to the recording buffer with forecolor <see cref="Color"/> | ||
/// </summary> | ||
/// <param name="text">Text to write</param> | ||
/// <param name="color">The forecolor. <see cref="Color"/></param> | ||
/// <returns><see cref="IAppendText"/></returns> | ||
IAppendText And(string text, Color color); | ||
|
||
/// <summary> | ||
/// Write a text to output console. | ||
/// </summary> | ||
void Write(); | ||
|
||
/// <summary> | ||
/// Write line terminator a text to output console with line terminator. | ||
/// </summary> | ||
void WriteLine(); | ||
} | ||
} |
Oops, something went wrong.