diff options
author | Benji Dial <benji6283@gmail.com> | 2021-01-24 12:00:11 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-01-24 12:00:11 -0500 |
commit | bce944d1498eaa3b6940ee234c863b3548a66b37 (patch) | |
tree | ea40c087ab4f0f236aee8d158cf68550f5209f72 /tools/man-gen.py | |
parent | ca731aa747214919df7b3dfe3478dbe787ce5b68 (diff) | |
download | portland-os-bce944d1498eaa3b6940ee234c863b3548a66b37.tar.gz |
graphics!
Diffstat (limited to 'tools/man-gen.py')
-rw-r--r-- | tools/man-gen.py | 135 |
1 files changed, 0 insertions, 135 deletions
diff --git a/tools/man-gen.py b/tools/man-gen.py deleted file mode 100644 index 30ade8a..0000000 --- a/tools/man-gen.py +++ /dev/null @@ -1,135 +0,0 @@ -from sys import argv - -infn, outfn = argv[1:] - -inf = open(infn, 'r') - -title = infn[infn.rfind('/')+1:infn.rfind('.')] -lines = [] -links = [] - -coutl = bytes(0) -cllen = 0 -cword = '' -ccol = 0x0f - -def word_end(): - global cword, cllen, coutl - - if cword == '': - return - - if cllen + len(cword) > 80: - line_end() - - cllen += len(cword) - coutl += bytes(cword, 'ascii') - cword = '' - - if cllen == 80: - line_end() - -def line_end(): - global lines, cllen, coutl, ccol - - if len(lines) == 0 and cllen == 0: - return - coutl += bytes([0x20] * (80 - cllen)) - - lines.append(coutl) - coutl = bytes(0) - cllen = 0 - if ccol != 0x0f: - coutl += bytes([ccol | 0x80]) - -while True: - ch = inf.read(1) - if ch == '': - word_end() - line_end() - break - - elif ch == '\\': - word_end() - - cmd = '' - while ch != '{': - cmd += ch - ch = inf.read(1) - cmd = cmd[1:] - - content = '' - while ch != '}': - content += ch - ch = inf.read(1) - content = content[1:] - - if cmd == 'title': - title = content - elif cmd == 'link': - lto = content - cpos = content.rfind(':') - if cpos != -1: - lto = content[cpos+1:] - content = content[:cpos] - links.append((len(lines), cllen, len(content), lto)) - coutl += bytes([0x89]) - cword = content - word_end() - coutl += bytes([0x8f]) - elif cmd == 'color': - ncol = int(content, base=16) - if ccol != ncol: - ccol = ncol - coutl += bytes([ccol | 0x80]) - - elif ch == ' ': - word_end() - if cllen != 0: - coutl += bytes([0x20]) - cllen += 1 - - elif ch == '\n': - word_end() - line_end() - - else: - cword += ch - -inf.close() - -def dword(n): - return bytes([n % 256, (n // 256) % 256, (n // 65536) % 256, n // 16777216]) - -outf = open(outfn, 'wb') - -outf.write(dword(len(title))) -outf.write(bytes(title, 'ascii')) -outf.write(bytes([0])) - -outf.write(dword(len(links))) - -ltable = bytes(0) -for link in links: - line, scol, tlen, fpto = link - - ltable += dword(line) - ltable += bytes([scol, tlen]) - ltable += dword(len(fpto)) - ltable += bytes(fpto, 'ascii') - ltable += bytes([0]) - -outf.write(dword(len(ltable))) -outf.write(ltable) - -outf.write(dword(len(lines))) - -off = 4 + len(title) + 1 + 4 + 4 + len(ltable) + 4 + len(lines) * 4 -for line in lines: - outf.write(dword(off)) - off += len(line) - -for line in lines: - outf.write(line) - -outf.close()
\ No newline at end of file |