Skip to content

Commit

Permalink
whee more control characters
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleyewdee committed Nov 15, 2018
1 parent 9d59e9c commit e40e759
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions src/ConsoleBuffer/SequenceParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,33 @@ enum ParserAppendResult
enum ParserCommand
{
/// <summary>
/// Line-feed (\n)
/// Not really a command but a notable character we may wish to specially handle (\0 or '^ ')
/// </summary>
LF = 0,
NUL = 0,
/// <summary>
/// Carriage return (\r)
/// Beep beep (\a or ^G)
/// </summary>
BEL,
/// <summary>
/// Backspace (\b or ^H)
/// </summary>
BS,
/// <summary>
/// Carriage return (\r or ^M)
/// </summary>
CR,
/// <summary>
/// Form feed (\f or ^L)
/// </summary>
FF,
/// <summary>
/// Line-feed (\n or ^J)
/// </summary>
LF,
/// <summary>
/// Horizontal tab (\t or ^I)
/// </summary>
TAB,
}

// Notes on the parser:
Expand Down Expand Up @@ -78,12 +98,30 @@ public ParserAppendResult Append(int character)
case SequenceType.None:
switch (character)
{
case '\0':
this.CurrentCommand = ParserCommand.NUL;
return ParserAppendResult.Complete;
case '\a':
this.CurrentCommand = ParserCommand.BEL;
return ParserAppendResult.Complete;
case '\b':
this.CurrentCommand = ParserCommand.BS;
return ParserAppendResult.Complete;
case '\f':
this.CurrentCommand = ParserCommand.FF;
return ParserAppendResult.Complete;
case '\n':
this.CurrentCommand = ParserCommand.LF;
return ParserAppendResult.Complete;
case '\r':
this.CurrentCommand = ParserCommand.CR;
return ParserAppendResult.Complete;
case '\t':
this.CurrentCommand = ParserCommand.TAB;
return ParserAppendResult.Complete;
case '\v':
this.CurrentCommand = ParserCommand.LF; // XXX: lazily treat these as same
return ParserAppendResult.Complete;
default:
return ParserAppendResult.Render;
}
Expand Down

0 comments on commit e40e759

Please sign in to comment.