Projects : yrc : yrc_input_history

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