Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[newbie question] How does editorRefreshScreen work? #32

Closed
bjorxi opened this issue Jul 17, 2016 · 3 comments
Closed

[newbie question] How does editorRefreshScreen work? #32

bjorxi opened this issue Jul 17, 2016 · 3 comments

Comments

@bjorxi
Copy link

bjorxi commented Jul 17, 2016

Hi. Awesome project!
I always wanted to learn, how does textminal/text magic work, and this code is fantastic. But I can't understand the editorRefreshScreen function. How doest it render text and doesn't just append it to terminal? What is the idea behind it?

Can someone give me a hint?

@skx
Copy link

skx commented Jul 17, 2016

As you say the routine builds up a big long string, then prints it to the console.

The magic comes from the escape codes, which are interpreted by your terminal.

As a simple example run these two commands:

 $ echo -e "\e[31mHello \e[32mWorld\e[0m"
 $ echo -e "\e[1;31;42m Yes it is awful \e[0mback to normal"

For the rest you'll need to consult this list - but if you work through what kilo is doing it's pretty good:

  • resets the cursor to 0,0
  • draws each line.
    • Setting colour where appropriate.
  • draws the cursor.

@bjorxi
Copy link
Author

bjorxi commented Jul 17, 2016

Thank you! Now it makes sense.

@skx
Copy link

skx commented Jul 18, 2016

Glad I could be useful!

Asking questions is good, but probably best to close this now you're clearer :)

@bjorxi bjorxi closed this as completed Jul 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants