+ // Do IRC Colors - only partly works
+ String fg = "<font color=\"<$1>\">";
+ text = text
+ .replaceAll("&", "&")
+ .replaceAll("<", "<")
+ .replaceAll(">", ">");
+ text = text
+ .replaceAll("\\002", "<b>") // bold
+ .replaceAll("\\011", "<i>") // italic
+ .replaceAll("\\025", "<u>"); // underline
+ text = text
+ .replaceAll("\\003(\\d+)(,\\d+)?", fg) // color
+ .replaceAll("\\013(\\d+)(,\\d+)?", fg); // color
+ text = text
+ .replaceAll("<0?0>", "#000000") // White
+ .replaceAll("<0?1>", "#000000") // Black
+ .replaceAll("<0?2>", "#000080") // Navy Blue
+ .replaceAll("<0?3>", "#008000") // Green
+ .replaceAll("<0?4>", "#FF0000") // Red
+ .replaceAll("<0?5>", "#804040") // Brown
+ .replaceAll("<0?6>", "#8000FF") // Purple
+ .replaceAll("<0?7>", "#808000") // Olive
+ .replaceAll("<0?8>", "#FFFF00") // Yellow
+ .replaceAll("<0?9>", "#00FF00") // Lime Green
+ .replaceAll("<10>", "#008080") // Teal
+ .replaceAll("<11>", "#00FFFF") // Aqua Light
+ .replaceAll("<12>", "#0000FF") // Royal Blue
+ .replaceAll("<13>", "#FF00FF") // Hot Pink
+ .replaceAll("<14>", "#808080") // Dark Gray
+ .replaceAll("<15>", "#C0C0C0"); // Light Gray
+
+ // Message formatting
+ switch (msg.how) {
+ case DIRECT:
+ case MENTION:
+ case PRIVMSG:
+ fmt = "<b>(%s) %s: %s</b>";
+ break;
+ case SENT:
+ fmt = "(%s) <b>%s</b>: %s";
+ break;
+ default:
+ fmt = "(%s) %s: %s";
+ break;
+ }
+
+ String html = String.format(fmt, when, from, text);
+ this.log.append(Html.fromHtml(html + "<br />"));
+ }
+
+ /* Private handler methods */
+ private void onRegister(Task task)
+ {
+ Os.debug("Main: onRegister");
+ this.task = task;
+ this.running = this.task.isRunning();
+ for (Object obj : this.task.getLog()) {
+ if (String.class.isInstance(obj))
+ this.notice((String)obj);
+ if (Message.class.isInstance(obj))
+ this.onMessage((Message)obj);
+ }
+ }
+
+ private void onMessage(Message msg)
+ {
+ // Debug