Projects : yrc : yrc_completion

yrc/codemap.txt

Dir - Raw

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