From cc8fe920805b48c118c59ec266aa38397c648120 Mon Sep 17 00:00:00 2001 From: MeexReay Date: Thu, 20 Mar 2025 01:21:45 +0300 Subject: [PATCH] hello woman and colors --- app/hello/hello.js | 2 +- app/woman/woman.js | 13 +++++++++++++ sys/terminal.js | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/hello/hello.js b/app/hello/hello.js index 6abe4c4..f8b55e7 100644 --- a/app/hello/hello.js +++ b/app/hello/hello.js @@ -24,10 +24,10 @@ Github - https://github.com/MeexReay/poshlostios * reset - УНИЧТОЖИТЬ СИСТЕМУ, и установить заново :3 * cat - показать содержимое файла * ppm [package] - пакетный менеджер +* woman
- руководства по всякому Планируется: * сделать hex цвета -* прога Worldwide Objective Manuals (WOMan) которая пишет туторы по пакетам, написанию прог и описание стандартных прог * прога чтото наподобе nano или vi ` diff --git a/app/woman/woman.js b/app/woman/woman.js index ab63dbe..b77cb62 100644 --- a/app/woman/woman.js +++ b/app/woman/woman.js @@ -11,6 +11,7 @@ async function main(args) { * terminal - Работа с остальными функциями консоли * packaging - Пакетирование приложений * graphics - Отрисовка графики +* colors - Цвета в консоли `) return 1 } @@ -158,6 +159,18 @@ async function main(args) { getCursorIndex() -> index - получить индекс курсора в тексте терминала getCursor() -> [x, y] - получить курсор +`) + return 0 + } else if (args[1] == "colors") { + writeStdout(`# Цвета в консоли + +Вот как сделать цвет: $$#000000 +Вот как убрать цвет: $$reset + +Чтоб вывести это в консоль как я щас сделал пиши в начале два доллара + +Все понятно? + `) return 0 } else if (args[1] == "packaging") { diff --git a/sys/terminal.js b/sys/terminal.js index 18d15cf..7defcd5 100644 --- a/sys/terminal.js +++ b/sys/terminal.js @@ -43,7 +43,7 @@ function clearTerminal() { } function updateTerminalWOCursor() { - terminal.innerText = terminal_text + terminal.innerHTML = convertColorCodes(terminal_text) } function updateTerminal() { @@ -88,6 +88,19 @@ function updateCursor() { cursor.scrollIntoView({behavior: "smooth", inline: "end"}) } +function convertColorCodes(input) { + return input.replace(/\$\$#([0-9a-fA-F]{6})/g, '$#$1') + .replace(/\$#([0-9a-fA-F]{6})/g, '') + .replace(/\$\$reset/g, '$reset') + .replace(/\$reset/g, ''); +} + +function stripHtml(html) { + let tmp = document.createElement("DIV"); + tmp.innerHTML = html; + return tmp.textContent || tmp.innerText || ""; +} + document.onkeydown = (e) => { let key = e.key; if (!disable_stdin) {