Hi Gregg, thanks for your info. I think about minimalism the same way as you do. Just, for future videos, it would be great, if the virtual terminal would be much bigger. Currently it is about a 9th of the video screen.
Neat. Awesome. Good vid. Totally agree with statements regarding independence and familiarity with the tools and language one would use to develop, and the terminal is inescapable (even in Windoze afic). The varied examples and use case scenarios are brilliant, common concerns and illustrated concisely; fantastic work!
Hi!, great content. Super inspiring for noobie C programmers like myself. I would love to understand more about bitops/masks and its uses. Thanks! One observation: I reckon the '1' parameter for SGR is bold and '0' is for normal :)
Why not zoom into your terminal? You have so much space left on the sides and the top and the bottom of the screen. Why not increase the font size too?
@@GreggInkCodesyou can zoom the terminal but also 80% of your screen space is used up by useless, unchanging, low-content desktop background. Us coding-junkies like to view these type of videos all day long and that means also on our phones and then dream about them in our sleep. All we care about is the text part, because from that we can render the rest in our dream-canvas.
The following link might help ( wiki.bash-hackers.org/scripting/terminalcodes) Note, don't trust anything until you have tested it for yourself. The VT100 is an obsolete terminal which was historically influential and that's why it is mentioned in the link.
Please is there any documentation on cursor code just like the color code which is documented in terminal-colors.d 5, i will be grateful if you can help me out thank you
Yes, there is. ( man7.org/linux/man-pages/man4/console_codes.4.html ) I played around with it a bit to test, it's working. e.g. write(1, "\033[30G", 5 ); will move cursor to column 30 of current row.
I want to build a function to get keycode from keyboard like getkeycode(uint64_t *c) .How I can build it by using your tc.h header files. I don't know how to cancel your thread in tc_init_input function. Please help me. Many Thanks !!!
I am a bit confused by your question. This comment is under the first video in the series which doesn't deal with keyboard input. If you want to deal with keyboard input yourself, get tc.h from the gitlab project which belongs to this video (gitlab.com/greggink/youtube_episode_control_terminal/). The second video in this series explains how I deal with keyboard input (th-cam.com/video/31p6xsjqehM/w-d-xo.html). This has its own gitlab project (gitlab.com/greggink/youtube_episode_terminal_control_2/) and this is where you find tc_init_input. How to cancel the thread in tc_init_input ? Well, I don't know why you would want to do that but if you do, just comment the line beginning with pthread_create(... Unless, I am misunderstanding your question. Hope this helps.
Nice video, it makes me want to code a vim wannabe lol. 4 years ago, me and a couple o friends started a a shell, but it didnt last much. Maybe in another video you could start one as well.
Also when you use a library (in any lang/framework) you lose control of your project recursively, because you don't control what other libraries that library calls, and what other-other libraries the other libraries call, and so on... Which is where we are today, with exponentially more computers made of expontentially better hardware, connected by exponentialialy faster networks, but still the user experience is slower than it was 20 years ago :(
At the moment, I'm trying to learn this stuff myself. I've used ncurses but it does not quite suite my needs and I'd like to see if I can do it myself. I've been looking into some of the APIs you have been using. You have given a lot of great tips. I had no idea the ANSI escape sequences could save and restore the terminal state. Well a video on ANSI escape sequences would be awesome :) or give a link to any resources you have used, thanks.
It has been a while so I don't remember exactly what I used as resources. I had a quick look through my bookmarks. Of course, not all bookmarks turn out to be equally useful in the end. Anyways, here they are: 1) invisible-island.net/xterm/ctlseqs/ctlseqs.html 2) wiki.bash-hackers.org/scripting/terminalcodes 3) en.wikipedia.org/wiki/ANSI_escape_code
Hi Gregg, one question. Why does one have to subtract 12 to the column value? I can see in my own program, that it's the only way to fit the text in the exact middle. I just would like to understand why. Thanks!
To get the text in the center, you need the empty space on either side to be the same. The empty space is the full width of the screen - the width of the text. Divide the difference by 2 to get equal space on either side. The length of the string in this case is 12. You could use a strlen() to make the solution more general. Of course, what makes this works is the monospace font and the fact that the width of every character matches a column.
Good topic, I was trying to watch it on my phone but the emulator (1/4 screen size) was not opened to full screen. So I will have to watch it at home later.
I really appreciate this video. I came across it trying to find out how to understand the gobbledegook that is, e.g., "\x1B[0;31m," as I came across similar formats to do a platform-agnostic screen clear. What does all of that represent? It reads to me like an escape sequence, but I'm not sure what exactly it's doing.
I just got the idea to do an exact match search for the string of characters and found that this relates to ANSI 6429--right? Finding this really helps me understand what's going on now.
The "\x1B[0;31m," is a control escape sequence. The "\x," means that whatever follows is a hexadecimal number. Then we have 1B in hex or 27 in base 10. This is the ASCII code for Escape, hence the whole thing being called an escape sequence. What follows after that is just a code to control what you want the terminal to do: change colour, clear screen, etc.
@@GreggInkCodes Thanks! Now I'm even more curious. Do you know the reason they drop the standard leading zero before the x in the hex? Is it for brevity or to be more universally agreeable with compilers and CLI's? Maybe some other reason? And that makes me also wonder what are we "escaping" from? Is it similar to a system() call to the CLI outside of the binary itself?
Functions produce a small amount of overhead as they require a new layer on the stack. Macros don't have that overhead and thus are more efficient. For very simple functions, I like to implement them as macros.
great video - thanks Gregg. This is the glue I was missing in my C studies....
Hi Gregg, thanks for your info. I think about minimalism the same way as you do. Just, for future videos, it would be great, if the virtual terminal would be much bigger. Currently it is about a 9th of the video screen.
Yeah, It has been pointed out to me. In later videos, I have it fullscreen.
Yes, do a full featured follow-up program! Would be awesome! 😎
Neat. Awesome. Good vid.
Totally agree with statements regarding independence and familiarity with the tools and language one would use to develop, and the terminal is inescapable (even in Windoze afic). The varied examples and use case scenarios are brilliant, common concerns and illustrated concisely; fantastic work!
Glad it helped.
@@GreggInkCodes Did more than help - it inspired. Seriously. Thank you!
that’s really cool. would love to see more
Really nice bro i really enjoyed. Keep up the good content!!! Greetings from Argentina!!
This is brilliant. Thanks.
Would love follow up to this. Great video!!
Hi!, great content. Super inspiring for noobie C programmers like myself. I would love to understand more about bitops/masks and its uses. Thanks!
One observation: I reckon the '1' parameter for SGR is bold and '0' is for normal :)
Thanks for the comment. I will consider making a video about that.
Great video and great presentation dude. Keep em coming.
Thanks, will do!
Why not zoom into your terminal?
You have so much space left on the sides and the top and the bottom of the screen.
Why not increase the font size too?
Ok, I will try to think of that for next time.
I tile em nowadays much nicer vybe / less eyestrain / get to flex my batman wallpaper
@@GreggInkCodesyou can zoom the terminal but also 80% of your screen space is used up by useless, unchanging, low-content desktop background. Us coding-junkies like to view these type of videos all day long and that means also on our phones and then dream about them in our sleep. All we care about is the text part, because from that we can render the rest in our dream-canvas.
Exactly what i needed! :)
You are welcome.
@@GreggInkCodes Does this also work on the BSD's?
@@mrpablodelosmarbles7966 Sorry, I have no experience with BSD.
Hi, excellent video. Where can I find a reference of the escape codes?
The following link might help ( wiki.bash-hackers.org/scripting/terminalcodes)
Note, don't trust anything until you have tested it for yourself. The VT100 is an obsolete terminal which was historically influential and that's why it is mentioned in the link.
@@GreggInkCodes by the way I also enjoyed the historical context.
😲 thx !
I tried it in Windows, discovered that there are some includes from the SYS directory which obviously Win doesn't have. But thank you for the lesson!
Very cool! Do you have any advice on listening for keyboard events in a C program? (on Linux/MacOS)
Nothing comes to mind immediately but this seems a good idea as a topic for a future video.
Sir, excellent video, but you could make the terminal fill the screen and make the font larger. Thank you.
Yeah, I realize that now but those were the early days of me making videos.
Please is there any documentation on cursor code just like the color code which is documented in terminal-colors.d 5, i will be grateful if you can help me out thank you
Yes, there is. ( man7.org/linux/man-pages/man4/console_codes.4.html )
I played around with it a bit to test, it's working.
e.g. write(1, "\033[30G", 5 ); will move cursor to column 30 of current row.
@@GreggInkCodes thanks bro, it good to know you
I want to build a function to get keycode from keyboard like getkeycode(uint64_t *c) .How I can build it by using your tc.h header files. I don't know how to cancel your thread in tc_init_input function. Please help me. Many Thanks !!!
I am a bit confused by your question. This comment is under the first video in the series which doesn't deal with keyboard input. If you want to deal with keyboard input yourself, get tc.h from the gitlab project which belongs to this video (gitlab.com/greggink/youtube_episode_control_terminal/).
The second video in this series explains how I deal with keyboard input (th-cam.com/video/31p6xsjqehM/w-d-xo.html). This has its own gitlab project (gitlab.com/greggink/youtube_episode_terminal_control_2/) and this is where you find tc_init_input. How to cancel the thread in tc_init_input ? Well, I don't know why you would want to do that but if you do, just comment the line beginning with pthread_create(... Unless, I am misunderstanding your question. Hope this helps.
Nice video, it makes me want to code a vim wannabe lol. 4 years ago, me and a couple o friends started a a shell, but it didnt last much. Maybe in another video you could start one as well.
bloat != progress
Also when you use a library (in any lang/framework) you lose control of your project recursively, because you don't control what other libraries that library calls, and what other-other libraries the other libraries call, and so on...
Which is where we are today, with exponentially more computers made of expontentially better hardware, connected by exponentialialy faster networks, but still the user experience is slower than it was 20 years ago :(
At the moment, I'm trying to learn this stuff myself. I've used ncurses but it does not quite suite my needs and I'd like to see if I can do it myself. I've been looking into some of the APIs you have been using. You have given a lot of great tips. I had no idea the ANSI escape sequences could save and restore the terminal state. Well a video on ANSI escape sequences would be awesome :) or give a link to any resources you have used, thanks.
It has been a while so I don't remember exactly what I used as resources. I had a quick look through my bookmarks. Of course, not all bookmarks turn out to be equally useful in the end. Anyways, here they are:
1) invisible-island.net/xterm/ctlseqs/ctlseqs.html
2) wiki.bash-hackers.org/scripting/terminalcodes
3) en.wikipedia.org/wiki/ANSI_escape_code
@@GreggInkCodes Thank you very much. The 1st link has far more comprehensible info than I've been able to find so far.
underrated content, plz continue if you can, why did you quite so?
19:09 if you want to do that in windows you need the termios.h header file and im not sure if this is even possible on dos/windows architecture
Include windows.h and u have the windows API console functions to use
Hi Gregg, one question. Why does one have to subtract 12 to the column value? I can see in my own program, that it's the only way to fit the text in the exact middle. I just would like to understand why. Thanks!
To get the text in the center, you need the empty space on either side to be the same. The empty space is the full width of the screen - the width of the text. Divide the difference by 2 to get equal space on either side. The length of the string in this case is 12. You could use a strlen() to make the solution more general. Of course, what makes this works is the monospace font and the fact that the width of every character matches a column.
@@GreggInkCodes awesome. cheers!
14:15 What's the magic number -12 for?
12 is the length of the string "Hello World!" It is needed to calculate where to display the string so it will be centered.
Good topic, I was trying to watch it on my phone but the emulator (1/4 screen size) was not opened to full screen. So I will have to watch it at home later.
Sorry about that. I am always on my laptop and never think about phones. I will have it fullscreen next time.
Can you do a video on just stdout, stdin, stderr?
Anything in particular you would like to know about that?
I really appreciate this video. I came across it trying to find out how to understand the gobbledegook that is, e.g., "\x1B[0;31m," as I came across similar formats to do a platform-agnostic screen clear. What does all of that represent? It reads to me like an escape sequence, but I'm not sure what exactly it's doing.
I just got the idea to do an exact match search for the string of characters and found that this relates to ANSI 6429--right? Finding this really helps me understand what's going on now.
The "\x1B[0;31m," is a control escape sequence. The "\x," means that whatever follows is a hexadecimal number. Then we have 1B in hex or 27 in base 10. This is the ASCII code for Escape, hence the whole thing being called an escape sequence. What follows after that is just a code to control what you want the terminal to do: change colour, clear screen, etc.
@@GreggInkCodes Thanks! Now I'm even more curious. Do you know the reason they drop the standard leading zero before the x in the hex? Is it for brevity or to be more universally agreeable with compilers and CLI's? Maybe some other reason?
And that makes me also wonder what are we "escaping" from? Is it similar to a system() call to the CLI outside of the binary itself?
5:35 why make tc_move_cursor a macro instead of a function?
Functions produce a small amount of overhead as they require a new layer on the stack. Macros don't have that overhead and thus are more efficient. For very simple functions, I like to implement them as macros.
5:35 why make tc_move_cursor a macro instead of a function?