changeset 1518:63dc211a4c1a

New command: /echo (display a message in the log window)
author Mikael Berthe <mikael@lilotux.net>
date Sat, 27 Sep 2008 22:41:29 +0200
parents 6df03b9b17ba
children ac5a2c262098
files mcabber/src/commands.c mcabber/src/logprint.h mcabber/src/screen.c
diffstat 3 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/commands.c	Sat Sep 27 21:21:37 2008 +0200
+++ b/mcabber/src/commands.c	Sat Sep 27 22:41:29 2008 +0200
@@ -85,6 +85,7 @@
 static void do_color(char *arg);
 static void do_otr(char *arg);
 static void do_otrpolicy(char *arg);
+static void do_echo(char *arg);
 
 static void do_say_internal(char *arg, int parse_flags);
 
@@ -125,9 +126,11 @@
           COMPL_BUFFER, 0, &do_buffer);
   cmd_add("chat_disable", "Disable chat mode", 0, 0, &do_chat_disable);
   cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear);
+  cmd_add("color", "Set coloring options", COMPL_COLOR, 0, &do_color);
   cmd_add("connect", "Connect to the server", 0, 0, &do_connect);
   cmd_add("del", "Delete the current buddy", 0, 0, &do_del);
   cmd_add("disconnect", "Disconnect from server", 0, 0, &do_disconnect);
+  cmd_add("echo", "Display a string in the log window", 0, 0, &do_echo);
   cmd_add("event", "Process an event", COMPL_EVENTSID, COMPL_EVENTS, &do_event);
   cmd_add("group", "Change group display settings",
           COMPL_GROUP, COMPL_GROUPNAME, &do_group);
@@ -161,7 +164,6 @@
   cmd_add("status_to", "Show or set your status for one recipient",
           COMPL_JID, COMPL_STATUS, &do_status_to);
   cmd_add("version", "Show mcabber version", 0, 0, &do_version);
-  cmd_add("color", "Set coloring options", COMPL_COLOR, 0, &do_color);
 
   // Status category
   compl_add_category_word(COMPL_STATUS, "online");
@@ -3619,4 +3621,11 @@
   help_process(arg);
 }
 
+static void do_echo(char *arg)
+{
+  if (arg)
+    scr_print_logwindow(arg);
+}
+
+
 /* vim: set expandtab cindent cinoptions=>2\:2(0:  For Vim users... */
--- a/mcabber/src/logprint.h	Sat Sep 27 21:21:37 2008 +0200
+++ b/mcabber/src/logprint.h	Sat Sep 27 22:41:29 2008 +0200
@@ -10,6 +10,7 @@
 // For convenience...
 #define LPRINT_LOGNORM  (LPRINT_NORMAL|LPRINT_LOG)
 
+void scr_print_logwindow(const char *string);
 void scr_LogPrint(unsigned int flag, const char *fmt, ...);
 
 void scr_DoUpdate(void);
--- a/mcabber/src/screen.c	Sat Sep 27 21:21:37 2008 +0200
+++ b/mcabber/src/screen.c	Sat Sep 27 22:41:29 2008 +0200
@@ -802,8 +802,27 @@
   return timepreflengths[(n < 3 ? n : 0)];
 }
 
+//  scr_print_logwindow(string)
+// Display the string in the log window.
+// Note: The string must be in the user's locale!
+void scr_print_logwindow(const char *string)
+{
+  time_t timestamp;
+  char strtimestamp[64];
+
+  timestamp = time(NULL);
+  strftime(strtimestamp, 48, "[%H:%M:%S]", localtime(&timestamp));
+  if (Curses) {
+    wprintw(logWnd, "\n%s %s", strtimestamp, string);
+    update_panels();
+  } else {
+    printf("%s %s\n", strtimestamp, string);
+  }
+}
+
 //  scr_LogPrint(...)
-// Display a message in the log window.
+// Display a message in the log window and in the status buffer.
+// Add the message to the tracelog file if the log flag is set.
 // This function will convert from UTF-8 unless the LPRINT_NOTUTF8 flag is set.
 void scr_LogPrint(unsigned int flag, const char *fmt, ...)
 {