|
| 1 | + |
| 2 | + |
| 3 | +<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! --> |
| 4 | + |
| 5 | +The quick brown fox jumps over the lazy dog. Jackdaws love my big sphinx |
| 6 | +of quartz. Pack my box with five dozen liquor jugs. How vexingly quick |
| 7 | +daft zebras jump! The five boxing wizards jump quickly. Sphinx of black |
| 8 | +quartz, judge my vow. Two driven jocks help fax my big quiz. Bright |
| 9 | +vixens jump; dozy fowl quack. |
| 10 | + |
| 11 | +``` python |
| 12 | +msg = await read_msg() |
| 13 | +id_ = msg.id |
| 14 | +cts = msg.content |
| 15 | +``` |
| 16 | + |
| 17 | +------------------------------------------------------------------------ |
| 18 | + |
| 19 | +<a |
| 20 | +href="https://github.com/AnswerDotAI/dialoghelper/blob/main/dialoghelper/exhash.py#L12" |
| 21 | +target="_blank" style="float:right; font-size:smaller">source</a> |
| 22 | + |
| 23 | +### lnhashview_msg |
| 24 | + |
| 25 | +``` python |
| 26 | +async def lnhashview_msg( |
| 27 | + id:str, # id of message to view |
| 28 | + dname:str='', # Dialog containing message; defaults to current dialog |
| 29 | + start_line:int=None, # Starting line (1-based) to view (defaults to 1st line if None) |
| 30 | + end_line:int=None, # End line (defaults to last line if None) |
| 31 | +)->str: |
| 32 | +``` |
| 33 | + |
| 34 | +*Show lnhash-addressed lines of a message* |
| 35 | + |
| 36 | +``` python |
| 37 | +await lnhashview_msg(id_, end_line=4) |
| 38 | +``` |
| 39 | + |
| 40 | + 1|da2a|The quick brown fox jumps over the lazy dog. |
| 41 | + 2|32e4|Jackdaws love my big sphinx of quartz. |
| 42 | + 3|04e4|Pack my box with five dozen liquor jugs. |
| 43 | + 4|025f|How vexingly quick daft zebras jump! |
| 44 | + |
| 45 | +------------------------------------------------------------------------ |
| 46 | + |
| 47 | +<a |
| 48 | +href="https://github.com/AnswerDotAI/dialoghelper/blob/main/dialoghelper/exhash.py#L25" |
| 49 | +target="_blank" style="float:right; font-size:smaller">source</a> |
| 50 | + |
| 51 | +### msg_exhash |
| 52 | + |
| 53 | +``` python |
| 54 | +async def msg_exhash( |
| 55 | + id:str, # id of message to edit |
| 56 | + cmds:list, # List of exhash command tuples to apply |
| 57 | + dname:str='', # Dialog containing message; defaults to current dialog |
| 58 | +)->str: |
| 59 | +``` |
| 60 | + |
| 61 | +*Verified line-addressed editor. Apply command tuples to msg `id` |
| 62 | +contents, return lnhash diff.* **NB**: every command is a tuple whose |
| 63 | +first element is an address string. **NB**: hashes are checked against |
| 64 | +the current text immediately before each command runs; order commands |
| 65 | +last-\>first. |
| 66 | + |
| 67 | +Use `lnhashview_msg(id)` to get hash-verified addresses before first |
| 68 | +use. |
| 69 | + |
| 70 | +Address strings: Single: `12|a3f2|` Range: `12|a3f2|,15|b1c3|` Last: `$` |
| 71 | +(last line) Whole: `%` (whole file, same as `1,$`) Special: `0|0000|` |
| 72 | +targets before line 1 (only with a or i) |
| 73 | + |
| 74 | +Command tuples: (addr, “s”, pattern, replacement\[, flags\]) Substitute |
| 75 | +(Rust regex syntax). Replacement supports $1, $0, ${name}. Flags: g=all, |
| 76 | +i=case-insensitive. args may contain literal / & newlines (addr, “d”) |
| 77 | +Delete line(s) (addr, “a”, text) Append payload after line (addr, “i”, |
| 78 | +text) Insert payload before line (addr, “c”, text) Change/replace with |
| 79 | +payload (addr, “j”) Join with next line; with range, joins all (addr, |
| 80 | +“m”, dest) Move line(s) after dest address (addr, “t”, dest) Copy |
| 81 | +line(s) after dest address (addr, “\>”, n) Indent n levels (default 1, 4 |
| 82 | +spaces each) (addr, “\<”, n) Dedent n levels (default 1) (addr, “sort”) |
| 83 | +Sort lines alphabetically (addr, “p”) Print (include in output without |
| 84 | +changing) (addr, “g”, payload), (addr, “g!”, payload), (addr, “v”, |
| 85 | +payload) Global commands; payload uses compact ex syntax such as |
| 86 | +`/pattern/d` (addr, “y”, payload) Transliterate; payload uses compact ex |
| 87 | +syntax such as `/abc/ABC/` |
| 88 | + |
| 89 | +`cmds` is a required list of command tuples. Text fields may contain |
| 90 | +newlines, including multiline a/i/c payloads and s pattern/replacement |
| 91 | +fields; payloads are inserted literally. Do NOT add a trailing `.` line |
| 92 | +— the string boundary ends the block. A trailing `.` will be inserted |
| 93 | +literally (with a warning). |
0 commit comments