mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
IsDigits
This commit is contained in:
parent
e766171a1a
commit
366c3831fc
1 changed files with 24 additions and 7 deletions
|
@ -21,6 +21,10 @@
|
||||||
#define ANSI_ESC 0x1B
|
#define ANSI_ESC 0x1B
|
||||||
#define ANSI_CSI 0x5B // [
|
#define ANSI_CSI 0x5B // [
|
||||||
|
|
||||||
|
U8 IsDigit(U8 ch) {
|
||||||
|
return '0' <= ch <= '9';
|
||||||
|
}
|
||||||
|
|
||||||
I64 TelnetOpen(U8 *host, U16 port) {
|
I64 TelnetOpen(U8 *host, U16 port) {
|
||||||
I64 sock;
|
I64 sock;
|
||||||
|
|
||||||
|
@ -214,12 +218,13 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
I64 ansi_code;
|
I64 ansi_code;
|
||||||
while (1) {
|
while (1) {
|
||||||
ansi_code = 0;
|
ansi_code = 0;
|
||||||
while (*ptr >= '0' && *ptr <= '9') {
|
while (IsDigit(*ptr)) {
|
||||||
ansi_code = ansi_code * 10 + (*ptr - '0');
|
ansi_code = ansi_code * 10 + (*ptr - '0');
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
// Process ansi_code
|
// Process ansi_code
|
||||||
if (*ptr == ' ') {
|
if (*ptr == ' ') {
|
||||||
|
// skip empty space
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
else if (*ptr == ';') {
|
else if (*ptr == ';') {
|
||||||
|
@ -288,7 +293,16 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
} else if (*ptr == 'C') {
|
} else if (*ptr == 'C') {
|
||||||
// Cursor Right
|
// Cursor Right
|
||||||
I64 i;
|
I64 i;
|
||||||
for (i = 0; i < ansi_code; i++) {
|
I64 move_count = 0;
|
||||||
|
while (IsDigit(*ptr)) {
|
||||||
|
move_count = move_count * 10 + (*ptr - '0');
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
if (move_count == 0) {
|
||||||
|
move_count = 1; // Default value if no number is provided
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < move_count; i++) {
|
||||||
Print(" ");
|
Print(" ");
|
||||||
}
|
}
|
||||||
// arg = isNaN(args[0]) ? 1 : args[0];
|
// arg = isNaN(args[0]) ? 1 : args[0];
|
||||||
|
@ -300,7 +314,7 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
// self.moveCursor(-arg, 0);
|
// self.moveCursor(-arg, 0);
|
||||||
ptr++;
|
ptr++;
|
||||||
} else if (*ptr == 'E') {
|
} else if (*ptr == 'E') {
|
||||||
Print("\n");
|
"\n";
|
||||||
ptr++;
|
ptr++;
|
||||||
} else if (*ptr == 'H' || *ptr == 'f') {
|
} else if (*ptr == 'H' || *ptr == 'f') {
|
||||||
// TODO: Cursor Position
|
// TODO: Cursor Position
|
||||||
|
@ -325,8 +339,7 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
ptr++;
|
ptr++;
|
||||||
I64 code = 0;
|
I64 code = 0;
|
||||||
|
|
||||||
// while (code >= '0' && code <= '9') {
|
while (IsDigit(*ptr)) {
|
||||||
while ('0' <= *ptr <= '9') {
|
|
||||||
code = code * 10 + (*ptr - '0');
|
code = code * 10 + (*ptr - '0');
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
@ -370,7 +383,11 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sleep(500);
|
// TODO: setting this to OFF makes the login/account creation process display
|
||||||
|
// https://github.com/NuSkooler/enigma-bbs/blob/97cd0c3063b0c9f93a0fa4a44a85318ca81aef43/core/config_default.js#LL30C13-L30C34
|
||||||
|
// related refs
|
||||||
|
// https://github.com/NuSkooler/enigma-bbs/blob/97cd0c3063b0c9f93a0fa4a44a85318ca81aef43/core/connect.js#L137
|
||||||
|
|
||||||
if (request_input) {
|
if (request_input) {
|
||||||
// Prompt user for input and send it to the remote host
|
// Prompt user for input and send it to the remote host
|
||||||
"\n$$RED$$$BK,1$Input$BK,0$$$BLACK$$: ";
|
"\n$$RED$$$BK,1$Input$BK,0$$$BLACK$$: ";
|
||||||
|
|
Loading…
Reference in a new issue