Allow vertical positioning of all windows

This commit is contained in:
James Booth
2016-09-23 00:56:53 +01:00
parent 3983ee1d6b
commit d3cc5bd7ed
26 changed files with 929 additions and 140 deletions

View File

@@ -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);

View File

@@ -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
},

View File

@@ -5522,16 +5522,134 @@ cmd_inpblock(ProfWin *window, const char *const command, gchar **args)
return TRUE;
}
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;
}

View File

@@ -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);