1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added yellow output to plugin api

This commit is contained in:
James Booth 2014-06-08 18:36:38 +01:00
parent cc7fb03603
commit c450a78b75
8 changed files with 59 additions and 0 deletions

View File

@ -214,3 +214,16 @@ api_win_show_cyan(const char *tag, const char *line)
ui_switch_win(num); 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);
ui_switch_win(num);
}
}

View File

@ -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_green(const char *tag, const char *line);
void api_win_show_red(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_cyan(const char *tag, const char *line);
void api_win_show_yellow(const char *tag, const char *line);
#endif #endif

View File

@ -165,6 +165,12 @@ c_api_win_show_cyan(char *tag, char *line)
api_win_show_cyan(tag, line); api_win_show_cyan(tag, line);
} }
void
c_api_win_show_yellow(char *tag, char *line)
{
api_win_show_yellow(tag, line);
}
void void
c_command_callback(PluginCommand *command, gchar **args) 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_green = c_api_win_show_green;
prof_win_show_red = c_api_win_show_red; 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_cyan;
prof_win_show_cyan = c_api_win_show_yellow;
} }

View File

@ -228,6 +228,14 @@ lua_api_win_show_cyan(lua_State *L)
return 0; 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 void
lua_command_callback(PluginCommand *command, gchar **args) 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_setglobal(L, "prof_win_show_red");
lua_pushcfunction(L, lua_api_win_show_cyan); lua_pushcfunction(L, lua_api_win_show_cyan);
lua_setglobal(L, "prof_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_pushcfunction(L, lua_api_win_process_line);
lua_setglobal(L, "prof_win_process_line"); lua_setglobal(L, "prof_win_process_line");
} }

View File

@ -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_green)(PROF_WIN_TAG win, char *line) = NULL;
void (*prof_win_show_red)(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_cyan)(PROF_WIN_TAG win, char *line) = NULL;
void (*prof_win_show_yellow)(PROF_WIN_TAG win, char *line) = NULL;

View File

@ -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_green)(PROF_WIN_TAG win, char *line);
void (*prof_win_show_red)(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_cyan)(PROF_WIN_TAG win, char *line);
void (*prof_win_show_yellow)(PROF_WIN_TAG win, char *line);
#endif #endif

View File

@ -286,6 +286,20 @@ python_api_win_show_cyan(PyObject *self, PyObject *args)
return Py_BuildValue(""); 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 void
python_command_callback(PluginCommand *command, gchar **args) 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_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_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_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." }, { "win_process_line", python_api_win_process_line, METH_VARARGS, "Send a line of input to a window." },
{ NULL, NULL, 0, NULL } { NULL, NULL, 0, NULL }
}; };

View File

@ -232,6 +232,16 @@ ruby_api_win_show_cyan(VALUE self, VALUE v_tag, VALUE v_line)
return Qnil; 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 void
ruby_command_callback(PluginCommand *command, gchar **args) 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_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_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_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);
} }