Text Editor E01 - How to use ANSI Escape Codes & Call Native APIs with Java

preview_player
Показать описание
Have you ever wanted to know how text editors work? How shell scripts change terminal text colors, update lines without scrolling, or move the cursor around?
Surprise, surprise, even as Java Devs, we can do this! In this series, l'll walk you through building a terminal-based text editor with Java.
Part 1: How to use ANSI escape codes and native C text input libraries to do fancy text output with Java. Let’s get started!

► Source Repository

► Timestamps
00:00 Intro
00:54 Project Notes
01:14 ANSI Escape Codes
06:04 Terminal Raw Mode
07:30 Setting Terminal Attributes With The Termios API
20:39 Building The Text Viewer Skeleton
24:58 Getting Terminal Rows & Columns With The IOCTL API
27:39 Bugfixing: Flickering & Cursor Positioning
28:51 Teaser
29:15 The End

► Acknowledgements

A BIG thank you goes out to:

► FOLLOW ME

Рекомендации по теме
Комментарии
Автор

Please continue with that series! It's great.

fmueller
Автор

It's actually so useful that you instruct on how could the viewer find things themselves! Thank you for the series!

amirshelli
Автор

What I really like about this video (I don't yet know your others) is your dense presentation of information.

tmsngr
Автор

Thank you so much!!!
I wanted to code something like an editor and I didn't know where to start from.
Your code guided me until the first half of your second video and now I got enough to continue with my development.
I'm making a kind of REST call maker (like postman) in console and I wanted this to be user interactive.
I'm glad to have met you.

aixo
Автор

oh my god, this is awesome! This is an awesome way to actually learn a whole bunch of new stuff

KolosBros
Автор

Thank you for the shout-out!

Cheers from an enterprise programmer ;-)

JanWillemKeizer
Автор

Hey Marco Huge fan, Please make more of these tutorial video. Really helps to break mundane task from work. Thank you so much. You are awesome programmer

ShivaniSingh-sfmv
Автор

Great video, thank you for the content!

tiziano
Автор

Record a problem I encountered in case others will too:
cc_t c_cc[NCCS]
The length of c_cc is different in different operating system!

The length is 20 in MacOS and 32 in Linux

If someone encounter `free(): invalid pointer` when executing, change the length of c_cc can fix

Mr-domenic
Автор

Pls make a video on complete spring batch

udhayasankar
Автор

Hi Marco, great tutorial! Just curious how your 'java' command is compiling and running Viewer.java?

jeffreymiller
Автор

Thanks. Very informative video. Is posible compile this project using graalvm/native-image and still work?

SLTRM
Автор

Great stuff man.
Can we call ncurse lib with jna? or is it a different thing from termios?

mmatteii
Автор

There was a problem calling tcgetattr is printed and i get return value as -1, how do i go about debugging it?

hue.huehuehue
Автор

Casually has a book called Shit! in the background :) Nice video, good explanation. Subscribed!

warnerjanveldhuis
Автор

I am working on a macbook pro with M1 processor. I cannot get the jna to work. Does somebody know how to get it to work?

Tom_van_Gorkom
Автор

Did anyone get this to work with MacOS (Intel, not M1)? I have watched the addendum in Part 03, but it still does not work. No error message, but the terminal just won't go into "raw" mode. It's a shame, seems like an interesting project, but this bit-fiddling is not for me. 🙈

cdhagen
Автор

Hi, is there some way how to run it on windows?

TomasZubrietovsky
Автор

After executing the command <$ java -cp jna-5.13.0.jar Viewer.java> the first @15:20, I do not get the values as you are, instead I get something like "free(): invalid pointer
Aborted" ---> I have the exact same code as you until that point, what is going on there? A little help please :)

**edit
It works now. I updated my jdk (OpenJDk 11 to 18) after seeing comment of @Carlos below.

mkhadka
Автор

Native.load() returned value 255. Can you tell me why?

ASHWINNAMBIARM