Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using inv() before or after println() makes a difference #57

Open
ghjwp7 opened this issue Jan 11, 2022 · 0 comments
Open

Using inv() before or after println() makes a difference #57

ghjwp7 opened this issue Jan 11, 2022 · 0 comments

Comments

@ghjwp7
Copy link

ghjwp7 commented Jan 11, 2022

This may be a feature or a quirk, rather than a bug, but perhaps could be noted in the docs. Also, while the code below that demonstrates the issue only illustrates it with inv(), perhaps it's applicable to any ANSI color setting strings.

The observed behavior (on an Ubuntu 20.04, Linux 5.4.0 system) is that if say Crayon(background = :green) has been in effect, and an inv() for it is printed after a println() instead of before, then there's a green background for the tail of the upcoming line (which I didn't expect).

#!/usr/bin/env julia
# -*- mode: julia; coding: utf-8 -*-
# Tues 11 Jan 2022 - j-waldby
module testcrayoninv
using Crayons
green = Crayon(background = :green)
blue  = Crayon(background = :blue)

function plines(nlines, befor, flu)
    perline, lex, c = 1:5, 4, 'a'
    println("\nbefor is ", befor, "    flu is ", flu)
    for l in 1:nlines
        print("Line ", l)
        if l%4<1  print(green)       end
        if l%5<1  print(blue)        end
        for p in perline
            lex = (lex+5)%9
            c = c<'z' ? c+1 : 'a'
            print("  ", join([c for i in 1:lex]))
        end
        if befor
            if l%4<1  print(inv(green))  end
            if l%5<1  print(inv(blue))   end
            if flu    flush(stdout)      end
        end

        println()  # Print the inv's before or after this println()

        if !befor
            if l%4<1  print(inv(green))  end
            if l%5<1  print(inv(blue))   end
            if flu    flush(stdout)      end
        end
    end
end
plines(11, false, true)
plines(11, false, false)
plines(11, true,  false)
plines(11, true,  true)
end # module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant