Блог пользователя kiwii

Автор kiwii, 5 лет назад, По-английски

Hello! Today I'm going to show you how to debug with colors in your lovely console ( ^◡^)
I'm sowwy if my engwish is bad (⁄ ⁄>⁄ω⁄<⁄ ⁄)⁄

First Step: wet's see huw it wurksss (*ゝω・)ノ 🍎🍌🍀📘

Okay, so first things first, our terminal has it's own way to interpret color. It basically will escape a certain kind of stuffs and it will interpret it as color for the next stream.

Pwease see this code: 💖💖

Code UωU

2nd Step: wet's make a cwass!

If we wunt to use itt.. Let's make it really easy for us to use!

ColorDebugger Class UωU

Pay attention that I defined endl as \n because we 💗 codeforces. Just kidding, that's because std::endl is a weird stuff that can't be defined with simple generics, and it's really weird, endl is more like a function (it's not but just take it for granted). Next, we got this implementation without defining endl as \n.

ColorDebugger Class Finish UωU

Step 三

Let's see this in action:

Input is in the color dark and output is blue

Beside windows, linux terminal has the same syntax, I awso have twied it.

Pwoof

Don't be confused with bashfast and compileCPP it's basically an alias I've made to access my WSL (Windows Subsystem fow Winux) and to compile C++ code.

ありがとう~! 🐾

I use light mode because it's cwuteeee UωU~~!! 🐾 🐾

  • Проголосовать: нравится
  • +232
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +34 Проголосовать: не нравится

N-nice tutowial UωU

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +129 Проголосовать: не нравится

Downvoted because of light theme

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +66 Проголосовать: не нравится

Light mode UωU 💖💕💓💘💞💝

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +32 Проголосовать: не нравится

UωU

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

UwU <3

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

(/ =ω=)/ kawaii

Really useful! I'll probably spend the next decade playing with all the different colours.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится -15 Проголосовать: не нравится

send me the compensation, my eyes are bleeding cuz you showed me the light theme without any warning.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +45 Проголосовать: не нравится

uwu twice if you need help

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Cool trick UwU

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

It's so pretty uwu

uwu

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Offtopic:

How you all are inserting emojis? When I try to copy paste the same and preview, it says:

Comment preview error:


Emoji (and other unusual UTF-8 characters) are not supported
»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What if I want to do the same on Window?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

colorblinds : 😑

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

I would also suggest a simpler trick, though it is less powerful (you cannot decide to print one thing red and the other thing blue, but it works if you want to separate input and output). You can make an alias x="./a.out | lolcat" and run your code with x; you will have rainbow output.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

So useful. Those colors will help me debug faster

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

This stackoverflow answer might also be useful to people: https://stackoverflow.com/questions/287871/how-to-print-colored-text-to-the-terminal

In particular the python library rich really shows off what you can do with this stuff.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

sir what does "uwu" and all the chinese/japanase letter mean?????