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

Add autoterminal #98

Merged
merged 43 commits into from
Jan 16, 2020
Merged

Add autoterminal #98

merged 43 commits into from
Jan 16, 2020

Conversation

basxto
Copy link
Member

@basxto basxto commented Jan 10, 2020

It’s not finished yet.
A PTY and multithreading is used now.
Terminal capabilities get communicated via a custom terminfo file.

  • The makefile needs some improvement since I’m currently linking all modules against libutil and pthread.

Broken:

  • ncurses looks shifted
    KILL ME!
  • lolcat doesn’t end

Also do:

  • clean up code
  • outsource the writing logic for cyriax

Copy link
Member

@vifino vifino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small review:

  • use oscore (src/oscore.h) insted of pthread directly
  • fix code formatting, make CI compile this successfully

Code looks good, now that it allocates a PTY and does threading, it's really nice! :)

src/modules/gfx_autoterminal.c Outdated Show resolved Hide resolved
src/modules/gfx_autoterminal.c Show resolved Hide resolved
@basxto
Copy link
Member Author

basxto commented Jan 11, 2020

* make CI compile this successfully

build.sr.ht needs to have ncurse installed, otherwise it can’t compile the terminfo file with tic

Codecy is just rediculous.

@basxto
Copy link
Member Author

basxto commented Jan 11, 2020

Apparently parse_sgr_value breaks for default values.
But htop looks a bit weird on that terminal

Edit: htop expects bold black to be gray hishamhm/htop#35

@basxto
Copy link
Member Author

basxto commented Jan 11, 2020

  • Evaluate how to support ANSI graphics (ponysay, doge)

Copy link
Member

@vifino vifino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good now!
Just a few nitpicks.

src/modules/gfx_autoterminal.c Show resolved Hide resolved
active_shell = 1;
type_index++;
type_pos = 0;
oscore_task_create("shell", launch, type_buffer[type_index - 1]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should store the thread handle and join it when it is done, otherwise you'll be leaking memory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oscore_event_* is not suitable, I don’t wanna block draw. I need some polling.
I always draw the buffer and I only want to do the autotyping if no child process is running.

@vifino
Copy link
Member

vifino commented Jan 11, 2020

* make CI compile this successfully

build.sr.ht needs to have ncurse installed, otherwise it can’t compile the terminfo file with tic

You can add ncurses to packages: in .builds/freebsd.yml. We should perhaps bundle a precompiled terminfo as to not require ncurses everywhere.

Travis complains differently... https://travis-ci.com/shinyblink/sled/jobs/274459240#L262

tic -o terminfo autoterminal.terminfo
"autoterminal.terminfo", line 12, col 34, terminal 'autoterminal': Illegal character - 'M-t'
"autoterminal.terminfo", line 12, col 34, terminal 'autoterminal': Entry does not start with terminal names in column one

Codecy is just rediculous.

shrug

@basxto
Copy link
Member Author

basxto commented Jan 11, 2020

tic also fails on Mac, make just does not notice.
And builds.sr.ht does not draw my terminal, where do I have to add it?

@vifino
Copy link
Member

vifino commented Jan 12, 2020

Can you prefix it? Having something global with clear_buffer etc.. is bound to cause trouble.

@basxto
Copy link
Member Author

basxto commented Jan 12, 2020

I postfixed it for whatever reason, I think I’ll go with:

#include "printbuffer.h"
printbuffer_init_default();
printbuffer_write_default("foo", 12, 42);//just writes to the buffer
// write understands \n and \r, but \r will jump to column 0
printbuffer_draw_default();//draws whole buffer
printbuffer_deinit();

EDIT: I renamed it

@basxto
Copy link
Member Author

basxto commented Jan 13, 2020

Altchars 🙌

while true; do echo " "; sleep 1; done | myman


asciiquarium is nearly flawless now, I do have some general drawing issues with the last column and line

htop looks a lot better now, but some text is still hidden and I have no idea what weird stuff it’s doing there.

@basxto
Copy link
Member Author

basxto commented Jan 13, 2020

  • Add UTF-8 detection: Show one unprintable character instead of up to 4

Also translate some characters with altcode equivalents
@basxto
Copy link
Member Author

basxto commented Jan 13, 2020

pipes.sh -t 2 uses unicode instead of altchars, but I understand that too.

@basxto
Copy link
Member Author

basxto commented Jan 13, 2020

Ponysay works now too 😁

EDIT: and doge

@vifino
Copy link
Member

vifino commented Jan 13, 2020

That is incredible!

@basxto
Copy link
Member Author

basxto commented Jan 13, 2020

TERM=xterm-256color tmux

@basxto
Copy link
Member Author

basxto commented Jan 14, 2020

It’s pretty much finnished now. I think it could be merged as soon as I support multiple scripts.
Stuff that’s left to do: (Don’t consider them very high priority)

  • Allow multiple scripts and randomly load one on reset
  • Look into tic errors on builds.sr.ht
  • Find out why asciiquarium sometimes draws characters on the wrong side
  • Find out why htop shows no text (TERM=xterm-256color htop works more or less)
  • Check whether I can link only autoterminal against libutil
  • Punch Codacy

@basxto
Copy link
Member Author

basxto commented Jan 14, 2020

  • kill child process on deinit

@basxto
Copy link
Member Author

basxto commented Jan 15, 2020

htop is finally working!

@basxto
Copy link
Member Author

basxto commented Jan 15, 2020

I added a little utility script that sends /next to fish after some specified time.
Things like ./next 10 & while true; do echo " "; sleep 1; done | myman are now possible.
timeout sadly does not work with piping.

EDIT: Since htop does not fit on the screen, it can also make use of this.

./next 30 & while true; do sleep 5; echo '^'; sleep 5; echo '$'; done | htop

@vifino vifino merged commit 0963a2d into shinyblink:master Jan 16, 2020
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

Successfully merging this pull request may close these issues.

2 participants