UI::Window - shabble/irssi-docs GitHub Wiki

Irssi::UI::Window

home | Irssi | UI

ATTRIBUTES

UI::Window->{}

refnum         - Reference number
name           - Name

width          - Width
height         - Height

history_name   - Name of named historylist for this window

active         - Active window item
active_server  - Active server

servertag      - active_server must be either undef or have this same tag
                 (unless there's items in this window). This is used by
                        /WINDOW SERVER -sticky

level          - Current window level

sticky_refnum  - 1 if reference number is sticky

data_level     - Current data level
hilight_color  - Current activity hilight color

last_timestamp - Last time timestamp was written in window
last_line      - Last time text was written in window

theme_name     - Active theme in window, undef = default

METHODS

Printing and Formatting

print $str, [$level]

Print $str to this window, optionally specifying a messagelevel constant in $level.

format_get_text $module, $server, $target, $format_num, @rest

TODO

gui_printtext_after $prev, $level, $str

TODO $line is Irssi::TextUI::Line

last_line_insert

TODO

print_after $prev, $level, $str

TODO $line is Irssi::TextUI::Line

printformat $level, $format, @rest

Prints the format specified in $format to the window at the level indicated by $level. The format should be a plain name, not quoted in format expansion braces. The remaining arguments @rest are used expanded as variables within the format.

NOTE: By default, this function will only print local formats, (that is, ones which you have defined within your script using the [[Irssi::theme_register| irssi#wiki-theme_register]] function.

my $format = Irssi::theme_register([ test => '{hilight $0} Testing $1-' ]);
my $win = Irssi::active_win;
$win->printformat(Irssi::MSGLEVEL_CLIENTCRAP, 'test', qw/cakes are delicious/ );

There is a (somewhat hacky) workaround if you wish to use a built-in format for printing. See the Guide for details.

Window Management

command $str

Execute the string $str in the context of this window.

destroy

Destroys the window.

Note: It is unclear whether it is better to use this function, or issue a command such as

Irssi::command("/WINDOW $n CLOSE");
set_active

Set this window active. For example:

# Equivalent to /WINDOW 10

my $win = Irssi::window_find_refnum(10);
$win->set_active();
set_history $name

TODO: What?

get_history_lines

Returns an list of strings corresponding to the previously entered commands and text in the input widget. If the setting /SET window_history is enabled, each window will have its own set of history lines, otherwise, the list will be global.

Newer entries are appended to the list, so the most recent command in the history is always the last entry.

my @history = Irssi::active_win->get_history_lines;
print "First command: " . $history[0];
print "Last  command: " . $history[-1];

The length of the list can be anywhere from 0 to /SET max_command_history elements. Once the maximum length is reached, items are dropped from the beginning (the oldest) to make way for new entries.

change_server $server

Change the specified server context for this window. $server should be an Irssi::Server reference.

An appropriate Server instance can be retrieved using:

  • [[Irssi::active_server|Irssi#wiki-active_server]]

  • [[Irssi::server_find_tag>|Irssi#wiki-server_find_tag]]

  • [[Irssi::server_find_chatnet|Irssi#wiki-server_find_chatnet]]

set_refnum $refnum

Change the refnum of this window. Note that specifying a refnum which is already in use will swap the current and targeted window refnums. For example:

my $win = Irssi::window_find_by_refnum(5);
$win->set_refnum(2); # the old window 2 is now window 5

Additionally, Window refnums do not have to be dense, that is, sequential without gaps. It is possible to have a set of windows {1, 2, 5, 50} if desired. Creating new windows (with /WINDOW NEW or whatever), will always attempt to use the lowest free refnum. In the example above, new windows allocated would be numbered {3, 4, 6, 7, ...}.

set_name $name

Set the name of the window to the string in $name

Note: The name of the window is not usually used if it has active windowitems. It can be accessed via the $winname expando though. See Formats#Expandos

set_level $level

Change server/refnum/name/history/level in window.

activity $data_level, $hilight_color

Trigger activity indicators for this window. The first argument, $data_level is one of the following values:

enum {
    DATA_LEVEL_NONE    = 0,
    DATA_LEVEL_TEXT    = 1,
    DATA_LEVEL_MSG     = 2,
    DATA_LEVEL_HILIGHT = 3
};

Note: These symbols are not available to Perl -- their numeric values should be used directly.

  • DATA_LEVEL_NONE - Clears the activity indicator for the specified window.

  • DATA_LEVEL_TEXT - Uses {sb_act_text} abstract format.

  • DATA_LEVEL_MSG - Uses {sb_act_msg} abstract format.

  • DATA_LEVEL_HILIGHT - uses {sb_act_hilight} abstract format unless a custom colour has been set via $hilight_color. In that case, it uses the {sb_act_hilight_color} abstract.

$hilight_color is only used for DATA_LEVEL_HILIGHT data levels. For the other 3 levels, their values are controlled by the abstracts defined in the active theme.

An activity indicator such as the activity statusbar item will refresh if the data_level increases, but will not revert to a lower value until the activity indicator has been cleared by making the window visible or setting it to DATA_LEVEL_NONE.

Internally, this function performs 3 main tasks:

  • Update the data_level member of the specified window to whichever is greater of the current and new levels.

  • Emit a "window hilight" signal with this window as its only parameter. This only occurs if the new $data_level is 0, or greater than the current level.

  • Emit a "window activity" signal with the window and previous data_level values.

The $hilight_color parameter is only stored if the conditions that apply to item 2 above hold. The specified colour is a string containing Irssi colour formats, which is prepended to the activity statusbar item string for the window. In the default theme, the control sequence specified is terminated (using %n) after the highlighted window name or number is displayed.

NOTE: The activity statusbar item does not show activity changes for a window that is currently visible. It can only increase in level (e.g.: TEXT -> MSG -> HILIGHT), but will never decrease unless the value is reset by making the window visible, or passing 0 (DATA_LEVEL_NONE) as the first argument to activity.

view

Returns the Irssi::TextUI::TextBufferView object associated with this window.

Window Item Management

items

Returns a list of the Irssi::Windowitems in the window.

item_add $item, $automatic

Adds the specified Irssi::Windowitem to this window. The $automatic flag indicates TODO: what?

item_remove $item

Removes the specified Windowitem from this window.

item_destroy $item

Destroys the specified windowitem

item_prev

Cycles through the windowitems contained within this window, selecting the one prior to the active item.

item_next

Cycles through the windowitems contained within this window, selecting the one subsequent to teh active item.

get_active_name

Return active item's name, or if none is active, the window's name

item_find $server, $name

Find window item that matches best to given arguments. Note: $server is an Irssi::Server object.

⚠️ **GitHub.com Fallback** ⚠️