Projects : yrc : yrc_completion
1 | Record types |
2 | ============ |
3 | |
4 | conn |
5 | - network: file-safe str |
6 | - sock: socket |
7 | - rdbuf: str |
8 | - wrbuf: str |
9 | - addrs: non-empty list of (host: str, port: int) (first entry is current) |
10 | - nick: str |
11 | - password: str | None |
12 | - registered: bool |
13 | - channels: dict of (channel: casemapped str) => (set of nick: casemapped str) |
14 | - casemapper: function of (str -> casemapped str) |
15 | - reconn_delay: int |
16 | - count: int (number of times connected) |
17 | - ping_ts: float (monotonic time of last sent ping) |
18 | - pong_ts: float (monotonic time of last received pong) |
19 | |
20 | buf |
21 | - name: str |
22 | - parent: buf |
23 | - title: str |
24 | - vscroll: (origin: int, offset: int) |
25 | - lines: list of str |
26 | - num_read: int |
27 | - at_end: bool |
28 | |
29 | buflist (singleton) |
30 | - vscroll: int |
31 | - width: int |
32 | - selection: buf |
33 | - cursor: buf |
34 | - last: buf |
35 | |
36 | prompt (singleton) |
37 | - chars: list of str |
38 | - cursor: int |
39 | - hscroll: int |
40 | |
41 | flags (singleton) |
42 | - refresh |
43 | - redraw |
44 | - buflist_draw |
45 | - buf_draw |
46 | - prompt_draw |
47 | - status_draw |
48 | - quit |
49 | - buflist |
50 | - prompt |
51 | - ping_draw |
52 | |
53 | ring |
54 | - start: int |
55 | - list: list |
56 | |
57 | Enumerations |
58 | ============ |
59 | |
60 | kbd_state: ks_start ks_cx ks_esc ks_cseq ks_cs_intermed |
61 | |
62 | Variant types |
63 | ============= |
64 | |
65 | message: (args all str unless noted) |
66 | - m_privmsg(sender, msg) |
67 | - m_notice(sender, msg) |
68 | - m_join(sender, chan) |
69 | - m_part(sender, chan, msg) |
70 | - m_quit(sender, msg) |
71 | - m_nick(sender, nick) |
72 | - m_kick(sender, chan, name, msg) |
73 | - m_kicked(sender, chan, msg) |
74 | - m_topic(sender, topic: str | None) |
75 | - m_chantopic(sender, chan, topic: str | None) |
76 | - m_mode(sender, modes) |
77 | - m_chanmode(sender, chan, modes) |
78 | - m_names(sender, chan, names) |
79 | - m_endnames(sender, chan) |
80 | - m_error(sender, msg) |
81 | - m_client(msg) |
82 | - m_server(sender, msg) |
83 | |
84 | Quasiconstants |
85 | ============== |
86 | |
87 | self_pipe_rd: int |
88 | self_pipe_wr: int |
89 | commands: (name: str) => function |
90 | slashcommands: list of str |
91 | |
92 | Global state |
93 | ============ |
94 | |
95 | cur_buf: buf |
96 | scr_height: int |
97 | scr_width: int |
98 | mono_last: float |
99 | mono_offset: float |
100 | out_buf: bytearray |
101 | kbd_accum: bytearray |
102 | kbd_state: function |
103 | history_pos: int | None |
104 | history_stash: str | None |
105 | kill_pos: int | None |
106 | yank_start_pos: int | None |
107 | yank_end_pos: int | None |
108 | |
109 | Collections |
110 | =========== |
111 | |
112 | buffers: non-empty list of buf |
113 | buffer_index: (name: str, parent_name: str) => buf |
114 | opening_conns: (fileno: int) => conn |
115 | open_conns: (fileno: int) => conn |
116 | network_conns: (network: str) => conn : all enabled networks, whether TCP alive or not |
117 | schedule: min-heap of (time: float) => thunk |
118 | history_ring: ring of str |
119 | kill_ring: ring of str |
120 | |
121 | Functions |
122 | ========= |
123 | |
124 | Excluding record constructors, accessors and basic mutators. |
125 | |
126 | Startup only: |
127 | command(name: str, min_args=0: int, max_args=None: int | None, extended_arg=False: bool)(function) -> function |
128 | check_command_dicts(keymap) |
129 | make_casemapper(int) -> function of (str -> casemapped str) |
130 | |
131 | Boring: |
132 | set_nonblock |
133 | |
134 | Pure functions: |
135 | format_time(time_tuple) -> str |
136 | is_ctrl(chr) -> bool |
137 | ctrl(chr) -> chr |
138 | is_meta(chr) -> bool |
139 | meta(chr) -> chr |
140 | variant_name(val) -> str |
141 | variant_args(val) -> list |
142 | matcher(vtype, cases: iterable of (constructor, receiver: function of (*args -> x))) -> function of (val: vtype -> x) |
143 | sequence(*thunks) -> thunk |
144 | partition(list, pred) -> (left: list, right: list) |
145 | split_pair(str, sep=' ': str) -> [str, str] |
146 | make_encoder(function of chr -> str) -> function of (str -> str) |
147 | asciify(str) -> str |
148 | fs_encode(str) -> str |
149 | casemap_ascii(str) -> str |
150 | clip(min: comparable, max: comparable, comparable) -> comparable |
151 | clip_to(list, int) -> int |
152 | get_clipped(list, int) -> element of list |
153 | clip_str(str, width: int) -> str |
154 | pad_or_clip_str(str, width: int, pad=' ': chr) -> str |
155 | wrap(line, width, indent=0) -> list of str |
156 | is_digit(chr) -> bool |
157 | is_alpha(chr) -> bool |
158 | parse_address(addr) -> (host: str, port: int) / ValueError |
159 | format_address((host: str, port: int)) -> str |
160 | rfind_word_start(chars: str | list of char, start_cursor: int) -> int |
161 | find_word_end(chars: str | list of char, start_cursor: int) -> int |
162 | rfind_prefix_start(chars: str | list of char, start_cursor: int) -> int |
163 | common_prefix(sequence, sequence) -> sequence |
164 | int_of_bytes(str) -> int |
165 | bit_length(int) -> int |
166 | heap_peek(heap: list) -> (key, value) / IndexError |
167 | safe_filename(name) -> bool |
168 | config_lines(text) -> non-empty list of non-empty str | None |
169 | format_buf_msg(val: message) -> str |
170 | buf_width() -> int |
171 | buf_height() -> int |
172 | render_line(str) -> list of str |
173 | buf_max_vscroll(buf) -> (int, int) |
174 | add_scroll_coords(lines: list of str, coords: (int, int), delta: int) -> (int, int) |
175 | sub_scroll_coords(lines: list of str, coords: (int, int), delta: int) -> (int, int) |
176 | render_lines(lines: list of str, vscroll: (int, int), row_limit: int) -> (list, int) |
177 | is_nick_start(chr) -> bool |
178 | is_nick_body(chr) -> bool |
179 | build_msg(prefix, cmd, params) -> str |
180 | max_param_len(cmd, prefix=None) -> int |
181 | parse_msg(msg) -> (prefix: str | None, cmd: str, params: list of str) / ProtocolError |
182 | is_chan(str) -> bool |
183 | valid_chan(str) -> bool |
184 | valid_nick(str) -> bool |
185 | valid_password(str) -> bool |
186 | conn_nick_lc(conn) -> casemapped str |
187 | sender_nick(str) -> str |
188 | arg2 |
189 | arg3 |
190 | empty2 |
191 | lterr / TypeError |
192 | format_log_msg(val: message except (m_chantopic | m_mode | m_client)) -> str |
193 | ring_index(ring, int) -> int |
194 | ring_get(ring of t, int) -> t | None |
195 | |
196 | Pure I/O: |
197 | write_all(blocking fd, str|bytearray) / EnvironmentError |
198 | read_all(nonblocking fd) -> str / EOFError, EnvironmentError : may return empty |
199 | |
200 | Pure drawing: |
201 | buf_draw(buf) |
202 | prompt_draw |
203 | draw_status(y: int) |
204 | buflist_draw |
205 | buflist_vline_draw |
206 | place_cursor |
207 | refresh_if_needed |
208 | |
209 | "Queries": |
210 | find_buf(buf) -> int : find buf's index in buffers list |
211 | #buf_network(buf) -> str |
212 | buf_conn(buf) -> conn / CommandError |
213 | buf_registered_conn(buf) -> conn / CommandError |
214 | get_config(key, paths=(()), default=None) -> str | default |
215 | |
216 | Side effects on data: |
217 | write_out(str) : stores for write to terminal |
218 | flush_out : sends full terminal output buffer |
219 | variant(vtype, name: str, nargs: int) -> constructor: function of (*args -> (tag, args)) |
220 | insert_multi(list, index: int, values: iterable) : inserts values into list at index |
221 | rand_int(int) -> int |
222 | heap_insert(heap: list, key: comparable, value) |
223 | heap_extract(heap: list) -> (key, value) / IndexError |
224 | run_command(line: str) -> * / CommandError |
225 | buf_log_msg(buf, m: message) |
226 | buf_privmsg(buf, msg: str) : buf_parent ; buf_registered_conn ; conn_privmsg / CommandError |
227 | check_buf_at_end : buf_set_at_end(cur_buf) | buf_clr_at_end(cur_buf) |
228 | is_child_of(buf) -> function of (buf -> bool) |
229 | sort_buffers : sorts buffers & generates buffer_index |
230 | get_buf(name, parent_name) -> buf : buffer_index lookup but creates if not found |
231 | close_buf(buf) |
232 | exit_yank |
233 | prompt_insert(chr) |
234 | prompt_submit |
235 | prompt_end |
236 | history_prev |
237 | history_next |
238 | prompt_backspace |
239 | prompt_delete |
240 | prompt_complete |
241 | kill_range(int, int) |
242 | yank |
243 | yank_next |
244 | info(msg: str, buf=None) : buf_log_msg to buf or buffers[0] |
245 | error(msg_or_exc: str | Exception, buf=None) : buf_log_msg to buf or buffers[0] |
246 | kaccum(str) |
247 | kaccept(str) |
248 | ktrans(kbd_state) |
249 | ks_start(chr) |
250 | ks_cx(chr) |
251 | ks_esc(chr) |
252 | ks_cseq(chr) |
253 | ks_cs_intermed(chr) |
254 | conn_run_in(conn, seconds: float, method: function of (conn), run_if_down=False) : run_in |
255 | conn_log_msg(conn, venue: casemapped str | None, m: message) : get_buf ; buf_log_msg ; file_log_msg |
256 | conn_info(conn, str) : uses conn_log_msg |
257 | conn_error(conn, str) : uses conn_log_msg |
258 | conn_start(conn) : starts connecting; bumps count; rotates addrs; adds to opening_conns and network_conns |
259 | conn_write(conn, str) : stores for nonblocking write by main loop |
260 | conn_send(conn, cmd: str, params: list of str, prefix=None: str) : build_msg ;conn_write (TODO check msg well-formedness) |
261 | conn_handle_connected(conn) : if successful, moves c from opening_conns to open_conns & sends login |
262 | conn_close(conn) : shuts down and removes from open_conns |
263 | conn_handle_data(conn, data: str) : does input buffering; extracts messages and calls... |
264 | conn_handle_msg(conn, msg: str) : mega-function for handling IRC commands |
265 | conn_join(conn, chan: str, key=None) : conn_info ; conn_send |
266 | conn_privmsg(conn, target: str, msg: str) : conn_log_msg ; conn_send |
267 | conn_ping(conn) |
268 | conn_timeout(conn) |
269 | conn_reg_timeout(conn) |
270 | file_log_msg(network: file-safe str, venue: casemapped str | None, m: message) |
271 | handle_resize |
272 | mono_time -> float |
273 | run_in(seconds, thunk) |
274 | ring_set(ring of t, int, t) |
275 | ring_rotate(ring, int) |
276 | ring_append(ring of t, t) |
277 | |
278 | Slash commands: |
279 | quit_cmd |
280 | connect_cmd |
281 | disconnect_cmd |
282 | join_cmd |
283 | kick_cmd |
284 | mode_cmd |
285 | nick_cmd |
286 | part_cmd |
287 | send_cmd |
288 | |
289 | Lifecycle: |
290 | main |
291 | crash_handler |
292 | |
293 | MVP: |
294 | finish commands |
295 | close/close-net debug |
296 | prefix case sensitivity in conn_handle_msg? |
297 | |
298 | TODO: |
299 | nick fallback |
300 | buflist vscroll |
301 | modes |
302 | date changes |
303 | prompt history, kill ring |
304 | tab completion (but how to focus buf/prompt?) |
305 | username, realname |
306 | logging |
307 | bold nicks (generally: formatted wrap) |
308 | search in scrollback |
309 | channel key (config, persist across reconnect) |
310 | buffer cleanup by category |
311 | help |
312 | scripting |
313 | self-ping to find user@host to calc max privmsg length |
314 | Proliferation of casemapping is bound to be buggy. |
315 | Recognize WHOIS/WHOWAS/LIST responses |
316 | bracketed paste |
317 | |
318 | Possible cleanups: |
319 | more use of lambda/sequence for trivial functions |
320 | rename buf* to wind* to match manual's terminology (nobody but emacs uses "buffer" to mean "window"...) |
321 | move cur_buf global to a buflist attribute |
322 | use the new scheduler for schedule_*; use delayed redraw to perform well under message floods |