TODO (in no particular order):
---------------------------
Cleaner separation between the ui (draw.c) and everything else:
	- ccur and navigation between channels are all function of the ui
	- stateful ui related things are functions of the ui, eg:
		- buffer scrollback
		- input bar framing
		- channel bar framing

Implement a mesg.c test framework before adding new message types, then:
----------------------
	/TOPIC [message]
		set/get channel topic

	/HELP [type]
		show available commands.
		if [type] is given, show more specific help

	/NICKS
		print the current nicks to the channel
		^(Also print this implicitly when end of nicks numeric is received)
		^(Also print server's ignore list for '/ignore' and '/unignore')

	Numerics:
	221 +<flags> :(null)
		 returned when MODE <current nick> is sent

	351 reply from server for /version
		 on freenode it sends me 005...

	401 no such nick or channel (eg /version <unknown nick>)

	402 no such server

	403 :no such channel (Getting this from privmsg sometimes)

	409 :No origin specified, (eg "/raw PING")

	435 cannot change nickname while banned
		(eg unregistered in channel and trying to /nick)

	441 <user> <channel> :They're not on that channel
		(eg kick a user not in the channel)

	442 <channel> :You're not on that channel

	451 :Connection not registered
		(eg sending a join before registering)

	461 <CMD>   :Syntax error  ... from "/nick" or "/join"

	470 <chan1> <chan2> :forwarding to another channel

	482 <channel> :You're not the channel operator

	501:Unknown mode "<flag>"

	502 :Can't set/get mode for other users
		 (e.g.: /raw MODE <not my nick> <flag>
----------------------

Buffer scrollback improvements:
	- full page scrollback
		- set to topmost line if it doesn't print in full, else the line before it
	- currently scrollback is still allowed if it doesnt affect the content of the page,
	  eg: a half full buffer, which prevents the scrollback pointer from being updated as
	  more input is receieved. If the content of the current page won't change, don't
	  allow the scrollback.
	- show scrollback % or x/y lines in the status bar

When connection is lost before ping timeout, disconnect, reconnect
and /connect errs out read: Connection reset by peer

Keep state of tab complete for successively getting the next nick lexicographically

Make sure all the thread related code is using thread-safe functions,
and that proper cancellation points are used. Make sure no resources
can be left hanging (eg: sockets left open when a thread is canceled?)

A configuration file and parser

Parsing 004/005 numeric for server specific configuration

buffer logging

Nickserv stuff

colorize output by linetype

Fix the channel colouring on various status events

Tests for all the send_*, recv_* handlers
	- split all the handlers out into mesg.c and move all net unrelated functions into
	  ui.c so they can be mocked in test cases. Ideally the only interface to mesg.c
	  would be send_mesg & recv_mesg
	- ui.c and draw.c would be separate; draw.c is strictly responsible for drawing to stdout,
	  while ui.c is responsible for all stateful user interactions

Allow for multiple connections passed as cli args

Reimplement the pasting stuff that was broken

link detection/launching

FIXME:
---------------------------
connection reset by peer:
 - was at about 220s latency, attempted to send something, assuming remote peer
   already reset the connection
 - errno = ECONNRESET

I broke the activity colouring stuff:
	join/part/quit sets activity (it shouldnt)
	message and ping dont set activity (they should)

Some servers place single args in the trailing section, eg: JOIN :channel vs JOIN channel
which forces the handlers to check p->params and p->trailing, however since p->params
is set to NULL in this case, the result is strtok(NULL, " "), so strtok attemps to continue
parsing whatever it last parsed. Instead, a function like strsep should be implemented
which correctly handles NULL input in this case

If in ##channel that requires authentication (ie bumps you to ##channel-unauthorized
or similar), /disconnect, /connect, rirc attempts to join ##channel, can't, and is
bumped to ##channel-unauthorized, but ##channel buffer remains open and not flagged
as parted, ie could potentially send messages to the channel, but won't receive any
	- or it returns 403, and cant /join the channel because it's not parted

use the alternate screen buffer to restore screen when rirc exits

##linux ~ cannot send to channel
-- cannot send to '##linux - cannot send to channel'
:::and on each message
	ERR_ERRONEUSNICKNAME: nick is null

when erroneous nickname on connect (eg too long) goes into infinite loop


MAYBE (Probably never):
---------------------------
For input pastes that exceed some defined limit, offer a third option:
	post to, for example, pastebin, and send the url to channel

Client/daemon mode:
	with -d, --daemon mode, rirc stays open in the background
	when the user closes the client. draw()s are ignored, etc.
	when a client connects to the daemon, send SIGWINCH, open pipes, etc
