I used to program exclusively in C. Now I program primarily in C++. Your videos make me wax nostalgic about my past. I miss the purity and simplicity of C! Great videos.
Back in the day (late 1970s) I knew most of the VT52 and VT100 escape codes off by heart when I wrote a 'visual' text editor for use on our PDP-11 terminals. Better than using TECO and later EDT for writing code anyway.
Awesome , I've been coding in C for a couple of years now and I still learn something new whenever I visit your channel. Keep up the good work. Stay safe.
@@JacobSorber Yeah I'd definitely love to see this. I've been working on a microservice architecture and one issue I'm dealing with is implementing CQRS for updating views. And that requires an event-driven model. I thought about using gRPC for that but I'd like to know all other options
I was recently making some terminal related lerning libraries and moving the cursor using ansi was something I was overcomplicating. This video really helped me understanding ansi better.
I started to research this after i saw the output of docker build, tought it was so cool, like how do i get this into my program ?! I knew it wasnt curses, glad to see its fairly simple. Great video, thanks !
While i was watching this video ,i noticed that most of icons in RUclips page changed from almost 1 minute ago. well, that's weird. Also love your videos man , i like people who respect C :D
really cool! how does the format know you meant \033 and not null terminator ('\0') followed by 33 without spaces? great video as usual, I'm always learnning new things.
Thanks. Octal escape sequences have 1-3 digits (octits), and the sequence ends when you either run into a non digit or you finish with 3 digits. So, "\0003" would be NULL character followed by '3' and \03 would be the character with value 3.
Hey jacob, really really love your stuff. Can you make a video on strings in general in c? I have a hard time with strings and would really like a video on string manipulation
Indeed. For the record, when you hit the backspace key on a terminal operating in canonical mode, the terminal driver echoes "\b \b", meaning: move back one cell, overwrite with a space, move back again.
Jacob, Nice videos to watch and to learn c from a profession. May I ask for a reqest. Maybe one step behind mulity threading, MPI (message pasing interface, executing parallel programs on different computers. I'm interested in how to use it in practice. Thanks Ben
Can you link some ANSI control sequence documentation? Whenever I need to use them, I end up using some random site that has like three to four escape sequences, which is really annoying. Is there a reference with an exhaustive list of all the standard ones?
The xterm documentation is one of the de facto standards for terminal escape sequences; you can search for "xterm sequences" and you'll find it, granted it's lengthy and technical. It's also worth mentioning that not all terminals support all sequences, and that's why the terminfo library (that ncurses uses) exists. You can use it to see if the terminal supports a sequence and if not, then you can avoid using it. (terminals can really get upset when they receive broken or unknown escape sequences) Aaand I'll also allow myself to shill Notcurses. It's an awesome terminal graphics library, more powerful and modern than ncurses is.
Just wanna point out that in real world you have to use some synchronization mechanism (mutexes / atomic variables) while updating and reading progress, otherwise it's data race, so undefined behaviour
Well, it of cource depends on the architecture, for example not synchronizing it on x86 is *probably* ok, you won't see half-updated int. But you should always pay attention to this kind of details.
Why do people say avoid using sleep functions? I can't ever seem to find a good answer or alternative. I imagine it isn't that big of a deal with modern computing
First off, you always want to be careful with this sort of advice. Such a broad recommendation is bound to be wrong at least some of the time. That said, there are a bunch of different reasons someone might say that. In embedded systems, we avoid *some* sleep functions (like __delay_cycles on the MSP430s) because they can keep the CPU active and may not properly utilize low power modes. Others do, and...so, no worries. Depending on what you're trying to do, sleep functions are often a bit clunky. They are often uninterpretable. They aren't guaranteed to wait for the amount of time you asked them to. So, you often have more efficient and responsive ways to wait for things - like condition variables, mutexes, timers, events, etc. For the example in this video, I didn't really care about any of that. I just didn't want to be constantly burning CPU cycles.
@@JacobSorber i think on arduino, using the delay functions it doesn't work well with some timing libs (for alarms, timeouts and intervals) and maybe another thing is that you can not use it on interrupts.
cmd and powershell do not support ANSI natively afaik, but Windows Terminal does, or you can use the colorama library to polyfill it (colorama.init() sets up your terminal to use ANSI, and the library also contains some shortcuts)
@@Starwort I'm pretty sure I used colorama.init in CMD and there are some escape sequences that don't work even though they are on the Microsoft developer website
Really like your channel. Would like to see your thoughts on a build system, if you are interested in looking it is called "qo" and it is on github from andlabs/qo . Thanks and keep up the good work :)
I used to program exclusively in C. Now I program primarily in C++. Your videos make me wax nostalgic about my past. I miss the purity and simplicity of C! Great videos.
C seems pure because it is so much more simple, I am sure your C++ code is pure also.
I was always in doubt about how it was done, but I had never really researched it. What a nice video to watch, thank you
Glad you enjoyed it!
Back in the day (late 1970s) I knew most of the VT52 and VT100 escape codes off by heart when I wrote a 'visual' text editor for use on our PDP-11 terminals. Better than using TECO and later EDT for writing code anyway.
Damn dude, you're a fantastic software engineer.
Awesome , I've been coding in C for a couple of years now and I still learn something new whenever I visit your channel.
Keep up the good work.
Stay safe.
Thanks! Hopefully, we'll keep learning new things together.
mind doing a video on event-driven model?
I would love to see this as well!
Yeah, it's been on my list for a while. For some reason, some ideas take more fiddling than others. It'll show up one of these weeks.
@@JacobSorber Yeah I'd definitely love to see this. I've been working on a microservice architecture and one issue I'm dealing with is implementing CQRS for updating views. And that requires an event-driven model. I thought about using gRPC for that but I'd like to know all other options
This was one of your most excellent videos ever! Progress bars have been making me feel lacking for years! haha. Thank you!
You're welcome!
I love C, and your videos about it.
Thanks. Glad you're enjoying them.
I was recently making some terminal related lerning libraries and moving the cursor using ansi was something I was overcomplicating. This video really helped me understanding ansi better.
I had a lot of problems understanding ESC characters but you made it all clear to me. Thanks!!
I really like your tutorials. They cover C, and how people can use it well.
I started to research this after i saw the output of docker build, tought it was so cool, like how do i get this into my program ?! I knew it wasnt curses, glad to see its fairly simple. Great video, thanks !
Can you do a video about #pragma once vs. header guards?
Thanks a lot! couldn't find a better explanation anywhere else than in your video! 👍
You're welcome! Glad it helped.
A video about namespaces would be great to see!
Please make more videos like this one
This was *exactly* what I was searching for :o really ty :D
Welcome. Glad I could help.
While i was watching this video ,i noticed that most of icons in RUclips page changed from almost 1 minute ago.
well, that's weird.
Also love your videos man , i like people who respect C :D
Thanks. Not sure what was happening with the icons, but I'm glad you're enjoying the videos.
really cool!
how does the format know you meant \033 and not null terminator ('\0') followed by 33 without spaces?
great video as usual, I'm always learnning new things.
Thanks. Octal escape sequences have 1-3 digits (octits), and the sequence ends when you either run into a non digit or you finish with 3 digits. So, "\0003" would be NULL character followed by '3' and \03 would be the character with value 3.
@@JacobSorber what if u used hex instead of octal
Hey jacob, really really love your stuff. Can you make a video on strings in general in c? I have a hard time with strings and would really like a video on string manipulation
Yeah, probably. Are there specific things about strings that are messing you up?
Can't you just use '\b' for backspace?
Good point. Yes, you can. I was just looking through the CSI docs and so I ended up using that one.
Indeed. For the record, when you hit the backspace key on a terminal operating in canonical mode, the terminal driver echoes "\b \b", meaning: move back one cell, overwrite with a space, move back again.
Jacob,
Nice videos to watch and to learn c from a profession. May I ask for a reqest. Maybe one step behind mulity threading, MPI (message pasing interface, executing parallel programs on different computers. I'm interested in how to use it in practice. Thanks Ben
An MPI tutorial could be fun. I'll see what I can do. Thanks.
Love your videos! How about making a selection menu?
Yeah, we could do that. I'll add it to the list.
Hi ,jacob can you explain fcntl- (fille control in unix ) record locking features in Unix
I'll add it to the list, and see what I can do in a future video. Thanks.
@@JacobSorber thank you jacob awesome.
Is this supposed to work on a windows terminal as well? or just unix?
can u make a video recommending other Yt channels that produce C content
So you are saying I can make ASCII games for a terminal without using windows.h? Excellent, right when I needed it.
Why not use "\e" for the ESC character?
the arrowhead overwrites the initial [ too
Why you didnt need to use mutexes? isnt It unsafe to access progress from diferent threads?
None of the threads are writing to the same memory location, so there is no conflict.
Can you link some ANSI control sequence documentation? Whenever I need to use them, I end up using some random site that has like three to four escape sequences, which is really annoying. Is there a reference with an exhaustive list of all the standard ones?
I typically use the wikipedia page (en.wikipedia.org/wiki/ANSI_escape_code). It also has links to more official docs down at the bottom.
The xterm documentation is one of the de facto standards for terminal escape sequences; you can search for "xterm sequences" and you'll find it, granted it's lengthy and technical.
It's also worth mentioning that not all terminals support all sequences, and that's why the terminfo library (that ncurses uses) exists. You can use it to see if the terminal supports a sequence and if not, then you can avoid using it. (terminals can really get upset when they receive broken or unknown escape sequences)
Aaand I'll also allow myself to shill Notcurses. It's an awesome terminal graphics library, more powerful and modern than ncurses is.
can you help to understand by example of old fashion terminal dashboard with dynamically updating values?. i.e gpsd do
Just wanna point out that in real world you have to use some synchronization mechanism (mutexes / atomic variables) while updating and reading progress, otherwise it's data race, so undefined behaviour
Well, it of cource depends on the architecture, for example not synchronizing it on x86 is *probably* ok, you won't see half-updated int. But you should always pay attention to this kind of details.
Why do people say avoid using sleep functions? I can't ever seem to find a good answer or alternative. I imagine it isn't that big of a deal with modern computing
First off, you always want to be careful with this sort of advice. Such a broad recommendation is bound to be wrong at least some of the time. That said, there are a bunch of different reasons someone might say that. In embedded systems, we avoid *some* sleep functions (like __delay_cycles on the MSP430s) because they can keep the CPU active and may not properly utilize low power modes. Others do, and...so, no worries. Depending on what you're trying to do, sleep functions are often a bit clunky. They are often uninterpretable. They aren't guaranteed to wait for the amount of time you asked them to. So, you often have more efficient and responsive ways to wait for things - like condition variables, mutexes, timers, events, etc. For the example in this video, I didn't really care about any of that. I just didn't want to be constantly burning CPU cycles.
@@JacobSorber well now I got some investigation to do! Thanks for the info!
@@JacobSorber i think on arduino, using the delay functions it doesn't work well with some timing libs (for alarms, timeouts and intervals) and maybe another thing is that you can not use it on interrupts.
Now I know what all the cryptic stuff in my shell prompt variable (PS1) means and why they give me different colors and text formats, thanks!
ESC CSI NUMTHREADS PREVIOUSLINE
Does it work in windows? I tried these escape sequences in CMD (but in python) and \033[5F doesn't appear to work. I used \033[5A
instead.
cmd and powershell do not support ANSI natively afaik, but Windows Terminal does, or you can use the colorama library to polyfill it (colorama.init() sets up your terminal to use ANSI, and the library also contains some shortcuts)
@@Starwort I'm pretty sure I used colorama.init in CMD and there are some escape sequences that don't work even though they are on the Microsoft developer website
@@Victor_Marius weird; were you using the colorama tools or ANSI escapes directly? If the latter, you may have messed up the parameters to init?
multiple progress in the bars terminal?
😘
Really like your channel. Would like to see your thoughts on a build system, if you are interested in looking it is called "qo" and it is on github from andlabs/qo . Thanks and keep up the good work :)
Thanks, Joe. I'll take a look.