Skip to content

Instantly share code, notes, and snippets.

@kaz-utashiro
Last active June 4, 2023 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaz-utashiro/f36da47151a4a583961bed7847122c96 to your computer and use it in GitHub Desktop.
Save kaz-utashiro/f36da47151a4a583961bed7847122c96 to your computer and use it in GitHub Desktop.
sl.c 2023 version
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <term.h>
void mvprintw(int y, int x, const char* fmt, const char* str) {
tputs(tparm(tgoto(cursor_address, x, y)), 1, putchar);
printf(fmt, str);
}
char *sl[] = {
" o o o o",
" o ",
" o ┯━━┯ ",
" ╒╕ │OO│ ",
" ┌─┘└──┘ │ ",
"┌┘ │ ",
"┴─O=O O=O─┴ з\n"
};
int main() {
setupterm(NULL, STDOUT_FILENO, NULL);
int COLS = tigetnum("cols"), LINES = tigetnum("lines");
int len = strlen(sl[0]), height = sizeof(sl)/sizeof(sl[0]);
int start_x = COLS - len, start_y = LINES - height - 1;
char dch2[20] = "", *dch2p = tparm(tigetstr("dch"), 2);
if (dch2p != NULL)
strcpy(dch2, dch2p);
char smoke[1024]; strcpy(smoke, sl[0]); sl[0] = smoke;
for (int x = start_x/2*2; x >= 0; x -= 2) {
for (int y = 0; y < height; y++) {
mvprintw(start_y + y, 0, "%s", dch2);
mvprintw(start_y + y, x, "%s", sl[y]);
}
fflush(stdout);
strcat(smoke, " o");
usleep(100000);
}
}
@kaz-utashiro
Copy link
Author

kaz-utashiro commented May 29, 2023

ChatGPT に alternate screen を使わないように書き直してもらった。

cc -o sl sl.c -lcurses

sl

@kaz-utashiro
Copy link
Author

kaz-utashiro commented Jun 1, 2023

罫線を使うようにしてみた。
sl

@kaz-utashiro
Copy link
Author

kaz-utashiro commented Jun 3, 2023

さくらのクラウドシェルでスライドインしてみた。

sl-2023.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment