From dee7825f05e0e558020fabe2e536e2b5d4df8050 Mon Sep 17 00:00:00 2001
From: Alexandre Morignot ]
+/* SYNTAX: CONNECT [-4 | -6] [-tls] [-tls_cert
] [-tls_pinned_cert
]
+/* SYNTAX: SERVER CONNECT [-4 | -6] [-tls] [-tls_cert
] [-tls_pinned_cert
: from the actual proxy password.
/STATUSBAR displays a list of statusbars:
/STATUSBAR displays a list of the current statusbars, along with their position and visibility:
Name Type Placement Position Visible
window window bottom 0 always
@@ -644,9 +644,9 @@ separated by : from the actual proxy password.
topic root top 1 always
-/STATUSBAR <name> prints the statusbar settings and it’s items. /STATUSBAR <name> ENABLE|DISABLE enables/disables the statusbar. /STATUSBAR <name> RESET resets the statusbar to it’s default settings, or if the statusbar was created by you, it will be removed.
/STATUSBAR <name> prints the statusbar settings (type, placement, position, visibility) as well as its items. /STATUSBAR <name> ENABLE|DISABLE enables/disables the statusbar. /STATUSBAR <name> RESET resets the statusbar to its default settings, or if the statusbar was created by you, it will be removed.
Type can be window or root, meaning if the statusbar should be created for each split window, or just once. Placement can be top or bottom. Position is a number, the higher the value the lower in screen it is. Visible can be always, active or inactive. Active/inactive is useful only with split windows, one split window is active and the rest are inactive. These settings can be changed with:
+The statusbar type can be either window or root. If the type is window, then a statusbar will be created for each split window, otherwise it will be created only once. Placement can be top or bottom, which refers to the top or bottom of the screen. Position is a number, the higher the value the lower it will appear in-screen. Visible can be always, active or inactive. Active/inactive is useful only with split windows; one split window is active and the rest are inactive. To adjust these settings, the following commands are available:
/STATUSBAR <name> TYPE window|root
/STATUSBAR <name> PLACEMENT top|bottom
@@ -654,10 +654,10 @@ separated by : from the actual proxy password.
/STATUSBAR <name> VISIBLE always|active|inactive
-When loading a new statusbar scripts, you’ll need to also specify where you want to show it. Statusbar items can be modified with:
+Statusbar items can also be added or removed via command. Note that when loading new statusbar scripts that add items, you will need to specify where you want to show the item and how it is aligned. This can be accomplished using the below commands:
/STATUSBAR <name> ADD [-before | -after <item>] [-priority #] [-alignment left|right] <item>
/STATUSBAR <name> REMOVE <item>
-The item name with statusbar scripts is usually same as the script’s name. Script’s documentation should tell if this isn’t the case. So, to add mail.pl before the window activity item (see the list with /STATUSBAR window), use: /STATUSBAR window ADD -before act mail.
For statusbar scripts, the item name is usually equivalent to the script name. The documentation of the script ought to tell you if this is not the case. For example, to add mail.pl before the window activity item, use: /STATUSBAR window ADD -before act mail.
: from the actual proxy password.
/STATUSBAR displays a list of the current statusbars, along with their position and visibility:
/STATUSBAR displays a list of statusbars:
Name Type Placement Position Visible
window window bottom 0 always
@@ -644,9 +644,9 @@ separated by : from the actual proxy password.
topic root top 1 always
-/STATUSBAR <name> prints the statusbar settings (type, placement, position, visibility) as well as its items. /STATUSBAR <name> ENABLE|DISABLE enables/disables the statusbar. /STATUSBAR <name> RESET resets the statusbar to its default settings, or if the statusbar was created by you, it will be removed.
/STATUSBAR <name> prints the statusbar settings and it’s items. /STATUSBAR <name> ENABLE|DISABLE enables/disables the statusbar. /STATUSBAR <name> RESET resets the statusbar to it’s default settings, or if the statusbar was created by you, it will be removed.
The statusbar type can be either window or root. If the type is window, then a statusbar will be created for each split window, otherwise it will be created only once. Placement can be top or bottom, which refers to the top or bottom of the screen. Position is a number, the higher the value the lower it will appear in-screen. Visible can be always, active or inactive. Active/inactive is useful only with split windows; one split window is active and the rest are inactive. To adjust these settings, the following commands are available:
+Type can be window or root, meaning if the statusbar should be created for each split window, or just once. Placement can be top or bottom. Position is a number, the higher the value the lower in screen it is. Visible can be always, active or inactive. Active/inactive is useful only with split windows, one split window is active and the rest are inactive. These settings can be changed with:
/STATUSBAR <name> TYPE window|root
/STATUSBAR <name> PLACEMENT top|bottom
@@ -654,10 +654,10 @@ separated by : from the actual proxy password.
/STATUSBAR <name> VISIBLE always|active|inactive
-Statusbar items can also be added or removed via command. Note that when loading new statusbar scripts that add items, you will need to specify where you want to show the item and how it is aligned. This can be accomplished using the below commands:
+When loading a new statusbar scripts, you’ll need to also specify where you want to show it. Statusbar items can be modified with:
/STATUSBAR <name> ADD [-before | -after <item>] [-priority #] [-alignment left|right] <item>
/STATUSBAR <name> REMOVE <item>
-For statusbar scripts, the item name is usually equivalent to the script name. The documentation of the script ought to tell you if this is not the case. For example, to add mail.pl before the window activity item, use: /STATUSBAR window ADD -before act mail.
The item name with statusbar scripts is usually same as the script’s name. Script’s documentation should tell if this isn’t the case. So, to add mail.pl before the window activity item (see the list with /STATUSBAR window), use: /STATUSBAR window ADD -before act mail.
A: They force ANSI colors even if terminal doesn’t support them. By default, irssi uses colors only if terminfo/termcap so says. The correct way to fix this would be to change your TERM environment to a value where colors work, like xterm-color or color_xterm (eg. TERM=xterm-color irssi). If this doesn’t help, then use the evil way of /SET term_force_colors ON.
A: Check here
+A: Check here
\ No newline at end of file diff --git a/docs/faq.txt b/docs/faq.txt new file mode 100644 index 00000000..719fbb9a --- /dev/null +++ b/docs/faq.txt @@ -0,0 +1,124 @@ + Frequently Asked Questions + +Q: Why doesn’t irssi display colors even when ircii etc. displays them? +A: They force ANSI colors even if terminal doesn’t support them. By default, + irssi uses colors only if terminfo/termcap so says. The correct way to fix this + would be to change your TERM environment to a value where colors work, like + xterm-color or color_xterm (eg. TERM=xterm-color irssi). If this doesn’t help, + then use the evil way of /SET term_force_colors ON. + +Q: How do I easily write text to channel that starts with ‘/’ character? +A: / /text + +Q: Why doesn’t irssi update my realname (or whatever) after I change it with / + SET realname and reconnect with /RECONNECT or /SERVER? +A: Irssi is trying to be too smart. This will be fixed in future, but for now + you should use /DISCONNECT and /CONNECT. + +Q: I connected to some server which isn’t responding but now irssi tries to + connect back to it all the time! How can I stop it? +A: Two ways. The “good way” to do it is with /DISCONNECT. Check the server tags + first with /SERVER without giving it any parameters, reconnections are those + that have tag starting with “recon” text. So most probably you’re going to do / + DISCONNECT recon-1. The other way is to remove all the reconnections with / + RMRECONNS, easier but may remove some connections you actually wanted to + reconnect (if you used multiple servers..). + +Q: How do I add seconds to timestamp? +A: /FORMAT timestamp {timestamp %%H:%%M:%%S} - and remember to add the trailing + space :) + +Q: Why does irssi say “Irssi: Channel not fully synchronized yet, try again + after a while” when I try to use /BAN etc? +A: Possibly a bug in irssi, or ircd you’re using does something that irssi + didn’t really notice. The new code should make this happen far less often than + before, but one known reason for this is when irssi doesn’t notice that you + were unable to join some channel. Currently however I don’t know of any such + events irssi doesn’t know about. + + Anyway, if this does happen, do /RAWLOG SAVE ~/rawlog soon after joining to + channel, and either try to figure out yourself why irssi didn’t get reply to + WHO request, or open a Github issue with the full log included. Note that the + rawlog is by default only 200 lines and it may not be enough to show all needed + information, so you might want to do /SET rawlog_lines 1000 or so. + + MODE +b still works fine though. + +Q: Where’s the GUI version? +A: There was one on [1]irssi-import/xirssi but it has not been maintained for a + long time. + +Q: How do I autorejoin channels after being kicked? +A: That’s evil and you shouldn’t do it. If you get kicked, you should stay out, + at least until the channel forgot you existed :) Most channels I’ve joined just + ban you if you autorejoin after kick. If you’re joined to channels who kick + people for fun, try changing channels or something. + + Anyway, if you REALLY want to do that, and you understand that you’re doing + evilness, you can use the autorejoin.pl script that comes with irssi. You’ll + still need to specify the channels you wish to rejoin with /SET + autorejoin_channels #chan1 #chan2 ... + +Q: How do I announce that I’m away/back in all channels I’ve joined? Or how do + I change my nick when setting myself away/back? +A: That’s even worse than autorejoin. Who could possibly care every time you + come and go? Many channels will kick you for using this, and I for example have + added several ignores so I’d never need to see these messages. Learn to use / + AWAY command properly and tell its existence to people who don’t know about it. + /WII yournick shows your away reason much better for people who actually want + to know if you’re there or not. + +Q: Why does irssi autojoin on invite by default? +A: The setting is /SET join_auto_chans_on_invite - it’s not the same as regular + autojoin-on-invite, which irssi doesn’t even have. The only channels that are + joined on invite, are the ones you’ve added to config with /CHANNEL ADD -auto. + This is very useful with +i channels when you need to first send an invite + request to bot, or if you get accidentally kicked from channel, the kicker can + invite you back immediately. + + I don’t see any bad side effects with this feature, so it’s ON by default. I + guess someone could start kicking/inviting you all the time but server + connection shouldn’t drop because of that, and you shouldn’t join channels + whose operators are that evil. + +Q: How to make UTF-8 support work with irssi? +A: Make sure your terminal supports UTF-8 (for example, xterm -u8). If you use + screen, you may have to do screen -U. And in Irssi do /SET term_charset utf-8. + (for 0.8.9 and older: /SET term_type utf-8) + +Q: Will there be /DETACH-like feature? +A: [2]tmux, [3]screen and [4]dtach can be used to do it just fine. + +Q: How do I run scripts automatically at startup? +A: Put them into ~/.irssi/scripts/autorun/ directory. Or better would be if you + placed them in ~/.irssi/scripts/ and created symlinks to autorun directory (eg. + cd ~/.irssi/scripts/autorun/ ; ln -s ../script.pl .) + +Q: How do I execute commands automatically at startup? +A: Put them into ~/.irssi/startup file, each command on its own line. The + preceding slash (/) is not necessary. + +Q: How do I easily edit existing topic? +A: /TOPICCopyright (c) 2000-2002 by Timo Sirainen, release under GNU FDL 1.1 license.
@@ -6,11 +8,7 @@Index with some FAQ questions that are answered in the chapter:
These settings should give you pretty good defaults (the ones I use):
+IRC Networks are made of servers, and servers have channels. The default config has a few predefined networks, to list them:
-If colors don’t work, and you know you’re not going to use some weird non-VT compatible terminal (you most probably aren’t), just say:
+/NETWORK LIST
+ /SET term_force_colors ON
-
+And to connect to one of those networks and join a channel:
-I don’t like automatic query windows, I don’t like status window, I do like msgs window where all messages go:
+/CONNECT Freenode
+/JOIN #irssi
+ /SET autocreate_own_query OFF
- /SET autocreate_query_level DCCMSGS
- /SET use_status_window OFF
- /SET use_msgs_window ON
-
+To add more networks:
-Disable automatic window closing when /PARTing channel or /UNQUERYing query:
/NETWORK ADD ExampleNet
+ /SET autoclose_windows OFF
- /SET reuse_unused_windows ON
-
+Then add some servers (with -auto to automatically connect):
-Here’s the settings that make irssi work exactly like ircII in window management (send me a note if you can think of more):
+/SERVER ADD -auto -network ExampleNet irc.example.net
+ /SET autocreate_own_query OFF
- /SET autocreate_query_level NONE
- /SET use_status_window OFF
- /SET use_msgs_window OFF
- /SET reuse_unused_windows ON
- /SET windows_auto_renumber OFF
+Automatically join to channels after connected to server:
- /SET autostick_split_windows OFF
- /SET autoclose_windows OFF
- /SET print_active_channel ON
-
+/CHANNEL ADD -auto #lounge ExampleNet
+And example how to add servers:
+To modify existing networks (or servers, or channels) just ADD again using the same name as before. This configures a network to identify with nickserv and wait for 2 seconds before joining channels:
-(OFTC network, identify with nickserv and wait for 2 seconds before joining channels)
+/NETWORK ADD -autosendcmd "/^msg nickserv ident pass;wait 2000" ExampleNet
+ /NETWORK ADD -autosendcmd "/^msg nickserv ident pass;wait 2000" OFTC
-
+If you have irssi 0.8.18 or higher and the irc network supports it, you can use SASL instead of nickserv, which is more reliable:
-(NOTE: use /IRCNET with 0.8.9 and older)
+/NETWORK ADD -sasl_username yourname -sasl_password yourpassword -sasl_mechanism PLAIN Freenode
+Then add some servers to different networks (network is already set up for them), irc.kpnqwest.fi is used by default for IRCNet but if it fails, irc.funet.fi is tried next:
+These commands have many more options, see their help for details:
- /SERVER ADD -auto -network IRCnet irc.kpnqwest.fi 6667
- /SERVER ADD -network IRCnet irc.funet.fi 6667
- /SERVER ADD -auto -network efnet efnet.cs.hut.fi 6667
-
-
-Automatically join to channels after connected to server, send op request to bot after joined to efnet/#irssi:
- - /CHANNEL ADD -auto #irssi IRCnet
- /CHANNEL ADD -auto -bots *!*bot@host.org -botcmd "/^msg $0 op pass" #irssi efnet
-
+/HELP NETWORK
+/HELP SERVER
+/HELP CHANNEL
+/HELP
+If you want lines containing your nick to hilight:
- /HILIGHT nick
-
+/HILIGHT nick
+Or, for irssi 0.8.18 or higher:
+ +/SET hilight_nick_matches_everywhere ON
+To get beeps on private messages or highlights:
+ +/SET beep_msg_level MSGS HILIGHT DCCMSGS
+No other irssi settings are needed (don’t enable bell_beeps), but there may be settings to change in your terminal multiplexer (screen/tmux), your terminal, or your desktop environment.
Windows can be scrolled up/down with PgUp and PgDown keys. If they don’t work for you, use Meta-p and Meta-n keys. For jumping to beginning or end of the buffer, use /SB HOME and /SB END commands.
By default, irssi uses “hidden windows” for everything. Hidden window is created every time you /JOIN a channel or /QUERY someone. There’s several ways you can change between these windows:
By default, irssi uses “hidden windows” for everything. Hidden windows are created every time you /JOIN a channel or /QUERY someone. There’s several ways you can change between these windows:
Meta-1, Meta-2, .. Meta-0 - Jump directly between windows 1-10
- Meta-q .. Meta-o - Jump directly between windows 11-19
- /WINDOW <number> - Jump to any window with specified number
- Ctrl-P, Ctrl-N - Jump to previous / next window
-
+Meta-1, Meta-2, .. Meta-0 - Jump directly between windows 1-10
+Meta-q .. Meta-o - Jump directly between windows 11-19
+/WINDOW <number> - Jump to any window with specified number
+Ctrl-P, Ctrl-N - Jump to previous / next window
+Clearly the easiest way is to use Meta-number keys. And what is the Meta key? ESC key always works as Meta, but there’s also easier ways. ALT could work as Meta, or if you have Windows keyboard, left Windows key might work as Meta. If they don’t work directly, you’ll need to set a few X resources (NOTE: these work with both xterm and rxvt):
+Clearly the easiest way is to use Meta-number keys. Meta usually means the ALT key, but if that doesn’t work, you can use ESC.
- XTerm*eightBitInput: false
+Mac OS X users with ALT key issues might prefer using iTerm2 instead of the default terminal emulator.
+
+Alt key as meta, for xterm/rxvt users
+
+If you use xterm or rxvt, you may need to set a few X resources:
+
+ XTerm*eightBitInput: false
XTerm*metaSendsEscape: true
-
+
With rxvt, you can also specify which key acts as Meta key. So if you want to use ALT instead of Windows key for it, use:
- rxvt*modifier: alt
-
+ rxvt*modifier: alt
+
You could do this by changing the X key mappings:
- xmodmap -e "keysym Alt_L = Meta_L Alt_L"
-
+ xmodmap -e "keysym Alt_L = Meta_L Alt_L"
+
And how exactly do you set these X resources? For Debian, there’s /etc/X11/Xresources/xterm file where you can put them and it’s read automatically when X starts. ~/.Xresources and ~/.Xdefaults files might also work. If you can’t get anything else to work, just copy and paste those lines to ~/.Xresources and directly call xrdb -merge ~/.Xresources in some xterm. The resources affect only the new xterms you start, not existing ones.
-Many windows SSH clients also don’t allow usage of ALT. One excellent client that does allow is putty, you can download it from http://www.chiark.greenend.org.uk/~sgtatham/putty/.
+Split windows and window items
+
+Note: this guide might be a better introduction to window splits
Irssi also supports split windows, they’ve had some problems in past but I think they should work pretty well now :) Here’s some commands related to them:
- /WINDOW NEW - Create new split window
- /WINDOW NEW HIDE - Create new hidden window
- /WINDOW CLOSE - Close split or hidden window
+/WINDOW NEW - Create new split window
+/WINDOW NEW HIDE - Create new hidden window
+/WINDOW CLOSE - Close split or hidden window
- /WINDOW HIDE [<number>|<name>] - Make the split window hidden window
- /WINDOW SHOW <number>|<name> - Make the hidden window a split window
+/WINDOW HIDE [<number>|<name>] - Make the split window hidden window
+/WINDOW SHOW <number>|<name> - Make the hidden window a split window
- /WINDOW SHRINK [<lines>] - Shrink the split window
- /WINDOW GROW [<lines>] - Grow the split window
- /WINDOW BALANCE - Balance the sizes of all split windows
-
+/WINDOW SHRINK [<lines>] - Shrink the split window
+/WINDOW GROW [<lines>] - Grow the split window
+/WINDOW BALANCE - Balance the sizes of all split windows
+
By default, irssi uses “sticky windowing” for split windows. This means that windows created inside one split window cannot be moved to another split window without some effort. For example you could have following window layout:
- Split window 1: win#1 - Status window, win#2 - Messages window
+ Split window 1: win#1 - Status window, win#2 - Messages window
Split window 2: win#3 - IRCnet/#channel1, win#4 - IRCnet/#channel2
Split window 3: win#5 - efnet/#channel1, win#6 - efnet/#channel2
-
+
When you are in win#1 and press ALT-6, irssi jumps to split window #3 and moves the efnet/#channel2 the active window.
With non-sticky windowing the windows don’t have any relationship with split windows, pressing ALT-6 in win#1 moves win#6 to split window 1 and sets it active, except if win#6 was already visible in some other split window irssi just changes to that split window. This it the way windows work with ircii, if you prefer it you can set it with
- /SET autostick_split_windows OFF
-
+/SET autostick_split_windows OFF
+
Each window can have multiple channels, queries and other “window items” inside them. If you don’t like windows at all, you disable automatic creating of them with
- /SET autocreate_windows OFF
-
+/SET autocreate_windows OFF
+
And if you keep all channels in one window, you most probably want the channel name printed in each line:
- /SET print_active_channel ON
-
+/SET print_active_channel ON
+
If you want to group only some channels or queries in one window, use
- /JOIN -window #channel
- /QUERY -window nick
-
+/JOIN -window #channel
+/QUERY -window nick
+
3. Server and channel automation
Irssi’s multiple IRC network support is IMHO very good - at least compared to other clients :) Even if you’re only in one IRC network you should group all your servers to be in the same IRC network as this helps with reconnecting if your primary server breaks and is probably useful in some other ways too :) For information how to actually use irssi correctly with multiple servers see the chapter 6.
-First you need to have your IRC network set, use /NETWORK command to see if it’s already there. If it isn’t, use /NETWORK ADD yournetwork. If you want to execute some commands automatically when you’re connected to some network, use -autosendcmd option. (NOTE: use /IRCNET with 0.8.9 and older.) Here’s some examples:
+First you need to have your IRC network set, use /NETWORK command to see if it’s already there. If it isn’t, use /NETWORK ADD yournetwork. If you want to execute some commands automatically when you’re connected to some network, use -autosendcmd option. Here’s some examples:
- /NETWORK ADD -autosendcmd '^msg bot invite' IRCnet
- /NETWORK ADD -autosendcmd "/^msg nickserv ident pass;wait 2000" OFTC
-
+/NETWORK ADD -autosendcmd '^msg bot invite' IRCnet
+/NETWORK ADD -autosendcmd "/^msg nickserv ident pass;wait 2000" OFTC
+
After that you need to add your servers. For example:
- /SERVER ADD -auto -network IRCnet irc.kpnqwest.fi 6667
- /SERVER ADD -auto -network worknet irc.mycompany.com 6667 password
-
+/SERVER ADD -auto -network IRCnet irc.kpnqwest.fi 6667
+/SERVER ADD -auto -network worknet irc.mycompany.com 6667 password
+
The -auto option specifies that this server is automatically connected at startup. You don’t need to make more than one server with -auto option to one IRC network, other servers are automatically connected in same network if the -auto server fails.
And finally channels:
- /CHANNEL ADD -auto -bots *!*bot@host.org -botcmd "/^msg $0 op pass" #irssi efnet
- /CHANNEL ADD -auto #secret IRCnet password
-
+/CHANNEL ADD -auto -bots *!*user@host -botcmd "/^msg $0 op pass" #irssi efnet
+/CHANNEL ADD -auto #secret IRCnet password
+
-bots and -botcmd should be the only ones needing a bit of explaining. They’re used to send commands automatically to bot when channel is joined, usually to get ops automatically. You can specify multiple bot masks with -bots option separated with spaces (and remember to quote the string then). The $0 in -botcmd specifies the first found bot in the list. If you don’t need the bot masks (ie. the bot is always with the same nick, like chanserv) you can give only the -botcmd option and the command is always sent.
@@ -228,9 +237,9 @@
First connect to all the servers, join the channels and create the queries you want. If you want to move the windows or channels around use commands:
- /WINDOW MOVE LEFT/RIGHT/number - move window elsewhere
- /WINDOW ITEM MOVE <number>|<name> - move channel/query to another window
-
+/WINDOW MOVE LEFT/RIGHT/number - move window elsewhere
+/WINDOW ITEM MOVE <number>|<name> - move channel/query to another window
+
When everything looks the way you like, use /LAYOUT SAVE command (and /SAVE, if you don’t have autosaving enabled) and when you start irssi next time, irssi remembers the positions of the channels, queries and everything. This “remembering” doesn’t mean that simply using /LAYOUT SAVE would automatically make irssi reconnect to all servers and join all channels, you’ll need the /SERVER ADD -auto and /CHANNEL ADD -auto commands to do that.
@@ -240,32 +249,32 @@
By default, all the “extra messages” go to status window. This means pretty much all messages that don’t clearly belong to some channel or query. Some people like it, some don’t. If you want to remove it, use
- /SET use_status_window OFF
-
+/SET use_status_window OFF
+
This doesn’t have any effect until you restart irssi. If you want to remove it immediately, just /WINDOW CLOSE it.
Another common window is “messages window”, where all private messages go. By default it’s disabled and query windows are created instead. To make all private messages go to msgs window, say:
- /SET use_msgs_window ON
- /SET autocreate_query_level DCCMSGS (or if you don't want queries to
+/SET use_msgs_window ON
+/SET autocreate_query_level DCCMSGS (or if you don't want queries to
dcc chats either, say NONE)
-
+
use_msgs_window either doesn’t have any effect until restarting irssi. To create it immediately say:
- /WINDOW NEW HIDE - create the window
- /WINDOW NAME (msgs) - name it to "(msgs)"
- /WINDOW LEVEL MSGS - make all private messages go to this window
- /WINDOW MOVE 1 - move it to first window
-
+/WINDOW NEW HIDE - create the window
+/WINDOW NAME (msgs) - name it to "(msgs)"
+/WINDOW LEVEL MSGS - make all private messages go to this window
+/WINDOW MOVE 1 - move it to first window
+
Note that neither use_msgs_window nor use_status_window have any effect at all if /LAYOUT SAVE has been used.
This brings us to message levels.. What are they? All messages that irssi prints have one or more “message levels”. Most common are PUBLIC for public messages in channels, MSGS for private messages and CRAP for all sorts of messages with no real classification. You can get a whole list of levels with
- /HELP levels
-
+/HELP levels
+
Status window has message level ALL -MSGS, meaning that all messages, except private messages, without more specific place go to status window. The -MSGS is there so it doesn’t conflict with messages window.
@@ -273,15 +282,15 @@
ircii and several other clients support multiple servers by placing the connection into some window. IRSSI DOES NOT. There is no required relationship between window and server. You can connect to 10 servers and manage them all in just one window, or join channel in each one of them to one single window if you really want to. That being said, here’s how you do connect to new server without closing the old connection:
- /CONNECT irc.server.org
-
+/CONNECT irc.server.org
+
Instead of the /SERVER which disconnects the existing connection. To see list of all active connections, use /SERVER without any parameters. You should see a list of something like:
- -!- IRCNet: irc.song.fi:6667 (IRCNet)
+ -!- IRCNet: irc.song.fi:6667 (IRCNet)
-!- OFTC: irc.oftc.net:6667 (OFTC)
-!- RECON-1: 192.168.0.1:6667 () (02:59 left before reconnecting)
-
+
Here you see that we’re connected to IRCNet and OFTC networks. The IRCNet at the beginning is called the “server tag” while the (IRCnet) at the end shows the IRC network. Server tag specifies unique tag to refer to the server, usually it’s the same as the IRC network. When the IRC network isn’t known it’s some part of the server name. When there’s multiple connections to same IRC network or server, irssi adds a number after the tag so there could be network, network2, network3 etc.
@@ -289,63 +298,63 @@
To disconnect one of the servers, or to stop irssi from reconnecting, use
- /DISCONNECT network - disconnect server with tag "network"
- /DISCONNECT recon-1 - stop trying to reconnect to RECON-1 server
- /RMRECONNS - stop all server reconnections
+/DISCONNECT network - disconnect server with tag "network"
+/DISCONNECT recon-1 - stop trying to reconnect to RECON-1 server
+/RMRECONNS - stop all server reconnections
- /RECONNECT recon-1 - immediately try reconnecting back to RECON-1
- /RECONNECT ALL - immediately try reconnecting back to all
+/RECONNECT recon-1 - immediately try reconnecting back to RECON-1
+/RECONNECT ALL - immediately try reconnecting back to all
servers in reconnection queue
-
+
Now that you’re connected to all your servers, you’ll have to know how to specify which one of them you want to use. One way is to have an empty window, like status or msgs window. In it, you can specify which server to set active with
- /WINDOW SERVER tag - set server "tag" active
- Ctrl-X - set the next server in list active
-
+/WINDOW SERVER tag - set server "tag" active
+Ctrl-X - set the next server in list active
+
When the server is active, you can use it normally. When there’s multiple connected servers, irssi adds [servertag] prefix to all messages in non-channel/query messages so you’ll know where it came from.
Several commands also accept -servertag option to specify which server it should use:
- /MSG -tag nick message
- /JOIN -tag #channel
- /QUERY -tag nick
-
+/MSG -tag nick message
+/JOIN -tag #channel
+/QUERY -tag nick
+
/MSG tab completion also automatically adds the -tag option when nick isn’t in active server.
Window’s server can be made sticky. When sticky, it will never automatically change to anything else, and if server gets disconnected, the window won’t have any active server. When the server gets connected again, it is automatically set active in the window. To set the window’s server sticky use
- /WINDOW SERVER -sticky tag
-
+/WINDOW SERVER -sticky tag
+
This is useful if you wish to have multiple status or msgs windows, one for each server. Here’s how to do them (repeat for each server)
- /WINDOW NEW HIDE
- /WINDOW NAME (status)
- /WINDOW LEVEL ALL -MSGS
- /WINDOW SERVER -sticky network
+/WINDOW NEW HIDE
+/WINDOW NAME (status)
+/WINDOW LEVEL ALL -MSGS
+/WINDOW SERVER -sticky network
- /WINDOW NEW HIDE
- /WINDOW NAME (msgs)
- /WINDOW LEVEL MSGS
- /WINDOW SERVER -sticky network
-
+/WINDOW NEW HIDE
+/WINDOW NAME (msgs)
+/WINDOW LEVEL MSGS
+/WINDOW SERVER -sticky network
+
7. /LASTLOG and jumping around in scrollback
/LASTLOG command can be used for searching texts in scrollback buffer. Simplest usages are
- /LASTLOG word - print all lines with "word" in them
- /LASTLOG word 10 - print last 10 occurances of "word"
- /LASTLOG -topics - print all topic changes
-
+/LASTLOG word - print all lines with "word" in them
+/LASTLOG word 10 - print last 10 occurances of "word"
+/LASTLOG -topics - print all topic changes
+
If there’s more than 1000 lines to be printed, irssi thinks that you probably made some mistake and won’t print them without -force option. If you want to save the full lastlog to file, use
- /LASTLOG -file ~/irc.log
-
+/LASTLOG -file ~/irc.log
+
With -file option you don’t need -force even if there’s more than 1000 lines. /LASTLOG has a lot of other options too, see /HELP lastlog for details.
@@ -355,29 +364,29 @@
Irssi can automatically log important messages when you’re set away (/AWAY reason). When you set yourself unaway (/AWAY), the new messages in away log are printed to screen. You can configure it with:
- /SET awaylog_level MSGS HILIGHT - Specifies what messages to log
- /SET awaylog_file ~/.irssi/away.log - Specifies the file to use
-
+/SET awaylog_level MSGS HILIGHT - Specifies what messages to log
+/SET awaylog_file ~/.irssi/away.log - Specifies the file to use
+
Easiest way to start logging with Irssi is to use autologging. With it Irssi logs all channels and private messages to specified directory. You can turn it on with
- /SET autolog ON
-
+/SET autolog ON
+
By default it logs pretty much everything execept CTCPS or CRAP (/WHOIS requests, etc). You can specify the logging level yourself with
- /SET autolog_level ALL -CRAP -CLIENTCRAP -CTCPS (this is the default)
-
+/SET autolog_level ALL -CRAP -CLIENTCRAP -CTCPS (this is the default)
+
By default irssi logs to ~/irclogs//.log. You can change this with
- /SET autolog_path ~/irclogs/$tag/$0.log (this is the default)
-
+/SET autolog_path ~/irclogs/$tag/$0.log (this is the default)
+
The path is automatically created if it doesn’t exist. $0 specifies the target (channel/nick). You can make irssi automatically rotate the logs by adding date/time formats to the file name. The formats are in “man strftime” format. For example
- /SET autolog_path ~/irclogs/%Y/$tag/$0.%m-%d.log
-
+/SET autolog_path ~/irclogs/%Y/$tag/$0.%m-%d.log
+
For logging only some specific channels or nicks, see /HELP log
@@ -387,16 +396,16 @@
/HELP bind tells pretty much everything there is to know about keyboard bindings. However, there’s the problem of how to bind some non-standard keys. They might differ a bit with each terminal, so you’ll need to find out what exactly the keypress produces. Easiest way to check that would be to see what it prints in cat. Here’s an example for pressing F1 key:
- [cras@hurina] ~% cat
+ [user@host] ~% cat
^[OP
-
+
So in irssi you would use /BIND ^[OP /ECHO F1 pressed. If you use multiple terminals which have different bindings for the key, it would be better to use eg.:
- /BIND ^[OP key F1
- /BIND ^[11~ key F1
- /BIND F1 /ECHO F1 pressed.
-
+/BIND ^[OP key F1
+/BIND ^[11~ key F1
+/BIND F1 /ECHO F1 pressed.
+
10. Proxies and IRC bouncers
@@ -404,20 +413,20 @@
Here’s an example: You have your bouncer (lets say, BNC or BNC-like) listening in irc.bouncer.org port 5000. You want to use it to connect to servers irc.dalnet and irc.efnet.org. First you’d need to setup the bouncer:
- /SET use_proxy ON
- /SET proxy_address irc.bouncer.org
- /SET proxy_port 5000
+/SET use_proxy ON
+/SET proxy_address irc.bouncer.org
+/SET proxy_port 5000
- /SET proxy_password YOUR_BNC_PASSWORD_HERE
- /SET -clear proxy_string
- /SET proxy_string_after conn %s %d
-
+/SET proxy_password YOUR_BNC_PASSWORD_HERE
+/SET -clear proxy_string
+/SET proxy_string_after conn %s %d
+
Then you’ll need to add the server connections. These are done exactly as if you’d want to connect directly to them. Nothing special about them:
- /SERVER ADD -auto -network dalnet irc.dal.net
- /SERVER ADD -auto -network efnet irc.efnet.org
-
+/SERVER ADD -auto -network dalnet irc.dal.net
+/SERVER ADD -auto -network efnet irc.efnet.org
+
With the proxy /SETs however, irssi now connects to those servers through your BNC. All server connections are made through them so you can just forget that your bouncer even exists.
@@ -427,36 +436,36 @@
All proxies have these settings in common:
- /SET use_proxy ON
- /SET proxy_address <Proxy host address>
- /SET proxy_port <Proxy port>
-
+/SET use_proxy ON
+/SET proxy_address <Proxy host address>
+/SET proxy_port <Proxy port>
+
HTTP proxy
Use these settings with HTTP proxies:
- /SET -clear proxy_password
- /EVAL SET proxy_string CONNECT %s:%d HTTP/1.0\n\n
-
+/SET -clear proxy_password
+/EVAL SET proxy_string CONNECT %s:%d HTTP/1.0\n\n
+
BNC
- /SET proxy_password your_pass
- /SET -clear proxy_string
- /SET proxy_string_after conn %s %d
-
+/SET proxy_password your_pass
+/SET -clear proxy_string
+/SET proxy_string_after conn %s %d
+
dircproxy
dircproxy separates the server connections by passwords. So, if you for example have network connection with password ircpass and OFTC connection with oftcpass, you would do something like this:
- /SET -clear proxy_password
- /SET -clear proxy_string
+/SET -clear proxy_password
+/SET -clear proxy_string
- /SERVER ADD -auto -network IRCnet fake.network 6667 ircpass
- /SERVER ADD -auto -network OFTC fake.oftc 6667 oftcpass
-
+/SERVER ADD -auto -network IRCnet fake.network 6667 ircpass
+/SERVER ADD -auto -network OFTC fake.oftc 6667 oftcpass
+
The server name and port you give isn’t used anywhere, so you can put anything you want in there.
@@ -464,19 +473,17 @@
psyBNC has internal support for multiple servers. However, it could be a bit annoying to use, and some people just use different users for connecting to different servers. You can manage this in a bit same way as with dircproxy, by creating fake connections:
- /SET -clear proxy_password
- /SET -clear proxy_string
+/SET -clear proxy_password
+/SET -clear proxy_string
- /NETWORK ADD -user networkuser IRCnet
- /SERVER ADD -auto -network IRCnet fake.network 6667 ircpass
- /NETWORK ADD -user oftcuser OFTC
- /SERVER ADD -auto -network OFTC fake.oftc 6667 oftcpass
-
+/NETWORK ADD -user networkuser IRCnet
+/SERVER ADD -auto -network IRCnet fake.network 6667 ircpass
+/NETWORK ADD -user oftcuser OFTC
+/SERVER ADD -auto -network OFTC fake.oftc 6667 oftcpass
+
So, you’ll specify the usernames with /NETWORK ADD command, and the user’s password with /SERVER ADD.
-(NOTE: use /IRCNET with 0.8.9 and older.)
-
Irssi proxy
Irssi contains it’s own proxy which you can build giving \--with-proxy option to configure. You’ll still need to run irssi in a screen to use it though.
@@ -487,65 +494,52 @@
Usage in proxy side:
- /LOAD proxy
- /SET irssiproxy_password <password>
- /SET irssiproxy_ports <network>=<port> ... (eg. IRCnet=2777 efnet=2778)
-
+/LOAD proxy
+/SET irssiproxy_password <password>
+/SET irssiproxy_ports <network>=<port> ... (eg. IRCnet=2777 efnet=2778)
+
NOTE: you MUST add all the servers you are using to server and network lists with /SERVER ADD and /NETWORK ADD. ..Except if you really don’t want to for some reason, and you only use one server connection, you may simply set:
- /SET irssiproxy_ports *=2777
-
-
-The special network name ? allows the client to select the
-network dynamically on connect (see below):
-
-
-/SET irssiproxy_ports ?=2777
-
+/SET irssiproxy_ports *=2777
+
Usage in client side:
Just connect to the irssi proxy like it is a normal server with password specified in /SET irssiproxy_password. For example:
- /SERVER ADD -network IRCnet my.irssi-proxy.org 2777 secret
- /SERVER ADD -network efnet my.irssi-proxy.org 2778 secret
-
-
-Or, if you used ? in irssiproxy_ports:
-
-
-/SERVER ADD -network IRCnet my.irssi-proxy.org 2777 IRCnet:secret
-/SERVER ADD -network efnet my.irssi-proxy.org 2777 efnet:secret
-
-
-I.e. the network to connect to is specified as part of the password,
-separated by : from the actual proxy password.
+/SERVER ADD -network IRCnet my.irssi-proxy.org 2777 secret
+/SERVER ADD -network efnet my.irssi-proxy.org 2778 secret
+
Irssi proxy works fine with other IRC clients as well.
SOCKS
-Irssi can be compiled with socks support (\--with-socks option to configure), but I don’t really know how it works, if at all. /SET proxy settings don’t have anything to do with socks however.
+Irssi can be compiled with socks support (\--with-socks option to configure), which requires “dante” and routes all connections through the proxy specified in the system-wide /etc/socks.conf. This method is known to have issues in Mac OS X.
+
+Note that /SET proxy settings don’t have anything to do with socks.
+
+Using proxychains-ng is recommended over recompiling irssi.
Others
IRC bouncers usually work like IRC servers, and want a password. You can give it with:
- /SET proxy_password <password>
-
+/SET proxy_password <password>
+
Irssi’s defaults for connect strings are
- /SET proxy_string CONNECT %s %d
- /SET proxy_string_after
-
+/SET proxy_string CONNECT %s %d
+/SET proxy_string_after
+
The proxy_string is sent before NICK/USER commands, the proxy_string_after is sent after them. %s and %d can be used with both of them.
11. Irssi’s settings
-You probably don’t like Irssi’s default settings. I don’t like them. But I’m still convinced that they’re pretty good defaults. Here’s some of them you might want to change (the default value is shown): Also check the Settings Documentation
+Here’s some settings you might want to change (the default value is shown): Also check the Settings Documentation
Queries
@@ -633,31 +627,61 @@ separated by : from the actual proxy password.
Completion character to use.
+For all the ircII people
+
+I don’t like automatic query windows, I don’t like status window, I do like msgs window where all messages go:
+
+/SET autocreate_own_query OFF
+/SET autocreate_query_level DCCMSGS
+/SET use_status_window OFF
+/SET use_msgs_window ON
+
+
+Disable automatic window closing when /PARTing channel or /UNQUERYing query:
+
+/SET autoclose_windows OFF
+/SET reuse_unused_windows ON
+
+
+Here’s the settings that make irssi work exactly like ircII in window management (send me a note if you can think of more):
+
+/SET autocreate_own_query OFF
+/SET autocreate_query_level NONE
+/SET use_status_window OFF
+/SET use_msgs_window OFF
+/SET reuse_unused_windows ON
+/SET windows_auto_renumber OFF
+
+/SET autostick_split_windows OFF
+/SET autoclose_windows OFF
+/SET print_active_channel ON
+
+
12. Statusbar
-/STATUSBAR displays a list of statusbars:
+/STATUSBAR displays a list of the current statusbars, along with their position and visibility:
- Name Type Placement Position Visible
+ Name Type Placement Position Visible
window window bottom 0 always
window_inact window bottom 1 inactive
prompt root bottom 100 always
topic root top 1 always
-
+
-/STATUSBAR <name> prints the statusbar settings and it’s items. /STATUSBAR <name> ENABLE|DISABLE enables/disables the statusbar. /STATUSBAR <name> RESET resets the statusbar to it’s default settings, or if the statusbar was created by you, it will be removed.
+/STATUSBAR <name> prints the statusbar settings (type, placement, position, visibility) as well as its items. /STATUSBAR <name> ENABLE|DISABLE enables/disables the statusbar. /STATUSBAR <name> RESET resets the statusbar to its default settings, or if the statusbar was created by you, it will be removed.
-Type can be window or root, meaning if the statusbar should be created for each split window, or just once. Placement can be top or bottom. Position is a number, the higher the value the lower in screen it is. Visible can be always, active or inactive. Active/inactive is useful only with split windows, one split window is active and the rest are inactive. These settings can be changed with:
+The statusbar type can be either window or root. If the type is window, then a statusbar will be created for each split window, otherwise it will be created only once. Placement can be top or bottom, which refers to the top or bottom of the screen. Position is a number, the higher the value the lower it will appear in-screen. Visible can be always, active or inactive. Active/inactive is useful only with split windows; one split window is active and the rest are inactive. To adjust these settings, the following commands are available:
- /STATUSBAR <name> TYPE window|root
- /STATUSBAR <name> PLACEMENT top|bottom
- /STATUSBAR <name> POSITION <num>
- /STATUSBAR <name> VISIBLE always|active|inactive
-
+/STATUSBAR <name> TYPE window|root
+/STATUSBAR <name> PLACEMENT top|bottom
+/STATUSBAR <name> POSITION <num>
+/STATUSBAR <name> VISIBLE always|active|inactive
+
-When loading a new statusbar scripts, you’ll need to also specify where you want to show it. Statusbar items can be modified with:
+Statusbar items can also be added or removed via command. Note that when loading new statusbar scripts that add items, you will need to specify where you want to show the item and how it is aligned. This can be accomplished using the below commands:
- /STATUSBAR <name> ADD [-before | -after <item>] [-priority #] [-alignment left|right] <item>
- /STATUSBAR <name> REMOVE <item>
-
+/STATUSBAR <name> ADD [-before | -after <item>] [-priority #] [-alignment left|right] <item>
+/STATUSBAR <name> REMOVE <item>
+
-The item name with statusbar scripts is usually same as the script’s name. Script’s documentation should tell if this isn’t the case. So, to add mail.pl before the window activity item (see the list with /STATUSBAR window), use: /STATUSBAR window ADD -before act mail.
+For statusbar scripts, the item name is usually equivalent to the script name. The documentation of the script ought to tell you if this is not the case. For example, to add mail.pl before the window activity item, use: /STATUSBAR window ADD -before act mail.
\ No newline at end of file
diff --git a/docs/startup-HOWTO.txt b/docs/startup-HOWTO.txt
new file mode 100644
index 00000000..23d7cf94
--- /dev/null
+++ b/docs/startup-HOWTO.txt
@@ -0,0 +1,797 @@
+Startup How-To
+
+To new Irssi users (not to new IRC users ..)
+
+Copyright (c) 2000-2002 by Timo Sirainen, release under [1]GNU FDL 1.1 license.
+
+Index with some FAQ questions that are answered in the chapter:
+
+ 1. First steps
+ 2. Basic user interface usage
+ □ Split windows work in weird way
+ □ How can I easily switch between windows?
+ □ But alt-1 etc. don’t work!
+ 3. Server and channel automation
+ □ How do I automatically connect to servers at startup?
+ □ How do I automatically join to channels at startup?
+ □ How do I automatically send commands to server at connect?
+ 4. Setting up windows and automatically restoring them at startup
+ 5. Status and msgs windows & message levels
+ □ I want /WHOIS to print reply to current window
+ □ I want all messages to go to one window, not create new windows
+ 6. How support for multiple servers works in irssi
+ □ I connected to some server that doesn’t respond and now irssi keeps
+ trying to reconnect to it again and again, how can I stop it??
+ □ I want to have own status and/or msgs window for each servers
+ 7. /LASTLOG and jumping around in scrollback
+ □ How can I save all texts in a window to file?
+ 8. Logging
+ 9. Changing keyboard bindings
+ □ How do I make F1 key do something?
+10. Proxies and IRC bouncers
+11. Irssi’s settings
+ □ For all the ircII people
+12. Statusbar
+ □ I loaded a statusbar script but it’s not visible anywhere!
+
+1. First steps
+
+IRC Networks are made of servers, and servers have channels. The default config
+has a few predefined networks, to list them:
+
+/NETWORK LIST
+
+And to connect to one of those networks and join a channel:
+
+/CONNECT Freenode
+/JOIN #irssi
+
+To add more networks:
+
+/NETWORK ADD ExampleNet
+
+Then add some servers (with -auto to automatically connect):
+
+/SERVER ADD -auto -network ExampleNet irc.example.net
+
+Automatically join to channels after connected to server:
+
+/CHANNEL ADD -auto #lounge ExampleNet
+
+To modify existing networks (or servers, or channels) just ADD again using the
+same name as before. This configures a network to identify with nickserv and
+wait for 2 seconds before joining channels:
+
+/NETWORK ADD -autosendcmd "/^msg nickserv ident pass;wait 2000" ExampleNet
+
+If you have irssi 0.8.18 or higher and the irc network supports it, you can use
+SASL instead of nickserv, which is more reliable:
+
+/NETWORK ADD -sasl_username yourname -sasl_password yourpassword -sasl_mechanism PLAIN Freenode
+
+These commands have many more options, see their help for details:
+
+/HELP NETWORK
+/HELP SERVER
+/HELP CHANNEL
+/HELP
+
+If you want lines containing your nick to hilight:
+
+/HILIGHT nick
+
+Or, for irssi 0.8.18 or higher:
+
+/SET hilight_nick_matches_everywhere ON
+
+To get beeps on private messages or highlights:
+
+/SET beep_msg_level MSGS HILIGHT DCCMSGS
+
+No other irssi settings are needed (don’t enable bell_beeps), but there may be
+settings to change in your terminal multiplexer (screen/tmux), your terminal,
+or your desktop environment.
+
+2. Basic user interface usage
+
+Windows can be scrolled up/down with PgUp and PgDown keys. If they don’t work
+for you, use Meta-p and Meta-n keys. For jumping to beginning or end of the
+buffer, use /SB HOME and /SB END commands.
+
+By default, irssi uses “hidden windows” for everything. Hidden windows are
+created every time you /JOIN a channel or /QUERY someone. There’s several ways
+you can change between these windows:
+
+Meta-1, Meta-2, .. Meta-0 - Jump directly between windows 1-10
+Meta-q .. Meta-o - Jump directly between windows 11-19
+/WINDOW - Jump to any window with specified number
+Ctrl-P, Ctrl-N - Jump to previous / next window
+
+Clearly the easiest way is to use Meta-number keys. Meta usually means the ALT
+key, but if that doesn’t work, you can use ESC.
+
+Mac OS X users with ALT key issues might prefer using [2]iTerm2 instead of the
+default terminal emulator.
+
+Alt key as meta, for xterm/rxvt users
+
+If you use xterm or rxvt, you may need to set a few X resources:
+
+ XTerm*eightBitInput: false
+ XTerm*metaSendsEscape: true
+
+With rxvt, you can also specify which key acts as Meta key. So if you want to
+use ALT instead of Windows key for it, use:
+
+ rxvt*modifier: alt
+
+You could do this by changing the X key mappings:
+
+ xmodmap -e "keysym Alt_L = Meta_L Alt_L"
+
+And how exactly do you set these X resources? For Debian, there’s /etc/X11/
+Xresources/xterm file where you can put them and it’s read automatically when X
+starts. ~/.Xresources and ~/.Xdefaults files might also work. If you can’t get
+anything else to work, just copy and paste those lines to ~/.Xresources and
+directly call xrdb -merge ~/.Xresources in some xterm. The resources affect
+only the new xterms you start, not existing ones.
+
+Split windows and window items
+
+Note: [3]this guide might be a better introduction to window splits
+
+Irssi also supports split windows, they’ve had some problems in past but I
+think they should work pretty well now :) Here’s some commands related to them:
+
+/WINDOW NEW - Create new split window
+/WINDOW NEW HIDE - Create new hidden window
+/WINDOW CLOSE - Close split or hidden window
+
+/WINDOW HIDE [|] - Make the split window hidden window
+/WINDOW SHOW | - Make the hidden window a split window
+
+/WINDOW SHRINK [] - Shrink the split window
+/WINDOW GROW [] - Grow the split window
+/WINDOW BALANCE - Balance the sizes of all split windows
+
+By default, irssi uses “sticky windowing” for split windows. This means that
+windows created inside one split window cannot be moved to another split window
+without some effort. For example you could have following window layout:
+
+ Split window 1: win#1 - Status window, win#2 - Messages window
+ Split window 2: win#3 - IRCnet/#channel1, win#4 - IRCnet/#channel2
+ Split window 3: win#5 - efnet/#channel1, win#6 - efnet/#channel2
+
+When you are in win#1 and press ALT-6, irssi jumps to split window #3 and moves
+the efnet/#channel2 the active window.
+
+With non-sticky windowing the windows don’t have any relationship with split
+windows, pressing ALT-6 in win#1 moves win#6 to split window 1 and sets it
+active, except if win#6 was already visible in some other split window irssi
+just changes to that split window. This it the way windows work with ircii, if
+you prefer it you can set it with
+
+/SET autostick_split_windows OFF
+
+Each window can have multiple channels, queries and other “window items” inside
+them. If you don’t like windows at all, you disable automatic creating of them
+with
+
+/SET autocreate_windows OFF
+
+And if you keep all channels in one window, you most probably want the channel
+name printed in each line:
+
+/SET print_active_channel ON
+
+If you want to group only some channels or queries in one window, use
+
+/JOIN -window #channel
+/QUERY -window nick
+
+3. Server and channel automation
+
+Irssi’s multiple IRC network support is IMHO very good - at least compared to
+other clients :) Even if you’re only in one IRC network you should group all
+your servers to be in the same IRC network as this helps with reconnecting if
+your primary server breaks and is probably useful in some other ways too :) For
+information how to actually use irssi correctly with multiple servers see the
+chapter 6.
+
+First you need to have your IRC network set, use /NETWORK command to see if
+it’s already there. If it isn’t, use /NETWORK ADD yournetwork. If you want to
+execute some commands automatically when you’re connected to some network, use
+-autosendcmd option. Here’s some examples:
+
+/NETWORK ADD -autosendcmd '^msg bot invite' IRCnet
+/NETWORK ADD -autosendcmd "/^msg nickserv ident pass;wait 2000" OFTC
+
+After that you need to add your servers. For example:
+
+/SERVER ADD -auto -network IRCnet irc.kpnqwest.fi 6667
+/SERVER ADD -auto -network worknet irc.mycompany.com 6667 password
+
+The -auto option specifies that this server is automatically connected at
+startup. You don’t need to make more than one server with -auto option to one
+IRC network, other servers are automatically connected in same network if the
+-auto server fails.
+
+And finally channels:
+
+/CHANNEL ADD -auto -bots *!*user@host -botcmd "/^msg $0 op pass" #irssi efnet
+/CHANNEL ADD -auto #secret IRCnet password
+
+-bots and -botcmd should be the only ones needing a bit of explaining. They’re
+used to send commands automatically to bot when channel is joined, usually to
+get ops automatically. You can specify multiple bot masks with -bots option
+separated with spaces (and remember to quote the string then). The $0 in
+-botcmd specifies the first found bot in the list. If you don’t need the bot
+masks (ie. the bot is always with the same nick, like chanserv) you can give
+only the -botcmd option and the command is always sent.
+
+4. Setting up windows and automatically restoring them at startup
+
+First connect to all the servers, join the channels and create the queries you
+want. If you want to move the windows or channels around use commands:
+
+/WINDOW MOVE LEFT/RIGHT/number - move window elsewhere
+/WINDOW ITEM MOVE | - move channel/query to another window
+
+When everything looks the way you like, use /LAYOUT SAVE command (and /SAVE, if
+you don’t have autosaving enabled) and when you start irssi next time, irssi
+remembers the positions of the channels, queries and everything. This
+“remembering” doesn’t mean that simply using /LAYOUT SAVE would automatically
+make irssi reconnect to all servers and join all channels, you’ll need the /
+SERVER ADD -auto and /CHANNEL ADD -auto commands to do that.
+
+If you want to change the layout, you just rearrange the layout like you want
+it and use /LAYOUT SAVE again. If you want to remove the layout for some
+reason, use /LAYOUT RESET.
+
+5. Status and msgs windows & message levels
+
+By default, all the “extra messages” go to status window. This means pretty
+much all messages that don’t clearly belong to some channel or query. Some
+people like it, some don’t. If you want to remove it, use
+
+/SET use_status_window OFF
+
+This doesn’t have any effect until you restart irssi. If you want to remove it
+immediately, just /WINDOW CLOSE it.
+
+Another common window is “messages window”, where all private messages go. By
+default it’s disabled and query windows are created instead. To make all
+private messages go to msgs window, say:
+
+/SET use_msgs_window ON
+/SET autocreate_query_level DCCMSGS (or if you don't want queries to
+ dcc chats either, say NONE)
+
+use_msgs_window either doesn’t have any effect until restarting irssi. To
+create it immediately say:
+
+/WINDOW NEW HIDE - create the window
+/WINDOW NAME (msgs) - name it to "(msgs)"
+/WINDOW LEVEL MSGS - make all private messages go to this window
+/WINDOW MOVE 1 - move it to first window
+
+Note that neither use_msgs_window nor use_status_window have any effect at all
+if /LAYOUT SAVE has been used.
+
+This brings us to message levels.. What are they? All messages that irssi
+prints have one or more “message levels”. Most common are PUBLIC for public
+messages in channels, MSGS for private messages and CRAP for all sorts of
+messages with no real classification. You can get a whole list of levels with
+
+/HELP levels
+
+Status window has message level ALL -MSGS, meaning that all messages, except
+private messages, without more specific place go to status window. The -MSGS is
+there so it doesn’t conflict with messages window.
+
+6. How support for multiple servers works in irssi
+
+ircii and several other clients support multiple servers by placing the
+connection into some window. IRSSI DOES NOT. There is no required relationship
+between window and server. You can connect to 10 servers and manage them all in
+just one window, or join channel in each one of them to one single window if
+you really want to. That being said, here’s how you do connect to new server
+without closing the old connection:
+
+/CONNECT irc.server.org
+
+Instead of the /SERVER which disconnects the existing connection. To see list
+of all active connections, use /SERVER without any parameters. You should see a
+list of something like:
+
+ -!- IRCNet: irc.song.fi:6667 (IRCNet)
+ -!- OFTC: irc.oftc.net:6667 (OFTC)
+ -!- RECON-1: 192.168.0.1:6667 () (02:59 left before reconnecting)
+
+Here you see that we’re connected to IRCNet and OFTC networks. The IRCNet at
+the beginning is called the “server tag” while the (IRCnet) at the end shows
+the IRC network. Server tag specifies unique tag to refer to the server,
+usually it’s the same as the IRC network. When the IRC network isn’t known it’s
+some part of the server name. When there’s multiple connections to same IRC
+network or server, irssi adds a number after the tag so there could be network,
+network2, network3 etc.
+
+Server tags beginning with RECON- mean server reconnections. Above we see that
+connection to server at 192.168.0.1 wasn’t successful and irssi will try to
+connect it again in 3 minutes.
+
+To disconnect one of the servers, or to stop irssi from reconnecting, use
+
+/DISCONNECT network - disconnect server with tag "network"
+/DISCONNECT recon-1 - stop trying to reconnect to RECON-1 server
+/RMRECONNS - stop all server reconnections
+
+/RECONNECT recon-1 - immediately try reconnecting back to RECON-1
+/RECONNECT ALL - immediately try reconnecting back to all
+ servers in reconnection queue
+
+Now that you’re connected to all your servers, you’ll have to know how to
+specify which one of them you want to use. One way is to have an empty window,
+like status or msgs window. In it, you can specify which server to set active
+with
+
+/WINDOW SERVER tag - set server "tag" active
+Ctrl-X - set the next server in list active
+
+When the server is active, you can use it normally. When there’s multiple
+connected servers, irssi adds [servertag] prefix to all messages in non-channel
+/query messages so you’ll know where it came from.
+
+Several commands also accept -servertag option to specify which server it
+should use:
+
+/MSG -tag nick message
+/JOIN -tag #channel
+/QUERY -tag nick
+
+/MSG tab completion also automatically adds the -tag option when nick isn’t in
+active server.
+
+Window’s server can be made sticky. When sticky, it will never automatically
+change to anything else, and if server gets disconnected, the window won’t have
+any active server. When the server gets connected again, it is automatically
+set active in the window. To set the window’s server sticky use
+
+/WINDOW SERVER -sticky tag
+
+This is useful if you wish to have multiple status or msgs windows, one for
+each server. Here’s how to do them (repeat for each server)
+
+/WINDOW NEW HIDE
+/WINDOW NAME (status)
+/WINDOW LEVEL ALL -MSGS
+/WINDOW SERVER -sticky network
+
+/WINDOW NEW HIDE
+/WINDOW NAME (msgs)
+/WINDOW LEVEL MSGS
+/WINDOW SERVER -sticky network
+
+7. /LASTLOG and jumping around in scrollback
+
+/LASTLOG command can be used for searching texts in scrollback buffer. Simplest
+usages are
+
+/LASTLOG word - print all lines with "word" in them
+/LASTLOG word 10 - print last 10 occurances of "word"
+/LASTLOG -topics - print all topic changes
+
+If there’s more than 1000 lines to be printed, irssi thinks that you probably
+made some mistake and won’t print them without -force option. If you want to
+save the full lastlog to file, use
+
+/LASTLOG -file ~/irc.log
+
+With -file option you don’t need -force even if there’s more than 1000 lines. /
+LASTLOG has a lot of other options too, see /HELP lastlog for details.
+
+Once you’ve found the lines you were interested in, you might want to check the
+discussion around them. Irssi has /SCROLLBACK (or alias /SB) command for
+jumping around in scrollback buffer. Since /LASTLOG prints the timestamp when
+the message was originally printed, you can use /SB GOTO hh:mm to jump directly
+there. To get back to the bottom of scrollback, use /SB END command.
+
+8. Logging
+
+Irssi can automatically log important messages when you’re set away (/AWAY
+reason). When you set yourself unaway (/AWAY), the new messages in away log are
+printed to screen. You can configure it with:
+
+/SET awaylog_level MSGS HILIGHT - Specifies what messages to log
+/SET awaylog_file ~/.irssi/away.log - Specifies the file to use
+
+Easiest way to start logging with Irssi is to use autologging. With it Irssi
+logs all channels and private messages to specified directory. You can turn it
+on with
+
+/SET autolog ON
+
+By default it logs pretty much everything execept CTCPS or CRAP (/WHOIS
+requests, etc). You can specify the logging level yourself with
+
+/SET autolog_level ALL -CRAP -CLIENTCRAP -CTCPS (this is the default)
+
+By default irssi logs to ~/irclogs//.log. You can change this with
+
+/SET autolog_path ~/irclogs/$tag/$0.log (this is the default)
+
+The path is automatically created if it doesn’t exist. $0 specifies the target
+(channel/nick). You can make irssi automatically rotate the logs by adding date
+/time formats to the file name. The formats are in “man strftime” format. For
+example
+
+/SET autolog_path ~/irclogs/%Y/$tag/$0.%m-%d.log
+
+For logging only some specific channels or nicks, see /HELP log
+
+9. Changing keyboard bindings
+
+You can change any keyboard binding that terminal lets irssi know about. It
+doesn’t let irssi know everything, so for example shift-backspace can’t be
+bound unless you modify xterm resources somehow.
+
+/HELP bind tells pretty much everything there is to know about keyboard
+bindings. However, there’s the problem of how to bind some non-standard keys.
+They might differ a bit with each terminal, so you’ll need to find out what
+exactly the keypress produces. Easiest way to check that would be to see what
+it prints in cat. Here’s an example for pressing F1 key:
+
+ [user@host] ~% cat
+ ^[OP
+
+So in irssi you would use /BIND ^[OP /ECHO F1 pressed. If you use multiple
+terminals which have different bindings for the key, it would be better to use
+eg.:
+
+/BIND ^[OP key F1
+/BIND ^[11~ key F1
+/BIND F1 /ECHO F1 pressed.
+
+10. Proxies and IRC bouncers
+
+Irssi supports connecting to IRC servers via a proxy. All server connections
+are then made through it, and if you’ve set up everything properly, you don’t
+need to do any /QUOTE SERVER commands manually.
+
+Here’s an example: You have your bouncer (lets say, BNC or BNC-like) listening
+in irc.bouncer.org port 5000. You want to use it to connect to servers
+irc.dalnet and irc.efnet.org. First you’d need to setup the bouncer:
+
+/SET use_proxy ON
+/SET proxy_address irc.bouncer.org
+/SET proxy_port 5000
+
+/SET proxy_password YOUR_BNC_PASSWORD_HERE
+/SET -clear proxy_string
+/SET proxy_string_after conn %s %d
+
+Then you’ll need to add the server connections. These are done exactly as if
+you’d want to connect directly to them. Nothing special about them:
+
+/SERVER ADD -auto -network dalnet irc.dal.net
+/SERVER ADD -auto -network efnet irc.efnet.org
+
+With the proxy /SETs however, irssi now connects to those servers through your
+BNC. All server connections are made through them so you can just forget that
+your bouncer even exists.
+
+If you don’t want to use the proxy for some reason, there’s -noproxy option
+which you can give to /SERVER and /SERVER ADD commands.
+
+Proxy specific settings:
+
+All proxies have these settings in common:
+
+/SET use_proxy ON
+/SET proxy_address
+/SET proxy_port
+
+HTTP proxy
+
+Use these settings with HTTP proxies:
+
+/SET -clear proxy_password
+/EVAL SET proxy_string CONNECT %s:%d HTTP/1.0\n\n
+
+BNC
+
+/SET proxy_password your_pass
+/SET -clear proxy_string
+/SET proxy_string_after conn %s %d
+
+dircproxy
+
+dircproxy separates the server connections by passwords. So, if you for example
+have network connection with password ircpass and OFTC connection with
+oftcpass, you would do something like this:
+
+/SET -clear proxy_password
+/SET -clear proxy_string
+
+/SERVER ADD -auto -network IRCnet fake.network 6667 ircpass
+/SERVER ADD -auto -network OFTC fake.oftc 6667 oftcpass
+
+The server name and port you give isn’t used anywhere, so you can put anything
+you want in there.
+
+psyBNC
+
+psyBNC has internal support for multiple servers. However, it could be a bit
+annoying to use, and some people just use different users for connecting to
+different servers. You can manage this in a bit same way as with dircproxy, by
+creating fake connections:
+
+/SET -clear proxy_password
+/SET -clear proxy_string
+
+/NETWORK ADD -user networkuser IRCnet
+/SERVER ADD -auto -network IRCnet fake.network 6667 ircpass
+/NETWORK ADD -user oftcuser OFTC
+/SERVER ADD -auto -network OFTC fake.oftc 6667 oftcpass
+
+So, you’ll specify the usernames with /NETWORK ADD command, and the user’s
+password with /SERVER ADD.
+
+Irssi proxy
+
+Irssi contains it’s own proxy which you can build giving \--with-proxy option
+to configure. You’ll still need to run irssi in a screen to use it though.
+
+Irssi proxy is a bit different than most proxies, normally proxies create a new
+connection to IRC server when you connect to it, but irssi proxy shares your
+existing IRC connection(s) to multiple clients. And even more clearly: You can
+use only one IRC server connection to IRC with as many clients as you want. Can
+anyone figure out even more easier ways to say this, so I wouldn’t need to try
+to explain this thing for minutes every time? :)
+
+Irssi proxy supports sharing multiple server connections in different ports,
+like you can share network in port 2777 and efnet in port 2778.
+
+Usage in proxy side:
+
+/LOAD proxy
+/SET irssiproxy_password
+/SET irssiproxy_ports = ... (eg. IRCnet=2777 efnet=2778)
+
+NOTE: you MUST add all the servers you are using to server and network lists
+with /SERVER ADD and /NETWORK ADD. ..Except if you really don’t want to for
+some reason, and you only use one server connection, you may simply set:
+
+/SET irssiproxy_ports *=2777
+
+Usage in client side:
+
+Just connect to the irssi proxy like it is a normal server with password
+specified in /SET irssiproxy_password. For example:
+
+/SERVER ADD -network IRCnet my.irssi-proxy.org 2777 secret
+/SERVER ADD -network efnet my.irssi-proxy.org 2778 secret
+
+Irssi proxy works fine with other IRC clients as well.
+
+SOCKS
+
+Irssi can be compiled with socks support (\--with-socks option to configure),
+which requires “dante” and routes all connections through the proxy specified
+in the system-wide /etc/socks.conf. This method is known to have issues in Mac
+OS X.
+
+Note that /SET proxy settings don’t have anything to do with socks.
+
+Using [4]proxychains-ng is recommended over recompiling irssi.
+
+Others
+
+IRC bouncers usually work like IRC servers, and want a password. You can give
+it with:
+
+/SET proxy_password
+
+Irssi’s defaults for connect strings are
+
+/SET proxy_string CONNECT %s %d
+/SET proxy_string_after
+
+The proxy_string is sent before NICK/USER commands, the proxy_string_after is
+sent after them. %s and %d can be used with both of them.
+
+11. Irssi’s settings
+
+Here’s some settings you might want to change (the default value is shown):
+Also check the [5]Settings Documentation
+
+Queries
+
+/SET autocreate_own_query ON
+ Should new query window be created when you send message to someone (with /
+ MSG).
+/SET autocreate_query_level MSGS
+ New query window should be created when receiving messages with this level.
+ MSGS, DCCMSGS and NOTICES levels work currently. You can disable this with
+ /SET -clear autocreate_query_level.
+/SET autoclose_query 0
+ Query windows can be automatically closed after certain time of inactivity.
+ Queries with unread messages aren’t closed and active window is neither
+ never closed. The value is given in seconds.
+
+Windows
+
+/SET use_msgs_window OFF
+ Create messages window at startup. All private messages go to this window.
+ This only makes sense if you’ve disabled automatic query windows. Message
+ window can also be created manually with /WINDOW LEVEL MSGS, /WINDOW NAME
+ (msgs).
+/SET use_status_window ON
+ Create status window at startup. All messages that don’t really have better
+ place go here, like all /WHOIS replies etc. Status window can also be
+ created manually with /WINDOW LEVEL ALL -MSGS, /WINDOW NAME (status).
+/SET autocreate_windows ON
+ Should we create new windows for new window items or just place everything
+ in one window
+/SET autoclose_windows ON
+ Should window be automatically closed when the last item in them is removed
+ (ie. /PART, /UNQUERY).
+/SET reuse_unused_windows OFF
+ When finding where to place new window item (channel, query) Irssi first
+ tries to use already existing empty windows. If this is set ON, new window
+ will always be created for all window items. This setting is ignored if
+ autoclose_windows is set ON.
+/SET window_auto_change OFF
+ Should Irssi automatically change to automatically created windows -
+ usually queries when someone sends you a message. To prevent accidentally
+ sending text meant to some other channel/nick, Irssi clears the input
+ buffer when changing the window. The text is still in scrollback buffer,
+ you can get it back with pressing arrow up key.
+/SET print_active_channel OFF
+ When you keep more than one channel in same window, Irssi prints the
+ messages coming to active channel as text and other channels as
+ text. If this setting is set ON, the messages to active
+ channels are also printed in the latter way.
+/SET window_history OFF
+ Should command history be kept separate for each window.
+
+User information
+
+/SET nick
+ Your nick name
+/SET alternate_nick
+ Your alternate nick.
+/SET user_name
+ Your username, if you have ident enabled this doesn’t affect anything
+/SET real_name
+ Your real name.
+
+Server information
+
+/SET skip_motd OFF
+ Should we hide server’s MOTD (Message Of The Day).
+/SET server_reconnect_time 300
+ Seconds to wait before connecting to same server again. Don’t set this too
+ low since it usually doesn’t help at all - if the host is down, the few
+ extra minutes of waiting won’t hurt much.
+/SET lag_max_before_disconnect 300
+ Maximum server lag in seconds before disconnecting and trying to reconnect.
+ This happens mostly only when network breaks between you and IRC server.
+
+Appearance
+
+/SET timestamps ON
+ Show timestamps before each message.
+/SET hide_text_style OFF
+ Hide all bolds, underlines, MIRC colors, etc.
+/SET show_nickmode ON
+ Show the nick’s mode before nick in channels, ie. ops have <@nick>, voices
+ <+nick> and others < nick>
+/SET show_nickmode_empty ON
+ If the nick doesn’t have a mode, use one space. ie. ON: < nick>, OFF:
+
+/SET show_quit_once OFF
+ Show quit message only once in some of the channel windows the nick was in
+ instead of in all windows.
+/SET lag_min_show 100
+ Show the server lag in status bar if it’s bigger than this, the unit is 1/
+ 100 of seconds (ie. the default value of 100 = 1 second).
+/SET indent 10
+ When lines are longer than screen width they have to be split to multiple
+ lines. This specifies how much space to put at the beginning of the line
+ before the text begins. This can be overridden in text formats with %|
+ format.
+/SET activity_hide_targets
+ If you don’t want to see window activity in some certain channels or
+ queries, list them here. For example #boringchannel =bot1 =bot2. If any
+ highlighted text or message for you appears in that window, this setting is
+ ignored and the activity is shown.
+
+Nick completion
+
+/SET completion_auto OFF
+ Automatically complete the nick if line begins with start of nick and the
+ completion character. Learn to use the tab-completion instead, it’s a lot
+ better ;)
+/SET completion_char :
+ Completion character to use.
+
+For all the ircII people
+
+I don’t like automatic query windows, I don’t like status window, I do like
+msgs window where all messages go:
+
+/SET autocreate_own_query OFF
+/SET autocreate_query_level DCCMSGS
+/SET use_status_window OFF
+/SET use_msgs_window ON
+
+Disable automatic window closing when /PARTing channel or /UNQUERYing query:
+
+/SET autoclose_windows OFF
+/SET reuse_unused_windows ON
+
+Here’s the settings that make irssi work exactly like ircII in window
+management (send me a note if you can think of more):
+
+/SET autocreate_own_query OFF
+/SET autocreate_query_level NONE
+/SET use_status_window OFF
+/SET use_msgs_window OFF
+/SET reuse_unused_windows ON
+/SET windows_auto_renumber OFF
+
+/SET autostick_split_windows OFF
+/SET autoclose_windows OFF
+/SET print_active_channel ON
+
+12. Statusbar
+
+/STATUSBAR displays a list of the current statusbars, along with their position
+and visibility:
+
+ Name Type Placement Position Visible
+ window window bottom 0 always
+ window_inact window bottom 1 inactive
+ prompt root bottom 100 always
+ topic root top 1 always
+
+/STATUSBAR prints the statusbar settings (type, placement, position,
+visibility) as well as its items. /STATUSBAR ENABLE|DISABLE enables/
+disables the statusbar. /STATUSBAR RESET resets the statusbar to its
+default settings, or if the statusbar was created by you, it will be removed.
+
+The statusbar type can be either window or root. If the type is window, then a
+statusbar will be created for each split window, otherwise it will be created
+only once. Placement can be top or bottom, which refers to the top or bottom of
+the screen. Position is a number, the higher the value the lower it will appear
+in-screen. Visible can be always, active or inactive. Active/inactive is useful
+only with split windows; one split window is active and the rest are inactive.
+To adjust these settings, the following commands are available:
+
+/STATUSBAR TYPE window|root
+/STATUSBAR PLACEMENT top|bottom
+/STATUSBAR POSITION
+/STATUSBAR VISIBLE always|active|inactive
+
+Statusbar items can also be added or removed via command. Note that when
+loading new statusbar scripts that add items, you will need to specify where
+you want to show the item and how it is aligned. This can be accomplished using
+the below commands:
+
+/STATUSBAR ADD [-before | -after - ] [-priority #] [-alignment left|right]
-
+/STATUSBAR
REMOVE -
+
+For statusbar scripts, the item name is usually equivalent to the script name.
+The documentation of the script ought to tell you if this is not the case. For
+example, to add mail.pl before the window activity item, use: /STATUSBAR window
+ADD -before act mail.
+
+
+References:
+
+[1] http://www.gnu.org/licenses/fdl.html
+[2] https://www.iterm2.com/
+[3] http://quadpoint.org/articles/irssisplit/
+[4] https://github.com/rofl0r/proxychains-ng
+[5] https://irssi.org/documentation/settings/
diff --git a/syncdocs.sh b/syncdocs.sh
new file mode 100755
index 00000000..1187eec9
--- /dev/null
+++ b/syncdocs.sh
@@ -0,0 +1,101 @@
+#!/bin/sh -e
+# Run this to download FAQ and startup-HOWTO from irssi.org
+
+PKG_NAME="Irssi"
+
+site=https://irssi.org
+
+faq=$site/documentation/faq/
+howto=$site/documentation/startup/
+
+# remove everything until H1 and optionally 2 DIVs before the
+# FOOTER. May need to be adjusted as the source pages change
+pageclean_regex='s{.*(?=
\s*)?(\s*)?)}{\1\2}g;'
+
+srcdir=`dirname "$0"`
+test -z "$srcdir" && srcdir=.
+
+if test ! -f "$srcdir"/configure.ac; then
+ echo -n "**Error**: Directory \`$srcdir' does not look like the"
+ echo " top-level $PKG_NAME directory"
+ exit 1
+fi
+
+# detect downloader app
+downloader=false
+
+if type curl >/dev/null 2>&1 ; then
+ downloader="curl -Ssf"
+elif type wget >/dev/null 2>&1 ; then
+ downloader="wget -nv -O-"
+else
+ echo "**Error**: No wget or curl present"
+ echo "Install wget or curl, then run syncdocs.sh again"
+fi
+
+# detect html converter app
+converter=false
+if [ "$1" = "-any" ]; then
+ any=true
+else
+ any=false
+fi
+
+if type w3m >/dev/null 2>&1 ; then
+ converter="w3m -o display_link_number=1 -dump -T text/html"
+ any=true
+elif type lynx >/dev/null 2>&1 ; then
+ converter="lynx -dump -stdin -force_html"
+elif type elinks >/dev/null 2>&1 ; then
+ converter="elinks -dump -force-html"
+else
+ echo "**Error**: Neither w3m, nor lynx or elinks present"
+ echo "Install w3m, then run syncdocs.sh again"
+ exit 1
+fi
+
+if ! $any ; then
+ echo "**Error**: w3m not present"
+ echo "If you want to use lynx or elinks, run syncdocs.sh -any"
+ exit 1
+fi
+
+check_download() {
+ if test "$1" -ne 0 || test ! -e "$2" || test "$(wc -l "$2" | awk '{print $1}')" -le 1 ; then
+ rm -f "$2"
+ echo "... download failed ( $1 )"
+ exit 2
+ fi
+}
+
+download_it() {
+ echo "Downloading $1 from $2 ..."
+ ret=0
+ $downloader "$2" > "$3".tmp || ret=$?
+ check_download "$ret" "$3".tmp
+ perl -i -0777 -p -e "$pageclean_regex" "$3".tmp
+ perl -i -0777 -p -e 's{\A}{'" "'\n}' "$3".tmp
+ perl -i -0777 -p -e 's{\[email protected\]}{user\@host}g' "$3".tmp
+ mv "$3".tmp "$3"
+}
+
+download_it "FAQ" "$faq" "$srcdir"/docs/faq.html
+download_it "Startup How-To" "$howto" "$srcdir"/docs/startup-HOWTO.html
+
+# .html -> .txt with lynx or elinks
+echo "Documentation: html -> txt..."
+
+cat "$srcdir"/docs/faq.html \
+ | LC_ALL=en_IE.utf8 $converter \
+ | perl -pe '
+ s/^ *//;
+ if ($_ eq "\n" && $state eq "Q") { $_ = ""; }
+ elsif (/^([QA]):/) { $state = $1 }
+ elsif ($_ ne "\n") { $_ = " $_"; };
+' > docs/faq.txt
+
+cat "$srcdir"/docs/startup-HOWTO.html \
+ | perl -pe "s/\\bhref=([\"\'])#.*?\\1//" \
+ | LC_ALL=en_IE.utf8 $converter > "$srcdir"/docs/startup-HOWTO.txt
From 9a3c0bce48d3f172d5638ecb37967528812129b1 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Tue, 24 Oct 2017 22:22:39 +0200
Subject: [PATCH 0104/1087] add a script to sync scripts as well
---
syncscripts.sh | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100755 syncscripts.sh
diff --git a/syncscripts.sh b/syncscripts.sh
new file mode 100755
index 00000000..eee95a5e
--- /dev/null
+++ b/syncscripts.sh
@@ -0,0 +1,38 @@
+#!/bin/sh -e
+# Run this script to sync dual lived scripts from scripts.irssi.org to scripts/
+
+PKG_NAME="Irssi"
+
+scriptbase=https://scripts.irssi.org/scripts
+
+srcdir=`dirname "$0"`
+test -z "$srcdir" && srcdir=.
+
+if test ! -f "$srcdir"/configure.ac; then
+ echo -n "**Error**: Directory \`$srcdir' does not look like the"
+ echo " top-level $PKG_NAME directory"
+ exit 1
+fi
+
+dl2='curl -Ssf'
+
+dl_it() {
+ echo "$1"
+ $dl2 -o "$srcdir/scripts/$1" "$scriptbase/$1"
+}
+
+for script in \
+ autoop.pl \
+ autorejoin.pl \
+ buf.pl \
+ dns.pl \
+ kills.pl \
+ mail.pl \
+ mlock.pl \
+ quitmsg.pl \
+ scriptassist.pl \
+ usercount.pl \
+ ;
+do
+ dl_it $script
+done
From 8843d4f77d8e829135e2ff9b354990134c58c46a Mon Sep 17 00:00:00 2001
From: Will Storey
Date: Sat, 21 Oct 2017 20:00:25 -0700
Subject: [PATCH 0105/1087] Strip : from parameters
This is to fix #601. The function used to extract the mode string
assumed that ":" would only occur in a particular spot. This lead to the
possibility that ":" could be treated as part of things like nicknames
or mode arguments, where it should have been stripped as part of
protocol escaping.
---
src/fe-common/irc/fe-events.c | 2 +-
src/irc/core/irc.c | 32 ++++++++++++++++++++++++++++++--
src/irc/core/modes.c | 4 ++--
3 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/src/fe-common/irc/fe-events.c b/src/fe-common/irc/fe-events.c
index 850174c5..cc83d476 100644
--- a/src/fe-common/irc/fe-events.c
+++ b/src/fe-common/irc/fe-events.c
@@ -224,7 +224,7 @@ static void event_nick(IRC_SERVER_REC *server, const char *data,
static void event_mode(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr)
{
- char *params, *channel, *mode;
+ char *params = NULL, *channel = NULL, *mode = NULL;
g_return_if_fail(data != NULL);
diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c
index 4dce3fcf..790c7122 100644
--- a/src/irc/core/irc.c
+++ b/src/irc/core/irc.c
@@ -40,6 +40,8 @@ static int signal_server_incoming;
# define MAX_SOCKET_READS 5
#endif
+static void strip_params_colon(char *const);
+
/* The core of the irc_send_cmd* functions. If `raw' is TRUE, the `cmd'
won't be checked at all if it's 512 bytes or not, or if it contains
line feeds or not. Use with extreme caution! */
@@ -269,8 +271,9 @@ char *event_get_params(const char *data, int count, ...)
while (count-- > 0) {
str = (char **) va_arg(args, char **);
if (count == 0 && rest) {
- /* put the rest to last parameter */
- tmp = *datad == ':' ? datad+1 : datad;
+ /* Put the rest into the last parameter. */
+ strip_params_colon(datad);
+ tmp = datad;
} else {
tmp = event_get_param(&datad);
}
@@ -281,6 +284,31 @@ char *event_get_params(const char *data, int count, ...)
return duprec;
}
+/* Given a string containing , strip any colon prefixing . */
+static void strip_params_colon(char *const params)
+{
+ if (!params) {
+ return;
+ }
+
+ char *s = params;
+ while (*s != '\0') {
+ if (*s == ':') {
+ memmove(s, s+1, strlen(s+1)+1);
+ return;
+ }
+
+ s = strchr(s, ' ');
+ if (!s) {
+ return;
+ }
+
+ while (*s == ' ') {
+ s++;
+ }
+ }
+}
+
static void irc_server_event(IRC_SERVER_REC *server, const char *line,
const char *nick, const char *address)
{
diff --git a/src/irc/core/modes.c b/src/irc/core/modes.c
index cc3d0faf..ecbf2571 100644
--- a/src/irc/core/modes.c
+++ b/src/irc/core/modes.c
@@ -480,8 +480,8 @@ static void event_user_mode(IRC_SERVER_REC *server, const char *data)
static void event_mode(IRC_SERVER_REC *server, const char *data,
const char *nick)
{
- IRC_CHANNEL_REC *chanrec;
- char *params, *channel, *mode;
+ IRC_CHANNEL_REC *chanrec = NULL;
+ char *params = NULL, *channel = NULL, *mode = NULL;
g_return_if_fail(data != NULL);
From ca3498d42d29383024382b0eb983f97ab4e6b614 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Wed, 25 Oct 2017 16:22:57 +0200
Subject: [PATCH 0106/1087] move some files into subdirs
---
Makefile.am | 21 ++++++-----------
autogen.sh | 27 +++++++++++++---------
configure.ac | 2 ++
themes/Makefile.am | 5 ++++
colorless.theme => themes/colorless.theme | 0
default.theme => themes/default.theme | 0
utils/Makefile.am | 4 ++++
file2header.sh => utils/file2header.sh | 0
irssi-version.sh => utils/irssi-version.sh | 0
syncdocs.sh => utils/syncdocs.sh | 3 ++-
syncscripts.sh => utils/syncscripts.sh | 1 +
syntax.pl => utils/syntax.pl | 0
12 files changed, 37 insertions(+), 26 deletions(-)
create mode 100644 themes/Makefile.am
rename colorless.theme => themes/colorless.theme (100%)
rename default.theme => themes/default.theme (100%)
create mode 100644 utils/Makefile.am
rename file2header.sh => utils/file2header.sh (100%)
rename irssi-version.sh => utils/irssi-version.sh (100%)
rename syncdocs.sh => utils/syncdocs.sh (98%)
rename syncscripts.sh => utils/syncscripts.sh (97%)
rename syntax.pl => utils/syntax.pl (100%)
diff --git a/Makefile.am b/Makefile.am
index 75d502f1..f52ac92f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,33 +7,26 @@ CLEANFILES = default-config.h default-theme.h
@MAINTAINER_MODE_TRUE@.PHONY: irssi-version.h
default-config.h: $(srcdir)/irssi.conf
- $(srcdir)/file2header.sh $(srcdir)/irssi.conf default_config > default-config.h
+ $(srcdir)/utils/file2header.sh $(srcdir)/irssi.conf default_config > default-config.h
-default-theme.h: $(srcdir)/default.theme
- $(srcdir)/file2header.sh $(srcdir)/default.theme default_theme > default-theme.h
+default-theme.h: $(srcdir)/themes/default.theme
+ $(srcdir)/utils/file2header.sh $(srcdir)/themes/default.theme default_theme > default-theme.h
irssi-version.h:
- VERSION="$(VERSION)" $(srcdir)/irssi-version.sh $(srcdir) | \
- cmp -s - $@ || VERSION="$(VERSION)" $(srcdir)/irssi-version.sh $(srcdir) >$@
+ VERSION="$(VERSION)" $(srcdir)/utils/irssi-version.sh $(srcdir) | \
+ cmp -s - $@ || VERSION="$(VERSION)" $(srcdir)/utils/irssi-version.sh $(srcdir) >$@
-SUBDIRS = src docs scripts
+SUBDIRS = src docs scripts themes utils
confdir = $(sysconfdir)
conf_DATA = irssi.conf
-themedir = $(datadir)/irssi/themes
-theme_DATA = default.theme colorless.theme
-
pkginclude_HEADERS = irssi-config.h irssi-version.h
EXTRA_DIST = \
ChangeLog \
autogen.sh \
README.md \
- file2header.sh \
$(conf_DATA) \
- $(theme_DATA) \
irssi-config.in \
- irssi-icon.png \
- irssi-version.sh \
- syntax.pl
+ irssi-icon.png
diff --git a/autogen.sh b/autogen.sh
index a9e354c9..9feb0872 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -3,21 +3,24 @@
PKG_NAME="Irssi"
-srcdir=`dirname $0`
+srcdir=`dirname "$0"`
test -z "$srcdir" && srcdir=.
+mydir=`pwd`
-if test ! -f $srcdir/configure.ac; then
- echo -n "**Error**: Directory \`$srcdir\' does not look like the"
+if test ! -f "$srcdir"/configure.ac; then
+ echo -n "**Error**: Directory \`$srcdir' does not look like the"
echo " top-level $PKG_NAME directory"
exit 1
fi
+cd "$srcdir"
+
# create help files
echo "Creating help files..."
-perl syntax.pl
+perl utils/syntax.pl
echo "Creating ChangeLog..."
-git log > $srcdir/ChangeLog
+git log > ChangeLog
if test "$?" -ne 0; then
echo "**Error**: ${PKG_NAME} Autogen must be run in a git clone, cannot proceed."
exit 1
@@ -38,17 +41,19 @@ fi
rm -f aclocal.m4
echo "Running autoreconf ..."
-autoreconf -i || exit 1
+autoreconf -i || exit $?
+
+# make sure perl hashes have correct length
+find src/perl -name '*.c' -o -name '*.xs' -exec grep -n hv_store {} + | perl -l -ne 'if (/"(\w+)",\s*(\d+)/ && $2 != length $1) { $X=1; print "Incorrect key length in $_" } END { exit $X }'
+
+cd "$mydir"
conf_flags="--enable-maintainer-mode"
if test x$NOCONFIGURE = x; then
- echo Running $srcdir/configure $conf_flags "$@" ...
- $srcdir/configure $conf_flags "$@" \
+ echo Running "$srcdir"/configure $conf_flags "$@" ...
+ "$srcdir"/configure $conf_flags "$@" \
&& echo Now type \`make\' to compile $PKG_NAME || exit 1
else
echo Skipping configure process.
fi
-
-# make sure perl hashes have correct length
-find src/perl -name '*.c' -o -name '*.xs' -exec grep -n hv_store {} + | perl -l -ne 'if (/"(\w+)",\s*(\d+)/ && $2 != length $1) { $X=1; print "Incorrect key length in $_" } END { exit $X }'
diff --git a/configure.ac b/configure.ac
index 9c026c5d..4b65d434 100644
--- a/configure.ac
+++ b/configure.ac
@@ -661,6 +661,8 @@ scripts/examples/Makefile
docs/Makefile
docs/help/Makefile
docs/help/in/Makefile
+utils/Makefile
+themes/Makefile
irssi-config
])
diff --git a/themes/Makefile.am b/themes/Makefile.am
new file mode 100644
index 00000000..ad0707c2
--- /dev/null
+++ b/themes/Makefile.am
@@ -0,0 +1,5 @@
+themedir = $(datadir)/irssi/themes
+theme_DATA = default.theme colorless.theme
+
+EXTRA_DIST = \
+ $(theme_DATA)
diff --git a/colorless.theme b/themes/colorless.theme
similarity index 100%
rename from colorless.theme
rename to themes/colorless.theme
diff --git a/default.theme b/themes/default.theme
similarity index 100%
rename from default.theme
rename to themes/default.theme
diff --git a/utils/Makefile.am b/utils/Makefile.am
new file mode 100644
index 00000000..be24c17f
--- /dev/null
+++ b/utils/Makefile.am
@@ -0,0 +1,4 @@
+EXTRA_DIST = \
+ file2header.sh \
+ irssi-version.sh \
+ syntax.pl
diff --git a/file2header.sh b/utils/file2header.sh
similarity index 100%
rename from file2header.sh
rename to utils/file2header.sh
diff --git a/irssi-version.sh b/utils/irssi-version.sh
similarity index 100%
rename from irssi-version.sh
rename to utils/irssi-version.sh
diff --git a/syncdocs.sh b/utils/syncdocs.sh
similarity index 98%
rename from syncdocs.sh
rename to utils/syncdocs.sh
index 1187eec9..e723edd2 100755
--- a/syncdocs.sh
+++ b/utils/syncdocs.sh
@@ -16,6 +16,7 @@ s{(<.*?)\sclass="(?:highlighter-rouge|highlight)"(.*?>)}{\1\2}g;'
srcdir=`dirname "$0"`
test -z "$srcdir" && srcdir=.
+srcdir="$srcdir"/..
if test ! -f "$srcdir"/configure.ac; then
echo -n "**Error**: Directory \`$srcdir' does not look like the"
@@ -94,7 +95,7 @@ cat "$srcdir"/docs/faq.html \
if ($_ eq "\n" && $state eq "Q") { $_ = ""; }
elsif (/^([QA]):/) { $state = $1 }
elsif ($_ ne "\n") { $_ = " $_"; };
-' > docs/faq.txt
+' > "$srcdir"/docs/faq.txt
cat "$srcdir"/docs/startup-HOWTO.html \
| perl -pe "s/\\bhref=([\"\'])#.*?\\1//" \
diff --git a/syncscripts.sh b/utils/syncscripts.sh
similarity index 97%
rename from syncscripts.sh
rename to utils/syncscripts.sh
index eee95a5e..533b77cc 100755
--- a/syncscripts.sh
+++ b/utils/syncscripts.sh
@@ -7,6 +7,7 @@ scriptbase=https://scripts.irssi.org/scripts
srcdir=`dirname "$0"`
test -z "$srcdir" && srcdir=.
+srcdir="$srcdir"/..
if test ! -f "$srcdir"/configure.ac; then
echo -n "**Error**: Directory \`$srcdir' does not look like the"
diff --git a/syntax.pl b/utils/syntax.pl
similarity index 100%
rename from syntax.pl
rename to utils/syntax.pl
From 8c0e0c81ee79684201020f843eeb0a4d656ed14c Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Wed, 25 Oct 2017 16:23:14 +0200
Subject: [PATCH 0107/1087] run syncscripts.sh
---
scripts/autorejoin.pl | 49 ++++++++++++++++++++++++++++---------------
scripts/mail.pl | 1 +
scripts/usercount.pl | 1 +
3 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/scripts/autorejoin.pl b/scripts/autorejoin.pl
index 42c97da7..e5be21b2 100644
--- a/scripts/autorejoin.pl
+++ b/scripts/autorejoin.pl
@@ -1,6 +1,9 @@
-# automatically rejoin to channel after kick
+# automatically rejoin to channel after kicked
# delayed rejoin: Lam 28.10.2001 (lam@lac.pl)
+# /SET autorejoin_channels #channel1 #channel2 ...
+# /SET autorejoin_delay 5
+
# NOTE: I personally don't like this feature, in most channels I'm in it
# will just result as ban. You've probably misunderstood the idea of /KICK
# if you kick/get kicked all the time "just for fun" ...
@@ -9,31 +12,22 @@ use Irssi;
use Irssi::Irc;
use strict;
use vars qw($VERSION %IRSSI);
-$VERSION = "1.0.0";
+$VERSION = "1.1.0";
%IRSSI = (
authors => "Timo 'cras' Sirainen, Leszek Matok",
contact => "lam\@lac.pl",
name => "autorejoin",
- description => "Automatically rejoin to channel after being kick, after a (short) user-defined delay",
+ description => "Automatically rejoin to channel after being kicked, after a (short) user-defined delay",
license => "GPLv2",
changed => "10.3.2002 14:00"
);
-
-# How many seconds to wait before the rejoin?
-# TODO: make this a /setting
-my $delay = 5;
-
-my @tags;
-my $acttag = 0;
-
sub rejoin {
my ( $data ) = @_;
- my ( $tag, $servtag, $channel, $pass ) = split( / +/, $data );
+ my ( $servtag, $channel, $pass ) = @{$data};
my $server = Irssi::server_find_tag( $servtag );
$server->send_raw( "JOIN $channel $pass" ) if ( $server );
- Irssi::timeout_remove( $tags[$tag] );
}
sub event_rejoin_kick {
@@ -48,10 +42,31 @@ sub event_rejoin_kick {
my $rejoinchan = $chanrec->{ name } if ( $chanrec );
my $servtag = $server->{ tag };
- Irssi::print "Rejoining $rejoinchan in $delay seconds.";
- $tags[$acttag] = Irssi::timeout_add( $delay * 1000, "rejoin", "$acttag $servtag $rejoinchan $password" );
- $acttag++;
- $acttag = 0 if ( $acttag > 60 );
+ # check if we want to autorejoin this channel
+ my $chans = Irssi::settings_get_str( 'autorejoin_channels' );
+
+ if ( $chans ) {
+ my $found = 0;
+ foreach my $chan ( split( /[ ,]/, $chans ) ) {
+ if ( lc( $chan ) eq lc( $channel ) ) {
+ $found = 1;
+ last;
+ }
+ }
+ return unless $found;
+ }
+
+ my @args = ($servtag, $rejoinchan, $password);
+ my $delay = Irssi::settings_get_int( "autorejoin_delay" );
+
+ if ($delay) {
+ Irssi::print "Rejoining $rejoinchan in $delay seconds.";
+ Irssi::timeout_add_once( $delay * 1000, "rejoin", \@args );
+ } else {
+ rejoin( \@args );
+ }
}
+Irssi::settings_add_int('misc', 'autorejoin_delay', 5);
+Irssi::settings_add_str('misc', 'autorejoin_channels', '');
Irssi::signal_add( 'event kick', 'event_rejoin_kick' );
diff --git a/scripts/mail.pl b/scripts/mail.pl
index ded02120..23f99c01 100644
--- a/scripts/mail.pl
+++ b/scripts/mail.pl
@@ -6,6 +6,7 @@ $VERSION = "2.92";
contact => "tss\@iki.fi, matti\@hiljanen.com, joost\@carnique.nl, bart\@dreamflow.nl",
name => "mail",
description => "Fully customizable mail counter statusbar item with multiple mailbox and multiple Maildir support",
+ sbitems => "mail",
license => "Public Domain",
url => "http://irssi.org, http://scripts.irssi.de",
);
diff --git a/scripts/usercount.pl b/scripts/usercount.pl
index 613da1de..650f9f36 100644
--- a/scripts/usercount.pl
+++ b/scripts/usercount.pl
@@ -7,6 +7,7 @@ $VERSION = "1.19";
contact => 'dgl@dgl.cx, tss@iki.fi, georg@boerde.de',
name => 'usercount',
description => 'Adds a usercount for a channel as a statusbar item',
+ sbitems => 'usercount',
license => 'GNU GPLv2 or later',
url => 'http://irssi.dgl.cx/',
changes => 'Only show halfops if server supports them',
From 96c7f68b3579ae5f83b635d946dc705d6322a16c Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Thu, 26 Oct 2017 16:15:25 +0200
Subject: [PATCH 0108/1087] clean up file path after move
---
src/perl/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/perl/Makefile.am b/src/perl/Makefile.am
index 427c5492..db52744e 100644
--- a/src/perl/Makefile.am
+++ b/src/perl/Makefile.am
@@ -59,7 +59,7 @@ perl-signals-list.h: $(top_srcdir)/docs/signals.txt $(srcdir)/get-signals.pl
cat $(top_srcdir)/docs/signals.txt | $(perlpath) $(srcdir)/get-signals.pl > perl-signals-list.h
irssi-core.pl.h: irssi-core.pl
- $(top_srcdir)/file2header.sh $(srcdir)/irssi-core.pl irssi_core_code > irssi-core.pl.h
+ $(top_srcdir)/utils/file2header.sh $(srcdir)/irssi-core.pl irssi_core_code > irssi-core.pl.h
common_sources = \
common/Irssi.xs \
From 7e619ed990503faf45fc1ae1e28a3a6062dc7532 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Mon, 30 Oct 2017 16:54:32 +0100
Subject: [PATCH 0109/1087] Update README.md
---
README.md | 128 ++++++++++++++++++++----------------------------------
1 file changed, 46 insertions(+), 82 deletions(-)
diff --git a/README.md b/README.md
index 8d91f4cb..0f54ccf5 100644
--- a/README.md
+++ b/README.md
@@ -1,109 +1,73 @@
-# Irssi
+# [Irssi](https://irssi.org/)
[](https://travis-ci.org/irssi/irssi)
Irssi is a modular chat client that is most commonly known for its
text mode user interface, but 80% of the code isn't text mode
-specific. We have a working but currently unmaintained GTK2 frontend
-called xirssi. Irssi comes with IRC support built in, and there are
+specific. Irssi comes with IRC support built in, and there are
third party [ICB](https://github.com/jperkin/irssi-icb),
[SILC](http://www.silcnet.org/),
[XMPP](http://cybione.org/~irssi-xmpp/) (Jabber),
-[PSYC](https://github.com/electric-blue/irssyc) and
+[PSYC](http://about.psyc.eu/Irssyc) and
[Quassel](https://github.com/phhusson/quassel-irssi) protocol modules
available.
-## Installation
+
-See the `INSTALL` file.
+## [Download information](https://irssi.org/download/)
-## Features
+#### Development source installation
-So what's so great about Irssi? Here's a list of some features I can
-think of currently:
+```
+git clone https://github.com/irssi/irssi
+cd irssi
+./autogen.sh
+make && sudo make install
+```
- - **Optional automation** - There's lots of things Irssi does for you
- automatically that some people like and others just hate. Things like:
- nick completion, creating new window for newly joined channel, creating
- queries when msgs/notices are received or when you send a msg, closing
- queries when it's been idle for some time, etc.
+#### Release source installation
- - **Multiserver friendly** - I think Irssi has clearly the best support
- for handling multiple server connections. You can have as many as you
- want in as many ircnets as you want. Having several connections in one
- server works too, for example when you hit the (ircnet's) 10
- channels/connection limit you can just create another connection and
- you hardly notice it. If connection to server is lost, Irssi tries to
- connect back until it's successful. Also channels you were joined
- before disconnection are restored, even if they're "temporarily
- unavailable" because of netsplits, Irssi keeps rejoining back to them.
- Also worth noticing - there's not that stupid "server is bound to this
- window, if this window gets closed the connection closes" thing that
- ircII based clients have.
+* Download [release](https://github.com/irssi/irssi/releases)
+* [Verify](https://irssi.org/download/#release-sources) signature
+```
+tar xJf irssi-*.tar.xz
+cd irssi-*
+./configure
+make && sudo make install
+```
- - **Channel automation** - You can specify what channels to join to
- immediately after connected to some server or IRC network. After joined
- to channel, Irssi can automatically request ops for you (or do
- anything, actually) from channel's bots.
+### Requirements
- - **Window content saving** - Say /LAYOUT SAVE when you've put all the
- channels and queries to their correct place, and after restarting
- Irssi, the channels will be joined back into windows where they were
- saved.
+- [glib-2.28](https://wiki.gnome.org/Projects/GLib) or greater
+- [openssl](https://www.openssl.org/)
+- [perl-5.6](https://www.perl.org/) or greater (for perl support)
+- terminfo or ncurses (for text frontend)
- - **Tab completing anything** - You can complete lots of things with tab:
- nicks, commands, command -options, file names, settings, text format
- names, channels and server names. There's also an excellent /msg
- completion that works transparently with multiple IRC networks.
- Completing channel nicks is also pretty intelligent, it first goes
- through the people who have talked to you recently, then the people who
- have talked to anyone recently and only then it fallbacks to rest of
- the nicks. You can also complete a set of words you've specified, for
- example homepage changes it to your actual home page URL.
+#### See the [INSTALL](INSTALL) file for details
- - **Excellent logging** - You can log any way you want and as easily or
- hard as you want. With autologging Irssi logs everything to specified
- directory, one file per channel/nick. ircII style /WINDOW LOG ON is
- also supported. There's also the "hard way" of logging - /LOG command
- which lets you specify exactly what you wish to log and where. Log
- rotating is supported with all the different logging methods, you can
- specify how often you want it to rotate and what kind of time stamp to
- use.
+## [Documentation](https://irssi.org/documentation/)
- - **Excellent ignoring** - You can most probably ignore anything any way
- you want. Nick masks, words, regular expressions. You can add
- exceptions to ignores. You can ignore other people's replies in
- channels to nicks you have ignored. You can also specify that the
- specific ignores work only in specific channel(s).
+* [Frequently Asked Questions](https://irssi.org/documentation/faq)
+* [Startup How-To](https://irssi.org/documentation/startup)
+* Check the built-in `/HELP`, it has all the details on command syntax
- - **Lastlog and scrollback handling** - /LASTLOG command has some new
- features: -new option checks only lines that came since you last did
- /LASTLOG command, -away option checks new lines since you last went
- away. Regular expression matches work also, of course. Going to some
- wanted place at scrollback has always been hard with non-GUI clients. A
- search command that jumps around in scrollback in GUI-style is still
- missing from Irssi, but there's something that's almost as good as it.
- /LASTLOG always shows timestamps when the line was printed, even if you
- didn't have timestamps on. Now doing /SB GOTO \ jumps
- directly to the position in scrollback you wanted. Great feature when
- you want to browse a bit of the discussion what happened when someone
- said your name (as seen in awaylog) or topic was changed (/last
- -topics)
+## [Themes](https://irssi-import.github.io/themes/)
-## Files
+## [Scripts](http://scripts.irssi.org/)
- - The `docs/` directory contains several documents:
- - `startup-HOWTO.txt` - new users should read this
- - `manual.txt` - manual I started writing but didn't get it very far :)
- - `perl.txt` - Perl scripting help
- - `formats.txt` - How to use colors, etc. with Irssi
- - `faq.txt` - Frequently Asked Questions
- - `special_vars.txt` - some predefined $variables you can use with Irssi
+## [Modules](https://irssi.org/modules/)
-## Bugs / Suggestions
+## [Security information](https://irssi.org/security/)
-See the `TODO` file, http://bugs.irssi.org and the GitHub issues if it is
-already listed in there; if not, open an issue on GitHub or send a mail to
-[staff@irssi.org](mailto:staff@irssi.org).
+Please report security issues to staff@irssi.org. Thanks!
-You can also contact the Irssi developers in #irssi on freenode.
+## [Bugs](https://github.com/irssi/irssi/issues) / Suggestions / [Contributing](https://irssi.org/development/)
+
+Check the GitHub issues if it is already listed in there; if not, open
+an issue on GitHub or send a mail to [staff@irssi.org](mailto:staff@irssi.org).
+
+Irssi is always looking for developers. Feel free to submit patches through
+GitHub pull requests.
+
+You can also contact the Irssi developers in
+[#irssi](https://irssi.org/support/irc/) on freenode.
From b0fa4dd46d8bf1cf63880fabf2105dd9134100df Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Wed, 1 Nov 2017 15:48:35 +0100
Subject: [PATCH 0110/1087] show initial nick and name on first start
---
src/core/settings.c | 10 +++++++
src/fe-common/core/Makefile.am | 1 +
src/fe-common/core/fe-settings.c | 7 ++++-
src/fe-common/core/fe-settings.h | 6 ++++
src/fe-text/irssi.c | 49 ++++++++++++++++----------------
src/fe-text/module-formats.c | 21 ++++++++++++++
src/fe-text/module-formats.h | 6 ++++
src/irc/core/irc-servers-setup.c | 11 ++++++-
8 files changed, 85 insertions(+), 26 deletions(-)
create mode 100644 src/fe-common/core/fe-settings.h
diff --git a/src/core/settings.c b/src/core/settings.c
index 4e0717cd..48d6640e 100644
--- a/src/core/settings.c
+++ b/src/core/settings.c
@@ -39,6 +39,7 @@ static GString *last_errors;
static GSList *last_invalid_modules;
static int fe_initialized;
static int config_changed; /* FIXME: remove after .98 (unless needed again) */
+static int user_settings_changed;
static GHashTable *settings;
static int timeout_tag;
@@ -464,6 +465,11 @@ SETTINGS_REC *settings_get_record(const char *key)
return g_hash_table_lookup(settings, key);
}
+static void sig_init_userinfo_changed(gpointer changedp)
+{
+ user_settings_changed = GPOINTER_TO_INT(changedp);
+}
+
static void sig_init_finished(void)
{
fe_initialized = TRUE;
@@ -479,6 +485,8 @@ static void sig_init_finished(void)
"updated, please /SAVE");
signal_emit("setup changed", 0);
}
+
+ signal_emit("settings userinfo changed", 1, GINT_TO_POINTER(user_settings_changed));
}
static void settings_clean_invalid_module(const char *module)
@@ -875,6 +883,7 @@ void settings_init(void)
timeout_tag = g_timeout_add(SETTINGS_AUTOSAVE_TIMEOUT,
(GSourceFunc) sig_autosave, NULL);
signal_add("irssi init finished", (SIGNAL_FUNC) sig_init_finished);
+ signal_add("irssi init userinfo changed", (SIGNAL_FUNC) sig_init_userinfo_changed);
signal_add("gui exit", (SIGNAL_FUNC) sig_autosave);
}
@@ -887,6 +896,7 @@ void settings_deinit(void)
{
g_source_remove(timeout_tag);
signal_remove("irssi init finished", (SIGNAL_FUNC) sig_init_finished);
+ signal_remove("irssi init userinfo changed", (SIGNAL_FUNC) sig_init_userinfo_changed);
signal_remove("gui exit", (SIGNAL_FUNC) sig_autosave);
g_slist_foreach(last_invalid_modules, (GFunc) g_free, NULL);
diff --git a/src/fe-common/core/Makefile.am b/src/fe-common/core/Makefile.am
index 29cc941a..cf4e8ee3 100644
--- a/src/fe-common/core/Makefile.am
+++ b/src/fe-common/core/Makefile.am
@@ -55,6 +55,7 @@ pkginc_fe_common_core_HEADERS = \
fe-exec.h \
fe-messages.h \
fe-queries.h \
+ fe-settings.h \
fe-tls.h \
formats.h \
hilight-text.h \
diff --git a/src/fe-common/core/fe-settings.c b/src/fe-common/core/fe-settings.c
index abbd45a8..de9f67a1 100644
--- a/src/fe-common/core/fe-settings.c
+++ b/src/fe-common/core/fe-settings.c
@@ -26,7 +26,7 @@
#include "misc.h"
#include "lib-config/iconfig.h"
#include "settings.h"
-
+#include "fe-settings.h"
#include "levels.h"
#include "printtext.h"
#include "keyboard.h"
@@ -41,6 +41,11 @@ static void set_print(SETTINGS_REC *rec)
g_free(value);
}
+void fe_settings_set_print(const char *key)
+{
+ set_print(settings_get_record(key));
+}
+
static void set_print_pattern(const char *pattern)
{
GSList *sets, *tmp;
diff --git a/src/fe-common/core/fe-settings.h b/src/fe-common/core/fe-settings.h
new file mode 100644
index 00000000..dd33f223
--- /dev/null
+++ b/src/fe-common/core/fe-settings.h
@@ -0,0 +1,6 @@
+#ifndef __FE_CHANNELS_H
+#define __FE_CHANNELS_H
+
+void fe_settings_set_print(const char *key);
+
+#endif
diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c
index b5df47c9..6349ae2a 100644
--- a/src/fe-text/irssi.c
+++ b/src/fe-text/irssi.c
@@ -31,6 +31,7 @@
#include "printtext.h"
#include "fe-common-core.h"
+#include "fe-settings.h"
#include "themes.h"
#include "term.h"
@@ -79,25 +80,8 @@ static int dirty, full_redraw;
static GMainLoop *main_loop;
int quitting;
-static const char *banner_text =
- " ___ _\n"
- "|_ _|_ _ _____(_)\n"
- " | || '_(_-<_-< |\n"
- "|___|_| /__/__/_|\n"
- "Irssi v" PACKAGE_VERSION " - http://www.irssi.org";
-
-static const char *firsttimer_text =
- "- - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"
- "Hi there! If this is your first time using Irssi, you\n"
- "might want to go to our website and read the startup\n"
- "documentation to get you going.\n\n"
- "Our community and staff are available to assist you or\n"
- "to answer any questions you may have.\n\n"
- "Use the /HELP command to get detailed information about\n"
- "the available commands.\n"
- "- - - - - - - - - - - - - - - - - - - - - - - - - - - -";
-
static int display_firsttimer = FALSE;
+static int user_settings_changed = 0;
static void sig_exit(void)
@@ -105,6 +89,11 @@ static void sig_exit(void)
quitting = TRUE;
}
+static void sig_settings_userinfo_changed(gpointer changedp)
+{
+ user_settings_changed = GPOINTER_TO_INT(changedp);
+}
+
/* redraw irssi's screen.. */
void irssi_redraw(void)
{
@@ -161,6 +150,7 @@ static void textui_init(void)
fe_common_irc_init();
theme_register(gui_text_formats);
+ signal_add("settings userinfo changed", (SIGNAL_FUNC) sig_settings_userinfo_changed);
signal_add_last("gui exit", (SIGNAL_FUNC) sig_exit);
}
@@ -199,14 +189,24 @@ static void textui_finish_init(void)
statusbar_redraw(NULL, TRUE);
if (servers == NULL && lookup_servers == NULL) {
- printtext(NULL, NULL, MSGLEVEL_CRAP|MSGLEVEL_NO_ACT,
- "%s", banner_text);
+ printformat(NULL, NULL, MSGLEVEL_CRAP|MSGLEVEL_NO_ACT, TXT_IRSSI_BANNER);
}
if (display_firsttimer) {
- printtext(NULL, NULL, MSGLEVEL_CRAP|MSGLEVEL_NO_ACT,
- "%s", firsttimer_text);
+ printformat(NULL, NULL, MSGLEVEL_CRAP|MSGLEVEL_NO_ACT, TXT_WELCOME_FIRSTTIME);
}
+
+ /* see irc-servers-setup.c:init_userinfo */
+ if (user_settings_changed)
+ printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_WELCOME_INIT_SETTINGS);
+ if (user_settings_changed & (1<<0))
+ fe_settings_set_print("real_name");
+ if (user_settings_changed & (1<<1))
+ fe_settings_set_print("user_name");
+ if (user_settings_changed & (1<<2))
+ fe_settings_set_print("nick");
+ if (user_settings_changed & (1<<3))
+ fe_settings_set_print("hostname");
}
static void textui_deinit(void)
@@ -223,6 +223,7 @@ static void textui_deinit(void)
#endif
dirty_check(); /* one last time to print any quit messages */
+ signal_remove("settings userinfo changed", (SIGNAL_FUNC) sig_settings_userinfo_changed);
signal_remove("gui exit", (SIGNAL_FUNC) sig_exit);
lastlog_deinit();
@@ -249,6 +250,7 @@ static void textui_deinit(void)
core_deinit();
}
+
static void check_files(void)
{
struct stat statbuf;
@@ -259,12 +261,11 @@ static void check_files(void)
}
}
-
int main(int argc, char **argv)
{
static int version = 0;
static GOptionEntry options[] = {
- { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Display irssi version", NULL },
+ { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Display Irssi version", NULL },
{ NULL }
};
int loglev;
diff --git a/src/fe-text/module-formats.c b/src/fe-text/module-formats.c
index 899827c2..c4606197 100644
--- a/src/fe-text/module-formats.c
+++ b/src/fe-text/module-formats.c
@@ -78,5 +78,26 @@ FORMAT_REC gui_text_formats[] =
{ "paste_warning", "Pasting $0 lines to $1. Press Ctrl-K if you wish to do this or Ctrl-C to cancel.", 2, { 1, 0 } },
{ "paste_prompt", "Hit Ctrl-K to paste, Ctrl-C to abort?", 0 },
+ /* ---- */
+ { NULL, "Welcome", 0 },
+
+ { "irssi_banner",
+ " ___ _%:"
+ "|_ _|_ _ _____(_)%:"
+ " | || '_(_-<_-< |%:"
+ "|___|_| /__/__/_|%:"
+ "Irssi v$J - http://www.irssi.org", 0 },
+ { "welcome_firsttime",
+ "- - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"
+ "Hi there! If this is your first time using Irssi, you%:"
+ "might want to go to our website and read the startup%:"
+ "documentation to get you going.%:%:"
+ "Our community and staff are available to assist you or%:"
+ "to answer any questions you may have.%:%:"
+ "Use the /HELP command to get detailed information about%:"
+ "the available commands.%:"
+ "- - - - - - - - - - - - - - - - - - - - - - - - - - - -", 0 },
+ { "welcome_init_settings", "The following settings were initialized", 0 },
+
{ NULL, NULL, 0 }
};
diff --git a/src/fe-text/module-formats.h b/src/fe-text/module-formats.h
index 3fa8c511..05e9438d 100644
--- a/src/fe-text/module-formats.h
+++ b/src/fe-text/module-formats.h
@@ -52,6 +52,12 @@ enum {
TXT_PASTE_WARNING,
TXT_PASTE_PROMPT,
+ TXT_FILL_5, /* Welcome */
+
+ TXT_IRSSI_BANNER,
+ TXT_WELCOME_FIRSTTIME,
+ TXT_WELCOME_INIT_SETTINGS,
+
TXT_COUNT
};
diff --git a/src/irc/core/irc-servers-setup.c b/src/irc/core/irc-servers-setup.c
index bae7d3b4..22c86f57 100644
--- a/src/irc/core/irc-servers-setup.c
+++ b/src/irc/core/irc-servers-setup.c
@@ -116,14 +116,17 @@ static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn,
static void init_userinfo(void)
{
+ int changed;
const char *set, *nick, *user_name, *str;
+ changed = 0;
/* check if nick/username/realname wasn't read from setup.. */
set = settings_get_str("real_name");
if (set == NULL || *set == '\0') {
str = g_getenv("IRCNAME");
settings_set_str("real_name",
str != NULL ? str : g_get_real_name());
+ changed |= 1<<0;
}
/* username */
@@ -134,6 +137,7 @@ static void init_userinfo(void)
str != NULL ? str : g_get_user_name());
user_name = settings_get_str("user_name");
+ changed |= 1<<1;
}
/* nick */
@@ -143,15 +147,20 @@ static void init_userinfo(void)
settings_set_str("nick", str != NULL ? str : user_name);
nick = settings_get_str("nick");
+ changed |= 1<<2;
}
/* host name */
set = settings_get_str("hostname");
if (set == NULL || *set == '\0') {
str = g_getenv("IRCHOST");
- if (str != NULL)
+ if (str != NULL) {
settings_set_str("hostname", str);
+ changed |= 1<<3;
+ }
}
+
+ signal_emit("irssi init userinfo changed", 1, GINT_TO_POINTER(changed));
}
static void sig_server_setup_read(IRC_SERVER_SETUP_REC *rec, CONFIG_NODE *node)
From 4d6822b1c43d876856a5df07ce69fb4e67c3591a Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Wed, 1 Nov 2017 15:52:45 +0100
Subject: [PATCH 0111/1087] up abi
---
src/common.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/common.h b/src/common.h
index 159f7124..a7eaa7cf 100644
--- a/src/common.h
+++ b/src/common.h
@@ -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 11
+#define IRSSI_ABI_VERSION 12
#define DEFAULT_SERVER_ADD_PORT 6667
#define DEFAULT_SERVER_ADD_TLS_PORT 6697
From 56013367983b61d8ee4d2e905767ce50b25ffb82 Mon Sep 17 00:00:00 2001
From: LemonBoy
Date: Mon, 30 Oct 2017 09:39:16 +0100
Subject: [PATCH 0112/1087] Turn the style guide into a clang-format file
---
.clang-format | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 .clang-format
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..5501478f
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,37 @@
+# IndentPPDirectives: None
+# SpaceInParentheses: false
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: Empty
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: true
+BinPackArguments: true
+BinPackParameters: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Attach
+BreakBeforeTernaryOperators: true
+ColumnLimit: 100
+IndentCaseLabels: true
+IndentWidth: 8
+IndentWrappedFunctionNames: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+Language: Cpp
+MaxEmptyLinesToKeep: 1
+PointerAlignment: Right
+SortIncludes: true
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesInCStyleCastParentheses: false
+SpacesInSquareBrackets: false
+TabWidth: 8
+UseTab: ForIndentation
From 60c31219a278330498e695e4d7fca05ea69962e4 Mon Sep 17 00:00:00 2001
From: Jari Matilainen
Date: Tue, 24 Oct 2017 12:02:30 +0200
Subject: [PATCH 0113/1087] Allow selection of what kind of activity targets to
ignore
Initialize tagtarget on declaration
move code around for better flow, extra checks for uninitialized values
remove unnecessary item->type checks
don't strdup sign
add braces around if statements, use strcmp0 with single characters and remove g_str_has_prefix
refactoring
changed g_ascii_strcasecmp to g_strcmp0
Add networktag/ shorthand
fixed memory leaks
changed from #@= to ::channels, ::queries and ::dccqueries
check for empty string and continue; if found
fixed bug with empty string check
Clean up code
---
src/fe-common/core/fe-common-core.c | 53 +++++++++++++++++++----------
1 file changed, 35 insertions(+), 18 deletions(-)
diff --git a/src/fe-common/core/fe-common-core.c b/src/fe-common/core/fe-common-core.c
index 512fc84c..bce9ab4e 100644
--- a/src/fe-common/core/fe-common-core.c
+++ b/src/fe-common/core/fe-common-core.c
@@ -461,26 +461,43 @@ void fe_common_core_finish_init(void)
gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest)
{
+ int channel_type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL");
+ int query_type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY");
+ char **tmp;
+
g_return_val_if_fail(array != NULL, FALSE);
+ g_return_val_if_fail(dest != NULL, FALSE);
+ g_return_val_if_fail(dest->window != NULL, FALSE);
+ g_return_val_if_fail(dest->target != NULL, FALSE);
- if (strarray_find(array, "*") != -1)
- return TRUE;
-
- if (strarray_find(array, dest->target) != -1)
- return TRUE;
-
- if (dest->server_tag != NULL) {
- char *tagtarget = g_strdup_printf("%s/%s", dest->server_tag, "*");
- int ret = strarray_find(array, tagtarget);
- g_free(tagtarget);
- if (ret != -1)
- return TRUE;
-
- tagtarget = g_strdup_printf("%s/%s", dest->server_tag, dest->target);
- ret = strarray_find(array, tagtarget);
- g_free(tagtarget);
- if (ret != -1)
- return TRUE;
+ WI_ITEM_REC *item = window_item_find_window(dest->window, dest->server, dest->target);
+ if (item == NULL) {
+ return FALSE;
}
+
+ int server_tag_len = dest->server_tag ? strlen(dest->server_tag) : 0;
+ for (tmp = array; *tmp != NULL; tmp++) {
+ char *str = *tmp;
+ if (*str == '\0') {
+ continue;
+ }
+
+ if (server_tag_len && !g_ascii_strncasecmp(str, dest->server_tag, server_tag_len) && str[server_tag_len] == '/') {
+ str += server_tag_len + 1;
+ }
+
+ if (!g_strcmp0(str, "") || !g_strcmp0(str, "::all")) {
+ return TRUE;
+ } else if (!g_ascii_strcasecmp(str, dest->target)) {
+ return TRUE;
+ } else if (item->type == query_type &&
+ !g_strcmp0(str, (dest->target[0] == '=') ? "::dccqueries" : "::queries")) {
+ return TRUE;
+ } else if (item->type == channel_type &&
+ !g_strcmp0(str, "::channels")) {
+ return TRUE;
+ }
+ }
+
return FALSE;
}
From f9d69597ef1e204640d5ce104061717aca0d213a Mon Sep 17 00:00:00 2001
From: Joseph Bisch
Date: Thu, 2 Nov 2017 11:44:57 -0400
Subject: [PATCH 0114/1087] Remove unnecessary malloc cast in fe-fuzz
We compile this as C code, so the cast is unnecessary.
---
src/fe-fuzz/irc/core/event-get-params.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/fe-fuzz/irc/core/event-get-params.c b/src/fe-fuzz/irc/core/event-get-params.c
index 89eb89d2..fc21bbeb 100644
--- a/src/fe-fuzz/irc/core/event-get-params.c
+++ b/src/fe-fuzz/irc/core/event-get-params.c
@@ -52,7 +52,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
return 0;
}
uint8_t count = *data;
- char *copy = (char *)malloc(sizeof(char)*(size-1+1));
+ char *copy = malloc(sizeof(char)*(size-1+1));
memcpy(copy, data+1, size-1);
copy[size-1] = '\0';
From f4b89044f075038d29089435f7620a068507d80e Mon Sep 17 00:00:00 2001
From: Joseph Bisch
Date: Thu, 2 Nov 2017 11:48:30 -0400
Subject: [PATCH 0115/1087] Fix malloc parameter in fe-fuzz
It is fairly safe to assume that sizeof(char) will always be 1 anyway
and replace the size calculation with a comment explaining the
calculation.
---
src/fe-fuzz/irc/core/event-get-params.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/fe-fuzz/irc/core/event-get-params.c b/src/fe-fuzz/irc/core/event-get-params.c
index fc21bbeb..f8060ffe 100644
--- a/src/fe-fuzz/irc/core/event-get-params.c
+++ b/src/fe-fuzz/irc/core/event-get-params.c
@@ -52,7 +52,8 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
return 0;
}
uint8_t count = *data;
- char *copy = malloc(sizeof(char)*(size-1+1));
+ /* malloc(size) instead of size+1, because we already used one byte of data */
+ char *copy = malloc(size);
memcpy(copy, data+1, size-1);
copy[size-1] = '\0';
From 532527ffa6a5eaccdbf607a2dc3d0e6ef884fce9 Mon Sep 17 00:00:00 2001
From: Joseph Bisch
Date: Thu, 2 Nov 2017 11:56:53 -0400
Subject: [PATCH 0116/1087] Use gchar and g_strndup in fe-fuzz
---
src/fe-fuzz/irc/core/event-get-params.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/fe-fuzz/irc/core/event-get-params.c b/src/fe-fuzz/irc/core/event-get-params.c
index f8060ffe..6266ffb6 100644
--- a/src/fe-fuzz/irc/core/event-get-params.c
+++ b/src/fe-fuzz/irc/core/event-get-params.c
@@ -53,9 +53,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
}
uint8_t count = *data;
/* malloc(size) instead of size+1, because we already used one byte of data */
- char *copy = malloc(size);
- memcpy(copy, data+1, size-1);
- copy[size-1] = '\0';
+ gchar *copy = g_strndup((const gchar *)data+1, size-1);
char *output0;
char *output1;
@@ -82,6 +80,6 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
params = event_get_params(copy, 4, &output0, &output1, &output2, &output3);
}
g_free(params);
- free(copy);
+ g_free(copy);
return 0;
}
From 66b2c9bc91a3b6e34ba59491c95747db75d21c6b Mon Sep 17 00:00:00 2001
From: LemonBoy
Date: Fri, 3 Nov 2017 16:37:04 +0100
Subject: [PATCH 0117/1087] Keep a copy of the strings coming from the config
The "HILIGHT_REC" structure used to keep a pointer to the "servertag"
string, owned by the "CONFIG_NODE", causing a double-free.
---
src/fe-common/core/hilight-text.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c
index 62e6f0de..b9912457 100644
--- a/src/fe-common/core/hilight-text.c
+++ b/src/fe-common/core/hilight-text.c
@@ -106,6 +106,7 @@ static void hilight_destroy(HILIGHT_REC *rec)
if (rec->channels != NULL) g_strfreev(rec->channels);
g_free_not_null(rec->color);
g_free_not_null(rec->act_color);
+ g_free_not_null(rec->servertag);
g_free(rec->text);
g_free(rec);
}
@@ -424,7 +425,7 @@ static void read_hilight_config(void)
CONFIG_NODE *node;
HILIGHT_REC *rec;
GSList *tmp;
- char *text, *color;
+ char *text, *color, *servertag;
hilights_destroy_all();
@@ -467,7 +468,9 @@ static void read_hilight_config(void)
rec->nickmask = config_node_get_bool(node, "mask", FALSE);
rec->fullword = config_node_get_bool(node, "fullword", FALSE);
rec->regexp = config_node_get_bool(node, "regexp", FALSE);
- rec->servertag = config_node_get_str(node, "servertag", NULL);
+ servertag = config_node_get_str(node, "servertag", NULL);
+ rec->servertag = servertag == NULL || *servertag == '\0' ? NULL :
+ g_strdup(servertag);
hilight_init_rec(rec);
node = iconfig_node_section(node, "channels", -1);
From 02c677f467b398f8b91b1e90544502ff98a6e0da Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Fri, 10 Nov 2017 22:02:36 +0100
Subject: [PATCH 0118/1087] use enum
---
src/core/settings.c | 6 +++---
src/core/settings.h | 7 +++++++
src/fe-text/irssi.c | 15 +++++++--------
src/irc/core/irc-servers-setup.c | 12 ++++++------
4 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/src/core/settings.c b/src/core/settings.c
index 48d6640e..3ebb9e4a 100644
--- a/src/core/settings.c
+++ b/src/core/settings.c
@@ -39,7 +39,7 @@ static GString *last_errors;
static GSList *last_invalid_modules;
static int fe_initialized;
static int config_changed; /* FIXME: remove after .98 (unless needed again) */
-static int user_settings_changed;
+static unsigned int user_settings_changed;
static GHashTable *settings;
static int timeout_tag;
@@ -467,7 +467,7 @@ SETTINGS_REC *settings_get_record(const char *key)
static void sig_init_userinfo_changed(gpointer changedp)
{
- user_settings_changed = GPOINTER_TO_INT(changedp);
+ user_settings_changed |= GPOINTER_TO_UINT(changedp);
}
static void sig_init_finished(void)
@@ -486,7 +486,7 @@ static void sig_init_finished(void)
signal_emit("setup changed", 0);
}
- signal_emit("settings userinfo changed", 1, GINT_TO_POINTER(user_settings_changed));
+ signal_emit("settings userinfo changed", 1, GUINT_TO_POINTER(user_settings_changed));
}
static void settings_clean_invalid_module(const char *module)
diff --git a/src/core/settings.h b/src/core/settings.h
index d174f250..b67a9e44 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -30,6 +30,13 @@ typedef struct {
char **choices;
} SETTINGS_REC;
+enum {
+ USER_SETTINGS_REAL_NAME = 0x1,
+ USER_SETTINGS_USER_NAME = 0x2,
+ USER_SETTINGS_NICK = 0x4,
+ USER_SETTINGS_HOSTNAME = 0x8,
+};
+
/* macros for handling the default Irssi configuration */
#define iconfig_get_str(a, b, c) config_get_str(mainconfig, a, b, c)
#define iconfig_get_int(a, b, c) config_get_int(mainconfig, a, b, c)
diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c
index 6349ae2a..ef443670 100644
--- a/src/fe-text/irssi.c
+++ b/src/fe-text/irssi.c
@@ -81,7 +81,7 @@ static GMainLoop *main_loop;
int quitting;
static int display_firsttimer = FALSE;
-static int user_settings_changed = 0;
+static unsigned int user_settings_changed = 0;
static void sig_exit(void)
@@ -91,7 +91,7 @@ static void sig_exit(void)
static void sig_settings_userinfo_changed(gpointer changedp)
{
- user_settings_changed = GPOINTER_TO_INT(changedp);
+ user_settings_changed = GPOINTER_TO_UINT(changedp);
}
/* redraw irssi's screen.. */
@@ -199,13 +199,13 @@ static void textui_finish_init(void)
/* see irc-servers-setup.c:init_userinfo */
if (user_settings_changed)
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_WELCOME_INIT_SETTINGS);
- if (user_settings_changed & (1<<0))
+ if (user_settings_changed & USER_SETTINGS_REAL_NAME)
fe_settings_set_print("real_name");
- if (user_settings_changed & (1<<1))
+ if (user_settings_changed & USER_SETTINGS_USER_NAME)
fe_settings_set_print("user_name");
- if (user_settings_changed & (1<<2))
+ if (user_settings_changed & USER_SETTINGS_NICK)
fe_settings_set_print("nick");
- if (user_settings_changed & (1<<3))
+ if (user_settings_changed & USER_SETTINGS_HOSTNAME)
fe_settings_set_print("hostname");
}
@@ -222,7 +222,7 @@ static void textui_deinit(void)
fe_perl_deinit();
#endif
- dirty_check(); /* one last time to print any quit messages */
+ dirty_check(); /* one last time to print any quit messages */
signal_remove("settings userinfo changed", (SIGNAL_FUNC) sig_settings_userinfo_changed);
signal_remove("gui exit", (SIGNAL_FUNC) sig_exit);
@@ -250,7 +250,6 @@ static void textui_deinit(void)
core_deinit();
}
-
static void check_files(void)
{
struct stat statbuf;
diff --git a/src/irc/core/irc-servers-setup.c b/src/irc/core/irc-servers-setup.c
index 22c86f57..e79557ab 100644
--- a/src/irc/core/irc-servers-setup.c
+++ b/src/irc/core/irc-servers-setup.c
@@ -116,7 +116,7 @@ static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn,
static void init_userinfo(void)
{
- int changed;
+ unsigned int changed;
const char *set, *nick, *user_name, *str;
changed = 0;
@@ -126,7 +126,7 @@ static void init_userinfo(void)
str = g_getenv("IRCNAME");
settings_set_str("real_name",
str != NULL ? str : g_get_real_name());
- changed |= 1<<0;
+ changed |= USER_SETTINGS_REAL_NAME;
}
/* username */
@@ -137,7 +137,7 @@ static void init_userinfo(void)
str != NULL ? str : g_get_user_name());
user_name = settings_get_str("user_name");
- changed |= 1<<1;
+ changed |= USER_SETTINGS_USER_NAME;
}
/* nick */
@@ -147,7 +147,7 @@ static void init_userinfo(void)
settings_set_str("nick", str != NULL ? str : user_name);
nick = settings_get_str("nick");
- changed |= 1<<2;
+ changed |= USER_SETTINGS_NICK;
}
/* host name */
@@ -156,11 +156,11 @@ static void init_userinfo(void)
str = g_getenv("IRCHOST");
if (str != NULL) {
settings_set_str("hostname", str);
- changed |= 1<<3;
+ changed |= USER_SETTINGS_HOSTNAME;
}
}
- signal_emit("irssi init userinfo changed", 1, GINT_TO_POINTER(changed));
+ signal_emit("irssi init userinfo changed", 1, GUINT_TO_POINTER(changed));
}
static void sig_server_setup_read(IRC_SERVER_SETUP_REC *rec, CONFIG_NODE *node)
From 596fa6b51ed2ab6be80041684ad805f7b22256ac Mon Sep 17 00:00:00 2001
From: LemonBoy
Date: Sat, 11 Nov 2017 09:14:41 +0100
Subject: [PATCH 0119/1087] Take into account Nei's suggestions
---
.clang-format | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/.clang-format b/.clang-format
index 5501478f..295356df 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,4 +1,4 @@
-# IndentPPDirectives: None
+# IndentPPDirectives: AfterHash
# SpaceInParentheses: false
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
@@ -12,22 +12,23 @@ AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
-AlwaysBreakBeforeMultilineStrings: true
+AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: None
-BreakBeforeBraces: Attach
-BreakBeforeTernaryOperators: true
+BreakBeforeBraces: Linux
+BreakBeforeTernaryOperators: false
ColumnLimit: 100
IndentCaseLabels: true
IndentWidth: 8
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: false
Language: Cpp
+Cpp11BracedListStyle: false
MaxEmptyLinesToKeep: 1
PointerAlignment: Right
SortIncludes: true
-SpaceAfterCStyleCast: false
+SpaceAfterCStyleCast: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
From 7605f67f95b6ee1ac26dd8fb7f3121f319497943 Mon Sep 17 00:00:00 2001
From: LemonBoy
Date: Sat, 11 Nov 2017 12:37:51 +0100
Subject: [PATCH 0120/1087] Prevent a UAF error during the execution of some
commands
Some arguments were free'd first and then printed, leading to gibberish
being output to screen or a crash.
Found by Joseph Bisch.
Closes: !GL17
---
src/fe-common/core/fe-channels.c | 2 +-
src/fe-common/core/fe-server.c | 2 +-
src/fe-common/irc/fe-ircnet.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c
index 8e434ab5..5cad51a7 100644
--- a/src/fe-common/core/fe-channels.c
+++ b/src/fe-common/core/fe-channels.c
@@ -278,9 +278,9 @@ static void cmd_channel_add_modify(const char *data, gboolean add)
rec = channel_setup_find(channel, chatnet);
if (rec == NULL) {
if (add == FALSE) {
- cmd_params_free(free_arg);
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
TXT_CHANSETUP_NOT_FOUND, channel, chatnet);
+ cmd_params_free(free_arg);
return;
}
diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c
index 810afe83..074a83f3 100644
--- a/src/fe-common/core/fe-server.c
+++ b/src/fe-common/core/fe-server.c
@@ -136,9 +136,9 @@ static void cmd_server_add_modify(const char *data, gboolean add)
if (rec == NULL) {
if (add == FALSE) {
- cmd_params_free(free_arg);
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
TXT_SETUPSERVER_NOT_FOUND, addr, port);
+ cmd_params_free(free_arg);
return;
}
diff --git a/src/fe-common/irc/fe-ircnet.c b/src/fe-common/irc/fe-ircnet.c
index 8f1d2efd..5ae5ac05 100644
--- a/src/fe-common/irc/fe-ircnet.c
+++ b/src/fe-common/irc/fe-ircnet.c
@@ -106,9 +106,9 @@ static void cmd_network_add_modify(const char *data, gboolean add)
rec = ircnet_find(name);
if (rec == NULL) {
if (add == FALSE) {
- cmd_params_free(free_arg);
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
IRCTXT_NETWORK_NOT_FOUND, name);
+ cmd_params_free(free_arg);
return;
}
From 3acc72f842a021ffcff8809c1f245ca614f68598 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Wed, 15 Nov 2017 16:33:06 +0100
Subject: [PATCH 0121/1087] reset colour at comma, like mIRC
Fixes #742 and #740
---
src/fe-common/core/formats.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c
index 005e6fb7..a340bffa 100644
--- a/src/fe-common/core/formats.c
+++ b/src/fe-common/core/formats.c
@@ -1072,7 +1072,8 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
fg = fg_ret == NULL ? -1 : *fg_ret;
bg = bg_ret == NULL ? -1 : *bg_ret;
- if (!i_isdigit(**str) && **str != ',') {
+ if (!i_isdigit(**str)) {
+ /* turn off color */
fg = -1;
bg = -1;
} else {
@@ -1085,11 +1086,8 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
(*str)++;
}
}
- if (**str == ',') {
+ if ((*str)[0] == ',' && i_isdigit((*str)[1])) {
/* background color */
- if (!i_isdigit((*str)[1]))
- bg = -1;
- else {
(*str)++;
bg = **str-'0';
(*str)++;
@@ -1097,7 +1095,6 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
bg = bg*10 + (**str-'0');
(*str)++;
}
- }
}
}
From ba3c5801a4bb175fe1e0d0fd273ae15318dd2b03 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Thu, 16 Nov 2017 13:50:48 +0100
Subject: [PATCH 0122/1087] Update .clang-format
do not indent case deeper
---
.clang-format | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.clang-format b/.clang-format
index 295356df..1180910e 100644
--- a/.clang-format
+++ b/.clang-format
@@ -19,7 +19,7 @@ BreakBeforeBinaryOperators: None
BreakBeforeBraces: Linux
BreakBeforeTernaryOperators: false
ColumnLimit: 100
-IndentCaseLabels: true
+IndentCaseLabels: false
IndentWidth: 8
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: false
From 47400d405a0680bfe4d69ce8b06ecbfd09931999 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Mon, 20 Nov 2017 14:17:15 +0100
Subject: [PATCH 0123/1087] Update formats.c
remove now useless check for ,
---
src/fe-common/core/formats.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c
index a340bffa..37db6f7c 100644
--- a/src/fe-common/core/formats.c
+++ b/src/fe-common/core/formats.c
@@ -1078,23 +1078,22 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
bg = -1;
} else {
/* foreground color */
- if (**str != ',') {
- fg = **str-'0';
+ fg = **str-'0';
+ (*str)++;
+ if (i_isdigit(**str)) {
+ fg = fg*10 + (**str-'0');
(*str)++;
- if (i_isdigit(**str)) {
- fg = fg*10 + (**str-'0');
- (*str)++;
- }
}
+
if ((*str)[0] == ',' && i_isdigit((*str)[1])) {
/* background color */
+ (*str)++;
+ bg = **str-'0';
+ (*str)++;
+ if (i_isdigit(**str)) {
+ bg = bg*10 + (**str-'0');
(*str)++;
- bg = **str-'0';
- (*str)++;
- if (i_isdigit(**str)) {
- bg = bg*10 + (**str-'0');
- (*str)++;
- }
+ }
}
}
From 1a49787ef25103d1a393c81e35fb949322fe0523 Mon Sep 17 00:00:00 2001
From: Will Storey
Date: Mon, 27 Nov 2017 19:37:11 -0800
Subject: [PATCH 0124/1087] Revert initializing pointers to NULL
To maintain C89 compatibility
---
src/fe-common/irc/fe-events.c | 2 +-
src/irc/core/modes.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/fe-common/irc/fe-events.c b/src/fe-common/irc/fe-events.c
index cc83d476..850174c5 100644
--- a/src/fe-common/irc/fe-events.c
+++ b/src/fe-common/irc/fe-events.c
@@ -224,7 +224,7 @@ static void event_nick(IRC_SERVER_REC *server, const char *data,
static void event_mode(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr)
{
- char *params = NULL, *channel = NULL, *mode = NULL;
+ char *params, *channel, *mode;
g_return_if_fail(data != NULL);
diff --git a/src/irc/core/modes.c b/src/irc/core/modes.c
index ecbf2571..cc3d0faf 100644
--- a/src/irc/core/modes.c
+++ b/src/irc/core/modes.c
@@ -480,8 +480,8 @@ static void event_user_mode(IRC_SERVER_REC *server, const char *data)
static void event_mode(IRC_SERVER_REC *server, const char *data,
const char *nick)
{
- IRC_CHANNEL_REC *chanrec = NULL;
- char *params = NULL, *channel = NULL, *mode = NULL;
+ IRC_CHANNEL_REC *chanrec;
+ char *params, *channel, *mode;
g_return_if_fail(data != NULL);
From b2ca8c04778866bd07cf1b612adf0df55f45b78e Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Wed, 29 Nov 2017 15:53:12 +0100
Subject: [PATCH 0125/1087] check for declaration-after-statement on travis
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index b4b93919..1d8786c4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -31,7 +31,7 @@ before_install:
install:
- ./configure --with-proxy --with-bot --with-perl=module --prefix=$HOME/irssi-build
- - make CFLAGS="-Wall -Werror"
+ - make CFLAGS="-Wall -Werror -Werror=declaration-after-statement"
- make install
before_script:
From b332d448f7e3c7e4b40ea4a08932d0bd46007bbf Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Thu, 30 Nov 2017 11:15:47 +0100
Subject: [PATCH 0126/1087] fix comments
---
src/core/ignore.h | 6 +++---
src/core/network-openssl.c | 20 ++++++++++----------
src/fe-fuzz/irssi.c | 2 +-
src/fe-text/statusbar-items.c | 4 ++--
src/irc/core/sasl.c | 6 +++---
5 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/core/ignore.h b/src/core/ignore.h
index e18be3c4..31171b58 100644
--- a/src/core/ignore.h
+++ b/src/core/ignore.h
@@ -27,14 +27,14 @@ int ignore_check(SERVER_REC *server, const char *nick, const char *host,
const char *channel, const char *text, int level);
enum {
- IGNORE_FIND_PATTERN = 0x01, // Match the pattern
- IGNORE_FIND_NOACT = 0x02, // Exclude the targets with NOACT level
+ IGNORE_FIND_PATTERN = 0x01, /* Match the pattern */
+ IGNORE_FIND_NOACT = 0x02, /* Exclude the targets with NOACT level */
};
IGNORE_REC *ignore_find_full (const char *servertag, const char *mask, const char *pattern,
char **channels, const int flags);
-// Convenience wrappers around ignore_find_full, for compatibility purpose
+/* Convenience wrappers around ignore_find_full, for compatibility purpose */
IGNORE_REC *ignore_find(const char *servertag, const char *mask, char **channels);
IGNORE_REC *ignore_find_noact(const char *servertag, const char *mask, char **channels, int noact);
diff --git a/src/core/network-openssl.c b/src/core/network-openssl.c
index 7ec902fb..26496f47 100644
--- a/src/core/network-openssl.c
+++ b/src/core/network-openssl.c
@@ -600,7 +600,7 @@ static void set_pubkey_info(TLS_REC *tls, X509 *cert, unsigned char *cert_finger
tls_rec_set_certificate_fingerprint(tls, cert_fingerprint_hex);
tls_rec_set_certificate_fingerprint_algorithm(tls, "SHA256");
- // Show algorithm.
+ /* Show algorithm. */
switch (EVP_PKEY_id(pubkey)) {
case EVP_PKEY_RSA:
tls_rec_set_public_key_algorithm(tls, "RSA");
@@ -624,7 +624,7 @@ static void set_pubkey_info(TLS_REC *tls, X509 *cert, unsigned char *cert_finger
tls_rec_set_public_key_size(tls, EVP_PKEY_bits(pubkey));
tls_rec_set_public_key_fingerprint_algorithm(tls, "SHA256");
- // Read the NotBefore timestamp.
+ /* Read the NotBefore timestamp. */
bio = BIO_new(BIO_s_mem());
ASN1_TIME_print(bio, X509_get_notBefore(cert));
length = BIO_read(bio, buffer, sizeof(buffer));
@@ -632,7 +632,7 @@ static void set_pubkey_info(TLS_REC *tls, X509 *cert, unsigned char *cert_finger
BIO_free(bio);
tls_rec_set_not_before(tls, buffer);
- // Read the NotAfter timestamp.
+ /* Read the NotAfter timestamp. */
bio = BIO_new(BIO_s_mem());
ASN1_TIME_print(bio, X509_get_notAfter(cert));
length = BIO_read(bio, buffer, sizeof(buffer));
@@ -670,7 +670,7 @@ static void set_peer_cert_chain_info(TLS_REC *tls, SSL *ssl)
for (i = 0; i < sk_X509_num(chain); i++) {
cert_rec = tls_cert_create_rec();
- // Subject.
+ /* Subject. */
name = X509_get_subject_name(sk_X509_value(chain, i));
for (j = 0; j < X509_NAME_entry_count(name); j++) {
@@ -689,7 +689,7 @@ static void set_peer_cert_chain_info(TLS_REC *tls, SSL *ssl)
tls_cert_rec_append_subject_entry(cert_rec, tls_cert_entry_rec);
}
- // Issuer.
+ /* Issuer. */
name = X509_get_issuer_name(sk_X509_value(chain, i));
for (j = 0; j < X509_NAME_entry_count(name); j++) {
@@ -718,10 +718,10 @@ static void set_server_temporary_key_info(TLS_REC *tls, SSL *ssl)
g_return_if_fail(ssl != NULL);
#ifdef SSL_get_server_tmp_key
- // Show ephemeral key information.
+ /* Show ephemeral key information. */
EVP_PKEY *ephemeral_key = NULL;
- // OPENSSL_NO_EC is for solaris 11.3 (2016), github ticket #598
+ /* OPENSSL_NO_EC is for solaris 11.3 (2016), github ticket #598 */
#ifndef OPENSSL_NO_EC
EC_KEY *ec_key = NULL;
#endif
@@ -759,7 +759,7 @@ static void set_server_temporary_key_info(TLS_REC *tls, SSL *ssl)
EVP_PKEY_free(ephemeral_key);
}
-#endif // SSL_get_server_tmp_key.
+#endif /* SSL_get_server_tmp_key. */
}
GIOChannel *net_connect_ip_ssl(IPADDR *ip, int port, IPADDR *my_ip, SERVER_REC *server)
@@ -866,7 +866,7 @@ int irssi_ssl_handshake(GIOChannel *handle)
set_peer_cert_chain_info(tls, chan->ssl);
set_server_temporary_key_info(tls, chan->ssl);
- // Emit the TLS rec.
+ /* Emit the TLS rec. */
signal_emit("tls handshake finished", 2, chan->server, tls);
ret = 1;
@@ -893,7 +893,7 @@ int irssi_ssl_handshake(GIOChannel *handle)
ret = irssi_ssl_verify(chan->ssl, chan->ctx, chan->server->connrec->address, chan->port, cert, chan->server, tls);
if (! ret) {
- // irssi_ssl_verify emits a warning itself.
+ /* irssi_ssl_verify emits a warning itself. */
goto done;
}
}
diff --git a/src/fe-fuzz/irssi.c b/src/fe-fuzz/irssi.c
index 77892aaf..c1b2ca9b 100644
--- a/src/fe-fuzz/irssi.c
+++ b/src/fe-fuzz/irssi.c
@@ -21,7 +21,7 @@
#include "module.h"
#include "modules-load.h"
#include "levels.h"
-#include "../fe-text/module-formats.h" // need to explicitly grab from fe-text
+#include "../fe-text/module-formats.h" /* need to explicitly grab from fe-text */
#include "themes.h"
#include "core.h"
#include "fe-common-core.h"
diff --git a/src/fe-text/statusbar-items.c b/src/fe-text/statusbar-items.c
index de4499b4..c7d6bcfb 100644
--- a/src/fe-text/statusbar-items.c
+++ b/src/fe-text/statusbar-items.c
@@ -369,8 +369,8 @@ static void item_lag(SBAR_ITEM_REC *item, int get_size_only)
last_lag_unknown = lag_unknown;
if (lag_unknown) {
- // "??)" in C becomes ']'
- // See: https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C
+ /* "??)" in C becomes ']'
+ See: https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C */
g_snprintf(str, sizeof(str), "%d (?""?)", lag / 100);
} else {
if (lag % 100 == 0)
diff --git a/src/irc/core/sasl.c b/src/irc/core/sasl.c
index 635b7dfb..2b589579 100644
--- a/src/irc/core/sasl.c
+++ b/src/irc/core/sasl.c
@@ -30,16 +30,16 @@
* Based on IRCv3 SASL Extension Specification:
* http://ircv3.net/specs/extensions/sasl-3.1.html
*/
-#define AUTHENTICATE_CHUNK_SIZE 400 // bytes
+#define AUTHENTICATE_CHUNK_SIZE 400 /* bytes */
/*
* Maximum size to allow the buffer to grow to before the next fragment comes in. Note that
* due to the way fragmentation works, the maximum message size will actually be:
* floor(AUTHENTICATE_MAX_SIZE / AUTHENTICATE_CHUNK_SIZE) + AUTHENTICATE_CHUNK_SIZE - 1
*/
-#define AUTHENTICATE_MAX_SIZE 8192 // bytes
+#define AUTHENTICATE_MAX_SIZE 8192 /* bytes */
-#define SASL_TIMEOUT (20 * 1000) // ms
+#define SASL_TIMEOUT (20 * 1000) /* ms */
static gboolean sasl_timeout(IRC_SERVER_REC *server)
{
From 2b918fd9b8438eeef8f33556723140263e36f731 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Thu, 30 Nov 2017 11:17:05 +0100
Subject: [PATCH 0127/1087] move decls before code
---
src/core/network-openssl.c | 18 +++++++++---------
src/fe-common/core/fe-windows.c | 4 +++-
src/perl/common/Expando.xs | 3 ++-
src/perl/textui/Statusbar.xs | 4 ++--
4 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/core/network-openssl.c b/src/core/network-openssl.c
index 26496f47..c7ce4b43 100644
--- a/src/core/network-openssl.c
+++ b/src/core/network-openssl.c
@@ -583,9 +583,6 @@ static void set_cipher_info(TLS_REC *tls, SSL *ssl)
static void set_pubkey_info(TLS_REC *tls, X509 *cert, unsigned char *cert_fingerprint, size_t cert_fingerprint_size, unsigned char *public_key_fingerprint, size_t public_key_fingerprint_size)
{
- g_return_if_fail(tls != NULL);
- g_return_if_fail(cert != NULL);
-
EVP_PKEY *pubkey = NULL;
char *cert_fingerprint_hex = NULL;
char *public_key_fingerprint_hex = NULL;
@@ -594,6 +591,9 @@ static void set_pubkey_info(TLS_REC *tls, X509 *cert, unsigned char *cert_finger
char buffer[128];
size_t length;
+ g_return_if_fail(tls != NULL);
+ g_return_if_fail(cert != NULL);
+
pubkey = X509_get_pubkey(cert);
cert_fingerprint_hex = binary_to_hex(cert_fingerprint, cert_fingerprint_size);
@@ -647,9 +647,6 @@ static void set_pubkey_info(TLS_REC *tls, X509 *cert, unsigned char *cert_finger
static void set_peer_cert_chain_info(TLS_REC *tls, SSL *ssl)
{
- g_return_if_fail(tls != NULL);
- g_return_if_fail(ssl != NULL);
-
int nid;
char *key = NULL;
char *value = NULL;
@@ -662,6 +659,9 @@ static void set_peer_cert_chain_info(TLS_REC *tls, SSL *ssl)
TLS_CERT_ENTRY_REC *tls_cert_entry_rec = NULL;
ASN1_STRING *data = NULL;
+ g_return_if_fail(tls != NULL);
+ g_return_if_fail(ssl != NULL);
+
chain = SSL_get_peer_cert_chain(ssl);
if (chain == NULL)
@@ -714,9 +714,6 @@ static void set_peer_cert_chain_info(TLS_REC *tls, SSL *ssl)
static void set_server_temporary_key_info(TLS_REC *tls, SSL *ssl)
{
- g_return_if_fail(tls != NULL);
- g_return_if_fail(ssl != NULL);
-
#ifdef SSL_get_server_tmp_key
/* Show ephemeral key information. */
EVP_PKEY *ephemeral_key = NULL;
@@ -729,6 +726,9 @@ static void set_server_temporary_key_info(TLS_REC *tls, SSL *ssl)
char *cname = NULL;
int nid;
+ g_return_if_fail(tls != NULL);
+ g_return_if_fail(ssl != NULL);
+
if (SSL_get_server_tmp_key(ssl, &ephemeral_key)) {
switch (EVP_PKEY_id(ephemeral_key)) {
case EVP_PKEY_DH:
diff --git a/src/fe-common/core/fe-windows.c b/src/fe-common/core/fe-windows.c
index 0afa2914..93f2e3f3 100644
--- a/src/fe-common/core/fe-windows.c
+++ b/src/fe-common/core/fe-windows.c
@@ -563,8 +563,10 @@ GSList *windows_get_sorted(void)
begin = windows_seq_begin();
while (iter != begin) {
+ WINDOW_REC *rec;
+
iter = g_sequence_iter_prev(iter);
- WINDOW_REC *rec = g_sequence_get(iter);
+ rec = g_sequence_get(iter);
sorted = g_slist_prepend(sorted, rec);
}
diff --git a/src/perl/common/Expando.xs b/src/perl/common/Expando.xs
index 26800b05..84853a02 100644
--- a/src/perl/common/Expando.xs
+++ b/src/perl/common/Expando.xs
@@ -74,6 +74,7 @@ static char *perl_expando_event(PerlExpando *rec, SERVER_REC *server,
ret = NULL;
if (SvTRUE(ERRSV)) {
+ char *error;
PERL_SCRIPT_REC *script = rec->script;
(void) POPs;
@@ -85,7 +86,7 @@ static char *perl_expando_event(PerlExpando *rec, SERVER_REC *server,
script_unregister_expandos(script);
/* rec has been freed now */
- char *error = g_strdup(SvPV_nolen(ERRSV));
+ error = g_strdup(SvPV_nolen(ERRSV));
signal_emit("script error", 2, script, error);
g_free(error);
} else if (retcount > 0) {
diff --git a/src/perl/textui/Statusbar.xs b/src/perl/textui/Statusbar.xs
index 8b0e5f65..111deaa7 100644
--- a/src/perl/textui/Statusbar.xs
+++ b/src/perl/textui/Statusbar.xs
@@ -67,7 +67,7 @@ static void perl_statusbar_event(char *function, SBAR_ITEM_REC *item,
if (SvTRUE(ERRSV)) {
PERL_SCRIPT_REC *script;
- char *package;
+ char *package, *error;
package = perl_function_get_package(function);
script = perl_script_find_package(package);
@@ -78,7 +78,7 @@ static void perl_statusbar_event(char *function, SBAR_ITEM_REC *item,
script_unregister_statusbars(script);
}
- char *error = g_strdup(SvPV_nolen(ERRSV));
+ error = g_strdup(SvPV_nolen(ERRSV));
signal_emit("script error", 2, script, error);
g_free(error);
} else {
From b0637ad6ea8784d3b2be829ca40f9dddf0c049fc Mon Sep 17 00:00:00 2001
From: Will Storey
Date: Sat, 2 Dec 2017 10:09:52 -0800
Subject: [PATCH 0128/1087] Update NULL comparison style and be C89 compatible
---
src/irc/core/irc.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c
index 790c7122..a740b0da 100644
--- a/src/irc/core/irc.c
+++ b/src/irc/core/irc.c
@@ -287,11 +287,13 @@ char *event_get_params(const char *data, int count, ...)
/* Given a string containing , strip any colon prefixing . */
static void strip_params_colon(char *const params)
{
- if (!params) {
+ char *s;
+
+ if (params == NULL) {
return;
}
- char *s = params;
+ s = params;
while (*s != '\0') {
if (*s == ':') {
memmove(s, s+1, strlen(s+1)+1);
@@ -299,7 +301,7 @@ static void strip_params_colon(char *const params)
}
s = strchr(s, ' ');
- if (!s) {
+ if (s == NULL) {
return;
}
From 1328e1ba08430b0eaa589919272d732bb84a6921 Mon Sep 17 00:00:00 2001
From: Will Storey
Date: Sat, 21 Oct 2017 20:01:04 -0700
Subject: [PATCH 0129/1087] Add a test program to test mode parsing
This uses GLib's testing framework. It is to test the changes to the
mode parsing for #603.
---
.gitignore | 3 +
.travis.yml | 4 +-
Makefile.am | 2 +-
configure.ac | 3 +
tests/Makefile.am | 1 +
tests/irc/Makefile.am | 1 +
tests/irc/core/Makefile.am | 36 ++++++
tests/irc/core/test-irc.c | 230 +++++++++++++++++++++++++++++++++++++
8 files changed, 278 insertions(+), 2 deletions(-)
create mode 100644 tests/Makefile.am
create mode 100644 tests/irc/Makefile.am
create mode 100644 tests/irc/core/Makefile.am
create mode 100644 tests/irc/core/test-irc.c
diff --git a/.gitignore b/.gitignore
index efc579cb..cf1cf72e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -49,6 +49,9 @@ src/perl/*/Makefile.old
src/fe-fuzz/crash-*
src/fe-fuzz/oom-*
+tests/irc/core/test-irc
+tests/irc/core/test-irc.trs
+
*.a
*.bs
*.la
diff --git a/.travis.yml b/.travis.yml
index 1d8786c4..1e04d943 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -49,5 +49,7 @@ before_script:
- echo ^quit >> irssi-test/startup
- irssi-build/bin/irssi --home irssi-test
- cat irc.log.*
+ - cd $TRAVIS_BUILD_DIR
-script: true
+script:
+ - make check
diff --git a/Makefile.am b/Makefile.am
index f52ac92f..ba45d8ac 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,7 +16,7 @@ irssi-version.h:
VERSION="$(VERSION)" $(srcdir)/utils/irssi-version.sh $(srcdir) | \
cmp -s - $@ || VERSION="$(VERSION)" $(srcdir)/utils/irssi-version.sh $(srcdir) >$@
-SUBDIRS = src docs scripts themes utils
+SUBDIRS = src tests docs scripts themes utils
confdir = $(sysconfdir)
conf_DATA = irssi.conf
diff --git a/configure.ac b/configure.ac
index 4b65d434..bf15e6ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -658,6 +658,9 @@ src/perl/ui/Makefile.PL
src/perl/textui/Makefile.PL
scripts/Makefile
scripts/examples/Makefile
+tests/Makefile
+tests/irc/Makefile
+tests/irc/core/Makefile
docs/Makefile
docs/help/Makefile
docs/help/in/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 00000000..58c348df
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = irc
diff --git a/tests/irc/Makefile.am b/tests/irc/Makefile.am
new file mode 100644
index 00000000..52770885
--- /dev/null
+++ b/tests/irc/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = core
diff --git a/tests/irc/core/Makefile.am b/tests/irc/core/Makefile.am
new file mode 100644
index 00000000..fff2a246
--- /dev/null
+++ b/tests/irc/core/Makefile.am
@@ -0,0 +1,36 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/core \
+ -DSYSCONFDIR=\""$(sysconfdir)"\" \
+ $(GLIB_CFLAGS)
+
+TESTS = test-irc
+check_PROGRAMS = test-irc
+
+test_irc_CPPFLAGS = \
+ -I$(top_srcdir)/src/irc/core \
+ $(AM_CPPFLAGS)
+
+test_irc_DEPENDENCIES = \
+ ../../../src/core/libcore.a \
+ ../../../src/lib-config/libirssi_config.a
+
+test_irc_LDADD = \
+ ../../../src/core/libcore.a \
+ ../../../src/lib-config/libirssi_config.a \
+ @GLIB_LIBS@ \
+ @OPENSSL_LIBS@
+
+test_irc_SOURCES = \
+ test-irc.c \
+ ../../../src/irc/core/irc-cap.c \
+ ../../../src/irc/core/irc-nicklist.c \
+ ../../../src/irc/core/irc-queries.c \
+ ../../../src/irc/core/irc-servers-reconnect.c \
+ ../../../src/irc/core/irc-servers-setup.c \
+ ../../../src/irc/core/irc-servers.c \
+ ../../../src/irc/core/irc.c \
+ ../../../src/irc/core/mode-lists.c \
+ ../../../src/irc/core/modes.c \
+ ../../../src/irc/core/servers-idle.c \
+ ../../../src/irc/core/servers-redirect.c
diff --git a/tests/irc/core/test-irc.c b/tests/irc/core/test-irc.c
new file mode 100644
index 00000000..7e85c9ba
--- /dev/null
+++ b/tests/irc/core/test-irc.c
@@ -0,0 +1,230 @@
+/*
+ test-irc.c : irssi
+
+ Copyright (C) 2017 Will Storey
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include
+#include
+#include
+
+static void test_event_get_param(void);
+static void test_event_get_params(void);
+
+int main(int argc, char **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/test/event_get_param", test_event_get_param);
+ g_test_add_func("/test/event_get_params", test_event_get_params);
+
+ return g_test_run();
+}
+
+static void test_event_get_param(void)
+{
+ struct test_case {
+ char const *const description;
+ char const *const input;
+ char const *const input_after;
+ char const *const output;
+ };
+
+ struct test_case const tests[] = {
+ {
+ .description = "Zero parameters",
+ .input = "",
+ .input_after = "",
+ .output = "",
+ },
+ {
+ .description = "One parameter",
+ .input = "#test",
+ .input_after = "",
+ .output = "#test",
+ },
+ {
+ .description = "One parameter, trailing space",
+ .input = "#test ",
+ .input_after = "",
+ .output = "#test",
+ },
+ {
+ .description = "One parameter, more trailing space",
+ .input = "#test ",
+ .input_after = " ",
+ .output = "#test",
+ },
+ {
+ .description = "Two parameters",
+ .input = "#test +o",
+ .input_after = "+o",
+ .output = "#test",
+ },
+ {
+ .description = "Two parameters continued",
+ .input = "+o",
+ .input_after = "",
+ .output = "+o",
+ },
+ {
+ .description = "Two parameters with trailing space",
+ .input = "#test +o ",
+ .input_after = "+o ",
+ .output = "#test",
+ },
+ {
+ .description = "Two parameters with trailing space continued",
+ .input = "+o ",
+ .input_after = "",
+ .output = "+o",
+ },
+ {
+ .description = "Two parameters with inline and trailing space",
+ .input = "#test +o ",
+ .input_after = " +o ",
+ .output = "#test",
+ },
+ /* TODO: It seems not ideal that the caller has to deal with inline space.
+ */
+ {
+ .description = "Two parameters with inline and trailing space continued",
+ .input = " +o ",
+ .input_after = "+o ",
+ .output = "",
+ },
+ };
+
+ char *buf = g_malloc0(1024);
+
+ int i = 0;
+ for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
+ struct test_case const test = tests[i];
+
+ memcpy(buf, test.input, strlen(test.input)+1);
+ char *input = buf;
+
+ char *const output = event_get_param(&input);
+
+ g_assert_cmpstr(input, ==, test.input_after);
+ g_assert_cmpstr(output, ==, test.output);
+ }
+
+ g_free(buf);
+}
+
+static void test_event_get_params(void)
+{
+ struct test_case {
+ char const *const description;
+ char const *const input;
+ char const *const output0;
+ char const *const output1;
+ };
+
+ struct test_case const tests[] = {
+ {
+ .description = "Only a channel",
+ .input = "#test",
+ .output0 = "#test",
+ .output1 = "",
+ },
+ {
+ .description = "Only a channel with trailing space",
+ .input = "#test ",
+ .output0 = "#test",
+ .output1 = "",
+ },
+ {
+ .description = "No :, channel mode with one parameter after channel name",
+ .input = "#test +i",
+ .output0 = "#test",
+ .output1 = "+i",
+ },
+ {
+ .description = "No :, channel mode with two parameters after channel name",
+ .input = "#test +o tester",
+ .output0 = "#test",
+ .output1 = "+o tester",
+ },
+ {
+ .description = "No :, channel mode with three parameters afer channel name",
+ .input = "#test +ov tester tester2",
+ .output0 = "#test",
+ .output1 = "+ov tester tester2",
+ },
+ {
+ .description = "No :, channel mode with three parameters afer channel name, bunch of extra space",
+ .input = "#test +ov tester tester2 ",
+ .output0 = "#test",
+ .output1 = " +ov tester tester2 ",
+ },
+ {
+ .description = "Channel mode with one parameter after channel name, : at the start of modes",
+ .input = "#test :+i",
+ .output0 = "#test",
+ .output1 = "+i",
+ },
+ {
+ .description = "Channel mode with two parameters after channel name, : at the start of modes",
+ .input = "#test :+o tester",
+ .output0 = "#test",
+ .output1 = "+o tester",
+ },
+ {
+ .description = "Channel mode with three parameters after channel name, : at the start of modes",
+ .input = "#test :+ov tester tester2",
+ .output0 = "#test",
+ .output1 = "+ov tester tester2",
+ },
+ {
+ .description = "Channel mode with two parameters after channel name, : on the final parameter",
+ .input = "#test +o :tester",
+ .output0 = "#test",
+ .output1 = "+o tester",
+ },
+ {
+ .description = "Channel mode with three parameters after channel name, : on the final parameter",
+ .input = "#test +ov tester :tester2",
+ .output0 = "#test",
+ .output1 = "+ov tester tester2",
+ },
+ {
+ .description = "Channel mode with three parameters after channel name, : on the final parameter, also a second : present",
+ .input = "#test +ov tester :tester2 hi:there",
+ .output0 = "#test",
+ .output1 = "+ov tester tester2 hi:there",
+ },
+ };
+
+ int i = 0;
+ for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
+ struct test_case const test = tests[i];
+
+ char *output0 = NULL;
+ char *output1 = NULL;
+ char *const params = event_get_params(test.input, 2 | PARAM_FLAG_GETREST,
+ &output0, &output1);
+
+ /* params happens to always point at the first output */
+ g_assert_cmpstr(params, ==, test.output0);
+ g_assert_cmpstr(output0, ==, test.output0);
+ g_assert_cmpstr(output1, ==, test.output1);
+
+ g_free(params);
+ }
+}
From c20eddeb385974d6f46494e71ab63d4493df119b Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Sun, 26 Nov 2017 16:19:31 +0100
Subject: [PATCH 0130/1087] add glib testing TAP utilities
---
configure.ac | 2 +
m4/glibtests.m4 | 28 ++
tests/irc/core/Makefile.am | 5 +-
tests/irc/core/test-irc.c | 1 +
utils/Makefile.am | 4 +-
utils/glib-tap.mk | 134 ++++++++
utils/tap-driver.sh | 652 +++++++++++++++++++++++++++++++++++++
utils/tap-test | 5 +
8 files changed, 828 insertions(+), 3 deletions(-)
create mode 100644 m4/glibtests.m4
create mode 100644 utils/glib-tap.mk
create mode 100755 utils/tap-driver.sh
create mode 100755 utils/tap-test
diff --git a/configure.ac b/configure.ac
index bf15e6ae..c780b9b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -295,6 +295,8 @@ fi
LIBS="$LIBS $GLIB_LIBS"
+GLIB_TESTS
+
dnl **
dnl ** OpenSSL checks
dnl **
diff --git a/m4/glibtests.m4 b/m4/glibtests.m4
new file mode 100644
index 00000000..7d5920a4
--- /dev/null
+++ b/m4/glibtests.m4
@@ -0,0 +1,28 @@
+dnl GLIB_TESTS
+dnl
+
+AC_DEFUN([GLIB_TESTS],
+[
+ AC_ARG_ENABLE(installed-tests,
+ AS_HELP_STRING([--enable-installed-tests],
+ [Enable installation of some test cases]),
+ [case ${enableval} in
+ yes) ENABLE_INSTALLED_TESTS="1" ;;
+ no) ENABLE_INSTALLED_TESTS="" ;;
+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-installed-tests]) ;;
+ esac])
+ AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], test "$ENABLE_INSTALLED_TESTS" = "1")
+ AC_ARG_ENABLE(always-build-tests,
+ AS_HELP_STRING([--enable-always-build-tests],
+ [Enable always building tests during 'make all']),
+ [case ${enableval} in
+ yes) ENABLE_ALWAYS_BUILD_TESTS="1" ;;
+ no) ENABLE_ALWAYS_BUILD_TESTS="" ;;
+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-always-build-tests]) ;;
+ esac])
+ AM_CONDITIONAL([ENABLE_ALWAYS_BUILD_TESTS], test "$ENABLE_ALWAYS_BUILD_TESTS" = "1")
+ if test "$ENABLE_INSTALLED_TESTS" = "1"; then
+ AC_SUBST(installed_test_metadir, [${datadir}/installed-tests/]AC_PACKAGE_NAME)
+ AC_SUBST(installed_testdir, [${libexecdir}/installed-tests/]AC_PACKAGE_NAME)
+ fi
+])
diff --git a/tests/irc/core/Makefile.am b/tests/irc/core/Makefile.am
index fff2a246..b5345067 100644
--- a/tests/irc/core/Makefile.am
+++ b/tests/irc/core/Makefile.am
@@ -1,11 +1,12 @@
+include $(top_srcdir)/utils/glib-tap.mk
+
AM_CPPFLAGS = \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/core \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
$(GLIB_CFLAGS)
-TESTS = test-irc
-check_PROGRAMS = test-irc
+test_programs = test-irc
test_irc_CPPFLAGS = \
-I$(top_srcdir)/src/irc/core \
diff --git a/tests/irc/core/test-irc.c b/tests/irc/core/test-irc.c
index 7e85c9ba..4c62e6a7 100644
--- a/tests/irc/core/test-irc.c
+++ b/tests/irc/core/test-irc.c
@@ -32,6 +32,7 @@ int main(int argc, char **argv)
g_test_add_func("/test/event_get_param", test_event_get_param);
g_test_add_func("/test/event_get_params", test_event_get_params);
+ g_test_set_nonfatal_assertions();
return g_test_run();
}
diff --git a/utils/Makefile.am b/utils/Makefile.am
index be24c17f..8af5c8f7 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -1,4 +1,6 @@
EXTRA_DIST = \
file2header.sh \
irssi-version.sh \
- syntax.pl
+ syntax.pl \
+ tap-driver.sh \
+ tap-test
diff --git a/utils/glib-tap.mk b/utils/glib-tap.mk
new file mode 100644
index 00000000..582f6d29
--- /dev/null
+++ b/utils/glib-tap.mk
@@ -0,0 +1,134 @@
+# GLIB - Library of useful C routines
+
+TESTS_ENVIRONMENT= \
+ G_TEST_SRCDIR="$(abs_srcdir)" \
+ G_TEST_BUILDDIR="$(abs_builddir)" \
+ G_DEBUG=gc-friendly \
+ MALLOC_CHECK_=2 \
+ MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
+LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/utils/tap-driver.sh
+LOG_COMPILER = $(top_srcdir)/utils/tap-test
+
+NULL =
+
+# initialize variables for unconditional += appending
+BUILT_SOURCES =
+BUILT_EXTRA_DIST =
+CLEANFILES = *.log *.trs
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+EXTRA_DIST =
+TESTS =
+
+installed_test_LTLIBRARIES =
+installed_test_PROGRAMS =
+installed_test_SCRIPTS =
+nobase_installed_test_DATA =
+
+noinst_LTLIBRARIES =
+noinst_PROGRAMS =
+noinst_SCRIPTS =
+noinst_DATA =
+
+check_LTLIBRARIES =
+check_PROGRAMS =
+check_SCRIPTS =
+check_DATA =
+
+# We support a fairly large range of possible variables. It is expected that all types of files in a test suite
+# will belong in exactly one of the following variables.
+#
+# First, we support the usual automake suffixes, but in lowercase, with the customary meaning:
+#
+# test_programs, test_scripts, test_data, test_ltlibraries
+#
+# The above are used to list files that are involved in both uninstalled and installed testing. The
+# test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite.
+# Note that _data is always used with the nobase_ automake variable name to ensure that installed test data is
+# installed in the same way as it appears in the package layout.
+#
+# In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled',
+# like so:
+#
+# installed_test_programs, uninstalled_test_programs
+# installed_test_scripts, uninstalled_test_scripts
+# installed_test_data, uninstalled_test_data
+# installed_test_ltlibraries, uninstalled_test_ltlibraries
+#
+# Additionally, we support 'extra' infixes for programs and scripts. This is used for support programs/scripts
+# that should not themselves be run as testcases (but exist to be used from other testcases):
+#
+# test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs
+# test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts
+#
+# Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or data
+# file automatically end up in the tarball.
+#
+# dist_test_scripts, dist_test_data, dist_test_extra_scripts
+# dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts
+# dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts
+#
+# Note that no file is automatically disted unless it appears in one of the dist_ variables. This follows the
+# standard automake convention of not disting programs scripts or data by default.
+#
+# test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their disted
+# variants) will be run as part of the in-tree 'make check'. These are all assumed to be runnable under
+# gtester. That's a bit strange for scripts, but it's possible.
+
+TESTS += $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
+ $(dist_test_scripts) $(dist_uninstalled_test_scripts)
+
+# Note: build even the installed-only targets during 'make check' to ensure that they still work.
+# We need to do a bit of trickery here and manage disting via EXTRA_DIST instead of using dist_ prefixes to
+# prevent automake from mistreating gmake functions like $(wildcard ...) and $(addprefix ...) as if they were
+# filenames, including removing duplicate instances of the opening part before the space, eg. '$(addprefix'.
+all_test_programs = $(test_programs) $(uninstalled_test_programs) $(installed_test_programs) \
+ $(test_extra_programs) $(uninstalled_test_extra_programs) $(installed_test_extra_programs)
+all_test_scripts = $(test_scripts) $(uninstalled_test_scripts) $(installed_test_scripts) \
+ $(test_extra_scripts) $(uninstalled_test_extra_scripts) $(installed_test_extra_scripts)
+all_dist_test_scripts = $(dist_test_scripts) $(dist_uninstalled_test_scripts) $(dist_installed_test_scripts) \
+ $(dist_test_extra_scripts) $(dist_uninstalled_test_extra_scripts) $(dist_installed_test_extra_scripts)
+all_test_scripts += $(all_dist_test_scripts)
+EXTRA_DIST += $(all_dist_test_scripts)
+all_test_data = $(test_data) $(uninstalled_test_data) $(installed_test_data)
+all_dist_test_data = $(dist_test_data) $(dist_uninstalled_test_data) $(dist_installed_test_data)
+all_test_data += $(all_dist_test_data)
+EXTRA_DIST += $(all_dist_test_data)
+all_test_ltlibs = $(test_ltlibraries) $(uninstalled_test_ltlibraries) $(installed_test_ltlibraries)
+
+if ENABLE_ALWAYS_BUILD_TESTS
+noinst_LTLIBRARIES += $(all_test_ltlibs)
+noinst_PROGRAMS += $(all_test_programs)
+noinst_SCRIPTS += $(all_test_scripts)
+noinst_DATA += $(all_test_data)
+else
+check_LTLIBRARIES += $(all_test_ltlibs)
+check_PROGRAMS += $(all_test_programs)
+check_SCRIPTS += $(all_test_scripts)
+check_DATA += $(all_test_data)
+endif
+
+if ENABLE_INSTALLED_TESTS
+installed_test_PROGRAMS += $(test_programs) $(installed_test_programs) \
+ $(test_extra_programs) $(installed_test_extra_programs)
+installed_test_SCRIPTS += $(test_scripts) $(installed_test_scripts) \
+ $(test_extra_scripts) $(test_installed_extra_scripts)
+installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) \
+ $(dist_installed_test_scripts) $(dist_installed_test_extra_scripts)
+nobase_installed_test_DATA += $(test_data) $(installed_test_data)
+nobase_installed_test_DATA += $(dist_test_data) $(dist_installed_test_data)
+installed_test_LTLIBRARIES += $(test_ltlibraries) $(installed_test_ltlibraries)
+installed_testcases = $(test_programs) $(installed_test_programs) \
+ $(test_scripts) $(installed_test_scripts) \
+ $(dist_test_scripts) $(dist_installed_test_scripts)
+
+installed_test_meta_DATA = $(installed_testcases:=.test)
+
+%.test: %$(EXEEXT) Makefile
+ $(AM_V_GEN) (echo '[Test]' > $@.tmp; \
+ echo 'Type=session' >> $@.tmp; \
+ echo 'Exec=$(installed_testdir)/$<' >> $@.tmp; \
+ mv $@.tmp $@)
+
+CLEANFILES += $(installed_test_meta_DATA)
+endif
diff --git a/utils/tap-driver.sh b/utils/tap-driver.sh
new file mode 100755
index 00000000..19aa531d
--- /dev/null
+++ b/utils/tap-driver.sh
@@ -0,0 +1,652 @@
+#! /bin/sh
+# Copyright (C) 2011-2013 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to or send patches to
+# .
+
+scriptversion=2011-12-27.17; # UTC
+
+# Make unconditional expansion of undefined variables an error. This
+# helps a lot in preventing typo-related bugs.
+set -u
+
+me=tap-driver.sh
+
+fatal ()
+{
+ echo "$me: fatal: $*" >&2
+ exit 1
+}
+
+usage_error ()
+{
+ echo "$me: $*" >&2
+ print_usage >&2
+ exit 2
+}
+
+print_usage ()
+{
+ cat <
+ #
+ trap : 1 3 2 13 15
+ if test $merge -gt 0; then
+ exec 2>&1
+ else
+ exec 2>&3
+ fi
+ "$@"
+ echo $?
+ ) | LC_ALL=C ${AM_TAP_AWK-awk} \
+ -v me="$me" \
+ -v test_script_name="$test_name" \
+ -v log_file="$log_file" \
+ -v trs_file="$trs_file" \
+ -v expect_failure="$expect_failure" \
+ -v merge="$merge" \
+ -v ignore_exit="$ignore_exit" \
+ -v comments="$comments" \
+ -v diag_string="$diag_string" \
+'
+# FIXME: the usages of "cat >&3" below could be optimized when using
+# FIXME: GNU awk, and/on on systems that supports /dev/fd/.
+
+# Implementation note: in what follows, `result_obj` will be an
+# associative array that (partly) simulates a TAP result object
+# from the `TAP::Parser` perl module.
+
+## ----------- ##
+## FUNCTIONS ##
+## ----------- ##
+
+function fatal(msg)
+{
+ print me ": " msg | "cat >&2"
+ exit 1
+}
+
+function abort(where)
+{
+ fatal("internal error " where)
+}
+
+# Convert a boolean to a "yes"/"no" string.
+function yn(bool)
+{
+ return bool ? "yes" : "no";
+}
+
+function add_test_result(result)
+{
+ if (!test_results_index)
+ test_results_index = 0
+ test_results_list[test_results_index] = result
+ test_results_index += 1
+ test_results_seen[result] = 1;
+}
+
+# Whether the test script should be re-run by "make recheck".
+function must_recheck()
+{
+ for (k in test_results_seen)
+ if (k != "XFAIL" && k != "PASS" && k != "SKIP")
+ return 1
+ return 0
+}
+
+# Whether the content of the log file associated to this test should
+# be copied into the "global" test-suite.log.
+function copy_in_global_log()
+{
+ for (k in test_results_seen)
+ if (k != "PASS")
+ return 1
+ return 0
+}
+
+# FIXME: this can certainly be improved ...
+function get_global_test_result()
+{
+ if ("ERROR" in test_results_seen)
+ return "ERROR"
+ if ("FAIL" in test_results_seen || "XPASS" in test_results_seen)
+ return "FAIL"
+ all_skipped = 1
+ for (k in test_results_seen)
+ if (k != "SKIP")
+ all_skipped = 0
+ if (all_skipped)
+ return "SKIP"
+ return "PASS";
+}
+
+function stringify_result_obj(result_obj)
+{
+ if (result_obj["is_unplanned"] || result_obj["number"] != testno)
+ return "ERROR"
+
+ if (plan_seen == LATE_PLAN)
+ return "ERROR"
+
+ if (result_obj["directive"] == "TODO")
+ return result_obj["is_ok"] ? "XPASS" : "XFAIL"
+
+ if (result_obj["directive"] == "SKIP")
+ return result_obj["is_ok"] ? "SKIP" : COOKED_FAIL;
+
+ if (length(result_obj["directive"]))
+ abort("in function stringify_result_obj()")
+
+ return result_obj["is_ok"] ? COOKED_PASS : COOKED_FAIL
+}
+
+function decorate_result(result)
+{
+ color_name = color_for_result[result]
+ if (color_name)
+ return color_map[color_name] "" result "" color_map["std"]
+ # If we are not using colorized output, or if we do not know how
+ # to colorize the given result, we should return it unchanged.
+ return result
+}
+
+function report(result, details)
+{
+ if (result ~ /^(X?(PASS|FAIL)|SKIP|ERROR)/)
+ {
+ msg = ": " test_script_name
+ add_test_result(result)
+ }
+ else if (result == "#")
+ {
+ msg = " " test_script_name ":"
+ }
+ else
+ {
+ abort("in function report()")
+ }
+ if (length(details))
+ msg = msg " " details
+ # Output on console might be colorized.
+ print decorate_result(result) msg
+ # Log the result in the log file too, to help debugging (this is
+ # especially true when said result is a TAP error or "Bail out!").
+ print result msg | "cat >&3";
+}
+
+function testsuite_error(error_message)
+{
+ report("ERROR", "- " error_message)
+}
+
+function handle_tap_result()
+{
+ details = result_obj["number"];
+ if (length(result_obj["description"]))
+ details = details " " result_obj["description"]
+
+ if (plan_seen == LATE_PLAN)
+ {
+ details = details " # AFTER LATE PLAN";
+ }
+ else if (result_obj["is_unplanned"])
+ {
+ details = details " # UNPLANNED";
+ }
+ else if (result_obj["number"] != testno)
+ {
+ details = sprintf("%s # OUT-OF-ORDER (expecting %d)",
+ details, testno);
+ }
+ else if (result_obj["directive"])
+ {
+ details = details " # " result_obj["directive"];
+ if (length(result_obj["explanation"]))
+ details = details " " result_obj["explanation"]
+ }
+
+ report(stringify_result_obj(result_obj), details)
+}
+
+# `skip_reason` should be empty whenever planned > 0.
+function handle_tap_plan(planned, skip_reason)
+{
+ planned += 0 # Avoid getting confused if, say, `planned` is "00"
+ if (length(skip_reason) && planned > 0)
+ abort("in function handle_tap_plan()")
+ if (plan_seen)
+ {
+ # Error, only one plan per stream is acceptable.
+ testsuite_error("multiple test plans")
+ return;
+ }
+ planned_tests = planned
+ # The TAP plan can come before or after *all* the TAP results; we speak
+ # respectively of an "early" or a "late" plan. If we see the plan line
+ # after at least one TAP result has been seen, assume we have a late
+ # plan; in this case, any further test result seen after the plan will
+ # be flagged as an error.
+ plan_seen = (testno >= 1 ? LATE_PLAN : EARLY_PLAN)
+ # If testno > 0, we have an error ("too many tests run") that will be
+ # automatically dealt with later, so do not worry about it here. If
+ # $plan_seen is true, we have an error due to a repeated plan, and that
+ # has already been dealt with above. Otherwise, we have a valid "plan
+ # with SKIP" specification, and should report it as a particular kind
+ # of SKIP result.
+ if (planned == 0 && testno == 0)
+ {
+ if (length(skip_reason))
+ skip_reason = "- " skip_reason;
+ report("SKIP", skip_reason);
+ }
+}
+
+function extract_tap_comment(line)
+{
+ if (index(line, diag_string) == 1)
+ {
+ # Strip leading `diag_string` from `line`.
+ line = substr(line, length(diag_string) + 1)
+ # And strip any leading and trailing whitespace left.
+ sub("^[ \t]*", "", line)
+ sub("[ \t]*$", "", line)
+ # Return what is left (if any).
+ return line;
+ }
+ return "";
+}
+
+# When this function is called, we know that line is a TAP result line,
+# so that it matches the (perl) RE "^(not )?ok\b".
+function setup_result_obj(line)
+{
+ # Get the result, and remove it from the line.
+ result_obj["is_ok"] = (substr(line, 1, 2) == "ok" ? 1 : 0)
+ sub("^(not )?ok[ \t]*", "", line)
+
+ # If the result has an explicit number, get it and strip it; otherwise,
+ # automatically assing the next progresive number to it.
+ if (line ~ /^[0-9]+$/ || line ~ /^[0-9]+[^a-zA-Z0-9_]/)
+ {
+ match(line, "^[0-9]+")
+ # The final `+ 0` is to normalize numbers with leading zeros.
+ result_obj["number"] = substr(line, 1, RLENGTH) + 0
+ line = substr(line, RLENGTH + 1)
+ }
+ else
+ {
+ result_obj["number"] = testno
+ }
+
+ if (plan_seen == LATE_PLAN)
+ # No further test results are acceptable after a "late" TAP plan
+ # has been seen.
+ result_obj["is_unplanned"] = 1
+ else if (plan_seen && testno > planned_tests)
+ result_obj["is_unplanned"] = 1
+ else
+ result_obj["is_unplanned"] = 0
+
+ # Strip trailing and leading whitespace.
+ sub("^[ \t]*", "", line)
+ sub("[ \t]*$", "", line)
+
+ # This will have to be corrected if we have a "TODO"/"SKIP" directive.
+ result_obj["description"] = line
+ result_obj["directive"] = ""
+ result_obj["explanation"] = ""
+
+ if (index(line, "#") == 0)
+ return # No possible directive, nothing more to do.
+
+ # Directives are case-insensitive.
+ rx = "[ \t]*#[ \t]*([tT][oO][dD][oO]|[sS][kK][iI][pP])[ \t]*"
+
+ # See whether we have the directive, and if yes, where.
+ pos = match(line, rx "$")
+ if (!pos)
+ pos = match(line, rx "[^a-zA-Z0-9_]")
+
+ # If there was no TAP directive, we have nothing more to do.
+ if (!pos)
+ return
+
+ # Let`s now see if the TAP directive has been escaped. For example:
+ # escaped: ok \# SKIP
+ # not escaped: ok \\# SKIP
+ # escaped: ok \\\\\# SKIP
+ # not escaped: ok \ # SKIP
+ if (substr(line, pos, 1) == "#")
+ {
+ bslash_count = 0
+ for (i = pos; i > 1 && substr(line, i - 1, 1) == "\\"; i--)
+ bslash_count += 1
+ if (bslash_count % 2)
+ return # Directive was escaped.
+ }
+
+ # Strip the directive and its explanation (if any) from the test
+ # description.
+ result_obj["description"] = substr(line, 1, pos - 1)
+ # Now remove the test description from the line, that has been dealt
+ # with already.
+ line = substr(line, pos)
+ # Strip the directive, and save its value (normalized to upper case).
+ sub("^[ \t]*#[ \t]*", "", line)
+ result_obj["directive"] = toupper(substr(line, 1, 4))
+ line = substr(line, 5)
+ # Now get the explanation for the directive (if any), with leading
+ # and trailing whitespace removed.
+ sub("^[ \t]*", "", line)
+ sub("[ \t]*$", "", line)
+ result_obj["explanation"] = line
+}
+
+function get_test_exit_message(status)
+{
+ if (status == 0)
+ return ""
+ if (status !~ /^[1-9][0-9]*$/)
+ abort("getting exit status")
+ if (status < 127)
+ exit_details = ""
+ else if (status == 127)
+ exit_details = " (command not found?)"
+ else if (status >= 128 && status <= 255)
+ exit_details = sprintf(" (terminated by signal %d?)", status - 128)
+ else if (status > 256 && status <= 384)
+ # We used to report an "abnormal termination" here, but some Korn
+ # shells, when a child process die due to signal number n, can leave
+ # in $? an exit status of 256+n instead of the more standard 128+n.
+ # Apparently, both behaviours are allowed by POSIX (2008), so be
+ # prepared to handle them both. See also Austing Group report ID
+ # 0000051
+ exit_details = sprintf(" (terminated by signal %d?)", status - 256)
+ else
+ # Never seen in practice.
+ exit_details = " (abnormal termination)"
+ return sprintf("exited with status %d%s", status, exit_details)
+}
+
+function write_test_results()
+{
+ print ":global-test-result: " get_global_test_result() > trs_file
+ print ":recheck: " yn(must_recheck()) > trs_file
+ print ":copy-in-global-log: " yn(copy_in_global_log()) > trs_file
+ for (i = 0; i < test_results_index; i += 1)
+ print ":test-result: " test_results_list[i] > trs_file
+ close(trs_file);
+}
+
+BEGIN {
+
+## ------- ##
+## SETUP ##
+## ------- ##
+
+'"$init_colors"'
+
+# Properly initialized once the TAP plan is seen.
+planned_tests = 0
+
+COOKED_PASS = expect_failure ? "XPASS": "PASS";
+COOKED_FAIL = expect_failure ? "XFAIL": "FAIL";
+
+# Enumeration-like constants to remember which kind of plan (if any)
+# has been seen. It is important that NO_PLAN evaluates "false" as
+# a boolean.
+NO_PLAN = 0
+EARLY_PLAN = 1
+LATE_PLAN = 2
+
+testno = 0 # Number of test results seen so far.
+bailed_out = 0 # Whether a "Bail out!" directive has been seen.
+
+# Whether the TAP plan has been seen or not, and if yes, which kind
+# it is ("early" is seen before any test result, "late" otherwise).
+plan_seen = NO_PLAN
+
+## --------- ##
+## PARSING ##
+## --------- ##
+
+is_first_read = 1
+
+while (1)
+ {
+ # Involutions required so that we are able to read the exit status
+ # from the last input line.
+ st = getline
+ if (st < 0) # I/O error.
+ fatal("I/O error while reading from input stream")
+ else if (st == 0) # End-of-input
+ {
+ if (is_first_read)
+ abort("in input loop: only one input line")
+ break
+ }
+ if (is_first_read)
+ {
+ is_first_read = 0
+ nextline = $0
+ continue
+ }
+ else
+ {
+ curline = nextline
+ nextline = $0
+ $0 = curline
+ }
+ # Copy any input line verbatim into the log file.
+ print | "cat >&3"
+ # Parsing of TAP input should stop after a "Bail out!" directive.
+ if (bailed_out)
+ continue
+
+ # TAP test result.
+ if ($0 ~ /^(not )?ok$/ || $0 ~ /^(not )?ok[^a-zA-Z0-9_]/)
+ {
+ testno += 1
+ setup_result_obj($0)
+ handle_tap_result()
+ }
+ # TAP plan (normal or "SKIP" without explanation).
+ else if ($0 ~ /^1\.\.[0-9]+[ \t]*$/)
+ {
+ # The next two lines will put the number of planned tests in $0.
+ sub("^1\\.\\.", "")
+ sub("[^0-9]*$", "")
+ handle_tap_plan($0, "")
+ continue
+ }
+ # TAP "SKIP" plan, with an explanation.
+ else if ($0 ~ /^1\.\.0+[ \t]*#/)
+ {
+ # The next lines will put the skip explanation in $0, stripping
+ # any leading and trailing whitespace. This is a little more
+ # tricky in truth, since we want to also strip a potential leading
+ # "SKIP" string from the message.
+ sub("^[^#]*#[ \t]*(SKIP[: \t][ \t]*)?", "")
+ sub("[ \t]*$", "");
+ handle_tap_plan(0, $0)
+ }
+ # "Bail out!" magic.
+ # Older versions of prove and TAP::Harness (e.g., 3.17) did not
+ # recognize a "Bail out!" directive when preceded by leading
+ # whitespace, but more modern versions (e.g., 3.23) do. So we
+ # emulate the latter, "more modern" behaviour.
+ else if ($0 ~ /^[ \t]*Bail out!/)
+ {
+ bailed_out = 1
+ # Get the bailout message (if any), with leading and trailing
+ # whitespace stripped. The message remains stored in `$0`.
+ sub("^[ \t]*Bail out![ \t]*", "");
+ sub("[ \t]*$", "");
+ # Format the error message for the
+ bailout_message = "Bail out!"
+ if (length($0))
+ bailout_message = bailout_message " " $0
+ testsuite_error(bailout_message)
+ }
+ # Maybe we have too look for dianogtic comments too.
+ else if (comments != 0)
+ {
+ comment = extract_tap_comment($0);
+ if (length(comment))
+ report("#", comment);
+ }
+ }
+
+## -------- ##
+## FINISH ##
+## -------- ##
+
+# A "Bail out!" directive should cause us to ignore any following TAP
+# error, as well as a non-zero exit status from the TAP producer.
+if (!bailed_out)
+ {
+ if (!plan_seen)
+ {
+ testsuite_error("missing test plan")
+ }
+ else if (planned_tests != testno)
+ {
+ bad_amount = testno > planned_tests ? "many" : "few"
+ testsuite_error(sprintf("too %s tests run (expected %d, got %d)",
+ bad_amount, planned_tests, testno))
+ }
+ if (!ignore_exit)
+ {
+ # Fetch exit status from the last line.
+ exit_message = get_test_exit_message(nextline)
+ if (exit_message)
+ testsuite_error(exit_message)
+ }
+ }
+
+write_test_results()
+
+exit 0
+
+} # End of "BEGIN" block.
+'
+
+# TODO: document that we consume the file descriptor 3 :-(
+} 3>"$log_file"
+
+test $? -eq 0 || fatal "I/O or internal error"
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/utils/tap-test b/utils/tap-test
new file mode 100755
index 00000000..481e333e
--- /dev/null
+++ b/utils/tap-test
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+# run a GTest in tap mode. The test binary is passed as $1
+
+$1 -k --tap
From 43d06369bf8e5c5e470dc2b00656ddcdb9ee0480 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Sun, 26 Nov 2017 21:10:07 +0100
Subject: [PATCH 0131/1087] move fixtures to outer scope
---
tests/irc/core/Makefile.am | 16 +-
tests/irc/core/test-irc.c | 372 ++++++++++++++++++-------------------
2 files changed, 190 insertions(+), 198 deletions(-)
diff --git a/tests/irc/core/Makefile.am b/tests/irc/core/Makefile.am
index b5345067..ccc6aa97 100644
--- a/tests/irc/core/Makefile.am
+++ b/tests/irc/core/Makefile.am
@@ -1,5 +1,7 @@
include $(top_srcdir)/utils/glib-tap.mk
+PACKAGE_STRING=irc/core
+
AM_CPPFLAGS = \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/core \
@@ -17,21 +19,11 @@ test_irc_DEPENDENCIES = \
../../../src/lib-config/libirssi_config.a
test_irc_LDADD = \
+ ../../../src/irc/core/libirc_core.a \
../../../src/core/libcore.a \
../../../src/lib-config/libirssi_config.a \
@GLIB_LIBS@ \
@OPENSSL_LIBS@
test_irc_SOURCES = \
- test-irc.c \
- ../../../src/irc/core/irc-cap.c \
- ../../../src/irc/core/irc-nicklist.c \
- ../../../src/irc/core/irc-queries.c \
- ../../../src/irc/core/irc-servers-reconnect.c \
- ../../../src/irc/core/irc-servers-setup.c \
- ../../../src/irc/core/irc-servers.c \
- ../../../src/irc/core/irc.c \
- ../../../src/irc/core/mode-lists.c \
- ../../../src/irc/core/modes.c \
- ../../../src/irc/core/servers-idle.c \
- ../../../src/irc/core/servers-redirect.c
+ test-irc.c
diff --git a/tests/irc/core/test-irc.c b/tests/irc/core/test-irc.c
index 4c62e6a7..90ce856b 100644
--- a/tests/irc/core/test-irc.c
+++ b/tests/irc/core/test-irc.c
@@ -22,210 +22,210 @@
#include
#include
-static void test_event_get_param(void);
-static void test_event_get_params(void);
+typedef struct {
+ char const *const description;
+ char const *const input;
+ char const *const input_after;
+ char const *const output;
+} event_get_param_test_case;
+
+event_get_param_test_case const event_get_param_fixtures[] = {
+ {
+ .description = "Zero parameters",
+ .input = "",
+ .input_after = "",
+ .output = "",
+ },
+ {
+ .description = "One parameter",
+ .input = "#test",
+ .input_after = "",
+ .output = "#test",
+ },
+ {
+ .description = "One parameter, trailing space",
+ .input = "#test ",
+ .input_after = "",
+ .output = "#test",
+ },
+ {
+ .description = "One parameter, more trailing space",
+ .input = "#test ",
+ .input_after = " ",
+ .output = "#test",
+ },
+ {
+ .description = "Two parameters",
+ .input = "#test +o",
+ .input_after = "+o",
+ .output = "#test",
+ },
+ {
+ .description = "Two parameters continued",
+ .input = "+o",
+ .input_after = "",
+ .output = "+o",
+ },
+ {
+ .description = "Two parameters with trailing space",
+ .input = "#test +o ",
+ .input_after = "+o ",
+ .output = "#test",
+ },
+ {
+ .description = "Two parameters with trailing space continued",
+ .input = "+o ",
+ .input_after = "",
+ .output = "+o",
+ },
+ {
+ .description = "Two parameters with inline and trailing space",
+ .input = "#test +o ",
+ .input_after = " +o ",
+ .output = "#test",
+ },
+ /* TODO: It seems not ideal that the caller has to deal with inline space.
+ */
+ {
+ .description = "Two parameters with inline and trailing space continued",
+ .input = " +o ",
+ .input_after = "+o ",
+ .output = "",
+ },
+};
+
+static void test_event_get_param(const event_get_param_test_case *test);
+
+typedef struct {
+ char const *const description;
+ char const *const input;
+ char const *const output0;
+ char const *const output1;
+} event_get_params_test_case;
+
+event_get_params_test_case const event_get_params_fixtures[] = {
+ {
+ .description = "Only a channel",
+ .input = "#test",
+ .output0 = "#test",
+ .output1 = "",
+ },
+ {
+ .description = "Only a channel with trailing space",
+ .input = "#test ",
+ .output0 = "#test",
+ .output1 = "",
+ },
+ {
+ .description = "No :, channel mode with one parameter after channel name",
+ .input = "#test +i",
+ .output0 = "#test",
+ .output1 = "+i",
+ },
+ {
+ .description = "No :, channel mode with two parameters after channel name",
+ .input = "#test +o tester",
+ .output0 = "#test",
+ .output1 = "+o tester",
+ },
+ {
+ .description = "No :, channel mode with three parameters afer channel name",
+ .input = "#test +ov tester tester2",
+ .output0 = "#test",
+ .output1 = "+ov tester tester2",
+ },
+ {
+ .description = "No :, channel mode with three parameters afer channel name, bunch of extra space",
+ .input = "#test +ov tester tester2 ",
+ .output0 = "#test",
+ .output1 = " +ov tester tester2 ",
+ },
+ {
+ .description = "Channel mode with one parameter after channel name, : at the start of modes",
+ .input = "#test :+i",
+ .output0 = "#test",
+ .output1 = "+i",
+ },
+ {
+ .description = "Channel mode with two parameters after channel name, : at the start of modes",
+ .input = "#test :+o tester",
+ .output0 = "#test",
+ .output1 = "+o tester",
+ },
+ {
+ .description = "Channel mode with three parameters after channel name, : at the start of modes",
+ .input = "#test :+ov tester tester2",
+ .output0 = "#test",
+ .output1 = "+ov tester tester2",
+ },
+ {
+ .description = "Channel mode with two parameters after channel name, : on the final parameter",
+ .input = "#test +o :tester",
+ .output0 = "#test",
+ .output1 = "+o tester",
+ },
+ {
+ .description = "Channel mode with three parameters after channel name, : on the final parameter",
+ .input = "#test +ov tester :tester2",
+ .output0 = "#test",
+ .output1 = "+ov tester tester2",
+ },
+ {
+ .description = "Channel mode with three parameters after channel name, : on the final parameter, also a second : present",
+ .input = "#test +ov tester :tester2 hi:there",
+ .output0 = "#test",
+ .output1 = "+ov tester tester2 hi:there",
+ },
+};
+
+static void test_event_get_params(const event_get_params_test_case *test);
int main(int argc, char **argv)
{
+ int i;
+
g_test_init(&argc, &argv, NULL);
- g_test_add_func("/test/event_get_param", test_event_get_param);
- g_test_add_func("/test/event_get_params", test_event_get_params);
+ for (i = 0; i < G_N_ELEMENTS(event_get_param_fixtures); i++) {
+ char *name = g_strdup_printf("/test/event_get_params/%d", i);
+ g_test_add_data_func(name, &event_get_params_fixtures[i], (GTestDataFunc)test_event_get_params);
+ g_free(name);
+ }
+ for (i = 0; i < G_N_ELEMENTS(event_get_param_fixtures); i++) {
+ char *name = g_strdup_printf("/test/event_get_param/%d", i);
+ g_test_add_data_func(name, &event_get_param_fixtures[i], (GTestDataFunc)test_event_get_param);
+ g_free(name);
+ }
g_test_set_nonfatal_assertions();
return g_test_run();
}
-static void test_event_get_param(void)
+static void test_event_get_param(const event_get_param_test_case *test)
{
- struct test_case {
- char const *const description;
- char const *const input;
- char const *const input_after;
- char const *const output;
- };
+ char *buf, *input, *output;
- struct test_case const tests[] = {
- {
- .description = "Zero parameters",
- .input = "",
- .input_after = "",
- .output = "",
- },
- {
- .description = "One parameter",
- .input = "#test",
- .input_after = "",
- .output = "#test",
- },
- {
- .description = "One parameter, trailing space",
- .input = "#test ",
- .input_after = "",
- .output = "#test",
- },
- {
- .description = "One parameter, more trailing space",
- .input = "#test ",
- .input_after = " ",
- .output = "#test",
- },
- {
- .description = "Two parameters",
- .input = "#test +o",
- .input_after = "+o",
- .output = "#test",
- },
- {
- .description = "Two parameters continued",
- .input = "+o",
- .input_after = "",
- .output = "+o",
- },
- {
- .description = "Two parameters with trailing space",
- .input = "#test +o ",
- .input_after = "+o ",
- .output = "#test",
- },
- {
- .description = "Two parameters with trailing space continued",
- .input = "+o ",
- .input_after = "",
- .output = "+o",
- },
- {
- .description = "Two parameters with inline and trailing space",
- .input = "#test +o ",
- .input_after = " +o ",
- .output = "#test",
- },
- /* TODO: It seems not ideal that the caller has to deal with inline space.
- */
- {
- .description = "Two parameters with inline and trailing space continued",
- .input = " +o ",
- .input_after = "+o ",
- .output = "",
- },
- };
+ input = buf = g_strdup(test->input);
+ output = event_get_param(&input);
- char *buf = g_malloc0(1024);
-
- int i = 0;
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
- struct test_case const test = tests[i];
-
- memcpy(buf, test.input, strlen(test.input)+1);
- char *input = buf;
-
- char *const output = event_get_param(&input);
-
- g_assert_cmpstr(input, ==, test.input_after);
- g_assert_cmpstr(output, ==, test.output);
- }
+ g_assert_cmpstr(input, ==, test->input_after);
+ g_assert_cmpstr(output, ==, test->output);
g_free(buf);
}
-static void test_event_get_params(void)
+static void test_event_get_params(const event_get_params_test_case *test)
{
- struct test_case {
- char const *const description;
- char const *const input;
- char const *const output0;
- char const *const output1;
- };
+ char *output0, *output1, *params;
+ output0 = NULL;
+ output1 = NULL;
+ params = event_get_params(test->input, 2 | PARAM_FLAG_GETREST,
+ &output0, &output1);
- struct test_case const tests[] = {
- {
- .description = "Only a channel",
- .input = "#test",
- .output0 = "#test",
- .output1 = "",
- },
- {
- .description = "Only a channel with trailing space",
- .input = "#test ",
- .output0 = "#test",
- .output1 = "",
- },
- {
- .description = "No :, channel mode with one parameter after channel name",
- .input = "#test +i",
- .output0 = "#test",
- .output1 = "+i",
- },
- {
- .description = "No :, channel mode with two parameters after channel name",
- .input = "#test +o tester",
- .output0 = "#test",
- .output1 = "+o tester",
- },
- {
- .description = "No :, channel mode with three parameters afer channel name",
- .input = "#test +ov tester tester2",
- .output0 = "#test",
- .output1 = "+ov tester tester2",
- },
- {
- .description = "No :, channel mode with three parameters afer channel name, bunch of extra space",
- .input = "#test +ov tester tester2 ",
- .output0 = "#test",
- .output1 = " +ov tester tester2 ",
- },
- {
- .description = "Channel mode with one parameter after channel name, : at the start of modes",
- .input = "#test :+i",
- .output0 = "#test",
- .output1 = "+i",
- },
- {
- .description = "Channel mode with two parameters after channel name, : at the start of modes",
- .input = "#test :+o tester",
- .output0 = "#test",
- .output1 = "+o tester",
- },
- {
- .description = "Channel mode with three parameters after channel name, : at the start of modes",
- .input = "#test :+ov tester tester2",
- .output0 = "#test",
- .output1 = "+ov tester tester2",
- },
- {
- .description = "Channel mode with two parameters after channel name, : on the final parameter",
- .input = "#test +o :tester",
- .output0 = "#test",
- .output1 = "+o tester",
- },
- {
- .description = "Channel mode with three parameters after channel name, : on the final parameter",
- .input = "#test +ov tester :tester2",
- .output0 = "#test",
- .output1 = "+ov tester tester2",
- },
- {
- .description = "Channel mode with three parameters after channel name, : on the final parameter, also a second : present",
- .input = "#test +ov tester :tester2 hi:there",
- .output0 = "#test",
- .output1 = "+ov tester tester2 hi:there",
- },
- };
+ /* params happens to always point at the first output */
+ g_assert_cmpstr(params, ==, test->output0);
+ g_assert_cmpstr(output0, ==, test->output0);
+ g_assert_cmpstr(output1, ==, test->output1);
- int i = 0;
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
- struct test_case const test = tests[i];
-
- char *output0 = NULL;
- char *output1 = NULL;
- char *const params = event_get_params(test.input, 2 | PARAM_FLAG_GETREST,
- &output0, &output1);
-
- /* params happens to always point at the first output */
- g_assert_cmpstr(params, ==, test.output0);
- g_assert_cmpstr(output0, ==, test.output0);
- g_assert_cmpstr(output1, ==, test.output1);
-
- g_free(params);
- }
+ g_free(params);
}
From d932e6e4b78383e0874721a76a8480a9a7e03667 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Sun, 26 Nov 2017 21:10:49 +0100
Subject: [PATCH 0132/1087] add test case for format_real_length
---
configure.ac | 2 ++
tests/Makefile.am | 2 +-
tests/fe-common/Makefile.am | 1 +
tests/fe-common/core/Makefile.am | 28 ++++++++++++++++
tests/fe-common/core/test-formats.c | 50 +++++++++++++++++++++++++++++
5 files changed, 82 insertions(+), 1 deletion(-)
create mode 100644 tests/fe-common/Makefile.am
create mode 100644 tests/fe-common/core/Makefile.am
create mode 100644 tests/fe-common/core/test-formats.c
diff --git a/configure.ac b/configure.ac
index c780b9b8..76ada09f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -661,6 +661,8 @@ src/perl/textui/Makefile.PL
scripts/Makefile
scripts/examples/Makefile
tests/Makefile
+tests/fe-common/Makefile
+tests/fe-common/core/Makefile
tests/irc/Makefile
tests/irc/core/Makefile
docs/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 58c348df..e16d190e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1 +1 @@
-SUBDIRS = irc
+SUBDIRS = fe-common irc
diff --git a/tests/fe-common/Makefile.am b/tests/fe-common/Makefile.am
new file mode 100644
index 00000000..52770885
--- /dev/null
+++ b/tests/fe-common/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = core
diff --git a/tests/fe-common/core/Makefile.am b/tests/fe-common/core/Makefile.am
new file mode 100644
index 00000000..070b6052
--- /dev/null
+++ b/tests/fe-common/core/Makefile.am
@@ -0,0 +1,28 @@
+include $(top_srcdir)/utils/glib-tap.mk
+
+PACKAGE_STRING=fe-common/core
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/core \
+ $(GLIB_CFLAGS)
+
+test_programs = test-formats
+
+test_formats_CPPFLAGS = \
+ -I$(top_srcdir)/src/fe-common/core \
+ $(AM_CPPFLAGS)
+
+test_formats_DEPENDENCIES = \
+ ../../../src/core/libcore.a \
+ ../../../src/lib-config/libirssi_config.a
+
+test_formats_LDADD = \
+ ../../../src/fe-common/core/libfe_common_core.a \
+ ../../../src/core/libcore.a \
+ ../../../src/lib-config/libirssi_config.a \
+ @GLIB_LIBS@ \
+ @OPENSSL_LIBS@
+
+test_formats_SOURCES = \
+ test-formats.c
diff --git a/tests/fe-common/core/test-formats.c b/tests/fe-common/core/test-formats.c
new file mode 100644
index 00000000..9ef23fd6
--- /dev/null
+++ b/tests/fe-common/core/test-formats.c
@@ -0,0 +1,50 @@
+#include "common.h"
+#include "formats.h"
+
+#define MAX_LENGTH 5
+
+typedef struct {
+ char const *const description;
+ char const *const input;
+ int const result[ MAX_LENGTH ];
+} format_real_length_test_case;
+
+static void test_format_real_length(const format_real_length_test_case *test);
+
+format_real_length_test_case const format_real_length_fixtures[] = {
+ {
+ .description = "",
+ .input = "%4%w ",
+ .result = { 0, 5, 5, -1 },
+ },
+};
+
+int main(int argc, char **argv)
+{
+ int i;
+
+ g_test_init(&argc, &argv, NULL);
+
+ for (i = 0; i < G_N_ELEMENTS(format_real_length_fixtures); i++) {
+ char *name = g_strdup_printf("/test/format_real_length/%d", i);
+ g_test_add_data_func(name, &format_real_length_fixtures[i], (GTestDataFunc)test_format_real_length);
+ g_free(name);
+ }
+
+ g_test_set_nonfatal_assertions();
+ return g_test_run();
+}
+
+static void test_format_real_length(const format_real_length_test_case *test)
+{
+ int j, len;
+
+ g_test_message("Testing format %s", test->input);
+
+ for (j = 0; test->result[j] != -1; j++) {
+ len = format_real_length(test->input, j);
+ g_assert_cmpint(len, ==, test->result[j]);
+ }
+
+ return;
+}
From d6458304d7dba0644fb4b682e09baf0acebdbb97 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Sun, 26 Nov 2017 21:23:51 +0100
Subject: [PATCH 0133/1087] mess with travis
---
.travis.yml | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 1e04d943..a6ff601f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,8 +12,13 @@ perl:
# - "5.18-shrplib"
- "system-perl"
env:
- - CC=clang
- - CC=gcc
+ - CC=clang UNITTESTS=false
+ - CC=gcc UNITTESTS=false
+ - CC=clang UNITTESTS=true
+matrix:
+ exclude:
+ - env: CC=clang UNITTESTS=true
+ perl: "system-perl"
addons:
apt:
@@ -31,11 +36,12 @@ before_install:
install:
- ./configure --with-proxy --with-bot --with-perl=module --prefix=$HOME/irssi-build
+ $( $UNITTESTS && echo --enable-always-build-tests )
- make CFLAGS="-Wall -Werror -Werror=declaration-after-statement"
- make install
before_script:
- - cd
+ - pushd ~
- mkdir irssi-test
- echo echo automated irssi launch test > irssi-test/startup;
echo ^set settings_autosave off >> irssi-test/startup;
@@ -47,9 +53,12 @@ before_script:
- echo load perl >> irssi-test/startup
- echo load proxy >> irssi-test/startup
- echo ^quit >> irssi-test/startup
- - irssi-build/bin/irssi --home irssi-test
- - cat irc.log.*
- - cd $TRAVIS_BUILD_DIR
script:
- - make check
+ - irssi-build/bin/irssi --home irssi-test
+ - popd
+ - if $UNITTESTS; then make -C tests -sk check; fi
+
+after_script:
+ - cat ~/irc.log.*;
+ find -name test-suite.log -exec cat {} +
From eb9e2ed6fdacc3fa262b4907de51dea3f12be5fe Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Tue, 28 Nov 2017 11:00:46 +0100
Subject: [PATCH 0134/1087] Update test-irc.c
Fix wrong array (missing an s)
---
tests/irc/core/test-irc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/irc/core/test-irc.c b/tests/irc/core/test-irc.c
index 90ce856b..c96956df 100644
--- a/tests/irc/core/test-irc.c
+++ b/tests/irc/core/test-irc.c
@@ -186,7 +186,7 @@ int main(int argc, char **argv)
g_test_init(&argc, &argv, NULL);
- for (i = 0; i < G_N_ELEMENTS(event_get_param_fixtures); i++) {
+ for (i = 0; i < G_N_ELEMENTS(event_get_params_fixtures); i++) {
char *name = g_strdup_printf("/test/event_get_params/%d", i);
g_test_add_data_func(name, &event_get_params_fixtures[i], (GTestDataFunc)test_event_get_params);
g_free(name);
From 8b34871ea67c420b045ead9e317b67a247c02aae Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Wed, 29 Nov 2017 14:40:40 +0100
Subject: [PATCH 0135/1087] make travis pass despite failures
---
.travis.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index a6ff601f..b0bc78e8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,6 +19,8 @@ matrix:
exclude:
- env: CC=clang UNITTESTS=true
perl: "system-perl"
+ allow_failures:
+ - env: CC=clang UNITTESTS=true
addons:
apt:
From 58557d18c49c11cd4a4de44c5a9e7c00f2d8f880 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Thu, 7 Dec 2017 12:08:20 +0100
Subject: [PATCH 0136/1087] add separator in travis.yml
---
.travis.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index b0bc78e8..e2b3f57c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -62,5 +62,5 @@ script:
- if $UNITTESTS; then make -C tests -sk check; fi
after_script:
- - cat ~/irc.log.*;
- find -name test-suite.log -exec cat {} +
+ - cat ~/irc.log.*
+ - find -name test-suite.log -exec cat {} +
From ef07b3c60c80a828f529a2075246185d7d0b5b25 Mon Sep 17 00:00:00 2001
From: Joseph Bisch
Date: Tue, 2 Jan 2018 20:21:07 -0500
Subject: [PATCH 0137/1087] Remove redundant if case
---
src/fe-fuzz/irc/core/event-get-params.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/fe-fuzz/irc/core/event-get-params.c b/src/fe-fuzz/irc/core/event-get-params.c
index 6266ffb6..beeca6ba 100644
--- a/src/fe-fuzz/irc/core/event-get-params.c
+++ b/src/fe-fuzz/irc/core/event-get-params.c
@@ -74,8 +74,6 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
params = event_get_params(copy, 2, &output0, &output1);
} else if (count % 8 == 6) {
params = event_get_params(copy, 3, &output0, &output1, &output2);
- } else if (count % 8 == 7) {
- params = event_get_params(copy, 4, &output0, &output1, &output2, &output3);
} else {
params = event_get_params(copy, 4, &output0, &output1, &output2, &output3);
}
From 15705432e1fb88d9f784cb3fc12c89f8f9164043 Mon Sep 17 00:00:00 2001
From: Joseph Bisch
Date: Tue, 2 Jan 2018 20:22:38 -0500
Subject: [PATCH 0138/1087] Remove outdated comment
---
src/fe-fuzz/irc/core/event-get-params.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/fe-fuzz/irc/core/event-get-params.c b/src/fe-fuzz/irc/core/event-get-params.c
index beeca6ba..c50b6205 100644
--- a/src/fe-fuzz/irc/core/event-get-params.c
+++ b/src/fe-fuzz/irc/core/event-get-params.c
@@ -52,7 +52,6 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
return 0;
}
uint8_t count = *data;
- /* malloc(size) instead of size+1, because we already used one byte of data */
gchar *copy = g_strndup((const gchar *)data+1, size-1);
char *output0;
From 54d453623d879ea83d0818a80bd14151192953ec Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Wed, 3 Jan 2018 12:45:43 +0100
Subject: [PATCH 0139/1087] do not record topic change time when sender is
blank
---
src/irc/core/channel-events.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c
index b0bddab2..46bbd5fa 100644
--- a/src/irc/core/channel-events.c
+++ b/src/irc/core/channel-events.c
@@ -138,7 +138,13 @@ static void channel_change_topic(IRC_SERVER_REC *server, const char *channel,
g_free_not_null(chanrec->topic_by);
chanrec->topic_by = g_strdup(setby);
- chanrec->topic_time = settime;
+ if (chanrec->topic_by == NULL) {
+ /* ensure invariant topic_time > 0 <=> topic_by != NULL.
+ this could be triggered by a topic command without sender */
+ chanrec->topic_time = 0;
+ } else {
+ chanrec->topic_time = settime;
+ }
signal_emit("channel topic changed", 1, chanrec);
}
From 7a83c63701b7395ee6cc606905314318eef77971 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Wed, 3 Jan 2018 14:09:48 +0100
Subject: [PATCH 0140/1087] check if \\c is complete in eval
---
src/core/misc.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/core/misc.c b/src/core/misc.c
index e589b8c5..4e9f4bbe 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -703,8 +703,11 @@ int expand_escape(const char **data)
*data += 2;
return strtol(digit, NULL, 16);
case 'c':
- /* control character (\cA = ^A) */
- (*data)++;
+ /* check for end of string */
+ if ((*data)[1] == '\0')
+ return 0;
+ /* control character (\cA = ^A) */
+ (*data)++;
return i_toupper(**data) - 64;
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
From 2361d4b1e5d38701f35146219ceddd318ac4e645 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Wed, 3 Jan 2018 15:35:18 +0100
Subject: [PATCH 0141/1087] rewrite completion code and check for direct match
of separator
---
src/fe-common/core/completion.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c
index e78fe7d5..fd452e5c 100644
--- a/src/fe-common/core/completion.c
+++ b/src/fe-common/core/completion.c
@@ -187,12 +187,18 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, i
char *old;
old = linestart;
- linestart = *linestart == '\0' ?
- g_strdup(word) :
- g_strdup_printf("%s%c%s",
- /* do not accidentally duplicate the word separator */
- line == wordstart - 1 ? "" : linestart,
- old_wordstart[-1], word);
+ /* we want to move word into linestart */
+ if (*linestart == '\0') {
+ linestart = g_strdup(word);
+ } else {
+ GString *str = g_string_new(linestart);
+ if (old_wordstart[-1] != str->str[str->len - 1]) {
+ /* do not accidentally duplicate the word separator */
+ g_string_append_c(str, old_wordstart[-1]);
+ }
+ g_string_append(str, word);
+ linestart = g_string_free(str, FALSE);
+ }
g_free(old);
g_free(word);
From cc17837a9b326ec9100a35981348fa0f5d6316fa Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Wed, 3 Jan 2018 15:51:51 +0100
Subject: [PATCH 0142/1087] disable variable arguments code
---
src/core/special-vars.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/core/special-vars.c b/src/core/special-vars.c
index aaf8da8f..f254c200 100644
--- a/src/core/special-vars.c
+++ b/src/core/special-vars.c
@@ -384,6 +384,7 @@ char *parse_special(char **cmd, SERVER_REC *server, void *item,
}
nest_free = FALSE; nest_value = NULL;
+#if 0 /* this code is disabled due to security issues until it is fixed */
if (**cmd == '(' && (*cmd)[1] != '\0') {
/* subvariable */
int toplevel = nested_orig_cmd == NULL;
@@ -412,6 +413,9 @@ char *parse_special(char **cmd, SERVER_REC *server, void *item,
if (toplevel) nested_orig_cmd = NULL;
}
+#else
+ if (nested_orig_cmd) nested_orig_cmd = NULL;
+#endif
if (**cmd != '{')
brackets = FALSE;
From 5bddfe7b7336f6b48408c72955dbcb664cc4dc97 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Thu, 4 Jan 2018 14:29:57 +0100
Subject: [PATCH 0143/1087] add new test skeleton
---
configure.ac | 1 +
tests/irc/Makefile.am | 4 +++-
tests/irc/flood/Makefile.am | 32 ++++++++++++++++++++++++++++++++
tests/irc/flood/test-796.c | 29 +++++++++++++++++++++++++++++
4 files changed, 65 insertions(+), 1 deletion(-)
create mode 100644 tests/irc/flood/Makefile.am
create mode 100644 tests/irc/flood/test-796.c
diff --git a/configure.ac b/configure.ac
index 76ada09f..61e96149 100644
--- a/configure.ac
+++ b/configure.ac
@@ -665,6 +665,7 @@ tests/fe-common/Makefile
tests/fe-common/core/Makefile
tests/irc/Makefile
tests/irc/core/Makefile
+tests/irc/flood/Makefile
docs/Makefile
docs/help/Makefile
docs/help/in/Makefile
diff --git a/tests/irc/Makefile.am b/tests/irc/Makefile.am
index 52770885..d42cfc87 100644
--- a/tests/irc/Makefile.am
+++ b/tests/irc/Makefile.am
@@ -1 +1,3 @@
-SUBDIRS = core
+SUBDIRS = \
+ core \
+ flood
diff --git a/tests/irc/flood/Makefile.am b/tests/irc/flood/Makefile.am
new file mode 100644
index 00000000..4bc4a93c
--- /dev/null
+++ b/tests/irc/flood/Makefile.am
@@ -0,0 +1,32 @@
+include $(top_srcdir)/utils/glib-tap.mk
+
+PACKAGE_STRING=irc/flood
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/core \
+ -DSYSCONFDIR=\""$(sysconfdir)"\" \
+ $(GLIB_CFLAGS)
+
+test_programs = \
+ test-796
+
+test_796_CPPFLAGS = \
+ -I$(top_srcdir)/src/irc/core \
+ -I$(top_srcdir)/src/irc/flood \
+ $(AM_CPPFLAGS)
+
+test_796_DEPENDENCIES = \
+ ../../../src/core/libcore.a \
+ ../../../src/lib-config/libirssi_config.a
+
+test_796_LDADD = \
+ ../../../src/irc/flood/libirc_flood.a \
+ ../../../src/irc/core/libirc_core.a \
+ ../../../src/core/libcore.a \
+ ../../../src/lib-config/libirssi_config.a \
+ @GLIB_LIBS@ \
+ @OPENSSL_LIBS@
+
+test_796_SOURCES = \
+ test-796.c
diff --git a/tests/irc/flood/test-796.c b/tests/irc/flood/test-796.c
new file mode 100644
index 00000000..9ca29489
--- /dev/null
+++ b/tests/irc/flood/test-796.c
@@ -0,0 +1,29 @@
+/*
+ test-796.c : irssi
+
+ Copyright (C) 2017 The Irssi project.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "common.h"
+
+int main(int argc, char **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_set_nonfatal_assertions();
+ return g_test_run();
+}
From c7cd49f8d7e83302c0f21f4449cddac528d28eea Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Thu, 4 Jan 2018 16:18:07 +0100
Subject: [PATCH 0144/1087] first bug case, exposes broken server object in
chat-completion
---
tests/irc/flood/Makefile.am | 8 +++
tests/irc/flood/test-796.c | 122 ++++++++++++++++++++++++++++++++++++
2 files changed, 130 insertions(+)
diff --git a/tests/irc/flood/Makefile.am b/tests/irc/flood/Makefile.am
index 4bc4a93c..85b52eab 100644
--- a/tests/irc/flood/Makefile.am
+++ b/tests/irc/flood/Makefile.am
@@ -12,6 +12,7 @@ test_programs = \
test-796
test_796_CPPFLAGS = \
+ -I$(top_srcdir)/src/fe-common/core \
-I$(top_srcdir)/src/irc/core \
-I$(top_srcdir)/src/irc/flood \
$(AM_CPPFLAGS)
@@ -21,8 +22,15 @@ test_796_DEPENDENCIES = \
../../../src/lib-config/libirssi_config.a
test_796_LDADD = \
+ ../../../src/irc/libirc.a \
+ ../../../src/fe-common/irc/libfe_common_irc.a \
+ ../../../src/fe-common/irc/dcc/libfe_irc_dcc.a \
+ ../../../src/fe-common/irc/notifylist/libfe_irc_notifylist.a \
+ ../../../src/irc/dcc/libirc_dcc.a \
+ ../../../src/irc/notifylist/libirc_notifylist.a \
../../../src/irc/flood/libirc_flood.a \
../../../src/irc/core/libirc_core.a \
+ ../../../src/fe-common/core/libfe_common_core.a \
../../../src/core/libcore.a \
../../../src/lib-config/libirssi_config.a \
@GLIB_LIBS@ \
diff --git a/tests/irc/flood/test-796.c b/tests/irc/flood/test-796.c
index 9ca29489..293e87d7 100644
--- a/tests/irc/flood/test-796.c
+++ b/tests/irc/flood/test-796.c
@@ -19,11 +19,133 @@
*/
#include "common.h"
+#include "args.h"
+#include "core.h"
+#include "misc.h"
+#include "servers-setup.h"
+
+#include "formats.h"
+#include "fe-common-core.h"
+
+#include "irc.h"
+#include "irc-servers.h"
+#include "irc-channels.h"
+
+/* irc.c */
+void irc_init(void);
+void irc_deinit(void) ;
+
+/* irc-session.c */
+void irc_session_init(void);
+void irc_session_deinit(void);
+
+/* fe-common-irc.c */
+void fe_common_irc_init(void);
+void fe_common_irc_deinit(void);
+
+typedef struct {
+} ServerDestroyFloodData;
+
+#define MODULE_NAME "tests"
+
+static void cmd_echo(const char *data, void *server, WI_ITEM_REC *item)
+{
+ g_test_message("echo: [server=%p,item=%p] %s", server, item, data);
+}
+
+static void sig_public(SERVER_REC *server, const char *msg, const char *nick, const char *address, const char *target)
+{
+ signal_emit("send command", 3, "/eval echo $tag", server, NULL);
+}
+
+static void print_disconnect(SERVER_REC *server)
+{
+ g_test_message("server %p was disconnected", server);
+}
+
+static void server_destroy_flood_set_up(ServerDestroyFloodData *fixture, const void *data)
+{
+ args_execute(0, NULL);
+ core_init();
+ irc_init();
+ fe_common_core_init();
+ fe_common_irc_init();
+ signal_emit("irssi init finished", 0);
+ command_bind("echo", NULL, (SIGNAL_FUNC) cmd_echo);
+ signal_add("message public", (SIGNAL_FUNC) sig_public);
+ signal_add_first("server disconnected", (SIGNAL_FUNC) print_disconnect);
+}
+
+static void server_destroy_flood_tear_down(ServerDestroyFloodData *fixture, const void *data)
+{
+ signal_remove("server disconnected", (SIGNAL_FUNC) print_disconnect);
+ signal_remove("message public", (SIGNAL_FUNC) sig_public);
+ command_unbind("echo", (SIGNAL_FUNC) cmd_echo);
+ fe_common_irc_deinit();
+ fe_common_core_deinit();
+ irc_deinit();
+ core_deinit();
+}
+
+static void irc_server_init_bare_minimum(IRC_SERVER_REC *server)
+{
+ server->isupport = g_hash_table_new((GHashFunc) g_istr_hash,
+ (GCompareFunc) g_istr_equal);
+
+ /* set the standards */
+ g_hash_table_insert(server->isupport, g_strdup("CHANMODES"), g_strdup("beI,k,l,imnpst"));
+ g_hash_table_insert(server->isupport, g_strdup("PREFIX"), g_strdup("(ohv)@%+"));
+}
+
+static void test_server_destroy_flood(ServerDestroyFloodData *fixture, const void *data)
+{
+ SERVER_REC *server; /* = g_new0(IRC_SERVER_REC, 1); */
+ CHAT_PROTOCOL_REC *proto;
+ SERVER_CONNECT_REC *conn;
+
+ g_test_bug("796");
+
+ proto = chat_protocol_find("IRC");
+ conn = server_create_conn(proto->id, "localhost", 0, "", "", "user");
+ server = proto->server_init_connect(conn);
+ server->session_reconnect = TRUE;
+ server->tag = g_strdup("testserver");
+
+ g_test_message("created server: %p", server);
+
+ /* we skip some initialisations that would try to send data */
+ /* irc_servers_deinit(); */
+ irc_session_deinit();
+ irc_irc_deinit();
+
+ signal_emit("server connected", 1, server);
+
+ /* make up for the skipped session init */
+ irc_server_init_bare_minimum(IRC_SERVER(server));
+
+ irc_irc_init();
+ irc_session_init();
+ /* irc_servers_init(); */
+
+ /* simulate failing irc_server_send_data() */
+ server->connection_lost = TRUE;
+
+ signal_emit("event privmsg", 4, server, "#someroom :test message", "nick", "user@host");
+}
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
+ g_test_bug_base("https://github.com/irssi/irssi/issues/");
+
+ g_test_add("/test/server_destroy_flood", ServerDestroyFloodData, NULL,
+ server_destroy_flood_set_up, test_server_destroy_flood,
+ server_destroy_flood_tear_down);
g_test_set_nonfatal_assertions();
+
+ core_preinit(*argv);
+ irssi_gui = IRSSI_GUI_NONE;
+
return g_test_run();
}
From 3b7b868bb11faf74c872ecf606c4eef189e31725 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Thu, 4 Jan 2018 16:43:58 +0100
Subject: [PATCH 0145/1087] finish test case
---
tests/irc/flood/test-796.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/tests/irc/flood/test-796.c b/tests/irc/flood/test-796.c
index 293e87d7..24a5d4be 100644
--- a/tests/irc/flood/test-796.c
+++ b/tests/irc/flood/test-796.c
@@ -110,6 +110,7 @@ static void test_server_destroy_flood(ServerDestroyFloodData *fixture, const voi
server = proto->server_init_connect(conn);
server->session_reconnect = TRUE;
server->tag = g_strdup("testserver");
+ server_ref(server);
g_test_message("created server: %p", server);
@@ -118,7 +119,8 @@ static void test_server_destroy_flood(ServerDestroyFloodData *fixture, const voi
irc_session_deinit();
irc_irc_deinit();
- signal_emit("server connected", 1, server);
+
+ server_connect_finished(server);
/* make up for the skipped session init */
irc_server_init_bare_minimum(IRC_SERVER(server));
@@ -130,6 +132,16 @@ static void test_server_destroy_flood(ServerDestroyFloodData *fixture, const voi
/* simulate failing irc_server_send_data() */
server->connection_lost = TRUE;
+ /*
+ chat_completion_deinit();
+ fe_messages_deinit();
+ irc_notifylist_deinit();
+ */
+
+ /* for the purpose of this exercise, we are ignoring the
+ errors of g_hash_table_lookup failure */
+ g_log_set_always_fatal(G_LOG_FATAL_MASK);
+
signal_emit("event privmsg", 4, server, "#someroom :test message", "nick", "user@host");
}
From bffced54981c191f5bac4f9611e4691fe442e58c Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Thu, 4 Jan 2018 21:11:00 +0100
Subject: [PATCH 0146/1087] Update test-796.c
odd space
---
tests/irc/flood/test-796.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/irc/flood/test-796.c b/tests/irc/flood/test-796.c
index 24a5d4be..ae94c5ab 100644
--- a/tests/irc/flood/test-796.c
+++ b/tests/irc/flood/test-796.c
@@ -33,7 +33,7 @@
/* irc.c */
void irc_init(void);
-void irc_deinit(void) ;
+void irc_deinit(void);
/* irc-session.c */
void irc_session_init(void);
From 6b0e14099655bf4d94a19dff252cce89b2858c93 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Thu, 4 Jan 2018 23:01:28 +0100
Subject: [PATCH 0147/1087] show destroyed event
---
tests/irc/flood/test-796.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/tests/irc/flood/test-796.c b/tests/irc/flood/test-796.c
index ae94c5ab..2e4affa0 100644
--- a/tests/irc/flood/test-796.c
+++ b/tests/irc/flood/test-796.c
@@ -63,6 +63,11 @@ static void print_disconnect(SERVER_REC *server)
g_test_message("server %p was disconnected", server);
}
+static void print_destroyed(SERVER_REC *server)
+{
+ g_test_message("server %p was destroyed", server);
+}
+
static void server_destroy_flood_set_up(ServerDestroyFloodData *fixture, const void *data)
{
args_execute(0, NULL);
@@ -73,12 +78,14 @@ static void server_destroy_flood_set_up(ServerDestroyFloodData *fixture, const v
signal_emit("irssi init finished", 0);
command_bind("echo", NULL, (SIGNAL_FUNC) cmd_echo);
signal_add("message public", (SIGNAL_FUNC) sig_public);
+ signal_add("server destroyed", (SIGNAL_FUNC) print_destroyed);
signal_add_first("server disconnected", (SIGNAL_FUNC) print_disconnect);
}
static void server_destroy_flood_tear_down(ServerDestroyFloodData *fixture, const void *data)
{
signal_remove("server disconnected", (SIGNAL_FUNC) print_disconnect);
+ signal_remove("server destroyed", (SIGNAL_FUNC) print_destroyed);
signal_remove("message public", (SIGNAL_FUNC) sig_public);
command_unbind("echo", (SIGNAL_FUNC) cmd_echo);
fe_common_irc_deinit();
@@ -90,27 +97,31 @@ static void server_destroy_flood_tear_down(ServerDestroyFloodData *fixture, cons
static void irc_server_init_bare_minimum(IRC_SERVER_REC *server)
{
server->isupport = g_hash_table_new((GHashFunc) g_istr_hash,
- (GCompareFunc) g_istr_equal);
+ (GCompareFunc) g_istr_equal);
- /* set the standards */
- g_hash_table_insert(server->isupport, g_strdup("CHANMODES"), g_strdup("beI,k,l,imnpst"));
- g_hash_table_insert(server->isupport, g_strdup("PREFIX"), g_strdup("(ohv)@%+"));
+ /* set the standards */
+ g_hash_table_insert(server->isupport, g_strdup("CHANMODES"), g_strdup("beI,k,l,imnpst"));
+ g_hash_table_insert(server->isupport, g_strdup("PREFIX"), g_strdup("(ohv)@%+"));
}
static void test_server_destroy_flood(ServerDestroyFloodData *fixture, const void *data)
{
SERVER_REC *server; /* = g_new0(IRC_SERVER_REC, 1); */
- CHAT_PROTOCOL_REC *proto;
+ CHAT_PROTOCOL_REC *proto;
SERVER_CONNECT_REC *conn;
+ GLogLevelFlags loglev;
g_test_bug("796");
+ /* for the purpose of this exercise, we are ignoring the
+ errors of g_hash_table_lookup failure */
+ loglev = g_log_set_always_fatal(G_LOG_FATAL_MASK);
+
proto = chat_protocol_find("IRC");
conn = server_create_conn(proto->id, "localhost", 0, "", "", "user");
server = proto->server_init_connect(conn);
server->session_reconnect = TRUE;
server->tag = g_strdup("testserver");
- server_ref(server);
g_test_message("created server: %p", server);
@@ -138,11 +149,11 @@ static void test_server_destroy_flood(ServerDestroyFloodData *fixture, const voi
irc_notifylist_deinit();
*/
- /* for the purpose of this exercise, we are ignoring the
- errors of g_hash_table_lookup failure */
- g_log_set_always_fatal(G_LOG_FATAL_MASK);
-
+ server_ref(server);
signal_emit("event privmsg", 4, server, "#someroom :test message", "nick", "user@host");
+ server_unref(server);
+
+ g_log_set_always_fatal(loglev);
}
int main(int argc, char **argv)
From c9b3d87eb7ef2ce99f659d7e567fc83629439142 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Wed, 3 Jan 2018 12:26:02 +0100
Subject: [PATCH 0148/1087] Postpone server cleanup until after unref
Add a new signal, server destroyed, that is supposed to run the clean up
tasks of server disconnected. This is so that some structures will stay
around longer.
---
src/core/servers.c | 1 +
src/fe-common/core/fe-common-core.c | 6 +++---
src/irc/core/irc-servers.c | 6 +++---
src/irc/flood/flood.c | 4 ++--
src/irc/notifylist/notifylist.c | 4 ++--
5 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/core/servers.c b/src/core/servers.c
index b9faab81..b1da9b7e 100644
--- a/src/core/servers.c
+++ b/src/core/servers.c
@@ -524,6 +524,7 @@ int server_unref(SERVER_REC *server)
return TRUE;
}
+ signal_emit("server destroyed", 1, server);
MODULE_DATA_DEINIT(server);
server_connect_unref(server->connrec);
if (server->rawlog != NULL) rawlog_destroy(server->rawlog);
diff --git a/src/fe-common/core/fe-common-core.c b/src/fe-common/core/fe-common-core.c
index a3b7364c..d0d36490 100644
--- a/src/fe-common/core/fe-common-core.c
+++ b/src/fe-common/core/fe-common-core.c
@@ -104,7 +104,7 @@ static void sig_connected(SERVER_REC *server)
MODULE_DATA_SET(server, g_new0(MODULE_SERVER_REC, 1));
}
-static void sig_disconnected(SERVER_REC *server)
+static void sig_destroyed(SERVER_REC *server)
{
void *data = MODULE_DATA(server);
g_free(data);
@@ -203,7 +203,7 @@ void fe_common_core_init(void)
settings_check();
signal_add_first("server connected", (SIGNAL_FUNC) sig_connected);
- signal_add_last("server disconnected", (SIGNAL_FUNC) sig_disconnected);
+ signal_add_last("server destroyed", (SIGNAL_FUNC) sig_destroyed);
signal_add_first("channel created", (SIGNAL_FUNC) sig_channel_created);
signal_add_last("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
@@ -249,7 +249,7 @@ void fe_common_core_deinit(void)
signal_remove("setup changed", (SIGNAL_FUNC) sig_setup_changed);
signal_remove("server connected", (SIGNAL_FUNC) sig_connected);
- signal_remove("server disconnected", (SIGNAL_FUNC) sig_disconnected);
+ signal_remove("server destroyed", (SIGNAL_FUNC) sig_destroyed);
signal_remove("channel created", (SIGNAL_FUNC) sig_channel_created);
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
}
diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c
index 4eaab712..5076a688 100644
--- a/src/irc/core/irc-servers.c
+++ b/src/irc/core/irc-servers.c
@@ -425,7 +425,7 @@ static void isupport_destroy_hash(void *key, void *value)
g_free(value);
}
-static void sig_disconnected(IRC_SERVER_REC *server)
+static void sig_destroyed(IRC_SERVER_REC *server)
{
GSList *tmp;
@@ -1031,7 +1031,7 @@ void irc_servers_init(void)
cmd_tag = -1;
signal_add_first("server connected", (SIGNAL_FUNC) sig_connected);
- signal_add_last("server disconnected", (SIGNAL_FUNC) sig_disconnected);
+ signal_add_last("server destroyed", (SIGNAL_FUNC) sig_destroyed);
signal_add_last("server quit", (SIGNAL_FUNC) sig_server_quit);
signal_add("event 001", (SIGNAL_FUNC) event_connected);
signal_add("event 004", (SIGNAL_FUNC) event_server_info);
@@ -1058,7 +1058,7 @@ void irc_servers_deinit(void)
g_source_remove(cmd_tag);
signal_remove("server connected", (SIGNAL_FUNC) sig_connected);
- signal_remove("server disconnected", (SIGNAL_FUNC) sig_disconnected);
+ signal_remove("server destroyed", (SIGNAL_FUNC) sig_destroyed);
signal_remove("server quit", (SIGNAL_FUNC) sig_server_quit);
signal_remove("event 001", (SIGNAL_FUNC) event_connected);
signal_remove("event 004", (SIGNAL_FUNC) event_server_info);
diff --git a/src/irc/flood/flood.c b/src/irc/flood/flood.c
index 0944a6eb..b528f707 100644
--- a/src/irc/flood/flood.c
+++ b/src/irc/flood/flood.c
@@ -324,7 +324,7 @@ void irc_flood_init(void)
read_settings();
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
signal_add_first("server connected", (SIGNAL_FUNC) flood_init_server);
- signal_add("server disconnected", (SIGNAL_FUNC) flood_deinit_server);
+ signal_add("server destroyed", (SIGNAL_FUNC) flood_deinit_server);
autoignore_init();
settings_check();
@@ -344,5 +344,5 @@ void irc_flood_deinit(void)
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
signal_remove("server connected", (SIGNAL_FUNC) flood_init_server);
- signal_remove("server disconnected", (SIGNAL_FUNC) flood_deinit_server);
+ signal_remove("server destroyed", (SIGNAL_FUNC) flood_deinit_server);
}
diff --git a/src/irc/notifylist/notifylist.c b/src/irc/notifylist/notifylist.c
index 573f7a7f..4fd5ef1a 100644
--- a/src/irc/notifylist/notifylist.c
+++ b/src/irc/notifylist/notifylist.c
@@ -331,7 +331,7 @@ void irc_notifylist_init(void)
notifylist_ison_init();
notifylist_whois_init();
signal_add("server connected", (SIGNAL_FUNC) notifylist_init_server);
- signal_add("server disconnected", (SIGNAL_FUNC) notifylist_deinit_server);
+ signal_add("server destroyed", (SIGNAL_FUNC) notifylist_deinit_server);
signal_add("event quit", (SIGNAL_FUNC) event_quit);
signal_add("event privmsg", (SIGNAL_FUNC) event_privmsg);
signal_add("event join", (SIGNAL_FUNC) event_join);
@@ -349,7 +349,7 @@ void irc_notifylist_deinit(void)
notifylist_whois_deinit();
signal_remove("server connected", (SIGNAL_FUNC) notifylist_init_server);
- signal_remove("server disconnected", (SIGNAL_FUNC) notifylist_deinit_server);
+ signal_remove("server destroyed", (SIGNAL_FUNC) notifylist_deinit_server);
signal_remove("event quit", (SIGNAL_FUNC) event_quit);
signal_remove("event privmsg", (SIGNAL_FUNC) event_privmsg);
signal_remove("event join", (SIGNAL_FUNC) event_join);
From c8012b2e574c6e1e25cf20ed31182323a492a98e Mon Sep 17 00:00:00 2001
From: Ailin Nemui
Date: Fri, 5 Jan 2018 00:32:03 +0100
Subject: [PATCH 0149/1087] Merge tag '1.0.6' into integrate/1.0.6
---
NEWS | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index cc301365..1054bb62 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,16 @@
-v1.1-head 2017-xx-xx The Irssi team
+v1.1-head 2018-xx-xx The Irssi team
+
+v1.0.6 2018-01-07 The Irssi team
+ - Fix invalid memory access when reading hilight configuration
+ (#787, #788).
+ - Fix null pointer dereference when the channel topic is set
+ without specifying a sender (GL#20, GL!25).
+ - Fix return of random memory when using incomplete escape
+ codes (GL#21, GL!26).
+ - Fix heap buffer overflow when completing certain strings
+ (GL#19, GL!27).
+ - Fix return of random memory when using an incomplete
+ variable argument (GL#18, GL!28).
v1.0.5 2017-10-23 The Irssi team
- Fix missing -sasl_method '' in /NETWORK (#718, #719).
From 3c7185c5ad61de24f9d1bc39240c8145665fba44 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Fri, 5 Jan 2018 00:38:54 +0100
Subject: [PATCH 0150/1087] Update irc-nicklist.c
move altnick check before the nick correction code
---
src/irc/core/irc-nicklist.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/irc/core/irc-nicklist.c b/src/irc/core/irc-nicklist.c
index a006a3cb..1f8c1fc9 100644
--- a/src/irc/core/irc-nicklist.c
+++ b/src/irc/core/irc-nicklist.c
@@ -345,6 +345,7 @@ static void event_nick_in_use(IRC_SERVER_REC *server, const char *data)
{
char *str, *cmd, *params, *nick;
int n;
+ gboolean try_alternate_nick;
g_return_if_fail(data != NULL);
@@ -352,6 +353,10 @@ static void event_nick_in_use(IRC_SERVER_REC *server, const char *data)
/* Already connected, no need to handle this anymore. */
return;
}
+
+ try_alternate_nick = g_ascii_strcasecmp(server->nick, server->connrec->nick) == 0 &&
+ server->connrec->alternate_nick != NULL &&
+ g_ascii_strcasecmp(server->connrec->alternate_nick, server->nick) != 0;
params = event_get_params(data, 2, NULL, &nick);
if (g_ascii_strcasecmp(server->nick, nick) != 0) {
@@ -362,9 +367,7 @@ static void event_nick_in_use(IRC_SERVER_REC *server, const char *data)
g_free(params);
/* nick already in use - need to change it .. */
- if (g_ascii_strcasecmp(server->nick, server->connrec->nick) == 0 &&
- server->connrec->alternate_nick != NULL &&
- g_ascii_strcasecmp(server->connrec->alternate_nick, server->nick) != 0) {
+ if (try_alternate_nick) {
/* first try, so try the alternative nick.. */
g_free(server->nick);
server->nick = g_strdup(server->connrec->alternate_nick);
From eb18904840cc7d4a6830bf0711f4682af50f1abc Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Fri, 5 Jan 2018 22:13:23 +0100
Subject: [PATCH 0151/1087] fix crash in notifylist
---
src/core/servers.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/core/servers.c b/src/core/servers.c
index b1da9b7e..0abfdfb0 100644
--- a/src/core/servers.c
+++ b/src/core/servers.c
@@ -524,7 +524,12 @@ int server_unref(SERVER_REC *server)
return TRUE;
}
- signal_emit("server destroyed", 1, server);
+ /* since module initialisation uses server connected, only let
+ them know that the object got destroyed if the server was
+ disconnected */
+ if (server->disconnected)
+ signal_emit("server destroyed", 1, server);
+
MODULE_DATA_DEINIT(server);
server_connect_unref(server->connrec);
if (server->rawlog != NULL) rawlog_destroy(server->rawlog);
From b111f038ddb7b5079f9901dd282fd4733390b1ba Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Fri, 5 Jan 2018 23:15:24 +0100
Subject: [PATCH 0152/1087] fix /exec -o for blank lines
since it is not allowed to send nothing, instead of spamming the status window
with error, send " " instead
Fixes FS#902
---
src/fe-common/core/fe-exec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/fe-common/core/fe-exec.c b/src/fe-common/core/fe-exec.c
index 36990866..c1739d39 100644
--- a/src/fe-common/core/fe-exec.c
+++ b/src/fe-common/core/fe-exec.c
@@ -613,7 +613,7 @@ static void sig_exec_input(PROCESS_REC *rec, const char *text)
str = g_strconcat(rec->target_nick ? "-nick " :
rec->target_channel ? "-channel " : "",
- rec->target, " ", text, NULL);
+ rec->target, " ", *text == '\0' ? " " : text, NULL);
signal_emit(rec->notice ? "command notice" : "command msg",
3, str, server, item);
g_free(str);
From 6e6a96d8c1eb8a51404d34809382e54eea46a9f7 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Fri, 5 Jan 2018 23:05:39 +0100
Subject: [PATCH 0153/1087] fix uaf in signal path
---
src/core/servers.c | 41 +++++++++++++++++++++++------------------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/src/core/servers.c b/src/core/servers.c
index 0abfdfb0..11eccc53 100644
--- a/src/core/servers.c
+++ b/src/core/servers.c
@@ -460,8 +460,6 @@ static int server_remove_channels(SERVER_REC *server)
void server_disconnect(SERVER_REC *server)
{
- int chans;
-
g_return_if_fail(IS_SERVER(server));
if (server->disconnected)
@@ -480,21 +478,9 @@ void server_disconnect(SERVER_REC *server)
server->disconnected = TRUE;
signal_emit("server disconnected", 1, server);
- /* close all channels */
- chans = server_remove_channels(server);
-
- if (server->handle != NULL) {
- if (!chans || server->connection_lost)
- net_sendbuffer_destroy(server->handle, TRUE);
- else {
- /* we were on some channels, try to let the server
- disconnect so that our quit message is guaranteed
- to get displayed */
- net_disconnect_later(net_sendbuffer_handle(server->handle));
- net_sendbuffer_destroy(server->handle, FALSE);
- }
- server->handle = NULL;
- }
+ /* we used to destroy the handle here but it may be still in
+ use during signal processing, so destroy it on unref
+ instead */
if (server->readtag > 0) {
g_source_remove(server->readtag);
@@ -513,6 +499,8 @@ void server_ref(SERVER_REC *server)
int server_unref(SERVER_REC *server)
{
+ int chans;
+
g_return_val_if_fail(IS_SERVER(server), FALSE);
if (--server->refcount > 0)
@@ -524,11 +512,28 @@ int server_unref(SERVER_REC *server)
return TRUE;
}
+ /* close all channels */
+ chans = server_remove_channels(server);
+
/* since module initialisation uses server connected, only let
them know that the object got destroyed if the server was
disconnected */
- if (server->disconnected)
+ if (server->disconnected) {
signal_emit("server destroyed", 1, server);
+ }
+
+ if (server->handle != NULL) {
+ if (!chans || server->connection_lost)
+ net_sendbuffer_destroy(server->handle, TRUE);
+ else {
+ /* we were on some channels, try to let the server
+ disconnect so that our quit message is guaranteed
+ to get displayed */
+ net_disconnect_later(net_sendbuffer_handle(server->handle));
+ net_sendbuffer_destroy(server->handle, FALSE);
+ }
+ server->handle = NULL;
+ }
MODULE_DATA_DEINIT(server);
server_connect_unref(server->connrec);
From 451019d05dfabbac2463f0d835c5113ac140c5c4 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Fri, 5 May 2017 14:45:13 +0200
Subject: [PATCH 0154/1087] make format_real_length left-collecting
---
src/fe-common/core/formats.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c
index 37db6f7c..4c819c2d 100644
--- a/src/fe-common/core/formats.c
+++ b/src/fe-common/core/formats.c
@@ -480,27 +480,30 @@ int format_real_length(const char *str, int len)
start = str;
tmp = g_string_new(NULL);
- while (*str != '\0' && len > 0) {
+ while (*str != '\0') {
+ oldstr = str;
if (*str == '%' && str[1] != '\0') {
str++;
if (*str != '%') {
adv = format_expand_styles(tmp, &str, NULL);
- str += adv;
- if (adv)
- continue;
- }
-
- /* %% or unknown %code, written as-is */
- if (*str != '%') {
- if (--len == 0)
- break;
+ if (adv) {
+ str += adv;
+ continue;
+ }
+ /* discount for unknown % */
+ if (--len < 0) {
+ str = oldstr;
+ break;
+ }
+ oldstr = str;
}
}
- oldstr = str;
len -= string_advance(&str, utf8);
- if (len < 0)
+ if (len < 0) {
str = oldstr;
+ break;
+ }
}
g_string_free(tmp, TRUE);
From 4e71a1f485d9a546cb92ad94e8918a2363a88b03 Mon Sep 17 00:00:00 2001
From: ailin-nemui
Date: Tue, 25 Apr 2017 00:42:53 +0200
Subject: [PATCH 0155/1087] sideways split support for Irssi
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!
---
docs/help/in/window.in | 15 +-
src/fe-common/core/fe-windows.h | 8 +
src/fe-common/core/window-commands.c | 7 +-
src/fe-common/core/window-items.c | 2 +-
src/fe-text/gui-printtext.c | 43 +-
src/fe-text/gui-printtext.h | 1 +
src/fe-text/gui-windows.c | 14 +-
src/fe-text/mainwindows-layout.c | 159 +++-
src/fe-text/mainwindows.c | 1144 +++++++++++++++++++++-----
src/fe-text/mainwindows.h | 22 +-
src/fe-text/module-formats.c | 4 +-
src/fe-text/statusbar-items.c | 19 +-
src/fe-text/statusbar.c | 72 +-
src/fe-text/statusbar.h | 6 +
src/fe-text/term-terminfo.c | 79 +-
src/fe-text/term.h | 2 +
src/fe-text/textbuffer-view.c | 120 +--
themes/default.theme | 1 +
18 files changed, 1373 insertions(+), 345 deletions(-)
diff --git a/docs/help/in/window.in b/docs/help/in/window.in
index 6dde6c50..0e7ed637 100644
--- a/docs/help/in/window.in
+++ b/docs/help/in/window.in
@@ -35,10 +35,19 @@
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.
@@ -46,6 +55,8 @@
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.
diff --git a/src/fe-common/core/fe-windows.h b/src/fe-common/core/fe-windows.h
index 32d6cfcd..aaa773c8 100644
--- a/src/fe-common/core/fe-windows.h
+++ b/src/fe-common/core/fe-windows.h
@@ -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;
diff --git a/src/fe-common/core/window-commands.c b/src/fe-common/core/window-commands.c
index 57c81ac2..a81c0180 100644
--- a/src/fe-common/core/window-commands.c
+++ b/src/fe-common/core/window-commands.c
@@ -169,7 +169,7 @@ 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;
@@ -177,8 +177,9 @@ static void cmd_window_new(const char *data, void *server, WI_ITEM_REC *item)
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);
diff --git a/src/fe-common/core/window-items.c b/src/fe-common/core/window-items.c
index bd6ae5e9..8eab7124 100644
--- a/src/fe-common/core/window-items.c
+++ b/src/fe-common/core/window-items.c
@@ -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 {
diff --git a/src/fe-text/gui-printtext.c b/src/fe-text/gui-printtext.c
index a07451fa..c52f9ced 100644
--- a/src/fe-text/gui-printtext.c
+++ b/src/fe-text/gui-printtext.c
@@ -24,6 +24,7 @@
#include "formats.h"
#include "printtext.h"
+#include "themes.h"
#include "term.h"
#include "gui-printtext.h"
@@ -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;
@@ -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;
}
diff --git a/src/fe-text/gui-printtext.h b/src/fe-text/gui-printtext.h
index d2671497..64595bbe 100644
--- a/src/fe-text/gui-printtext.h
+++ b/src/fe-text/gui-printtext.h
@@ -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
diff --git a/src/fe-text/gui-windows.c b/src/fe-text/gui-windows.c
index c63c495c..966c5138 100644
--- a/src/fe-text/gui-windows.c
+++ b/src/fe-text/gui-windows.c
@@ -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);
@@ -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);
diff --git a/src/fe-text/mainwindows-layout.c b/src/fe-text/mainwindows-layout.c
index fae02539..734c9acb 100644
--- a/src/fe-text/mainwindows-layout.c
+++ b/src/fe-text/mainwindows-layout.c
@@ -48,9 +48,9 @@ static void sig_layout_window_save(WINDOW_REC *window, CONFIG_NODE *node)
static void sig_layout_window_restore(WINDOW_REC *window, CONFIG_NODE *node)
{
WINDOW_REC *parent;
- GUI_WINDOW_REC *gui;
+ GUI_WINDOW_REC *gui;
- gui = WINDOW_GUI(window);
+ gui = WINDOW_GUI(window);
parent = window_find_refnum(config_node_get_int(node, "parent", -1));
if (parent != NULL)
@@ -61,7 +61,7 @@ static void sig_layout_window_restore(WINDOW_REC *window, CONFIG_NODE *node)
if (config_node_get_str(node, "scroll", NULL) != NULL) {
gui->use_scroll = TRUE;
gui->scroll = config_node_get_bool(node, "scroll", TRUE);
- textbuffer_view_set_scroll(gui->view, gui->scroll);
+ textbuffer_view_set_scroll(gui->view, gui->scroll);
}
}
@@ -74,6 +74,8 @@ static void main_window_save(MAIN_WINDOW_REC *window, CONFIG_NODE *node)
iconfig_node_set_int(node, "first_line", window->first_line);
iconfig_node_set_int(node, "lines", window->height);
+ iconfig_node_set_int(node, "first_column", window->first_column);
+ iconfig_node_set_int(node, "columns", window->width);
}
static void sig_layout_save(void)
@@ -88,8 +90,16 @@ static void sig_layout_save(void)
static int window_node_cmp(CONFIG_NODE *n1, CONFIG_NODE *n2)
{
- return config_node_get_int(n1, "first_line", 0) >
- config_node_get_int(n2, "first_line", 0) ? -1 : 1;
+ return (config_node_get_int(n1, "first_line", 0) ==
+ config_node_get_int(n2, "first_line", 0)
+ &&
+ config_node_get_int(n1, "first_column", 0) >
+ config_node_get_int(n2, "first_column", 0)
+ ) ||
+ config_node_get_int(n1, "first_line", 0) >
+ config_node_get_int(n2, "first_line", 0)
+ ? -1
+ : 1;
}
/* Returns list of mainwindow nodes sorted by first_line
@@ -108,14 +118,45 @@ static GSList *get_sorted_windows_config(CONFIG_NODE *node)
return output;
}
+static GSList *get_windows_config_filter_line(GSList *in)
+{
+ GSList *tmp, *output;
+
+ output = NULL;
+ for (tmp = in; tmp != NULL; tmp = tmp->next) {
+ CONFIG_NODE *node = tmp->data;
+ if (config_node_get_int(node, "first_column", 0) == 0)
+ output = g_slist_append(output, node);
+ }
+
+ return output;
+}
+
+static GSList *get_windows_config_filter_column(GSList *in, int first_line, int last_line)
+{
+ GSList *tmp, *output;
+
+ output = NULL;
+ for (tmp = in; tmp != NULL; tmp = tmp->next) {
+ int l1, l2;
+ CONFIG_NODE *node = tmp->data;
+ l1 = config_node_get_int(node, "first_line", -1);
+ l2 = l1 + config_node_get_int(node, "lines", 0) - 1;
+ if (l1 >= first_line && l2 <= last_line)
+ output = g_slist_prepend(output, node);
+ }
+
+ return output;
+}
+
static void sig_layout_restore(void)
{
- MAIN_WINDOW_REC *lower_window;
- WINDOW_REC *window;
+ MAIN_WINDOW_REC *lower_window;
+ WINDOW_REC *window, *first;
CONFIG_NODE *node;
- GSList *tmp, *sorted_config;
- int avail_height, height, *heights;
- int i, lower_size, windows_count, diff;
+ GSList *tmp, *sorted_config, *lines_config;
+ int avail_height, height, *heights, *widths, max_wins_line;
+ int i, lower_size, lines_count, columns_count, diff;
node = iconfig_node_traverse("mainwindows", FALSE);
if (node == NULL) return;
@@ -123,51 +164,56 @@ static void sig_layout_restore(void)
sorted_config = get_sorted_windows_config(node);
if (sorted_config == NULL) return;
- windows_count = g_slist_length(sorted_config);
+ lines_config = get_windows_config_filter_line(sorted_config);
+ lines_count = g_slist_length(lines_config);
- /* calculate the saved terminal height */
+ /* calculate the saved terminal height */
avail_height = term_height -
screen_reserved_top - screen_reserved_bottom;
height = 0;
- heights = g_new0(int, windows_count);
- for (i = 0, tmp = sorted_config; tmp != NULL; tmp = tmp->next, i++) {
+ heights = g_new0(int, lines_count);
+ for (i = 0, tmp = lines_config; tmp != NULL; tmp = tmp->next, i++) {
CONFIG_NODE *node = tmp->data;
- heights[i] = config_node_get_int(node, "lines", 0);
+ heights[i] = config_node_get_int(node, "lines", 0);
height += heights[i];
}
+ max_wins_line = (term_width + 1) / (NEW_WINDOW_WIDTH + 1);
+ if (max_wins_line < 1)
+ max_wins_line = 1;
+
if (avail_height <= (WINDOW_MIN_SIZE*2)+1) {
/* we can fit only one window to screen -
give it all the height we can */
- windows_count = 1;
- heights[0] = avail_height;
+ lines_count = 1;
+ heights[0] = avail_height;
} else if (height != avail_height) {
/* Terminal's height is different from the saved one.
Resize the windows so they fit to screen. */
while (height > avail_height &&
- windows_count*(WINDOW_MIN_SIZE+1) > avail_height) {
+ lines_count*(WINDOW_MIN_SIZE+1) > avail_height) {
/* all windows can't fit into screen,
remove the lowest ones */
- windows_count--;
+ lines_count--;
}
- /* try to keep the windows' size about the same in percents */
- for (i = 0; i < windows_count; i++) {
+ /* try to keep the windows' size about the same in percents */
+ for (i = 0; i < lines_count; i++) {
int size = avail_height*heights[i]/height;
if (size < WINDOW_MIN_SIZE+1)
- size = WINDOW_MIN_SIZE+1;
+ size = WINDOW_MIN_SIZE+1;
heights[i] = size;
}
/* give/remove the last bits */
- height = 0;
- for (i = 0; i < windows_count; i++)
- height += heights[i];
+ height = 0;
+ for (i = 0; i < lines_count; i++)
+ height += heights[i];
diff = height < avail_height ? 1 : -1;
for (i = 0; height != avail_height; i++) {
- if (i == windows_count)
+ if (i == lines_count)
i = 0;
if (heights[i] > WINDOW_MIN_SIZE+1) {
@@ -178,25 +224,59 @@ static void sig_layout_restore(void)
}
/* create all the visible windows with correct size */
- lower_window = NULL; lower_size = 0;
- for (i = 0, tmp = sorted_config; i < windows_count; tmp = tmp->next, i++) {
+ lower_window = NULL; lower_size = 0; first = NULL;
+ for (i = 0, tmp = lines_config; i < lines_count; tmp = tmp->next, i++) {
+ GSList *tmp2, *columns_config, *line;
+ int j, l1, l2;
CONFIG_NODE *node = tmp->data;
if (node->key == NULL) continue;
- /* create a new window + mainwindow */
- signal_emit("gui window create override", 1,
- GINT_TO_POINTER(0));
+ l1 = config_node_get_int(node, "first_line", -1);
+ l2 = l1 + config_node_get_int(node, "lines", 0) - 1;
+ columns_config = get_windows_config_filter_column(sorted_config, l1, l2);
- window = window_create(NULL, TRUE);
- window_set_refnum(window, atoi(node->key));
+ window = NULL; columns_count = 0;
+ widths = g_new0(int, max_wins_line);
+ for (j = 0, tmp2 = columns_config; j < max_wins_line && tmp2 != NULL; tmp2 = tmp2->next, j++) {
+ int width;
+ WINDOW_REC *new_win;
+ CONFIG_NODE *node2 = tmp2->data;
+ if (node2->key == NULL) continue;
+
+ /* create a new window + mainwindow */
+ signal_emit("gui window create override", 1,
+ GINT_TO_POINTER(window == NULL ? MAIN_WINDOW_TYPE_SPLIT : MAIN_WINDOW_TYPE_RSPLIT));
+
+ new_win = window_create(NULL, TRUE);
+
+ window_set_refnum(new_win, atoi(node2->key));
+ width = config_node_get_int(node2, "columns", NEW_WINDOW_WIDTH);
+ widths[j] = width;
+ columns_count += width + (window == NULL ? 0 : 1);
+
+ if (window == NULL)
+ window = new_win;
+ if (first == NULL)
+ first = new_win;
+
+ window_set_active(new_win);
+ active_mainwin = WINDOW_MAIN(new_win);
+ }
+ if (window == NULL)
+ continue;
+ line = g_slist_reverse(mainwindows_get_line(WINDOW_MAIN(window)));
+ for (j = g_slist_length(line), tmp2 = line; tmp2 != NULL; tmp2 = tmp2->next, j--) {
+ int width = MAX(NEW_WINDOW_WIDTH, widths[j-1] * term_width / columns_count);
+ MAIN_WINDOW_REC *rec = tmp2->data;
+ mainwindow_set_rsize(rec, width);
+ }
+ g_slist_free(line);
+ g_free(widths);
if (lower_size > 0)
mainwindow_set_size(lower_window, lower_size, FALSE);
- window_set_active(window);
- active_mainwin = WINDOW_MAIN(window);
-
- lower_window = WINDOW_MAIN(window);
+ lower_window = WINDOW_MAIN(window);
lower_size = heights[i];
if (lower_size < WINDOW_MIN_SIZE+1)
lower_size = WINDOW_MIN_SIZE+1;
@@ -206,6 +286,11 @@ static void sig_layout_restore(void)
if (lower_size > 0)
mainwindow_set_size(lower_window, lower_size, FALSE);
+
+ if (first != NULL) {
+ window_set_active(first);
+ active_mainwin = WINDOW_MAIN(first);
+ }
}
static void sig_layout_reset(void)
diff --git a/src/fe-text/mainwindows.c b/src/fe-text/mainwindows.c
index 5f58c25f..deab8de8 100644
--- a/src/fe-text/mainwindows.c
+++ b/src/fe-text/mainwindows.c
@@ -34,24 +34,27 @@
GSList *mainwindows;
MAIN_WINDOW_REC *active_mainwin;
+MAIN_WINDOW_BORDER_REC *clrtoeol_info;
int screen_reserved_top, screen_reserved_bottom;
-static int old_screen_width, old_screen_height;
+int screen_reserved_left, screen_reserved_right;
+static int screen_width, screen_height;
#define mainwindow_create_screen(window) \
- term_window_create(0, \
+ term_window_create((window)->first_column + (window)->statusbar_columns_left, \
(window)->first_line + (window)->statusbar_lines_top, \
- (window)->width, \
+ (window)->width - (window)->statusbar_columns, \
(window)->height - (window)->statusbar_lines)
#define mainwindow_set_screen_size(window) \
- term_window_move((window)->screen_win, 0, \
+ term_window_move((window)->screen_win, \
+ (window)->first_column + (window)->statusbar_columns_left, \
(window)->first_line + (window)->statusbar_lines_top, \
- (window)->width, \
+ (window)->width - (window)->statusbar_columns, \
(window)->height - (window)->statusbar_lines);
-static MAIN_WINDOW_REC *find_window_with_room(void)
+static MAIN_WINDOW_REC *find_window_with_room()
{
MAIN_WINDOW_REC *biggest_rec;
GSList *tmp;
@@ -71,14 +74,34 @@ static MAIN_WINDOW_REC *find_window_with_room(void)
return biggest_rec;
}
+static MAIN_WINDOW_REC *find_window_with_room_right(void)
+{
+ MAIN_WINDOW_REC *biggest_rec;
+ GSList *tmp;
+ int space, biggest;
+
+ biggest = 0; biggest_rec = NULL;
+ for (tmp = mainwindows; tmp != NULL; tmp = tmp->next) {
+ MAIN_WINDOW_REC *rec = tmp->data;
+
+ space = MAIN_WINDOW_TEXT_WIDTH(rec);
+ if (space >= 2 * NEW_WINDOW_WIDTH && space > biggest) {
+ biggest = space;
+ biggest_rec = rec;
+ }
+ }
+
+ return biggest_rec;
+}
+
#define window_size_equals(window, mainwin) \
- ((window)->width == (mainwin)->width && \
+ ((window)->width == MAIN_WINDOW_TEXT_WIDTH(mainwin) && \
(window)->height == MAIN_WINDOW_TEXT_HEIGHT(mainwin))
static void mainwindow_resize_windows(MAIN_WINDOW_REC *window)
{
GSList *tmp;
- int resized;
+ int resized;
mainwindow_set_screen_size(window);
@@ -89,24 +112,31 @@ static void mainwindow_resize_windows(MAIN_WINDOW_REC *window)
if (rec->gui_data != NULL &&
WINDOW_GUI(rec)->parent == window &&
!window_size_equals(rec, window)) {
- resized = TRUE;
- gui_window_resize(rec, window->width,
+ resized = TRUE;
+ gui_window_resize(rec, MAIN_WINDOW_TEXT_WIDTH(window),
MAIN_WINDOW_TEXT_HEIGHT(window));
}
}
- if (resized)
+ if (resized)
signal_emit("mainwindow resized", 1, window);
}
static void mainwindow_resize(MAIN_WINDOW_REC *window, int xdiff, int ydiff)
{
+ int height, width;
if (quitting || (xdiff == 0 && ydiff == 0))
- return;
+ return;
- window->width += xdiff;
+ height = window->height + ydiff;
+ width = window->width + xdiff;
+ window->width = window->last_column-window->first_column+1;
window->height = window->last_line-window->first_line+1;
- window->size_dirty = TRUE;
+ if (height != window->height || width != window->width) {
+ g_warning("Resizing window %p W:%d expected:%d H:%d expected:%d",
+ window, window->width, width, window->height, height);
+ }
+ window->size_dirty = TRUE;
}
static GSList *get_sticky_windows_sorted(MAIN_WINDOW_REC *mainwin)
@@ -178,14 +208,13 @@ void mainwindows_recreate(void)
}
}
-MAIN_WINDOW_REC *mainwindow_create(void)
+MAIN_WINDOW_REC *mainwindow_create(int right)
{
MAIN_WINDOW_REC *rec, *parent;
int space;
rec = g_new0(MAIN_WINDOW_REC, 1);
rec->dirty = TRUE;
- rec->width = term_width;
if (mainwindows == NULL) {
active_mainwin = rec;
@@ -193,21 +222,53 @@ MAIN_WINDOW_REC *mainwindow_create(void)
rec->first_line = screen_reserved_top;
rec->last_line = term_height-1 - screen_reserved_bottom;
rec->height = rec->last_line-rec->first_line+1;
+ rec->first_column = screen_reserved_left;
+ rec->last_column = screen_width-1 - screen_reserved_right;
+ rec->width = rec->last_column-rec->first_column+1;
} else {
parent = WINDOW_MAIN(active_win);
- if (MAIN_WINDOW_TEXT_HEIGHT(parent) <
- WINDOW_MIN_SIZE+NEW_WINDOW_SIZE)
- parent = find_window_with_room();
- if (parent == NULL)
- return NULL; /* not enough space */
- space = parent->height / 2;
- rec->first_line = parent->first_line;
- rec->last_line = rec->first_line + space;
- rec->height = rec->last_line-rec->first_line+1;
+ if (!right) {
+ GSList *tmp, *line;
+ if (MAIN_WINDOW_TEXT_HEIGHT(parent) <
+ WINDOW_MIN_SIZE+NEW_WINDOW_SIZE)
+ parent = find_window_with_room();
+ if (parent == NULL)
+ return NULL; /* not enough space */
- parent->first_line += space+1;
- mainwindow_resize(parent, 0, -space-1);
+ space = parent->height / 2;
+ rec->first_line = parent->first_line;
+ rec->last_line = rec->first_line + space;
+ rec->height = rec->last_line-rec->first_line+1;
+ rec->first_column = screen_reserved_left;
+ rec->last_column = screen_width-1 - screen_reserved_right;
+ rec->width = rec->last_column-rec->first_column+1;
+
+ line = mainwindows_get_line(parent);
+ for (tmp = line; tmp != NULL; tmp = tmp->next) {
+ MAIN_WINDOW_REC *rec = tmp->data;
+ rec->first_line += space+1;
+ mainwindow_resize(rec, 0, -space-1);
+ }
+ g_slist_free(line);
+ } else {
+ if (MAIN_WINDOW_TEXT_WIDTH(parent) <
+ 2* NEW_WINDOW_WIDTH)
+ parent = find_window_with_room_right();
+ if (parent == NULL)
+ return NULL; /* not enough space */
+
+ space = parent->width / 2;
+ rec->first_line = parent->first_line;
+ rec->last_line = parent->last_line;
+ rec->height = parent->height;
+ rec->first_column = parent->last_column - space + 1;
+ rec->last_column = parent->last_column;
+ rec->width = rec->last_column-rec->first_column+1;
+
+ parent->last_column -= space+1;
+ mainwindow_resize(parent, -space-1, 0);
+ }
}
rec->screen_win = mainwindow_create_screen(rec);
@@ -218,16 +279,22 @@ MAIN_WINDOW_REC *mainwindow_create(void)
return rec;
}
-static MAIN_WINDOW_REC *mainwindows_find_lower(int line)
+static MAIN_WINDOW_REC *mainwindows_find_lower(MAIN_WINDOW_REC *window)
{
+ int last_line;
MAIN_WINDOW_REC *best;
GSList *tmp;
+ if (window != NULL)
+ last_line = window->last_line;
+ else
+ last_line = -1;
+
best = NULL;
for (tmp = mainwindows; tmp != NULL; tmp = tmp->next) {
MAIN_WINDOW_REC *rec = tmp->data;
- if (rec->first_line > line &&
+ if (rec->first_line > last_line &&
(best == NULL || rec->first_line < best->first_line))
best = rec;
}
@@ -235,16 +302,64 @@ static MAIN_WINDOW_REC *mainwindows_find_lower(int line)
return best;
}
-static MAIN_WINDOW_REC *mainwindows_find_upper(int line)
+static MAIN_WINDOW_REC *mainwindows_find_right(MAIN_WINDOW_REC *window, int find_first)
{
+ int first_line, last_line, last_column;
MAIN_WINDOW_REC *best;
GSList *tmp;
+ if (window != NULL) {
+ first_line = window->first_line;
+ last_line = window->last_line;
+ last_column = window->last_column;
+ } else {
+ first_line = last_line = last_column = -1;
+ }
+
+ if (find_first)
+ last_column = -1;
+
best = NULL;
for (tmp = mainwindows; tmp != NULL; tmp = tmp->next) {
MAIN_WINDOW_REC *rec = tmp->data;
- if (rec->last_line < line &&
+ if (rec->first_line >= first_line &&
+ rec->last_line <= last_line &&
+ rec->first_column > last_column &&
+ (best == NULL || rec->first_column < best->first_column))
+ best = rec;
+ }
+
+ return best;
+}
+
+static MAIN_WINDOW_REC *mainwindows_find_lower_right(MAIN_WINDOW_REC *window)
+{
+ MAIN_WINDOW_REC *best;
+
+ best = mainwindows_find_right(window, FALSE);
+ if (best == NULL)
+ best = mainwindows_find_lower(window);
+
+ return best;
+}
+
+static MAIN_WINDOW_REC *mainwindows_find_upper(MAIN_WINDOW_REC *window)
+{
+ int first_line;
+ MAIN_WINDOW_REC *best;
+ GSList *tmp;
+
+ if (window != NULL)
+ first_line = window->first_line;
+ else
+ first_line = screen_height;
+
+ best = NULL;
+ for (tmp = mainwindows; tmp != NULL; tmp = tmp->next) {
+ MAIN_WINDOW_REC *rec = tmp->data;
+
+ if (rec->last_line < first_line &&
(best == NULL || rec->last_line > best->last_line))
best = rec;
}
@@ -252,27 +367,142 @@ static MAIN_WINDOW_REC *mainwindows_find_upper(int line)
return best;
}
-static void mainwindows_add_space(int first_line, int last_line)
+static MAIN_WINDOW_REC *mainwindows_find_left(MAIN_WINDOW_REC *window, int find_last)
+{
+ int first_line, last_line, first_column;
+ MAIN_WINDOW_REC *best;
+ GSList *tmp;
+
+ if (window != NULL) {
+ first_line = window->first_line;
+ last_line = window->last_line;
+ first_column = window->first_column;
+ } else {
+ first_line = last_line = screen_height;
+ first_column = screen_width;
+ }
+
+ if (find_last)
+ first_column = screen_width;
+
+ best = NULL;
+ for (tmp = mainwindows; tmp != NULL; tmp = tmp->next) {
+ MAIN_WINDOW_REC *rec = tmp->data;
+
+ if (rec->first_line >= first_line &&
+ rec->last_line <= last_line &&
+ rec->last_column < first_column &&
+ (best == NULL || rec->last_column > best->last_column))
+ best = rec;
+ }
+
+ return best;
+}
+
+static MAIN_WINDOW_REC *mainwindows_find_upper_left(MAIN_WINDOW_REC *window)
+{
+ MAIN_WINDOW_REC *best;
+
+ best = mainwindows_find_left(window, FALSE);
+ if (best == NULL)
+ best = mainwindows_find_upper(window);
+
+ return best;
+}
+
+static MAIN_WINDOW_REC *mainwindows_find_left_upper(MAIN_WINDOW_REC *window)
+{
+ MAIN_WINDOW_REC *best;
+
+ best = mainwindows_find_left(window, FALSE);
+ if (best == NULL)
+ best = mainwindows_find_left(mainwindows_find_upper(window), TRUE);
+
+ return best;
+}
+
+GSList *mainwindows_get_line(MAIN_WINDOW_REC *rec)
+{
+ MAIN_WINDOW_REC *win;
+ GSList *list;
+
+ list = NULL;
+
+ for (win = mainwindows_find_left(rec, FALSE);
+ win != NULL;
+ win = mainwindows_find_left(win, FALSE)) {
+ list = g_slist_append(list, win);
+ }
+
+ if (rec != NULL)
+ list = g_slist_append(list, rec);
+
+ for (win = mainwindows_find_right(rec, FALSE);
+ win != NULL;
+ win = mainwindows_find_right(win, FALSE)) {
+ list = g_slist_append(list, win);
+ }
+
+ return list;
+}
+
+/* add back the space which was occupied by destroyed mainwindow first_line .. last_line */
+static void mainwindows_add_space(MAIN_WINDOW_REC *destroy_win)
{
MAIN_WINDOW_REC *rec;
- int size;
+ int size, rsize;
- if (last_line < first_line)
+ if (destroy_win->last_line < destroy_win->first_line)
return;
- size = last_line-first_line+1;
+ if (destroy_win->last_column < destroy_win->first_column)
+ return;
- rec = mainwindows_find_lower(last_line);
+ rsize = destroy_win->last_column-destroy_win->first_column+1;
+ rec = mainwindows_find_left(destroy_win, FALSE);
if (rec != NULL) {
- rec->first_line = first_line;
- mainwindow_resize(rec, 0, size);
+ rec->last_column = destroy_win->last_column;
+ mainwindow_resize(rec, rsize+1, 0);
return;
}
- rec = mainwindows_find_upper(first_line);
+ rec = mainwindows_find_right(destroy_win, FALSE);
if (rec != NULL) {
- rec->last_line = last_line;
- mainwindow_resize(rec, 0, size);
+ rec->first_column = destroy_win->first_column;
+ mainwindow_resize(rec, rsize+1, 0);
+ return;
+ }
+
+ size = destroy_win->last_line-destroy_win->first_line+1;
+
+ rec = mainwindows_find_lower(destroy_win);
+ if (rec != NULL) {
+ GSList *tmp, *list;
+ list = mainwindows_get_line(rec);
+
+ for (tmp = list; tmp != NULL; tmp = tmp->next) {
+ MAIN_WINDOW_REC *rec = tmp->data;
+ rec->first_line = destroy_win->first_line;
+ mainwindow_resize(rec, 0, size);
+ }
+
+ g_slist_free(list);
+ return;
+ }
+
+ rec = mainwindows_find_upper(destroy_win);
+ if (rec != NULL) {
+ GSList *tmp, *list;
+ list = mainwindows_get_line(rec);
+
+ for (tmp = list; tmp != NULL; tmp = tmp->next) {
+ MAIN_WINDOW_REC *rec = tmp->data;
+ rec->last_line = destroy_win->last_line;
+ mainwindow_resize(rec, 0, size);
+ }
+
+ g_slist_free(list);
+ return;
}
}
@@ -302,8 +532,7 @@ void mainwindow_destroy(MAIN_WINDOW_REC *window)
if (mainwindows != NULL) {
gui_windows_remove_parent(window);
if (!quitting) {
- mainwindows_add_space(window->first_line,
- window->last_line);
+ mainwindows_add_space(window);
mainwindows_redraw();
}
}
@@ -313,6 +542,14 @@ void mainwindow_destroy(MAIN_WINDOW_REC *window)
if (active_mainwin == window) active_mainwin = NULL;
}
+void mainwindow_destroy_half(MAIN_WINDOW_REC *window)
+{
+ int really_quitting = quitting;
+ quitting = TRUE;
+ mainwindow_destroy(window);
+ quitting = really_quitting;
+}
+
void mainwindows_redraw(void)
{
GSList *tmp;
@@ -327,12 +564,20 @@ void mainwindows_redraw(void)
static int mainwindows_compare(MAIN_WINDOW_REC *w1, MAIN_WINDOW_REC *w2)
{
- return w1->first_line < w2->first_line ? -1 : 1;
+ return w1->first_line < w2->first_line ? -1
+ : w1->first_line > w2->first_line ? 1
+ : w1->first_column < w2->first_column ? -1
+ : w1->first_column > w2->first_column ? 1
+ : 0;
}
static int mainwindows_compare_reverse(MAIN_WINDOW_REC *w1, MAIN_WINDOW_REC *w2)
{
- return w1->first_line < w2->first_line ? 1 : -1;
+ return w1->first_line < w2->first_line ? 1
+ : w1->first_line > w2->first_line ? -1
+ : w1->first_column < w2->first_column ? 1
+ : w1->first_column > w2->first_column ? -1
+ : 0;
}
GSList *mainwindows_get_sorted(int reverse)
@@ -348,123 +593,235 @@ GSList *mainwindows_get_sorted(int reverse)
return list;
}
-static void mainwindows_resize_smaller(int xdiff, int ydiff)
+static void mainwindows_resize_smaller(int ydiff)
{
- MAIN_WINDOW_REC *rec;
+ MAIN_WINDOW_REC *rec;
GSList *sorted, *tmp;
- int space;
+ int space;
- sorted = mainwindows_get_sorted(TRUE);
+ sorted = NULL;
+ for (rec = mainwindows_find_lower(NULL);
+ rec != NULL;
+ rec = mainwindows_find_lower(rec)) {
+ sorted = g_slist_prepend(sorted, rec);
+ }
if (sorted == NULL)
return;
for (;;) {
+ int skip_active = FALSE;
space = 0;
- for (tmp = mainwindows; tmp != NULL; tmp = tmp->next) {
+ /* for each line of windows, calculate the space that can be reduced still */
+ for (tmp = sorted; tmp != NULL; tmp = tmp->next) {
+ int min;
+ GSList *line, *ltmp;
rec = tmp->data;
- space += MAIN_WINDOW_TEXT_HEIGHT(rec)-WINDOW_MIN_SIZE;
+ line = mainwindows_get_line(rec);
+ min = screen_height - ydiff;
+ for (ltmp = line; ltmp != NULL; ltmp = ltmp->next) {
+ int lmin;
+ MAIN_WINDOW_REC *win = ltmp->data;
+ if (win == active_mainwin && tmp == sorted)
+ skip_active = TRUE;
+
+ lmin = MAIN_WINDOW_TEXT_HEIGHT(win)-WINDOW_MIN_SIZE;
+ if (lmin < min)
+ min = lmin;
+ }
+ g_slist_free(line);
+ space += min;
}
if (space >= -ydiff)
break;
rec = sorted->data;
- if (rec == active_mainwin && sorted->next != NULL)
+ if (skip_active && sorted->next != NULL)
rec = sorted->next->data;
sorted = g_slist_remove(sorted, rec);
if (sorted != NULL) {
/* terminal is too small - destroy the
uppest window and try again */
- mainwindow_destroy(rec);
+ GSList *line, *ltmp;
+ line = mainwindows_get_line(rec);
+ for (ltmp = line; ltmp != NULL; ltmp = ltmp->next) {
+ MAIN_WINDOW_REC *win = ltmp->data;
+ mainwindow_destroy(win);
+ }
+ g_slist_free(line);
} else {
- /* only one window in screen.. just force the resize */
- rec->last_line += ydiff;
- mainwindow_resize(rec, xdiff, ydiff);
- return;
+ /* only one line of window in screen.. just force the resize */
+ GSList *line, *ltmp;
+ line = mainwindows_get_line(rec);
+ for (ltmp = line; ltmp != NULL; ltmp = ltmp->next) {
+ MAIN_WINDOW_REC *win = ltmp->data;
+ win->last_line += ydiff;
+ mainwindow_resize(win, 0, ydiff);
+ }
+ g_slist_free(line);
+ return;
}
}
/* resize windows that have space */
for (tmp = sorted; tmp != NULL && ydiff < 0; tmp = tmp->next) {
+ int min;
+ GSList *line, *ltmp;
+
rec = tmp->data;
+ line = mainwindows_get_line(rec);
+ min = screen_height - ydiff;
+ for (ltmp = line; ltmp != NULL; ltmp = ltmp->next) {
+ int lmin;
+ MAIN_WINDOW_REC *win = ltmp->data;
+ lmin = MAIN_WINDOW_TEXT_HEIGHT(win)-WINDOW_MIN_SIZE;
+ if (lmin < min)
+ min = lmin;
+ }
+ space = min;
- space = MAIN_WINDOW_TEXT_HEIGHT(rec)-WINDOW_MIN_SIZE;
if (space == 0) {
- mainwindow_resize(rec, xdiff, 0);
+ /* move the line */
+ for (ltmp = line; ltmp != NULL; ltmp = ltmp->next) {
+ MAIN_WINDOW_REC *win = ltmp->data;
+ mainwindow_resize(win, 0, 0);
+ win->size_dirty = TRUE;
+ win->first_line += ydiff;
+ win->last_line += ydiff;
+ signal_emit("mainwindow moved", 1, win);
+ }
+ } else {
+ if (space > -ydiff) space = -ydiff;
+ for (ltmp = line; ltmp != NULL; ltmp = ltmp->next) {
+ MAIN_WINDOW_REC *win = ltmp->data;
+ win->last_line += ydiff;
+ win->first_line += ydiff + space;
- rec->first_line += ydiff;
- rec->last_line += ydiff;
- signal_emit("mainwindow moved", 1, rec);
- continue;
- }
-
- if (space > -ydiff) space = -ydiff;
- rec->last_line += ydiff;
- ydiff += space;
- rec->first_line += ydiff;
-
- mainwindow_resize(rec, xdiff, -space);
- }
-
- if (xdiff != 0) {
- while (tmp != NULL) {
- mainwindow_resize(tmp->data, xdiff, 0);
- tmp = tmp->next;
+ mainwindow_resize(win, 0, -space);
+ }
+ ydiff += space;
}
+ g_slist_free(line);
}
g_slist_free(sorted);
}
-static void mainwindows_resize_bigger(int xdiff, int ydiff)
+static void mainwindows_rresize_line(int xdiff, MAIN_WINDOW_REC *win)
{
- GSList *sorted, *tmp;
+ int windows, i, extra_width, next_column, shrunk;
+ int *widths;
+ GSList *line, *tmp;
- sorted = mainwindows_get_sorted(FALSE);
- for (tmp = sorted; tmp != NULL; tmp = tmp->next) {
+ line = mainwindows_get_line(win);
+ windows = g_slist_length(line);
+ widths = g_new0(int, windows);
+
+ extra_width = screen_width - windows + 1;
+ for (tmp = line, i = 0; tmp != NULL; tmp = tmp->next, i++) {
MAIN_WINDOW_REC *rec = tmp->data;
-
- if (ydiff == 0 || tmp->next != NULL) {
- mainwindow_resize(rec, xdiff, 0);
- continue;
+ widths[i] = (MAIN_WINDOW_TEXT_WIDTH(rec) * (screen_width - windows + 1)) / (screen_width - xdiff - windows + 1);
+ extra_width -= widths[i] + rec->statusbar_columns;
+ }
+ shrunk = FALSE;
+ for (i = windows; extra_width < 0; i = i > 1 ? i - 1 : windows) {
+ if (widths[i-1] > NEW_WINDOW_WIDTH || (i == 1 && !shrunk)) {
+ widths[i-1]--;
+ extra_width++;
+ shrunk = i == 1;
}
-
- /* lowest window - give all the extra space for it */
- rec->last_line += ydiff;
- mainwindow_resize(rec, xdiff, ydiff);
}
- g_slist_free(sorted);
-}
-static void mainwindows_resize_horiz(int xdiff)
-{
- GSList *tmp;
+ next_column = 0;
- for (tmp = mainwindows; tmp != NULL; tmp = tmp->next) {
+#define extra ( (i >= screen_width % windows && i < extra_width + (screen_width % windows)) \
+ || i + windows < extra_width + (screen_width % windows) ? 1 : 0 )
+
+ for (tmp = line, i = 0; tmp != NULL; tmp = tmp->next, i++) {
MAIN_WINDOW_REC *rec = tmp->data;
-
- mainwindow_resize(rec, xdiff, 0);
+ rec->first_column = next_column;
+ rec->last_column = rec->first_column + widths[i] + rec->statusbar_columns + extra - 1;
+ next_column = rec->last_column + 2;
+ mainwindow_resize(rec, widths[i] + rec->statusbar_columns + extra - rec->width, 0);
+ rec->size_dirty = TRUE;
}
+#undef extra
+
+ g_free(widths);
+ g_slist_free(line);
}
void mainwindows_resize(int width, int height)
{
int xdiff, ydiff;
- xdiff = width-old_screen_width;
- ydiff = height-old_screen_height;
- old_screen_width = width;
- old_screen_height = height;
+ xdiff = width-screen_width;
+ ydiff = height-screen_height;
+ screen_width = width;
+ screen_height = height;
- if (ydiff < 0)
- mainwindows_resize_smaller(xdiff, ydiff);
- else if (ydiff > 0)
- mainwindows_resize_bigger(xdiff, ydiff);
- else if (xdiff != 0)
- mainwindows_resize_horiz(xdiff);
+ if (ydiff > 0) {
+ /* algorithm: enlarge bottom window */
+ MAIN_WINDOW_REC *rec;
+ GSList *line, *tmp;
+ line = mainwindows_get_line(mainwindows_find_upper(NULL));
+ for (tmp = line; tmp != NULL; tmp = tmp->next) {
+ rec = tmp->data;
+ rec->last_line += ydiff;
+ mainwindow_resize(rec, 0, ydiff);
+ }
+ g_slist_free(line);
+ }
- signal_emit("terminal resized", 0);
+ if (xdiff > 0) {
+ /* algorithm: distribute new space on each line */
+ MAIN_WINDOW_REC *win;
+
+ for (win = mainwindows_find_lower(NULL);
+ win != NULL;
+ win = mainwindows_find_lower(win)) {
+ mainwindows_rresize_line(xdiff, win);
+ }
+ }
+
+ if (xdiff < 0) {
+ /* algorithm: shrink each window,
+ destroy windows on the right if no room */
+ MAIN_WINDOW_REC *win;
+
+ for (win = mainwindows_find_lower(NULL);
+ win != NULL;
+ win = mainwindows_find_lower(win)) {
+ int max_windows, i, last_column;
+ GSList *line, *tmp;
+
+ line = mainwindows_get_line(win);
+ max_windows = (screen_width + 1) / (NEW_WINDOW_WIDTH + 1);
+ if (max_windows < 1)
+ max_windows = 1;
+ last_column = screen_width - 1;
+ for (tmp = line, i = 0; tmp != NULL; tmp = tmp->next, i++) {
+ MAIN_WINDOW_REC *rec = tmp->data;
+ if (i >= max_windows)
+ mainwindow_destroy_half(rec);
+ else
+ last_column = rec->last_column;
+ }
+ win = line->data;
+ g_slist_free(line);
+
+ mainwindows_rresize_line(screen_width - last_column + 1, win);
+ }
+ }
+
+ if (ydiff < 0) {
+ /* algorithm: shrink windows starting from bottom,
+ destroy windows starting from top if no room */
+ mainwindows_resize_smaller(ydiff);
+ }
+
+ signal_emit("terminal resized", 0);
irssi_redraw();
}
@@ -474,31 +831,37 @@ int mainwindows_reserve_lines(int top, int bottom)
MAIN_WINDOW_REC *window;
int ret;
- ret = -1;
+ ret = -1;
if (top != 0) {
+ GSList *list, *tmp;
g_return_val_if_fail(top > 0 || screen_reserved_top > top, -1);
ret = screen_reserved_top;
screen_reserved_top += top;
- window = mainwindows_find_lower(-1);
- if (window != NULL) {
+ list = mainwindows_get_line(mainwindows_find_lower(NULL));
+ for (tmp = list; tmp != NULL; tmp = tmp->next) {
+ window = tmp->data;
window->first_line += top;
mainwindow_resize(window, 0, -top);
}
+ g_slist_free(list);
}
if (bottom != 0) {
+ GSList *list, *tmp;
g_return_val_if_fail(bottom > 0 || screen_reserved_bottom > bottom, -1);
ret = screen_reserved_bottom;
screen_reserved_bottom += bottom;
- window = mainwindows_find_upper(term_height);
- if (window != NULL) {
+ list = mainwindows_get_line(mainwindows_find_upper(NULL));
+ for (tmp = list; tmp != NULL; tmp = tmp->next) {
+ window = tmp->data;
window->last_line -= bottom;
mainwindow_resize(window, 0, -bottom);
}
+ g_slist_free(list);
}
return ret;
@@ -528,47 +891,109 @@ int mainwindow_set_statusbar_lines(MAIN_WINDOW_REC *window,
return ret;
}
-static void mainwindows_resize_two(MAIN_WINDOW_REC *grow_win,
- MAIN_WINDOW_REC *shrink_win, int count)
+static void mainwindows_resize_two(GSList *grow_list,
+ GSList *shrink_list, int count)
{
- irssi_set_dirty();
+ GSList *tmp;
+ MAIN_WINDOW_REC *win;
- mainwindow_resize(grow_win, 0, count);
- mainwindow_resize(shrink_win, 0, -count);
- grow_win->dirty = TRUE;
- shrink_win->dirty = TRUE;
+ irssi_set_dirty();
+
+ for (tmp = shrink_list; tmp != NULL; tmp = tmp->next) {
+ win = tmp->data;
+ mainwindow_resize(win, 0, -count);
+ win->dirty = TRUE;
+ }
+ for (tmp = grow_list; tmp != NULL; tmp = tmp->next) {
+ win = tmp->data;
+ mainwindow_resize(win, 0, count);
+ win->dirty = TRUE;
+ }
}
static int try_shrink_lower(MAIN_WINDOW_REC *window, int count)
{
MAIN_WINDOW_REC *shrink_win;
- shrink_win = mainwindows_find_lower(window->last_line);
- if (shrink_win != NULL &&
- MAIN_WINDOW_TEXT_HEIGHT(shrink_win)-count >= WINDOW_MIN_SIZE) {
- window->last_line += count;
- shrink_win->first_line += count;
- mainwindows_resize_two(window, shrink_win, count);
- return TRUE;
+ shrink_win = mainwindows_find_lower(window);
+ if (shrink_win != NULL) {
+ int ok;
+ GSList *shrink_list, *tmp;
+ MAIN_WINDOW_REC *win;
+
+ ok = TRUE;
+ shrink_list = mainwindows_get_line(shrink_win);
+
+ for (tmp = shrink_list; tmp != NULL; tmp = tmp->next) {
+ win = tmp->data;
+ if (MAIN_WINDOW_TEXT_HEIGHT(win)-count < WINDOW_MIN_SIZE) {
+ ok = FALSE;
+ break;
+ }
+ }
+ if (ok) {
+ GSList *grow_list;
+ grow_list = mainwindows_get_line(window);
+
+ for (tmp = shrink_list; tmp != NULL; tmp = tmp->next) {
+ win = tmp->data;
+ win->first_line += count;
+ }
+ for (tmp = grow_list; tmp != NULL; tmp = tmp->next) {
+ win = tmp->data;
+ win->last_line += count;
+ }
+
+ mainwindows_resize_two(grow_list, shrink_list, count);
+ g_slist_free(grow_list);
+ }
+
+ g_slist_free(shrink_list);
+ return ok;
}
- return FALSE;
+ return FALSE;
}
static int try_shrink_upper(MAIN_WINDOW_REC *window, int count)
{
MAIN_WINDOW_REC *shrink_win;
- shrink_win = mainwindows_find_upper(window->first_line);
- if (shrink_win != NULL &&
- MAIN_WINDOW_TEXT_HEIGHT(shrink_win)-count >= WINDOW_MIN_SIZE) {
- window->first_line -= count;
- shrink_win->last_line -= count;
- mainwindows_resize_two(window, shrink_win, count);
- return TRUE;
+ shrink_win = mainwindows_find_upper(window);
+ if (shrink_win != NULL) {
+ int ok;
+ GSList *shrink_list, *tmp;
+ MAIN_WINDOW_REC *win;
+
+ ok = TRUE;
+ shrink_list = mainwindows_get_line(shrink_win);
+
+ for (tmp = shrink_list; tmp != NULL; tmp = tmp->next) {
+ win = tmp->data;
+ if (MAIN_WINDOW_TEXT_HEIGHT(win)-count < WINDOW_MIN_SIZE) {
+ ok = FALSE;
+ break;
+ }
+ }
+ if (ok) {
+ GSList *grow_list;
+ grow_list = mainwindows_get_line(window);
+ for (tmp = grow_list; tmp != NULL; tmp = tmp->next) {
+ win = tmp->data;
+ win->first_line -= count;
+ }
+ for (tmp = shrink_list; tmp != NULL; tmp = tmp->next) {
+ win = tmp->data;
+ win->last_line -= count;
+ }
+ mainwindows_resize_two(grow_list, shrink_list, count);
+ g_slist_free(grow_list);
+ }
+ g_slist_free(shrink_list);
+ return ok;
}
- return FALSE;
+ return FALSE;
}
static int mainwindow_grow(MAIN_WINDOW_REC *window, int count,
@@ -588,28 +1013,52 @@ static int try_grow_lower(MAIN_WINDOW_REC *window, int count)
{
MAIN_WINDOW_REC *grow_win;
- grow_win = mainwindows_find_lower(window->last_line);
+ grow_win = mainwindows_find_lower(window);
if (grow_win != NULL) {
- window->last_line -= count;
- grow_win->first_line -= count;
- mainwindows_resize_two(grow_win, window, count);
+ MAIN_WINDOW_REC *win;
+ GSList *grow_list, *shrink_list, *tmp;
+ grow_list = mainwindows_get_line(grow_win);
+ shrink_list = mainwindows_get_line(window);
+ for (tmp = grow_list; tmp != NULL; tmp = tmp->next) {
+ win = tmp->data;
+ win->first_line -= count;
+ }
+ for (tmp = shrink_list; tmp != NULL; tmp = tmp->next) {
+ win = tmp->data;
+ win->last_line -= count;
+ }
+ mainwindows_resize_two(grow_list, shrink_list, count);
+ g_slist_free(shrink_list);
+ g_slist_free(grow_list);
}
- return grow_win != NULL;
+ return grow_win != NULL;
}
static int try_grow_upper(MAIN_WINDOW_REC *window, int count)
{
MAIN_WINDOW_REC *grow_win;
- grow_win = mainwindows_find_upper(window->first_line);
+ grow_win = mainwindows_find_upper(window);
if (grow_win != NULL) {
- window->first_line += count;
- grow_win->last_line += count;
- mainwindows_resize_two(grow_win, window, count);
+ MAIN_WINDOW_REC *win;
+ GSList *grow_list, *shrink_list, *tmp;
+ grow_list = mainwindows_get_line(grow_win);
+ shrink_list = mainwindows_get_line(window);
+ for (tmp = grow_list; tmp != NULL; tmp = tmp->next) {
+ win = tmp->data;
+ win->last_line += count;
+ }
+ for (tmp = shrink_list; tmp != NULL; tmp = tmp->next) {
+ win = tmp->data;
+ win->first_line += count;
+ }
+ mainwindows_resize_two(grow_list, shrink_list, count);
+ g_slist_free(shrink_list);
+ g_slist_free(grow_list);
}
- return grow_win != NULL;
+ return grow_win != NULL;
}
static int mainwindow_shrink(MAIN_WINDOW_REC *window, int count, int resize_lower)
@@ -627,6 +1076,109 @@ static int mainwindow_shrink(MAIN_WINDOW_REC *window, int count, int resize_lowe
return TRUE;
}
+static void mainwindows_rresize_two(MAIN_WINDOW_REC *grow_win,
+ MAIN_WINDOW_REC *shrink_win, int count)
+{
+ irssi_set_dirty();
+
+ mainwindow_resize(grow_win, count, 0);
+ mainwindow_resize(shrink_win, -count, 0);
+ grow_win->dirty = TRUE;
+ shrink_win->dirty = TRUE;
+}
+
+static int try_rshrink_right(MAIN_WINDOW_REC *window, int count)
+{
+ MAIN_WINDOW_REC *shrink_win;
+
+ shrink_win = mainwindows_find_right(window, FALSE);
+ if (shrink_win != NULL) {
+ if (MAIN_WINDOW_TEXT_WIDTH(shrink_win)-count < NEW_WINDOW_WIDTH) {
+ return FALSE;
+ }
+
+ shrink_win->first_column += count;
+ window->last_column += count;
+
+ mainwindows_rresize_two(window, shrink_win, count);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static int try_rshrink_left(MAIN_WINDOW_REC *window, int count)
+{
+ MAIN_WINDOW_REC *shrink_win;
+
+ shrink_win = mainwindows_find_left(window, FALSE);
+ if (shrink_win != NULL) {
+ if (MAIN_WINDOW_TEXT_WIDTH(shrink_win)-count < NEW_WINDOW_WIDTH) {
+ return FALSE;
+ }
+ window->first_column -= count;
+ shrink_win->last_column -= count;
+
+ mainwindows_rresize_two(window, shrink_win, count);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static int mainwindow_rgrow(MAIN_WINDOW_REC *window, int count)
+{
+ if (!try_rshrink_right(window, count)) {
+ if (!try_rshrink_left(window, count))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static int try_rgrow_right(MAIN_WINDOW_REC *window, int count)
+{
+ MAIN_WINDOW_REC *grow_win;
+
+ grow_win = mainwindows_find_right(window, FALSE);
+ if (grow_win != NULL) {
+ grow_win->first_column -= count;
+ window->last_column -= count;
+ mainwindows_rresize_two(grow_win, window, count);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static int try_rgrow_left(MAIN_WINDOW_REC *window, int count)
+{
+ MAIN_WINDOW_REC *grow_win;
+
+ grow_win = mainwindows_find_left(window, FALSE);
+ if (grow_win != NULL) {
+ grow_win->last_column += count;
+ window->first_column += count;
+ mainwindows_rresize_two(grow_win, window, count);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static int mainwindow_rshrink(MAIN_WINDOW_REC *window, int count)
+{
+ if (MAIN_WINDOW_TEXT_WIDTH(window)-count < NEW_WINDOW_WIDTH)
+ return FALSE;
+
+ if (!try_rgrow_right(window, count)) {
+ if (!try_rgrow_left(window, count))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/* Change the window height - the height includes the lines needed for
statusbars. If resize_lower is TRUE, the lower window is first tried
to be resized instead of upper window. */
@@ -639,6 +1191,15 @@ void mainwindow_set_size(MAIN_WINDOW_REC *window, int height, int resize_lower)
mainwindow_grow(window, height, resize_lower);
}
+void mainwindow_set_rsize(MAIN_WINDOW_REC *window, int width)
+{
+ width -= window->width;
+ if (width < 0)
+ mainwindow_rshrink(window, -width);
+ else
+ mainwindow_rgrow(window, width);
+}
+
void mainwindows_redraw_dirty(void)
{
GSList *tmp;
@@ -707,35 +1268,52 @@ static void cmd_window_size(const char *data)
/* SYNTAX: WINDOW BALANCE */
static void cmd_window_balance(void)
{
- GSList *sorted, *tmp;
+ GSList *sorted, *stmp, *line, *ltmp;
int avail_size, unit_size, bigger_units;
int windows, last_line, old_size;
+ MAIN_WINDOW_REC *win;
windows = g_slist_length(mainwindows);
if (windows == 1) return;
+ sorted = NULL;
+ windows = 0;
+ for (win = mainwindows_find_lower(NULL);
+ win != NULL;
+ win = mainwindows_find_lower(win)) {
+ windows++;
+ sorted = g_slist_append(sorted, win);
+ }
+
avail_size = term_height - screen_reserved_top-screen_reserved_bottom;
unit_size = avail_size/windows;
bigger_units = avail_size%windows;
- sorted = mainwindows_get_sorted(FALSE);
- last_line = screen_reserved_top;
- for (tmp = sorted; tmp != NULL; tmp = tmp->next) {
- MAIN_WINDOW_REC *rec = tmp->data;
+ last_line = screen_reserved_top;
+ for (stmp = sorted; stmp != NULL; stmp = stmp->next) {
+ win = stmp->data;
+ line = mainwindows_get_line(win);
- old_size = rec->height;
- rec->first_line = last_line;
- rec->last_line = rec->first_line + unit_size-1;
+ for (ltmp = line; ltmp != NULL; ltmp = ltmp->next) {
+ MAIN_WINDOW_REC *rec = ltmp->data;
+ old_size = rec->height;
+ rec->first_line = last_line;
+ rec->last_line = rec->first_line + unit_size-1;
- if (bigger_units > 0) {
- rec->last_line++;
- bigger_units--;
+ if (bigger_units > 0) {
+ rec->last_line++;
+ }
+
+ rec->height = rec->last_line-rec->first_line+1;
+
+ mainwindow_resize(rec, 0, rec->height-old_size);
}
+ if (line != NULL && bigger_units > 0) {
+ bigger_units--;
+ }
+ last_line = win->last_line+1;
- rec->height = rec->last_line-rec->first_line+1;
- last_line = rec->last_line+1;
-
- mainwindow_resize(rec, 0, rec->height-old_size);
+ g_slist_free(line);
}
g_slist_free(sorted);
@@ -769,29 +1347,30 @@ static void cmd_window_hide(const char *data)
return;
if (WINDOW_MAIN(window)->sticky_windows) {
- printformat_window(active_win, MSGLEVEL_CLIENTERROR,
- TXT_CANT_HIDE_STICKY_WINDOWS);
- return;
+ if (!settings_get_bool("autounstick_windows")) {
+ printformat_window(active_win, MSGLEVEL_CLIENTERROR,
+ TXT_CANT_HIDE_STICKY_WINDOWS);
+ return;
+ }
}
mainwindow_destroy(WINDOW_MAIN(window));
if (active_mainwin == NULL) {
active_mainwin = WINDOW_MAIN(active_win);
- window_set_active(active_mainwin->active);
+ window_set_active(active_mainwin->active);
}
}
-/* SYNTAX: WINDOW SHOW | */
-static void cmd_window_show(const char *data)
+static void _cmd_window_show_opt(const char *data, int right)
{
- MAIN_WINDOW_REC *parent;
+ MAIN_WINDOW_REC *parent;
WINDOW_REC *window;
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
if (is_numeric(data, '\0')) {
- window = window_find_refnum(atoi(data));
+ window = window_find_refnum(atoi(data));
if (window == NULL) {
printformat_window(active_win, MSGLEVEL_CLIENTERROR,
TXT_REFNUM_NOT_FOUND, data);
@@ -804,30 +1383,150 @@ static void cmd_window_show(const char *data)
return;
if (WINDOW_GUI(window)->sticky) {
- printformat_window(active_win, MSGLEVEL_CLIENTERROR,
- TXT_CANT_SHOW_STICKY_WINDOWS);
- return;
+ if (!settings_get_bool("autounstick_windows")) {
+ printformat_window(active_win, MSGLEVEL_CLIENTERROR,
+ TXT_CANT_SHOW_STICKY_WINDOWS);
+ return;
+ }
}
- parent = mainwindow_create();
+ parent = mainwindow_create(right);
parent->active = window;
- gui_window_reparent(window, parent);
+ gui_window_reparent(window, parent);
if (settings_get_bool("autostick_split_windows"))
- gui_window_set_sticky(window);
+ gui_window_set_sticky(window);
active_mainwin = NULL;
window_set_active(window);
}
+/* SYNTAX: WINDOW SHOW | */
+static void cmd_window_show(const char *data)
+{
+ _cmd_window_show_opt(data, FALSE);
+}
+
+/* SYNTAX: WINDOW RSHOW | */
+static void cmd_window_rshow(const char *data)
+{
+ _cmd_window_show_opt(data, TRUE);
+}
+
+/* SYNTAX: WINDOW RGROW [] */
+static void cmd_window_rgrow(const char *data)
+{
+ int count;
+
+ count = *data == '\0' ? 1 : atoi(data);
+ if (!mainwindow_rgrow(WINDOW_MAIN(active_win), count)) {
+ printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
+ TXT_WINDOW_TOO_SMALL);
+ }
+}
+
+/* SYNTAX: WINDOW RSHRINK [] */
+static void cmd_window_rshrink(const char *data)
+{
+ int count;
+
+ count = *data == '\0' ? 1 : atoi(data);
+ if (!mainwindow_rshrink(WINDOW_MAIN(active_win), count)) {
+ printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
+ TXT_WINDOW_TOO_SMALL);
+ }
+}
+
+/* SYNTAX: WINDOW RSIZE */
+static void cmd_window_rsize(const char *data)
+{
+ char rsizestr[MAX_INT_STRLEN];
+ int rsize;
+
+ if (!is_numeric(data, 0)) return;
+ rsize = atoi(data);
+
+ rsize -= MAIN_WINDOW_TEXT_WIDTH(WINDOW_MAIN(active_win));
+ if (rsize == 0) return;
+
+ ltoa(rsizestr, rsize < 0 ? -rsize : rsize);
+ if (rsize < 0)
+ cmd_window_rshrink(rsizestr);
+ else
+ cmd_window_rgrow(rsizestr);
+}
+
+/* SYNTAX: WINDOW RBALANCE */
+static void cmd_window_rbalance(void)
+{
+ GSList *line, *ltmp;
+ int avail_width, unit_width, bigger_units;
+ int windows, last_column, old_width;
+ MAIN_WINDOW_REC *win;
+
+ line = mainwindows_get_line(WINDOW_MAIN(active_win));
+ windows = g_slist_length(line);
+ if (windows == 1) {
+ g_slist_free(line);
+ return;
+ }
+
+ avail_width = term_width - screen_reserved_left-screen_reserved_right - windows + 1;
+ unit_width = avail_width/windows;
+ bigger_units = avail_width%windows;
+
+ last_column = screen_reserved_left;
+ for (ltmp = line; ltmp != NULL; ltmp = ltmp->next) {
+ win = ltmp->data;
+ old_width = win->width;
+ win->first_column = last_column;
+ win->last_column = win->first_column + unit_width-1;
+
+ if (bigger_units > 0) {
+ win->last_column++;
+ bigger_units--;
+ }
+
+ mainwindow_resize(win, win->last_column - win->first_column + 1 - old_width, 0);
+ last_column = win->last_column+2;
+ }
+ g_slist_free(line);
+
+ mainwindows_redraw();
+}
+
/* SYNTAX: WINDOW UP */
static void cmd_window_up(void)
{
MAIN_WINDOW_REC *rec;
- rec = mainwindows_find_upper(active_mainwin->first_line);
+ rec = mainwindows_find_left_upper(active_mainwin);
if (rec == NULL)
- rec = mainwindows_find_upper(term_height);
+ rec = mainwindows_find_left_upper(NULL);
+ if (rec != NULL)
+ window_set_active(rec->active);
+}
+
+/* SYNTAX: WINDOW DUP */
+static void cmd_window_dup(void)
+{
+ MAIN_WINDOW_REC *rec;
+
+ rec = mainwindows_find_upper(active_mainwin);
+ if (rec == NULL)
+ rec = mainwindows_find_upper(NULL);
+ if (rec != NULL)
+ window_set_active(rec->active);
+}
+
+/* SYNTAX: WINDOW DLEFT */
+static void cmd_window_dleft(void)
+{
+ MAIN_WINDOW_REC *rec;
+
+ rec = mainwindows_find_left(active_mainwin, FALSE);
+ if (rec == NULL)
+ rec = mainwindows_find_left(active_mainwin, TRUE);
if (rec != NULL)
window_set_active(rec->active);
}
@@ -837,9 +1536,33 @@ static void cmd_window_down(void)
{
MAIN_WINDOW_REC *rec;
- rec = mainwindows_find_lower(active_mainwin->last_line);
+ rec = mainwindows_find_lower_right(active_mainwin);
if (rec == NULL)
- rec = mainwindows_find_lower(-1);
+ rec = mainwindows_find_lower_right(NULL);
+ if (rec != NULL)
+ window_set_active(rec->active);
+}
+
+/* SYNTAX: WINDOW DDOWN */
+static void cmd_window_ddown(void)
+{
+ MAIN_WINDOW_REC *rec;
+
+ rec = mainwindows_find_lower(active_mainwin);
+ if (rec == NULL)
+ rec = mainwindows_find_lower(NULL);
+ if (rec != NULL)
+ window_set_active(rec->active);
+}
+
+/* SYNTAX: WINDOW DRIGHT */
+static void cmd_window_dright(void)
+{
+ MAIN_WINDOW_REC *rec;
+
+ rec = mainwindows_find_right(active_mainwin, FALSE);
+ if (rec == NULL)
+ rec = mainwindows_find_right(active_mainwin, TRUE);
if (rec != NULL)
window_set_active(rec->active);
}
@@ -997,13 +1720,37 @@ static void cmd_window_move_right(void)
window_set_refnum(active_win, refnum);
}
+/* SYNTAX: WINDOW MOVE DLEFT */
+static void cmd_window_move_dleft(void)
+{
+ MAIN_WINDOW_REC *rec;
+
+ rec = mainwindows_find_left(active_mainwin, FALSE);
+ if (rec == NULL)
+ rec = mainwindows_find_left(active_mainwin, TRUE);
+ if (rec != NULL)
+ window_reparent(active_win, rec);
+}
+
+/* SYNTAX: WINDOW MOVE DRIGHT */
+static void cmd_window_move_dright(void)
+{
+ MAIN_WINDOW_REC *rec;
+
+ rec = mainwindows_find_right(active_mainwin, FALSE);
+ if (rec == NULL)
+ rec = mainwindows_find_right(active_mainwin, TRUE);
+ if (rec != NULL)
+ window_reparent(active_win, rec);
+}
+
/* SYNTAX: WINDOW MOVE UP */
static void cmd_window_move_up(void)
{
MAIN_WINDOW_REC *rec;
- rec = mainwindows_find_upper(active_mainwin->first_line);
- if (rec != NULL)
+ rec = mainwindows_find_upper_left(active_mainwin);
+ if (rec != NULL)
window_reparent(active_win, rec);
}
@@ -1012,7 +1759,7 @@ static void cmd_window_move_down(void)
{
MAIN_WINDOW_REC *rec;
- rec = mainwindows_find_lower(active_mainwin->last_line);
+ rec = mainwindows_find_lower_right(active_mainwin);
if (rec != NULL)
window_reparent(active_win, rec);
}
@@ -1058,12 +1805,14 @@ static void sig_window_print_info(WINDOW_REC *win)
void mainwindows_init(void)
{
- old_screen_width = term_width;
- old_screen_height = term_height;
+ screen_width = term_width;
+ screen_height = term_height;
mainwindows = NULL;
active_mainwin = NULL;
+ clrtoeol_info = g_new0(MAIN_WINDOW_BORDER_REC, 1);
screen_reserved_top = screen_reserved_bottom = 0;
+ screen_reserved_left = screen_reserved_right = 0;
command_bind("window grow", NULL, (SIGNAL_FUNC) cmd_window_grow);
command_bind("window shrink", NULL, (SIGNAL_FUNC) cmd_window_shrink);
@@ -1075,18 +1824,30 @@ void mainwindows_init(void)
command_bind("window down", NULL, (SIGNAL_FUNC) cmd_window_down);
command_bind("window left", NULL, (SIGNAL_FUNC) cmd_window_left);
command_bind("window right", NULL, (SIGNAL_FUNC) cmd_window_right);
+ command_bind("window dup", NULL, (SIGNAL_FUNC) cmd_window_dup);
+ command_bind("window ddown", NULL, (SIGNAL_FUNC) cmd_window_ddown);
+ command_bind("window dleft", NULL, (SIGNAL_FUNC) cmd_window_dleft);
+ command_bind("window dright", NULL, (SIGNAL_FUNC) cmd_window_dright);
command_bind("window stick", NULL, (SIGNAL_FUNC) cmd_window_stick);
command_bind("window move left", NULL, (SIGNAL_FUNC) cmd_window_move_left);
command_bind("window move right", NULL, (SIGNAL_FUNC) cmd_window_move_right);
command_bind("window move up", NULL, (SIGNAL_FUNC) cmd_window_move_up);
command_bind("window move down", NULL, (SIGNAL_FUNC) cmd_window_move_down);
- signal_add("window print info", (SIGNAL_FUNC) sig_window_print_info);
+ command_bind("window move dleft", NULL, (SIGNAL_FUNC) cmd_window_move_dleft);
+ command_bind("window move dright", NULL, (SIGNAL_FUNC) cmd_window_move_dright);
+ command_bind("window rgrow", NULL, (SIGNAL_FUNC) cmd_window_rgrow);
+ command_bind("window rshrink", NULL, (SIGNAL_FUNC) cmd_window_rshrink);
+ command_bind("window rsize", NULL, (SIGNAL_FUNC) cmd_window_rsize);
+ command_bind("window rbalance", NULL, (SIGNAL_FUNC) cmd_window_rbalance);
+ command_bind("window rshow", NULL, (SIGNAL_FUNC) cmd_window_rshow);
+ signal_add("window print info", (SIGNAL_FUNC) sig_window_print_info);
}
void mainwindows_deinit(void)
{
while (mainwindows != NULL)
mainwindow_destroy(mainwindows->data);
+ g_free(clrtoeol_info);
command_unbind("window grow", (SIGNAL_FUNC) cmd_window_grow);
command_unbind("window shrink", (SIGNAL_FUNC) cmd_window_shrink);
@@ -1098,10 +1859,21 @@ void mainwindows_deinit(void)
command_unbind("window down", (SIGNAL_FUNC) cmd_window_down);
command_unbind("window left", (SIGNAL_FUNC) cmd_window_left);
command_unbind("window right", (SIGNAL_FUNC) cmd_window_right);
+ command_unbind("window dup", (SIGNAL_FUNC) cmd_window_dup);
+ command_unbind("window ddown", (SIGNAL_FUNC) cmd_window_ddown);
+ command_unbind("window dleft", (SIGNAL_FUNC) cmd_window_dleft);
+ command_unbind("window dright", (SIGNAL_FUNC) cmd_window_dright);
command_unbind("window stick", (SIGNAL_FUNC) cmd_window_stick);
command_unbind("window move left", (SIGNAL_FUNC) cmd_window_move_left);
command_unbind("window move right", (SIGNAL_FUNC) cmd_window_move_right);
command_unbind("window move up", (SIGNAL_FUNC) cmd_window_move_up);
command_unbind("window move down", (SIGNAL_FUNC) cmd_window_move_down);
- signal_remove("window print info", (SIGNAL_FUNC) sig_window_print_info);
+ command_unbind("window move dleft", (SIGNAL_FUNC) cmd_window_move_dleft);
+ command_unbind("window move dright", (SIGNAL_FUNC) cmd_window_move_dright);
+ command_unbind("window rgrow", (SIGNAL_FUNC) cmd_window_rgrow);
+ command_unbind("window rshrink", (SIGNAL_FUNC) cmd_window_rshrink);
+ command_unbind("window rsize", (SIGNAL_FUNC) cmd_window_rsize);
+ command_unbind("window rbalance", (SIGNAL_FUNC) cmd_window_rbalance);
+ command_unbind("window rshow", (SIGNAL_FUNC) cmd_window_rshow);
+ signal_remove("window print info", (SIGNAL_FUNC) sig_window_print_info);
}
diff --git a/src/fe-text/mainwindows.h b/src/fe-text/mainwindows.h
index 1bca333d..414275bf 100644
--- a/src/fe-text/mainwindows.h
+++ b/src/fe-text/mainwindows.h
@@ -5,36 +5,48 @@
#include "term.h"
#define WINDOW_MIN_SIZE 2
+#define NEW_WINDOW_WIDTH 10
#define MAIN_WINDOW_TEXT_HEIGHT(window) \
((window)->height-(window)->statusbar_lines)
+#define MAIN_WINDOW_TEXT_WIDTH(window) \
+ ((window)->width-(window)->statusbar_columns)
+
typedef struct {
WINDOW_REC *active;
TERM_WINDOW *screen_win;
- int sticky_windows; /* number of sticky windows */
+ int sticky_windows; /* number of sticky windows */
int first_line, last_line; /* first/last line used by this window (0..x) (includes statusbars) */
+ int first_column, last_column; /* first/last column used by this window (0..x) (includes statusbars) */
int width, height; /* width/height of the window (includes statusbars) */
GSList *statusbars;
- int statusbar_lines_top;
- int statusbar_lines_bottom;
+ int statusbar_lines_top, statusbar_lines_bottom;
int statusbar_lines; /* top+bottom */
+ int statusbar_columns_left, statusbar_columns_right;
+ int statusbar_columns; /* left+right */
unsigned int dirty:1; /* This window needs a redraw */
unsigned int size_dirty:1; /* We'll need to resize the window, but haven't got around doing it just yet. */
} MAIN_WINDOW_REC;
+typedef struct {
+ char *color;
+ TERM_WINDOW *window;
+} MAIN_WINDOW_BORDER_REC;
+
extern GSList *mainwindows;
extern MAIN_WINDOW_REC *active_mainwin;
+extern MAIN_WINDOW_BORDER_REC *clrtoeol_info;
extern int screen_reserved_top, screen_reserved_bottom;
void mainwindows_init(void);
void mainwindows_deinit(void);
-MAIN_WINDOW_REC *mainwindow_create(void);
+MAIN_WINDOW_REC *mainwindow_create(int);
void mainwindow_destroy(MAIN_WINDOW_REC *window);
void mainwindows_redraw(void);
@@ -45,6 +57,7 @@ void mainwindows_recreate(void);
to be resized instead of upper window. */
void mainwindow_set_size(MAIN_WINDOW_REC *window, int height,
int resize_lower);
+void mainwindow_set_rsize(MAIN_WINDOW_REC *window, int width);
void mainwindows_resize(int width, int height);
void mainwindow_change_active(MAIN_WINDOW_REC *mainwin,
@@ -56,5 +69,6 @@ int mainwindow_set_statusbar_lines(MAIN_WINDOW_REC *window,
void mainwindows_redraw_dirty(void);
GSList *mainwindows_get_sorted(int reverse);
+GSList *mainwindows_get_line(MAIN_WINDOW_REC *rec);
#endif
diff --git a/src/fe-text/module-formats.c b/src/fe-text/module-formats.c
index c4606197..c37d5c62 100644
--- a/src/fe-text/module-formats.c
+++ b/src/fe-text/module-formats.c
@@ -41,8 +41,8 @@ FORMAT_REC gui_text_formats[] =
{ "refnum_not_found", "Window number $0 not found", 1, { 0 } },
{ "window_too_small", "Not enough room to resize this window", 0 },
{ "cant_hide_last", "You can't hide the last window", 0 },
- { "cant_hide_sticky_windows", "You can't hide sticky windows (use /WINDOW STICK OFF)", 0 },
- { "cant_show_sticky_windows", "You can't show sticky windows (use /WINDOW STICK OFF)", 0 },
+ { "cant_hide_sticky_windows", "You can't hide sticky windows (use /SET autounstick_windows ON)", 0 },
+ { "cant_show_sticky_windows", "You can't show sticky windows (use /SET autounstick_windows ON)", 0 },
{ "window_not_sticky", "Window is not sticky", 0 },
{ "window_set_sticky", "Window set sticky", 0 },
{ "window_unset_sticky", "Window is not sticky anymore", 0 },
diff --git a/src/fe-text/statusbar-items.c b/src/fe-text/statusbar-items.c
index c7d6bcfb..5740a40b 100644
--- a/src/fe-text/statusbar-items.c
+++ b/src/fe-text/statusbar-items.c
@@ -418,7 +418,7 @@ static void item_input(SBAR_ITEM_REC *item, int get_size_only)
rec = g_hash_table_lookup(input_entries, item->bar->config->name);
if (rec == NULL) {
- rec = gui_entry_create(item->xpos, item->bar->real_ypos,
+ rec = gui_entry_create(ITEM_WINDOW_REAL_XPOS(item), item->bar->real_ypos,
item->size, term_type == TERM_TYPE_UTF8);
gui_entry_set_active(rec);
g_hash_table_insert(input_entries,
@@ -426,12 +426,21 @@ static void item_input(SBAR_ITEM_REC *item, int get_size_only)
}
if (get_size_only) {
- item->min_size = 2+term_width/10;
- item->max_size = term_width;
- return;
+ int max_width;
+ WINDOW_REC *window;
+
+ window = item->bar->parent_window != NULL
+ ? item->bar->parent_window->active
+ : NULL;
+
+ max_width = window != NULL ? window->width : term_width;
+
+ item->min_size = 2+max_width/10;
+ item->max_size = max_width;
+ return;
}
- gui_entry_move(rec, item->xpos, item->bar->real_ypos,
+ gui_entry_move(rec, ITEM_WINDOW_REAL_XPOS(item), item->bar->real_ypos,
item->size);
gui_entry_redraw(rec); /* FIXME: this is only necessary with ^L.. */
}
diff --git a/src/fe-text/statusbar.c b/src/fe-text/statusbar.c
index f0dff828..40837eea 100644
--- a/src/fe-text/statusbar.c
+++ b/src/fe-text/statusbar.c
@@ -242,17 +242,24 @@ static void statusbar_resize_items(STATUSBAR_REC *bar, int max_width)
static void statusbar_calc_item_positions(STATUSBAR_REC *bar)
{
- WINDOW_REC *old_active_win;
+ WINDOW_REC *window;
+ WINDOW_REC *old_active_win;
GSList *tmp, *right_items;
int xpos, rxpos;
+ int max_width;
old_active_win = active_win;
- if (bar->parent_window != NULL)
+ if (bar->parent_window != NULL)
active_win = bar->parent_window->active;
- statusbar_resize_items(bar, term_width);
+ window = bar->parent_window != NULL
+ ? bar->parent_window->active
+ : NULL;
- /* left-aligned items */
+ max_width = window != NULL ? window->width : term_width;
+ statusbar_resize_items(bar, max_width);
+
+ /* left-aligned items */
xpos = 0;
for (tmp = bar->items; tmp != NULL; tmp = tmp->next) {
SBAR_ITEM_REC *rec = tmp->data;
@@ -260,11 +267,11 @@ static void statusbar_calc_item_positions(STATUSBAR_REC *bar)
if (!rec->config->right_alignment &&
(rec->size > 0 || rec->current_size > 0)) {
if (SBAR_ITEM_REDRAW_NEEDED(bar, rec, xpos)) {
- /* redraw the item */
+ /* redraw the item */
rec->dirty = TRUE;
if (bar->dirty_xpos == -1 ||
xpos < bar->dirty_xpos) {
- irssi_set_dirty();
+ irssi_set_dirty();
bar->dirty = TRUE;
bar->dirty_xpos = xpos;
}
@@ -277,12 +284,12 @@ static void statusbar_calc_item_positions(STATUSBAR_REC *bar)
/* right-aligned items - first copy them to a new list backwards,
easier to draw them in right order */
- right_items = NULL;
+ right_items = NULL;
for (tmp = bar->items; tmp != NULL; tmp = tmp->next) {
SBAR_ITEM_REC *rec = tmp->data;
if (rec->config->right_alignment) {
- if (rec->size > 0)
+ if (rec->size > 0)
right_items = g_slist_prepend(right_items, rec);
else if (rec->current_size > 0 &&
(bar->dirty_xpos == -1 ||
@@ -291,12 +298,12 @@ static void statusbar_calc_item_positions(STATUSBAR_REC *bar)
to begin from the item's old xpos */
irssi_set_dirty();
bar->dirty = TRUE;
- bar->dirty_xpos = rec->xpos;
+ bar->dirty_xpos = rec->xpos;
}
}
}
- rxpos = term_width;
+ rxpos = max_width;
for (tmp = right_items; tmp != NULL; tmp = tmp->next) {
SBAR_ITEM_REC *rec = tmp->data;
@@ -312,7 +319,7 @@ static void statusbar_calc_item_positions(STATUSBAR_REC *bar)
rec->xpos = rxpos;
}
}
- g_slist_free(right_items);
+ g_slist_free(right_items);
active_win = old_active_win;
}
@@ -451,8 +458,13 @@ static void mainwindow_recalc_ypos(MAIN_WINDOW_REC *window, int placement)
static void sig_mainwindow_resized(MAIN_WINDOW_REC *window)
{
- mainwindow_recalc_ypos(window, STATUSBAR_TOP);
- mainwindow_recalc_ypos(window, STATUSBAR_BOTTOM);
+ GSList *tmp;
+ mainwindow_recalc_ypos(window, STATUSBAR_TOP);
+ mainwindow_recalc_ypos(window, STATUSBAR_BOTTOM);
+ for (tmp = window->statusbars; tmp != NULL; tmp = tmp->next) {
+ STATUSBAR_REC *bar = tmp->data;
+ statusbar_redraw(bar, TRUE);
+ }
}
STATUSBAR_REC *statusbar_create(STATUSBAR_GROUP_REC *group,
@@ -728,7 +740,7 @@ void statusbar_item_default_handler(SBAR_ITEM_REC *item, int get_size_only,
g_string_append_c(out, ' ');
}
- gui_printtext(item->xpos, item->bar->real_ypos, out->str);
+ gui_printtext(ITEM_WINDOW_REAL_XPOS(item), item->bar->real_ypos, out->str);
g_string_free(out, TRUE);
}
g_free(tmpstr);
@@ -960,20 +972,42 @@ void statusbar_item_destroy(SBAR_ITEM_REC *item)
g_free(item);
}
+static MAIN_WINDOW_BORDER_REC *set_border_info(STATUSBAR_REC *bar)
+{
+ MAIN_WINDOW_BORDER_REC *orig_border, *new_border;
+ orig_border = clrtoeol_info;
+ new_border = g_new0(MAIN_WINDOW_BORDER_REC, 1);
+ new_border->window = bar->parent_window != NULL ? bar->parent_window->screen_win : NULL;
+ new_border->color = bar->color;
+ clrtoeol_info = new_border;
+ return orig_border;
+}
+
+static void restore_border_info(MAIN_WINDOW_BORDER_REC *border_info)
+{
+ MAIN_WINDOW_BORDER_REC *old_border;
+ old_border = clrtoeol_info;
+ clrtoeol_info = border_info;
+ g_free(old_border);
+}
+
static void statusbar_redraw_needed_items(STATUSBAR_REC *bar)
{
- WINDOW_REC *old_active_win;
+ WINDOW_REC *old_active_win;
GSList *tmp;
char *str;
old_active_win = active_win;
- if (bar->parent_window != NULL)
+ if (bar->parent_window != NULL)
active_win = bar->parent_window->active;
if (bar->dirty_xpos >= 0) {
+ MAIN_WINDOW_BORDER_REC *orig_border;
+ orig_border = set_border_info(bar);
str = g_strconcat(bar->color, "%>", NULL);
- gui_printtext(bar->dirty_xpos, bar->real_ypos, str);
+ gui_printtext(BAR_WINDOW_REAL_DIRTY_XPOS(bar), bar->real_ypos, str);
g_free(str);
+ restore_border_info(orig_border);
}
for (tmp = bar->items; tmp != NULL; tmp = tmp->next) {
@@ -982,13 +1016,13 @@ static void statusbar_redraw_needed_items(STATUSBAR_REC *bar)
if (rec->dirty ||
(bar->dirty_xpos != -1 &&
rec->xpos >= bar->dirty_xpos)) {
- rec->current_size = rec->size;
+ rec->current_size = rec->size;
rec->func(rec, FALSE);
rec->dirty = FALSE;
}
}
- active_win = old_active_win;
+ active_win = old_active_win;
}
void statusbar_redraw_dirty(void)
diff --git a/src/fe-text/statusbar.h b/src/fe-text/statusbar.h
index 309294b0..b0048cc4 100644
--- a/src/fe-text/statusbar.h
+++ b/src/fe-text/statusbar.h
@@ -23,6 +23,12 @@ typedef struct SBAR_ITEM_REC SBAR_ITEM_REC;
#define STATUSBAR_VISIBLE_ACTIVE 2
#define STATUSBAR_VISIBLE_INACTIVE 3
+#define ITEM_WINDOW_REAL_XPOS(item) ( ( (item)->bar->parent_window != NULL ? \
+ (item)->bar->parent_window->first_column + (item)->bar->parent_window->statusbar_columns_left : 0 ) + (item)->xpos )
+
+#define BAR_WINDOW_REAL_DIRTY_XPOS(bar) ( ( (bar)->parent_window != NULL ? \
+ (bar)->parent_window->first_column + (bar)->parent_window->statusbar_columns_left : 0 ) + (bar)->dirty_xpos )
+
typedef struct {
char *name;
GSList *config_bars;
diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c
index 6645cfb0..0b2c7cb0 100644
--- a/src/fe-text/term-terminfo.c
+++ b/src/fe-text/term-terminfo.c
@@ -23,6 +23,7 @@
#include "term.h"
#include "terminfo-core.h"
#include "fe-windows.h"
+#include "gui-printtext.h"
#include "utf8.h"
#include