diff options
author | James Booth <boothj5@gmail.com> | 2016-09-23 00:56:53 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-09-23 00:56:53 +0100 |
commit | d3cc5bd7ed9563dfc673b72ac3347cf41fc3d057 (patch) | |
tree | 6f7c72dda85e179b7cf1be3278e64f7a8d900674 /src/command | |
parent | 3983ee1d6be8245901e83d7d06974005000a1721 (diff) | |
download | profani-tty-d3cc5bd7ed9563dfc673b72ac3347cf41fc3d057.tar.gz |
Allow vertical positioning of all windows
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_ac.c | 16 | ||||
-rw-r--r-- | src/command/cmd_defs.c | 63 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 130 | ||||
-rw-r--r-- | src/command/cmd_funcs.h | 3 |
4 files changed, 192 insertions, 20 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index b66fce4d..adfef4af 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -194,7 +194,7 @@ static Autocomplete blocked_ac; static Autocomplete tray_ac; static Autocomplete presence_ac; static Autocomplete presence_setting_ac; -static Autocomplete inputwin_ac; +static Autocomplete winpos_ac; void cmd_ac_init(void) @@ -737,9 +737,9 @@ cmd_ac_init(void) autocomplete_add(presence_setting_ac, "online"); autocomplete_add(presence_setting_ac, "none"); - inputwin_ac = autocomplete_new(); - autocomplete_add(inputwin_ac, "top"); - autocomplete_add(inputwin_ac, "bottom"); + winpos_ac = autocomplete_new(); + autocomplete_add(winpos_ac, "up"); + autocomplete_add(winpos_ac, "down"); } void @@ -1003,7 +1003,7 @@ cmd_ac_reset(ProfWin *window) autocomplete_reset(tray_ac); autocomplete_reset(presence_ac); autocomplete_reset(presence_setting_ac); - autocomplete_reset(inputwin_ac); + autocomplete_reset(winpos_ac); autocomplete_reset(script_ac); if (script_show_ac) { @@ -1126,7 +1126,7 @@ cmd_ac_uninit(void) autocomplete_free(tray_ac); autocomplete_free(presence_ac); autocomplete_free(presence_setting_ac); - autocomplete_free(inputwin_ac); + autocomplete_free(winpos_ac); } static char* @@ -1207,8 +1207,8 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input) } } - gchar *cmds[] = { "/prefs", "/disco", "/room", "/autoping", "/inputwin" }; - Autocomplete completers[] = { prefs_ac, disco_ac, room_ac, autoping_ac, inputwin_ac }; + gchar *cmds[] = { "/prefs", "/disco", "/room", "/autoping", "/titlebar", "/mainwin", "/statusbar", "/inputwin" }; + Autocomplete completers[] = { prefs_ac, disco_ac, room_ac, autoping_ac, winpos_ac, winpos_ac, winpos_ac, winpos_ac }; for (i = 0; i < ARRAY_SIZE(cmds); i++) { result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE); diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 52c06ae5..c8732b34 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1302,20 +1302,71 @@ static struct cmd_t command_defs[] = CMD_NOEXAMPLES }, + { "/titlebar", + parse_args, 1, 1, &cons_winpos_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_titlebar) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/titlebar up", + "/titlebar down") + CMD_DESC( + "Move the title bar.") + CMD_ARGS( + { "up", "Move the title bar up the screen." }, + { "down", "Move the title bar down the screen." }) + CMD_NOEXAMPLES + }, + + { "/mainwin", + parse_args, 1, 1, &cons_winpos_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_mainwin) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/mainwin up", + "/mainwin down") + CMD_DESC( + "Move the main window.") + CMD_ARGS( + { "up", "Move the main window up the screen." }, + { "down", "Move the main window down the screen." }) + CMD_NOEXAMPLES + }, + + { "/statusbar", + parse_args, 1, 1, &cons_winpos_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_statusbar) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/statusbar up", + "/statusbar down") + CMD_DESC( + "Move the status bar.") + CMD_ARGS( + { "up", "Move the status bar up the screen." }, + { "down", "Move the status bar down the screen." }) + CMD_NOEXAMPLES + }, + { "/inputwin", - parse_args, 1, 1, &cons_inputwin_setting, + parse_args, 1, 1, &cons_winpos_setting, CMD_NOSUBFUNCS CMD_MAINFUNC(cmd_inputwin) CMD_TAGS( CMD_TAG_UI) CMD_SYN( - "/inputwin top", - "/inputwin bottom") + "/inputwin up", + "/inputwin down") CMD_DESC( - "Where to display the input window.") + "Move the input window.") CMD_ARGS( - { "top", "Show the input window at the top of the screen." }, - { "bottom", "Show the input window at the bottom of the screen." }) + { "up", "Move the input window up the screen." }, + { "down", "Move the input window down the screen." }) CMD_NOEXAMPLES }, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 4f8dc993..97782e64 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -5523,15 +5523,133 @@ cmd_inpblock(ProfWin *window, const char *const command, gchar **args) } gboolean +cmd_titlebar(ProfWin *window, const char *const command, gchar **args) +{ + if (g_strcmp0(args[0], "up") == 0) { + gboolean result = prefs_titlebar_pos_up(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move title bar up."); + } + + return TRUE; + } + if (g_strcmp0(args[0], "down") == 0) { + gboolean result = prefs_titlebar_pos_down(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move title bar down."); + } + + return TRUE; + } + + cons_bad_cmd_usage(command); + + return TRUE; +} + +gboolean +cmd_mainwin(ProfWin *window, const char *const command, gchar **args) +{ + if (g_strcmp0(args[0], "up") == 0) { + gboolean result = prefs_mainwin_pos_up(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move main window up."); + } + + return TRUE; + } + if (g_strcmp0(args[0], "down") == 0) { + gboolean result = prefs_mainwin_pos_down(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move main window down."); + } + + return TRUE; + } + + cons_bad_cmd_usage(command); + + return TRUE; +} + +gboolean +cmd_statusbar(ProfWin *window, const char *const command, gchar **args) +{ + if (g_strcmp0(args[0], "up") == 0) { + gboolean result = prefs_statusbar_pos_up(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move status bar up."); + } + + return TRUE; + } + if (g_strcmp0(args[0], "down") == 0) { + gboolean result = prefs_statusbar_pos_down(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move status bar down."); + } + + return TRUE; + } + + cons_bad_cmd_usage(command); + + return TRUE; +} + +gboolean cmd_inputwin(ProfWin *window, const char *const command, gchar **args) { - if ((g_strcmp0(args[0], "top") == 0) || (g_strcmp0(args[0], "bottom") == 0)) { - prefs_set_string(PREF_INPUTWIN, args[0]); - ui_resize(); - cons_show("Set input window position to %s", args[0]); - } else { - cons_bad_cmd_usage(command); + if (g_strcmp0(args[0], "up") == 0) { + gboolean result = prefs_inputwin_pos_up(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move input window up."); + } + + return TRUE; } + if (g_strcmp0(args[0], "down") == 0) { + gboolean result = prefs_inputwin_pos_down(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move input window down."); + } + + return TRUE; + } + + cons_bad_cmd_usage(command); return TRUE; } diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index b936de63..69358277 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -149,6 +149,9 @@ gboolean cmd_wrap(ProfWin *window, const char *const command, gchar **args); gboolean cmd_time(ProfWin *window, const char *const command, gchar **args); gboolean cmd_resource(ProfWin *window, const char *const command, gchar **args); gboolean cmd_inpblock(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_titlebar(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_mainwin(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_statusbar(ProfWin *window, const char *const command, gchar **args); gboolean cmd_inputwin(ProfWin *window, const char *const command, gchar **args); gboolean cmd_encwarn(ProfWin *window, const char *const command, gchar **args); gboolean cmd_script(ProfWin *window, const char *const command, gchar **args); |