Moved silc_client_ch[u]mode[_char] to client library from silc/.
[silc.git] / apps / silc / screen.h
1 /*
2
3   screen.h
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6
7   Copyright (C) 1997 - 2000 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13   
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18
19 */
20
21 #ifndef SCREEN_H
22 #define SCREEN_H
23
24 typedef struct {
25   char *mode;
26   char *nickname;
27   char *connection;
28   char *channel;
29   char *channel_mode;
30   int away;
31 } *SilcScreenBottomLine;
32
33 typedef struct {
34   /* Status line window top of the screen */
35   WINDOW *upper_stat_line;
36
37   /* Output windows */
38   WINDOW **output_win;
39   WINDOW **output_stat_line;
40   unsigned int output_win_count;
41
42   /* Input window at the bottom of the screen */
43   WINDOW *input_win;
44   unsigned char *input_buffer;
45   unsigned int input_pos;
46   unsigned int input_end;
47   unsigned int cursor_pos;
48   int virtual_window;
49
50   /* Bottom line on screen */
51   SilcScreenBottomLine bottom_line;
52
53   /* On/off flag for insert */
54   int insert;
55
56   /* XXX */
57   struct upper_status_line {
58     const char *program_name;
59     const char *program_version;
60   } u_stat_line;
61
62 } SilcScreenObject;
63
64 typedef SilcScreenObject *SilcScreen;
65
66 /* Size of the input window. User can type this many characters into
67    the window. After that no more characters may be added into the 
68    window. */
69 #define SILC_SCREEN_INPUT_WIN_SIZE 1024
70
71 /* Maximum length of nickaname that will be shown on the screen */
72 #define SILC_SCREEN_MAX_NICK_LEN 16
73
74 /* Maximum length of channel name that will be shown on the screen */
75 #define SILC_SCREEN_MAX_CHANNEL_LEN 20
76
77 /* Maximum length of connection name that will be shown on the screen */
78 #define SILC_SCREEN_MAX_CONN_LEN 20
79
80 /* Macros */
81
82 /* Macro used to insert typed character into the buffer. The character
83    is not added at the end of the buffer but somewhere in between. */
84 #define SILC_SCREEN_INPUT_INSERT(__x, __y, __ch, __end) \
85 do {                                                    \
86   unsigned char __tmp[SILC_SCREEN_INPUT_WIN_SIZE + 1];  \
87   memcpy(__tmp, &(__x)[(__y)], (__end) - (__y));        \
88   (__x)[(__y)] = __ch;                                  \
89   memcpy(&(__x)[(__y) + 1], __tmp, (__end) - (__y));    \
90 } while(0)
91
92 /* Macro used to delete character from the buffer. The character
93    is not removed from the end of the buffer but somewhere in between. */
94 #define SILC_SCREEN_INPUT_DELETE(__x, __y, __end)       \
95 do {                                                    \
96   unsigned char __tmp[SILC_SCREEN_INPUT_WIN_SIZE + 1];  \
97   memcpy(__tmp, &(__x)[(__y) + 1], (__end));            \
98   memset(&(__x)[(__y)], 0, (__end) - (__y) + 1);        \
99   memcpy(&(__x)[(__y)], __tmp, strlen(__tmp));          \
100 } while(0)
101
102 /* Prototypes */
103 SilcScreen silc_screen_init();
104 WINDOW *silc_screen_create_output_window(SilcScreen screen);
105 WINDOW *silc_screen_add_output_window(SilcScreen screen);
106 void silc_screen_create_input_window(SilcScreen screen);
107 void silc_screen_init_upper_status_line(SilcScreen screen);
108 void silc_screen_print_upper_stat_line(SilcScreen screen);
109 void silc_screen_init_output_status_line(SilcScreen screen);
110 void silc_screen_print_clock(SilcScreen screen);
111 void silc_screen_print_coordinates(SilcScreen screen, int win_index);
112 void silc_screen_print_bottom_line(SilcScreen screen, int win_index);
113 void silc_screen_refresh_all(SilcScreen screen);
114 void silc_screen_refresh_win(WINDOW *win);
115 void silc_screen_input_reset(SilcScreen screen);
116 void silc_screen_input_backspace(SilcScreen screen);
117 void silc_screen_input_insert(SilcScreen screen);
118 void silc_screen_input_cursor_right(SilcScreen screen);
119 void silc_screen_input_cursor_left(SilcScreen screen);
120 void silc_screen_input_cursor_home(SilcScreen screen);
121 void silc_screen_input_cursor_end(SilcScreen screen);
122 void silc_screen_input_print(SilcScreen screen, unsigned char c);
123 void silc_screen_input_print_prompt(SilcScreen screen, char *prompt);
124
125 #endif