~rcr/rirc

ref: 7ca2a99a605b7e0b88fa85bc43a8fadc13695ba8 rirc/src/state.h -rw-r--r-- 1.7 KiB
7ca2a99a — Richard Robbins refactor order of includes 1 year, 2 months ago
                                                                                
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
#ifndef STATE_H
#define STATE_H

#include "src/components/buffer.h"
#include "src/components/channel.h"
#include "src/components/server.h"

#define FROM_INFO "--"
#define FROM_ERROR "-!!-"
#define FROM_UNKNOWN "-\?\?-"
#define FROM_JOIN ">>"
#define FROM_NICK "--"
#define FROM_PART "<<"
#define FROM_QUIT "<<"

#define server_info(S, ...) \
	do { newlinef((S)->channel, BUFFER_LINE_SERVER_INFO, FROM_INFO, __VA_ARGS__); } while (0)

#define server_error(S, ...) \
	do { newlinef((S)->channel, BUFFER_LINE_SERVER_ERROR, FROM_ERROR, __VA_ARGS__); } while (0)

#define server_unknown(S, ...) \
	do { newlinef((S)->channel, BUFFER_LINE_SERVER_ERROR, FROM_UNKNOWN, __VA_ARGS__); } while (0)

int state_server_set_chans(struct server*, const char*);

struct channel* current_channel(void);

struct server_list* state_server_list(void);

void state_init(void);
void state_term(void);

// TODO: most of this stuff can be static
//TODO: move to channel.c, function of server's channel list
/* Useful state retrieval abstractions */
struct channel* channel_get_first(void);
struct channel* channel_get_last(void);
struct channel* channel_get_next(struct channel*);
struct channel* channel_get_prev(struct channel*);

/* FIXME: */
void buffer_scrollback_back(struct channel*);
void buffer_scrollback_forw(struct channel*);
void channel_clear(struct channel*);

void channel_close(struct channel*);
void channel_move_prev(void);
void channel_move_next(void);
void channel_set_current(struct channel*);

void newlinef(struct channel*, enum buffer_line_t, const char*, const char*, ...);
void newline(struct channel*, enum buffer_line_t, const char*, const char*);

extern char *action_message;

#endif