Skip to content

Commit

Permalink
sideways split support for Irssi
Browse files Browse the repository at this point in the history
warning:

* may be buggy

This commit adds support for sideways splits into Irssi. To that regard,
there are a number of new commands available

the "R" commands:
	/window new rsplit - make a new sideways split
	/window rshow - show an existing window to the right
	/window rgrow/rshrink/rsize/rbalance
	 - manipulate the size of your sideways split windows

the "D" commands:
	/window dup/ddown/dleft/dright
	 - navigate the windows directionally, as an alternative to
	   /window up/down that you can bind to some key
	/window move dleft/dright - the same for moving

Enjoy!
  • Loading branch information
ailin-nemui committed May 5, 2017
1 parent c664fb6 commit ae5fbdf
Show file tree
Hide file tree
Showing 19 changed files with 1,370 additions and 346 deletions.
1 change: 1 addition & 0 deletions default.theme
Expand Up @@ -251,6 +251,7 @@ abstracts = {
# default background for all statusbars. You can also give
# the default foreground color for statusbar items.
sb_background = "%4%w";
window_border = "%4%w";

# default backround for "default" statusbar group
#sb_default_bg = "%4";
Expand Down
15 changes: 13 additions & 2 deletions docs/help/in/window.in
Expand Up @@ -35,17 +35,28 @@
SHRINK: %|Decrease the size of the active split window by the specified number of lines.
SIZE: %|Set the current split window size to the specified numer of lines.
BALANCE: %|Balance the heights of all split windows.
RGROW: %|Increase the width of the active split window by the specified number of columns.
RSHRINK: %|Decrease the wodth of the active split window by the specified number of columns.
RSIZE: %|Set the current split window width to the specified numer of columns.
RBALANCE: %|Balance the widths of all split windows in this line.
HIDE: %|Hides the current split window, or the split window specified by number or item name.
SHOW: %|Show the window specified by number or item name as a new split windows. It is made sticky when autostick_split_windows is turned on.
UP: %|Set the split window above the current one active. At the top, wraps to the bottom.
DOWN: %|Set the split window below the current one active. At the bottom, wraps to the top.
RSHOW: %|Show the window specified by number or item name as a new windows split to the right of the current window. It is made sticky when autostick_split_windows is turned on.
UP: %|Set the split window left or above the current one active. At the top, wraps to the bottom.
DOWN: %|Set the split window right or below the current one active. At the bottom, wraps to the top.
DUP: %|Set the split window above the current one active. At the top, wraps to the bottom.
DDOWN: %|Set the split window below the current one active. At the bottom, wraps to the top.
DLEFT: %|Set the split window left to the current one active. At the left, wraps to the right.
DRIGHT: %|Set the split window right to the current one active. At the right, wraps to the left.
LEFT: %|Go to the previous window numerically that is part of the current sticky group (or not part of any sticky group).
RIGHT: %|Go to the next window numerically that is part of the current sticky group (or not part of any sticky group).
STICK: %|Make the currently active window sticky, or stick the window specified by number to the currently visible split window. Or turn off stickyness of the currently active window or the window specified by number.
MOVE LEFT: %|Move the window to the numerically previous location inside the current sticky group.
MOVE RIGHT: %|Move the window to the numerically next location inside the current sticky group.
MOVE UP: %|Move the current window to the sticky group of the split window above. If no sticky group remains, the split window collapses.
MOVE DOWN: %|Move the current window to the sticky group of the split window below. If no sticky group remains, the split window collapses.
MOVE DLEFT: %|Move the current window to the sticky group of the split window to the left. If no sticky group remains, the split window collapses.
MOVE DRIGHT: %|Move the current window to the sticky group of the split window to the right. If no sticky group remains, the split window collapses.

%|Add the required arguments for the given command. Without arguments, the details (size, immortality, levels, server, name and sticky group) of the currently active window are displayed. If used with a number as argument, same as WINDOW REFNUM.

Expand Down
2 changes: 1 addition & 1 deletion src/common.h
Expand Up @@ -6,7 +6,7 @@
#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */

#define IRSSI_ABI_VERSION 9
#define IRSSI_ABI_VERSION 10

#define DEFAULT_SERVER_ADD_PORT 6667

Expand Down
8 changes: 8 additions & 0 deletions src/fe-common/core/fe-windows.h
Expand Up @@ -11,6 +11,14 @@ enum {
DATA_LEVEL_HILIGHT
};

enum {
MAIN_WINDOW_TYPE_NONE = -1,
MAIN_WINDOW_TYPE_DEFAULT = 0,
MAIN_WINDOW_TYPE_HIDDEN = 1,
MAIN_WINDOW_TYPE_SPLIT = 2,
MAIN_WINDOW_TYPE_RSPLIT = 3
};

typedef struct {
char *servertag;
char *name;
Expand Down
7 changes: 4 additions & 3 deletions src/fe-common/core/window-commands.c
Expand Up @@ -169,16 +169,17 @@ static void cmd_window(const char *data, void *server, WI_ITEM_REC *item)
command_runsub("window", data, server, item);
}

/* SYNTAX: WINDOW NEW [HIDDEN|SPLIT] */
/* SYNTAX: WINDOW NEW [HIDDEN|SPLIT|RSPLIT] */
static void cmd_window_new(const char *data, void *server, WI_ITEM_REC *item)
{
WINDOW_REC *window;
int type;

g_return_if_fail(data != NULL);

type = (g_ascii_strncasecmp(data, "hid", 3) == 0 || g_ascii_strcasecmp(data, "tab") == 0) ? 1 :
(g_ascii_strcasecmp(data, "split") == 0 ? 2 : 0);
type = (g_ascii_strncasecmp(data, "hid", 3) == 0 || g_ascii_strcasecmp(data, "tab") == 0) ? MAIN_WINDOW_TYPE_HIDDEN :
g_ascii_strcasecmp(data, "split") == 0 ? MAIN_WINDOW_TYPE_SPLIT :
g_ascii_strncasecmp(data, "rs", 2) == 0 ? MAIN_WINDOW_TYPE_RSPLIT : MAIN_WINDOW_TYPE_DEFAULT;
signal_emit("gui window create override", 1, GINT_TO_POINTER(type));

window = window_create(NULL, FALSE);
Expand Down
2 changes: 1 addition & 1 deletion src/fe-common/core/window-items.c
Expand Up @@ -314,7 +314,7 @@ void window_item_create(WI_ITEM_REC *item, int automatic)
/* create new window to use */
if (settings_get_bool("autocreate_split_windows")) {
signal_emit("gui window create override", 1,
GINT_TO_POINTER(0));
GINT_TO_POINTER(MAIN_WINDOW_TYPE_SPLIT));
}
window = window_create(item, automatic);
} else {
Expand Down
43 changes: 41 additions & 2 deletions src/fe-text/gui-printtext.c
Expand Up @@ -24,6 +24,7 @@

#include "formats.h"
#include "printtext.h"
#include "themes.h"

#include "term.h"
#include "gui-printtext.h"
Expand Down Expand Up @@ -138,6 +139,39 @@ void gui_printtext_after(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str)
gui_printtext_after_time(dest, prev, str, 0);
}

