- 1. The Core Output Function
- 2. Supported Output Types
- 3. Multi-Line Output
- 4. Dynamic Output Based on Logic
- 5. Output With Variables
- 6. Outputting Objects or JSON
- 7. Using HTML (Safe Mode)
- 8. Output After Async Work (APIs, blockchain, etc.)
- 9. Scrolling Behavior (auto-scroll)
- 10. Output Events
- 11. Clearing Output
- Summary
Every command—built-in, custom, or from an add-on—prints text to the terminal using the output engine.
This engine handles text formatting, colors, auto-scrolling, and event dispatching.
This article explains exactly how to output text from your commands safely and cleanly.
1. The Core Output Function #
All output goes through one central function:
cointacted_social_terminal_append_line(text, type);
Parameters: #
- text → the message (string)
- type → message category (string)
Example:
cointacted_social_terminal_append_line("Hello!", "system");
This prints:
Hello!
2. Supported Output Types #
Your plugin supports multiple built-in output types:
| Type | Purpose |
|---|---|
"system" | Neutral/default output |
"success" | Confirmations, positive messages |
"error" | Errors, warnings, usage instructions |
"wallet" | Wallet/chain-related info |
"fun" | For FUN commands (dice, random, hi) |
"admin" | Admin/debug outputs |
| (custom) | Any custom CSS class you define |
Example usage:
cointacted_social_terminal_append_line("Done!", "success");
cointacted_social_terminal_append_line("Something went wrong", "error");
3. Multi-Line Output #
You can append as many lines as you want:
CointactedSocialTerminalTerminal.registry.demo = function() {
cointacted_social_terminal_append_line("Line One", "system");
cointacted_social_terminal_append_line("Line Two", "success");
cointacted_social_terminal_append_line("Line Three", "error");
};
4. Dynamic Output Based on Logic #
Since commands are just JavaScript functions, you can output dynamically:
CointactedSocialTerminalTerminal.registry.checkage = function(input) {
const age = parseInt(input.args[0]);
if (age < 18) {
return cointacted_social_terminal_append_line("You must be 18+.", "error");
}
cointacted_social_terminal_append_line("Access granted.", "success");
};
5. Output With Variables #
Example:
CointactedSocialTerminalTerminal.registry.greet = function(input) {
const name = input.args[0] || "stranger";
cointacted_social_terminal_append_line(`Hello, ${name}!`, "success");
};
Usage:
greet Rosvaldas
6. Outputting Objects or JSON #
Always stringify objects:
CointactedSocialTerminalTerminal.registry.debugjson = function() {
const data = {hello: "world", num: 42}
cointacted_social_terminal_append_line(JSON.stringify(data), "admin");
};
7. Using HTML (Safe Mode) #
Important:
Your terminal escapes HTML by default to prevent XSS.
So output like:
cointacted_social_terminal_append_line("<b>Bold</b>", "system");
Will print literally:
<b>Bold</b>
If you want to allow limited HTML, you must: #
- Mark the line as trusted (add a safe wrapper)
- Or use custom CSS classes with custom parsing
- Or create a new output type with innerHTML intentionally enabled
(only recommended for add-ons)
This keeps users safe.
8. Output After Async Work (APIs, blockchain, etc.) #
Async output works naturally.
CointactedSocialTerminalTerminal.registry.api = async function() {
cointacted_social_terminal_append_line("Fetching...", "system");
const res = await fetch("https://api.example.com/data");
const json = await res.json();
cointacted_social_terminal_append_line(`Result: ${json.value}`, "success");
};
The terminal will:
- print “Fetching…”
- wait for the promise
- print the result
No blocking.
9. Scrolling Behavior (auto-scroll) #
Every time you append a line:
- the terminal automatically scrolls to the bottom
- unless the user manually scrolled up (terminal won’t force scroll)
This behavior is built-in.
10. Output Events #
Every time a line is printed, the terminal fires an event:
document.addEventListener(
"cointacted_social_terminal_output",
(event) => {
console.log("Printed:", event.detail.text, "Type:", event.detail.type);
}
);
This lets developers:
- log usage
- push analytics
- sync commands to backend
- trigger animations
- add sound effects
- extend commands further
11. Clearing Output #
You never clear output manually.
The terminal already includes the clear / cls commands:
clear
If you must clear via command logic, you can call the same internal clear function (not recommended for custom commands unless intentional).
Summary #
The Output Engine provides:
✔ Unified system for printing to the terminal #
✔ Multiple style types #
✔ Multi-line output #
✔ Safe automatic escaping #
✔ Async support #
✔ Auto-scroll behavior #
✔ Output events for developers #
✔ A clean API: append_line("text", "type") #
Every terminal output—core, addons, or custom—is handled through this engine.