mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-27 09:40:07 +01:00
35 lines
531 B
C++
35 lines
531 B
C++
#include <ion.h>
|
|
|
|
namespace Ion {
|
|
namespace Console {
|
|
|
|
char readChar();
|
|
void writeChar(char c);
|
|
|
|
void writeLine(const char * line) {
|
|
while (*line != 0) {
|
|
writeChar(*line++);
|
|
}
|
|
writeChar('\r');
|
|
writeChar('\n');
|
|
}
|
|
|
|
void readLine(char * line, int maxLineLength) {
|
|
if (maxLineLength <= 0) {
|
|
return;
|
|
}
|
|
char * cursor = line;
|
|
char * last = line+maxLineLength-1;
|
|
while (true) {
|
|
*cursor = readChar();
|
|
if (*cursor == '\r' || cursor == last) {
|
|
*cursor = 0;
|
|
return;
|
|
}
|
|
cursor++;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|