Skip to content

Commit

Permalink
release 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hsaturn committed Nov 30, 2022
1 parent 1131486 commit d146cb8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TinyConsole
version=0.1.0
version=0.2.0
author=Francois BIOT, HSaturn, <[email protected]>
maintainer=Francois BIOT, HSaturn, <[email protected]>
sentence=A tiny command line and term handler
Expand Down
6 changes: 3 additions & 3 deletions src/TinyConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ const TinyConsole& TinyConsole::fg(enum TinyConsole::Color c) const

const TinyConsole& TinyConsole::prompt() const
{
if (term) *serial << "\r\n" << ps1;
if (term)
*serial << CSI << 'G' << ps1 << input << ' ' << CSI << (int)(ps1.size()+cursor+1) << 'G';
return *this;
}

Expand Down Expand Up @@ -167,8 +168,7 @@ void TinyConsole::loop()
(*this) << "code(" << (int)c << ')';
restoreCursor();
*/
if (term)
*serial << CSI << 'G' << ps1 << input << ' ' << CSI << (int)(ps1.size()+cursor+1) << 'G';
prompt();
}
}

Expand Down
18 changes: 17 additions & 1 deletion src/TinyConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ class TinyConsole
none = 255
};

enum Operation
{
hide_cur,
show_cur,
erase_to_end
};

using CallBack = void(*)(const std::string& command);
using CallBackFnKey = void(*)(int fkey);

Expand Down Expand Up @@ -79,7 +86,16 @@ class TinyConsole
console.fg(color);
return console;
}


friend TinyConsole& operator << (TinyConsole& console, Operation op)
{
if (op == erase_to_end)
console.eraseEol();
else
console.cursorVisible(op == show_cur);
return console;
}

private:
char waitChar();
void handleEscape();
Expand Down

0 comments on commit d146cb8

Please sign in to comment.