PySnooper icon indicating copy to clipboard operation
PySnooper copied to clipboard

Feature request: Add output coloring, option to disable

Open cool-RR opened this issue 5 years ago • 15 comments

cool-RR avatar Apr 21 '19 11:04 cool-RR

Hey, i'd like to work on this one,any good advice for me?

LeetaoGoooo avatar Apr 24 '19 00:04 LeetaoGoooo

Great!

I think this isn't too tricky, just find the color characters for the shell, and use different colors for different parts of the output. If there's anything I'd want to correct about your pull request, I'll tell you.

On Wed, Apr 24, 2019 at 3:48 AM leetao [email protected] wrote:

Hey, i'd like to work on this one,any good advice for me?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cool-RR/PySnooper/issues/1#issuecomment-486025311, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAN3SXKTQ5PALRLJGKATT3PR6U6JANCNFSM4HHLPUJA .

cool-RR avatar Apr 24 '19 07:04 cool-RR

I hava already fix this one,you can see my last commit #1, but got no idea about how to test color. would you mind giving me some help,thx~

LeetaoGoooo avatar Apr 25 '19 07:04 LeetaoGoooo

Great, can you submit a pull request to this repo? I tried making sense of your code but couldn't separate your commits from mine on your repo.

cool-RR avatar Apr 25 '19 07:04 cool-RR

i made the pr~~O(∩_∩)O

LeetaoGoooo avatar Apr 25 '19 07:04 LeetaoGoooo

This PR is up for grabs again. It's a good one, I hope someone takes it.

cool-RR avatar Apr 27 '19 07:04 cool-RR

I'll give it a shot.

Mark-Jung avatar Apr 28 '19 22:04 Mark-Jung

What about doing this with pycolorama? @Mark-Jung lemme know if you want help, definitely looking forward to this PR.

AtHeartEngineer avatar May 02 '19 21:05 AtHeartEngineer

I haven't looked into this yet, but I will asap. Have been swamped with work this week.

Mark-Jung avatar May 02 '19 21:05 Mark-Jung

Before jumping into a PR with colorama you should be aware that there is a reluctance here to use any dependencies, see #48 and #68

alexmojaki avatar May 03 '19 06:05 alexmojaki

@AtHeartEngineer : Alex is correct, I prefer to avoid dependencies for this project.

cool-RR avatar May 03 '19 08:05 cool-RR

@AtHeartEngineer : Alex is correct, I prefer to avoid dependencies for this project.

Definitely understand that. It could be an optional dependency, if you want color. Just a thought, figured colorama did a lot of the cross-compatibility work.

AtHeartEngineer avatar May 07 '19 14:05 AtHeartEngineer

It could be an optional dependency, if you want color

I know @cool-RR is not interested in maintaining optional dependencies either, I tried that too in #71

I tried to make this project extensible in #103 so that another project could be built on top of it with extra features through dependencies, but that's been rejected. I'd already written some code using Pygments which added syntax highlighting in the terminal.

alexmojaki avatar May 10 '19 13:05 alexmojaki

Anyone reading this: This feature is up for grabs for anyone interested in implementing it.

cool-RR avatar Jun 10 '19 15:06 cool-RR

My version of PySnooper is out and it is colorful! I'd love to hear people's thoughts about the design and use of color here.

It seems that colorama is not needed for Windows support after all, which is good because it only supports a few colors anyway. Windows 10 has had support for ANSI codes in cmd for two years now, you just have to enable it: https://stackoverflow.com/a/36760881/2482744 That's what I'm doing. I don't know what happens in other terminals, I'm not a Windows user.

So PySnooper can still accomplish this without dependencies. If you want syntax highlighting, maybe check what https://github.com/Qix-/better-exceptions is doing for ideas.

alexmojaki avatar Jul 03 '19 13:07 alexmojaki

It would be great to have color coding under windows as well!

colorama supports windows, as I have just tested and confirmed, so implementing it in the same way would be possible :)

skjerns avatar Dec 07 '22 06:12 skjerns

Oh, I forgot to close this issue when i implemented this functionality. I'm closing it now.

@skjerns can you please open a separate issue for implementing this functionality on Windows? And link these two issues to each other.

if you'll be interested in working on it, then you should know two things: 1. I'll want it done with no dependencies, so if you use anything from Colorama, you'll have to copy-paste some code. And 2. If you'll be interested in implementing, I'll try to figure out what was the original reason I didn't implement on Windows.

Let me know.

cool-RR avatar Dec 07 '22 07:12 cool-RR