void gui_printtext_window_border(int x, int y)
{
char *v0, *v1;
int len;
if (current_theme != NULL) {
v1 = theme_format_expand(current_theme, "{window_border} ");
len = format_real_length(v1, 1);
v1[len] = '\0';
}
else {
v1 = g_strdup(" ");
}

if (*v1 == '\0') {
g_free(v1);
v1 = g_strdup(" ");
}

if (clrtoeol_info->color != NULL) {
char *color = g_strdup(clrtoeol_info->color);
len = format_real_length(color, 0);
color[len] = '\0';
v0 = g_strconcat(color, v1, NULL);
g_free(color);
g_free(v1);
} else {
v0 = v1;
}

gui_printtext(x, y, v0);
g_free(v0);
}

static void remove_old_lines(TEXT_BUFFER_VIEW_REC *view)
{
LINE_REC *line;
Expand Down Expand Up @@ -236,8 +270,13 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor,
term_set_color2(root_window, attr, fg, bg);

term_move(root_window, next_xpos, next_ypos);
if (flags & GUI_PRINT_FLAG_CLRTOEOL)
term_clrtoeol(root_window);
if (flags & GUI_PRINT_FLAG_CLRTOEOL) {
if (clrtoeol_info->window != NULL) {
term_window_clrtoeol_abs(clrtoeol_info->window, next_ypos);
} else {
term_clrtoeol(root_window);
}
}
next_xpos += term_addstr(root_window, str);
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/fe-text/gui-printtext.h
Expand Up @@ -20,5 +20,6 @@ void gui_printtext(int xpos, int ypos, const char *str);
void gui_printtext_internal(int xpos, int ypos, const char *str);
void gui_printtext_after(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str);
void gui_printtext_after_time(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str, time_t time);
void gui_printtext_window_border(int xpos, int ypos);

#endif
14 changes: 8 additions & 6 deletions src/fe-text/gui-windows.c
Expand Up @@ -73,17 +73,18 @@ static void gui_window_created(WINDOW_REC *window, void *automatic)

g_return_if_fail(window != NULL);

new_parent = window_create_override == 0 ||
window_create_override == 2 ||
new_parent = window_create_override == MAIN_WINDOW_TYPE_DEFAULT ||
window_create_override == MAIN_WINDOW_TYPE_SPLIT ||
window_create_override == MAIN_WINDOW_TYPE_RSPLIT ||
active_win == NULL || WINDOW_GUI(active_win) == NULL;
parent = !new_parent ? WINDOW_MAIN(active_win) : mainwindow_create();
parent = !new_parent ? WINDOW_MAIN(active_win) : mainwindow_create(window_create_override == MAIN_WINDOW_TYPE_RSPLIT);
if (parent == NULL) {
/* not enough space for new window, but we really can't
abort creation of the window anymore, so create hidden
window instead. */
parent = WINDOW_MAIN(active_win);
}
window_create_override = -1;
window_create_override = MAIN_WINDOW_TYPE_NONE;

if (parent->active == NULL) parent->active = window;
window->gui_data = gui_window_init(window, parent);
Expand Down Expand Up @@ -281,13 +282,14 @@ static void read_settings(void)

void gui_windows_init(void)
{
settings_add_bool("lookandfeel", "autostick_split_windows", TRUE);
settings_add_bool("lookandfeel", "autostick_split_windows", FALSE);
settings_add_bool("lookandfeel", "autounstick_windows", TRUE);
settings_add_int("lookandfeel", "indent", 10);
settings_add_bool("lookandfeel", "indent_always", FALSE);
settings_add_bool("lookandfeel", "break_wide", FALSE);
settings_add_bool("lookandfeel", "scroll", TRUE);

window_create_override = -1;
window_create_override = MAIN_WINDOW_TYPE_NONE;

read_settings();
signal_add("gui window create override", (SIGNAL_FUNC) sig_window_create_override);
Expand Down

0 comments on commit ae5fbdf

Please sign in to comment.