Added current_win_is_console

This commit is contained in:
James Booth
2016-02-28 23:28:12 +00:00
parent 7b81c5ba6d
commit ae47e116db
3 changed files with 31 additions and 6 deletions

View File

@@ -2,12 +2,16 @@ import prof
import subprocess
def _cmd_ascii(text):
proc = subprocess.Popen(['figlet', '--', text], stdout=subprocess.PIPE)
ascii_out = proc.communicate()[0].decode('utf-8')
recipient = prof.get_current_recipient()
room = prof.get_current_muc()
if recipient or room:
proc = subprocess.Popen(['figlet', '--', text], stdout=subprocess.PIPE)
ascii_out = proc.communicate()[0].decode('utf-8')
if recipient:
prof.send_line(u'\u000A' + ascii_out)
elif room:
prof.send_line(u'\u000A' + ascii_out)
elif prof.current_win_is_console():
prof.cons_show(u'\u000A' + ascii_out)
def prof_init(version, status):
synopsis = [ "/ascii <message>" ]

View File

@@ -34,7 +34,15 @@ def cmd_pythontest(arg1=None, arg2=None, arg3=None, arg4=None, arg5=None):
create_win()
prof.win_focus(plugin_win)
prof.cons_show_themed(group, key, dflt, message)
prof.win_show(plugin_win, "called -> prof_cons_show_themed: " + arg2 + ", " + arg3 + ", " + arg4 + ", " + arg5)
prof.win_show(plugin_win, "called -> prof.cons_show_themed: " + arg2 + ", " + arg3 + ", " + arg4 + ", " + arg5)
elif arg1 == "constest":
res = prof.current_win_is_console()
create_win()
prof.win_focus(plugin_win)
if res:
prof.win_show(plugin_win, "called -> prof.current_win_is_console: true")
else:
prof.win_show(plugin_win, "called -> prof.current_win_is_console: false")
elif arg1 == "winshow":
if arg2 != None:
create_win()
@@ -141,6 +149,7 @@ def prof_init(version, status):
"/python-test consalert",
"/python-test consshow <message>",
"/python-test consshow_t <group> <key> <default> <message>",
"/python-test constest",
"/python-test winshow <message>",
"/python-test winshow_t <group> <key> <default> <message>",
"/python-test notify <message>",
@@ -153,6 +162,7 @@ def prof_init(version, status):
[ "consalert", "Highlight the console window in the status bar" ],
[ "consshow <message>", "Show the message in the console window" ],
[ "consshow_t <group> <key> <default> <message>", "Show the themed message in the console window. " ],
[ "constest", "Show whether the command was run in the console." ],
[ "winshow <message>", "Show the message in the plugin window" ],
[ "winshow_t <group> <key> <default> <message>", "Show the themed message in the plugin window. " ],
[ "notify <message>", "Send a desktop notification with message" ],
@@ -171,7 +181,7 @@ def prof_init(version, status):
prof.register_command("/python-test", 1, 5, synopsis, description, args, examples, cmd_pythontest)
prof.register_ac("/python-test",
[ "consalert", "consshow", "consshow_t", "winshow", "winshow_t", "notify", "sendline", "get", "log" ]
[ "consalert", "consshow", "consshow_t", "constest", "winshow", "winshow_t", "notify", "sendline", "get", "log" ]
)
prof.register_ac("/python-test get",
[ "recipient", "room" ]

View File

@@ -60,6 +60,15 @@ cmd_ctest(char **args)
sprintf(buf, "%s%s, %s, %s, %s", str, args[1], args[2], args[3], args[4]);
prof_win_show(plugin_win, buf);
}
} else if (strcmp(args[0], "constest") == 0) {
int res = prof_current_win_is_console();
create_win();
prof_win_focus(plugin_win);
if (res) {
prof_win_show(plugin_win, "called -> prof_current_win_is_console: true");
} else {
prof_win_show(plugin_win, "called -> prof_current_win_is_console: false");
}
} else if (strcmp(args[0], "winshow") == 0) {
if (args[1]) {
create_win();
@@ -212,6 +221,7 @@ prof_init(const char * const version, const char * const status)
"/c-test consalert",
"/c-test consshow <message>",
"/c-test consshow_t <group> <key> <default> <message>",
"/c-test constest",
"/c-test winshow <message>",
"/c-test winshow_t <group> <key> <default> <message>",
"/c-test notify <message>",
@@ -225,6 +235,7 @@ prof_init(const char * const version, const char * const status)
{ "consalert", "Highlight the console window in the status bar" },
{ "consshow <message>", "Show the message in the console window" },
{ "consshow_t <group> <key> <default> <message>", "Show the themed message in the console window. " },
{ "constest", "Show whether the command was run in the console." },
{ "winshow <message>", "Show the message in the plugin window" },
{ "winshow_t <group> <key> <default> <message>", "Show the themed message in the plugin window. " },
{ "notify <message>", "Send a desktop notification with message" },
@@ -245,7 +256,7 @@ prof_init(const char * const version, const char * const status)
prof_register_command("/c-test", 1, 5, synopsis, description, args, examples, cmd_ctest);
char *cmd_ac[] = { "consalert", "consshow", "consshow_t", "winshow", "winshow_t", "notify", "sendline", "get", "log", NULL };
char *cmd_ac[] = { "consalert", "consshow", "consshow_t", "constest", "winshow", "winshow_t", "notify", "sendline", "get", "log", NULL };
prof_register_ac("/c-test", cmd_ac);
char *get_ac[] = { "recipient", "room", NULL };