scripts: generate-alt-random-writes: add support for bold/italic/underline

This commit is contained in:
Daniel Eklöf 2020-11-16 20:02:53 +01:00
parent 60c8637231
commit b437013a3b
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -27,6 +27,9 @@ def main():
parser.add_argument('--colors-rgb', action='store_true') parser.add_argument('--colors-rgb', action='store_true')
parser.add_argument('--scroll', action='store_true') parser.add_argument('--scroll', action='store_true')
parser.add_argument('--scroll-region', action='store_true') parser.add_argument('--scroll-region', action='store_true')
parser.add_argument('--attr-bold', action='store_true')
parser.add_argument('--attr-italic', action='store_true')
parser.add_argument('--attr-underline', action='store_true')
opts = parser.parse_args() opts = parser.parse_args()
out = opts.out if opts.out is not None else sys.stdout out = opts.out if opts.out is not None else sys.stdout
@ -121,6 +124,13 @@ def main():
# New-style (sub-parameter based) # New-style (sub-parameter based)
out.write(f'\033[{base}:2::{rgb[0]}:{rgb[1]}:{rgb[2]}m') out.write(f'\033[{base}:2::{rgb[0]}:{rgb[1]}:{rgb[2]}m')
if opts.attr_bold and rand.read(1)[0] % 5 == 0:
out.write('\033[1m')
if opts.attr_italic and rand.read(1)[0] % 5 == 0:
out.write('\033[3m')
if opts.attr_underline and rand.read(1)[0] % 5 == 0:
out.write('\033[4m')
out.write(c * repeat) out.write(c * repeat)
do_sgr_reset = rand.read(1)[0] % 2 do_sgr_reset = rand.read(1)[0] % 2