Re: Need Pr gram to add > marks to text
JJ <[email protected]>
| Newsgroups | alt.comp.freeware |
|---|---|
| Organization | To protect and to server |
| Message-ID | <[email protected]> |
On Sat, 15 Jun 2024 15:33:38 -0500, [email protected] wrote: > I want to be able to copy/paste a text file and have the program place > a > (Greater-than-sign) quote mark before each line of text. > > I must also be able to control line length. > > My Message Cleaner program will not work on my Windows 7 machine. It > does this function fine on my XP comp. > > Yes, I know that my newsreader does this job automatically on a Reply. Since I'm an Autohotkey user, I'd make my own script for it. Below Autohotkey v1 script does it. It provides 2 keyboard shortcuts. CTRL+SHIFT+C: generate CTRL+C keyboard shortcut to copy selection into clipboard, then changes the clipboard content, then generate CTRL+V to paste the clipboard. CTRL+SHIFT+D: same as above except it doesn't generate any keyboard shortcut. It will simply use the current clipboard data and change it, even if it's already changed. This is for adding multiple levels of quoting mark. For example, if the clipboard initially contains unquoted text e.g. This is a sample text. The first time CTRL+SHIFT+D is pressed, it changes the clipboard to: > This is a sample text. The second time CTRL+SHIFT+D is pressed, it changes the clipboard to: > > This is a sample text. And so on... Use it with CTRL+C before one or more CTRL+SHIFT+D, then CTRL+V. The `regexchars` and `maxlinelen` variables near the start of code should be changed as needed. [code] ;for Autohotkey v1 only. ;characters which can be followed by a line cutting point: ; whitespace, `;`, `,`, `)`, `]`, `}` regexchars:= "\s|[;,)\]}]" maxlinelen:= 70 mll:= maxlinelen - 2 ;maxlinelen including `> ` prefix return ^+c:: send ^c gosub process send ^v return ^+d:: gosub process return process: ;do nothing if clipboard doesn't contain any text if ((txt:= clipboard) = "") return lf:= instr(txt, "`r`n") ? "`r`n" : "`n" if (substr(txt, 1 - strlen(lf)) = lf) txt:= substr(txt, 1, -2) lines:= strsplit(txt, lf) txt:= "" for i, line in lines { while (true) { l:= strlen(line) - 2 if (l > mll) { l:= mll while (l) { c:= substr(line, l, 1) if (regexmatch(c, regexchars)) { break } l-- } ;if line cutting point is not found, use line length minus 2 if (l = 0) l:= mll txt.= "> " substr(line, 1, l) "`r`n" line:= ltrim(substr(line, l + 1)) } else { txt.= "> " line "`r`n" break } } } clipboard:= txt return [/code]