mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
stop the madness
This commit is contained in:
parent
6d42c4f949
commit
f0bd434eb0
@ -915,6 +915,8 @@ static int try_shrink_lower(MAIN_WINDOW_REC *window, int count)
|
|||||||
{
|
{
|
||||||
MAIN_WINDOW_REC *shrink_win;
|
MAIN_WINDOW_REC *shrink_win;
|
||||||
|
|
||||||
|
g_return_val_if_fail(count >= 0, FALSE);
|
||||||
|
|
||||||
shrink_win = mainwindows_find_lower(window);
|
shrink_win = mainwindows_find_lower(window);
|
||||||
if (shrink_win != NULL) {
|
if (shrink_win != NULL) {
|
||||||
int ok;
|
int ok;
|
||||||
@ -959,6 +961,8 @@ static int try_shrink_upper(MAIN_WINDOW_REC *window, int count)
|
|||||||
{
|
{
|
||||||
MAIN_WINDOW_REC *shrink_win;
|
MAIN_WINDOW_REC *shrink_win;
|
||||||
|
|
||||||
|
g_return_val_if_fail(count >= 0, FALSE);
|
||||||
|
|
||||||
shrink_win = mainwindows_find_upper(window);
|
shrink_win = mainwindows_find_upper(window);
|
||||||
if (shrink_win != NULL) {
|
if (shrink_win != NULL) {
|
||||||
int ok;
|
int ok;
|
||||||
@ -1063,6 +1067,8 @@ static int try_grow_upper(MAIN_WINDOW_REC *window, int count)
|
|||||||
|
|
||||||
static int mainwindow_shrink(MAIN_WINDOW_REC *window, int count, int resize_lower)
|
static int mainwindow_shrink(MAIN_WINDOW_REC *window, int count, int resize_lower)
|
||||||
{
|
{
|
||||||
|
g_return_val_if_fail(count >= 0, FALSE);
|
||||||
|
|
||||||
if (MAIN_WINDOW_TEXT_HEIGHT(window)-count < WINDOW_MIN_SIZE)
|
if (MAIN_WINDOW_TEXT_HEIGHT(window)-count < WINDOW_MIN_SIZE)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -1091,6 +1097,8 @@ static int try_rshrink_right(MAIN_WINDOW_REC *window, int count)
|
|||||||
{
|
{
|
||||||
MAIN_WINDOW_REC *shrink_win;
|
MAIN_WINDOW_REC *shrink_win;
|
||||||
|
|
||||||
|
g_return_val_if_fail(count >= 0, FALSE);
|
||||||
|
|
||||||
shrink_win = mainwindows_find_right(window, FALSE);
|
shrink_win = mainwindows_find_right(window, FALSE);
|
||||||
if (shrink_win != NULL) {
|
if (shrink_win != NULL) {
|
||||||
if (MAIN_WINDOW_TEXT_WIDTH(shrink_win)-count < NEW_WINDOW_WIDTH) {
|
if (MAIN_WINDOW_TEXT_WIDTH(shrink_win)-count < NEW_WINDOW_WIDTH) {
|
||||||
@ -1111,6 +1119,8 @@ static int try_rshrink_left(MAIN_WINDOW_REC *window, int count)
|
|||||||
{
|
{
|
||||||
MAIN_WINDOW_REC *shrink_win;
|
MAIN_WINDOW_REC *shrink_win;
|
||||||
|
|
||||||
|
g_return_val_if_fail(count >= 0, FALSE);
|
||||||
|
|
||||||
shrink_win = mainwindows_find_left(window, FALSE);
|
shrink_win = mainwindows_find_left(window, FALSE);
|
||||||
if (shrink_win != NULL) {
|
if (shrink_win != NULL) {
|
||||||
if (MAIN_WINDOW_TEXT_WIDTH(shrink_win)-count < NEW_WINDOW_WIDTH) {
|
if (MAIN_WINDOW_TEXT_WIDTH(shrink_win)-count < NEW_WINDOW_WIDTH) {
|
||||||
@ -1168,6 +1178,8 @@ static int try_rgrow_left(MAIN_WINDOW_REC *window, int count)
|
|||||||
|
|
||||||
static int mainwindow_rshrink(MAIN_WINDOW_REC *window, int count)
|
static int mainwindow_rshrink(MAIN_WINDOW_REC *window, int count)
|
||||||
{
|
{
|
||||||
|
g_return_val_if_fail(count >= 0, FALSE);
|
||||||
|
|
||||||
if (MAIN_WINDOW_TEXT_WIDTH(window)-count < NEW_WINDOW_WIDTH)
|
if (MAIN_WINDOW_TEXT_WIDTH(window)-count < NEW_WINDOW_WIDTH)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -1220,19 +1232,29 @@ void mainwindows_redraw_dirty(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mainwindow_grow_int(int count)
|
||||||
|
{
|
||||||
|
if (count == 0) {
|
||||||
|
return;
|
||||||
|
} else if (count < 0) {
|
||||||
|
if (!mainwindow_shrink(WINDOW_MAIN(active_win), -count, FALSE)) {
|
||||||
|
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, TXT_WINDOW_TOO_SMALL);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!mainwindow_grow(WINDOW_MAIN(active_win), count, FALSE)) {
|
||||||
|
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, TXT_WINDOW_TOO_SMALL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* SYNTAX: WINDOW GROW [<lines>] */
|
/* SYNTAX: WINDOW GROW [<lines>] */
|
||||||
static void cmd_window_grow(const char *data)
|
static void cmd_window_grow(const char *data)
|
||||||
{
|
{
|
||||||
MAIN_WINDOW_REC *window;
|
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
count = *data == '\0' ? 1 : atoi(data);
|
count = *data == '\0' ? 1 : atoi(data);
|
||||||
window = WINDOW_MAIN(active_win);
|
|
||||||
|
|
||||||
if (!mainwindow_grow(window, count, FALSE)) {
|
mainwindow_grow_int(count);
|
||||||
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
|
|
||||||
TXT_WINDOW_TOO_SMALL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: WINDOW SHRINK [<lines>] */
|
/* SYNTAX: WINDOW SHRINK [<lines>] */
|
||||||
@ -1241,16 +1263,13 @@ static void cmd_window_shrink(const char *data)
|
|||||||
int count;
|
int count;
|
||||||
|
|
||||||
count = *data == '\0' ? 1 : atoi(data);
|
count = *data == '\0' ? 1 : atoi(data);
|
||||||
if (!mainwindow_shrink(WINDOW_MAIN(active_win), count, FALSE)) {
|
|
||||||
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
|
mainwindow_grow_int(-count);
|
||||||
TXT_WINDOW_TOO_SMALL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: WINDOW SIZE <lines> */
|
/* SYNTAX: WINDOW SIZE <lines> */
|
||||||
static void cmd_window_size(const char *data)
|
static void cmd_window_size(const char *data)
|
||||||
{
|
{
|
||||||
char sizestr[MAX_INT_STRLEN];
|
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
if (!is_numeric(data, 0)) return;
|
if (!is_numeric(data, 0)) return;
|
||||||
@ -1258,13 +1277,8 @@ static void cmd_window_size(const char *data)
|
|||||||
|
|
||||||
size -= WINDOW_MAIN(active_win)->height -
|
size -= WINDOW_MAIN(active_win)->height -
|
||||||
WINDOW_MAIN(active_win)->statusbar_lines;
|
WINDOW_MAIN(active_win)->statusbar_lines;
|
||||||
if (size == 0) return;
|
|
||||||
|
|
||||||
ltoa(sizestr, size < 0 ? -size : size);
|
mainwindow_grow_int(size);
|
||||||
if (size < 0)
|
|
||||||
cmd_window_shrink(sizestr);
|
|
||||||
else
|
|
||||||
cmd_window_grow(sizestr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: WINDOW BALANCE */
|
/* SYNTAX: WINDOW BALANCE */
|
||||||
@ -1415,16 +1429,29 @@ static void cmd_window_rshow(const char *data)
|
|||||||
_cmd_window_show_opt(data, TRUE);
|
_cmd_window_show_opt(data, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void window_rgrow_int(int count)
|
||||||
|
{
|
||||||
|
if (count == 0) {
|
||||||
|
return;
|
||||||
|
} else if (count < 0) {
|
||||||
|
if (!mainwindow_rshrink(WINDOW_MAIN(active_win), -count)) {
|
||||||
|
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, TXT_WINDOW_TOO_SMALL);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!mainwindow_rgrow(WINDOW_MAIN(active_win), count)) {
|
||||||
|
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, TXT_WINDOW_TOO_SMALL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* SYNTAX: WINDOW RGROW [<columns>] */
|
/* SYNTAX: WINDOW RGROW [<columns>] */
|
||||||
static void cmd_window_rgrow(const char *data)
|
static void cmd_window_rgrow(const char *data)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
count = *data == '\0' ? 1 : atoi(data);
|
count = *data == '\0' ? 1 : atoi(data);
|
||||||
if (!mainwindow_rgrow(WINDOW_MAIN(active_win), count)) {
|
|
||||||
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
|
window_rgrow_int(count);
|
||||||
TXT_WINDOW_TOO_SMALL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: WINDOW RSHRINK [<lines>] */
|
/* SYNTAX: WINDOW RSHRINK [<lines>] */
|
||||||
@ -1433,29 +1460,21 @@ static void cmd_window_rshrink(const char *data)
|
|||||||
int count;
|
int count;
|
||||||
|
|
||||||
count = *data == '\0' ? 1 : atoi(data);
|
count = *data == '\0' ? 1 : atoi(data);
|
||||||
if (!mainwindow_rshrink(WINDOW_MAIN(active_win), count)) {
|
|
||||||
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
|
window_rgrow_int(-count);
|
||||||
TXT_WINDOW_TOO_SMALL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: WINDOW RSIZE <columns> */
|
/* SYNTAX: WINDOW RSIZE <columns> */
|
||||||
static void cmd_window_rsize(const char *data)
|
static void cmd_window_rsize(const char *data)
|
||||||
{
|
{
|
||||||
char rsizestr[MAX_INT_STRLEN];
|
|
||||||
int rsize;
|
int rsize;
|
||||||
|
|
||||||
if (!is_numeric(data, 0)) return;
|
if (!is_numeric(data, 0)) return;
|
||||||
rsize = atoi(data);
|
rsize = atoi(data);
|
||||||
|
|
||||||
rsize -= MAIN_WINDOW_TEXT_WIDTH(WINDOW_MAIN(active_win));
|
rsize -= MAIN_WINDOW_TEXT_WIDTH(WINDOW_MAIN(active_win));
|
||||||
if (rsize == 0) return;
|
|
||||||
|
|
||||||
ltoa(rsizestr, rsize < 0 ? -rsize : rsize);
|
window_rgrow_int(rsize);
|
||||||
if (rsize < 0)
|
|
||||||
cmd_window_rshrink(rsizestr);
|
|
||||||
else
|
|
||||||
cmd_window_rgrow(rsizestr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: WINDOW RBALANCE */
|
/* SYNTAX: WINDOW RBALANCE */
|
||||||
|
Loading…
Reference in New Issue
Block a user