Projects : yrc : yrc_reindent_docs
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 | |
91 | Global state |
92 | ============ |
93 | |
94 | cur_buf: buf |
95 | scr_height: int |
96 | scr_width: int |
97 | mono_last: float |
98 | mono_offset: float |
99 | out_buf: bytearray |
100 | kbd_accum: bytearray |
101 | kbd_state: function |
102 | history_pos: int | None |
103 | history_stash: str | None |
104 | kill_pos: int | None |
105 | yank_start_pos: int | None |
106 | yank_end_pos: int | None |
107 | |
108 | Collections |
109 | =========== |
110 | |
111 | buffers: non-empty list of buf |
112 | buffer_index: (name: str, parent_name: str) => buf |
113 | opening_conns: (fileno: int) => conn |
114 | open_conns: (fileno: int) => conn |
115 | network_conns: (network: str) => conn : all enabled networks, whether TCP alive or not |
116 | schedule: min-heap of (time: float) => thunk |
117 | history_ring: ring of str |
118 | kill_ring: ring of str |
119 | |
120 | Functions |
121 | ========= |
122 | |
123 | Excluding record constructors, accessors and basic mutators. |
124 | |
125 | Startup only: |
126 | command(name: str, min_args=0: int, max_args=None: int | None, extended_arg=False: bool)(function) -> function |
127 | check_command_dicts(keymap) |
128 | make_casemapper(int) -> function of (str -> casemapped str) |
129 | |
130 | Boring: |
131 | set_nonblock |
132 | |
133 | Pure functions: |
134 | format_time(time_tuple) -> str |
135 | is_ctrl(chr) -> bool |
136 | ctrl(chr) -> chr |
137 | is_meta(chr) -> bool |
138 | meta(chr) -> chr |
139 | variant_name(val) -> str |
140 | variant_args(val) -> list |
141 | matcher(vtype, cases: iterable of (constructor, receiver: function of (*args -> x))) -> function of (val: vtype -> x) |
142 | sequence(*thunks) -> thunk |
143 | char_range(pair) -> str |
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 | int_of_bytes(str) -> int |
163 | bit_length(int) -> int |
164 | heap_peek(heap: list) -> (key, value) / IndexError |
165 | safe_filename(name) -> bool |
166 | config_lines(text) -> non-empty list of non-empty str | None |
167 | format_buf_msg(val: message) -> str |
168 | buf_width() -> int |
169 | buf_height() -> int |
170 | render_line(str) -> list of str |
171 | buf_max_vscroll(buf) -> (int, int) |
172 | add_scroll_coords(lines: list of str, coords: (int, int), delta: int) -> (int, int) |
173 | sub_scroll_coords(lines: list of str, coords: (int, int), delta: int) -> (int, int) |
174 | render_lines(lines: list of str, vscroll: (int, int), row_limit: int) -> (list, int) |
175 | build_msg(prefix, cmd, params) -> str |
176 | max_param_len(cmd, prefix=None) -> int |
177 | parse_msg(msg) -> (prefix: str | None, cmd: str, params: list of str) / ProtocolError |
178 | is_chan(str) -> bool |
179 | valid_chan(str) -> bool |
180 | valid_nick(str) -> bool |
181 | valid_password(str) -> bool |
182 | conn_nick_lc(conn) -> casemapped str |
183 | sender_nick(str) -> str |
184 | arg2 |
185 | arg3 |
186 | empty2 |
187 | lterr / TypeError |
188 | format_log_msg(val: message except (m_chantopic | m_mode | m_client)) -> str |
189 | ring_index(ring, int) -> int |
190 | ring_get(ring of t, int) -> t | None |
191 | |
192 | Pure I/O: |
193 | write_all(blocking fd, str|bytearray) / EnvironmentError |
194 | read_all(nonblocking fd) -> str / EOFError, EnvironmentError : may return empty |
195 | |
196 | Pure drawing: |
197 | buf_draw(buf) |
198 | prompt_draw |
199 | draw_status(y: int) |
200 | buflist_draw |
201 | buflist_vline_draw |
202 | place_cursor |
203 | refresh_if_needed |
204 | |
205 | "Queries": |
206 | find_buf(buf) -> int : find buf's index in buffers list |
207 | #buf_network(buf) -> str |
208 | buf_conn(buf) -> conn / CommandError |
209 | buf_registered_conn(buf) -> conn / CommandError |
210 | get_config(key, paths=(()), default=None) -> str | default |
211 | |
212 | Side effects on data: |
213 | write_out(str) : stores for write to terminal |
214 | flush_out : sends full terminal output buffer |
215 | variant(vtype, name: str, nargs: int) -> constructor: function of (*args -> (tag, args)) |
216 | rand_int(int) -> int |
217 | heap_insert(heap: list, key: comparable, value) |
218 | heap_extract(heap: list) -> (key, value) / IndexError |
219 | run_command(line: str) -> * / CommandError |
220 | buf_log_msg(buf, m: message) |
221 | buf_privmsg(buf, msg: str) : buf_parent ; buf_registered_conn ; conn_privmsg / CommandError |
222 | check_buf_at_end : buf_set_at_end(cur_buf) | buf_clr_at_end(cur_buf) |
223 | is_child_of(buf) -> function of (buf -> bool) |
224 | sort_buffers : sorts buffers & generates buffer_index |
225 | get_buf(name, parent_name) -> buf : buffer_index lookup but creates if not found |
226 | close_buf(buf) |
227 | exit_yank |
228 | prompt_insert(chr) |
229 | prompt_submit |
230 | prompt_end |
231 | history_prev |
232 | history_next |
233 | prompt_backspace |
234 | prompt_delete |
235 | kill_range(int, int) |
236 | yank |
237 | yank_next |
238 | info(msg: str, buf=None) : buf_log_msg to buf or buffers[0] |
239 | error(msg_or_exc: str | Exception, buf=None) : buf_log_msg to buf or buffers[0] |
240 | kaccum(str) |
241 | kaccept(str) |
242 | ktrans(kbd_state) |
243 | ks_start(chr) |
244 | ks_cx(chr) |
245 | ks_esc(chr) |
246 | ks_cseq(chr) |
247 | ks_cs_intermed(chr) |
248 | conn_run_in(conn, seconds: float, method: function of (conn), run_if_down=False) : run_in |
249 | conn_log_msg(conn, venue: casemapped str | None, m: message) : get_buf ; buf_log_msg ; file_log_msg |
250 | conn_info(conn, str) : uses conn_log_msg |
251 | conn_error(conn, str) : uses conn_log_msg |
252 | conn_start(conn) : starts connecting; bumps count; rotates addrs; adds to opening_conns and network_conns |
253 | conn_write(conn, str) : stores for nonblocking write by main loop |
254 | conn_send(conn, cmd: str, params: list of str, prefix=None: str) : build_msg ;conn_write (TODO check msg well-formedness) |
255 | conn_handle_connected(conn) : if successful, moves c from opening_conns to open_conns & sends login |
256 | conn_close(conn) : shuts down and removes from open_conns |
257 | conn_handle_data(conn, data: str) : does input buffering; extracts messages and calls... |
258 | conn_handle_msg(conn, msg: str) : mega-function for handling IRC commands |
259 | conn_join(conn, chan: str, key=None) : conn_info ; conn_send |
260 | conn_privmsg(conn, target: str, msg: str) : conn_log_msg ; conn_send |
261 | conn_ping(conn) |
262 | conn_timeout(conn) |
263 | conn_reg_timeout(conn) |
264 | file_log_msg(network: file-safe str, venue: casemapped str | None, m: message) |
265 | handle_resize |
266 | mono_time -> float |
267 | run_in(seconds, thunk) |
268 | ring_set(ring of t, int, t) |
269 | ring_rotate(ring, int) |
270 | ring_append(ring of t, t) |
271 | |
272 | Slash commands: |
273 | quit_cmd |
274 | connect_cmd |
275 | disconnect_cmd |
276 | join_cmd |
277 | kick_cmd |
278 | mode_cmd |
279 | nick_cmd |
280 | part_cmd |
281 | send_cmd |
282 | |
283 | Lifecycle: |
284 | main |
285 | crash_handler |
286 | |
287 | MVP: |
288 | finish commands |
289 | close/close-net debug |
290 | prefix case sensitivity in conn_handle_msg? |
291 | |
292 | TODO: |
293 | nick fallback |
294 | buflist vscroll |
295 | modes |
296 | date changes |
297 | prompt history, kill ring |
298 | tab completion (but how to focus buf/prompt?) |
299 | username, realname |
300 | logging |
301 | bold nicks (generally: formatted wrap) |
302 | search in scrollback |
303 | channel key (config, persist across reconnect) |
304 | buffer cleanup by category |
305 | help |
306 | scripting |
307 | self-ping to find user@host to calc max privmsg length |
308 | Proliferation of casemapping is bound to be buggy. |
309 | Recognize WHOIS/WHOWAS/LIST responses |
310 | bracketed paste |
311 | |
312 | Possible cleanups: |
313 | more use of lambda/sequence for trivial functions |
314 | rename buf* to wind* to match manual's terminology (nobody but emacs uses "buffer" to mean "window"...) |
315 | move cur_buf global to a buflist attribute |
316 | use the new scheduler for schedule_*; use delayed redraw to perform well under message floods |