ANSI Wallpaper

This commit is contained in:
y4my4my4m 2023-05-19 14:12:59 +09:00
parent ee9bf4feaa
commit 13921f5403
4 changed files with 110 additions and 38 deletions

View file

@ -0,0 +1,28 @@
U0 (*old_wall_paper)(CTask *task);
CDoc *wallpaper_doc;
U0 WallPaperAnsiInit(I64 filepath="::/Home/Wallpapers/Default.DD")
{
// if (Fs != sys_task)
// {
// "\nMust be System Included. (SHIFT-F5 / RightClick->System Include) \n";
// return;
// }
old_wall_paper = gr.fp_wall_paper;
wallpaper_doc = DocRead(filepath, DOCF_DBL_DOLLARS | DOCF_NO_CURSOR);
sys_winmgr_task->display_doc = wallpaper_doc;
if (gr_palette[0] > gr_palette[15])
Fs->text_attr = WHITE << 4 + WHITE;
else
Fs->text_attr = BLACK << 4 + BLACK;
wallpaper_doc->win_task = sys_winmgr_task;
// gr.fp_wall_paper = &WallPaperAnsi;
}
// WallPaperAnsiInit;
// WallInit;

View file

@ -0,0 +1,9 @@
There is a Telnet client, you can use it to navigate BBS systems.
ZealOS community has it's own, feel free to join us at Telnet("bbs.zealos.net", 4001);
You can now add an ANSI wallpaper using WallPaperAnsiInit;.
If you'd like for it to run at the start, make the following changes:
In ::/StartOS.ZC add the following lines after the WallPaperInit
#include "::/Demo/Graphics/WallPaperAnsi"
WallPaperAnsiInit("::/Home/Wallpapers/MyWallPaper.DD");

55
src/Home/Net/Programs/Telnet/Telnet.ZC Normal file → Executable file
View file

@ -44,26 +44,6 @@ I64 TelnetOpen(U8 *host, U16 port) {
return sock;
}
// function to increase/decrease col or row
U0 SetPos(I64 col, I64 row, Bool relativeCol=TRUE, Bool relativeRow=TRUE) {
if (col < 0) {
if (relativeCol)
term.current_col += col;
else
term.current_col = col;
if (term.current_col > term.window_width)
term.current_col = 1;
}
if (row < 0) {
if (relativeCol)
term.current_row += row;
else
term.current_row = row;
if (term.current_row > term.window_height)
term.current_row = 1;
}
}
U0 HandleControlCodes(U8 ch) {
if (ch < 32) { // ASCII code below 32 (control character)
switch (ch) {
@ -90,8 +70,8 @@ U0 HandleControlCodes(U8 ch) {
// DocPrint(term.doc, "\f");
break;
case 13: // CR (Carriage Return)
// DocPrint(term.doc, "\r");
DocPrint(term.doc, "$$CM+LX+PRY,LE=0,RE=1$$");
DocPrint(term.doc, "\r");
// DocPrint(term.doc, "$$CM+LX+PRY,LE=0,RE=1$$");
break;
case 14: // SO (Shift Out) - Switch to an alternate character set
case 15: // SI (Shift In) - Switch back to the default character set
@ -543,7 +523,7 @@ U0 ANSIParse()
term.current_col = col;
DocPrint(term.doc, "$$CM+LX+TY,LE=%d,RE=%d$$", term.current_col-1, term.current_row-1);
//DocCursorPosSet(term.doc, col, row);
ptr++;
break;
case 'J':
@ -568,20 +548,16 @@ U0 ANSIParse()
case 'K':
// TODO: I have no idea if this actually works
if (ansi_param_count == 0 || ansi_code[0] == 0) {
// Erase from cursor to end of line
// I'm not calculating current_row properly yet so it wont work as expected.
SysLog("K code 0, cur: %d\n", term.doc->cur_entry->y);
DocDelToNum(term.doc, term.doc->cur_entry->y);
} else if (ansi_code[0] == 1) {
// Erase from cursor to beginning of line
SysLog("K code 1, cur: %d\n", term.doc->cur_entry->y);
DocDelToEntry(term.doc, term.doc->cur_entry, TRUE);
} else if (ansi_code[0] == 2) {
// Erase entire line
SysLog("K code 2, cur: %d\n", term.doc->cur_entry->y);
DocDelEntry(term.doc, term.doc->cur_entry);
}
// if (ansi_param_count == 0 || ansi_code[0] == 0) {
// // Erase from cursor to end of line
// LineDeleteToEnd(term.doc->cur_entry, doc.term->cur_col);
// } else if (ansi_code[0] == 1) {
// // Erase from cursor to beginning of line
// LineDeleteToStart(term.doc->cur_entry, doc.term->cur_col);
// } else if (ansi_code[0] == 2) {
// // Erase entire line
// LineDeleteEntire(term.doc->cur_entry);
// }
ptr++;
break;
case 'L':
@ -926,6 +902,11 @@ init_connection:
"Error: Could not load art.\n";
}
break;
case CH_CTRLS:
// Save as DD image.
StrCopy(term.doc->filename.name, "::/Home/Wallpapers/Default.DD");
DocWrite(term.doc, TRUE);
break;
case CH_CTRLD:
dark_mode = !dark_mode;
if (dark_mode) Fs->text_attr = WHITE << 4 + BLACK;

56
src/Home/Net/Programs/Telnet/TelnetHelpers.ZC Normal file → Executable file
View file

@ -75,7 +75,8 @@ public U8 *ANSIArtBrowser()
U8 *selectedFile = PopUpPickFile("::/Home/Net/Programs/Telnet/Art");
if (selectedFile) {
if (StrCompare(selectedFile, "")) {
SysLog(selectedFile);
// SysLog(selectedFile);
StrCopy(Fs->task_title, selectedFile);
return selectedFile;
}
}
@ -83,6 +84,59 @@ public U8 *ANSIArtBrowser()
return NULL;
}
U0 DocCursorPosSet(CDoc *doc, I64 x, I64 y)
{
Bool unlock;
unlock = DocLock(doc);
if (doc->doc_signature == DOC_SIGNATURE_VAL)
{
doc->x = x;
doc->y = y;
DocRecalc(doc, RECALCt_FIND_CURSOR);
if (unlock)
DocUnlock(doc);
}
}
U0 DocRelCursorPosSet(CDoc *doc, I64 dx, I64 dy) {
Bool unlock;
if (!doc && !(doc = DocPut)) {
return;
}
unlock = DocLock(doc);
doc->x += dx;
doc->y += dy;
DocRecalc(doc, RECALCt_FIND_CURSOR);
if (unlock)
DocUnlock(doc);
}
// function to increase/decrease col or row
U0 SetPos(I64 col, I64 row, Bool relativeCol=TRUE, Bool relativeRow=TRUE) {
if (col < 0) {
if (relativeCol)
term.current_col += col;
else
term.current_col = col;
if (term.current_col > term.window_width)
term.current_col = 1;
}
if (row < 0) {
if (relativeCol)
term.current_row += row;
else
term.current_row = row;
if (term.current_row > term.window_height)
term.current_row = 1;
}
}
// public I64 ANSIArtBrowser()
// {
// CDirEntry *tmpde1 = NULL, *tmpde2;