Update icons and enhance chat command functionality in terminal

This commit is contained in:
2026-03-05 19:30:22 +11:00
parent 4f5664a633
commit da4f07b8fe
6 changed files with 60 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -59,8 +59,8 @@
<span class="quick-commands"> <span class="quick-commands">
<button class="quick-cmd" onclick="runQuickCommand('help')" title="Show all commands">help</button> <button class="quick-cmd" onclick="runQuickCommand('help')" title="Show all commands">help</button>
<button class="quick-cmd" onclick="runQuickCommand('about')" title="About this terminal">about</button> <button class="quick-cmd" onclick="runQuickCommand('about')" title="About this terminal">about</button>
<button class="quick-cmd" onclick="runQuickCommand('projects')" title="View projects">projects</button>
<button class="quick-cmd" onclick="runQuickCommand('chat')" title="Join chat room">chat</button> <button class="quick-cmd" onclick="runQuickCommand('chat')" title="Join chat room">chat</button>
<button class="quick-cmd" onclick="runQuickCommand('clear')" title="Clear screen">clear</button>
</span> </span>
</span> </span>
</div> </div>

View File

@@ -273,6 +273,7 @@ async function enterChatMode() {
term.writeln('─'.repeat(term.cols || 60)); term.writeln('─'.repeat(term.cols || 60));
term.write('\x1b[1;32m>\x1b[0m '); term.write('\x1b[1;32m>\x1b[0m ');
showInlineInput(); showInlineInput();
updateQuickCommands('chat');
} }
// Exit chat mode // Exit chat mode
@@ -287,8 +288,57 @@ function exitChatMode() {
term.writeln(' Exited chat mode.\r\n'); term.writeln(' Exited chat mode.\r\n');
term.write(promptColored); term.write(promptColored);
showInlineInput(); showInlineInput();
updateQuickCommands('terminal');
} }
/**
* Update quick command buttons based on context
* @param {string} mode - 'terminal' or 'chat'
*/
function updateQuickCommands(mode) {
const container = document.querySelector('.quick-commands');
const statusLeft = document.querySelector('.status-left');
if (!container) return;
if (mode === 'chat') {
if (statusLeft) statusLeft.textContent = 'Chat Mode';
container.innerHTML = `
<button class="quick-cmd" onclick="runChatCommand('/help')" title="Show chat help">/help</button>
<button class="quick-cmd" onclick="runChatCommand('/nick')" title="Change nickname">/nick</button>
<button class="quick-cmd" onclick="runChatCommand('/quit')" title="Exit chat">/quit</button>
`;
} else {
if (statusLeft) statusLeft.textContent = 'Ready';
container.innerHTML = `
<button class="quick-cmd" onclick="runQuickCommand('help')" title="Show all commands">help</button>
<button class="quick-cmd" onclick="runQuickCommand('about')" title="About this terminal">about</button>
<button class="quick-cmd" onclick="runQuickCommand('chat')" title="Join chat room">chat</button>
<button class="quick-cmd" onclick="runQuickCommand('clear')" title="Clear screen">clear</button>
`;
}
}
/**
* Run a chat command from button click
* @param {string} command - The chat command to run
*/
function runChatCommand(command) {
if (!chatMode.active) return;
if (command === '/nick') {
// For /nick, just fill in the command prefix
inlineInput.value = '/nick ';
inlineInput.focus();
return;
}
// Execute the command
inlineInput.value = command;
submitInlineInput();
}
window.runChatCommand = runChatCommand;
// Sync messages from Matrix // Sync messages from Matrix
async function syncChatMessages(onlyNew = false) { async function syncChatMessages(onlyNew = false) {
try { try {
@@ -396,6 +446,9 @@ async function sendChatMessage(message) {
chatMode.inputLine = ''; chatMode.inputLine = '';
renderChatPrompt(); renderChatPrompt();
// Reposition input after render
setTimeout(() => positionInlineInput(), 10);
// Immediately sync to show our message // Immediately sync to show our message
setTimeout(() => syncChatMessages(true), 500); setTimeout(() => syncChatMessages(true), 500);
} catch (error) { } catch (error) {
@@ -404,6 +457,7 @@ async function sendChatMessage(message) {
term.writeln(`\x1b[31mError: ${error.message}\x1b[0m`); term.writeln(`\x1b[31mError: ${error.message}\x1b[0m`);
term.writeln('─'.repeat(term.cols || 60)); term.writeln('─'.repeat(term.cols || 60));
term.write(`\x1b[1;32m>\x1b[0m `); term.write(`\x1b[1;32m>\x1b[0m `);
setTimeout(() => positionInlineInput(), 10);
} }
} }
@@ -1043,7 +1097,7 @@ async function submitInlineInput() {
term.writeln(' /quit - Exit chat mode'); term.writeln(' /quit - Exit chat mode');
term.writeln('─'.repeat(term.cols || 60)); term.writeln('─'.repeat(term.cols || 60));
term.write('\x1b[1;32m>\x1b[0m '); term.write('\x1b[1;32m>\x1b[0m ');
positionInlineInput(); setTimeout(() => positionInlineInput(), 10);
return; return;
} }
@@ -1082,21 +1136,21 @@ async function submitInlineInput() {
} }
term.writeln('─'.repeat(term.cols || 60)); term.writeln('─'.repeat(term.cols || 60));
term.write('\x1b[1;32m>\x1b[0m '); term.write('\x1b[1;32m>\x1b[0m ');
positionInlineInput(); setTimeout(() => positionInlineInput(), 10);
return; return;
} }
if (cmd && !cmd.startsWith('/')) { if (cmd && !cmd.startsWith('/')) {
await sendChatMessage(cmd); await sendChatMessage(cmd);
positionInlineInput(); setTimeout(() => positionInlineInput(), 10);
} else if (cmd.startsWith('/')) { } else if (cmd.startsWith('/')) {
term.writeln(`\x1b[31mUnknown command: ${cmd.split(' ')[0]}. Type /help\x1b[0m`); term.writeln(`\x1b[31mUnknown command: ${cmd.split(' ')[0]}. Type /help\x1b[0m`);
term.writeln('─'.repeat(term.cols || 60)); term.writeln('─'.repeat(term.cols || 60));
term.write('\x1b[1;32m>\x1b[0m '); term.write('\x1b[1;32m>\x1b[0m ');
positionInlineInput(); setTimeout(() => positionInlineInput(), 10);
} else { } else {
term.write('\x1b[1;32m>\x1b[0m '); term.write('\x1b[1;32m>\x1b[0m ');
positionInlineInput(); setTimeout(() => positionInlineInput(), 10);
} }
return; return;
} }