aboutsummaryrefslogtreecommitdiff
path: root/src/cmd.c
blob: c187bb98edac9b4824956402fd3e25ead6d6ebb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <atari.h>
#include <stdio.h>
#include "irc.h"
#include "addrs.h"
#include "screen.h"

/* A "command" is actually anything the user types, whether or
   not it starts with a /character. */

void cmd_chan_text(const char *cmd) {
	char s;

	s = scr_getbyname(channel);
	scr_activate(s);

	/* 0x02 = ^B = enable bold */
	scr_print_active("\x02<");
	scr_print_active(usernick);
	if(!s) {
		scr_print_active("/");
		scr_print_active(channel);
	}
	scr_print_active(">\x02 ");

	txbuf_set_str("PRIVMSG ");
	txbuf_append_str(channel);
	txbuf_append_str(" :");
	txbuf_append_str(cmd);
	txbuf_send();
}

void cmd_command(const char *cmd) {
	if(*cmd == '/')
		txbuf_send_str(cmd + 1);
	else if(channel[0])
		cmd_chan_text(cmd);
	else scr_print_current("*** You are not on a channel\n");
}

void cmd_execute(void) {
	cmd_command(edit_box);
}