From c450a78b75b35b2b252658f3abf6fcbc27d36975 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 8 Jun 2014 18:36:38 +0100 Subject: [PATCH] Added yellow output to plugin api --- src/plugins/api.c | 13 +++++++++++++ src/plugins/api.h | 1 + src/plugins/c_api.c | 7 +++++++ src/plugins/lua_api.c | 10 ++++++++++ src/plugins/profapi.c | 1 + src/plugins/profapi.h | 1 + src/plugins/python_api.c | 15 +++++++++++++++ src/plugins/ruby_api.c | 11 +++++++++++ 8 files changed, 59 insertions(+) diff --git a/src/plugins/api.c b/src/plugins/api.c index cec2e5bb..9ed16a66 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -208,6 +208,19 @@ api_win_show_cyan(const char *tag, const char *line) ProfWin *window = wins_get_by_recipient(tag); win_print_line(window, '-', COLOUR_AWAY, line); + // refresh if current + if (wins_is_current(window)) { + int num = wins_get_num(window); + ui_switch_win(num); + } +} + +void +api_win_show_yellow(const char *tag, const char *line) +{ + ProfWin *window = wins_get_by_recipient(tag); + win_print_line(window, '-', COLOUR_INCOMING, line); + // refresh if current if (wins_is_current(window)) { int num = wins_get_num(window); diff --git a/src/plugins/api.h b/src/plugins/api.h index 8af54be4..382358ce 100644 --- a/src/plugins/api.h +++ b/src/plugins/api.h @@ -51,5 +51,6 @@ void api_win_show(const char *tag, const char *line); void api_win_show_green(const char *tag, const char *line); void api_win_show_red(const char *tag, const char *line); void api_win_show_cyan(const char *tag, const char *line); +void api_win_show_yellow(const char *tag, const char *line); #endif diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c index 32cb1133..582d555b 100644 --- a/src/plugins/c_api.c +++ b/src/plugins/c_api.c @@ -165,6 +165,12 @@ c_api_win_show_cyan(char *tag, char *line) api_win_show_cyan(tag, line); } +void +c_api_win_show_yellow(char *tag, char *line) +{ + api_win_show_yellow(tag, line); +} + void c_command_callback(PluginCommand *command, gchar **args) { @@ -211,4 +217,5 @@ c_api_init(void) prof_win_show_green = c_api_win_show_green; prof_win_show_red = c_api_win_show_red; prof_win_show_cyan = c_api_win_show_cyan; + prof_win_show_cyan = c_api_win_show_yellow; } diff --git a/src/plugins/lua_api.c b/src/plugins/lua_api.c index 0f1267b6..c8b0e112 100644 --- a/src/plugins/lua_api.c +++ b/src/plugins/lua_api.c @@ -228,6 +228,14 @@ lua_api_win_show_cyan(lua_State *L) return 0; } +static int +lua_api_win_show_yellow(lua_State *L) +{ + const char *tag = lua_tostring(L, -2); + const char *line = lua_tostring(L, -1); + api_win_show_yellow(tag, line); + return 0; +} void lua_command_callback(PluginCommand *command, gchar **args) @@ -338,6 +346,8 @@ lua_api_init(lua_State *L) lua_setglobal(L, "prof_win_show_red"); lua_pushcfunction(L, lua_api_win_show_cyan); lua_setglobal(L, "prof_win_show_cyan"); + lua_pushcfunction(L, lua_api_win_show_yellow); + lua_setglobal(L, "prof_win_show_yellow"); lua_pushcfunction(L, lua_api_win_process_line); lua_setglobal(L, "prof_win_process_line"); } diff --git a/src/plugins/profapi.c b/src/plugins/profapi.c index 626e266d..2806aafd 100644 --- a/src/plugins/profapi.c +++ b/src/plugins/profapi.c @@ -53,3 +53,4 @@ void (*prof_win_show)(PROF_WIN_TAG win, char *line) = NULL; void (*prof_win_show_green)(PROF_WIN_TAG win, char *line) = NULL; void (*prof_win_show_red)(PROF_WIN_TAG win, char *line) = NULL; void (*prof_win_show_cyan)(PROF_WIN_TAG win, char *line) = NULL; +void (*prof_win_show_yellow)(PROF_WIN_TAG win, char *line) = NULL; diff --git a/src/plugins/profapi.h b/src/plugins/profapi.h index cc810d44..a9ac87a5 100644 --- a/src/plugins/profapi.h +++ b/src/plugins/profapi.h @@ -53,5 +53,6 @@ void (*prof_win_show)(PROF_WIN_TAG win, char *line); void (*prof_win_show_green)(PROF_WIN_TAG win, char *line); void (*prof_win_show_red)(PROF_WIN_TAG win, char *line); void (*prof_win_show_cyan)(PROF_WIN_TAG win, char *line); +void (*prof_win_show_yellow)(PROF_WIN_TAG win, char *line); #endif diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c index 81607c35..91ac3910 100644 --- a/src/plugins/python_api.c +++ b/src/plugins/python_api.c @@ -286,6 +286,20 @@ python_api_win_show_cyan(PyObject *self, PyObject *args) return Py_BuildValue(""); } +static PyObject * +python_api_win_show_yellow(PyObject *self, PyObject *args) +{ + char *tag = NULL; + char *line = NULL; + + if (!PyArg_ParseTuple(args, "ss", &tag, &line)) { + return Py_BuildValue(""); + } + + api_win_show_yellow(tag, line); + return Py_BuildValue(""); +} + void python_command_callback(PluginCommand *command, gchar **args) { @@ -366,6 +380,7 @@ static PyMethodDef apiMethods[] = { { "win_show_green", python_api_win_show_green, METH_VARARGS, "Show green text in the window." }, { "win_show_red", python_api_win_show_red, METH_VARARGS, "Show red text in the window." }, { "win_show_cyan", python_api_win_show_cyan, METH_VARARGS, "Show cyan text in the window." }, + { "win_show_yellow", python_api_win_show_yellow, METH_VARARGS, "Show yellow text in the window." }, { "win_process_line", python_api_win_process_line, METH_VARARGS, "Send a line of input to a window." }, { NULL, NULL, 0, NULL } }; diff --git a/src/plugins/ruby_api.c b/src/plugins/ruby_api.c index e3707aca..680a5463 100644 --- a/src/plugins/ruby_api.c +++ b/src/plugins/ruby_api.c @@ -232,6 +232,16 @@ ruby_api_win_show_cyan(VALUE self, VALUE v_tag, VALUE v_line) return Qnil; } +static VALUE +ruby_api_win_show_yellow(VALUE self, VALUE v_tag, VALUE v_line) +{ + char *tag = STR2CSTR(v_tag); + char *line = STR2CSTR(v_line); + + api_win_show_yellow(tag, line); + return Qnil; +} + void ruby_command_callback(PluginCommand *command, gchar **args) { @@ -301,4 +311,5 @@ ruby_api_init(void) rb_define_module_function(prof_module, "win_show_green", RUBY_METHOD_FUNC(ruby_api_win_show_green), 2); rb_define_module_function(prof_module, "win_show_red", RUBY_METHOD_FUNC(ruby_api_win_show_red), 2); rb_define_module_function(prof_module, "win_show_cyan", RUBY_METHOD_FUNC(ruby_api_win_show_cyan), 2); + rb_define_module_function(prof_module, "win_show_yellow", RUBY_METHOD_FUNC(ruby_api_win_show_yellow), 2); }