mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
Dark mode toggle
This commit is contained in:
parent
1286fe322d
commit
532c10dcc8
1 changed files with 54 additions and 21 deletions
|
@ -19,8 +19,8 @@ Cd(__DIR__);;
|
||||||
#include "TelnetHelpers"
|
#include "TelnetHelpers"
|
||||||
|
|
||||||
// If you're using a custom palette, the colors might not seem right.
|
// If you're using a custom palette, the colors might not seem right.
|
||||||
PaletteSet("Temple");
|
// PaletteSet("DarkTemple");
|
||||||
|
Bool dark_mode = FALSE;
|
||||||
Bool force_disconnect = FALSE;
|
Bool force_disconnect = FALSE;
|
||||||
|
|
||||||
I64 TelnetOpen(U8 *host, U16 port) {
|
I64 TelnetOpen(U8 *host, U16 port) {
|
||||||
|
@ -238,6 +238,9 @@ U0 ANSIParse()
|
||||||
if (ansi_code[m] <= 10) {
|
if (ansi_code[m] <= 10) {
|
||||||
switch (ansi_code[m]) {
|
switch (ansi_code[m]) {
|
||||||
case 0:
|
case 0:
|
||||||
|
if (dark_mode)
|
||||||
|
DocPrint(term.doc, "$$BG,WHITE$$$$BLACK$$");
|
||||||
|
else
|
||||||
DocPrint(term.doc, "$$BG$$$$FG$$");
|
DocPrint(term.doc, "$$BG$$$$FG$$");
|
||||||
isBright = FALSE;
|
isBright = FALSE;
|
||||||
break; // reset
|
break; // reset
|
||||||
|
@ -252,7 +255,8 @@ U0 ANSIParse()
|
||||||
if(!isBright){
|
if(!isBright){
|
||||||
switch (ansi_code[m]) {
|
switch (ansi_code[m]) {
|
||||||
case 30:
|
case 30:
|
||||||
DocPrint(term.doc, "$$BLACK$$");
|
if (dark_mode) DocPrint(term.doc, "$$WHITE$$");
|
||||||
|
else DocPrint(term.doc, "$$BLACK$$");
|
||||||
break;
|
break;
|
||||||
case 31:
|
case 31:
|
||||||
DocPrint(term.doc, "$$RED$$");
|
DocPrint(term.doc, "$$RED$$");
|
||||||
|
@ -273,10 +277,12 @@ U0 ANSIParse()
|
||||||
DocPrint(term.doc, "$$CYAN$$");
|
DocPrint(term.doc, "$$CYAN$$");
|
||||||
break;
|
break;
|
||||||
case 37:
|
case 37:
|
||||||
DocPrint(term.doc, "$$WHITE$$");
|
if (dark_mode) DocPrint(term.doc, "$$BLACK$$");
|
||||||
|
else DocPrint(term.doc, "$$WHITE$$");
|
||||||
break;
|
break;
|
||||||
case 39:
|
case 39:
|
||||||
DocPrint(term.doc, "$$FG$$");
|
if (dark_mode) DocPrint(term.doc, "$$WHITE$$");
|
||||||
|
else DocPrint(term.doc, "$$FG$$");
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -285,7 +291,8 @@ U0 ANSIParse()
|
||||||
switch (ansi_code[m]) {
|
switch (ansi_code[m]) {
|
||||||
case 90:
|
case 90:
|
||||||
case 30:
|
case 30:
|
||||||
DocPrint(term.doc, "$$DKGRAY$$");
|
if (dark_mode) DocPrint(term.doc, "$$LTGRAY$$");
|
||||||
|
else DocPrint(term.doc, "$$DKGRAY$$");
|
||||||
break;
|
break;
|
||||||
case 91:
|
case 91:
|
||||||
case 31:
|
case 31:
|
||||||
|
@ -313,10 +320,12 @@ U0 ANSIParse()
|
||||||
break;
|
break;
|
||||||
case 97:
|
case 97:
|
||||||
case 37:
|
case 37:
|
||||||
DocPrint(term.doc, "$$LTGRAY$$");
|
if (dark_mode) DocPrint(term.doc, "$$DKGRAY$$");
|
||||||
|
else DocPrint(term.doc, "$$LTGRAY$$");
|
||||||
break;
|
break;
|
||||||
case 39:
|
case 39:
|
||||||
DocPrint(term.doc, "$$FG$$");
|
if (dark_mode) DocPrint(term.doc, "$$WHITE$$");
|
||||||
|
else DocPrint(term.doc, "$$FG$$");
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -330,7 +339,8 @@ U0 ANSIParse()
|
||||||
if(!isBright){
|
if(!isBright){
|
||||||
switch (ansi_code[m]) {
|
switch (ansi_code[m]) {
|
||||||
case 40:
|
case 40:
|
||||||
DocPrint(term.doc,"$$BG,BLACK$$");
|
if (dark_mode) DocPrint(term.doc, "$$BG,WHITE$$");
|
||||||
|
else DocPrint(term.doc, "$$BG,BLACK$$");
|
||||||
break;
|
break;
|
||||||
case 41:
|
case 41:
|
||||||
DocPrint(term.doc,"$$BG,RED$$");
|
DocPrint(term.doc,"$$BG,RED$$");
|
||||||
|
@ -351,10 +361,12 @@ U0 ANSIParse()
|
||||||
DocPrint(term.doc,"$$BG,CYAN$$");
|
DocPrint(term.doc,"$$BG,CYAN$$");
|
||||||
break;
|
break;
|
||||||
case 47:
|
case 47:
|
||||||
DocPrint(term.doc,"$$BG,WHITE$$");
|
if (dark_mode) DocPrint(term.doc, "$$BG,BLACK$$");
|
||||||
|
else DocPrint(term.doc, "$$BG,WHITE$$");
|
||||||
break;
|
break;
|
||||||
case 49:
|
case 49:
|
||||||
DocPrint(term.doc,"$$BG$$");
|
if (dark_mode) DocPrint(term.doc, "$$BG,WHITE$$");
|
||||||
|
else DocPrint(term.doc, "$$BG$$");
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -363,7 +375,8 @@ U0 ANSIParse()
|
||||||
switch (ansi_code[m]) {
|
switch (ansi_code[m]) {
|
||||||
case 100:
|
case 100:
|
||||||
case 40:
|
case 40:
|
||||||
DocPrint(term.doc,"$$BG,DKGRAY$$");
|
if (dark_mode) DocPrint(term.doc, "$$BG,LTGRAY$$");
|
||||||
|
else DocPrint(term.doc, "$$BG,DKGRAY$$");
|
||||||
break;
|
break;
|
||||||
case 101:
|
case 101:
|
||||||
case 41:
|
case 41:
|
||||||
|
@ -391,10 +404,12 @@ U0 ANSIParse()
|
||||||
break;
|
break;
|
||||||
case 107:
|
case 107:
|
||||||
case 47:
|
case 47:
|
||||||
DocPrint(term.doc,"$$BG,LTGRAY$$");
|
if (dark_mode) DocPrint(term.doc, "$$BG,DKGRAY$$");
|
||||||
|
else DocPrint(term.doc, "$$BG,LTGRAY$$");
|
||||||
break;
|
break;
|
||||||
case 49:
|
case 49:
|
||||||
DocPrint(term.doc,"$$BG$$");
|
if (dark_mode) DocPrint(term.doc, "$$BG,LTGRAY$$");
|
||||||
|
else DocPrint(term.doc, "$$BG$$");
|
||||||
break;
|
break;
|
||||||
// reset
|
// reset
|
||||||
default: break;
|
default: break;
|
||||||
|
@ -619,6 +634,7 @@ U0 TerminalTask() {
|
||||||
ANSIParse;
|
ANSIParse;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// Buffer full or connection closed
|
||||||
DocPrint(term.doc, "Error: Connection closed by the remote host.\n");
|
DocPrint(term.doc, "Error: Connection closed by the remote host.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -642,6 +658,10 @@ U0 Telnet(U8 *host=NULL, U16 port=TELNET_PORT) {
|
||||||
"}"
|
"}"
|
||||||
"Load {"
|
"Load {"
|
||||||
" ANSIArt(,CH_CTRLO);"
|
" ANSIArt(,CH_CTRLO);"
|
||||||
|
"}"
|
||||||
|
"Config {"
|
||||||
|
" ToggleDarkMode(,CH_CTRLD);"
|
||||||
|
" SetDarkColors(,CH_CTRLT);"
|
||||||
"}"
|
"}"
|
||||||
"About {"
|
"About {"
|
||||||
" Info(,CH_CTRLL);"
|
" Info(,CH_CTRLL);"
|
||||||
|
@ -651,7 +671,8 @@ U0 Telnet(U8 *host=NULL, U16 port=TELNET_PORT) {
|
||||||
StrCopy(Fs->task_title, "TELNET");
|
StrCopy(Fs->task_title, "TELNET");
|
||||||
Fs->border_src = BDS_CONST;
|
Fs->border_src = BDS_CONST;
|
||||||
Fs->border_attr = LTGREEN << 4 + DriveTextAttrGet(':') & 15;
|
Fs->border_attr = LTGREEN << 4 + DriveTextAttrGet(':') & 15;
|
||||||
Fs->text_attr = BLACK << 4 + WHITE;
|
if (dark_mode) Fs->text_attr = WHITE << 4 + BLACK;
|
||||||
|
else Fs->text_attr = BLACK << 4 + WHITE;
|
||||||
Fs->title_src = TTS_LOCKED_CONST;
|
Fs->title_src = TTS_LOCKED_CONST;
|
||||||
DocClear(Fs->border_doc, TRUE);
|
DocClear(Fs->border_doc, TRUE);
|
||||||
|
|
||||||
|
@ -670,12 +691,16 @@ U0 Telnet(U8 *host=NULL, U16 port=TELNET_PORT) {
|
||||||
show_splash:
|
show_splash:
|
||||||
// SplashScreen
|
// SplashScreen
|
||||||
DocClear;
|
DocClear;
|
||||||
|
// probably should use word wrap?
|
||||||
|
DocPrint(, "$$WW,1$$");
|
||||||
|
DocCursor(OFF);
|
||||||
// Load the file into the buffer and get its size
|
// Load the file into the buffer and get its size
|
||||||
term.buffer_len = ANSIArtLoad(art_path, term.buffer);
|
term.buffer_len = ANSIArtLoad(art_path, term.buffer);
|
||||||
if (term.buffer_len > 0) {
|
if (term.buffer_len > 0) {
|
||||||
term.buffer[term.buffer_len] = '\0';
|
term.buffer[term.buffer_len] = '\0';
|
||||||
// parse the buffer
|
// parse the buffer
|
||||||
ANSIParse;
|
ANSIParse;
|
||||||
|
// Free(term.buffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Print("Error: Could not load splash screen.\n");
|
Print("Error: Could not load splash screen.\n");
|
||||||
|
@ -690,9 +715,6 @@ init_connection:
|
||||||
// Spawn a task to receive data from the socket
|
// Spawn a task to receive data from the socket
|
||||||
term.task = Spawn(&TerminalTask, NULL, "Telnet");
|
term.task = Spawn(&TerminalTask, NULL, "Telnet");
|
||||||
|
|
||||||
// probably should use word wrap?
|
|
||||||
DocPrint(, "$$WW,1$$");
|
|
||||||
DocCursor(OFF);
|
|
||||||
|
|
||||||
term.sock = TelnetOpen(host, port);
|
term.sock = TelnetOpen(host, port);
|
||||||
if (term.sock <= 0) {
|
if (term.sock <= 0) {
|
||||||
|
@ -793,6 +815,17 @@ init_connection:
|
||||||
"Error: Could not load art.\n";
|
"Error: Could not load art.\n";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CH_CTRLD:
|
||||||
|
SysLog("Dark mode: %d\n", dark_mode);
|
||||||
|
dark_mode = !dark_mode;
|
||||||
|
if (dark_mode) Fs->text_attr = WHITE << 4 + BLACK;
|
||||||
|
else Fs->text_attr = BLACK << 4 + WHITE;
|
||||||
|
DocRecalc(doc);
|
||||||
|
DocRecalc(term.doc);
|
||||||
|
break;
|
||||||
|
case CH_CTRLT:
|
||||||
|
PaletteSet("DarkTemple");
|
||||||
|
break;
|
||||||
case CH_CTRLL:
|
case CH_CTRLL:
|
||||||
PopUpOk("\n\n Not all BBS will work perfectly (yet). \n\n You can load ANSi artwork with Ctrl+O","\n\n\n\t\tMade by y4my4m\n\n");
|
PopUpOk("\n\n Not all BBS will work perfectly (yet). \n\n You can load ANSi artwork with Ctrl+O","\n\n\n\t\tMade by y4my4m\n\n");
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue