aboutsummaryrefslogtreecommitdiff
path: root/src/cmd.c
blob: d9abc8712cc36ef111208b17bc5a56e15a80bf88 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#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. */

static char *target;
static const char *command;
static char slashcmd[10];
static char *slasharg;

static void cmd_chan_text(void) {
	char s;

	scr_activate(scr_current);

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

	txbuf_set_str("PRIVMSG ");
	txbuf_append_str(target);
	txbuf_append_str(" :");
	txbuf_append_str(command);
	txbuf_send();
}

static void cmd_slash(void) {
	txbuf_send_str(command + 1);
}

void cmd_command(const char *cmd) {
	command = cmd;

	target = scr_get_cur_name();

	if(*cmd == '/')
		cmd_slash();
	else if(target)
		cmd_chan_text();
	else scr_print_current("*** You are not in a channel\n");
}

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